2013-06-14 09:42:03

by Philip, Avinash

[permalink] [raw]
Subject: [PATCH v2 0/4] GPIO DT support for da850

With conversion of GPIO davinci driver to platform driver, gpio-davinci driver
can support DT boot.
This patch series
- adds dt binding support for gpio-davinci.
- da850 dt support goio.

This patch series is based on Linux 3.10-rc4 and is availabel at [1].

1. https://github.com/avinashphilip/am335x_linux/tree/linux_davinci_v3.10_soc_gpio_v310-rc4

KV Sujith (3):
gpio: davinci: DT changes for driver
ARM: davinci: da850: add GPIO DT entries
ARM: davinci: da850 evm: add GPIO DT data

Philip Avinash (1):
ARM: davinci: da850: Use #include for all device trees

.../devicetree/bindings/gpio/gpio-davinci.txt | 32 +++++++++++
arch/arm/boot/dts/da850-enbw-cmc.dts | 2 +-
arch/arm/boot/dts/da850-evm.dts | 21 +++++++-
arch/arm/boot/dts/da850.dtsi | 17 +++++-
drivers/gpio/gpio-davinci.c | 57 ++++++++++++++++++--
5 files changed, 123 insertions(+), 6 deletions(-)
create mode 100644 Documentation/devicetree/bindings/gpio/gpio-davinci.txt

--
1.7.9.5


2013-06-14 09:44:21

by Philip, Avinash

[permalink] [raw]
Subject: [PATCH v2 1/4] ARM: davinci: da850: Use #include for all device trees

Replace /include/ by #include for da850 device tree files, in order to
use the C pre-processor, making use of #define features possible.

Signed-off-by: Philip Avinash <[email protected]>
---
Changes since v1:
- New patch and comes as a dependency of patch 3/4

arch/arm/boot/dts/da850-enbw-cmc.dts | 2 +-
arch/arm/boot/dts/da850-evm.dts | 2 +-
arch/arm/boot/dts/da850.dtsi | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/da850-enbw-cmc.dts b/arch/arm/boot/dts/da850-enbw-cmc.dts
index 422fdb3..e750ab9 100644
--- a/arch/arm/boot/dts/da850-enbw-cmc.dts
+++ b/arch/arm/boot/dts/da850-enbw-cmc.dts
@@ -10,7 +10,7 @@
* option) any later version.
*/
/dts-v1/;
-/include/ "da850.dtsi"
+#include "da850.dtsi"

/ {
compatible = "enbw,cmc", "ti,da850";
diff --git a/arch/arm/boot/dts/da850-evm.dts b/arch/arm/boot/dts/da850-evm.dts
index c914357..5bce7cc 100644
--- a/arch/arm/boot/dts/da850-evm.dts
+++ b/arch/arm/boot/dts/da850-evm.dts
@@ -8,7 +8,7 @@
* Free Software Foundation, version 2.
*/
/dts-v1/;
-/include/ "da850.dtsi"
+#include "da850.dtsi"

/ {
compatible = "ti,da850-evm", "ti,da850";
diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
index 452bdc6..3b66020 100644
--- a/arch/arm/boot/dts/da850.dtsi
+++ b/arch/arm/boot/dts/da850.dtsi
@@ -7,7 +7,7 @@
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
-/include/ "skeleton.dtsi"
+#include "skeleton.dtsi"

/ {
arm {
--
1.7.9.5

2013-06-14 09:44:53

by Philip, Avinash

[permalink] [raw]
Subject: [PATCH v2 3/4] ARM: davinci: da850: add GPIO DT entries

From: KV Sujith <[email protected]>

Add DT entries for Davinci GPIO.

Signed-off-by: KV Sujith <[email protected]>
Signed-off-by: Philip Avinash <[email protected]>
---
Changes since v1:
- interrupts member defined as array and with interrupt flags

arch/arm/boot/dts/da850.dtsi | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
index 3b66020..cd7b362 100644
--- a/arch/arm/boot/dts/da850.dtsi
+++ b/arch/arm/boot/dts/da850.dtsi
@@ -8,6 +8,7 @@
* option) any later version.
*/
#include "skeleton.dtsi"
+#include <dt-bindings/interrupt-controller/irq.h>

/ {
arm {
@@ -126,6 +127,20 @@
>;
};
};
+ gpio: gpio@1e26000 {
+ compatible = "ti,da830-gpio";
+ reg = <0x226000 0x1000>;
+ interrupts = <42 IRQ_TYPE_EDGE_BOTH
+ 43 IRQ_TYPE_EDGE_BOTH 44 IRQ_TYPE_EDGE_BOTH
+ 45 IRQ_TYPE_EDGE_BOTH 46 IRQ_TYPE_EDGE_BOTH
+ 47 IRQ_TYPE_EDGE_BOTH 48 IRQ_TYPE_EDGE_BOTH
+ 49 IRQ_TYPE_EDGE_BOTH 50 IRQ_TYPE_EDGE_BOTH>;
+ ngpio = <144>;
+ intc_irq_num = <101>;
+ gpio_unbanked = <0>;
+ status = "disabled";
+ };
serial0: serial@1c42000 {
compatible = "ns16550a";
reg = <0x42000 0x100>;
--
1.7.9.5

2013-06-14 09:45:11

by Philip, Avinash

[permalink] [raw]
Subject: [PATCH v2 4/4] ARM: davinci: da850 evm: add GPIO DT data

From: KV Sujith <[email protected]>

- Add GPIO DT Data and pinmux for DA850 EVM. GPIO is configurable differently
on different boards. So add GPIO pinmuxing in dts file.
- Dependency: This patch is dependent on Grab-pin-control patch;
https://patchwork.kernel.org/patch/2013751/

Signed-off-by: KV Sujith <[email protected]>
Signed-off-by: Philip Avinash <[email protected]>
---
arch/arm/boot/dts/da850-evm.dts | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/arch/arm/boot/dts/da850-evm.dts b/arch/arm/boot/dts/da850-evm.dts
index 5bce7cc..2c127ff 100644
--- a/arch/arm/boot/dts/da850-evm.dts
+++ b/arch/arm/boot/dts/da850-evm.dts
@@ -17,6 +17,20 @@
soc {
pmx_core: pinmux@1c14120 {
status = "okay";
+ gpio_pins: pinmux_gpio_pins {
+ pinctrl-single,bits = <
+ /* GPIO2_4 GPIO2_6 */
+ 0x18 0x00008080 0x0000f0f0
+ /* GPIO2_8 GPIO2_15 */
+ 0x14 0x80000008 0xf000000f
+ /* GPIO3_12 GPIO3_13 */
+ 0x1C 0x00008800 0x0000ff00
+ /* GPIO4_0 GPIO4_1 */
+ 0x28 0x88000000 0xff000000
+ /* GPIO6_9 GPIO6_10 GPIO6_13 */
+ 0x34 0x08800800 0x0ff00f00
+ >;
+ };
};
serial0: serial@1c42000 {
status = "okay";
@@ -90,6 +104,11 @@
};
};
};
+ gpio: gpio@1e26000 {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio_pins>;
+ };
};
nand_cs3@62000000 {
status = "okay";
--
1.7.9.5

2013-06-14 10:19:10

by Philip Avinash

[permalink] [raw]
Subject: [PATCH v2 2/4] gpio: davinci: DT changes for driver

From: KV Sujith <[email protected]>

- Add of_device_id for Davinci GPIO driver.
- Add function to populate data from DT.
- Modify the probe to read from DT if DT match is found.
- Add DT binding documentation for Davinci GPIO properties in a new file
gpio-davinci.txt located at Documentation/devicetree/bindings/gpio/.

Signed-off-by: KV Sujith <[email protected]>
Signed-off-by: Philip Avinash <[email protected]>
---
Changes since v1:
- description for interrupts changed to reflecti
interrupt array usage.

.../devicetree/bindings/gpio/gpio-davinci.txt | 32 +++++++++++
drivers/gpio/gpio-davinci.c | 57 ++++++++++++++++++--
2 files changed, 86 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/gpio/gpio-davinci.txt b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt
new file mode 100644
index 0000000..1c31638
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt
@@ -0,0 +1,32 @@
+Davinci GPIO controller bindings
+
+Required Properties:
+- compatible:"ti,da830-gpio"
+
+- reg: Physical base address of the controller and length of memory mapped
+ region.
+
+- interrupts: Array of GPIO interrupt number.
+
+- ngpio: The number of GPIO pins supported
+
+- intc_irq_num: The number of IRQs supported by the Interrupt Controller
+
+- gpio_unbanked: The number of GPIOs that have an individual interrupt
+ line to processor.
+
+Example:
+#include <dt-bindings/interrupt-controller/irq.h>
+
+gpio: gpio@1e26000 {
+ compatible = "ti,da830-gpio";
+ reg = <0x226000 0x1000>;
+ interrupts = <42 IRQ_TYPE_EDGE_BOTH 43 IRQ_TYPE_EDGE_BOTH
+ 44 IRQ_TYPE_EDGE_BOTH 45 IRQ_TYPE_EDGE_BOTH
+ 46 IRQ_TYPE_EDGE_BOTH 47 IRQ_TYPE_EDGE_BOTH
+ 48 IRQ_TYPE_EDGE_BOTH 49 IRQ_TYPE_EDGE_BOTH
+ 50 IRQ_TYPE_EDGE_BOTH>;
+ ngpio = <144>;
+ intc_irq_num = <101>;
+ gpio_unbanked = <0>;
+};
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 475a5ece..cd2ed25 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -20,6 +20,8 @@
#include <linux/irqdomain.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/platform_data/gpio-davinci.h>

@@ -137,6 +139,50 @@ davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
__raw_writel((1 << offset), value ? &g->set_data : &g->clr_data);
}

+static struct davinci_gpio_platform_data *davinci_gpio_set_pdata_of(
+ struct platform_device *pdev)
+{
+ struct device_node *dn = pdev->dev.of_node;
+ struct davinci_gpio_platform_data *pdata;
+ u32 val, ret;
+
+ pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+ if (pdata) {
+ ret = of_property_read_u32(dn, "ngpio", &val);
+ if (ret)
+ goto of_err;
+
+ pdata->ngpio = val;
+
+ ret = of_property_read_u32(dn, "gpio_unbanked", &val);
+ if (ret)
+ goto of_err;
+
+ pdata->gpio_unbanked = val;
+
+ ret = of_property_read_u32(dn, "intc_irq_num", &val);
+ if (ret)
+ goto of_err;
+
+ pdata->intc_irq_num = val;
+ }
+
+ return pdata;
+
+of_err:
+ dev_err(&pdev->dev, "Populating pdata from DT failed: err %d\n", ret);
+ return NULL;
+}
+
+static const struct of_device_id davinci_gpio_ids[] = {
+ {
+ .compatible = "ti,da830-gpio",
+ },
+ { },
+};
+
+MODULE_DEVICE_TABLE(of, davinci_gpio_ids);
+
static int davinci_gpio_probe(struct platform_device *pdev)
{
int i, base;
@@ -146,13 +192,17 @@ static int davinci_gpio_probe(struct platform_device *pdev)
struct davinci_gpio_regs __iomem *regs;
struct device *dev = &pdev->dev;
struct resource *res;
+ const struct of_device_id *match =
+ of_match_device(of_match_ptr(davinci_gpio_ids), &pdev->dev);

- pdata = dev->platform_data;
+ pdata = match ? davinci_gpio_set_pdata_of(pdev) : dev->platform_data;
if (!pdata) {
dev_err(dev, "No platform data found\n");
return -EINVAL;
}

+ dev->platform_data = pdata;
+
/*
* The gpio banks conceptually expose a segmented bitmap,
* and "ngpio" is one more than the largest zero-based
@@ -497,8 +547,9 @@ done:
static struct platform_driver davinci_gpio_driver = {
.probe = davinci_gpio_probe,
.driver = {
- .name = "davinci_gpio",
- .owner = THIS_MODULE,
+ .name = "davinci_gpio",
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(davinci_gpio_ids),
},
};

--
1.7.9.5

2013-06-14 10:22:31

by Philip, Avinash

[permalink] [raw]
Subject: RE: [PATCH v2 0/4] GPIO DT support for da850

On Fri, Jun 14, 2013 at 15:13:36, Philip, Avinash wrote:
> With conversion of GPIO davinci driver to platform driver, gpio-davinci driver
> can support DT boot.
> This patch series
> - adds dt binding support for gpio-davinci.
> - da850 dt support goio.
>
> This patch series is based on Linux 3.10-rc4 and is availabel at [1].
>
> 1. https://github.com/avinashphilip/am335x_linux/tree/linux_davinci_v3.10_soc_gpio_v310-rc4


This patch series has dependency on [PATCH v2 0/7] Convert GPIO Davinci to platform driver

https://lkml.org/lkml/2013/6/14/120

Thanks
Avinash

>
> KV Sujith (3):
> gpio: davinci: DT changes for driver
> ARM: davinci: da850: add GPIO DT entries
> ARM: davinci: da850 evm: add GPIO DT data
>
> Philip Avinash (1):
> ARM: davinci: da850: Use #include for all device trees
>
> .../devicetree/bindings/gpio/gpio-davinci.txt | 32 +++++++++++
> arch/arm/boot/dts/da850-enbw-cmc.dts | 2 +-
> arch/arm/boot/dts/da850-evm.dts | 21 +++++++-
> arch/arm/boot/dts/da850.dtsi | 17 +++++-
> drivers/gpio/gpio-davinci.c | 57 ++++++++++++++++++--
> 5 files changed, 123 insertions(+), 6 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/gpio/gpio-davinci.txt
>
> --
> 1.7.9.5
>
> _______________________________________________
> Davinci-linux-open-source mailing list
> [email protected]
> http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
>

2013-06-19 19:10:43

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v2 2/4] gpio: davinci: DT changes for driver

On Fri, Jun 14, 2013 at 12:20 PM, Philip Avinash
<[email protected]> wrote:

> From: KV Sujith <[email protected]>
>
> - Add of_device_id for Davinci GPIO driver.
> - Add function to populate data from DT.
> - Modify the probe to read from DT if DT match is found.
> - Add DT binding documentation for Davinci GPIO properties in a new file
> gpio-davinci.txt located at Documentation/devicetree/bindings/gpio/.
>
> Signed-off-by: KV Sujith <[email protected]>
> Signed-off-by: Philip Avinash <[email protected]>
> ---
> Changes since v1:
> - description for interrupts changed to reflecti
> interrupt array usage.
(...)

> +static struct davinci_gpio_platform_data *davinci_gpio_set_pdata_of(
> + struct platform_device *pdev)
> +{
> + struct device_node *dn = pdev->dev.of_node;
> + struct davinci_gpio_platform_data *pdata;
> + u32 val, ret;
> +
> + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> + if (pdata) {

Instead of this arrow pattern:

if (!pdata) {
dev_err( ... "out of memory allocating platform data");
return NULL;
}

And de-indent the rest.

With that change:
Acked-by: Linus Walleij <[email protected]>

I guess this may go through the DaVinci tree with the rest of the DaVinci
patches?

Yours,
Linus Walleij

2013-06-20 04:52:26

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH v2 2/4] gpio: davinci: DT changes for driver

On 6/20/2013 12:40 AM, Linus Walleij wrote:
> On Fri, Jun 14, 2013 at 12:20 PM, Philip Avinash
> <[email protected]> wrote:
>
>> From: KV Sujith <[email protected]>
>>
>> - Add of_device_id for Davinci GPIO driver.
>> - Add function to populate data from DT.
>> - Modify the probe to read from DT if DT match is found.
>> - Add DT binding documentation for Davinci GPIO properties in a new file
>> gpio-davinci.txt located at Documentation/devicetree/bindings/gpio/.
>>
>> Signed-off-by: KV Sujith <[email protected]>
>> Signed-off-by: Philip Avinash <[email protected]>
>> ---
>> Changes since v1:
>> - description for interrupts changed to reflecti
>> interrupt array usage.
> (...)
>
>> +static struct davinci_gpio_platform_data *davinci_gpio_set_pdata_of(
>> + struct platform_device *pdev)
>> +{
>> + struct device_node *dn = pdev->dev.of_node;
>> + struct davinci_gpio_platform_data *pdata;
>> + u32 val, ret;
>> +
>> + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
>> + if (pdata) {
>
> Instead of this arrow pattern:
>
> if (!pdata) {
> dev_err( ... "out of memory allocating platform data");
> return NULL;
> }
>
> And de-indent the rest.
>
> With that change:
> Acked-by: Linus Walleij <[email protected]>
>
> I guess this may go through the DaVinci tree with the rest of the DaVinci
> patches?

Linus, yes, I will pick these up with your acks.

Thanks,
Sekhar

2013-06-20 10:37:00

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH v2 2/4] gpio: davinci: DT changes for driver

On 6/14/2013 3:50 PM, Philip Avinash wrote:
> From: KV Sujith <[email protected]>
>
> - Add of_device_id for Davinci GPIO driver.
> - Add function to populate data from DT.
> - Modify the probe to read from DT if DT match is found.
> - Add DT binding documentation for Davinci GPIO properties in a new file
> gpio-davinci.txt located at Documentation/devicetree/bindings/gpio/.
>
> Signed-off-by: KV Sujith <[email protected]>
> Signed-off-by: Philip Avinash <[email protected]>
> ---
> Changes since v1:
> - description for interrupts changed to reflecti
> interrupt array usage.
>
> .../devicetree/bindings/gpio/gpio-davinci.txt | 32 +++++++++++
> drivers/gpio/gpio-davinci.c | 57 ++++++++++++++++++--
> 2 files changed, 86 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/gpio/gpio-davinci.txt b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt
> new file mode 100644
> index 0000000..1c31638
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt
> @@ -0,0 +1,32 @@
> +Davinci GPIO controller bindings
> +
> +Required Properties:
> +- compatible:"ti,da830-gpio"

"ti,dm6441-gpio" instead since this came first on DM6441?

> +
> +- reg: Physical base address of the controller and length of memory mapped
> + region.
> +
> +- interrupts: Array of GPIO interrupt number.
> +
> +- ngpio: The number of GPIO pins supported

Is this a generic GPIO property? I could not find it in documentation.
Looks like Marvell GPIO uses a similar property too, but even there it
is not marked as Marvell specific. Should this be added as a generic
GPIO property?

> +- intc_irq_num: The number of IRQs supported by the Interrupt Controller

You are not actually looking at the number of IRQs interrupt controller
on the SoC supports (which is quite unrelated to GPIO module). What you
are actually looking for is the base from where GPIO interrupt numbering
can start. So "ti,davinci-gpio-irq-base" is more meaningful.

That said, this property is probably not required if irqdomains are used
(I myself have to read about that). Not sure if it is okay to add this
property now waiting for irqdomain conversion. I will let Linus take a call.

> +
> +- gpio_unbanked: The number of GPIOs that have an individual interrupt
> + line to processor.

This is also a TI specific property so it should be
"ti,davinci-gpio-unbanked".

Thanks,
Sekhar

2013-06-20 11:07:14

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] ARM: davinci: da850: Use #include for all device trees

On 6/14/2013 3:15 PM, Philip Avinash wrote:
> Replace /include/ by #include for da850 device tree files, in order to
> use the C pre-processor, making use of #define features possible.
>
> Signed-off-by: Philip Avinash <[email protected]>

Added this to my v3.11/dt branch.

Thanks,
Sekhar

2013-08-11 09:34:52

by Lad, Prabhakar

[permalink] [raw]
Subject: Re: [PATCH v2 0/4] GPIO DT support for da850

Hi Sekhar,

On Fri, Jun 14, 2013 at 3:50 PM, Philip, Avinash <[email protected]> wrote:
> On Fri, Jun 14, 2013 at 15:13:36, Philip, Avinash wrote:
>> With conversion of GPIO davinci driver to platform driver, gpio-davinci driver
>> can support DT boot.
>> This patch series
>> - adds dt binding support for gpio-davinci.
>> - da850 dt support goio.
>>
>> This patch series is based on Linux 3.10-rc4 and is availabel at [1].
>>
>> 1. https://github.com/avinashphilip/am335x_linux/tree/linux_davinci_v3.10_soc_gpio_v310-rc4
>
>
> This patch series has dependency on [PATCH v2 0/7] Convert GPIO Davinci to platform driver
>
> https://lkml.org/lkml/2013/6/14/120
>
What is the status of this patch series is any one taking care of it or
else I can take care of review comments and repost them.

Regards,
--Prabhakar Lad

2013-08-14 04:43:19

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH v2 0/4] GPIO DT support for da850

Hi Prabhakar,

On 8/11/2013 3:04 PM, Prabhakar Lad wrote:
> Hi Sekhar,
>
> On Fri, Jun 14, 2013 at 3:50 PM, Philip, Avinash <[email protected]> wrote:
>> On Fri, Jun 14, 2013 at 15:13:36, Philip, Avinash wrote:
>>> With conversion of GPIO davinci driver to platform driver, gpio-davinci driver
>>> can support DT boot.
>>> This patch series
>>> - adds dt binding support for gpio-davinci.
>>> - da850 dt support goio.
>>>
>>> This patch series is based on Linux 3.10-rc4 and is availabel at [1].
>>>
>>> 1. https://github.com/avinashphilip/am335x_linux/tree/linux_davinci_v3.10_soc_gpio_v310-rc4
>>
>>
>> This patch series has dependency on [PATCH v2 0/7] Convert GPIO Davinci to platform driver
>>
>> https://lkml.org/lkml/2013/6/14/120
>>
> What is the status of this patch series is any one taking care of it or
> else I can take care of review comments and repost them.

Avinash is not working for TI anymore. It will be great if you can take
this up.

Thanks,
Sekhar