All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org>
To: Alexander Holler <holler-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Alexandre Courbot
	<gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Linus Walleij
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Grant Likely
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH] gpio: davinci: fix gpio selection for OF
Date: Wed, 5 Mar 2014 12:43:26 +0200	[thread overview]
Message-ID: <5316FFCE.1060603@ti.com> (raw)
In-Reply-To: <1393970762-5346-1-git-send-email-holler-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>

On 03/05/2014 12:06 AM, Alexander Holler wrote:
> The driver missed an of_xlate function to translate gpio numbers
> as found in the DT to the correct chip and number.
>
> While there I've set #gpio_cells to a fixed value of 2.
>
> I've used gpio-pxa.c as template for those changes and tested my changes
> successfully on a da850 board using entries for gpio-leds in a DT. So I didn't
> reinvent the wheel but just copied and tested stuff.
>
> Thanks to Grygorii Strashko for the hint of the existing code in gpio-pxa.
>
> Signed-off-by: Alexander Holler <holler-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
> ---
>   drivers/gpio/gpio-davinci.c | 27 +++++++++++++++++++++++++++
>   1 file changed, 27 insertions(+)
>
> diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
> index 7629b4f..79f45c4 100644
> --- a/drivers/gpio/gpio-davinci.c
> +++ b/drivers/gpio/gpio-davinci.c
> @@ -44,6 +44,9 @@ struct davinci_gpio_regs {
>
>   static void __iomem *gpio_base;
>
> +static struct davinci_gpio_controller *davinci_gpio_chips;
> +static int davinci_last_gpio;
> +
>   static struct davinci_gpio_regs __iomem *gpio2regs(unsigned gpio)
>   {
>   	void __iomem *ptr;
> @@ -172,6 +175,24 @@ of_err:
>   	return NULL;
>   }
>
> +#ifdef CONFIG_OF_GPIO
> +static int davinci_gpio_of_xlate(struct gpio_chip *gc,
> +			     const struct of_phandle_args *gpiospec,
> +			     u32 *flags)
> +{
> +	if (gpiospec->args[0] > davinci_last_gpio)
> +		return -EINVAL;
> +
> +	if (gc != &davinci_gpio_chips[gpiospec->args[0] / 32].chip)
> +		return -EINVAL;
> +
> +	if (flags)
> +		*flags = gpiospec->args[1];

Just one question here - Could we use gpio_chip-dev and hence, drop
static variables (davinci_gpio_chips, davinci_last_gpio)?

The Davinci device holds davinci_gpio_platform_data
in dev->platform_data and pointer on davinci_gpio_controller array
in dev->p->driver_data.

And looks like, dev_get_platdata(gc->dev) and
dev_get_drvdata(gc->dev) can be used here.

> +
> +	return gpiospec->args[0] % 32;
> +}
> +#endif
> +
>   static int davinci_gpio_probe(struct platform_device *pdev)
>   {
>   	int i, base;
> @@ -236,6 +257,8 @@ static int davinci_gpio_probe(struct platform_device *pdev)
>   			chips[i].chip.ngpio = 32;
>

add here	chips[i].chip.dev = dev;

>   #ifdef CONFIG_OF_GPIO
> +		chips[i].chip.of_gpio_n_cells = 2;
> +		chips[i].chip.of_xlate = davinci_gpio_of_xlate;
>   		chips[i].chip.of_node = dev->of_node;
>   #endif
>   		spin_lock_init(&chips[i].lock);
> @@ -251,6 +274,10 @@ static int davinci_gpio_probe(struct platform_device *pdev)
>
>   	platform_set_drvdata(pdev, chips);
>   	davinci_gpio_irq_setup(pdev);
> +
> +	davinci_gpio_chips = chips;
> +	davinci_last_gpio = ngpio;
> +
>   	return 0;
>   }

regards,
-grygorii

WARNING: multiple messages have this Message-ID (diff)
From: grygorii.strashko@ti.com (Grygorii Strashko)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] gpio: davinci: fix gpio selection for OF
Date: Wed, 5 Mar 2014 12:43:26 +0200	[thread overview]
Message-ID: <5316FFCE.1060603@ti.com> (raw)
In-Reply-To: <1393970762-5346-1-git-send-email-holler@ahsoftware.de>

On 03/05/2014 12:06 AM, Alexander Holler wrote:
> The driver missed an of_xlate function to translate gpio numbers
> as found in the DT to the correct chip and number.
>
> While there I've set #gpio_cells to a fixed value of 2.
>
> I've used gpio-pxa.c as template for those changes and tested my changes
> successfully on a da850 board using entries for gpio-leds in a DT. So I didn't
> reinvent the wheel but just copied and tested stuff.
>
> Thanks to Grygorii Strashko for the hint of the existing code in gpio-pxa.
>
> Signed-off-by: Alexander Holler <holler@ahsoftware.de>
> ---
>   drivers/gpio/gpio-davinci.c | 27 +++++++++++++++++++++++++++
>   1 file changed, 27 insertions(+)
>
> diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
> index 7629b4f..79f45c4 100644
> --- a/drivers/gpio/gpio-davinci.c
> +++ b/drivers/gpio/gpio-davinci.c
> @@ -44,6 +44,9 @@ struct davinci_gpio_regs {
>
>   static void __iomem *gpio_base;
>
> +static struct davinci_gpio_controller *davinci_gpio_chips;
> +static int davinci_last_gpio;
> +
>   static struct davinci_gpio_regs __iomem *gpio2regs(unsigned gpio)
>   {
>   	void __iomem *ptr;
> @@ -172,6 +175,24 @@ of_err:
>   	return NULL;
>   }
>
> +#ifdef CONFIG_OF_GPIO
> +static int davinci_gpio_of_xlate(struct gpio_chip *gc,
> +			     const struct of_phandle_args *gpiospec,
> +			     u32 *flags)
> +{
> +	if (gpiospec->args[0] > davinci_last_gpio)
> +		return -EINVAL;
> +
> +	if (gc != &davinci_gpio_chips[gpiospec->args[0] / 32].chip)
> +		return -EINVAL;
> +
> +	if (flags)
> +		*flags = gpiospec->args[1];

Just one question here - Could we use gpio_chip-dev and hence, drop
static variables (davinci_gpio_chips, davinci_last_gpio)?

The Davinci device holds davinci_gpio_platform_data
in dev->platform_data and pointer on davinci_gpio_controller array
in dev->p->driver_data.

And looks like, dev_get_platdata(gc->dev) and
dev_get_drvdata(gc->dev) can be used here.

> +
> +	return gpiospec->args[0] % 32;
> +}
> +#endif
> +
>   static int davinci_gpio_probe(struct platform_device *pdev)
>   {
>   	int i, base;
> @@ -236,6 +257,8 @@ static int davinci_gpio_probe(struct platform_device *pdev)
>   			chips[i].chip.ngpio = 32;
>

add here	chips[i].chip.dev = dev;

>   #ifdef CONFIG_OF_GPIO
> +		chips[i].chip.of_gpio_n_cells = 2;
> +		chips[i].chip.of_xlate = davinci_gpio_of_xlate;
>   		chips[i].chip.of_node = dev->of_node;
>   #endif
>   		spin_lock_init(&chips[i].lock);
> @@ -251,6 +274,10 @@ static int davinci_gpio_probe(struct platform_device *pdev)
>
>   	platform_set_drvdata(pdev, chips);
>   	davinci_gpio_irq_setup(pdev);
> +
> +	davinci_gpio_chips = chips;
> +	davinci_last_gpio = ngpio;
> +
>   	return 0;
>   }

regards,
-grygorii

WARNING: multiple messages have this Message-ID (diff)
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: Alexander Holler <holler@ahsoftware.de>, <linux-kernel@vger.kernel.org>
Cc: <linux-gpio@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<davinci-linux-open-source@linux.davincidsp.com>,
	<linux-arm-kernel@lists.infradead.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	Grant Likely <grant.likely@linaro.org>,
	Rob Herring <robh+dt@kernel.org>, Sekhar Nori <nsekhar@ti.com>,
	Prabhakar Lad <prabhakar.csengg@gmail.com>
Subject: Re: [PATCH] gpio: davinci: fix gpio selection for OF
Date: Wed, 5 Mar 2014 12:43:26 +0200	[thread overview]
Message-ID: <5316FFCE.1060603@ti.com> (raw)
In-Reply-To: <1393970762-5346-1-git-send-email-holler@ahsoftware.de>

On 03/05/2014 12:06 AM, Alexander Holler wrote:
> The driver missed an of_xlate function to translate gpio numbers
> as found in the DT to the correct chip and number.
>
> While there I've set #gpio_cells to a fixed value of 2.
>
> I've used gpio-pxa.c as template for those changes and tested my changes
> successfully on a da850 board using entries for gpio-leds in a DT. So I didn't
> reinvent the wheel but just copied and tested stuff.
>
> Thanks to Grygorii Strashko for the hint of the existing code in gpio-pxa.
>
> Signed-off-by: Alexander Holler <holler@ahsoftware.de>
> ---
>   drivers/gpio/gpio-davinci.c | 27 +++++++++++++++++++++++++++
>   1 file changed, 27 insertions(+)
>
> diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
> index 7629b4f..79f45c4 100644
> --- a/drivers/gpio/gpio-davinci.c
> +++ b/drivers/gpio/gpio-davinci.c
> @@ -44,6 +44,9 @@ struct davinci_gpio_regs {
>
>   static void __iomem *gpio_base;
>
> +static struct davinci_gpio_controller *davinci_gpio_chips;
> +static int davinci_last_gpio;
> +
>   static struct davinci_gpio_regs __iomem *gpio2regs(unsigned gpio)
>   {
>   	void __iomem *ptr;
> @@ -172,6 +175,24 @@ of_err:
>   	return NULL;
>   }
>
> +#ifdef CONFIG_OF_GPIO
> +static int davinci_gpio_of_xlate(struct gpio_chip *gc,
> +			     const struct of_phandle_args *gpiospec,
> +			     u32 *flags)
> +{
> +	if (gpiospec->args[0] > davinci_last_gpio)
> +		return -EINVAL;
> +
> +	if (gc != &davinci_gpio_chips[gpiospec->args[0] / 32].chip)
> +		return -EINVAL;
> +
> +	if (flags)
> +		*flags = gpiospec->args[1];

Just one question here - Could we use gpio_chip-dev and hence, drop
static variables (davinci_gpio_chips, davinci_last_gpio)?

The Davinci device holds davinci_gpio_platform_data
in dev->platform_data and pointer on davinci_gpio_controller array
in dev->p->driver_data.

And looks like, dev_get_platdata(gc->dev) and
dev_get_drvdata(gc->dev) can be used here.

> +
> +	return gpiospec->args[0] % 32;
> +}
> +#endif
> +
>   static int davinci_gpio_probe(struct platform_device *pdev)
>   {
>   	int i, base;
> @@ -236,6 +257,8 @@ static int davinci_gpio_probe(struct platform_device *pdev)
>   			chips[i].chip.ngpio = 32;
>

add here	chips[i].chip.dev = dev;

>   #ifdef CONFIG_OF_GPIO
> +		chips[i].chip.of_gpio_n_cells = 2;
> +		chips[i].chip.of_xlate = davinci_gpio_of_xlate;
>   		chips[i].chip.of_node = dev->of_node;
>   #endif
>   		spin_lock_init(&chips[i].lock);
> @@ -251,6 +274,10 @@ static int davinci_gpio_probe(struct platform_device *pdev)
>
>   	platform_set_drvdata(pdev, chips);
>   	davinci_gpio_irq_setup(pdev);
> +
> +	davinci_gpio_chips = chips;
> +	davinci_last_gpio = ngpio;
> +
>   	return 0;
>   }

regards,
-grygorii



  parent reply	other threads:[~2014-03-05 10:43 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5315ED51.1000006@ti.com>
     [not found] ` <5315ED51.1000006-l0cyMroinI0@public.gmane.org>
2014-03-04 22:06   ` [PATCH] gpio: davinci: fix gpio selection for OF Alexander Holler
2014-03-04 22:06     ` Alexander Holler
2014-03-04 22:06     ` Alexander Holler
     [not found]     ` <1393970762-5346-1-git-send-email-holler-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2014-03-05  2:27       ` Linus Walleij
2014-03-05  2:27         ` Linus Walleij
2014-03-05  2:27         ` Linus Walleij
2014-03-05 10:43       ` Grygorii Strashko [this message]
2014-03-05 10:43         ` Grygorii Strashko
2014-03-05 10:43         ` Grygorii Strashko
     [not found]         ` <5316FFCE.1060603-l0cyMroinI0@public.gmane.org>
2014-03-05 11:21           ` [PATCH v2] " Alexander Holler
2014-03-05 11:21             ` Alexander Holler
2014-03-05 11:21             ` Alexander Holler
     [not found]             ` <1394018461-757-1-git-send-email-holler-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2014-03-05 13:12               ` Grygorii Strashko
2014-03-05 13:12                 ` Grygorii Strashko
2014-03-05 13:12                 ` Grygorii Strashko
2014-03-11 10:15             ` Linus Walleij
2014-03-11 10:15               ` Linus Walleij
     [not found]               ` <CACRpkdaF=jc9Z1XZCtH8VPuih01t--qyV-sgH1R_ix0VM4RzVA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-14 10:08                 ` Alexander Holler
2014-03-14 10:08                   ` Alexander Holler
2014-03-14 10:08                   ` Alexander Holler
2014-03-14 11:02                   ` Linus Walleij
2014-03-14 11:02                     ` Linus Walleij
2014-03-14 12:38                     ` Alexander Holler
2014-03-14 12:38                       ` Alexander Holler
2014-03-14 13:54                       ` Linus Walleij
2014-03-14 13:54                         ` Linus Walleij
2014-03-14 18:33                         ` Alexander Holler
2014-03-14 18:33                           ` Alexander Holler
2014-03-14 19:52                           ` Linus Walleij
2014-03-14 19:52                             ` Linus Walleij
2014-03-15  7:37                             ` Alexander Holler
2014-03-15  7:37                               ` Alexander Holler
2014-03-17 13:29                     ` Sekhar Nori
2014-03-17 13:29                       ` Sekhar Nori
2014-03-17 13:29                       ` Sekhar Nori
2014-03-17 14:05                       ` Linus Walleij
2014-03-17 14:05                         ` Linus Walleij
     [not found]                         ` <CACRpkdYZMzw31NkA4uSq+ZowzOnZgZthXhZri-eJY2Ozb8aNRQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-18  8:37                           ` Sekhar Nori
2014-03-18  8:37                             ` Sekhar Nori
2014-03-18  8:37                             ` Sekhar Nori
     [not found]                             ` <532805AE.9000806-l0cyMroinI0@public.gmane.org>
2014-03-18  9:45                               ` Alexander Holler
2014-03-18  9:45                                 ` Alexander Holler
2014-03-18  9:45                                 ` Alexander Holler
     [not found]                                 ` <532815A8.9090807-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2014-03-18 10:54                                   ` Sekhar Nori
2014-03-18 10:54                                     ` Sekhar Nori
2014-03-18 10:54                                     ` Sekhar Nori
2014-03-21  8:28                                   ` Linus Walleij
2014-03-21  8:28                                     ` Linus Walleij
2014-03-21  8:28                                     ` Linus Walleij
2014-03-21  8:59                                     ` Alexander Holler
2014-03-21  8:59                                       ` Alexander Holler
     [not found]                       ` <5326F8C5.5090406-l0cyMroinI0@public.gmane.org>
2014-03-17 14:11                         ` Alexander Holler
2014-03-17 14:11                           ` Alexander Holler
2014-03-17 14:11                           ` Alexander Holler
2014-03-17 14:13                           ` Linus Walleij
2014-03-17 14:13                             ` Linus Walleij
2014-03-17 15:04                         ` Grygorii Strashko
2014-03-17 15:04                           ` Grygorii Strashko
2014-03-17 15:04                           ` Grygorii Strashko

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=5316FFCE.1060603@ti.com \
    --to=grygorii.strashko-l0cymroini0@public.gmane.org \
    --cc=davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=holler-SXC+2es9fhnfWeYVQQPykw@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /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.