]> git.sur5r.net Git - u-boot/blobdiff - drivers/gpio/mxc_gpio.c
Merge branch 'master' of git://git.denx.de/u-boot-sunxi
[u-boot] / drivers / gpio / mxc_gpio.c
index 70fe5b6a4e3ebb48f798091295d32ddce4ad59be..d8e72ada194322d70a363146ef39f55d22ee5a8a 100644 (file)
@@ -1,11 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2009
  * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de>
  *
  * Copyright (C) 2011
  * Stefano Babic, DENX Software Engineering, <sbabic@denx.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
 #include <errno.h>
@@ -41,18 +40,18 @@ static unsigned long gpio_ports[] = {
        [2] = GPIO3_BASE_ADDR,
 #if defined(CONFIG_MX25) || defined(CONFIG_MX27) || defined(CONFIG_MX51) || \
                defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
-               defined(CONFIG_MX7)
+               defined(CONFIG_MX7) || defined(CONFIG_MX8M)
        [3] = GPIO4_BASE_ADDR,
 #endif
 #if defined(CONFIG_MX27) || defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
-               defined(CONFIG_MX7)
+               defined(CONFIG_MX7) || defined(CONFIG_MX8M)
        [4] = GPIO5_BASE_ADDR,
-#ifndef CONFIG_MX6UL
+#if !(defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL) || defined(CONFIG_MX8M))
        [5] = GPIO6_BASE_ADDR,
 #endif
 #endif
 #if defined(CONFIG_MX53) || defined(CONFIG_MX6) || defined(CONFIG_MX7)
-#ifndef CONFIG_MX6UL
+#if !(defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
        [6] = GPIO7_BASE_ADDR,
 #endif
 #endif
@@ -158,8 +157,6 @@ int gpio_direction_output(unsigned gpio, int value)
 
 #ifdef CONFIG_DM_GPIO
 #include <fdtdec.h>
-DECLARE_GLOBAL_DATA_PTR;
-
 static int mxc_gpio_is_output(struct gpio_regs *regs, int offset)
 {
        u32 val;
@@ -302,15 +299,20 @@ static int mxc_gpio_bind(struct udevice *dev)
        if (plat)
                return 0;
 
-       addr = dev_get_addr(dev);
+       addr = devfdt_get_addr(dev);
        if (addr == FDT_ADDR_T_NONE)
-               return -ENODEV;
+               return -EINVAL;
 
        /*
         * TODO:
         * When every board is converted to driver model and DT is supported,
         * this can be done by auto-alloc feature, but not using calloc
         * to alloc memory for platdata.
+        *
+        * For example mxc_plat below uses platform data rather than device
+        * tree.
+        *
+        * NOTE: DO NOT COPY this code if you are using device tree.
         */
        plat = calloc(1, sizeof(*plat));
        if (!plat)
@@ -344,13 +346,17 @@ static const struct mxc_gpio_plat mxc_plat[] = {
        { 1, (struct gpio_regs *)GPIO2_BASE_ADDR },
        { 2, (struct gpio_regs *)GPIO3_BASE_ADDR },
 #if defined(CONFIG_MX25) || defined(CONFIG_MX27) || defined(CONFIG_MX51) || \
-               defined(CONFIG_MX53) || defined(CONFIG_MX6)
+               defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
+               defined(CONFIG_MX8M)
        { 3, (struct gpio_regs *)GPIO4_BASE_ADDR },
 #endif
-#if defined(CONFIG_MX27) || defined(CONFIG_MX53) || defined(CONFIG_MX6)
+#if defined(CONFIG_MX27) || defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
+               defined(CONFIG_MX8M)
        { 4, (struct gpio_regs *)GPIO5_BASE_ADDR },
+#ifndef CONFIG_MX8M
        { 5, (struct gpio_regs *)GPIO6_BASE_ADDR },
 #endif
+#endif
 #if defined(CONFIG_MX53) || defined(CONFIG_MX6)
        { 6, (struct gpio_regs *)GPIO7_BASE_ADDR },
 #endif
@@ -361,13 +367,17 @@ U_BOOT_DEVICES(mxc_gpios) = {
        { "gpio_mxc", &mxc_plat[1] },
        { "gpio_mxc", &mxc_plat[2] },
 #if defined(CONFIG_MX25) || defined(CONFIG_MX27) || defined(CONFIG_MX51) || \
-               defined(CONFIG_MX53) || defined(CONFIG_MX6)
+               defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
+               defined(CONFIG_MX8M)
        { "gpio_mxc", &mxc_plat[3] },
 #endif
-#if defined(CONFIG_MX27) || defined(CONFIG_MX53) || defined(CONFIG_MX6)
+#if defined(CONFIG_MX27) || defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
+               defined(CONFIG_MX8M)
        { "gpio_mxc", &mxc_plat[4] },
+#ifndef CONFIG_MX8M
        { "gpio_mxc", &mxc_plat[5] },
 #endif
+#endif
 #if defined(CONFIG_MX53) || defined(CONFIG_MX6)
        { "gpio_mxc", &mxc_plat[6] },
 #endif