From patchwork Fri May 22 18:02:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Tull X-Patchwork-Id: 6467011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 44A2AC0020 for ; Fri, 22 May 2015 18:10:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B0CF9204A2 for ; Fri, 22 May 2015 18:10:26 +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 384EA2049D for ; Fri, 22 May 2015 18:10:25 +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 1YvrLq-0001ph-KP; Fri, 22 May 2015 18:07:18 +0000 Received: from mail-by2on0100.outbound.protection.outlook.com ([207.46.100.100] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YvrKx-0001IJ-Ct for linux-arm-kernel@lists.infradead.org; Fri, 22 May 2015 18:06:25 +0000 Received: from BY2PR03CA058.namprd03.prod.outlook.com (10.141.249.31) by DM2PR03MB320.namprd03.prod.outlook.com (10.141.54.23) with Microsoft SMTP Server (TLS) id 15.1.166.22; Fri, 22 May 2015 18:06:00 +0000 Received: from BN1BFFO11FD001.protection.gbl (2a01:111:f400:7c10::1:106) by BY2PR03CA058.outlook.office365.com (2a01:111:e400:2c5d::31) with Microsoft SMTP Server (TLS) id 15.1.172.22 via Frontend Transport; Fri, 22 May 2015 18:05:59 +0000 Authentication-Results: spf=fail (sender IP is 66.35.236.236) smtp.mailfrom=opensource.altera.com; 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 BN1BFFO11FD001.mail.protection.outlook.com (10.58.144.64) with Microsoft SMTP Server (TLS) id 15.1.172.14 via Frontend Transport; Fri, 22 May 2015 18:05:58 +0000 Received: from na01-bl2-obe.outbound.protection.outlook.com (207.46.163.208) by webmail.altera.com (66.35.236.236) with Microsoft SMTP Server (TLS) id 14.3.174.1; Fri, 22 May 2015 11:04:36 -0700 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=atull@opensource.altera.com; Received: from linuxheads99.altera.com (64.129.157.38) by BY1PR03MB1515.namprd03.prod.outlook.com (10.162.210.149) with Microsoft SMTP Server (TLS) id 15.1.172.22; Fri, 22 May 2015 18:05:53 +0000 From: Alan Tull To: Dinh Nguyen , Rob Herring Subject: [PATCH v4 1/2] ARM: socfpga: support suspend to ram Date: Fri, 22 May 2015 13:02:14 -0500 Message-ID: <1432317735-29413-2-git-send-email-atull@opensource.altera.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1432317735-29413-1-git-send-email-atull@opensource.altera.com> References: <1432317735-29413-1-git-send-email-atull@opensource.altera.com> MIME-Version: 1.0 X-Originating-IP: [64.129.157.38] X-ClientProxiedBy: DM2PR10CA0071.namprd10.prod.outlook.com (10.141.241.39) To BY1PR03MB1515.namprd03.prod.outlook.com (25.162.210.149) X-Microsoft-Exchange-Diagnostics-untrusted: 1; BY1PR03MB1515; 2:G6VOcPTTA+MYyteo+10irXBifdeo1gYmgwg2nCE+ig5mgzc7pRYIBtb7y46n27pH; 2:K61/3IKp2qT/x5r0l+iS6eCEWZ2YrUS0CJNlt9OBxhIOrNqXtmA44DNIZHMPOkMzuFzFdpVbPB8xv7vfnPcmzoa7v+SyvDvf76JTOO9fyKWPQOkFTUrA8bJhg5H3agEuN+OcCGcPiqjdcPjsBjXkYw==; 6:k3ad/joUvJRGvfwoHQnbpNJem7ot4He8iF0Z2QLlFHEuYN7ulCh/kJoANMav6D1fhgzpfFhSmhpBhGIriR0XNQ9eTgDi1/3VoCxB/aCjpitS54sI0f6dMFf3rWgL0Zc0fToMvc6LUPfhi9UvMIDo9g==; 3:+SPi9qkZHBEGE8x+MY4lBpoWoZum+APhAEru7j647SojmR0UvdbXufP+1x2an2zvCeYlPiOZRt5KDSHeZIqxK7J11V0DhLkFWrE+MqlR0/Rvm9Cg7nzo++inVjTdE/KM5b3Z2WNU4mXCySMsss6fZU6XN3Ha6W9OZJmjYxSImCnmmgg9DlAAXYIxyMLozHv8TTRMF9WyFPGUJVhG9CwUjxefagi7tdN+BYTsdPWqeApRVS3AwmBqhNvHsqpNvRQhQabrtpca2kY51qthHgXmv7WXevffEzGTHhzgSIJNIj+8jLarrSwOj4dnNwQGeV+q X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BY1PR03MB1515; UriScan:; BCL:0; PCL:0; RULEID:; SRVR:DM2PR03MB320; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:;UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(520002)(3002001); SRVR:BY1PR03MB1515; BCL:0; PCL:0; RULEID:; SRVR:BY1PR03MB1515; BCL:0; PCL:0; RULEID:(601004)(520002)(5005006)(3002001); SRVR:DM2PR03MB320; BCL:0; PCL:0; RULEID:; SRVR:DM2PR03MB320; X-Forefront-PRVS: 058441C12A X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(106356001)(50466002)(42186005)(33646002)(105586002)(575784001)(86362001)(87976001)(2950100001)(5001770100001)(97736004)(4001540100001)(81156007)(229853001)(53416004)(48376002)(40100003)(68736005)(77156002)(77096005)(15975445007)(62966003)(122386002)(5001830100001)(19580405001)(5001860100001)(19580395003)(5001920100001)(5001960100002)(69596002)(46102003)(76176999)(47776003)(66066001)(50986999)(189998001)(64706001)(101416001)(50226001)(92566002)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR03MB1515; H:linuxheads99.altera.com; 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; BY1PR03MB1515; 9:y0V5nRpxzCn3DHJsExm1CCO2isn6W5MEIkuCKuwNNP?= =?us-ascii?Q?ff/3L19B7mH7Uqys8OgMa1gbBo+m9Cy1ZrmipCUSl9yhWtPrnKA9NG/T09qP?= =?us-ascii?Q?nuJIw79x9rJncJpIWhdgXIyiqtKLsuUXsvkWlX7Dfl4ZqBYOhKys399ldLOj?= =?us-ascii?Q?UmkCxR9X7KQaiYltrcADSIkghMAULFgnKfm7TeCNWSfuv7rbuKR/0dNPtWi0?= =?us-ascii?Q?nuoqUF+/4wJAGkx3vphLLBOFgeBoHwa3lqPlOEdeb37UdJyo7i6VNuW299ty?= =?us-ascii?Q?ydseQRtl0dRbMLcIHlHYJstJnTmWdo4gXszhV7iT8P9RiV46q0neAXSWJu5h?= =?us-ascii?Q?JiSmUHlG2ypomgfQJ+c3Q3ooW9aB7ZSNP2iEwT6dXiPI4W4ShTQQywILLnet?= =?us-ascii?Q?alPvAa5a32VL8ku49JVwdvxfFWmxjlaV93aNhDtehTJrXZQWml0T5NkHuABS?= =?us-ascii?Q?A7jnSdmueCxBI/l09qfkn9B3nU4kzSrZVtipC//nzqKXO2gnqUFIzFGtj+Rc?= =?us-ascii?Q?NqphUDvxCDA6DvLRCkuxCAcRRv1POHpjp/Z88jQ9b6IV/DLbS9XIErARGXJn?= =?us-ascii?Q?D0osNbrByroihzh+2JUuKHqwTFrE8QK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exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1515 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BN1BFFO11FD001.protection.gbl X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD001; 1:wa6xgrNzyZpEHJ2a4XfQZUwTAvlOCm+ffF3k/89blo0x8T9uMYR3Be0EL8X0Yj3DG/8e4OYAwjEgER5GSd4xtvlPsWiqAEx5Z1SCP4uKtXgyvATCcWUyYRIP2KeHkt7TyJNS88CbDmnk/oYq9XJNMKkdjhuV9vcWqo84+0yJH2SqFWuf6MHmxcLYKUfmNB2h8LGA/mBQtVY8qgz4OMbM6eIQV/U+IriB1QJ7AQlJL/GHRZH0CxDjyjC+sKcGYUFXanZOdOfj6BZbN+ihAXOdcp0z6i7FxpNneYfq0BncFI2EoO/uykGl7aoecJGNgNOw X-Forefront-Antispam-Report: CIP:66.35.236.236; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(339900001)(189002)(199003)(50466002)(81156007)(105606002)(4001540100001)(50986999)(53416004)(19580395003)(19580405001)(46102003)(122386002)(92566002)(50226001)(86362001)(189998001)(97736004)(575784001)(2950100001)(85426001)(76176999)(87936001)(40100003)(6806004)(64706001)(6070500001)(47776003)(229853001)(66066001)(68736005)(77096005)(48376002)(15975445007)(33646002)(106466001)(5001960100002)(5001860100001)(62966003)(77156002)(16796002)(5001830100001)(5001770100001)(7099028)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR03MB320; H:sj-itexedge04.altera.priv.altera.com; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:0; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB320; 2:pq9xRae/frgyhrDxNXIeOOwhp20XCl+GAE8yZUgnoSRt9cLsNNrivdUtLoikP75N; 2:mK8YguQ0HD1h7BoDh/gqsjBlfOdKUs5Tt2nYFmMShnfJ1zg91DL06l8lpKb07jaCSAuDRc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ascii?Q?+ZlRshdMrsYhOmpPjsJUbzYfeZ2Y+EaKX?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB320; 3:iPvvHwqVazjL/IsuFecR1DO3+uAXcaPOSsxAmZ60SsHel2gvGqoiUbWsUIjww1ZBPjMRoOhoZG2wcjhJlBaTyiTsqEM9UpvzF+dIUXrsVzh7ZVnrFAo7SjKanf45TnFHWKuKWI3hQE4EdDHB5lx7bQ==; 10:OpeguxmptazIE2IBhtYiP5yRayb00Ie5nC0WMpQJdMuzk6GtyWVMgUTDOBPwIbXpaw39OvfzCv3ogd9FZhUxC7ayk48eidMmvHs+pIdJoY8=; 6:aYeVT1Vz4jXIpu2pkumOIh5vPBuUbhotLWGYkOgaNVT1C0VEp0XlyQxeYeCk62Kd X-OriginatorOrg: opensource.altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2015 18:05:58.4632 (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: DM2PR03MB320 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150522_110623_597644_4ECB6414 X-CRM114-Status: GOOD ( 12.99 ) X-Spam-Score: -1.1 (-) Cc: Mark Rutland , devicetree@vger.kernel.org, Russell King , Arnd Bergmann , Pawel Moll , Ian Campbell , Alan Tull , Pavel Machek , linux-kernel@vger.kernel.org, Kumar Gala , Steffen Trumtrar , Delicious Quinoq , linux-arm-kernel@lists.infradead.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 Add code that requests that the sdr controller go into self-refresh mode. This code is run from ocram. This patch assumes that u-boot has already configured sdr: sdr.ctrlcfg.lowpwreq.selfrfshmask = 3 sdr.ctrlcfg.lowpwrtiming.clkdisablecycles = 8 sdr.ctrlcfg.dramtiming4.selfrfshexit = 512 Suspend-to-RAM and EDAC support are mutually exclusive on SOCFPGA platforms. CONFIG_SOCFPGA_SUSPEND enables suspend-to-RAM and prevents selecting CONFIG_EDAC_ALTERA_MC. How to suspend to ram: $ echo enabled > \ /sys/devices/soc/ffc02000.serial0/tty/ttyS0/power/wakeup $ echo -n mem > /sys/power/state Signed-off-by: Alan Tull Cc: Pavel Machek Cc: Arnd Bergmann Cc: Dinh Nguyen Cc: Steffen Trumtrar --- v2: use Generic on-chip SRAM driver to allocate ocram rm fncpy_align since generic allocator handles alignment check __arm_ioremap_exec return code check for NULL pointers add a comment regarding sdram controller configuration v3: fix renamed #define propagate socfpga_setup_ocram_self_refresh error code v4: Kconfig: don't need to select GENERIC_ALLOCATER add CONFIG_SOCFPGA_SUSPEND make s2r and EDAC support mutually exclusive socfpga.c: add sdr_ctl_base_addr return error if ocram not available in device tree update copyright years --- arch/arm/mach-socfpga/Kconfig | 10 ++- arch/arm/mach-socfpga/Makefile | 1 + arch/arm/mach-socfpga/core.h | 6 +- arch/arm/mach-socfpga/pm.c | 150 ++++++++++++++++++++++++++++++++ arch/arm/mach-socfpga/self-refresh.S | 157 ++++++++++++++++++++++++++++++++++ arch/arm/mach-socfpga/socfpga.c | 6 +- drivers/edac/Kconfig | 2 +- 7 files changed, 328 insertions(+), 4 deletions(-) create mode 100644 arch/arm/mach-socfpga/pm.c create mode 100644 arch/arm/mach-socfpga/self-refresh.S diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig index b5f8d75..b26a684 100644 --- a/arch/arm/mach-socfpga/Kconfig +++ b/arch/arm/mach-socfpga/Kconfig @@ -1,4 +1,4 @@ -config ARCH_SOCFPGA +menuconfig ARCH_SOCFPGA bool "Altera SOCFPGA family" if ARCH_MULTI_V7 select ARM_AMBA select ARM_GIC @@ -8,3 +8,11 @@ config ARCH_SOCFPGA select HAVE_ARM_SCU select HAVE_ARM_TWD if SMP select MFD_SYSCON + +if ARCH_SOCFPGA +config SOCFPGA_SUSPEND + bool "Suspend to RAM on SOCFPGA" + help + Select this if you want to enable Suspend-to-RAM on SOCFPGA + platforms. +endif diff --git a/arch/arm/mach-socfpga/Makefile b/arch/arm/mach-socfpga/Makefile index 6dd7a93..b8f9e23 100644 --- a/arch/arm/mach-socfpga/Makefile +++ b/arch/arm/mach-socfpga/Makefile @@ -4,3 +4,4 @@ obj-y := socfpga.o obj-$(CONFIG_SMP) += headsmp.o platsmp.o +obj-$(CONFIG_SOCFPGA_SUSPEND) += pm.o self-refresh.o diff --git a/arch/arm/mach-socfpga/core.h b/arch/arm/mach-socfpga/core.h index a0f3b1c..498b271 100644 --- a/arch/arm/mach-socfpga/core.h +++ b/arch/arm/mach-socfpga/core.h @@ -1,6 +1,6 @@ /* * Copyright 2012 Pavel Machek - * Copyright (C) 2012 Altera Corporation + * Copyright (C) 2012-2015 Altera Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,6 +39,10 @@ extern void socfpga_sysmgr_init(void); extern void __iomem *sys_manager_base_addr; extern void __iomem *rst_manager_base_addr; +extern void __iomem *sdr_ctl_base_addr; + +u32 socfpga_sdram_self_refresh(u32 sdr_base, u32 scu_base); +extern unsigned int socfpga_sdram_self_refresh_sz; extern struct smp_operations socfpga_smp_ops; extern char secondary_trampoline, secondary_trampoline_end; diff --git a/arch/arm/mach-socfpga/pm.c b/arch/arm/mach-socfpga/pm.c new file mode 100644 index 0000000..166ac32 --- /dev/null +++ b/arch/arm/mach-socfpga/pm.c @@ -0,0 +1,150 @@ +/* + * arch/arm/mach-socfpga/pm.c + * + * Copyright (C) 2014-2015 Altera Corporation. All rights reserved. + * + * with code from pm-imx6.c + * Copyright 2011-2014 Freescale Semiconductor, Inc. + * Copyright 2011 Linaro Ltd. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "core.h" + +/* Pointer to function copied to ocram */ +static u32 (*socfpga_sdram_self_refresh_in_ocram)(u32 sdr_base, u32 scu_base); + +static int socfpga_setup_ocram_self_refresh(void) +{ + struct platform_device *pdev; + phys_addr_t ocram_pbase; + struct device_node *np; + struct gen_pool *ocram_pool; + unsigned long ocram_base; + void __iomem *suspend_ocram_base; + int ret = 0; + + np = of_find_compatible_node(NULL, NULL, "mmio-sram"); + if (!np) { + pr_err("%s: Unable to find mmio-sram in dtb\n", __func__); + return -ENODEV; + } + + pdev = of_find_device_by_node(np); + if (!pdev) { + pr_warn("%s: failed to find ocram device!\n", __func__); + ret = -ENODEV; + goto put_node; + } + + ocram_pool = dev_get_gen_pool(&pdev->dev); + if (!ocram_pool) { + pr_warn("%s: ocram pool unavailable!\n", __func__); + ret = -ENODEV; + goto put_node; + } + + ocram_base = gen_pool_alloc(ocram_pool, socfpga_sdram_self_refresh_sz); + if (!ocram_base) { + pr_warn("%s: unable to alloc ocram!\n", __func__); + ret = -ENOMEM; + goto put_node; + } + + ocram_pbase = gen_pool_virt_to_phys(ocram_pool, ocram_base); + + suspend_ocram_base = __arm_ioremap_exec(ocram_pbase, + socfpga_sdram_self_refresh_sz, + false); + if (!suspend_ocram_base) { + pr_warn("%s: __arm_ioremap_exec failed!\n", __func__); + ret = -ENOMEM; + goto put_node; + } + + /* Copy the code that puts DDR in self refresh to ocram */ + socfpga_sdram_self_refresh_in_ocram = + (void *)fncpy(suspend_ocram_base, + &socfpga_sdram_self_refresh, + socfpga_sdram_self_refresh_sz); + + WARN(!socfpga_sdram_self_refresh_in_ocram, + "could not copy function to ocram"); + if (!socfpga_sdram_self_refresh_in_ocram) + ret = -EFAULT; + +put_node: + of_node_put(np); + + return ret; +} + +static int socfpga_pm_suspend(unsigned long arg) +{ + u32 ret; + + if (!sdr_ctl_base_addr || !socfpga_scu_base_addr) + return -EFAULT; + + ret = socfpga_sdram_self_refresh_in_ocram( + (u32)sdr_ctl_base_addr, (u32)socfpga_scu_base_addr); + + pr_debug("%s self-refresh loops request=%d exit=%d\n", __func__, + ret & 0xffff, (ret >> 16) & 0xffff); + + return 0; +} + +static int socfpga_pm_enter(suspend_state_t state) +{ + switch (state) { + case PM_SUSPEND_STANDBY: + case PM_SUSPEND_MEM: + outer_disable(); + cpu_suspend(0, socfpga_pm_suspend); + outer_resume(); + break; + default: + return -EINVAL; + } + return 0; +} + +static const struct platform_suspend_ops socfpga_pm_ops = { + .valid = suspend_valid_only_mem, + .enter = socfpga_pm_enter, +}; + +static int __init socfpga_pm_init(void) +{ + int ret; + + ret = socfpga_setup_ocram_self_refresh(); + if (ret) + return ret; + + suspend_set_ops(&socfpga_pm_ops); + pr_info("SoCFPGA initialized for DDR self-refresh during suspend.\n"); + + return 0; +} +arch_initcall(socfpga_pm_init); diff --git a/arch/arm/mach-socfpga/self-refresh.S b/arch/arm/mach-socfpga/self-refresh.S new file mode 100644 index 0000000..b9f95bc --- /dev/null +++ b/arch/arm/mach-socfpga/self-refresh.S @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2014-2015 Altera Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +#include +#include + +#define SOCFPGA_SCU_CTRL_OFFS 0 +#define SCU_STANDBY_ENA 0x20 +#define MAX_LOOP_COUNT 1000 + +/* Register offset */ +#define SDR_CTRLGRP_LOWPWREQ_ADDR 0x54 +#define SDR_CTRLGRP_LOWPWRACK_ADDR 0x58 + +/* Bitfield positions */ +#define SELFRSHREQ_POS 3 +#define SELFRSHREQ_MASK 0x8 + +#define SELFRFSHACK_POS 1 +#define SELFRFSHACK_MASK 0x2 + + /* + * This code assumes that the bootloader has already + * properly configured the sdram controller: + * + * sdr.ctrlcfg.lowpwreq.selfrfshmask = 3 + * sdr.ctrlcfg.lowpwrtiming.clkdisablecycles = 8 + * sdr.ctrlcfg.dramtiming4.selfrfshexit = 512 + */ + + .arch armv7-a + .text + .align 3 + + /* + * socfpga_sdram_self_refresh + * + * r0 : sdr_ctl_base_addr + * r1 : socfpga_scu_base_addr + * r2 : temp storage of register values + * r3 : loop counter + * r4 : temp storage of return value + * + * return value: lower 16 bits: loop count going into self refresh + * upper 16 bits: loop count exiting self refresh + */ +ENTRY(socfpga_sdram_self_refresh) + stmfd sp!, {r4} + + /* + * Enable SCU (snoop) standby mode. + * + * From the ARM Cortex-A9 MPCore Technical Reference Manual: + * "When set, SCU CLK is turned off when all processors are in WFI + * mode, there is no pending request on the ACP (if implemented), and + * there is no remaining activity in the SCU." + */ + ldr r2, [r1, #SOCFPGA_SCU_CTRL_OFFS] + orr r2, r2, #SCU_STANDBY_ENA + str r2, [r1, #SOCFPGA_SCU_CTRL_OFFS] + + /* Enable dynamic clock gating in the Power Control Register. */ + mrc p15, 0, r2, c15, c0, 0 + orr r2, r2, #1 + mcr p15, 0, r2, c15, c0, 0 + + /* Enable self refresh: set sdr.ctrlgrp.lowpwreq.selfrshreq = 1 */ + ldr r2, [r0, #SDR_CTRLGRP_LOWPWREQ_ADDR] + orr r2, r2, #SELFRSHREQ_MASK + str r2, [r0, #SDR_CTRLGRP_LOWPWREQ_ADDR] + + /* Poll until sdr.ctrlgrp.lowpwrack.selfrfshack == 1 or hit max loops */ + mov r3, #0 +while_ack_0: + ldr r2, [r0, #SDR_CTRLGRP_LOWPWRACK_ADDR] + and r2, r2, #SELFRFSHACK_MASK + cmp r2, #SELFRFSHACK_MASK + beq ack_1 + + add r3, #1 + cmp r3, #MAX_LOOP_COUNT + bne while_ack_0 + +ack_1: + mov r4, r3 + + /* + * Execute an ISB instruction to ensure that all of the + * CP15 register changes have been committed. + */ + isb + + /* + * Execute a barrier instruction to ensure that all cache, + * TLB and branch predictor maintenance operations issued + * by any CPU in the cluster have completed. + */ + dsb + dmb + + wfi + + /* Disable self-refresh: set sdr.ctrlgrp.lowpwreq.selfrshreq = 0 */ + ldr r2, [r0, #SDR_CTRLGRP_LOWPWREQ_ADDR] + bic r2, r2, #SELFRSHREQ_MASK + str r2, [r0, #SDR_CTRLGRP_LOWPWREQ_ADDR] + + /* Poll until sdr.ctrlgrp.lowpwrack.selfrfshack == 0 or hit max loops */ + mov r3, #0 +while_ack_1: + ldr r2, [r0, #SDR_CTRLGRP_LOWPWRACK_ADDR] + and r2, r2, #SELFRFSHACK_MASK + cmp r2, #SELFRFSHACK_MASK + bne ack_0 + + add r3, #1 + cmp r3, #MAX_LOOP_COUNT + bne while_ack_1 + +ack_0: + /* + * Prepare return value: + * Shift loop count for exiting self refresh into upper 16 bits. + * Leave loop count for requesting self refresh in lower 16 bits. + */ + mov r3, r3, lsl #16 + add r4, r4, r3 + + /* Disable dynamic clock gating in the Power Control Register. */ + mrc p15, 0, r2, c15, c0, 0 + bic r2, r2, #1 + mcr p15, 0, r2, c15, c0, 0 + + /* Disable SCU standby mode */ + ldr r2, [r1, #SOCFPGA_SCU_CTRL_OFFS] + bic r2, r2, #SCU_STANDBY_ENA + str r2, [r1, #SOCFPGA_SCU_CTRL_OFFS] + + mov r0, r4 @ return value + ldmfd sp!, {r4} + bx lr @ return + +ENDPROC(socfpga_sdram_self_refresh) +ENTRY(socfpga_sdram_self_refresh_sz) + .word . - socfpga_sdram_self_refresh diff --git a/arch/arm/mach-socfpga/socfpga.c b/arch/arm/mach-socfpga/socfpga.c index f5e597c..a807aa0 100644 --- a/arch/arm/mach-socfpga/socfpga.c +++ b/arch/arm/mach-socfpga/socfpga.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Altera Corporation + * Copyright (C) 2012-2015 Altera Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ void __iomem *socfpga_scu_base_addr = ((void __iomem *)(SOCFPGA_SCU_VIRT_BASE)); void __iomem *sys_manager_base_addr; void __iomem *rst_manager_base_addr; +void __iomem *sdr_ctl_base_addr; unsigned long socfpga_cpu1start_addr; static struct map_desc scu_io_desc __initdata = { @@ -82,6 +83,9 @@ void __init socfpga_sysmgr_init(void) np = of_find_compatible_node(NULL, NULL, "altr,rst-mgr"); rst_manager_base_addr = of_iomap(np, 0); + + np = of_find_compatible_node(NULL, NULL, "altr,sdr-ctl"); + sdr_ctl_base_addr = of_iomap(np, 0); } static void __init socfpga_init_irq(void) diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig index cb59619..9b69b97 100644 --- a/drivers/edac/Kconfig +++ b/drivers/edac/Kconfig @@ -378,7 +378,7 @@ config EDAC_OCTEON_PCI config EDAC_ALTERA_MC tristate "Altera SDRAM Memory Controller EDAC" - depends on EDAC_MM_EDAC && ARCH_SOCFPGA + depends on EDAC_MM_EDAC && ARCH_SOCFPGA && !SOCFPGA_SUSPEND help Support for error detection and correction on the Altera SDRAM memory controller. Note that the