From patchwork Mon Mar 30 03:31:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Lozano X-Patchwork-Id: 244503 List-Id: U-Boot discussion From: walter.lozano at collabora.com (Walter Lozano) Date: Mon, 30 Mar 2020 00:31:56 -0300 Subject: [RFC 5/7] gpio: mxc_gpio: add OF_PLATDATA support In-Reply-To: <20200330033158.26751-1-walter.lozano@collabora.com> References: <20200330033158.26751-1-walter.lozano@collabora.com> Message-ID: <20200330033158.26751-6-walter.lozano@collabora.com> Signed-off-by: Walter Lozano --- 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 #include #include +#include +#include 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) = { + .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 },