From patchwork Fri Aug 19 09:54:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 3544 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 E0CD523F36 for ; Fri, 19 Aug 2011 09:54:42 +0000 (UTC) Received: from mail-yi0-f52.google.com (mail-yi0-f52.google.com [209.85.218.52]) by fiordland.canonical.com (Postfix) with ESMTP id 9D414A183FA for ; Fri, 19 Aug 2011 09:54:42 +0000 (UTC) Received: by yie13 with SMTP id 13so2989424yie.11 for ; Fri, 19 Aug 2011 02:54:42 -0700 (PDT) Received: by 10.150.47.2 with SMTP id u2mr2015443ybu.162.1313747682067; Fri, 19 Aug 2011 02:54:42 -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.150.157.17 with SMTP id f17cs91756ybe; Fri, 19 Aug 2011 02:54:41 -0700 (PDT) Received: by 10.14.99.3 with SMTP id w3mr434699eef.4.1313747680791; Fri, 19 Aug 2011 02:54:40 -0700 (PDT) Received: from eu1sys200aog113.obsmtp.com (eu1sys200aog113.obsmtp.com [207.126.144.135]) by mx.google.com with SMTP id f51si2149920eec.111.2011.08.19.02.54.29 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Aug 2011 02:54:40 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.135 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.135; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.135 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-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob113.postini.com ([207.126.147.11]) with SMTP ID DSNKTk4y0etExJpuab55+Q2LImK/tu/XtGVT@postini.com; Fri, 19 Aug 2011 09:54:40 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 79529F2; Fri, 19 Aug 2011 09:54:18 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id DBCD1D3F; Fri, 19 Aug 2011 09:54:17 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 9BEB824C07C; Fri, 19 Aug 2011 11:54:11 +0200 (CEST) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 19 Aug 2011 11:54:16 +0200 From: Linus Walleij To: , , Grant Likely Cc: Lee Jones , Stephen Warren , Joe Perches , Russell King , Linaro Dev , Linus Walleij Subject: [PATCH 3/4 v4] amba: request muxing for PrimeCell devices Date: Fri, 19 Aug 2011 11:54:13 +0200 Message-ID: <1313747654-32328-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.3.2 MIME-Version: 1.0 From: Linus Walleij This makes the AMBA PrimeCell drivers request padmuxing for themselves in the same manner as clocks and voltage is currently requested. Signed-off-by: Linus Walleij --- drivers/amba/bus.c | 49 ++++++++++++++++++++++++++++++++++++++++++++- include/linux/amba/bus.h | 2 + 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index d74926e..bd0516c 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -474,6 +474,40 @@ static void amba_put_disable_vcore(struct amba_device *pcdev) } } +static int amba_get_enable_pinmux(struct amba_device *pcdev) +{ + struct pinmux *pmx = pinmux_get(&pcdev->dev, NULL); + int ret; + + pcdev->pmx = pmx; + + if (IS_ERR(pmx)) { + /* It is OK not to supply a pinmux regulator */ + if (PTR_ERR(pmx) == -ENODEV) + return 0; + return PTR_ERR(pmx); + } + + ret = pinmux_enable(pmx); + if (ret) { + pinmux_put(pmx); + pcdev->pmx = ERR_PTR(-ENODEV); + } + + return ret; +} + +static void amba_put_disable_pinmux(struct amba_device *pcdev) +{ + struct pinmux *pmx = pcdev->pmx; + + if (!IS_ERR(pmx)) { + pinmux_disable(pmx); + pinmux_put(pmx); + } +} + + /* * These are the device model conversion veneers; they convert the * device model structures to our more specific structures. @@ -486,13 +520,22 @@ static int amba_probe(struct device *dev) int ret; do { - ret = amba_get_enable_vcore(pcdev); + ret = amba_get_enable_pinmux(pcdev); if (ret) break; + ret = amba_get_enable_vcore(pcdev); + if (ret) { + amba_put_disable_pinmux(pcdev); + break; + } + ret = amba_get_enable_pclk(pcdev); - if (ret) + if (ret) { + amba_put_disable_pinmux(pcdev); + amba_put_disable_vcore(pcdev); break; + } ret = pcdrv->probe(pcdev, id); if (ret == 0) @@ -500,6 +543,7 @@ static int amba_probe(struct device *dev) amba_put_disable_pclk(pcdev); amba_put_disable_vcore(pcdev); + amba_put_disable_pinmux(pcdev); } while (0); return ret; @@ -513,6 +557,7 @@ static int amba_remove(struct device *dev) amba_put_disable_pclk(pcdev); amba_put_disable_vcore(pcdev); + amba_put_disable_pinmux(pcdev); return ret; } diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h index fcbbe71..35f1193 100644 --- a/include/linux/amba/bus.h +++ b/include/linux/amba/bus.h @@ -19,6 +19,7 @@ #include #include #include +#include #define AMBA_NR_IRQS 2 #define AMBA_CID 0xb105f00d @@ -30,6 +31,7 @@ struct amba_device { struct resource res; struct clk *pclk; struct regulator *vcore; + struct pinmux *pmx; u64 dma_mask; unsigned int periphid; unsigned int irq[AMBA_NR_IRQS];