From: Grant Likely <grant.likely@secretlab.ca>
To: sameo@linux.intel.com, tony@atomide.com
Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Benoit Cousson <b-cousson@ti.com>
Subject: Re: [PATCH 09/12] gpio/twl: Add DT support to gpio-twl4030 driver
Date: Mon, 12 Mar 2012 11:48:12 -0600 [thread overview]
Message-ID: <20120312174812.6A6BD3E07B0@localhost> (raw)
In-Reply-To: <1330707024-23730-10-git-send-email-b-cousson@ti.com>
On Fri, 2 Mar 2012 17:50:21 +0100, Benoit Cousson <b-cousson@ti.com> wrote:
> Add the DT support for the I2C GPIO expander inside the twl4030.
>
> Signed-off-by: Benoit Cousson <b-cousson@ti.com>
> Acked-by: Felipe Balbi <balbi@ti.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> .../devicetree/bindings/gpio/gpio-twl4030.txt | 23 ++++++
> drivers/gpio/gpio-twl4030.c | 79 ++++++++++++-------
> 2 files changed, 73 insertions(+), 29 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
>
> diff --git a/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt b/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
> new file mode 100644
> index 0000000..16695d9
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
> @@ -0,0 +1,23 @@
> +twl4030 GPIO controller bindings
> +
> +Required properties:
> +- compatible:
> + - "ti,twl4030-gpio" for twl4030 GPIO controller
> +- #gpio-cells : Should be two.
> + - first cell is the pin number
> + - second cell is used to specify optional parameters (unused)
> +- gpio-controller : Marks the device node as a GPIO controller.
> +- #interrupt-cells : Should be 2.
> +- interrupt-controller: Mark the device node as an interrupt controller
> + The first cell is the GPIO number.
> + The second cell is not used.
> +
> +Example:
> +
> +twl_gpio: gpio {
> + compatible = "ti,twl4030-gpio";
> + #gpio-cells = <2>;
> + gpio-controller;
> + #interrupt-cells = <2>;
> + interrupt-controller;
> +};
> diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
> index 49e5c6e..94256fe 100644
> --- a/drivers/gpio/gpio-twl4030.c
> +++ b/drivers/gpio/gpio-twl4030.c
> @@ -32,6 +32,8 @@
> #include <linux/irq.h>
> #include <linux/gpio.h>
> #include <linux/platform_device.h>
> +#include <linux/of.h>
> +#include <linux/irqdomain.h>
>
> #include <linux/i2c/twl.h>
>
> @@ -256,7 +258,8 @@ static int twl_request(struct gpio_chip *chip, unsigned offset)
> * and vMMC2 power supplies based on card presence.
> */
> pdata = chip->dev->platform_data;
> - value |= pdata->mmc_cd & 0x03;
> + if (pdata)
> + value |= pdata->mmc_cd & 0x03;
>
> status = gpio_twl4030_write(REG_GPIO_CTRL, value);
> }
> @@ -395,6 +398,7 @@ static int gpio_twl4030_remove(struct platform_device *pdev);
> static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
> {
> struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data;
> + struct device_node *node = pdev->dev.of_node;
> int ret, irq_base;
>
> /* maybe setup IRQs */
> @@ -409,6 +413,9 @@ static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
> return irq_base;
> }
>
> + irq_domain_add_legacy(node, TWL4030_GPIO_MAX, irq_base, 0,
> + &irq_domain_simple_ops, NULL);
> +
> ret = twl4030_sih_setup(&pdev->dev, TWL4030_MODULE_GPIO, irq_base);
> if (ret < 0)
> return ret;
> @@ -416,40 +423,45 @@ static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
> twl4030_gpio_irq_base = irq_base;
>
> no_irqs:
> - /*
> - * NOTE: boards may waste power if they don't set pullups
> - * and pulldowns correctly ... default for non-ULPI pins is
> - * pulldown, and some other pins may have external pullups
> - * or pulldowns. Careful!
> - */
> - ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns);
> - if (ret)
> - dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n",
> - pdata->pullups, pdata->pulldowns,
> - ret);
> -
> - ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
> - if (ret)
> - dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
> - pdata->debounce, pdata->mmc_cd,
> - ret);
> -
> - twl_gpiochip.base = pdata->gpio_base;
> + twl_gpiochip.base = -1;
> twl_gpiochip.ngpio = TWL4030_GPIO_MAX;
> twl_gpiochip.dev = &pdev->dev;
>
> - /* NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE,
> - * is (still) clear if use_leds is set.
> - */
> - if (pdata->use_leds)
> - twl_gpiochip.ngpio += 2;
> + if (pdata) {
> + twl_gpiochip.base = pdata->gpio_base;
> +
> + /*
> + * NOTE: boards may waste power if they don't set pullups
> + * and pulldowns correctly ... default for non-ULPI pins is
> + * pulldown, and some other pins may have external pullups
> + * or pulldowns. Careful!
> + */
> + ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns);
> + if (ret)
> + dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n",
> + pdata->pullups, pdata->pulldowns,
> + ret);
> +
> + ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
> + if (ret)
> + dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
> + pdata->debounce, pdata->mmc_cd,
> + ret);
> +
> + /*
> + * NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE,
> + * is (still) clear if use_leds is set.
> + */
> + if (pdata->use_leds)
> + twl_gpiochip.ngpio += 2;
> + }
>
> ret = gpiochip_add(&twl_gpiochip);
> if (ret < 0) {
> dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret);
> twl_gpiochip.ngpio = 0;
> gpio_twl4030_remove(pdev);
> - } else if (pdata->setup) {
> + } else if (pdata && pdata->setup) {
> int status;
>
> status = pdata->setup(&pdev->dev,
> @@ -467,7 +479,7 @@ static int gpio_twl4030_remove(struct platform_device *pdev)
> struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data;
> int status;
>
> - if (pdata->teardown) {
> + if (pdata && pdata->teardown) {
> status = pdata->teardown(&pdev->dev,
> pdata->gpio_base, TWL4030_GPIO_MAX);
> if (status) {
> @@ -488,12 +500,21 @@ static int gpio_twl4030_remove(struct platform_device *pdev)
> return -EIO;
> }
>
> +static const struct of_device_id twl_gpio_match[] = {
> + { .compatible = "ti,twl4030-gpio", },
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, twl_gpio_match);
> +
> /* Note: this hardware lives inside an I2C-based multi-function device. */
> MODULE_ALIAS("platform:twl4030_gpio");
>
> static struct platform_driver gpio_twl4030_driver = {
> - .driver.name = "twl4030_gpio",
> - .driver.owner = THIS_MODULE,
> + .driver = {
> + .name = "twl4030_gpio",
> + .owner = THIS_MODULE,
> + .of_match_table = of_match_ptr(twl_gpio_match),
> + },
> .probe = gpio_twl4030_probe,
> .remove = gpio_twl4030_remove,
> };
> --
> 1.7.0.4
>
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies,Ltd.
WARNING: multiple messages have this Message-ID (diff)
From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 09/12] gpio/twl: Add DT support to gpio-twl4030 driver
Date: Mon, 12 Mar 2012 11:48:12 -0600 [thread overview]
Message-ID: <20120312174812.6A6BD3E07B0@localhost> (raw)
In-Reply-To: <1330707024-23730-10-git-send-email-b-cousson@ti.com>
On Fri, 2 Mar 2012 17:50:21 +0100, Benoit Cousson <b-cousson@ti.com> wrote:
> Add the DT support for the I2C GPIO expander inside the twl4030.
>
> Signed-off-by: Benoit Cousson <b-cousson@ti.com>
> Acked-by: Felipe Balbi <balbi@ti.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> .../devicetree/bindings/gpio/gpio-twl4030.txt | 23 ++++++
> drivers/gpio/gpio-twl4030.c | 79 ++++++++++++-------
> 2 files changed, 73 insertions(+), 29 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
>
> diff --git a/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt b/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
> new file mode 100644
> index 0000000..16695d9
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
> @@ -0,0 +1,23 @@
> +twl4030 GPIO controller bindings
> +
> +Required properties:
> +- compatible:
> + - "ti,twl4030-gpio" for twl4030 GPIO controller
> +- #gpio-cells : Should be two.
> + - first cell is the pin number
> + - second cell is used to specify optional parameters (unused)
> +- gpio-controller : Marks the device node as a GPIO controller.
> +- #interrupt-cells : Should be 2.
> +- interrupt-controller: Mark the device node as an interrupt controller
> + The first cell is the GPIO number.
> + The second cell is not used.
> +
> +Example:
> +
> +twl_gpio: gpio {
> + compatible = "ti,twl4030-gpio";
> + #gpio-cells = <2>;
> + gpio-controller;
> + #interrupt-cells = <2>;
> + interrupt-controller;
> +};
> diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
> index 49e5c6e..94256fe 100644
> --- a/drivers/gpio/gpio-twl4030.c
> +++ b/drivers/gpio/gpio-twl4030.c
> @@ -32,6 +32,8 @@
> #include <linux/irq.h>
> #include <linux/gpio.h>
> #include <linux/platform_device.h>
> +#include <linux/of.h>
> +#include <linux/irqdomain.h>
>
> #include <linux/i2c/twl.h>
>
> @@ -256,7 +258,8 @@ static int twl_request(struct gpio_chip *chip, unsigned offset)
> * and vMMC2 power supplies based on card presence.
> */
> pdata = chip->dev->platform_data;
> - value |= pdata->mmc_cd & 0x03;
> + if (pdata)
> + value |= pdata->mmc_cd & 0x03;
>
> status = gpio_twl4030_write(REG_GPIO_CTRL, value);
> }
> @@ -395,6 +398,7 @@ static int gpio_twl4030_remove(struct platform_device *pdev);
> static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
> {
> struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data;
> + struct device_node *node = pdev->dev.of_node;
> int ret, irq_base;
>
> /* maybe setup IRQs */
> @@ -409,6 +413,9 @@ static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
> return irq_base;
> }
>
> + irq_domain_add_legacy(node, TWL4030_GPIO_MAX, irq_base, 0,
> + &irq_domain_simple_ops, NULL);
> +
> ret = twl4030_sih_setup(&pdev->dev, TWL4030_MODULE_GPIO, irq_base);
> if (ret < 0)
> return ret;
> @@ -416,40 +423,45 @@ static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
> twl4030_gpio_irq_base = irq_base;
>
> no_irqs:
> - /*
> - * NOTE: boards may waste power if they don't set pullups
> - * and pulldowns correctly ... default for non-ULPI pins is
> - * pulldown, and some other pins may have external pullups
> - * or pulldowns. Careful!
> - */
> - ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns);
> - if (ret)
> - dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n",
> - pdata->pullups, pdata->pulldowns,
> - ret);
> -
> - ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
> - if (ret)
> - dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
> - pdata->debounce, pdata->mmc_cd,
> - ret);
> -
> - twl_gpiochip.base = pdata->gpio_base;
> + twl_gpiochip.base = -1;
> twl_gpiochip.ngpio = TWL4030_GPIO_MAX;
> twl_gpiochip.dev = &pdev->dev;
>
> - /* NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE,
> - * is (still) clear if use_leds is set.
> - */
> - if (pdata->use_leds)
> - twl_gpiochip.ngpio += 2;
> + if (pdata) {
> + twl_gpiochip.base = pdata->gpio_base;
> +
> + /*
> + * NOTE: boards may waste power if they don't set pullups
> + * and pulldowns correctly ... default for non-ULPI pins is
> + * pulldown, and some other pins may have external pullups
> + * or pulldowns. Careful!
> + */
> + ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns);
> + if (ret)
> + dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n",
> + pdata->pullups, pdata->pulldowns,
> + ret);
> +
> + ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
> + if (ret)
> + dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
> + pdata->debounce, pdata->mmc_cd,
> + ret);
> +
> + /*
> + * NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE,
> + * is (still) clear if use_leds is set.
> + */
> + if (pdata->use_leds)
> + twl_gpiochip.ngpio += 2;
> + }
>
> ret = gpiochip_add(&twl_gpiochip);
> if (ret < 0) {
> dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret);
> twl_gpiochip.ngpio = 0;
> gpio_twl4030_remove(pdev);
> - } else if (pdata->setup) {
> + } else if (pdata && pdata->setup) {
> int status;
>
> status = pdata->setup(&pdev->dev,
> @@ -467,7 +479,7 @@ static int gpio_twl4030_remove(struct platform_device *pdev)
> struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data;
> int status;
>
> - if (pdata->teardown) {
> + if (pdata && pdata->teardown) {
> status = pdata->teardown(&pdev->dev,
> pdata->gpio_base, TWL4030_GPIO_MAX);
> if (status) {
> @@ -488,12 +500,21 @@ static int gpio_twl4030_remove(struct platform_device *pdev)
> return -EIO;
> }
>
> +static const struct of_device_id twl_gpio_match[] = {
> + { .compatible = "ti,twl4030-gpio", },
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, twl_gpio_match);
> +
> /* Note: this hardware lives inside an I2C-based multi-function device. */
> MODULE_ALIAS("platform:twl4030_gpio");
>
> static struct platform_driver gpio_twl4030_driver = {
> - .driver.name = "twl4030_gpio",
> - .driver.owner = THIS_MODULE,
> + .driver = {
> + .name = "twl4030_gpio",
> + .owner = THIS_MODULE,
> + .of_match_table = of_match_ptr(twl_gpio_match),
> + },
> .probe = gpio_twl4030_probe,
> .remove = gpio_twl4030_remove,
> };
> --
> 1.7.0.4
>
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies,Ltd.
next prev parent reply other threads:[~2012-03-12 17:48 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-02 16:50 [PATCH 00/12] mfd: twl: Fix for irqdomain/next + SPARSE_IRQ + MMC card detect Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-02 16:50 ` [PATCH 01/12] mfd: twl-core: don't depend on pdata->irq_base/end Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-14 20:59 ` Kevin Hilman
2012-03-14 20:59 ` Kevin Hilman
2012-03-14 21:08 ` Cousson, Benoit
2012-03-14 21:08 ` Cousson, Benoit
2012-03-14 21:17 ` Kevin Hilman
2012-03-14 21:17 ` Kevin Hilman
2012-03-14 21:53 ` Kevin Hilman
2012-03-14 21:53 ` Kevin Hilman
2012-03-19 14:23 ` Cousson, Benoit
2012-03-19 14:23 ` Cousson, Benoit
2012-03-14 22:14 ` Tony Lindgren
2012-03-14 22:14 ` Tony Lindgren
2012-03-19 15:07 ` Felipe Balbi
2012-03-19 15:07 ` Felipe Balbi
2012-03-02 16:50 ` [PATCH 02/12] mfd: twl-core: remove unneeded header Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-02 16:50 ` [PATCH 03/12] mfd: twl-core: Remove references already defined in header file Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-02 16:50 ` [PATCH 04/12] mfd: twl-core: Move IRQ allocation into twl[4030|6030]-irq files Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-02 16:50 ` [PATCH 05/12] mfd: twl4030-irq: Make SIH SPARSE_IRQ capable Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-02 16:50 ` [PATCH 06/12] mfd: twl4030-irq: micro-optimization on IRQ handler Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-02 16:50 ` [PATCH 07/12] mfd: twl-*: Change from pr_XXX to dev_XXX macros and various cleanups Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-02 16:50 ` [PATCH 08/12] gpio/twl: Allocate irq_desc dynamically for SPARSE_IRQ support Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-07 12:57 ` Cousson, Benoit
2012-03-07 12:57 ` Cousson, Benoit
2012-03-09 16:39 ` Cousson, Benoit
2012-03-09 16:39 ` Cousson, Benoit
2012-03-12 17:46 ` Grant Likely
2012-03-12 17:46 ` Grant Likely
2012-03-02 16:50 ` [PATCH 09/12] gpio/twl: Add DT support to gpio-twl4030 driver Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-12 17:48 ` Grant Likely [this message]
2012-03-12 17:48 ` Grant Likely
2012-03-02 16:50 ` [PATCH 10/12] arm/dts: twl4030: Add twl4030-gpio node Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-02 16:50 ` [PATCH 11/12] mfd: twl4030-irq: Return twl6030_mmc_card_detect IRQ for board setup Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-02 18:15 ` Felipe Balbi
2012-03-02 18:15 ` Felipe Balbi
2012-03-02 19:20 ` Tony Lindgren
2012-03-02 19:20 ` Tony Lindgren
2012-03-02 20:28 ` Cousson, Benoit
2012-03-02 20:28 ` Cousson, Benoit
2012-03-02 21:38 ` Cousson, Benoit
2012-03-02 21:38 ` Cousson, Benoit
2012-03-02 21:44 ` Tony Lindgren
2012-03-02 21:44 ` Tony Lindgren
2012-03-05 8:19 ` Rajendra Nayak
2012-03-05 8:19 ` Rajendra Nayak
2012-03-05 8:58 ` Cousson, Benoit
2012-03-05 8:58 ` Cousson, Benoit
2012-03-03 15:09 ` Sergei Shtylyov
2012-03-03 15:09 ` Sergei Shtylyov
2012-03-05 8:29 ` Cousson, Benoit
2012-03-05 8:29 ` Cousson, Benoit
2012-03-02 16:50 ` [PATCH 12/12] ARM: OMAP2+: board-omap4-*: Do not use anymore TWL6030_IRQ_BASE in board files Benoit Cousson
2012-03-02 16:50 ` Benoit Cousson
2012-03-13 17:07 ` Tony Lindgren
2012-03-13 17:07 ` Tony Lindgren
2012-03-13 21:35 ` Cousson, Benoit
2012-03-13 21:35 ` Cousson, Benoit
2012-03-02 20:33 ` [PATCH 07/12] mfd: twl-*: Replace pr_ macros by the dev_ equivalent and do various cleanups Benoit Cousson
2012-03-02 20:33 ` Benoit Cousson
2012-03-02 20:49 ` Cousson, Benoit
2012-03-02 20:49 ` Cousson, Benoit
2012-03-14 20:50 ` [PATCH 00/12] mfd: twl: Fix for irqdomain/next + SPARSE_IRQ + MMC card detect Kevin Hilman
2012-03-14 20:50 ` Kevin Hilman
2012-03-14 21:01 ` Cousson, Benoit
2012-03-14 21:01 ` Cousson, Benoit
2012-03-14 21:24 ` Kevin Hilman
2012-03-14 21:24 ` Kevin Hilman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120312174812.6A6BD3E07B0@localhost \
--to=grant.likely@secretlab.ca \
--cc=b-cousson@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=sameo@linux.intel.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.