From patchwork Thu Sep 1 09:32:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 3833 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 915D623F36 for ; Thu, 1 Sep 2011 09:33:46 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 86AFEA18065 for ; Thu, 1 Sep 2011 09:33:46 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id 18so746299fxd.11 for ; Thu, 01 Sep 2011 02:33:46 -0700 (PDT) Received: by 10.223.24.21 with SMTP id t21mr27649fab.24.1314869626454; Thu, 01 Sep 2011 02:33:46 -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.152.11.8 with SMTP id m8cs45560lab; Thu, 1 Sep 2011 02:33:46 -0700 (PDT) Received: by 10.213.113.201 with SMTP id b9mr700750ebq.148.1314869625892; Thu, 01 Sep 2011 02:33:45 -0700 (PDT) Received: from eu1sys200aog108.obsmtp.com (eu1sys200aog108.obsmtp.com [207.126.144.125]) by mx.google.com with SMTP id d48si337931eei.41.2011.09.01.02.33.32 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Sep 2011 02:33:45 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.125 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.125; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.125 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 eu1sys200aob108.postini.com ([207.126.147.11]) with SMTP ID DSNKTl9RZCWpcHOh6WwSBZbr6SJfvyue2rs1@postini.com; Thu, 01 Sep 2011 09:33:45 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 C973A131; Thu, 1 Sep 2011 09:32:57 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 38F84101C; Thu, 1 Sep 2011 09:32:57 +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 1720024C075; Thu, 1 Sep 2011 11:32:51 +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; Thu, 1 Sep 2011 11:32:55 +0200 From: Linus Walleij To: , , Grant Likely , Stephen Warren Cc: Lee Jones , Joe Perches , Russell King , Linaro Dev , Sascha Hauer , David Brown , Barry Song <21cnbao@gmail.com>, Linus Walleij Subject: [PATCH 3/4 v6] amba: request muxing for PrimeCell devices Date: Thu, 1 Sep 2011 11:32:53 +0200 Message-ID: <1314869573-5569-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];