[RFC 5/7] gpio: mxc_gpio: add OF_PLATDATA support
Walter Lozano
walter.lozano at collabora.com
Tue Apr 7 22:05:57 CEST 2020
Hi Simon,
On 6/4/20 00:42, Simon Glass wrote:
> Hi Walter,
>
> On Sun, 29 Mar 2020 at 21:32, Walter Lozano<walter.lozano at collabora.com> wrote:
>> Signed-off-by: Walter Lozano<walter.lozano at collabora.com>
>> ---
>> drivers/gpio/mxc_gpio.c | 27 ++++++++++++++++++++++++++-
>> 1 file changed, 26 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
>> index c924e52f07..ba63c0b76a 100644
>> --- a/drivers/gpio/mxc_gpio.c
>> +++ b/drivers/gpio/mxc_gpio.c
>> @@ -13,6 +13,8 @@
>> #include <asm/arch/imx-regs.h>
>> #include <asm/gpio.h>
>> #include <asm/io.h>
>> +#include <dt-structs.h>
>> +#include <mapmem.h>
>>
>> enum mxc_gpio_direction {
>> MXC_GPIO_DIRECTION_IN,
>> @@ -22,6 +24,10 @@ enum mxc_gpio_direction {
>> #define GPIO_PER_BANK 32
>>
>> struct mxc_gpio_plat {
>> +#if CONFIG_IS_ENABLED(OF_PLATDATA)
>> + /* Put this first since driver model will copy the data here */
>> + struct dtd_fsl_imx6q_gpio dtplat;
>> +#endif
>> int bank_index;
>> struct gpio_regs *regs;
>> };
>> @@ -303,8 +309,16 @@ static int mxc_gpio_bind(struct udevice *dev)
>> * is statically initialized in U_BOOT_DEVICES.Here
>> * will return.
>> */
>> - if (plat)
>> +
>> + if (plat) {
>> +#if CONFIG_IS_ENABLED(OF_PLATDATA)
>> + struct dtd_fsl_imx6q_gpio *dtplat = &plat->dtplat;
>> +
>> + plat->regs = map_sysmem(dtplat->reg[0], dtplat->reg[1]);
>> + plat->bank_index = dev->req_seq;
>> +#endif
>> return 0;
>> + }
>>
>> addr = devfdt_get_addr(dev);
>> if (addr == FDT_ADDR_T_NONE)
>> @@ -347,6 +361,17 @@ U_BOOT_DRIVER(gpio_mxc) = {
>> .bind = mxc_gpio_bind,
>> };
>>
>> +#if CONFIG_IS_ENABLED(OF_PLATDATA)
>> +U_BOOT_DRIVER(fsl_imx6q_gpio) = {
> Please drop this and find a way to use the existing U_BOOT_DRIVER() declaration.
Thanks for pointing it. This discussion already began in a previous
patch from this series, so probably the best way to accomplish this will
be discussed there.
>> + .name = "fsl_imx6q_gpio",
>> + .id = UCLASS_GPIO,
>> + .ops = &gpio_mxc_ops,
>> + .probe = mxc_gpio_probe,
>> + .priv_auto_alloc_size = sizeof(struct mxc_bank_info),
>> + .bind = mxc_gpio_bind,
>> +};
>> +#endif
>> +
>> #if !CONFIG_IS_ENABLED(OF_CONTROL)
>> static const struct mxc_gpio_plat mxc_plat[] = {
>> { 0, (struct gpio_regs *)GPIO1_BASE_ADDR },
>> --
>> 2.20.1
>>
> Regards,
> Simon
More information about the U-Boot
mailing list