Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752305AbbGaNIs (ORCPT ); Fri, 31 Jul 2015 09:08:48 -0400 Received: from mail-by2on0139.outbound.protection.outlook.com ([207.46.100.139]:38824 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750901AbbGaNIp (ORCPT ); Fri, 31 Jul 2015 09:08:45 -0400 X-Greylist: delayed 914 seconds by postgrey-1.27 at vger.kernel.org; Fri, 31 Jul 2015 09:08:45 EDT Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; From: Chenhui Zhao To: , CC: , Subject: [PATCH 3/4] powerpc: pm: add EPU FSM configuration for deep sleep Date: Fri, 31 Jul 2015 20:53:05 +0800 Message-ID: <1438347186-8462-3-git-send-email-chenhui.zhao@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438347186-8462-1-git-send-email-chenhui.zhao@freescale.com> References: <1438347186-8462-1-git-send-email-chenhui.zhao@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD021;1:7u3xtahxtVsnJ4OIrbVlQ22HDJTxKxmSi1amN+hR2/71WwLd0AqDX3tQUC27GcMlsPuv2lpqB/ckAqcykZ2+nS9LWSRCyAyXLQk/QUyJYGDQrNoFAgrlAmzVhAbwkjLb9L6jqkBXnEiBHqhRhLe1drfz8br6OxGZbB5dJXcCneuU62/0/VD5FIDzTn0tBVMjwWVfUh/bIwB2x+VZrIy7mVCyj1yyNKaI6xk0uoBpFjRK7rZmqNEAWhFUiN6sJtC1txZJgz71g2JqfomaRwFv8zNEgRqu3ysLGTB61YmgkTcsme77fHvZppf7gcC8zp13S9IEj5eezPaErHsWWV+pxQ== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(86362001)(92566002)(87936001)(19580405001)(19580395003)(2950100001)(36756003)(62966003)(575784001)(49486002)(46102003)(85426001)(48376002)(104016003)(5001960100002)(229853001)(33646002)(189998001)(5001770100001)(107886002)(77096005)(50466002)(47776003)(106466001)(77156002)(6806004)(105606002)(50986999)(4001450100002)(76176999)(50226001)(217873001)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR0301MB1296;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1296;2:qAN8opQ5/vvlCS8wGcV4kCgZyHJD28/TFhOdeyxTQIQ46DfXU8tW0eVFVEZqd09lXMuCh+1bRx1F2UvnS9vnfir4TUqzyFlk0dN1ijIVlCeX2avjWYSannhCG0HQSnvpY5rIlUnYdT1XnfNOUckvFeeOzKHCGPvCRZSRNqERz00=;3:aPOf6rBqrHavDhLPmRL0HW2zQwJhSyKHwh6QdIg779KZrDsJLID1aPy66sZIuADFzWsT1mamIA98ooki9SocEaGezY7ys1wwOSboxJPFAYY4xfcCOKELJL+ZLlTdJcAzzookgEK3Mca5ezZiVE5LckqtvlYm4o0zH+H2jocwckCkgn/0IHRFd8CXxO4PADz1uULFwfE9lB3d7JH9SiJlRxPydY1hpsnoTRulhNQn5d4=;25:j7MNDrJQ1QYOl3e0589/PqYwPDZkeuD4gErebqRf9YSwWrwsAZVvN06/YBdSuc1DG5HNZlJ8KY0vMqCK1M/bIu+K/D6FHXA9AEHBVSez0nMTK/YO6darbpjiF6u+Rn/5Tpx+sv7d0vJiKQJGrmwAZyEGN2ZVERMkGz6wwN1W5PlgXcXwUIm745Vku6SCiQqVfXKT9LUv7bVMVklQ5Y2K5Jb55dPz3CUvs/+hCKSDLCK6wXukGjXwO6fOVzQvtORq5kpynY2YzOMfOnyQPuaQ3g== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1296; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1296;20:/lGUatvP6sV90roY1BI5SQJh33xZutLYmIYfOnI2Wvzb5O2Rb+ctspIEkwL4z+nP/4lRKXr6ZhJWNHJaW3gFsChzctlru8/5WPolR1/arC0Wh+keAhhagL3KC366QNeSuvSqUdz+5QgJjX7ldv59T4Nglc/8nOOaNopA3yaswOkvja6hTZwqXt4iXi1xWLkv9yo5DOput4QUR3i17ktfqmWis+lIsJCHpgKQtmRzT89W46QQaQ623Bxd3f1sgRd3me2eus+KcsbgKERjbm/jswfEXqylx3iee7YeLd6VqROtLCXoJJ5QQePBxregh9OmjxLrYFovvivdU6GhpaiiBhtI3cOzDvrtwj3N8hxgXZk=;4:yC3AcQgH8S7AVM5RZ4vBWF1ArImumqMjl47bCM/jenNCUh8S8iIIarwUBJ5ZzHSJyd2W29HF6iHxYuAqC26OVLc3fI1wYh8bFu3fXckD6+ke+PsmwgCW8nK6+Kt2Rk7juU+FW3kBr7b6ugFY7DulMXTH35KwsoCoJpDzr4yZpynVXc0S1mjsn4q4+zltpMD0VaSghKpxi1Ckq1iUm4TQqZcr21lnblAreAGEHQ0FpzkR0StheAyrgF/K92VZXDGcp/afphDMmd7q6XuZcSTulTSXF3wxfv3YTg0nY1Up/PQ= DM2PR0301MB1296: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:DM2PR0301MB1296;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1296; X-Forefront-PRVS: 0654257CF5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR0301MB1296;23:Btaw2HgVovOOoJwvP6NQsWzh0qz9bDn0aARGopj?= =?us-ascii?Q?sZGT8gzu72s5hW7WsrjF4zhgJN4q1WXNjLOC5b+l/zHkfS/qZAUhcOsXpRT7?= =?us-ascii?Q?OHiuI2ZdVUAt7igwyHLQj9dFWfOB26qJHKrzpIXk6eTjWE4rqt/nsaJihzrZ?= =?us-ascii?Q?CQNUAOd5CX0z/xH2BgouLrEJaNYsrswew624EMDk/dQNNXDT5LqbmiLfTi8/?= =?us-ascii?Q?Hrqegmtpv2Vy3A1B73WWL0TwlUnDs0bdQmEEwZnS+fibRWB61HCHDL4MLcgr?= =?us-ascii?Q?fgczn93tLQwV8I8st+k2iYjBL0ZqH5YF9k6u+eTPc5FKF9JBcoH9hEdmg3wQ?= =?us-ascii?Q?y5nLKqLU/FX5HBGijAIWyhNQfqN98lNekMhXhzMHD5F5pKAgAlnb21idCLkj?= =?us-ascii?Q?MtVWp2GqYKYclCPbfkoMvaTiRzk21qTM1yInwd5ERRmYxKV5Wu/KUd2z2kfS?= =?us-ascii?Q?loQkoHDNC2B5qRSiQm/2EzW9MzGeYMcP31bPsEeXvL9T0D6K7zPn+IpaoAii?= =?us-ascii?Q?feqZ0cYkcyTiHI0fNHnc7BJOs5Uj1JCCvDEa8+I0rBtGf621xCGBa5udG91I?= =?us-ascii?Q?j74Yy9qNpvfFSwEI8E7+xQnstLxSmY5J/LQ+3yPTtmlY+58t4v1SSRsS5oU8?= =?us-ascii?Q?sDt36bJRmjELr1uWD3Yre7s57BX2IRmVoxUzgSTjXk8W0rqbZhrmH+U6fwo4?= =?us-ascii?Q?LB4dDDj57NouHXz9tw0udEvDycxDpmS+kKKxxPVKcVm724bf8B287zp0wkr4?= =?us-ascii?Q?KbQ/O41N3MOV3/ynZ26gFTMJ3EAb/g1gOh56k+NpmHBKSaMcc0zuCm5exE6X?= =?us-ascii?Q?+MohGVx+vdRZlfaigFBK0nkM2uPKciDnzyS7X/k/bpXqjerwlasynK4rlaql?= =?us-ascii?Q?q7jqfOe6qijVfKRfQP+RaXMHx4/nXBoa8yQee+hc4fzbZE5ZXDcAxkvorOph?= =?us-ascii?Q?f6LRMvTIovXHL5HaL5bT318hiaAMwitpvFITj7AEnet+RZ3pY4vSbPoE9kwD?= =?us-ascii?Q?tWYFp1RMeS+DEh4gOgvdHN3EDZgrwcYBwD9ZYhQ6AkinEpA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1296;5:rUDnUs+WQc6Mm+SksjQYv3EiRpOxOZ5GPrOb1vei9TuoTlUoCKao3TZocKgdwBtus4VinzX3x2qkO8U9tN/ZSn3oAcZcI/p23SE32YCVoEnuPqSg31ITotsNG1MhP3w9wwJw6rFk9DaNI9w+x+dEXA==;24:a0FZUsxUYFxEnnpL7slMhnVpTKhrSpcOimLRdKfuahnvSsnluLVymfYIUHdJfZyjXyo69sun75bsHYgq0zL6s+Ce+ZAmildEutK/gGn/YNQ=;20:GaMZpEIogiRXxq7lTevXdObZy7usB5hnAHlJlt8XbNkk89SPQpN3+QQ1vA24a7k2qcrrEOKna7NLQW0OeXRj3g== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2015 12:53:24.0825 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB1296 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 13601 Lines: 411 In the last stage of deep sleep, software will trigger a Finite State Machine (FSM) to control the hardware precedure, such as board isolation, killing PLLs, removing power, and so on. When the system is waked up by an interrupt, the FSM controls the hardware to complete the early resume precedure. This patch configure the EPU FSM preparing for deep sleep. Signed-off-by: Chenhui Zhao --- arch/powerpc/platforms/85xx/Makefile | 2 +- arch/powerpc/platforms/85xx/sleep_fsm.c | 256 ++++++++++++++++++++++++++++++++ arch/powerpc/platforms/85xx/sleep_fsm.h | 104 +++++++++++++ 3 files changed, 361 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/platforms/85xx/sleep_fsm.c create mode 100644 arch/powerpc/platforms/85xx/sleep_fsm.h diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile index fdae28b..87fb847 100644 --- a/arch/powerpc/platforms/85xx/Makefile +++ b/arch/powerpc/platforms/85xx/Makefile @@ -3,7 +3,7 @@ # obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_FSL_PMC) += mpc85xx_pm_ops.o -obj-$(CONFIG_FSL_QORIQ_PM) += qoriq_pm.o +obj-$(CONFIG_FSL_QORIQ_PM) += qoriq_pm.o sleep_fsm.o obj-y += common.o diff --git a/arch/powerpc/platforms/85xx/sleep_fsm.c b/arch/powerpc/platforms/85xx/sleep_fsm.c new file mode 100644 index 0000000..2e81d37 --- /dev/null +++ b/arch/powerpc/platforms/85xx/sleep_fsm.c @@ -0,0 +1,256 @@ +/* + * Freescale deep sleep FSM (finite-state machine) configuration + * + * Copyright 2015 Freescale Semiconductor Inc. + * + * Author: Hongbo Zhang + * Chenhui Zhao + * + * 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 the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include + +#include "sleep_fsm.h" +/* + * These values are from chip's reference manual. For example, + * the values for T1040 can be found in "8.4.3.8 Programming + * supporting deep sleep mode" of Chapter 8 "Run Control and + * Power Management (RCPM)". + * The default value can be applied to T104x, LS1021. + */ +struct fsm_reg_vals epu_default_val[] = { + /* EPGCR (Event Processor Global Control Register) */ + {EPGCR, 0}, + /* EPECR (Event Processor Event Control Registers) */ + {EPECR0 + EPECR_STRIDE * 0, 0}, + {EPECR0 + EPECR_STRIDE * 1, 0}, + {EPECR0 + EPECR_STRIDE * 2, 0xF0004004}, + {EPECR0 + EPECR_STRIDE * 3, 0x80000084}, + {EPECR0 + EPECR_STRIDE * 4, 0x20000084}, + {EPECR0 + EPECR_STRIDE * 5, 0x08000004}, + {EPECR0 + EPECR_STRIDE * 6, 0x80000084}, + {EPECR0 + EPECR_STRIDE * 7, 0x80000084}, + {EPECR0 + EPECR_STRIDE * 8, 0x60000084}, + {EPECR0 + EPECR_STRIDE * 9, 0x08000084}, + {EPECR0 + EPECR_STRIDE * 10, 0x42000084}, + {EPECR0 + EPECR_STRIDE * 11, 0x90000084}, + {EPECR0 + EPECR_STRIDE * 12, 0x80000084}, + {EPECR0 + EPECR_STRIDE * 13, 0x08000084}, + {EPECR0 + EPECR_STRIDE * 14, 0x02000084}, + {EPECR0 + EPECR_STRIDE * 15, 0x00000004}, + /* + * EPEVTCR (Event Processor EVT Pin Control Registers) + * SCU8 triger EVT2, and SCU11 triger EVT9 + */ + {EPEVTCR0 + EPEVTCR_STRIDE * 0, 0}, + {EPEVTCR0 + EPEVTCR_STRIDE * 1, 0}, + {EPEVTCR0 + EPEVTCR_STRIDE * 2, 0x80000001}, + {EPEVTCR0 + EPEVTCR_STRIDE * 3, 0}, + {EPEVTCR0 + EPEVTCR_STRIDE * 4, 0}, + {EPEVTCR0 + EPEVTCR_STRIDE * 5, 0}, + {EPEVTCR0 + EPEVTCR_STRIDE * 6, 0}, + {EPEVTCR0 + EPEVTCR_STRIDE * 7, 0}, + {EPEVTCR0 + EPEVTCR_STRIDE * 8, 0}, + {EPEVTCR0 + EPEVTCR_STRIDE * 9, 0xB0000001}, + /* EPCMPR (Event Processor Counter Compare Registers) */ + {EPCMPR0 + EPCMPR_STRIDE * 0, 0}, + {EPCMPR0 + EPCMPR_STRIDE * 1, 0}, + {EPCMPR0 + EPCMPR_STRIDE * 2, 0x000000FF}, + {EPCMPR0 + EPCMPR_STRIDE * 3, 0}, + {EPCMPR0 + EPCMPR_STRIDE * 4, 0x000000FF}, + {EPCMPR0 + EPCMPR_STRIDE * 5, 0x00000020}, + {EPCMPR0 + EPCMPR_STRIDE * 6, 0}, + {EPCMPR0 + EPCMPR_STRIDE * 7, 0}, + {EPCMPR0 + EPCMPR_STRIDE * 8, 0x000000FF}, + {EPCMPR0 + EPCMPR_STRIDE * 9, 0x000000FF}, + {EPCMPR0 + EPCMPR_STRIDE * 10, 0x000000FF}, + {EPCMPR0 + EPCMPR_STRIDE * 11, 0x000000FF}, + {EPCMPR0 + EPCMPR_STRIDE * 12, 0x000000FF}, + {EPCMPR0 + EPCMPR_STRIDE * 13, 0}, + {EPCMPR0 + EPCMPR_STRIDE * 14, 0x000000FF}, + {EPCMPR0 + EPCMPR_STRIDE * 15, 0x000000FF}, + /* EPCCR (Event Processor Counter Control Registers) */ + {EPCCR0 + EPCCR_STRIDE * 0, 0}, + {EPCCR0 + EPCCR_STRIDE * 1, 0}, + {EPCCR0 + EPCCR_STRIDE * 2, 0x92840000}, + {EPCCR0 + EPCCR_STRIDE * 3, 0}, + {EPCCR0 + EPCCR_STRIDE * 4, 0x92840000}, + {EPCCR0 + EPCCR_STRIDE * 5, 0x92840000}, + {EPCCR0 + EPCCR_STRIDE * 6, 0}, + {EPCCR0 + EPCCR_STRIDE * 7, 0}, + {EPCCR0 + EPCCR_STRIDE * 8, 0x92840000}, + {EPCCR0 + EPCCR_STRIDE * 9, 0x92840000}, + {EPCCR0 + EPCCR_STRIDE * 10, 0x92840000}, + {EPCCR0 + EPCCR_STRIDE * 11, 0x92840000}, + {EPCCR0 + EPCCR_STRIDE * 12, 0x92840000}, + {EPCCR0 + EPCCR_STRIDE * 13, 0}, + {EPCCR0 + EPCCR_STRIDE * 14, 0x92840000}, + {EPCCR0 + EPCCR_STRIDE * 15, 0x92840000}, + /* EPSMCR (Event Processor SCU Mux Control Registers) */ + {EPSMCR0 + EPSMCR_STRIDE * 0, 0}, + {EPSMCR0 + EPSMCR_STRIDE * 1, 0}, + {EPSMCR0 + EPSMCR_STRIDE * 2, 0x6C700000}, + {EPSMCR0 + EPSMCR_STRIDE * 3, 0x2F000000}, + {EPSMCR0 + EPSMCR_STRIDE * 4, 0x002F0000}, + {EPSMCR0 + EPSMCR_STRIDE * 5, 0x00002E00}, + {EPSMCR0 + EPSMCR_STRIDE * 6, 0x7C000000}, + {EPSMCR0 + EPSMCR_STRIDE * 7, 0x30000000}, + {EPSMCR0 + EPSMCR_STRIDE * 8, 0x64300000}, + {EPSMCR0 + EPSMCR_STRIDE * 9, 0x00003000}, + {EPSMCR0 + EPSMCR_STRIDE * 10, 0x65000030}, + {EPSMCR0 + EPSMCR_STRIDE * 11, 0x31740000}, + {EPSMCR0 + EPSMCR_STRIDE * 12, 0x7F000000}, + {EPSMCR0 + EPSMCR_STRIDE * 13, 0x00003100}, + {EPSMCR0 + EPSMCR_STRIDE * 14, 0x00000031}, + {EPSMCR0 + EPSMCR_STRIDE * 15, 0x76000000}, + /* EPACR (Event Processor Action Control Registers) */ + {EPACR0 + EPACR_STRIDE * 0, 0}, + {EPACR0 + EPACR_STRIDE * 1, 0}, + {EPACR0 + EPACR_STRIDE * 2, 0}, + {EPACR0 + EPACR_STRIDE * 3, 0x00000080}, + {EPACR0 + EPACR_STRIDE * 4, 0}, + {EPACR0 + EPACR_STRIDE * 5, 0x00000040}, + {EPACR0 + EPACR_STRIDE * 6, 0}, + {EPACR0 + EPACR_STRIDE * 7, 0}, + {EPACR0 + EPACR_STRIDE * 8, 0}, + {EPACR0 + EPACR_STRIDE * 9, 0x0000001C}, + {EPACR0 + EPACR_STRIDE * 10, 0x00000020}, + {EPACR0 + EPACR_STRIDE * 11, 0}, + {EPACR0 + EPACR_STRIDE * 12, 0x00000003}, + {EPACR0 + EPACR_STRIDE * 13, 0x06000000}, + {EPACR0 + EPACR_STRIDE * 14, 0x04000000}, + {EPACR0 + EPACR_STRIDE * 15, 0x02000000}, + /* EPIMCR (Event Processor Input Mux Control Registers) */ + {EPIMCR0 + EPIMCR_STRIDE * 0, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 1, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 2, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 3, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 4, 0x44000000}, + {EPIMCR0 + EPIMCR_STRIDE * 5, 0x40000000}, + {EPIMCR0 + EPIMCR_STRIDE * 6, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 7, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 8, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 9, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 10, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 11, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 12, 0x44000000}, + {EPIMCR0 + EPIMCR_STRIDE * 13, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 14, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 15, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 16, 0x6A000000}, + {EPIMCR0 + EPIMCR_STRIDE * 17, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 18, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 19, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 20, 0x48000000}, + {EPIMCR0 + EPIMCR_STRIDE * 21, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 22, 0x6C000000}, + {EPIMCR0 + EPIMCR_STRIDE * 23, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 24, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 25, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 26, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 27, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 28, 0x76000000}, + {EPIMCR0 + EPIMCR_STRIDE * 29, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 30, 0}, + {EPIMCR0 + EPIMCR_STRIDE * 31, 0x76000000}, + /* EPXTRIGCR (Event Processor Crosstrigger Control Register) */ + {EPXTRIGCR, 0x0000FFDF}, + /* end */ + {FSM_END_FLAG, 0}, +}; + +struct fsm_reg_vals npc_default_val[] = { + /* NPC triggered Memory-Mapped Access Registers */ + {NCR, 0x80000000}, + {MCCR1, 0}, + {MCSR1, 0}, + {MMAR1LO, 0}, + {MMAR1HI, 0}, + {MMDR1, 0}, + {MCSR2, 0}, + {MMAR2LO, 0}, + {MMAR2HI, 0}, + {MMDR2, 0}, + {MCSR3, 0x80000000}, + {MMAR3LO, 0x000E2130}, + {MMAR3HI, 0x00030000}, + {MMDR3, 0x00020000}, + /* end */ + {FSM_END_FLAG, 0}, +}; + +/** + * fsl_fsm_setup - Configure EPU's FSM registers + * @base: the base address of registers + * @val: Pointer to address-value pairs for FSM registers + */ +void fsl_fsm_setup(void __iomem *base, struct fsm_reg_vals *val) +{ + struct fsm_reg_vals *data = val; + + BUG_ON(!base || !data); + while (data->offset != FSM_END_FLAG) { + iowrite32be(data->value, base + data->offset); + data++; + } +} + +void fsl_epu_setup_default(void __iomem *epu_base) +{ + fsl_fsm_setup(epu_base, epu_default_val); +} + +void fsl_npc_setup_default(void __iomem *npc_base) +{ + fsl_fsm_setup(npc_base, npc_default_val); +} + +void fsl_epu_clean_default(void __iomem *epu_base) +{ + u32 offset; + + /* follow the exact sequence to clear the registers */ + /* Clear EPACRn */ + for (offset = EPACR0; offset <= EPACR15; offset += EPACR_STRIDE) + iowrite32be(0, epu_base + offset); + + /* Clear EPEVTCRn */ + for (offset = EPEVTCR0; offset <= EPEVTCR9; offset += EPEVTCR_STRIDE) + iowrite32be(0, epu_base + offset); + + /* Clear EPGCR */ + iowrite32be(0, epu_base + EPGCR); + + /* Clear EPSMCRn */ + for (offset = EPSMCR0; offset <= EPSMCR15; offset += EPSMCR_STRIDE) + iowrite32be(0, epu_base + offset); + + /* Clear EPCCRn */ + for (offset = EPCCR0; offset <= EPCCR31; offset += EPCCR_STRIDE) + iowrite32be(0, epu_base + offset); + + /* Clear EPCMPRn */ + for (offset = EPCMPR0; offset <= EPCMPR31; offset += EPCMPR_STRIDE) + iowrite32be(0, epu_base + offset); + + /* Clear EPCTRn */ + for (offset = EPCTR0; offset <= EPCTR31; offset += EPCTR_STRIDE) + iowrite32be(0, epu_base + offset); + + /* Clear EPIMCRn */ + for (offset = EPIMCR0; offset <= EPIMCR31; offset += EPIMCR_STRIDE) + iowrite32be(0, epu_base + offset); + + /* Clear EPXTRIGCRn */ + iowrite32be(0, epu_base + EPXTRIGCR); + + /* Clear EPECRn */ + for (offset = EPECR0; offset <= EPECR15; offset += EPECR_STRIDE) + iowrite32be(0, epu_base + offset); +} diff --git a/arch/powerpc/platforms/85xx/sleep_fsm.h b/arch/powerpc/platforms/85xx/sleep_fsm.h new file mode 100644 index 0000000..2c60b40 --- /dev/null +++ b/arch/powerpc/platforms/85xx/sleep_fsm.h @@ -0,0 +1,104 @@ +/* + * Freescale deep sleep FSM (finite-state machine) configuration + * + * Copyright 2015 Freescale Semiconductor Inc. + * + * 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 the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ +#ifndef _FSL_SLEEP_FSM_H +#define _FSL_SLEEP_FSM_H + +#define FSL_STRIDE_4B 4 +#define FSL_STRIDE_8B 8 + +/* End flag */ +#define FSM_END_FLAG 0xFFFFFFFFUL + +/* Block offsets */ +#define RCPM_BLOCK_OFFSET 0x00022000 +#define EPU_BLOCK_OFFSET 0x00000000 +#define NPC_BLOCK_OFFSET 0x00001000 + +/* EPGCR (Event Processor Global Control Register) */ +#define EPGCR 0x000 + +/* EPEVTCR0-9 (Event Processor EVT Pin Control Registers) */ +#define EPEVTCR0 0x050 +#define EPEVTCR9 0x074 +#define EPEVTCR_STRIDE FSL_STRIDE_4B + +/* EPXTRIGCR (Event Processor Crosstrigger Control Register) */ +#define EPXTRIGCR 0x090 + +/* EPIMCR0-31 (Event Processor Input Mux Control Registers) */ +#define EPIMCR0 0x100 +#define EPIMCR31 0x17C +#define EPIMCR_STRIDE FSL_STRIDE_4B + +/* EPSMCR0-15 (Event Processor SCU Mux Control Registers) */ +#define EPSMCR0 0x200 +#define EPSMCR15 0x278 +#define EPSMCR_STRIDE FSL_STRIDE_8B + +/* EPECR0-15 (Event Processor Event Control Registers) */ +#define EPECR0 0x300 +#define EPECR15 0x33C +#define EPECR_STRIDE FSL_STRIDE_4B + +/* EPACR0-15 (Event Processor Action Control Registers) */ +#define EPACR0 0x400 +#define EPACR15 0x43C +#define EPACR_STRIDE FSL_STRIDE_4B + +/* EPCCRi0-15 (Event Processor Counter Control Registers) */ +#define EPCCR0 0x800 +#define EPCCR15 0x83C +#define EPCCR31 0x87C +#define EPCCR_STRIDE FSL_STRIDE_4B + +/* EPCMPR0-15 (Event Processor Counter Compare Registers) */ +#define EPCMPR0 0x900 +#define EPCMPR15 0x93C +#define EPCMPR31 0x97C +#define EPCMPR_STRIDE FSL_STRIDE_4B + +/* EPCTR0-31 (Event Processor Counter Register) */ +#define EPCTR0 0xA00 +#define EPCTR31 0xA7C +#define EPCTR_STRIDE FSL_STRIDE_4B + +/* NPC triggered Memory-Mapped Access Registers */ +#define NCR 0x000 +#define MCCR1 0x0CC +#define MCSR1 0x0D0 +#define MMAR1LO 0x0D4 +#define MMAR1HI 0x0D8 +#define MMDR1 0x0DC +#define MCSR2 0x0E0 +#define MMAR2LO 0x0E4 +#define MMAR2HI 0x0E8 +#define MMDR2 0x0EC +#define MCSR3 0x0F0 +#define MMAR3LO 0x0F4 +#define MMAR3HI 0x0F8 +#define MMDR3 0x0FC + +/* RCPM Core State Action Control Register 0 */ +#define CSTTACR0 0xB00 + +/* RCPM Core Group 1 Configuration Register 0 */ +#define CG1CR0 0x31C + +struct fsm_reg_vals { + u32 offset; + u32 value; +}; + +void fsl_epu_setup_default(void __iomem *epu_base); +void fsl_npc_setup_default(void __iomem *npc_base); +void fsl_epu_clean_default(void __iomem *epu_base); + +#endif /* _FSL_SLEEP_FSM_H */ -- 1.9.1 -- 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/