gpio: s5p: call: dev_get_addr() instead of fdtdec_get_addr()
authorPrzemyslaw Marczak <p.marczak@samsung.com>
Wed, 30 Sep 2015 11:14:51 +0000 (13:14 +0200)
committerSimon Glass <sjg@chromium.org>
Sat, 3 Oct 2015 13:39:19 +0000 (14:39 +0100)
After rework in lib/fdtdec.c, the function fdtdec_get_addr()
doesn't work for nodes with #size-cells property set to 0.

To get GPIO's 'reg' property, the code should use one of:
fdtdec_get_addr_size_auto_no/parent() function.

Fortunately dm core provides a function to get the property.

This commit reworks function gpio_exynos_bind(), to properly
use dev_get_addr() for GPIO device.

This prevents setting a wrong base register for Exynos GPIOs.

Tested on: Odroid U3/X2, Trats, Trats2, Odroid XU3, Snow (by Simon).

Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
drivers/gpio/s5p_gpio.c

index 17fcfbf4d3f62ac144152f908852ac034b363a17..0f22b238ba99ec09679df0d8fe840f98632f55d4 100644 (file)
@@ -341,18 +341,22 @@ static int gpio_exynos_bind(struct udevice *parent)
                plat = calloc(1, sizeof(*plat));
                if (!plat)
                        return -ENOMEM;
-               reg = fdtdec_get_addr(blob, node, "reg");
-               if (reg != FDT_ADDR_T_NONE)
-                       bank = (struct s5p_gpio_bank *)((ulong)base + reg);
-               plat->bank = bank;
-               plat->bank_name = fdt_get_name(blob, node, NULL);
-               debug("dev at %p: %s\n", bank, plat->bank_name);
 
+               plat->bank_name = fdt_get_name(blob, node, NULL);
                ret = device_bind(parent, parent->driver,
-                                       plat->bank_name, plat, -1, &dev);
+                                 plat->bank_name, plat, -1, &dev);
                if (ret)
                        return ret;
+
                dev->of_offset = node;
+
+               reg = dev_get_addr(dev);
+               if (reg != FDT_ADDR_T_NONE)
+                       bank = (struct s5p_gpio_bank *)((ulong)base + reg);
+
+               plat->bank = bank;
+
+               debug("dev at %p: %s\n", bank, plat->bank_name);
        }
 
        return 0;