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:44 UTC|newest]
Thread overview: 23+ 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 ` [PATCH v5 1/7] gpio: davinci: remove unnecessary printk Prabhakar Lad
2013-11-08 15:39 ` Grygorii Strashko
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-18 13:01 ` Linus Walleij
2013-11-08 10:11 ` [PATCH v5 3/7] gpio: davinci: use irqdomain Prabhakar Lad
2013-11-18 13:11 ` Linus Walleij
2013-11-18 13:56 ` Russell King - ARM Linux
2013-11-18 14:34 ` Grygorii Strashko
2013-11-18 23:06 ` Linus Walleij
2013-11-19 16:22 ` Grygorii Strashko
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 ` [PATCH v5 5/7] gpio: davinci: add OF support Prabhakar Lad
2013-11-11 15:18 ` Grygorii Strashko
2013-11-11 15:37 ` Prabhakar Lad
2013-11-11 15:44 ` Grygorii Strashko [this message]
2013-11-18 13:13 ` Linus Walleij
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 ` [PATCH v5 7/7] ARM: davinci: da850 evm: add GPIO pinumux entries " Prabhakar Lad
2013-11-11 15:52 ` [PATCH v5 0/7] gpio: daVinci: cleanup and feature enhancement 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=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).