From patchwork Fri Feb 10 10:22:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 6752 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8705723ECC for ; Fri, 10 Feb 2012 10:22:35 +0000 (UTC) Received: from mail-tul01m020-f180.google.com (mail-tul01m020-f180.google.com [209.85.214.180]) by fiordland.canonical.com (Postfix) with ESMTP id 438C2A1833F for ; Fri, 10 Feb 2012 10:22:35 +0000 (UTC) Received: by obbuo19 with SMTP id uo19so4849772obb.11 for ; Fri, 10 Feb 2012 02:22:34 -0800 (PST) Received: by 10.50.153.133 with SMTP id vg5mr2226993igb.8.1328869354145; Fri, 10 Feb 2012 02:22:34 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.12.131 with SMTP id x3cs73353ibx; Fri, 10 Feb 2012 02:22:33 -0800 (PST) Received: by 10.216.137.210 with SMTP id y60mr557282wei.14.1328869351932; Fri, 10 Feb 2012 02:22:31 -0800 (PST) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id n21si3709210wed.13.2012.02.10.02.22.28 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 10 Feb 2012 02:22:31 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=209.85.212.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: by wibhm14 with SMTP id hm14so2407826wib.37 for ; Fri, 10 Feb 2012 02:22:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.76.235 with SMTP id n11mr2215091wiw.11.1328869348738; Fri, 10 Feb 2012 02:22:28 -0800 (PST) Received: from localhost.localdomain (AToulouse-159-1-49-54.w92-134.abo.wanadoo.fr. [92.134.80.54]) by mx.google.com with ESMTPS id n5sm16556462wiw.7.2012.02.10.02.22.26 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 10 Feb 2012 02:22:27 -0800 (PST) From: Daniel Lezcano To: srinidhi.kasagar@stericsson.com, linus.walleij@stericsson.com Cc: linux-arm-kernel@lists.infradead.org, rickard.andersson@stericsson.com, jonas.aberg@stericsson.com, patches@linaro.org, linaro-dev@lists.linaro.org Subject: [PATCH][V3] ux500 : decouple/recouple gic from the PRCMU Date: Fri, 10 Feb 2012 11:22:24 +0100 Message-Id: <1328869344-31332-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.5.4 X-Gm-Message-State: ALoCoQmiU6P6c57h4/zGTZw4pGP8sw2Bb/0Xkz8Qf24KZshzPWr1nmLunqA+c5fG3kxodfQ2Oa7c This patch allows to decouple and recouple the gic from the PRCMU. This is needed to put the A9 core in retention mode with the cpuidle driver. Signed-off-by: Daniel Lezcano --- drivers/mfd/db8500-prcmu.c | 32 ++++++++++++++++++++++++++++++++ include/linux/mfd/db8500-prcmu.h | 2 ++ include/linux/mfd/dbx500-prcmu.h | 16 ++++++++++++++++ 3 files changed, 50 insertions(+), 0 deletions(-) diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c index af8e0ef..9baf4cd 100644 --- a/drivers/mfd/db8500-prcmu.c +++ b/drivers/mfd/db8500-prcmu.c @@ -787,6 +787,38 @@ int db8500_prcmu_set_power_state(u8 state, bool keep_ulp_clk, bool keep_ap_pll) return 0; } +#define PRCMU_A9_MASK_REQ 0x00000328 +#define PRCMU_A9_MASK_REQ_MASK 0x00000001 +#define PRCMU_GIC_DELAY 1 + +/* This function decouple the gic from the prcmu */ +int db8500_prcmu_gic_decouple(void) +{ + u32 val = readl(_PRCMU_BASE + PRCMU_A9_MASK_REQ); + + /* Set bit 0 register value to 1 */ + writel(val | PRCMU_A9_MASK_REQ_MASK, _PRCMU_BASE + PRCMU_A9_MASK_REQ); + + /* Make sure the register is updated */ + readl(_PRCMU_BASE + PRCMU_A9_MASK_REQ); + + /* Wait a few cycles for the gic mask completion */ + udelay(PRCMU_GIC_DELAY); + + return 0; +} + +/* This function recouple the gic with the prcmu */ +int db8500_prcmu_gic_recouple(void) +{ + u32 val = readl(_PRCMU_BASE + PRCMU_A9_MASK_REQ); + + /* Set bit 0 register value to 0 */ + writel(val & ~PRCMU_A9_MASK_REQ_MASK, _PRCMU_BASE + PRCMU_A9_MASK_REQ); + + return 0; +} + /* This function should only be called while mb0_transfer.lock is held. */ static void config_wakeups(void) { diff --git a/include/linux/mfd/db8500-prcmu.h b/include/linux/mfd/db8500-prcmu.h index 60d27f7..a3c7eba 100644 --- a/include/linux/mfd/db8500-prcmu.h +++ b/include/linux/mfd/db8500-prcmu.h @@ -536,6 +536,8 @@ int prcmu_load_a9wdog(u8 id, u32 val); void db8500_prcmu_system_reset(u16 reset_code); int db8500_prcmu_set_power_state(u8 state, bool keep_ulp_clk, bool keep_ap_pll); +int db8500_prcmu_gic_decouple(void); +int db8500_prcmu_gic_recouple(void); void db8500_prcmu_enable_wakeups(u32 wakeups); int db8500_prcmu_set_epod(u16 epod_id, u8 epod_state); int db8500_prcmu_request_clock(u8 clock, bool enable); diff --git a/include/linux/mfd/dbx500-prcmu.h b/include/linux/mfd/dbx500-prcmu.h index bac942f..d38cf7d 100644 --- a/include/linux/mfd/dbx500-prcmu.h +++ b/include/linux/mfd/dbx500-prcmu.h @@ -237,6 +237,22 @@ static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk, keep_ap_pll); } +static inline int prcmu_gic_decouple(void) +{ + if (machine_is_u5500()) + return -EINVAL; + else + return db8500_prcmu_gic_decouple(); +} + +static inline int prcmu_gic_recouple(void) +{ + if (machine_is_u5500()) + return -EINVAL; + else + return db8500_prcmu_gic_recouple(); +} + static inline int prcmu_set_epod(u16 epod_id, u8 epod_state) { if (machine_is_u5500())