From patchwork Wed May 13 21:49:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tthayer@opensource.altera.com X-Patchwork-Id: 6400461 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DE5E99F1C2 for ; Wed, 13 May 2015 21:52:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0320820270 for ; Wed, 13 May 2015 21:52:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1D38320220 for ; Wed, 13 May 2015 21:52:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YseXC-0000AO-Kv; Wed, 13 May 2015 21:49:46 +0000 Received: from mail-bl2on0053.outbound.protection.outlook.com ([65.55.169.53] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YseWe-0008As-Eg for linux-arm-kernel@lists.infradead.org; Wed, 13 May 2015 21:49:13 +0000 Received: from CH1PR03CA003.namprd03.prod.outlook.com (10.255.156.148) by BY1PR03MB1497.namprd03.prod.outlook.com (10.162.210.143) with Microsoft SMTP Server (TLS) id 15.1.160.19; Wed, 13 May 2015 21:48:45 +0000 Received: from BY2FFO11FD005.protection.gbl (10.255.156.132) by CH1PR03CA003.outlook.office365.com (10.255.156.148) with Microsoft SMTP Server (TLS) id 15.1.154.19 via Frontend Transport; Wed, 13 May 2015 21:48:45 +0000 Authentication-Results: spf=fail (sender IP is 66.35.236.236) smtp.mailfrom=opensource.altera.com; vger.kernel.org; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of opensource.altera.com does not designate 66.35.236.236 as permitted sender) receiver=protection.outlook.com; client-ip=66.35.236.236; helo=sj-itexedge04.altera.priv.altera.com; Received: from sj-itexedge04.altera.priv.altera.com (66.35.236.236) by BY2FFO11FD005.mail.protection.outlook.com (10.1.14.126) with Microsoft SMTP Server (TLS) id 15.1.160.8 via Frontend Transport; Wed, 13 May 2015 21:48:45 +0000 Received: from na01-by2-obe.outbound.protection.outlook.com (207.46.163.236) by webmail.altera.com (66.35.236.236) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 13 May 2015 14:47:36 -0700 Received: from DM2PR03MB430.namprd03.prod.outlook.com (10.141.85.14) by DM2PR03MB365.namprd03.prod.outlook.com (10.141.55.12) with Microsoft SMTP Server (TLS) id 15.1.160.10; Wed, 13 May 2015 21:48:44 +0000 Authentication-Results: alien8.de; dkim=none (message not signed) header.d=none; Received: from tthayer-HP-Z620-Ubuntu.altera.com (64.129.157.38) by DM2PR03MB430.namprd03.prod.outlook.com (10.141.85.14) with Microsoft SMTP Server (TLS) id 15.1.166.19; Wed, 13 May 2015 21:48:42 +0000 From: To: , , , , , , , , , , Subject: [PATCH 1/4] edac, altera: Generalize driver to use DT Memory size Date: Wed, 13 May 2015 16:49:44 -0500 Message-ID: <1431553787-27741-2-git-send-email-tthayer@opensource.altera.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1431553787-27741-1-git-send-email-tthayer@opensource.altera.com> References: <1431553787-27741-1-git-send-email-tthayer@opensource.altera.com> MIME-Version: 1.0 X-Originating-IP: [64.129.157.38] X-ClientProxiedBy: SN1PR12CA0028.namprd12.prod.outlook.com (25.162.96.166) To DM2PR03MB430.namprd03.prod.outlook.com (10.141.85.14) X-Microsoft-Exchange-Diagnostics-untrusted: 1; DM2PR03MB430; 2:BIhDdbm1cTOCey7JLe1BoS26Bp4OfGtefIjXjbVATzbNLNkYStRRdY9qYV+u/0s6; 2:BjuH3hY4ApAjFvH2VSW8+BJl1jhdhSXPUk/byMpzu+7vcina24FLosibfKI7JXHYj0NkbS8Rw+XIc5oFtMpEwxJ16hI4jsIBKSA4qsrjbns9u4oYEWSakfmV/hPe2oXKQ5r9agBnRW23FQPqni4bEA==; 6:ImDsMoXlLtbCZmcuXXuxf+dPsjucQOmcWFa8utHll1XEgTY567iS3LABRQVOQDuOFCRwABDRCvgUy6LuQz+STs8PRC6QkTfsMo3tZdZaWcw+lPrqtXj31ixugs8Rs3CnDPAFPs6KyZss6J9w88lm5A==; 3:LOZpPor9E2sZVnysAz6QlIlgLQQ/wXIhFZUAjao/sEBCcIVXFPmTJZRG+oY+SIAfm4wQ4rFse943MvUC1oLS9c4l2UbXUHkeI9S2cDxKu4PARxZrAKps6JVvov6nZZPGhu/DiwMtyzrI1GavVMu7Bzx3WWkZ8x7jJOiDzba1jEc7121kmWv4sV60AbMlhopJqdtSHIHZqEcCYI2LSy4Dzth+PQmEUvvpiA4DmSfTPRzphAK9bT+S8Q5/baby9SwGrMinqT4a5w9cKwwKI06m1IhqAorBxHghJFjvtUTi8vc= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:; SRVR:DM2PR03MB430; UriScan:; BCL:0; PCL:0; RULEID:; SRVR:DM2PR03MB365; UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BY1PR03MB1497; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:;UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:DM2PR03MB430; BCL:0; PCL:0; RULEID:; SRVR:DM2PR03MB430; BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BY1PR03MB1497; BCL:0; PCL:0; RULEID:; SRVR:BY1PR03MB1497; X-Forefront-PRVS: 0575F81B58 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(6009001)(76176999)(47776003)(189998001)(33646002)(50226001)(50466002)(46102003)(87976001)(86152002)(2201001)(92566002)(86362001)(62966003)(2950100001)(77156002)(107886002)(5001960100002)(50986999)(122386002)(19580405001)(40100003)(19580395003)(5001770100001)(48376002)(66066001)(229853001)(77096005)(42186005)(53416004)(921003)(1121003)(4001430100001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR03MB430; H:tthayer-HP-Z620-Ubuntu.altera.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics-untrusted: 1; DM2PR03MB430; 9:kn3TLHrNSh4ji7FyTazertijO3HnMD0XmNbrs5wypAjiwKCL7MiHBHOurd5s60F/8teXWvyq5Ht9ODWXvv6JCKE1zg+NW808VimVkS+xu0YL6xInn2vjymciQ2tGjFMNc32bHH/6TlDHh7zP0lVsMuvqegSANgIFhz5A6yeTa2BhnqAIrILlEH4jmToIbSH2oWcBDMVCzuIVRg5FRpzLUdvbl48XCWtgNtGMtturWp9Xd0waBfn//6jUvfR4FhWOYCXutk4+zDaGmJjyKs3OySxYR1gwN6avo/1d6kV1zKmACf2va7wL4qZtbXRu7iLkLQLTVnQYOCDx12KcoS8FAAXoMD66kJ/Y9pQanJwFNkhxV3NTU9abPgF+SmIbytDA2jTWprg1GBSQN1MDTYRBJumgoYnQyIztZy4ty/yYYa8RXIVQ8oKZ5vbaKqfcfegLCmrLw7lav3d+PRZ6sjyBih3IhXmDZ7amFMhDPXMziOVohjBVzddI2NRJgW0/JnTjgbAugYn6Zvx8lOX/LyPMSwkIRbf7Gz9hYaVyxpReW9RYivBa3zD0znzz1ZrlroSSMtncUt8IB/RIRmJFQjZfLPJUsyUWHmaNqIdqVComBnmg0UNliWirba3WipAKEqtmDwCAvQVc4ThtCHo1yn9KT/2/XIjfSUWHEl1bU3F7HiJYryCUaMTOaB4sYsESms4dHoAldb6Hav++ZP6PhZ3sUS96z2XbtD/50P8ztwB/3s/BJrKqfTZBEXE37cOp7UHvDiWs2Ng14tZ0Yk/BnjU+JerASA+Utm5sttS8KMJa4JebJXEc16IAURFIjKd0yAJUCML6Bku0tjeFQVx2HUxWyPQ72t1wRREcVLvqjNXfnwj5m+7Zc+Cm+f+DyxvXf7uXvMDFh9f4g551eXLg/TM2+w== X-Microsoft-Exchange-Diagnostics-untrusted: 1; DM2PR03MB430; 3:Hh+V5SfjxcMH3Q89z+IIbtt6asdvPddJLYCFuI8mRZklCz+pjxqJ2TTTQVTK1iaqE2MZKCyKPXborarkBwN835NJLEGGl/b5mR8glZQnhkXBqCW2lHEWdRusG3M9J8+nZvHDATL5sHXPzK7cI7KEzg==; 10:0hog1OP1ex/HvKH511HFYuLeV94foSoOSRSf8lBVhOJOcYwlG3CvRIQEVF01bvNbayqQ7kQugzXY5biiet5fJjTRjR3MgiuU30Q0I/XqhUI=; 6:94Vrt3kiPHDcie+b9tQ2fI/j9cfL2bGU9m8acXtjk5r0TBE0nbLu64QxRv53ZQV4fv+wKD2ipQgqVbVqyBAtwm7kBKdXkSyFk+pKTDAUfeNujamgOFcezomcnBOCvAfz4cdR5mT9MSu4zamgl9ZHDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR03MB430 X-Microsoft-Exchange-Diagnostics-untrusted: 1; DM2PR03MB365; 2:PtDCzOw8F2g8vYcXbw2duws63zIU4ou1wKWWt3h6KpUpIwPo/FLAQxV5vw5wg4xB; 2:V/+A5bNrR1SocKZbm/MiljjcvhomqbULwfE53oW/WOIEfgLFrWp3vun0iI6ygOgTNm32HOh8NJxdexpaGQeZ9W4cQPf8Xk+E+IdANtWssuAeQFofQqsmSKQHJVrGoe7th8Yds30OfZ0TikeCAMyfMg==; 9:bT3jnZ5DvOB1FeZkeURRVHAjQIM3b18vRPRTlJd76EuhzZAVrdP0ZHIYcNg6vVwUaLZOQbfECkdClsIASyT3EatNUkUdN4ujFFekEUIFBgruNh3ln1QpkZ1cpmAPhpFMalYXgh2Ekah6Z6zTwI722w== X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BY2FFO11FD005.protection.gbl X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD005; 1:n9nM8sNEbUtGgALHcjg36UQ4SNo1EyBjn3v7tL+TFfTaML9taiAGeEkLSZvf9E2aW2U7CAwSWUes7gWl0+f0WZ0LNcJPRIDfxbECjTAxATlr1rRlHb3CSGI/qV/3uX6Pc2953AQUS/y7FDj9W95RMxF5/+3cJWyzkn/Xv24J77Zig22NgkAA8etYInmecw8c9bnt8JRMF42asbcAcbzp/LTiPnU8XD54WYx/f4zLoP+iTh/A3UKoYE4/sSUi4kdOiGMt1w6zT8MBqlcqDjbVygJUgOI20OzIxO5FzDzQDCKGKJ5F2T8TrO2ESyJnc9xB X-Forefront-Antispam-Report: CIP:66.35.236.236; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(339900001)(199003)(189002)(6806004)(76176999)(85426001)(47776003)(189998001)(33646002)(50226001)(50466002)(87936001)(46102003)(86152002)(2201001)(92566002)(86362001)(62966003)(2950100001)(77156002)(107886002)(5001960100002)(50986999)(122386002)(105606002)(19580405001)(40100003)(19580395003)(5001770100001)(48376002)(106466001)(66066001)(81156007)(229853001)(77096005)(53416004)(7099028)(921003)(1121003)(4001430100001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR03MB1497; H:sj-itexedge04.altera.priv.altera.com; FPR:; SPF:Fail; MLV:ovrnspm; A:0; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1497; 2:mJxRiPv5wOqtnbch2fD1e0O8yutQEDvp7PO2Gay4uOpGPuZa6BZ82dN6cIVSd5cJ; 2:NQiqUYZvm+tcJaPo6uV6n0mvFJ4H/xagqB+7HZ4lEwkWfjBxqHi5Ei7tCZjDFwFkA63WeIWGeM02IZFXQVZZANANiYjJcJx7gIOOqcU2vEV4yhehVNtd6j47b2HlepuwlDlfhvBlg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10:5lklHmPtRb3PN2wsUE/uqAgeGgfO0M2YqBVx0kBJcraqo1Npo9v7ExZS2P6d5DmaXtQSBDrRI8t31HIOQ321ud6tcWH6vDqHT2ehsCr3WDo=; 6:hAHf5iwmicK4QeK1mP9ingAG5y2QzibfnGcaXMosGho4uqA7GVY2PQoyUMRvUC2Z5p16WOTeWI6zcrMEeLD6QSiXhf4ly4YF0+IWOEdff3suYiK0tpmveenrE/iiLddIW6oJkQDeEaZXlgawS2lNzA== X-OriginatorOrg: opensource.altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2015 21:48:45.2808 (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.236]; Helo=[sj-itexedge04.altera.priv.altera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1497 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150513_144912_826002_1AF3801F X-CRM114-Status: GOOD ( 13.67 ) X-Spam-Score: -0.0 (/) Cc: devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, tthayer.linux@gmail.com, tthayer@opensource.altera.com, linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thor Thayer The Arria10 SOC uses a completely different SDRAM controller from the earlier CycloneV and ArriaV SoCs. The memory size is calculated in the bootloader and passed via the device tree. Using this device tree size is more generic than using the register fields to calculate the memory size for different SDRAM controllers. Signed-off-by: Thor Thayer --- drivers/edac/altera_edac.c | 53 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c index 3c4929f..e18a205 100644 --- a/drivers/edac/altera_edac.c +++ b/drivers/edac/altera_edac.c @@ -219,36 +219,35 @@ static void altr_sdr_mc_create_debugfs_nodes(struct mem_ctl_info *mci) {} #endif -/* Get total memory size in bytes */ -static u32 altr_sdram_get_total_mem_size(struct regmap *mc_vbase) +/* Get total memory size from Open Firmware DTB */ +static unsigned long get_total_mem(void) { - u32 size, read_reg, row, bank, col, cs, width; + struct device_node *np = NULL; + const unsigned int *reg, *reg_end; + int len, sw, aw; + unsigned long start, size, total_mem; - if (regmap_read(mc_vbase, DRAMADDRW_OFST, &read_reg) < 0) + np = of_find_node_by_type(NULL, "memory"); + if (!np) return 0; - if (regmap_read(mc_vbase, DRAMIFWIDTH_OFST, &width) < 0) - return 0; - - col = (read_reg & DRAMADDRW_COLBIT_MASK) >> - DRAMADDRW_COLBIT_SHIFT; - row = (read_reg & DRAMADDRW_ROWBIT_MASK) >> - DRAMADDRW_ROWBIT_SHIFT; - bank = (read_reg & DRAMADDRW_BANKBIT_MASK) >> - DRAMADDRW_BANKBIT_SHIFT; - cs = (read_reg & DRAMADDRW_CSBIT_MASK) >> - DRAMADDRW_CSBIT_SHIFT; - - /* Correct for ECC as its not addressible */ - if (width == DRAMIFWIDTH_32B_ECC) - width = 32; - if (width == DRAMIFWIDTH_16B_ECC) - width = 16; - - /* calculate the SDRAM size base on this info */ - size = 1 << (row + bank + col); - size = size * cs * (width / 8); - return size; + aw = of_n_addr_cells(np); + sw = of_n_size_cells(np); + reg = (const unsigned int *)of_get_property(np, "reg", &len); + reg_end = reg + (len / sizeof(u32)); + + total_mem = 0; + do { + start = of_read_number(reg, aw); + reg += aw; + size = of_read_number(reg, sw); + reg += sw; + total_mem += size; + } while (reg < reg_end); + + of_node_put(np); + edac_printk(KERN_ERR, EDAC_MC, "total_mem 0x%lx\n", total_mem); + return total_mem; } static int altr_sdram_probe(struct platform_device *pdev) @@ -280,7 +279,7 @@ static int altr_sdram_probe(struct platform_device *pdev) } /* Grab memory size from device tree. */ - mem_size = altr_sdram_get_total_mem_size(mc_vbase); + mem_size = get_total_mem(); if (!mem_size) { edac_printk(KERN_ERR, EDAC_MC, "Unable to calculate memory size\n");