]> git.sur5r.net Git - u-boot/commitdiff
dm: Use dev_get_addr() where possible
authorSimon Glass <sjg@chromium.org>
Tue, 11 Aug 2015 14:33:29 +0000 (08:33 -0600)
committerSimon Glass <sjg@chromium.org>
Mon, 31 Aug 2015 13:57:26 +0000 (07:57 -0600)
This is a convenient way for a driver to get the hardware address of a
device, when regmap or syscon are not being used. Change existing callers
to use it as an example to others.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
20 files changed:
drivers/core/device.c
drivers/gpio/s5p_gpio.c
drivers/gpio/sunxi_gpio.c
drivers/gpio/tegra_gpio.c
drivers/i2c/s3c24x0_i2c.c
drivers/i2c/tegra_i2c.c
drivers/serial/ns16550.c
drivers/serial/serial_arc.c
drivers/serial/serial_pl01x.c
drivers/serial/serial_s5p.c
drivers/spi/designware_spi.c
drivers/spi/exynos_spi.c
drivers/spi/fsl_dspi.c
drivers/spi/tegra114_spi.c
drivers/spi/tegra20_sflash.c
drivers/spi/tegra20_slink.c
drivers/spi/zynq_spi.c
drivers/usb/host/ehci-tegra.c
drivers/usb/host/xhci-exynos5.c
drivers/video/tegra124/dp.c

index a31e25f6b5c5b30b92c2d0251c5dd083f3939de2..826d82c61743c120f11d8ebfe0ed1f2d4da05098 100644 (file)
@@ -575,8 +575,10 @@ fdt_addr_t dev_get_addr(struct udevice *dev)
 
        addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
        if (addr != FDT_ADDR_T_NONE) {
+#ifndef CONFIG_SPL_BUILD
                if (device_get_uclass_id(dev->parent) == UCLASS_SIMPLE_BUS)
                        addr = simple_bus_translate(dev->parent, addr);
+#endif
        }
 
        return addr;
index 49b1054660ac81d467c6f0d7684d8269ff8a1092..17fcfbf4d3f62ac144152f908852ac034b363a17 100644 (file)
@@ -327,8 +327,7 @@ static int gpio_exynos_bind(struct udevice *parent)
        if (plat)
                return 0;
 
-       base = (struct s5p_gpio_bank *)fdtdec_get_addr(gd->fdt_blob,
-                                                  parent->of_offset, "reg");
+       base = (struct s5p_gpio_bank *)dev_get_addr(parent);
        for (node = fdt_first_subnode(blob, parent->of_offset), bank = base;
             node > 0;
             node = fdt_next_subnode(blob, node), bank++) {
index 57b78e55e23b9ef048bb4edd69ad110443ec9384..9d8f11ef302ac960d0a8ad1e36181508d05db83f 100644 (file)
@@ -285,8 +285,7 @@ static int gpio_sunxi_bind(struct udevice *parent)
                no_banks = SUNXI_GPIO_BANKS;
        }
 
-       ctlr = (struct sunxi_gpio_reg *)fdtdec_get_addr(gd->fdt_blob,
-                                                  parent->of_offset, "reg");
+       ctlr = (struct sunxi_gpio_reg *)dev_get_addr(parent);
        for (bank = 0; bank < no_banks; bank++) {
                struct sunxi_gpio_platdata *plat;
                struct udevice *dev;
index 8017e359f543dffb77ce17c97411414ed09afdd7..4921f0ff42e9706957ae6ca785187a3dcfc8e9ec 100644 (file)
@@ -343,8 +343,7 @@ static int gpio_tegra_bind(struct udevice *parent)
        if (!fdt_getprop(gd->fdt_blob, parent->of_offset, "interrupts", &len))
                return -EINVAL;
        bank_count = len / 3 / sizeof(u32);
-       ctlr = (struct gpio_ctlr *)fdtdec_get_addr(gd->fdt_blob,
-                                                  parent->of_offset, "reg");
+       ctlr = (struct gpio_ctlr *)dev_get_addr(parent);
        }
 #endif
        for (bank = 0; bank < bank_count; bank++) {
index ae6f436385a616479db3096256613657c3d14665..dc9b661c1cf754632cc7d673c024f860332e60b4 100644 (file)
@@ -1397,12 +1397,10 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev)
 
        if (i2c_bus->is_highspeed) {
                flags = PINMUX_FLAG_HS_MODE;
-               i2c_bus->hsregs = (struct exynos5_hsi2c *)
-                               fdtdec_get_addr(blob, node, "reg");
+               i2c_bus->hsregs = (struct exynos5_hsi2c *)dev_get_addr(dev);
        } else {
                flags = 0;
-               i2c_bus->regs = (struct s3c24x0_i2c *)
-                               fdtdec_get_addr(blob, node, "reg");
+               i2c_bus->regs = (struct s3c24x0_i2c *)dev_get_addr(dev);
        }
 
        i2c_bus->id = pinmux_decode_periph_id(blob, node);
index a4289788a65cb7ae8e9583a03299c2b1b992ef41..2fa07f9c57c455d96121183eff05c02ba7d72b40 100644 (file)
@@ -339,7 +339,7 @@ static int tegra_i2c_probe(struct udevice *dev)
 
        i2c_bus->id = dev->seq;
        i2c_bus->type = dev_get_driver_data(dev);
-       i2c_bus->regs = (struct i2c_ctlr *)fdtdec_get_addr(blob, node, "reg");
+       i2c_bus->regs = (struct i2c_ctlr *)dev_get_addr(dev);
 
        /*
         * We don't have a binding for pinmux yet. Leave it out for now. So
index 2b6d1e46386b0ee895ef10f77b14e550cb50e4c2..6275a11a0c8c28b530c6897196172ea0c627083e 100644 (file)
@@ -364,7 +364,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
        fdt_addr_t addr;
 
        /* try Processor Local Bus device first */
-       addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
+       addr = dev_get_addr(dev);
 #ifdef CONFIG_PCI
        if (addr == FDT_ADDR_T_NONE) {
                /* then try pci device */
index 54e596c4ed624d9b952f7ebf3f06d607cd9d1c90..7dbb49f81464c1dffbc949c91e88000da3bc0691 100644 (file)
@@ -133,8 +133,7 @@ static int arc_serial_ofdata_to_platdata(struct udevice *dev)
        struct arc_serial_platdata *plat = dev_get_platdata(dev);
        DECLARE_GLOBAL_DATA_PTR;
 
-       plat->reg = (struct arc_serial_regs *)fdtdec_get_addr(gd->fdt_blob,
-                                                       dev->of_offset, "reg");
+       plat->reg = (struct arc_serial_regs *)dev_get_addr(dev);
        plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
                                       "clock-frequency", 0);
 
index 917b6034d360e824bdfa6fd95e8ae82224f08fa8..ecf3bc02409e4a741353cd97404f827ea18e7896 100644 (file)
@@ -365,7 +365,7 @@ static int pl01x_serial_ofdata_to_platdata(struct udevice *dev)
        struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
        fdt_addr_t addr;
 
-       addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
+       addr = dev_get_addr(dev);
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
index 21cb566c2906cb01d9dd911c3581bd9458122359..3f0b5882541bfe9a320e01972af6ff4c1e095d58 100644 (file)
@@ -169,7 +169,7 @@ static int s5p_serial_ofdata_to_platdata(struct udevice *dev)
        struct s5p_serial_platdata *plat = dev->platdata;
        fdt_addr_t addr;
 
-       addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
+       addr = dev_get_addr(dev);
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
index 8f5c0fc8029d6b862bbbf1962ae55a27d80ec531..86ee90f4be50f796550ed17437d68b357f0ba861 100644 (file)
@@ -134,7 +134,7 @@ static int dw_spi_ofdata_to_platdata(struct udevice *bus)
        const void *blob = gd->fdt_blob;
        int node = bus->of_offset;
 
-       plat->regs = (struct dw_spi *)fdtdec_get_addr(blob, node, "reg");
+       plat->regs = (struct dw_spi *)dev_get_addr(bus);
 
        /* Use 500KHz as a suitable default */
        plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency",
index 418b48120a30b5fc63ed3e93748a9d30e1734129..44948c37364d27d42138fd824145e426ad56acdf 100644 (file)
@@ -255,7 +255,7 @@ static int exynos_spi_ofdata_to_platdata(struct udevice *bus)
        const void *blob = gd->fdt_blob;
        int node = bus->of_offset;
 
-       plat->regs = (struct exynos_spi *)fdtdec_get_addr(blob, node, "reg");
+       plat->regs = (struct exynos_spi *)dev_get_addr(bus);
        plat->periph_id = pinmux_decode_periph_id(blob, node);
 
        if (plat->periph_id == PERIPH_ID_NONE) {
index 3881b2e8a54630938667d08ca911a5f06854542d..887edd801a42d1a87662ca7e3f0f036f19e50cc2 100644 (file)
@@ -654,7 +654,7 @@ static int fsl_dspi_ofdata_to_platdata(struct udevice *bus)
        plat->num_chipselect =
                fdtdec_get_int(blob, node, "num-cs", FSL_DSPI_MAX_CHIPSELECT);
 
-       addr = fdtdec_get_addr(blob, node, "reg");
+       addr = dev_get_addr(bus);
        if (addr == FDT_ADDR_T_NONE) {
                debug("DSPI: Can't get base address or size\n");
                return -ENOMEM;
index d7eecd5bc606888982ae5b3ed6ff320c8dab41af..a965f80aebb5b5f5e95a27e80395d2651a09b09a 100644 (file)
@@ -118,7 +118,7 @@ static int tegra114_spi_ofdata_to_platdata(struct udevice *bus)
        const void *blob = gd->fdt_blob;
        int node = bus->of_offset;
 
-       plat->base = fdtdec_get_addr(blob, node, "reg");
+       plat->base = dev_get_addr(bus);
        plat->periph_id = clock_decode_periph_id(blob, node);
 
        if (plat->periph_id == PERIPH_ID_NONE) {
index 82c1b84f3bd953ec50dfdb0b4197448da3043584..afa0848dcb0357c8dd26991d9741c049448e9be1 100644 (file)
@@ -90,7 +90,7 @@ static int tegra20_sflash_ofdata_to_platdata(struct udevice *bus)
        const void *blob = gd->fdt_blob;
        int node = bus->of_offset;
 
-       plat->base = fdtdec_get_addr(blob, node, "reg");
+       plat->base = dev_get_addr(bus);
        plat->periph_id = clock_decode_periph_id(blob, node);
 
        if (plat->periph_id == PERIPH_ID_NONE) {
index f6fb89b393f0881e624e006baf9f16cd056d2474..fbb665b86f3f3faa4d2cd4dcbcca21c0da799790 100644 (file)
@@ -106,7 +106,7 @@ static int tegra30_spi_ofdata_to_platdata(struct udevice *bus)
        const void *blob = gd->fdt_blob;
        int node = bus->of_offset;
 
-       plat->base = fdtdec_get_addr(blob, node, "reg");
+       plat->base = dev_get_addr(bus);
        plat->periph_id = clock_decode_periph_id(blob, node);
 
        if (plat->periph_id == PERIPH_ID_NONE) {
index 7ae1f0ec9aeade68a873356dcecdebf28e0cf604..310fb69c8d76d2d036a202b2b3db5c231e253e13 100644 (file)
@@ -72,7 +72,7 @@ static int zynq_spi_ofdata_to_platdata(struct udevice *bus)
        const void *blob = gd->fdt_blob;
        int node = bus->of_offset;
 
-       plat->regs = (struct zynq_spi_regs *)fdtdec_get_addr(blob, node, "reg");
+       plat->regs = (struct zynq_spi_regs *)dev_get_addr(bus);
 
        /* FIXME: Use 250MHz as a suitable default */
        plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency",
index 4a4f5593e9da0718c91915b7d7d4b557765c5bfe..31d54ab285bf01c9ea0e864559413f880868b46e 100644 (file)
@@ -684,11 +684,13 @@ static void config_clock(const u32 timing[])
                timing[PARAM_CPCON], timing[PARAM_LFCON]);
 }
 
-static int fdt_decode_usb(const void *blob, int node, struct fdt_usb *config)
+static int fdt_decode_usb(struct udevice *dev, struct fdt_usb *config)
 {
+       const void *blob = gd->fdt_blob;
+       int node = dev->of_offset;
        const char *phy, *mode;
 
-       config->reg = (struct usb_ctlr *)fdtdec_get_addr(blob, node, "reg");
+       config->reg = (struct usb_ctlr *)dev_get_addr(dev);
        mode = fdt_getprop(blob, node, "dr_mode", NULL);
        if (mode) {
                if (0 == strcmp(mode, "host"))
@@ -812,7 +814,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
        struct fdt_usb *priv = dev_get_priv(dev);
        int ret;
 
-       ret = fdt_decode_usb(gd->fdt_blob, dev->of_offset, priv);
+       ret = fdt_decode_usb(dev, priv);
        if (ret)
                return ret;
 
index 251885b28b3a9a1e16d6e34edb4ca7ff993e4ce2..28416ed1064914bbdf8c8fce1258381c182d1115 100644 (file)
@@ -61,7 +61,7 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
        /*
         * Get the base address for XHCI controller from the device node
         */
-       plat->hcd_base = fdtdec_get_addr(blob, dev->of_offset, "reg");
+       plat->hcd_base = dev_get_addr(dev);
        if (plat->hcd_base == FDT_ADDR_T_NONE) {
                debug("Can't get the XHCI register base address\n");
                return -ENXIO;
index 3c0b721e3b8226d024d39a31270ceed2d69fab2d..1bf92020ae6deb0b7c0afb5944752041045814b6 100644 (file)
@@ -1555,9 +1555,8 @@ error_enable:
 static int tegra_dp_ofdata_to_platdata(struct udevice *dev)
 {
        struct tegra_dp_plat *plat = dev_get_platdata(dev);
-       const void *blob = gd->fdt_blob;
 
-       plat->base = fdtdec_get_addr(blob, dev->of_offset, "reg");
+       plat->base = dev_get_addr(dev);
 
        return 0;
 }