All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] dm:gpio:mxc get configuration from dtb
@ 2015-01-19  6:11 Peng Fan
  2015-01-19 19:00 ` Igor Grinberg
  2015-01-19 19:45 ` Simon Glass
  0 siblings, 2 replies; 4+ messages in thread
From: Peng Fan @ 2015-01-19  6:11 UTC (permalink / raw)
  To: u-boot

This patch supports getting gpios' configuration from dtb.
CONFIG_OF_CONTROL is used to indicated which part is for device tree,
and which is not.

This patch is already tested on mx6sxsabresd board. Since device tree
has not been upstreamed, if want to test this patch. The followings
need to be done.
 + pieces of code does not gpio_request when using gpio_direction_xxx and
   etc, need to request gpio.
 + move the gpio settings from board_early_init_f to board_init
 + define CONFIG_DM ,CONFIG_DM_GPIO and CONFIG_OF_CONTROL
 + Add device tree file and do related configuration in
   `make ARCH=arm menuconfig`

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
---
 drivers/gpio/mxc_gpio.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
index 8bb9e39..8603068 100644
--- a/drivers/gpio/mxc_gpio.c
+++ b/drivers/gpio/mxc_gpio.c
@@ -14,6 +14,10 @@
 #include <asm/arch/imx-regs.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
+#ifdef CONFIG_OF_CONTROL
+#include <fdtdec.h>
+DECLARE_GLOBAL_DATA_PTR;
+#endif
 
 enum mxc_gpio_direction {
 	MXC_GPIO_DIRECTION_IN,
@@ -258,6 +262,7 @@ static const struct dm_gpio_ops gpio_mxc_ops = {
 	.get_function		= mxc_gpio_get_function,
 };
 
+#ifndef CONFIG_OF_CONTROL
 static const struct mxc_gpio_plat mxc_plat[] = {
 	{ (struct gpio_regs *)GPIO1_BASE_ADDR },
 	{ (struct gpio_regs *)GPIO2_BASE_ADDR },
@@ -274,6 +279,7 @@ static const struct mxc_gpio_plat mxc_plat[] = {
 	{ (struct gpio_regs *)GPIO7_BASE_ADDR },
 #endif
 };
+#endif
 
 static int mxc_gpio_probe(struct udevice *dev)
 {
@@ -283,7 +289,19 @@ static int mxc_gpio_probe(struct udevice *dev)
 	int banknum;
 	char name[18], *str;
 
+#ifdef CONFIG_OF_CONTROL
+	/*
+	 * In dts file add:
+	 * aliases {
+	 *	gpio0 = &gpio1;
+	 *	gpio1 = &gpio2;
+	 *	.....
+	 * };
+	 * Then set banknum accoring dev's seq number. */
+	banknum = dev->seq;
+#else
 	banknum = plat - mxc_plat;
+#endif
 	sprintf(name, "GPIO%d_", banknum + 1);
 	str = strdup(name);
 	if (!str)
@@ -295,14 +313,71 @@ static int mxc_gpio_probe(struct udevice *dev)
 	return 0;
 }
 
+#ifdef CONFIG_OF_CONTROL
+static int mxc_gpio_bind(struct udevice *device)
+{
+	struct mxc_gpio_plat *plat = device->platdata;
+	struct gpio_regs *ctrl;
+
+	if (plat)
+		return 0;
+	/*
+	 * In the dts file, gpiox bank are as following:
+	 *	gpio1: gpio at 0209c000 {
+	 *		compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
+	 *		reg = <0x0209c000 0x4000>;
+	 *		interrupts = <0 66 0x04 0 67 0x04>;
+	 *		gpio-controller;
+	 *		#gpio-cells = <2>;
+	 *		interrupt-controller;
+	 *		#interrupt-cells = <2>;
+	 *	};
+	 *
+	 *	gpio2: gpio at 020a0000 {
+	 *		compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
+	 *		reg = <0x020a0000 0x4000>;
+	 *		interrupts = <0 68 0x04 0 69 0x04>;
+	 *		gpio-controller;
+	 *		#gpio-cells = <2>;
+	 *		interrupt-controller;
+	 *		#interrupt-cells = <2>;
+	 *	};
+	 *
+	 * gpio1 is the 1st bank, gpio2 is the 2nd bank and gpio3 ....
+	 */
+
+	ctrl = (struct gpio_regs *)fdtdec_get_addr(gd->fdt_blob,
+						   device->of_offset, "reg");
+	plat = calloc(1, sizeof(*plat));
+	if (!plat)
+		return -ENOMEM;
+
+	plat->regs = ctrl;
+
+	device->platdata = plat;
+
+	return 0;
+}
+
+static const struct udevice_id mxc_gpio_ids[] = {
+	{ .compatible = "fsl,imx35-gpio" },
+	{ }
+};
+#endif
+
 U_BOOT_DRIVER(gpio_mxc) = {
 	.name	= "gpio_mxc",
 	.id	= UCLASS_GPIO,
 	.ops	= &gpio_mxc_ops,
 	.probe	= mxc_gpio_probe,
 	.priv_auto_alloc_size = sizeof(struct mxc_bank_info),
+#ifdef CONFIG_OF_CONTROL
+	.of_match = mxc_gpio_ids,
+	.bind	= mxc_gpio_bind,
+#endif
 };
 
+#ifndef CONFIG_OF_CONTROL
 U_BOOT_DEVICES(mxc_gpios) = {
 	{ "gpio_mxc", &mxc_plat[0] },
 	{ "gpio_mxc", &mxc_plat[1] },
@@ -320,3 +395,4 @@ U_BOOT_DEVICES(mxc_gpios) = {
 #endif
 };
 #endif
+#endif
-- 
1.8.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] dm:gpio:mxc get configuration from dtb
  2015-01-19  6:11 [U-Boot] [PATCH] dm:gpio:mxc get configuration from dtb Peng Fan
@ 2015-01-19 19:00 ` Igor Grinberg
  2015-01-19 19:45 ` Simon Glass
  1 sibling, 0 replies; 4+ messages in thread
From: Igor Grinberg @ 2015-01-19 19:00 UTC (permalink / raw)
  To: u-boot

Hi Peng Fan,

On 01/19/15 08:11, Peng Fan wrote:
> This patch supports getting gpios' configuration from dtb.
> CONFIG_OF_CONTROL is used to indicated which part is for device tree,
> and which is not.

Can we please avoid the DT #ifdeffery in the drivers?
and just implement the needed API stubs?

> 
> This patch is already tested on mx6sxsabresd board. Since device tree
> has not been upstreamed, if want to test this patch. The followings
> need to be done.
>  + pieces of code does not gpio_request when using gpio_direction_xxx and
>    etc, need to request gpio.
>  + move the gpio settings from board_early_init_f to board_init
>  + define CONFIG_DM ,CONFIG_DM_GPIO and CONFIG_OF_CONTROL
>  + Add device tree file and do related configuration in
>    `make ARCH=arm menuconfig`
> 
> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
> ---
>  drivers/gpio/mxc_gpio.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 76 insertions(+)
> 
> diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
> index 8bb9e39..8603068 100644
> --- a/drivers/gpio/mxc_gpio.c
> +++ b/drivers/gpio/mxc_gpio.c
> @@ -14,6 +14,10 @@
>  #include <asm/arch/imx-regs.h>
>  #include <asm/gpio.h>
>  #include <asm/io.h>
> +#ifdef CONFIG_OF_CONTROL
> +#include <fdtdec.h>
> +DECLARE_GLOBAL_DATA_PTR;
> +#endif

Is there a problem  to include fdtdec.h with no CONFIG_OF_CONTROL?

>  
>  enum mxc_gpio_direction {
>  	MXC_GPIO_DIRECTION_IN,
> @@ -258,6 +262,7 @@ static const struct dm_gpio_ops gpio_mxc_ops = {
>  	.get_function		= mxc_gpio_get_function,
>  };
>  
> +#ifndef CONFIG_OF_CONTROL
>  static const struct mxc_gpio_plat mxc_plat[] = {
>  	{ (struct gpio_regs *)GPIO1_BASE_ADDR },
>  	{ (struct gpio_regs *)GPIO2_BASE_ADDR },
> @@ -274,6 +279,7 @@ static const struct mxc_gpio_plat mxc_plat[] = {
>  	{ (struct gpio_regs *)GPIO7_BASE_ADDR },
>  #endif
>  };
> +#endif

I think instead of compiling this out, you should reuse it.

>  
>  static int mxc_gpio_probe(struct udevice *dev)
>  {
> @@ -283,7 +289,19 @@ static int mxc_gpio_probe(struct udevice *dev)
>  	int banknum;
>  	char name[18], *str;
>  
> +#ifdef CONFIG_OF_CONTROL
> +	/*
> +	 * In dts file add:
> +	 * aliases {
> +	 *	gpio0 = &gpio1;
> +	 *	gpio1 = &gpio2;
> +	 *	.....
> +	 * };
> +	 * Then set banknum accoring dev's seq number. */
> +	banknum = dev->seq;
> +#else
>  	banknum = plat - mxc_plat;
> +#endif

Well, I never liked too much that plat - mxc-plat logic, but
still I think, you should be able to have one implementation for both cases?
There is a good example in doc/driver-model/spi-howto.txt.

>  	sprintf(name, "GPIO%d_", banknum + 1);
>  	str = strdup(name);
>  	if (!str)
> @@ -295,14 +313,71 @@ static int mxc_gpio_probe(struct udevice *dev)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_OF_CONTROL
> +static int mxc_gpio_bind(struct udevice *device)
> +{
> +	struct mxc_gpio_plat *plat = device->platdata;
> +	struct gpio_regs *ctrl;
> +
> +	if (plat)
> +		return 0;
> +	/*
> +	 * In the dts file, gpiox bank are as following:
> +	 *	gpio1: gpio at 0209c000 {
> +	 *		compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
> +	 *		reg = <0x0209c000 0x4000>;
> +	 *		interrupts = <0 66 0x04 0 67 0x04>;
> +	 *		gpio-controller;
> +	 *		#gpio-cells = <2>;
> +	 *		interrupt-controller;
> +	 *		#interrupt-cells = <2>;
> +	 *	};
> +	 *
> +	 *	gpio2: gpio at 020a0000 {
> +	 *		compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
> +	 *		reg = <0x020a0000 0x4000>;
> +	 *		interrupts = <0 68 0x04 0 69 0x04>;
> +	 *		gpio-controller;
> +	 *		#gpio-cells = <2>;
> +	 *		interrupt-controller;
> +	 *		#interrupt-cells = <2>;
> +	 *	};
> +	 *
> +	 * gpio1 is the 1st bank, gpio2 is the 2nd bank and gpio3 ....
> +	 */

The above comment looks not belonging here... but in documentation/dts itself?

> +
> +	ctrl = (struct gpio_regs *)fdtdec_get_addr(gd->fdt_blob,
> +						   device->of_offset, "reg");

How about implementing a stub for this returning NULL?

> +	plat = calloc(1, sizeof(*plat));
> +	if (!plat)
> +		return -ENOMEM;
> +
> +	plat->regs = ctrl;
> +
> +	device->platdata = plat;
> +
> +	return 0;
> +}
> +
> +static const struct udevice_id mxc_gpio_ids[] = {
> +	{ .compatible = "fsl,imx35-gpio" },
> +	{ }
> +};
> +#endif
> +
>  U_BOOT_DRIVER(gpio_mxc) = {
>  	.name	= "gpio_mxc",
>  	.id	= UCLASS_GPIO,
>  	.ops	= &gpio_mxc_ops,
>  	.probe	= mxc_gpio_probe,
>  	.priv_auto_alloc_size = sizeof(struct mxc_bank_info),
> +#ifdef CONFIG_OF_CONTROL
> +	.of_match = mxc_gpio_ids,
> +	.bind	= mxc_gpio_bind,
> +#endif
>  };
>  
> +#ifndef CONFIG_OF_CONTROL
>  U_BOOT_DEVICES(mxc_gpios) = {
>  	{ "gpio_mxc", &mxc_plat[0] },
>  	{ "gpio_mxc", &mxc_plat[1] },
> @@ -320,3 +395,4 @@ U_BOOT_DEVICES(mxc_gpios) = {
>  #endif
>  };
>  #endif
> +#endif
> 

-- 
Regards,
Igor.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] dm:gpio:mxc get configuration from dtb
  2015-01-19  6:11 [U-Boot] [PATCH] dm:gpio:mxc get configuration from dtb Peng Fan
  2015-01-19 19:00 ` Igor Grinberg
@ 2015-01-19 19:45 ` Simon Glass
  2015-01-20  1:27   ` Peng Fan
  1 sibling, 1 reply; 4+ messages in thread
From: Simon Glass @ 2015-01-19 19:45 UTC (permalink / raw)
  To: u-boot

Hi Peng.

On 18 January 2015 at 23:11, Peng Fan <Peng.Fan@freescale.com> wrote:
> This patch supports getting gpios' configuration from dtb.
> CONFIG_OF_CONTROL is used to indicated which part is for device tree,
> and which is not.
>
> This patch is already tested on mx6sxsabresd board. Since device tree
> has not been upstreamed, if want to test this patch. The followings
> need to be done.
>  + pieces of code does not gpio_request when using gpio_direction_xxx and
>    etc, need to request gpio.
>  + move the gpio settings from board_early_init_f to board_init
>  + define CONFIG_DM ,CONFIG_DM_GPIO and CONFIG_OF_CONTROL
>  + Add device tree file and do related configuration in
>    `make ARCH=arm menuconfig`
>

Sorry I am going to repeat some of Igor's comments...

> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
> ---
>  drivers/gpio/mxc_gpio.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 76 insertions(+)
>
> diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
> index 8bb9e39..8603068 100644
> --- a/drivers/gpio/mxc_gpio.c
> +++ b/drivers/gpio/mxc_gpio.c
> @@ -14,6 +14,10 @@
>  #include <asm/arch/imx-regs.h>
>  #include <asm/gpio.h>
>  #include <asm/io.h>
> +#ifdef CONFIG_OF_CONTROL
> +#include <fdtdec.h>
> +DECLARE_GLOBAL_DATA_PTR;
> +#endif

Hopefully #ifdef not needed.

>
>  enum mxc_gpio_direction {
>         MXC_GPIO_DIRECTION_IN,
> @@ -258,6 +262,7 @@ static const struct dm_gpio_ops gpio_mxc_ops = {
>         .get_function           = mxc_gpio_get_function,
>  };
>
> +#ifndef CONFIG_OF_CONTROL
>  static const struct mxc_gpio_plat mxc_plat[] = {
>         { (struct gpio_regs *)GPIO1_BASE_ADDR },
>         { (struct gpio_regs *)GPIO2_BASE_ADDR },
> @@ -274,6 +279,7 @@ static const struct mxc_gpio_plat mxc_plat[] = {
>         { (struct gpio_regs *)GPIO7_BASE_ADDR },
>  #endif

Same here.

>  };
> +#endif
>
>  static int mxc_gpio_probe(struct udevice *dev)
>  {
> @@ -283,7 +289,19 @@ static int mxc_gpio_probe(struct udevice *dev)
>         int banknum;
>         char name[18], *str;
>
> +#ifdef CONFIG_OF_CONTROL
> +       /*
> +        * In dts file add:
> +        * aliases {
> +        *      gpio0 = &gpio1;
> +        *      gpio1 = &gpio2;
> +        *      .....
> +        * };
> +        * Then set banknum accoring dev's seq number. */
> +       banknum = dev->seq;
> +#else
>         banknum = plat - mxc_plat;
> +#endif
>         sprintf(name, "GPIO%d_", banknum + 1);
>         str = strdup(name);
>         if (!str)
> @@ -295,14 +313,71 @@ static int mxc_gpio_probe(struct udevice *dev)
>         return 0;
>  }
>
> +#ifdef CONFIG_OF_CONTROL
> +static int mxc_gpio_bind(struct udevice *device)
> +{
> +       struct mxc_gpio_plat *plat = device->platdata;
> +       struct gpio_regs *ctrl;
> +
> +       if (plat)
> +               return 0;
> +       /*
> +        * In the dts file, gpiox bank are as following:
> +        *      gpio1: gpio at 0209c000 {
> +        *              compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
> +        *              reg = <0x0209c000 0x4000>;
> +        *              interrupts = <0 66 0x04 0 67 0x04>;
> +        *              gpio-controller;
> +        *              #gpio-cells = <2>;
> +        *              interrupt-controller;
> +        *              #interrupt-cells = <2>;
> +        *      };
> +        *
> +        *      gpio2: gpio at 020a0000 {
> +        *              compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
> +        *              reg = <0x020a0000 0x4000>;
> +        *              interrupts = <0 68 0x04 0 69 0x04>;
> +        *              gpio-controller;
> +        *              #gpio-cells = <2>;
> +        *              interrupt-controller;
> +        *              #interrupt-cells = <2>;
> +        *      };
> +        *
> +        * gpio1 is the 1st bank, gpio2 is the 2nd bank and gpio3 ....
> +        */
> +
> +       ctrl = (struct gpio_regs *)fdtdec_get_addr(gd->fdt_blob,
> +                                                  device->of_offset, "reg");
> +       plat = calloc(1, sizeof(*plat));
> +       if (!plat)
> +               return -ENOMEM;
> +
> +       plat->regs = ctrl;
> +
> +       device->platdata = plat;
> +
> +       return 0;
> +}
> +
> +static const struct udevice_id mxc_gpio_ids[] = {
> +       { .compatible = "fsl,imx35-gpio" },
> +       { }
> +};
> +#endif
> +
>  U_BOOT_DRIVER(gpio_mxc) = {
>         .name   = "gpio_mxc",
>         .id     = UCLASS_GPIO,
>         .ops    = &gpio_mxc_ops,
>         .probe  = mxc_gpio_probe,
>         .priv_auto_alloc_size = sizeof(struct mxc_bank_info),
> +#ifdef CONFIG_OF_CONTROL
> +       .of_match = mxc_gpio_ids,
> +       .bind   = mxc_gpio_bind,
> +#endif
>  };
>
> +#ifndef CONFIG_OF_CONTROL
>  U_BOOT_DEVICES(mxc_gpios) = {
>         { "gpio_mxc", &mxc_plat[0] },
>         { "gpio_mxc", &mxc_plat[1] },
> @@ -320,3 +395,4 @@ U_BOOT_DEVICES(mxc_gpios) = {
>  #endif
>  };
>  #endif
> +#endif

Overall I wonder why you don't just convert the boards to device tree?
It might be more work, but it would be a lot cleaner.

Regards,
Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] dm:gpio:mxc get configuration from dtb
  2015-01-19 19:45 ` Simon Glass
@ 2015-01-20  1:27   ` Peng Fan
  0 siblings, 0 replies; 4+ messages in thread
From: Peng Fan @ 2015-01-20  1:27 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 1/20/2015 3:45 AM, Simon Glass wrote:
> Hi Peng.
>
> On 18 January 2015 at 23:11, Peng Fan <Peng.Fan@freescale.com> wrote:
>> This patch supports getting gpios' configuration from dtb.
>> CONFIG_OF_CONTROL is used to indicated which part is for device tree,
>> and which is not.
>>
>> This patch is already tested on mx6sxsabresd board. Since device tree
>> has not been upstreamed, if want to test this patch. The followings
>> need to be done.
>>   + pieces of code does not gpio_request when using gpio_direction_xxx and
>>     etc, need to request gpio.
>>   + move the gpio settings from board_early_init_f to board_init
>>   + define CONFIG_DM ,CONFIG_DM_GPIO and CONFIG_OF_CONTROL
>>   + Add device tree file and do related configuration in
>>     `make ARCH=arm menuconfig`
>>
> Sorry I am going to repeat some of Igor's comments...
I've seen Igor's comments.I'll address them.
>
>> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
>> ---
>>   drivers/gpio/mxc_gpio.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 76 insertions(+)
>>
>> diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
>> index 8bb9e39..8603068 100644
>> --- a/drivers/gpio/mxc_gpio.c
>> +++ b/drivers/gpio/mxc_gpio.c
>> @@ -14,6 +14,10 @@
>>   #include <asm/arch/imx-regs.h>
>>   #include <asm/gpio.h>
>>   #include <asm/io.h>
>> +#ifdef CONFIG_OF_CONTROL
>> +#include <fdtdec.h>
>> +DECLARE_GLOBAL_DATA_PTR;
>> +#endif
> Hopefully #ifdef not needed.
Ok. I'll try to remove them in v2 patch.
>
>>   enum mxc_gpio_direction {
>>          MXC_GPIO_DIRECTION_IN,
>> @@ -258,6 +262,7 @@ static const struct dm_gpio_ops gpio_mxc_ops = {
>>          .get_function           = mxc_gpio_get_function,
>>   };
>>
>> +#ifndef CONFIG_OF_CONTROL
>>   static const struct mxc_gpio_plat mxc_plat[] = {
>>          { (struct gpio_regs *)GPIO1_BASE_ADDR },
>>          { (struct gpio_regs *)GPIO2_BASE_ADDR },
>> @@ -274,6 +279,7 @@ static const struct mxc_gpio_plat mxc_plat[] = {
>>          { (struct gpio_regs *)GPIO7_BASE_ADDR },
>>   #endif
> Same here.
>
>>   };
>> +#endif
>>
>>   static int mxc_gpio_probe(struct udevice *dev)
>>   {
>> @@ -283,7 +289,19 @@ static int mxc_gpio_probe(struct udevice *dev)
>>          int banknum;
>>          char name[18], *str;
>>
>> +#ifdef CONFIG_OF_CONTROL
>> +       /*
>> +        * In dts file add:
>> +        * aliases {
>> +        *      gpio0 = &gpio1;
>> +        *      gpio1 = &gpio2;
>> +        *      .....
>> +        * };
>> +        * Then set banknum accoring dev's seq number. */
>> +       banknum = dev->seq;
>> +#else
>>          banknum = plat - mxc_plat;
>> +#endif
>>          sprintf(name, "GPIO%d_", banknum + 1);
>>          str = strdup(name);
>>          if (!str)
>> @@ -295,14 +313,71 @@ static int mxc_gpio_probe(struct udevice *dev)
>>          return 0;
>>   }
>>
>> +#ifdef CONFIG_OF_CONTROL
>> +static int mxc_gpio_bind(struct udevice *device)
>> +{
>> +       struct mxc_gpio_plat *plat = device->platdata;
>> +       struct gpio_regs *ctrl;
>> +
>> +       if (plat)
>> +               return 0;
>> +       /*
>> +        * In the dts file, gpiox bank are as following:
>> +        *      gpio1: gpio at 0209c000 {
>> +        *              compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
>> +        *              reg = <0x0209c000 0x4000>;
>> +        *              interrupts = <0 66 0x04 0 67 0x04>;
>> +        *              gpio-controller;
>> +        *              #gpio-cells = <2>;
>> +        *              interrupt-controller;
>> +        *              #interrupt-cells = <2>;
>> +        *      };
>> +        *
>> +        *      gpio2: gpio at 020a0000 {
>> +        *              compatible = "fsl,imx6q-gpio", "fsl,imx35-gpio";
>> +        *              reg = <0x020a0000 0x4000>;
>> +        *              interrupts = <0 68 0x04 0 69 0x04>;
>> +        *              gpio-controller;
>> +        *              #gpio-cells = <2>;
>> +        *              interrupt-controller;
>> +        *              #interrupt-cells = <2>;
>> +        *      };
>> +        *
>> +        * gpio1 is the 1st bank, gpio2 is the 2nd bank and gpio3 ....
>> +        */
>> +
>> +       ctrl = (struct gpio_regs *)fdtdec_get_addr(gd->fdt_blob,
>> +                                                  device->of_offset, "reg");
>> +       plat = calloc(1, sizeof(*plat));
>> +       if (!plat)
>> +               return -ENOMEM;
>> +
>> +       plat->regs = ctrl;
>> +
>> +       device->platdata = plat;
>> +
>> +       return 0;
>> +}
>> +
>> +static const struct udevice_id mxc_gpio_ids[] = {
>> +       { .compatible = "fsl,imx35-gpio" },
>> +       { }
>> +};
>> +#endif
>> +
>>   U_BOOT_DRIVER(gpio_mxc) = {
>>          .name   = "gpio_mxc",
>>          .id     = UCLASS_GPIO,
>>          .ops    = &gpio_mxc_ops,
>>          .probe  = mxc_gpio_probe,
>>          .priv_auto_alloc_size = sizeof(struct mxc_bank_info),
>> +#ifdef CONFIG_OF_CONTROL
>> +       .of_match = mxc_gpio_ids,
>> +       .bind   = mxc_gpio_bind,
>> +#endif
>>   };
>>
>> +#ifndef CONFIG_OF_CONTROL
>>   U_BOOT_DEVICES(mxc_gpios) = {
>>          { "gpio_mxc", &mxc_plat[0] },
>>          { "gpio_mxc", &mxc_plat[1] },
>> @@ -320,3 +395,4 @@ U_BOOT_DEVICES(mxc_gpios) = {
>>   #endif
>>   };
>>   #endif
>> +#endif
> Overall I wonder why you don't just convert the boards to device tree?
> It might be more work, but it would be a lot cleaner.
Yeah. Agree. Converting the boards to device tree may require lots of 
change, I am just hacking this in my side for personal interests.

Anyway, I'll try to address you all comments to make it better.
>
> Regards,
> Simon
Regards,
Peng.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-01-20  1:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-19  6:11 [U-Boot] [PATCH] dm:gpio:mxc get configuration from dtb Peng Fan
2015-01-19 19:00 ` Igor Grinberg
2015-01-19 19:45 ` Simon Glass
2015-01-20  1:27   ` Peng Fan

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.