diff mbox series

[RFC,5/7] gpio: mxc_gpio: add OF_PLATDATA support

Message ID 20200330033158.26751-6-walter.lozano@collabora.com
State New
Headers show
Series mx6cuboxi: enable OF_PLATDATA with MMC support | expand

Commit Message

Walter Lozano March 30, 2020, 3:31 a.m. UTC
Signed-off-by: Walter Lozano <walter.lozano at collabora.com>
---
 drivers/gpio/mxc_gpio.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
diff mbox series

Patch

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) = {
+	.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 },