From patchwork Fri Dec 14 16:19:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 13602 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 1570623FB4 for ; Fri, 14 Dec 2012 16:20:14 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 972A6A195F5 for ; Fri, 14 Dec 2012 16:20:13 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id t4so3226376iag.11 for ; Fri, 14 Dec 2012 08:20:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=WvXQ692s2723vlvmTe7slbw6LoaU455ehGKXNOMrGXM=; b=gv59u6XFajve+p6MpqCM0CHBT/9JilCxpLqCsOTcKDpt8OULib61ipcTa6TvcvVRav 65EZWPb4GAeZgBKtbS+Ovy3+QjHfm0cLhp/qZf8YNML+KhNiRHA9qcYTSKFf9I9BP3h+ LKYBwPsJ12wRGilp+uGrd0pDTiyODYLHLG6PfHXLFtyGqNYFz4htHu/kYDP3Cd5CJwil L8VxuU86b9TizHl+ijkymhO/naOIPJH6CuqqtNwws7dsgzHjfBvTygoKTc76WrmnaI8p eNGsQWhVM66Fxk5X6Imq6jLsWV+fKbPdbAoAjk43spAxTix1dbC9N81BWa07Lb+YOJQp pJzA== Received: by 10.50.173.34 with SMTP id bh2mr2004126igc.70.1355502013042; Fri, 14 Dec 2012 08:20:13 -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.50.67.148 with SMTP id n20csp81607igt; Fri, 14 Dec 2012 08:20:12 -0800 (PST) Received: by 10.194.174.196 with SMTP id bu4mr4455862wjc.35.1355502011995; Fri, 14 Dec 2012 08:20:11 -0800 (PST) Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com [74.125.82.42]) by mx.google.com with ESMTPS id y9si14995792wiw.38.2012.12.14.08.20.11 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Dec 2012 08:20:11 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.42 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.42; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.42 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wg0-f42.google.com with SMTP id dr1so506801wgb.1 for ; Fri, 14 Dec 2012 08:20:11 -0800 (PST) Received: by 10.180.102.234 with SMTP id fr10mr3565185wib.17.1355502011438; Fri, 14 Dec 2012 08:20:11 -0800 (PST) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id u6sm8325248wif.2.2012.12.14.08.20.10 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Dec 2012 08:20:10 -0800 (PST) From: Lee Jones To: linux-kernel@vger.kernel.org Cc: linus.walleij@linaro.org, Alexandre Torgue , Lee Jones , Yang QU Subject: [PATCH 16/21] gpio: ab8500: Add internal pull up on GPIO of ab8540 Date: Fri, 14 Dec 2012 16:19:34 +0000 Message-Id: <1355501979-1157-17-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1355501979-1157-1-git-send-email-lee.jones@linaro.org> References: <1355501979-1157-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQn5+7xqJcJzYBNuSMsumIVlSPjzI4EAca8vnK/wJKrD1AbQTgH8X4omFBdVA5SfALp8GrBE From: Alexandre Torgue Add 4 GPIOs named GPIOx_VBAT which have both internal pull up and pull down capability on ab8540. We can also select different voltage domains for GPIOx_VBAT. Signed-off-by: Lee Jones Signed-off-by: Yang QU Reviewed-by: Alexandre TORGUE Reviewed-by: Philippe LANGLAIS Tested-by: Alexandre TORGUE Tested-by: Philippe LANGLAIS --- drivers/gpio/gpio-ab8500.c | 64 ++++++++++++++++++++++++++++ include/linux/mfd/abx500/ab8500-gpio.h | 71 +++++++++++--------------------- 2 files changed, 87 insertions(+), 48 deletions(-) diff --git a/drivers/gpio/gpio-ab8500.c b/drivers/gpio/gpio-ab8500.c index 757ae34..ff8df1f 100644 --- a/drivers/gpio/gpio-ab8500.c +++ b/drivers/gpio/gpio-ab8500.c @@ -72,6 +72,8 @@ #define AB8500_GPIO_IN5_REG 0x44 #define AB8500_GPIO_IN6_REG 0x45 #define AB9540_GPIO_IN7_REG 0x46 +#define AB8540_GPIO_VINSEL_REG 0x47 +#define AB8540_GPIO_PULL_UPDOWN_REG 0x48 #define AB8500_GPIO_ALTFUN_REG 0x50 #define AB8500_ALTFUN_REG_INDEX 6 #define AB9540_ALTFUN_REG_INDEX 7 @@ -80,6 +82,8 @@ #define AB8505_NUM_GPIO 53 #define AB8540_NUM_GPIO 56 #define AB8500_NUM_VIR_GPIO_IRQ 16 +#define AB8540_GPIO_PULL_UPDOWN_MASK 0x03 +#define AB8540_GPIO_VINSEL_MASK 0x03 enum ab8500_gpio_action { NONE, @@ -552,6 +556,20 @@ static int __devinit ab8500_gpio_probe(struct platform_device *pdev) if (ret < 0) goto out_free; } + + if (is_ab8540(parent)) { + ret = abx500_set_register_interruptible(ab8500_gpio->dev, + AB8500_MISC, AB8540_GPIO_VINSEL_REG, + pdata->config_vinsel); + if (ret < 0) + goto out_free; + ret = abx500_set_register_interruptible(ab8500_gpio->dev, + AB8500_MISC, AB8540_GPIO_PULL_UPDOWN_REG, + pdata->config_pullupdown); + if (ret < 0) + goto out_free; + } + ret = abx500_set_register_interruptible(ab8500_gpio->dev, AB8500_MISC, AB8500_GPIO_ALTFUN_REG, pdata->config_reg[altfun_reg_index]); @@ -619,6 +637,52 @@ int ab8500_config_pulldown(struct device *dev, EXPORT_SYMBOL(ab8500_config_pulldown); /* + * ab8540_config_pull_updown() only available for following GPIOs: + * GPIO51(GPIO1_VBAT) + * GPIO52(GPIO2_VBAT) + * GPIO53(GPIO3_VBAT) + * GPIO54(GPIO4_VBAT) + */ +int ab8540_config_pull_updown(struct device *dev, + int gpio, enum ab8540_gpio_pull_updown reg) +{ + u8 offset = gpio - AB8500_PIN_GPIO(51); + u8 pos = 2 * offset; + int ret; + + ret = abx500_mask_and_set_register_interruptible(dev, + AB8500_MISC, AB8540_GPIO_PULL_UPDOWN_REG, + AB8540_GPIO_PULL_UPDOWN_MASK << pos, reg << pos); + if (ret < 0) + dev_err(dev, "%s failed (%d)\n", __func__, ret); + return ret; +} +EXPORT_SYMBOL(ab8540_config_pull_updown); + +/* + * ab8540_gpio_config_vinsel() only available for following GPIOs: + * GPIO51(GPIO1_VBAT) + * GPIO52(GPIO2_VBAT) + * GPIO53(GPIO3_VBAT) + * GPIO54(GPIO4_VBAT) + */ +int ab8540_gpio_config_vinsel(struct device *dev, + int gpio, enum ab8540_gpio_vinsel reg) +{ + u8 offset = gpio - AB8500_PIN_GPIO(51); + u8 pos = 2 * offset; + int ret; + + ret = abx500_mask_and_set_register_interruptible(dev, + AB8500_MISC, AB8540_GPIO_VINSEL_REG, + AB8540_GPIO_VINSEL_MASK << pos, reg << pos); + if (ret < 0) + dev_err(dev, "%s failed (%d)\n", __func__, ret); + return ret; +} +EXPORT_SYMBOL(ab8540_gpio_config_vinsel); + +/* * ab8500_gpio_config_select() * * Configure functionality of pin, either specific use or GPIO. diff --git a/include/linux/mfd/abx500/ab8500-gpio.h b/include/linux/mfd/abx500/ab8500-gpio.h index 48325db..20df07d 100644 --- a/include/linux/mfd/abx500/ab8500-gpio.h +++ b/include/linux/mfd/abx500/ab8500-gpio.h @@ -18,62 +18,37 @@ struct ab8500_gpio_platform_data { int gpio_base; u32 irq_base; u8 config_reg[8]; - u8 config_direction[6]; - u8 config_pullups[6]; + u8 config_direction[7]; + u8 config_pullups[7]; + u8 config_vinsel; + u8 config_pullupdown; }; -enum ab8500_pin { - AB8500_PIN_GPIO1 = 0, - AB8500_PIN_GPIO2, - AB8500_PIN_GPIO3, - AB8500_PIN_GPIO4, - AB8500_PIN_GPIO5, - AB8500_PIN_GPIO6, - AB8500_PIN_GPIO7, - AB8500_PIN_GPIO8, - AB8500_PIN_GPIO9, - AB8500_PIN_GPIO10, - AB8500_PIN_GPIO11, - AB8500_PIN_GPIO12, - AB8500_PIN_GPIO13, - AB8500_PIN_GPIO14, - AB8500_PIN_GPIO15, - AB8500_PIN_GPIO16, - AB8500_PIN_GPIO17, - AB8500_PIN_GPIO18, - AB8500_PIN_GPIO19, - AB8500_PIN_GPIO20, - AB8500_PIN_GPIO21, - AB8500_PIN_GPIO22, - AB8500_PIN_GPIO23, - AB8500_PIN_GPIO24, - AB8500_PIN_GPIO25, - AB8500_PIN_GPIO26, - AB8500_PIN_GPIO27, - AB8500_PIN_GPIO28, - AB8500_PIN_GPIO29, - AB8500_PIN_GPIO30, - AB8500_PIN_GPIO31, - AB8500_PIN_GPIO32, - AB8500_PIN_GPIO33, - AB8500_PIN_GPIO34, - AB8500_PIN_GPIO35, - AB8500_PIN_GPIO36, - AB8500_PIN_GPIO37, - AB8500_PIN_GPIO38, - AB8500_PIN_GPIO39, - AB8500_PIN_GPIO40, - AB8500_PIN_GPIO41, - AB8500_PIN_GPIO42, +enum ab8540_gpio_pull_updown { + AB8540_GPIO_PULL_DOWN = 0x0, + AB8540_GPIO_PULL_NONE = 0x1, + AB8540_GPIO_PULL_UP = 0x3, +}; + +enum ab8540_gpio_vinsel { + AB8540_GPIO_VINSEL_VBAT = 0x0, + AB8540_GPIO_VINSEL_VIN_1V8 = 0x1, + AB8540_GPIO_VINSEL_VDD_BIF = 0x2, }; int ab8500_config_pulldown(struct device *dev, - enum ab8500_pin gpio, bool enable); + int gpio, bool enable); + +int ab8540_config_pull_updown(struct device *dev, + int gpio, enum ab8540_gpio_pull_updown reg); + +int ab8540_gpio_config_vinsel(struct device *dev, + int gpio, enum ab8540_gpio_vinsel reg); int ab8500_gpio_config_select(struct device *dev, - enum ab8500_pin gpio, bool gpio_select); + int gpio, bool gpio_select); int ab8500_gpio_config_get_select(struct device *dev, - enum ab8500_pin gpio, bool *gpio_select); + int gpio, bool *gpio_select); #endif /* _AB8500_GPIO_H */