From: Grygorii Strashko <grygorii.strashko@ti.com>
To: Prabhakar Lad <prabhakar.csengg@gmail.com>
Cc: Sekhar Nori <nsekhar@ti.com>,
Linus Walleij <linus.walleij@linaro.org>,
LKML <linux-kernel@vger.kernel.org>,
DLOS <davinci-linux-open-source@linux.davincidsp.com>,
LAK <linux-arm-kernel@lists.infradead.org>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
LDOC <linux-doc@vger.kernel.org>,
Rob Herring <rob.herring@calxeda.com>,
Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Stephen Warren <swarren@wwwdotorg.org>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Rob Landley <rob@landley.net>,
Grant Likely <grant.likely@linaro.org>
Subject: Re: [PATCH v5 5/7] gpio: davinci: add OF support
Date: Mon, 11 Nov 2013 17:44:12 +0200 [thread overview]
Message-ID: <5280FB4C.80404@ti.com> (raw)
In-Reply-To: <CA+V-a8tW9dKsE+Ps_MSsr_BsDR2HVE7uEE9GN7yNga3YWoCGow@mail.gmail.com>
On 11/11/2013 05:37 PM, Prabhakar Lad wrote:
> Hi Grygorii,
>
> Thanks for the review.
>
> On Mon, Nov 11, 2013 at 8:48 PM, Grygorii Strashko
> <grygorii.strashko@ti.com> wrote:
>> On 11/08/2013 12:11 PM, Prabhakar Lad wrote:
> [Snip]
>>> @@ -134,6 +137,40 @@ davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
>>> writel((1 << offset), value ? &g->set_data : &g->clr_data);
>>> }
>>>
>>> +static struct davinci_gpio_platform_data *
>>> +davinci_gpio_get_pdata(struct platform_device *pdev)
>>
>> Minor: usually such functions have "_of" in their names:
>> davinci_gpio_of_get_pdata()
>>
> Ahh but actual this function is intended to get pdata in both the
> cases DT and NON-DT, so kept it generic :)
np
>
>>> +{
>>> + struct device_node *dn = pdev->dev.of_node;
>>> + struct davinci_gpio_platform_data *pdata;
>>> + int ret;
>>> + u32 val;
>>> +
>>> + if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node)
>>> + return pdev->dev.platform_data;
>>> +
>>> + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
>>> + if (!pdata)
>>> + return NULL;
>>> +
>>> + ret = of_property_read_u32(dn, "ti,ngpio", &val);
>>> + if (ret)
>>> + goto of_err;
>>> +
>>> + pdata->ngpio = val;
>>> +
>>> + ret = of_property_read_u32(dn, "ti,davinci-gpio-unbanked", &val);
>>> + if (ret)
>>> + goto of_err;
>>> +
>>> + pdata->gpio_unbanked = val;
>>> +
>>> + return pdata;
>>> +
>>> +of_err:
>>> + dev_err(&pdev->dev, "Populating pdata from DT failed: err %d\n", ret);
>>> + return NULL;
>>> +}
>>> +
>>> static int davinci_gpio_probe(struct platform_device *pdev)
>>> {
>>> int i, base;
>>> @@ -144,12 +181,14 @@ static int davinci_gpio_probe(struct platform_device *pdev)
>>> struct device *dev = &pdev->dev;
>>> struct resource *res;
>>>
>>> - pdata = dev->platform_data;
>>> + pdata = davinci_gpio_get_pdata(pdev);
>>> if (!pdata) {
>>> dev_err(dev, "No platform data found\n");
>>> return -EINVAL;
>>> }
>>>
>>> + dev->platform_data = pdata;
>>> +
>>
>> Pls, add following code to GPIO chip initialization:
>>
>> @@ -233,6 +245,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
>> chips[i].chip.ngpio = ngpio - base;
>> if (chips[i].chip.ngpio > 32)
>> chips[i].chip.ngpio = 32;
>> +#ifdef CONFIG_OF_GPIO
>> + chips[i].chip.of_node = dev->of_node;
>> +#endif
>>
>>
> OK
>
> Regards,
> --Prabhakar Lad
>
WARNING: multiple messages have this Message-ID (diff)
From: grygorii.strashko@ti.com (Grygorii Strashko)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 5/7] gpio: davinci: add OF support
Date: Mon, 11 Nov 2013 17:44:12 +0200 [thread overview]
Message-ID: <5280FB4C.80404@ti.com> (raw)
In-Reply-To: <CA+V-a8tW9dKsE+Ps_MSsr_BsDR2HVE7uEE9GN7yNga3YWoCGow@mail.gmail.com>
On 11/11/2013 05:37 PM, Prabhakar Lad wrote:
> Hi Grygorii,
>
> Thanks for the review.
>
> On Mon, Nov 11, 2013 at 8:48 PM, Grygorii Strashko
> <grygorii.strashko@ti.com> wrote:
>> On 11/08/2013 12:11 PM, Prabhakar Lad wrote:
> [Snip]
>>> @@ -134,6 +137,40 @@ davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
>>> writel((1 << offset), value ? &g->set_data : &g->clr_data);
>>> }
>>>
>>> +static struct davinci_gpio_platform_data *
>>> +davinci_gpio_get_pdata(struct platform_device *pdev)
>>
>> Minor: usually such functions have "_of" in their names:
>> davinci_gpio_of_get_pdata()
>>
> Ahh but actual this function is intended to get pdata in both the
> cases DT and NON-DT, so kept it generic :)
np
>
>>> +{
>>> + struct device_node *dn = pdev->dev.of_node;
>>> + struct davinci_gpio_platform_data *pdata;
>>> + int ret;
>>> + u32 val;
>>> +
>>> + if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node)
>>> + return pdev->dev.platform_data;
>>> +
>>> + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
>>> + if (!pdata)
>>> + return NULL;
>>> +
>>> + ret = of_property_read_u32(dn, "ti,ngpio", &val);
>>> + if (ret)
>>> + goto of_err;
>>> +
>>> + pdata->ngpio = val;
>>> +
>>> + ret = of_property_read_u32(dn, "ti,davinci-gpio-unbanked", &val);
>>> + if (ret)
>>> + goto of_err;
>>> +
>>> + pdata->gpio_unbanked = val;
>>> +
>>> + return pdata;
>>> +
>>> +of_err:
>>> + dev_err(&pdev->dev, "Populating pdata from DT failed: err %d\n", ret);
>>> + return NULL;
>>> +}
>>> +
>>> static int davinci_gpio_probe(struct platform_device *pdev)
>>> {
>>> int i, base;
>>> @@ -144,12 +181,14 @@ static int davinci_gpio_probe(struct platform_device *pdev)
>>> struct device *dev = &pdev->dev;
>>> struct resource *res;
>>>
>>> - pdata = dev->platform_data;
>>> + pdata = davinci_gpio_get_pdata(pdev);
>>> if (!pdata) {
>>> dev_err(dev, "No platform data found\n");
>>> return -EINVAL;
>>> }
>>>
>>> + dev->platform_data = pdata;
>>> +
>>
>> Pls, add following code to GPIO chip initialization:
>>
>> @@ -233,6 +245,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
>> chips[i].chip.ngpio = ngpio - base;
>> if (chips[i].chip.ngpio > 32)
>> chips[i].chip.ngpio = 32;
>> +#ifdef CONFIG_OF_GPIO
>> + chips[i].chip.of_node = dev->of_node;
>> +#endif
>>
>>
> OK
>
> Regards,
> --Prabhakar Lad
>
next prev parent reply other threads:[~2013-11-11 15:47 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-08 10:11 [PATCH v5 0/7] gpio: daVinci: cleanup and feature enhancement Prabhakar Lad
2013-11-08 10:11 ` Prabhakar Lad
2013-11-08 10:11 ` [PATCH v5 1/7] gpio: davinci: remove unnecessary printk Prabhakar Lad
2013-11-08 10:11 ` Prabhakar Lad
[not found] ` <1383905510-31760-2-git-send-email-prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-11-08 15:39 ` Grygorii Strashko
2013-11-08 15:39 ` Grygorii Strashko
2013-11-08 15:39 ` Grygorii Strashko
2013-11-11 15:39 ` Prabhakar Lad
2013-11-11 15:39 ` Prabhakar Lad
2013-11-08 10:11 ` [PATCH v5 2/7] gpio: davinci: use readl/writel instead of __raw_* Prabhakar Lad
2013-11-08 10:11 ` Prabhakar Lad
2013-11-18 13:01 ` Linus Walleij
2013-11-18 13:01 ` Linus Walleij
2013-11-08 10:11 ` [PATCH v5 3/7] gpio: davinci: use irqdomain Prabhakar Lad
2013-11-08 10:11 ` Prabhakar Lad
2013-11-18 13:11 ` Linus Walleij
2013-11-18 13:11 ` Linus Walleij
2013-11-18 13:56 ` Russell King - ARM Linux
2013-11-18 13:56 ` Russell King - ARM Linux
2013-11-18 13:56 ` Russell King - ARM Linux
[not found] ` <CACRpkdaJg4wqtD5xhPVrHJHxFoVwau6jidbOuQ9xFSK_6drxPQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-18 14:34 ` Grygorii Strashko
2013-11-18 14:34 ` Grygorii Strashko
2013-11-18 14:34 ` Grygorii Strashko
2013-11-18 23:06 ` Linus Walleij
2013-11-18 23:06 ` Linus Walleij
[not found] ` <CACRpkda7h4hsMYv_2gdrY+JB80kHu3BkS5OOGyGhEZFc_UkCig-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-19 16:22 ` Grygorii Strashko
2013-11-19 16:22 ` Grygorii Strashko
2013-11-19 16:22 ` Grygorii Strashko
2013-11-19 20:34 ` Linus Walleij
2013-11-19 20:34 ` Linus Walleij
2013-11-08 10:11 ` [PATCH v5 4/7] gpio: davinci: remove unused variable intc_irq_num Prabhakar Lad
2013-11-08 10:11 ` Prabhakar Lad
2013-11-08 10:11 ` [PATCH v5 5/7] gpio: davinci: add OF support Prabhakar Lad
2013-11-08 10:11 ` Prabhakar Lad
[not found] ` <1383905510-31760-6-git-send-email-prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-11-11 15:18 ` Grygorii Strashko
2013-11-11 15:18 ` Grygorii Strashko
2013-11-11 15:18 ` Grygorii Strashko
2013-11-11 15:37 ` Prabhakar Lad
2013-11-11 15:37 ` Prabhakar Lad
2013-11-11 15:44 ` Grygorii Strashko [this message]
2013-11-11 15:44 ` Grygorii Strashko
2013-11-18 13:13 ` Linus Walleij
2013-11-18 13:13 ` Linus Walleij
2013-11-18 13:42 ` Rob Herring
2013-11-18 13:42 ` Rob Herring
2013-11-08 10:11 ` [PATCH v5 6/7] ARM: davinci: da850: add GPIO DT node Prabhakar Lad
2013-11-08 10:11 ` Prabhakar Lad
2013-11-08 10:11 ` [PATCH v5 7/7] ARM: davinci: da850 evm: add GPIO pinumux entries " Prabhakar Lad
2013-11-08 10:11 ` Prabhakar Lad
[not found] ` <1383905510-31760-1-git-send-email-prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-11-11 15:52 ` [PATCH v5 0/7] gpio: daVinci: cleanup and feature enhancement Grygorii Strashko
2013-11-11 15:52 ` Grygorii Strashko
2013-11-11 15:52 ` 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=5280FB4C.80404@ti.com \
--to=grygorii.strashko@ti.com \
--cc=davinci-linux-open-source@linux.davincidsp.com \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=nsekhar@ti.com \
--cc=pawel.moll@arm.com \
--cc=prabhakar.csengg@gmail.com \
--cc=rob.herring@calxeda.com \
--cc=rob@landley.net \
--cc=swarren@wwwdotorg.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.