From patchwork Wed Mar 5 01:53:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 3769841 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 EC6709F376 for ; Wed, 5 Mar 2014 02:00:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E5032022F for ; Wed, 5 Mar 2014 02:00:00 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 016E920220 for ; Wed, 5 Mar 2014 01:59:59 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WL17g-00065H-H5; Wed, 05 Mar 2014 01:59:52 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WL17e-0004Yv-3s; Wed, 05 Mar 2014 01:59:50 +0000 Received: from nasmtp01.atmel.com ([192.199.1.246] helo=DVREDG02.corp.atmel.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WL17b-0004Xc-27 for linux-arm-kernel@lists.infradead.org; Wed, 05 Mar 2014 01:59:47 +0000 Received: from apsmtp01.atmel.com (10.168.254.30) by DVREDG02.corp.atmel.com (10.42.103.31) with Microsoft SMTP Server (TLS) id 14.2.347.0; Tue, 4 Mar 2014 18:59:21 -0700 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server id 14.2.347.0; Wed, 5 Mar 2014 10:04:12 +0800 From: Wenyou Yang To: , Subject: [PATCH] pinctrl: at91: add the config GPIO_OUTPUT_x Date: Wed, 5 Mar 2014 09:53:20 +0800 Message-ID: <1393984400-14687-1-git-send-email-wenyou.yang@atmel.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140304_205947_264901_0786BCCB X-CRM114-Status: GOOD ( 11.94 ) X-Spam-Score: 1.1 (+) Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, pawel.moll@arm.com, ijc+devicetree@hellion.org.uk, linux-kernel@vger.kernel.org, b.brezillon@overkiz.com, robh+dt@kernel.org, galak@codeaurora.org, wenyou.yang@atmel.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no 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 In order to support the pinctrl sleep state. Signed-off-by: Wenyou Yang --- Hi Linus, The patch is based on branch: for-next git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl Best Regards, Wenyou Yang drivers/pinctrl/pinctrl-at91.c | 31 +++++++++++++++++++++++++++++++ include/dt-bindings/pinctrl/at91.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 5d24aae..fc51e59 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -62,6 +62,8 @@ static int gpio_banks; #define DEGLITCH (1 << 2) #define PULL_DOWN (1 << 3) #define DIS_SCHMIT (1 << 4) +#define GPIO_OUTPUT_HIGH (1 << 5) +#define GPIO_OUTPUT_LOW (1 << 6) #define DEBOUNCE (1 << 16) #define DEBOUNCE_VAL_SHIFT 17 #define DEBOUNCE_VAL (0x3fff << DEBOUNCE_VAL_SHIFT) @@ -152,12 +154,15 @@ struct at91_pinctrl_mux_ops { void (*set_pulldown)(void __iomem *pio, unsigned mask, bool is_on); bool (*get_schmitt_trig)(void __iomem *pio, unsigned pin); void (*disable_schmitt_trig)(void __iomem *pio, unsigned mask); + bool (*get_gpio_output)(void __iomem *pio, unsigned mask); + void (*set_gpio_output)(void __iomem *pio, unsigned mask, bool is_high); /* irq */ int (*irq_type)(struct irq_data *d, unsigned type); }; static int gpio_irq_type(struct irq_data *d, unsigned type); static int alt_gpio_irq_type(struct irq_data *d, unsigned type); +static void at91_mux_gpio_enable(void __iomem *pio, unsigned mask, bool input); struct at91_pinctrl { struct device *dev; @@ -472,6 +477,20 @@ static bool at91_mux_pio3_get_schmitt_trig(void __iomem *pio, unsigned pin) return (__raw_readl(pio + PIO_SCHMITT) >> pin) & 0x1; } +static bool at91_mux_pio3_get_gpio_output(void __iomem *pio, unsigned pin) +{ + return (__raw_readl(pio + PIO_ODSR) >> pin) & 0x1; +} + +static void at91_mux_pio3_set_gpio_output(void __iomem *pio, + unsigned mask, + bool is_high) +{ + at91_mux_gpio_enable(pio, mask, 0); + writel_relaxed(mask, pio + (is_high ? PIO_SODR : PIO_CODR)); +} + + static struct at91_pinctrl_mux_ops at91rm9200_ops = { .get_periph = at91_mux_get_periph, .mux_A_periph = at91_mux_set_A_periph, @@ -495,6 +514,8 @@ static struct at91_pinctrl_mux_ops at91sam9x5_ops = { .set_pulldown = at91_mux_pio3_set_pulldown, .get_schmitt_trig = at91_mux_pio3_get_schmitt_trig, .disable_schmitt_trig = at91_mux_pio3_disable_schmitt_trig, + .get_gpio_output = at91_mux_pio3_get_gpio_output, + .set_gpio_output = at91_mux_pio3_set_gpio_output, .irq_type = alt_gpio_irq_type, }; @@ -741,6 +762,10 @@ static int at91_pinconf_get(struct pinctrl_dev *pctldev, *config |= PULL_DOWN; if (info->ops->get_schmitt_trig && info->ops->get_schmitt_trig(pio, pin)) *config |= DIS_SCHMIT; + if (info->ops->get_gpio_output) { + *config |= info->ops->get_gpio_output(pio, pin) ? + GPIO_OUTPUT_HIGH : GPIO_OUTPUT_LOW; + } return 0; } @@ -778,6 +803,12 @@ static int at91_pinconf_set(struct pinctrl_dev *pctldev, info->ops->set_pulldown(pio, mask, config & PULL_DOWN); if (info->ops->disable_schmitt_trig && config & DIS_SCHMIT) info->ops->disable_schmitt_trig(pio, mask); + if (info->ops->set_gpio_output) { + if (config & GPIO_OUTPUT_HIGH) + info->ops->set_gpio_output(pio, mask, 1); + if (config & GPIO_OUTPUT_LOW) + info->ops->set_gpio_output(pio, mask, 0); + }; } /* for each config */ diff --git a/include/dt-bindings/pinctrl/at91.h b/include/dt-bindings/pinctrl/at91.h index 0fee6ff..e799268 100644 --- a/include/dt-bindings/pinctrl/at91.h +++ b/include/dt-bindings/pinctrl/at91.h @@ -15,6 +15,8 @@ #define AT91_PINCTRL_DEGLITCH (1 << 2) #define AT91_PINCTRL_PULL_DOWN (1 << 3) #define AT91_PINCTRL_DIS_SCHMIT (1 << 4) +#define AT91_PINCTRL_OUTPUT_HIGH (1 << 5) +#define AT91_PINCTRL_OUTPUT_LOW (1 << 6) #define AT91_PINCTRL_DEBOUNCE (1 << 16) #define AT91_PINCTRL_DEBOUNCE_VAL(x) (x << 17)