From patchwork Mon Nov 24 13:04:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kachhap X-Patchwork-Id: 5366211 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 257C89F2F5 for ; Mon, 24 Nov 2014 13:20:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2EE16203F3 for ; Mon, 24 Nov 2014 13:19:55 +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 51549203E3 for ; Mon, 24 Nov 2014 13:19:50 +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 1XstVq-000336-Lz; Mon, 24 Nov 2014 13:17:06 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XstVg-0002nC-HF for linux-arm-kernel@lists.infradead.org; Mon, 24 Nov 2014 13:16:57 +0000 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NFJ004D7OVMSMD0@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Mon, 24 Nov 2014 22:16:34 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id C4.21.18167.2BF23745; Mon, 24 Nov 2014 22:16:34 +0900 (KST) X-AuditID: cbfee690-f79ab6d0000046f7-b3-54732fb2bdb3 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 58.F5.20081.2BF23745; Mon, 24 Nov 2014 22:16:34 +0900 (KST) Received: from chromebld-server.sisodomain.com ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NFJ00EZLOLG6V60@mmp2.samsung.com>; Mon, 24 Nov 2014 22:16:34 +0900 (KST) From: Amit Daniel Kachhap To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH RFC v2 06/12] driver: soc: exynos-pmu: Add exynos7 power domain on/off ops Date: Mon, 24 Nov 2014 18:34:10 +0530 Message-id: <1416834256-11225-6-git-send-email-amit.daniel@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1416834256-11225-1-git-send-email-amit.daniel@samsung.com> References: <1416833572-6880-1-git-send-email-amit.daniel@samsung.com> <1416834256-11225-1-git-send-email-amit.daniel@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeLIzCtJLcpLzFFi42JZI2JSrbtJvzjEoH2OjEXD1RCL+UfOsVo8 u7WXyaJ3wVU2i6ebHzNZbHp8jdXi8q45bBafe48wWsw4v4/JYtHWL+wWZ05fYrU4/Kad1eL4 2nAHXo9NqzrZPO5c28PmcehwB6PH5iX1HluutrN49G1ZxejxeZNcAHsUl01Kak5mWWqRvl0C V8bth9dZC5rMKx6sOsnUwLhUv4uRk0NCwERi+9f3zBC2mMSFe+vZuhi5OIQEljJKLLq2gxWm 6MbrVnaIxHRGib7rvUwQzgQmieU/ZrOBVLEJGEv83LkfqIqDQ0TAW2L5NUWQGmaB1UwSW9s/ MIHUCAvESNzePosdxGYRUJW43fkKLM4r4C5x7u8iJpBeCQEFiTmTbEDCnAIeEi8OtjBD7Gph lLj0eC4riC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vKGxibmpsamliYWJmaWSOO+Nm7khQgLpiSWp2ampBalFMH1MHJxSDYxa0rdl +Zi0ajP3dpv3bGk/f5bHcP3tszwSbjyMhx9nPBV+xylt+try9r4i9h0Xb833dF2UFV8xvSPe bKHDadb4jhnWd01vcG19w3SPWTiH7YClUx1zs4rzqrUZ3XudhNauvTL5Kod8gbVxj5XZx4Mc pvlprG9NA/q65R8u7ok5W9Qvd5wvUYmlOCPRUIu5qDgRALRyY6PeAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141124_051656_733272_ACDDDEC1 X-CRM114-Status: GOOD ( 12.69 ) X-Spam-Score: -5.0 (-----) Cc: devicetree@vger.kernel.org, ulf.hansson@linaro.org, kgene.kim@samsung.com, khilman@kernel.org, pankaj.dubey@samsung.com, linux-pm@vger.kernel.org, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, Amit Daniel Kachhap , geert@linux-m68k.org, s.nawrocki@samsung.com 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, 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 This patch uses the restructuring done in PD handlers and adds PD on/off/status handlers for exynos7. In this SoC, some extra settings need to be done prior to turning on/off power domains. Some of those settings are also different from different power domains so is uses the power domain compatible name feature to distinguish between power domains. Signed-off-by: Amit Daniel Kachhap --- drivers/soc/samsung/exynos-pmu.c | 105 +++++++++++++++++++++++++++ include/linux/soc/samsung/exynos-regs-pmu.h | 17 +++++ 2 files changed, 122 insertions(+) diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-pmu.c index e690f65..b9631d5 100644 --- a/drivers/soc/samsung/exynos-pmu.c +++ b/drivers/soc/samsung/exynos-pmu.c @@ -1202,6 +1202,104 @@ static void exynos7_pmu_init(void) } } +static int exynos7_pd_extraconf_base(const char *pd_name) +{ + if (!pd_name) + return -EINVAL; + + if (!strcmp("samsung,exynos7-pd-mfc", pd_name)) + return EXYNOS7_CLKRUN_CMU_MFC_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-hevc", pd_name)) + return EXYNOS7_CLKRUN_CMU_HEVC_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-mscl", pd_name)) + return EXYNOS7_CLKRUN_CMU_MSCL_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-g2d", pd_name)) + return EXYNOS7_CLKRUN_CMU_G2D_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-fsys0", pd_name)) + return EXYNOS7_CLKRUN_CMU_FSYS0_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-fsys1", pd_name)) + return EXYNOS7_CLKRUN_CMU_FSYS1_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-aud", pd_name)) + return EXYNOS7_CLKRUN_CMU_AUD_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-disp", pd_name)) + return EXYNOS7_CLKRUN_CMU_DISP_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-vpp", pd_name)) + return EXYNOS7_CLKRUN_CMU_VPP_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-vpp", pd_name)) + return EXYNOS7_CLKRUN_CMU_VPP_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-isp0", pd_name)) + return EXYNOS7_CLKRUN_CMU_ISP0_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-isp1", pd_name)) + return EXYNOS7_CLKRUN_CMU_ISP1_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-cam0", pd_name)) + return EXYNOS7_CLKRUN_CMU_CAM0_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-cam1", pd_name)) + return EXYNOS7_CLKRUN_CMU_CAM1_SYS_PWR_REG; + else if (!strcmp("samsung,exynos7-pd-g3d", pd_name)) + return EXYNOS7_CLKRUN_CMU_CAM1_SYS_PWR_REG; + + pr_err("%s: Unsupported power domain\n", pd_name); + return 0; +} + +static int exynos7_pd_powerdown(const char *pd_name, void __iomem *pd_addr) +{ + int off_base = exynos7_pd_extraconf_base(pd_name); + + if (!off_base) + return -EINVAL; + + /* Initialise the pd extraconf registers */ + pmu_raw_writel(0, off_base + EXYNOS7_CLKRUN_CMU_PD_SYS_PWR_REG); + pmu_raw_writel(0, off_base + EXYNOS7_CLKSTOP_CMU_PD_SYS_PWR_REG); + pmu_raw_writel(0, off_base + EXYNOS7_DISABLE_PLL_CMU_PD_SYS_PWR_REG); + pmu_raw_writel(0, off_base + EXYNOS7_RESET_LOGIC_PD_SYS_PWR_REG); + pmu_raw_writel(0, off_base + EXYNOS7_MEMORY_PD_SYS_PWR_REG); + pmu_raw_writel(0, off_base + EXYNOS7_RESET_CMU_PD_SYS_PWR_REG); + + if (!strcmp("samsung,exynos7-pd-fsys0", pd_name) || + !strcmp("samsung,exynos7-pd-fsys1", pd_name)) + pmu_raw_writel(1, + off_base + EXYNOS7_RESET_SLEEP_PD_SYS_PWR_REG); + + if (!strcmp("samsung,exynos7-pd-aud", pd_name)) { + pmu_raw_writel(0, EXYNOS7_PAD_RETENTION_AUD_SYS_PWR_REG); + pmu_raw_writel(0, EXYNOS7_GPIO_MODE_AUD_SYS_PWR_REG); + } + + writel_relaxed((EXYNOS7_USE_PROLONGED_LOGIC_RESET | + EXYNOS7_USE_SC_FEEDBACK), pd_addr + EXYNOS_PD_OPTION); + + return 0; +} + +static int exynos7_pd_poweron(const char *pd_name, void __iomem *pd_addr) +{ + if (exynos7_pd_powerdown(pd_name, pd_addr)) + return -EINVAL; + + return __exynos_pd_poweron_off(true, pd_name, pd_addr, + EXYNOS7_INT_LOCAL_PWR_EN); +} + +static int exynos7_pd_poweroff(const char *pd_name, void __iomem *pd_addr) +{ + if (exynos7_pd_powerdown(pd_name, pd_addr)) + return -EINVAL; + + return __exynos_pd_poweron_off(false, pd_name, pd_addr, + EXYNOS7_INT_LOCAL_PWR_EN); +} + +static bool exynos7_pd_status(void __iomem *pd_addr) +{ + unsigned int val; + + val = readl_relaxed(pd_addr + EXYNOS_PD_STATUS) & + EXYNOS7_INT_LOCAL_PWR_EN; + return val ? true : false; +} + static struct exynos_pmu_pd_ops exynos_pd_ops = { .pd_on = exynos_pd_poweron, .pd_off = exynos_pd_poweroff, @@ -1238,12 +1336,19 @@ static struct exynos_pmu_data exynos5420_pmu_data = { .pd_ops = &exynos_pd_ops, }; +static struct exynos_pmu_pd_ops exynos7_pd_ops = { + .pd_on = exynos7_pd_poweron, + .pd_off = exynos7_pd_poweroff, + .pd_status = exynos7_pd_status, +}; + static const struct exynos_pmu_data exynos7_pmu_data = { .pmu_config = exynos7_pmu_config, .pmu_init = exynos7_pmu_init, .pmu_config_extra = exynos7_pmu_config_extra, .powerdown_conf = exynos7_powerdown_conf, .powerup_conf = exynos7_powerup_conf, + .pd_ops = &exynos7_pd_ops, }; /* diff --git a/include/linux/soc/samsung/exynos-regs-pmu.h b/include/linux/soc/samsung/exynos-regs-pmu.h index c61f91a..520595f 100644 --- a/include/linux/soc/samsung/exynos-regs-pmu.h +++ b/include/linux/soc/samsung/exynos-regs-pmu.h @@ -680,6 +680,8 @@ static inline unsigned int exynos_pmu_cpunr(unsigned int mpidr) #define EXYNOS7_VPP_SYS_PWR_REG (0x1438) #define EXYNOS7_CLKRUN_CMU_AUD_SYS_PWR_REG (0x1440) #define EXYNOS7_CLKRUN_CMU_BUS0_SYS_PWR_REG (0x1444) +#define EXYNOS7_CLKRUN_CMU_CAM0_SYS_PWR_REG (0x1448) +#define EXYNOS7_CLKRUN_CMU_CAM1_SYS_PWR_REG (0x144C) #define EXYNOS7_CLKRUN_CMU_DISP_SYS_PWR_REG (0x1450) #define EXYNOS7_CLKRUN_CMU_FSYS0_SYS_PWR_REG (0x1454) #define EXYNOS7_CLKRUN_CMU_FSYS1_SYS_PWR_REG (0x1458) @@ -824,6 +826,7 @@ static inline unsigned int exynos_pmu_cpunr(unsigned int mpidr) #define EXYNOS7_USE_STANDBYWFI (0x1 << 16) #define EXYNOS7_USE_SC_FEEDBACK (0x1 << 1) #define EXYNOS7_USE_SC_COUNTER (0x1 << 0) +#define EXYNOS7_USE_PROLONGED_LOGIC_RESET (0x1 << 8) /* EXYNOS7_PAD_RETENTION_AUD_OPTION */ #define PAD_INITIATE_WAKEUP (0x1 << 28) @@ -841,4 +844,18 @@ static inline unsigned int exynos_pmu_cpunr(unsigned int mpidr) #define EXYNOS7_CORE_ARMCLK_STOPCTRL (0x1000) +#define EXYNOS7_INT_LOCAL_PWR_EN 0xF + +/* + * Power domain register offsets from the EXYNOS7 + * CLKRUN_CMU_HEVC_SYS_PWR_REG configuration register. + */ +#define EXYNOS7_CLKRUN_CMU_PD_SYS_PWR_REG (0x0) +#define EXYNOS7_CLKSTOP_CMU_PD_SYS_PWR_REG (0x40) +#define EXYNOS7_DISABLE_PLL_CMU_PD_SYS_PWR_REG (0x80) +#define EXYNOS7_RESET_LOGIC_PD_SYS_PWR_REG (0xC0) +#define EXYNOS7_MEMORY_PD_SYS_PWR_REG (0x100) +#define EXYNOS7_RESET_CMU_PD_SYS_PWR_REG (0x140) +#define EXYNOS7_RESET_SLEEP_PD_SYS_PWR_REG (0x180) + #endif /* __ASM_ARCH_REGS_PMU_H */