Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932192AbbFDO1t (ORCPT ); Thu, 4 Jun 2015 10:27:49 -0400 Received: from mail-by2on0090.outbound.protection.outlook.com ([207.46.100.90]:61208 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932120AbbFDO1l (ORCPT ); Thu, 4 Jun 2015 10:27:41 -0400 Authentication-Results: spf=fail (sender IP is 66.35.236.227) smtp.mailfrom=opensource.altera.com; alien8.de; dkim=none (message not signed) header.d=none; Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tthayer@opensource.altera.com; From: To: , , , , , , , , , , CC: , , , , , , Subject: [PATCHv2 3/4] edac, altera: Addition of Arria10 EDAC Date: Thu, 4 Jun 2015 09:28:47 -0500 Message-ID: <1433428128-7292-4-git-send-email-tthayer@opensource.altera.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1433428128-7292-1-git-send-email-tthayer@opensource.altera.com> References: <1433428128-7292-1-git-send-email-tthayer@opensource.altera.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [64.129.157.38] X-ClientProxiedBy: SN1PR12CA0039.namprd12.prod.outlook.com (25.162.96.177) To BLUPR03MB423.namprd03.prod.outlook.com (10.141.78.150) X-Microsoft-Exchange-Diagnostics-untrusted: 1;BLUPR03MB423;2:xGnjtA4YH8znsKkDrOkO2Z6h3cbTipfuPNoiJ0nVB1bdYAh59UEVdx9BEsgCSTyM;2:wwU/iuv4e3fWn9fSmDyA97HpzLaHJO5Pk2GQ0AVi9oWbpke+7cQeZWNq8cRo7lCsaTrInBtHrLuqrwHXf2eBs561BEEBQCLX9amelhe3Fsl0+MiycobrpoTq2G0VtqJtDdeCneOGYqqJt2SlOWbKHA==;6:qzZ0FtcusLzMXEMfbX1dnCzvIv5vFYvf4E5Uj+uOW2BWJsH3azjoFvZWGoPlkVX+SrL893hEPaW2GAZi+XOTuG+GAl9OeTV+SmG8jhaVJXOlWfgQZ+ETf+Z3/3vwW9LNjVn8lV6lfund2z0kwOBE5Q==;3:apiiGPnbgxhnNoM6t4Mn+qAOhFSM7AOmKKjF9Fm7HYVrrT2FV/X83bqCN/Wb3e7kDZxoixB/0XduPC5NxWjhQzxnf75DQAlB5npHW91SYAph/wJNQ7ULEJoiLtuGA0gu3/XBqDiZjREOaHaF/K/b3iFxne9jeBa5tuBMmFnaQ6CC2Zg/A5qSvolcJP2cMnDnyq5ARcBlz4QfVy4pS8DCruZ3425VoJQka5c+kRMq/BlGODFf8XozJtMOrkG8akVDHgwfkrZaX0Lh0p1LrT0pq6QaxfSg+scLCbbylJf2LBIHOGCu66HWpFf5TEJXwO5n X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB423;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB128; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:;UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(520003)(5005006)(3002001);SRVR:BLUPR03MB423;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB423;BCL:0;PCL:0;RULEID:(601004)(520003)(5005006)(3002001);SRVR:BY2PR03MB128;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB128; X-Forefront-PRVS: 0597911EE1 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM;SFS:(10009020)(6069001)(6009001)(199003)(189002)(42186005)(101416001)(106356001)(50466002)(5001830100001)(64706001)(76176999)(47776003)(33646002)(81156007)(4001540100001)(92566002)(122386002)(48376002)(97736004)(5001770100001)(77156002)(62966003)(40100003)(19580395003)(68736005)(50226001)(229853001)(46102003)(86152002)(2201001)(2950100001)(66066001)(5001960100002)(189998001)(50986999)(107886002)(19580405001)(5001860100001)(105586002)(86362001)(575784001)(87976001)(77096005)(921003)(4001430100001)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR03MB423;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:0;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics-untrusted: =?us-ascii?Q?1;BLUPR03MB423;9:6hJdOwMom8BJN1YFWC1UNGi17USxNf28mOT/Cyu+ZUz?= =?us-ascii?Q?guJe/PEW4VfhCduYnxc07GIBmL7YiGdLkygRPed+IYQ0jXfe/Bspvb0zNxXD?= =?us-ascii?Q?vM5Q+1+vsa+4QM+c7Hv0qSWbrKQzJZ0EvlhyYzKe8MU97ausu8R5LIQI2FBh?= =?us-ascii?Q?0ncaQ2WVdjPaaWuvvBHvP3/ACmkRCiIcdvLlT/v3dY3K6bMJqWV6yd43euKx?= =?us-ascii?Q?LVZW0gUO/Dc7VUtqT0bSoiBM18EXBCotmzaw6aR7tR76HaTqAD1RL7zH9MJX?= =?us-ascii?Q?+uYrX7n2k61hQlwoTnnHKLdCSLnXSQpGmYqUSBnb2iJSeJh6kRIxYL3bWNjo?= =?us-ascii?Q?QGzR2A1M68de/dQTqqjAocbT44NTe3Nvhfn1bY556dud8x7xTr9cmQIzJ5FZ?= =?us-ascii?Q?sdndtTMWJnx1776gRBhWzkMBQw47rq7vCGYfyeBvS4BTSoboAL4oJ5GTaExp?= =?us-ascii?Q?eG8NOJUxugHgEZNCgeSn9/SqUtSDWuKrSp8PLN2CcPqjDmrEVw/gAPUV6god?= =?us-ascii?Q?tHu3fqYawRkZTUpGJJnFT1grxwLerHiTBa15G7jdok2alTkdF2wGz1OVgoMW?= =?us-ascii?Q?/htFjFxUKuDAdIgpl1/N6P2B45NtiycTQWP2zo854X3UH69ewiCJPtVA/TX8?= =?us-ascii?Q?gGJTLkXn2NZo5ydrCq41PDIL/vecWGNCG2TgIj3JQSz1UuZf+GzOkm1YuiGC?= =?us-ascii?Q?36N9jMjEeX+bhIxOBPkjn4LKBcmOYNnNvvtTzup5kU53M0olXSkItOMW23mu?= =?us-ascii?Q?w7VKL1kobfeSB0z+jcaA2RUxtGiih+SIw74h8Lm5WNdNB7QePLdhDZGfmcql?= =?us-ascii?Q?idLE8WQrk+GSzIBwsZaeR8CXytoF004LVdy/qoCeTnEBdxOWMdAngg/a6R55?= =?us-ascii?Q?dY6NAvE/9yqci6OlgIrnt1Ru5YwLIgBw4XqCukcSCtTxxyKd/USchj5FRGIS?= =?us-ascii?Q?NIYulNy3OcHioJDm52pGc6riRw9ADfMFL9zAwTGAz7q0HmGlAbK5jRSdbWZU?= =?us-ascii?Q?P5IBPr7Y+HIvwTCnFxneyuvfWgEmN9IpzIjZE93IqFnrqvLVfDbi7uBRfHqo?= =?us-ascii?Q?ExqQ/gmCaaSKTglSzc7VE0qAMSQwUAr1L7nIu8dBcXev3Ue8s/01S2GPtk9B?= =?us-ascii?Q?QrmKYk51nYAoedieg0dC/FjzQXA9cPw41OmYeJqgvlyr+YDqpTeyE8v+xsei?= =?us-ascii?Q?t0ZEY8tW5iYbra/ky5RCetcii8KU8Lgc4?= X-Microsoft-Exchange-Diagnostics-untrusted: 1;BLUPR03MB423;3:QR2xaHTgU7EJEFGcUUltgl33mQ6S8VROmhYXC14Erg6eHzwNloe9W8Sfhc3MYpqJSPcHYptAkw+OU+LqnH61S65I6P/QjqkDxktdB8D7tKIQbbhsF9VcL/WGhoHnX+0l1WKGRBah2g1QzF7FHUrvAw==;10:N1nAw3t0bDuD4eRgnubz5IARt1JFEhhuKSjaZbZVSDrjBNYNEUcHpkV1W5jFGRibHWshw0HpP69ljy9K2tL6HfQFHBoEpY7Ip38GywVRX1U=;6:3AJcEkd3R7zo2O3P5gvMFni9K4COPD9brwkPLHRGYo/qw5vMZcCh/KuVnl0uFASZcgHKJzvq5IQNLsOVSb/IgNa7dKY9VE7F+UayMBI6dtBNA6WbKvXEYADjUKrIoTVb5tLIJ6Bz++WehOWZ+0dMYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB423 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BN1BFFO11FD056.protection.gbl X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD056;1:Xp+1/ZfLKLe2FtEPaF/jicchU5DoEsY3Wn9LdEkODLuxQ4JexV25DaRDWDl0pjaPOHQt1szAQXj27eKXxibcmnt3Txvjz6rFwEMPDSDPeCKDBW7yhAfxgvYgrS0o/Tobpn0pRZcModoB5phYmHcPcwyW9zQJjSbQl+4RsO5/tpHZEVMwmjU2DDOEJu46BQi7ZSNPGfNFWQ6zI8T9J1Du77Zo3Dlvq4OJs6r0tEPmAoM6ON4tVijDiHC80z9Grwt+bi9ddhA3Ley6biso2w9R+Q== X-Forefront-Antispam-Report: CIP:66.35.236.227;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(339900001)(189002)(199003)(49486002)(2201001)(33646002)(105606002)(19580405001)(64706001)(40100003)(77156002)(62966003)(122386002)(86362001)(575784001)(85426001)(50986999)(86152002)(16796002)(19580395003)(50466002)(48376002)(6806004)(46102003)(87936001)(229853001)(47776003)(106466001)(97736004)(4001540100001)(81156007)(6070500001)(189998001)(5001770100001)(5001830100001)(2950100001)(92566002)(5001960100002)(5001920100001)(107886002)(5001860100001)(66066001)(76176999)(50226001)(77096005)(68736005)(7099028)(921003)(4001430100001)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR03MB128;H:sj-itexedge03.altera.priv.altera.com;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:0;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB128;2:5h0Yht4UqJyB1aqVO80mVzu07Cken3zHuwR6vogtfT9+HGADMloeg8tc8+5SNHub;2:faHUo7O8Lxa4iCmCn/DgPFzpbT2JWhpl5shWat756M5TOy0ftTbJ/n5SmeJ/KbBAC0KfDM9oM5S02C6chd1Gq2BqXitZ3xAvpFP67VQB4KqP9mbbi0VT6Mrio+o6dThXp8kc6GsbjlzgMKyI0T8YH79/I75H1WFDW2AS4jgBWUM7Ag+1N7Npws9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rJjCT+jyiz2zSKcuW/5pMNCFBJYrOryceGMF4cixObReYxlDPseJ60?= =?us-ascii?Q?yv4C0ioZK3SNXmYz+fsI=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB128;3:eIqJLSk2bcMfhOLg8HHPz4Vvj4uqT5qP1V/CvnEYaSkdw4NaKZoNyxf3UdMw/swCge3McBHZQZfdTE3zJic7xp/NuitF9Up/c3d/QB1lyn/7cdmE4i1qCNvvkVTTgzaLPYyC1E0CRG4aerP3bE6cLg==;10:xkh/d6HaPJ6gnxzbNEnfMcUH2XxtfVk+Fsj7cR/ytrTFYvALLjSDRoGe6xnKDD7+wlQkCfRDeQtO66B96WHYZzIUW1yW3AdOpsZpRPn9n3E=;6:/cgBybOl9ysppNcRrZ8HvIzWi6GSSj7uWdcxe5leVOAnZBNQYemIXIfFt0D/DRSpJyBERHUCTC8wi6GVcr6uiYt+RzO/2Uslq9VcB4l+x+RDtui/5VtQjfQo7VV1JLbZu0EFvkOD7QbEztSvSZb5GQ== X-OriginatorOrg: opensource.altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2015 14:27:36.9719 (UTC) X-MS-Exchange-CrossTenant-Id: fbd72e03-d4a5-4110-adce-614d51f2077a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fbd72e03-d4a5-4110-adce-614d51f2077a;Ip=[66.35.236.227];Helo=[sj-itexedge03.altera.priv.altera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB128 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 10332 Lines: 325 From: Thor Thayer The Arria10 SDRAM and ECC system differs significantly from the Cyclone5 and Arria5 SoCs. This patch adds support for the Arria10 SoC. 1) IRQ handler needs to support SHARED IRQ 2) Support sberr and dberr address reporting. Signed-off-by: Thor Thayer --- v2: Reposition a10_unmask_irq(). Use simple request_mem_region(), ioremap() instead of devm versions. Make a10_data static. --- drivers/edac/altera_edac.c | 135 ++++++++++++++++++++++++++++++++++++++------ drivers/edac/altera_edac.h | 85 ++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+), 16 deletions(-) diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c index a8350f6..bee475b 100644 --- a/drivers/edac/altera_edac.c +++ b/drivers/edac/altera_edac.c @@ -42,6 +42,7 @@ static const struct altr_sdram_prv_data c5_data = { .ecc_stat_ce_mask = CV_DRAMSTS_SBEERR, .ecc_stat_ue_mask = CV_DRAMSTS_DBEERR, .ecc_saddr_offset = CV_ERRADDR_OFST, + .ecc_daddr_offset = CV_ERRADDR_OFST, .ecc_cecnt_offset = CV_SBECOUNT_OFST, .ecc_uecnt_offset = CV_DBECOUNT_OFST, .ecc_irq_en_offset = CV_DRAMINTR_OFST, @@ -57,37 +58,62 @@ static const struct altr_sdram_prv_data c5_data = { #endif }; +static const struct altr_sdram_prv_data a10_data = { + .ecc_ctrl_offset = A10_ECCCTRL1_OFST, + .ecc_ctl_en_mask = A10_ECCCTRL1_ECC_EN, + .ecc_stat_offset = A10_INTSTAT_OFST, + .ecc_stat_ce_mask = A10_INTSTAT_SBEERR, + .ecc_stat_ue_mask = A10_INTSTAT_DBEERR, + .ecc_saddr_offset = A10_SERRADDR_OFST, + .ecc_daddr_offset = A10_DERRADDR_OFST, + .ecc_irq_en_offset = A10_ERRINTEN_OFST, + .ecc_irq_en_mask = A10_ECC_IRQ_EN_MASK, + .ecc_irq_clr_offset = A10_INTSTAT_OFST, + .ecc_irq_clr_mask = (A10_INTSTAT_SBEERR | A10_INTSTAT_DBEERR), + .ecc_cnt_rst_offset = A10_ECCCTRL1_OFST, + .ecc_cnt_rst_mask = A10_ECC_CNT_RESET_MASK, +#ifdef CONFIG_EDAC_DEBUG + .ce_ue_trgr_offset = A10_DIAGINTTEST_OFST, + .ce_set_mask = A10_DIAGINT_TSERRA_MASK, + .ue_set_mask = A10_DIAGINT_TDERRA_MASK, +#endif +}; + static irqreturn_t altr_sdram_mc_err_handler(int irq, void *dev_id) { struct mem_ctl_info *mci = dev_id; struct altr_sdram_mc_data *drvdata = mci->pvt_info; const struct altr_sdram_prv_data *priv = drvdata->data; - u32 status, err_count, err_addr; - - /* Error Address is shared by both SBE & DBE */ - regmap_read(drvdata->mc_vbase, priv->ecc_saddr_offset, &err_addr); + u32 status, err_count = 1, err_addr; regmap_read(drvdata->mc_vbase, priv->ecc_stat_offset, &status); if (status & priv->ecc_stat_ue_mask) { - regmap_read(drvdata->mc_vbase, priv->ecc_uecnt_offset, - &err_count); + regmap_read(drvdata->mc_vbase, priv->ecc_daddr_offset, + &err_addr); + if (priv->ecc_uecnt_offset) + regmap_read(drvdata->mc_vbase, priv->ecc_uecnt_offset, + &err_count); panic("\nEDAC: [%d Uncorrectable errors @ 0x%08X]\n", err_count, err_addr); } if (status & priv->ecc_stat_ce_mask) { - regmap_read(drvdata->mc_vbase, priv->ecc_cecnt_offset, - &err_count); + regmap_read(drvdata->mc_vbase, priv->ecc_saddr_offset, + &err_addr); + if (priv->ecc_uecnt_offset) + regmap_read(drvdata->mc_vbase, priv->ecc_cecnt_offset, + &err_count); edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, err_count, err_addr >> PAGE_SHIFT, err_addr & ~PAGE_MASK, 0, 0, 0, -1, mci->ctl_name, ""); - } - - regmap_write(drvdata->mc_vbase, priv->ecc_irq_clr_offset, - priv->ecc_irq_clr_mask); + /* Clear IRQ to resume */ + regmap_write(drvdata->mc_vbase, priv->ecc_irq_clr_offset, + priv->ecc_irq_clr_mask); - return IRQ_HANDLED; + return IRQ_HANDLED; + } + return IRQ_NONE; } #ifdef CONFIG_EDAC_DEBUG @@ -203,10 +229,60 @@ static unsigned long get_total_mem(void) static const struct of_device_id altr_sdram_ctrl_of_match[] = { { .compatible = "altr,sdram-edac", .data = (void *)&c5_data}, + { .compatible = "altr,sdram-edac-a10", .data = (void *)&a10_data}, {}, }; MODULE_DEVICE_TABLE(of, altr_sdram_ctrl_of_match); +static int a10_init(struct regmap *mc_vbase) +{ + if (regmap_update_bits(mc_vbase, A10_INTMODE_OFST, + A10_INTMODE_SB_INT, A10_INTMODE_SB_INT)) { + edac_printk(KERN_ERR, EDAC_MC, + "Error setting SB IRQ mode\n"); + return -ENODEV; + } + + if (regmap_write(mc_vbase, A10_SERRCNTREG_OFST, 1)) { + edac_printk(KERN_ERR, EDAC_MC, + "Error setting trigger count\n"); + return -ENODEV; + } + + return 0; +} + +static int a10_unmask_irq(struct platform_device *pdev, u32 mask) +{ + void __iomem *sm_base; + int ret = 0; + + if (!request_mem_region(A10_SYMAN_INTMASK_CLR, sizeof(u32), + dev_name(&pdev->dev))) { + edac_printk(KERN_ERR, EDAC_MC, + "Unable to request mem region\n"); + return -EBUSY; + } + + sm_base = ioremap(A10_SYMAN_INTMASK_CLR, sizeof(u32)); + if (!sm_base) { + edac_printk(KERN_ERR, EDAC_MC, + "Unable to ioremap device\n"); + + ret = -ENOMEM; + goto release; + } + + iowrite32(mask, sm_base); + + iounmap(sm_base); + +release: + release_mem_region(A10_SYMAN_INTMASK_CLR, sizeof(u32)); + + return ret; +} + static int altr_sdram_probe(struct platform_device *pdev) { const struct of_device_id *id; @@ -217,8 +293,8 @@ static int altr_sdram_probe(struct platform_device *pdev) struct regmap *mc_vbase; struct dimm_info *dimm; u32 read_reg; - int irq, res = 0; - unsigned long mem_size; + int irq, irq2, res = 0; + unsigned long mem_size, irqflags = 0; id = of_match_device(altr_sdram_ctrl_of_match, &pdev->dev); if (!id) @@ -284,6 +360,9 @@ static int altr_sdram_probe(struct platform_device *pdev) return -ENODEV; } + /* Arria10 has a 2nd IRQ */ + irq2 = platform_get_irq(pdev, 1); + layers[0].type = EDAC_MC_LAYER_CHIP_SELECT; layers[0].size = 1; layers[0].is_virt_csrow = true; @@ -328,8 +407,32 @@ static int altr_sdram_probe(struct platform_device *pdev) if (res < 0) goto err; + /* Only the Arria10 has separate IRQs */ + if (irq2 > 0) { + /* Arria10 specific initialization */ + res = a10_init(mc_vbase); + if (res < 0) + goto err2; + + res = devm_request_irq(&pdev->dev, irq2, + altr_sdram_mc_err_handler, + IRQF_SHARED, dev_name(&pdev->dev), mci); + if (res < 0) { + edac_mc_printk(mci, KERN_ERR, + "Unable to request irq %d\n", irq2); + res = -ENODEV; + goto err2; + } + + res = a10_unmask_irq(pdev, A10_DDR0_IRQ_MASK); + if (res < 0) + goto err2; + + irqflags = IRQF_SHARED; + } + res = devm_request_irq(&pdev->dev, irq, altr_sdram_mc_err_handler, - 0, dev_name(&pdev->dev), mci); + irqflags, dev_name(&pdev->dev), mci); if (res < 0) { edac_mc_printk(mci, KERN_ERR, "Unable to request irq %d\n", irq); diff --git a/drivers/edac/altera_edac.h b/drivers/edac/altera_edac.h index b744d91..7b64dc7 100644 --- a/drivers/edac/altera_edac.h +++ b/drivers/edac/altera_edac.h @@ -80,6 +80,91 @@ /* SDRAM Controller ECC Error Address Register */ #define CV_ERRADDR_OFST 0x48 +/*-----------------------------------------*/ + +/* SDRAM Controller EccCtrl Register */ +#define A10_ECCCTRL1_OFST 0x00 + +/* SDRAM Controller EccCtrl Register Bit Masks */ +#define A10_ECCCTRL1_ECC_EN 0x001 +#define A10_ECCCTRL1_CNT_RST 0x010 +#define A10_ECCCTRL1_AWB_CNT_RST 0x100 +#define A10_ECC_CNT_RESET_MASK (A10_ECCCTRL1_CNT_RST | \ + A10_ECCCTRL1_AWB_CNT_RST) + +/* SDRAM Controller Address Width Register */ +#define CV_DRAMADDRW 0xFFC2502C +#define A10_DRAMADDRW 0xFFCFA0A8 + +/* SDRAM Controller Address Widths Field Register */ +#define DRAMADDRW_COLBIT_MASK 0x001F +#define DRAMADDRW_COLBIT_SHIFT 0 +#define DRAMADDRW_ROWBIT_MASK 0x03E0 +#define DRAMADDRW_ROWBIT_SHIFT 5 +#define CV_DRAMADDRW_BANKBIT_MASK 0x1C00 +#define CV_DRAMADDRW_BANKBIT_SHIFT 10 +#define CV_DRAMADDRW_CSBIT_MASK 0xE000 +#define CV_DRAMADDRW_CSBIT_SHIFT 13 + +#define A10_DRAMADDRW_BANKBIT_MASK 0x3C00 +#define A10_DRAMADDRW_BANKBIT_SHIFT 10 +#define A10_DRAMADDRW_GRPBIT_MASK 0xC000 +#define A10_DRAMADDRW_GRPBIT_SHIFT 14 +#define A10_DRAMADDRW_CSBIT_MASK 0x70000 +#define A10_DRAMADDRW_CSBIT_SHIFT 16 + +/* SDRAM Controller Interface Data Width Register */ +#define CV_DRAMIFWIDTH 0xFFC25030 +#define A10_DRAMIFWIDTH 0xFFCFB008 + +/* SDRAM Controller Interface Data Width Defines */ +#define CV_DRAMIFWIDTH_16B_ECC 24 +#define CV_DRAMIFWIDTH_32B_ECC 40 + +#define A10_DRAMIFWIDTH_16B 0x0 +#define A10_DRAMIFWIDTH_32B 0x1 +#define A10_DRAMIFWIDTH_64B 0x2 + +/* SDRAM Controller DRAM IRQ Register */ +#define A10_ERRINTEN_OFST 0x10 + +/* SDRAM Controller DRAM IRQ Register Bit Masks */ +#define A10_ERRINTEN_SERRINTEN 0x01 +#define A10_ERRINTEN_DERRINTEN 0x02 +#define A10_ECC_IRQ_EN_MASK (A10_ERRINTEN_SERRINTEN | \ + A10_ERRINTEN_DERRINTEN) + +/* SDRAM Interrupt Mode Register */ +#define A10_INTMODE_OFST 0x1C +#define A10_INTMODE_SB_INT 1 + +/* SDRAM Controller Error Status Register */ +#define A10_INTSTAT_OFST 0x20 + +/* SDRAM Controller Error Status Register Bit Masks */ +#define A10_INTSTAT_SBEERR 0x01 +#define A10_INTSTAT_DBEERR 0x02 + +/* SDRAM Controller ECC Error Address Register */ +#define A10_DERRADDR_OFST 0x2C +#define A10_SERRADDR_OFST 0x30 + +/* SDRAM Controller ECC Diagnostic Register */ +#define A10_DIAGINTTEST_OFST 0x24 + +#define A10_DIAGINT_TSERRA_MASK 0x0001 +#define A10_DIAGINT_TDERRA_MASK 0x0100 + +#define A10_SBERR_IRQ 34 +#define A10_DBERR_IRQ 32 + +/* SDRAM Single Bit Error Count Compare Set Register */ +#define A10_SERRCNTREG_OFST 0x3C + +#define A10_SYMAN_INTMASK_CLR 0xFFD06098 +#define A10_INTMASK_CLR_OFST 0x10 +#define A10_DDR0_IRQ_MASK BIT(17) + struct altr_sdram_prv_data { int ecc_ctrl_offset; int ecc_ctl_en_mask; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/