From patchwork Fri Aug 12 08:30:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 3417 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 B18E023F4D for ; Fri, 12 Aug 2011 08:30:32 +0000 (UTC) Received: from mail-qy0-f173.google.com (mail-qy0-f173.google.com [209.85.216.173]) by fiordland.canonical.com (Postfix) with ESMTP id 62203A18756 for ; Fri, 12 Aug 2011 08:30:32 +0000 (UTC) Received: by qyk31 with SMTP id 31so248596qyk.11 for ; Fri, 12 Aug 2011 01:30:31 -0700 (PDT) Received: by 10.229.62.150 with SMTP id x22mr429451qch.136.1313137831894; Fri, 12 Aug 2011 01:30:31 -0700 (PDT) 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.229.190.71 with SMTP id dh7cs141514qcb; Fri, 12 Aug 2011 01:30:31 -0700 (PDT) Received: from mr.google.com ([10.213.9.71]) by 10.213.9.71 with SMTP id k7mr537665ebk.136.1313137831549 (num_hops = 1); Fri, 12 Aug 2011 01:30:31 -0700 (PDT) Received: by 10.213.9.71 with SMTP id k7mr392231ebk.136.1313137830823; Fri, 12 Aug 2011 01:30:30 -0700 (PDT) Received: from eu1sys200aog104.obsmtp.com (eu1sys200aog104.obsmtp.com [207.126.144.117]) by mx.google.com with SMTP id e19si2006766eeb.110.2011.08.12.01.30.21 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 12 Aug 2011 01:30:30 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.117 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.117; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.117 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob104.postini.com ([207.126.147.11]) with SMTP ID DSNKTkTknWGuQKRvZGTd5DlcgmFZP/9FflNa@postini.com; Fri, 12 Aug 2011 08:30:30 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id A377B58; Fri, 12 Aug 2011 08:30:06 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 1F8FE59; Fri, 12 Aug 2011 08:30:06 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id E8D4224C075; Fri, 12 Aug 2011 10:30:00 +0200 (CEST) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 12 Aug 2011 10:30:05 +0200 From: Linus Walleij To: Samuel Ortiz , Cc: Lee Jones , Shreshtha Kumar Sahu , Linus Walleij Subject: [PATCH 18/23] mfd/db5500-prcmu: implement OPP handling Date: Fri, 12 Aug 2011 10:30:02 +0200 Message-ID: <1313137802-31180-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.3.2 MIME-Version: 1.0 From: Shreshtha Kumar Sahu This implements the ARM OPP accessor functions necessary to implement CPUfreq frequency scaling on the DB5500 PRCMU. Signed-off-by: Shreshtha Kumar Sahu Signed-off-by: Linus Walleij --- drivers/mfd/db5500-prcmu.c | 94 ++++++++++++++++++++++++++++++++++++++ include/linux/mfd/dbx500-prcmu.h | 4 +- 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/db5500-prcmu.c b/drivers/mfd/db5500-prcmu.c index 91bb353..35a7a0c 100644 --- a/drivers/mfd/db5500-prcmu.c +++ b/drivers/mfd/db5500-prcmu.c @@ -814,6 +814,100 @@ int db5500_prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size) return r; } +/** + * db5500_prcmu_set_arm_opp - set the appropriate ARM OPP + * @opp: The new ARM operating point to which transition is to be made + * Returns: 0 on success, non-zero on failure + * + * This function sets the the operating point of the ARM. + */ +int db5500_prcmu_set_arm_opp(u8 opp) +{ + int r; + u8 db5500_opp; + + r = 0; + + switch (opp) { + case ARM_EXTCLK: + db5500_opp = DB5500_ARM_EXT_OPP; + break; + case ARM_50_OPP: + db5500_opp = DB5500_ARM_50_OPP; + break; + case ARM_100_OPP: + db5500_opp = DB5500_ARM_100_OPP; + break; + default: + pr_err("prcmu: %s() received wrong opp value: %d\n", + __func__, opp); + r = -EINVAL; + goto bailout; + } + + mutex_lock(&mb1_transfer.lock); + + while (readl(PRCM_MBOX_CPU_VAL) & MBOX_BIT(1)) + cpu_relax(); + + writeb(MB1H_ARM_OPP, PRCM_REQ_MB1_HEADER); + + writeb(db5500_opp, PRCM_REQ_MB1_ARM_OPP); + writel(MBOX_BIT(1), PRCM_MBOX_CPU_SET); + + if (!wait_for_completion_timeout(&mb1_transfer.work, + msecs_to_jiffies(500))) { + r = -EIO; + WARN(1, "prcmu: failed to set arm opp"); + goto unlock_and_return; + } + + if (mb1_transfer.ack.header != MB1H_ARM_OPP || + (mb1_transfer.ack.arm_opp != db5500_opp) || + (mb1_transfer.ack.arm_voltage_st != RC_SUCCESS)) + r = -EIO; + +unlock_and_return: + mutex_unlock(&mb1_transfer.lock); +bailout: + return r; +} + +/** + * db5500_prcmu_get_arm_opp - get the current ARM OPP + * + * Returns: the current ARM OPP + */ +int db5500_prcmu_get_arm_opp(void) +{ + return readb(PRCM_ACK_MB1_CURRENT_ARM_OPP); +} + +int prcmu_resetout(u8 resoutn, u8 state) +{ + int pin = -1; + + switch (resoutn) { + case 0: + pin = PRCMU_RESOUTN0_PIN; + break; + case 1: + pin = PRCMU_RESOUTN1_PIN; + break; + case 2: + pin = PRCMU_RESOUTN2_PIN; + default: + break; + } + + if (pin > 0) + writel(pin, state > 0 ? PRCM_RESOUTN_SET : PRCM_RESOUTN_CLR); + else + return -EINVAL; + + return 0; +} + int db5500_prcmu_enable_dsipll(void) { int i; diff --git a/include/linux/mfd/dbx500-prcmu.h b/include/linux/mfd/dbx500-prcmu.h index e8541ff..78258c4 100644 --- a/include/linux/mfd/dbx500-prcmu.h +++ b/include/linux/mfd/dbx500-prcmu.h @@ -295,7 +295,7 @@ int prcmu_get_ddr_opp(void); static inline int prcmu_set_arm_opp(u8 opp) { if (machine_is_u5500()) - return -EINVAL; + return db5500_prcmu_set_arm_opp(opp); else return db8500_prcmu_set_arm_opp(opp); } @@ -303,7 +303,7 @@ static inline int prcmu_set_arm_opp(u8 opp) static inline int prcmu_get_arm_opp(void) { if (machine_is_u5500()) - return -EINVAL; + return db5500_prcmu_get_arm_opp(); else return db8500_prcmu_get_arm_opp(); }