From patchwork Thu Jun 4 14:28:45 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: 6547631 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 48EF49F1CC for ; Thu, 4 Jun 2015 14:31:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C363207E9 for ; Thu, 4 Jun 2015 14:31:15 +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 34C2B207E6 for ; Thu, 4 Jun 2015 14:31:14 +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 1Z0W7p-0002WG-Jo; Thu, 04 Jun 2015 14:28:05 +0000 Received: from mail-bl2on0089.outbound.protection.outlook.com ([65.55.169.89] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z0W7d-0002Qs-0w for linux-arm-kernel@lists.infradead.org; Thu, 04 Jun 2015 14:27:57 +0000 Received: from BN3PR0301CA0035.namprd03.prod.outlook.com (10.160.180.173) by BLUPR03MB231.namprd03.prod.outlook.com (10.255.213.22) with Microsoft SMTP Server (TLS) id 15.1.184.10; Thu, 4 Jun 2015 14:27:30 +0000 Received: from BY2FFO11FD005.protection.gbl (2a01:111:f400:7c0c::167) by BN3PR0301CA0035.outlook.office365.com (2a01:111:e400:4000::45) with Microsoft SMTP Server (TLS) id 15.1.184.17 via Frontend Transport; Thu, 4 Jun 2015 14:27:30 +0000 Authentication-Results: spf=fail (sender IP is 66.35.236.236) smtp.mailfrom=opensource.altera.com; alien8.de; 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.184.11 via Frontend Transport; Thu, 4 Jun 2015 14:27:29 +0000 Received: from na01-by2-obe.outbound.protection.outlook.com (207.46.163.240) by webmail.altera.com (66.35.236.236) with Microsoft SMTP Server (TLS) id 14.3.174.1; Thu, 4 Jun 2015 07:26:18 -0700 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tthayer@opensource.altera.com; Received: from localhost.localdomain (64.129.157.38) by BLUPR03MB423.namprd03.prod.outlook.com (10.141.78.150) with Microsoft SMTP Server (TLS) id 15.1.184.10; Thu, 4 Jun 2015 14:26:53 +0000 From: To: , , , , , , , , , , Subject: [PATCHv2 1/4] edac, altera: Generalize driver to use DT Memory size Date: Thu, 4 Jun 2015 09:28:45 -0500 Message-ID: <1433428128-7292-2-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 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:sgZ6I9btoYRB8BwqFDXopTMOsZCOt1gNaCoWIhk0mO4p3xFZ1UZv/koJEhdg9zpT; 2:IUkiKvekCjBtXz1ZmT0EJSPrZZjZb8NE0C/zvBbk81rniGLP5YC6ht77PxKChunLhH9HdFVM+/YeN4ezBtxeSrai3XEgTyk0ny9YFfqbSaKWT00UxN6MKUdkQz/mQ37JrCQbwu0qY1VcE2mM1OZZgQ==; 6:Fw+DDYRjvCQF3PiD4cZiTwc1e0wPA/jPIABVHwYLc91iXf+fMvNhakur/6S4NLTr/O2wV4SUV1pW2NLL/0hFZ5h9Z0JuzoLZIJA4ZNyf0rrmV4X0TCEJmowyKlnyUEaatJwfQBmF4tvs4hX/2mVJyQ==; 3:6a+J1w1QA6U7nk+NbAKCB3/XWHZxhkS0t/atJjy7mbPBMlN1K/KOIPiO2c/XvZ45u5I+PXEl1g1omxJRwo9PVE1MWUwd4EyVv3EglHFYA6uwa6c8Izn8tuZh/vlovcTU6LphqcSIfTd9mKA9evTyyFFT+aygqQL92ArRwDOPg++Bf7fxBJJ/3bvjGeFP8m2v8ytWPvJZp+5Ve9GNAF/bCYUSkw4MwRTeQGDumtBwHSXT/q6FSGLhor9K5IR3LIu5KAGth9Ojmln8eQW7dp+yCCtwnxHxDj1aCGBOHIDpPUVD/9hF6wRpl4vm/AMAr7s0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB423; UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB231; 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)(5005006)(520003)(3002001); SRVR:BLUPR03MB231; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB231; 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)(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; Received-SPF: None (protection.outlook.com: opensource.altera.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics-untrusted: =?us-ascii?Q?1; BLUPR03MB423; 9:Kw3kjB2zDou2DRUF28cWP62HYh8ORCmxw7sBlq1Tzme?= =?us-ascii?Q?lkH0HQaLepeX6JgldSxslA5KGUj/E5PlRk4bpynlmwFH2lF2UWMdhnwjbLPq?= =?us-ascii?Q?qp8f5BrmNXcxMMWCkWp76o/xYWNIzt2VhREaVp7HBk27y5vFOvtOl09sy2TX?= =?us-ascii?Q?ivPGUO7+KyUONkrByVQYPCQp48ua6OfFkqhWIE4hxV2Xp2JPgctFgGhR5eFN?= =?us-ascii?Q?v/NPY+6cKdfCM7NsaDJ7i4KOh3TqVywgRD+UUCBQi4Jpn/oVz6ZcoRhep67V?= =?us-ascii?Q?3cLoiAJ8EkQt3w5EK306GrAkRUnN0ikvLz6BSH1eSfzD6v62tV8HFuX5VR6k?= =?us-ascii?Q?B1drlgCQfPGNPpNxEMH6WZvWpKAhkeVBh7ULfWdAMxlJdH+aHfUyHrghpvhP?= =?us-ascii?Q?DOweSVUzaim17dTFRllOfL2JNl2DFyPtGNsaJKPkQf2Etkc6HtAeKVbRUPCQ?= =?us-ascii?Q?EeNwN8avPMUpxmd0OTaBeodyeutA6GhSb3ET3MRW1/dlxt+Z5BxltbACNoYP?= =?us-ascii?Q?oYzmj0ZW0fz5un0QLYQb0Xpnhz8AOcjwKU7tsRX+4BxOt3Yl4BxQUYznhsT6?= =?us-ascii?Q?OxNNI51RxV6EADkesWpCU2V/u76WE/qhtHsX5gvAURvOOLuJc16jZgc4qnCV?= =?us-ascii?Q?qPQEryo8zLYPfBYe8KW2yeQNunioI7Ehoveh+8aloc2lCDhiiHKXoREE1LGt?= =?us-ascii?Q?hkWrnsBdZf01uDkK8iT4nXadWUONiSIwK/kHqeKVx/y0i3+va6zuN1daSEM0?= =?us-ascii?Q?iczvjPsaI19Hd1S94M3aLSphbqn6GocqQ1PS+E3PD9KcwU20efbSqxrv4YXR?= =?us-ascii?Q?Ve6iEaWSeEaXSWeTtxdMWZpah3GRl28uojpJ2w4nRFDTws2nn4VM1R/2UQas?= =?us-ascii?Q?oH9GPLpTjevRhq37OKJC/AZsHR0NKZg/jVZQHITsIm8i0h9ufBiCjqP3vxzy?= =?us-ascii?Q?zOunxe/2iA2DHqBPfOqBdCAyo6R4jdKXolod1DYxN1tYUT/J+HVV0tDgf9A/?= =?us-ascii?Q?cGyNHD4xMSkzYMj7oJ+3eaoPArqI65B83vSyPCLHC5ff406nPO0f50Z7FVkk?= =?us-ascii?Q?4joCzxuCri2lYhG9CNLvOiR27vLV2Rdj+GB4HftKwVlwDSP45izXP+HluXZf?= =?us-ascii?Q?kGP+wBgipOhS97lX4g6qCtj72LNBMZbLs9EnMeC4kFzBkUHH+tumH5yj/N6b?= =?us-ascii?Q?f4qyOREHqPNM=3D?= X-Microsoft-Exchange-Diagnostics-untrusted: 1; BLUPR03MB423; 3:P7QCrKFGqtkGtOrUEoACTraQuEnPPgVrI5UXacdSc+FcFbXKm0EJWvP2bFDx90kGxUnlywi82DsywbEK5U+p922Kq9hGDsDpu5GYx8p2ln7vmj+Ko5yTBeb8r0+Hj9jbC7vcokCH1sI95OBfLuw/hw==; 10:5ItXajVrFzit2/O5xgD3m4d/6vbmiVoW24m85wT6e0QcTgHQSdxHByoAte3f5fYTPC7+cZC9QrtNy2yMKQ+7XmUP3LqE44SSN2nHPI6d2W8=; 6:jiGiKA0ZvJXMQzKEux4i7io4BesP9SmObzs2ZL+3G86A47+bqr75be6K6oFDMJSrGQ8YTm3514/72gpLQeN5IirzH+saPH8VGy7feKrs7a16J2LefzjmePAoTieOyL7HUX1gejfGJinJiQ8ra9tcdA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB423 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BY2FFO11FD005.protection.gbl X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD005; 1:l486EhpJ0yK/VckK3hzSYTFDvbnKGhPzWMEXVTqBNgIXWg2q2yTLYipAJaO6nQMLW20Vb2rVj4bj/Ql1O+gn8PA4EggUsvgd1SdleoKxbGBMjLXfmIHikNgTlrfAOOkUIMWqSr9EmZAoSILdHFXbBzXjpdEzWb1ZPfrzV5HOAa215A4ldQiswQg/1Nt9F+kDIF7MFhhzAYbPsGH/wASI1QSTwmn97Ihagq2W+P2vjUoXpoZ9knl3Iqyf+JPBuwS8O1PuPm+3moQL0cKiZ5HSrg== X-Forefront-Antispam-Report: CIP:66.35.236.236; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(339900001)(189002)(199003)(50466002)(33646002)(86362001)(76176999)(16796002)(50986999)(48376002)(64706001)(47776003)(46102003)(66066001)(229853001)(106466001)(50226001)(49486002)(87936001)(6806004)(19580405001)(85426001)(86152002)(19580395003)(2201001)(81156007)(4001540100001)(77096005)(2950100001)(68736005)(5001770100001)(189998001)(122386002)(62966003)(97736004)(77156002)(5001860100001)(5001830100001)(92566002)(105606002)(107886002)(40100003)(5001960100002)(6070500001)(7099028)(921003)(1121003)(4001430100001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB231; H:sj-itexedge04.altera.priv.altera.com; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:0; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB231; 2:ghlZW/X9n+C1oMbH8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h125m/weWCiyyBba9Bh6LIc0zQLNbxPJyysL6rOkFU8Rz1C9hHk8JSzvh2?= =?us-ascii?Q?EkNNvqdRHxKD5XdB4gdZLJak+JRlTUv7ETTN3nIlrFf5+OWH2D3WwCG98Nbx?= =?us-ascii?Q?9nkeunSEwHHCJjvaGehAvR9vqODFt+XH/dsB45izIGauRSPGknhXRplzhBI7?= =?us-ascii?Q?Esf5tQaTpY8YnZ1NUYNVHCDYhEvM8lk92xZu1?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB231; 3:6iB4XDiIQXYjoAExtCi9OrRQoCRJSLpz5A7gLAGf0i0UC6WoJTdFMuOztan1pzncKdnrvTbWGb037Vwx2bxO7Xx0bxpl3Z5RdGqASmHpVDx/4ldq/0tp47njkbE4V/rd2Bfz3R30kDAhKdmWL7YJLg==; 10:0gruwBuovzwDy+19IIGUQVVzqvCX2/V8qi+N94G64lwnK8yGuy4wf5pfU3Ag3YNpnI+lr5u3BU/DPVS5bsmDscT7RIVcYR5ZHcGtkV62k8A=; 6:hS2jgziDrWGWnz9FTOKbJcN/lIbxWyA6eZxd/YYCtShEGKXPYcilcWMx0m73vg7GX+UzjIG/aQtC/RHbV5bahC8xGRiBYHLOWCKRJsWXTewppUPSU8NpurdStXQDlvbPFfcTK1QEYw3vaeJMn6nDeQ== X-OriginatorOrg: opensource.altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2015 14:27:29.5632 (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: BLUPR03MB231 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150604_072753_302234_BF33113D X-CRM114-Status: GOOD ( 14.39 ) X-Spam-Score: -1.1 (-) 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 --- v2: Use edac_dbg() for memory size print. Use loop for DT memory. --- drivers/edac/altera_edac.c | 55 ++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c index 806b63b..a9e7c69 100644 --- a/drivers/edac/altera_edac.c +++ b/drivers/edac/altera_edac.c @@ -219,36 +219,31 @@ 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; - - if (regmap_read(mc_vbase, DRAMADDRW_OFST, &read_reg) < 0) - 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; + struct device_node *np = NULL; + const unsigned int *reg, *reg_end; + int len, sw, aw; + unsigned long start, size, total_mem = 0; + + for_each_node_by_type(np, "memory") { + 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); + } + edac_dbg(0, "total_mem 0x%lx\n", total_mem); + return total_mem; } static int altr_sdram_probe(struct platform_device *pdev) @@ -280,7 +275,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");