phy: Fix possible NULL pointer deference
[oweals/u-boot.git] / drivers / gpio / zynq_gpio.c
index a760c5bdda68d9e8bac3893babf06f9f07d63ad2..d0e90b8d633f5cbe642c8602a46a60e2a95a0e5b 100644 (file)
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
+#include <linux/bitops.h>
 #include <linux/errno.h>
 #include <dm.h>
 #include <fdtdec.h>
@@ -93,6 +94,9 @@
 /* GPIO upper 16 bit mask */
 #define ZYNQ_GPIO_UPPER_MASK 0xFFFF0000
 
+#define PMC_GPIO_NR_GPIOS      116
+#define PMC_GPIO_MAX_BANK      5
+
 struct zynq_gpio_platdata {
        phys_addr_t base;
        const struct zynq_platform_data *p_data;
@@ -114,6 +118,33 @@ struct zynq_platform_data {
        u32 bank_max[ZYNQMP_GPIO_MAX_BANK];
 };
 
+#define VERSAL_GPIO_NR_GPIOS   58
+#define VERSAL_GPIO_MAX_BANK   4
+
+static const struct zynq_platform_data versal_gpio_def = {
+       .label = "versal_gpio",
+       .ngpio = VERSAL_GPIO_NR_GPIOS,
+       .max_bank = VERSAL_GPIO_MAX_BANK,
+       .bank_min[0] = 0,
+       .bank_max[0] = 25,
+       .bank_min[3] = 26,
+       .bank_max[3] = 57,
+};
+
+static const struct zynq_platform_data pmc_gpio_def = {
+       .label = "pmc_gpio",
+       .ngpio = PMC_GPIO_NR_GPIOS,
+       .max_bank = PMC_GPIO_MAX_BANK,
+       .bank_min[0] = 0,
+       .bank_max[0] = 25,
+       .bank_min[1] = 26,
+       .bank_max[1] = 51,
+       .bank_min[3] = 52,
+       .bank_max[3] = 83,
+       .bank_min[4] = 84,
+       .bank_max[4] = 115,
+};
+
 static const struct zynq_platform_data zynqmp_gpio_def = {
        .label = "zynqmp_gpio",
        .ngpio = ZYNQMP_GPIO_NR_GPIOS,
@@ -329,6 +360,10 @@ static const struct udevice_id zynq_gpio_ids[] = {
          .data = (ulong)&zynq_gpio_def},
        { .compatible = "xlnx,zynqmp-gpio-1.0",
          .data = (ulong)&zynqmp_gpio_def},
+       { .compatible = "xlnx,versal-gpio-1.0",
+         .data = (ulong)&versal_gpio_def},
+       { .compatible = "xlnx,pmc-gpio-1.0",
+         .data = (ulong)&pmc_gpio_def },
        { }
 };