Signed-off-by: Álvaro Fernández Rojas <nolt...@gmail.com> --- v2: Introduce changes suggested by Daniel Schwierzeck: - Use generic dev_remap_addr function.
drivers/led/led_bcm6358.c | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/drivers/led/led_bcm6358.c b/drivers/led/led_bcm6358.c index e8a3b64e68..86ec7aba75 100644 --- a/drivers/led/led_bcm6358.c +++ b/drivers/led/led_bcm6358.c @@ -32,8 +32,6 @@ #define LED_CTRL_BUSY_SHIFT 3 #define LED_CTRL_BUSY_MASK (1 << LED_CTRL_BUSY_SHIFT) -DECLARE_GLOBAL_DATA_PTR; - struct bcm6358_led_priv { void __iomem *regs; uint8_t pin; @@ -115,8 +113,6 @@ static const struct led_ops bcm6358_led_ops = { static int bcm6358_led_probe(struct udevice *dev) { struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev); - fdt_addr_t addr; - fdt_size_t size; /* Top-level LED node */ if (!uc_plat->label) { @@ -124,17 +120,14 @@ static int bcm6358_led_probe(struct udevice *dev) unsigned int clk_div; u32 set_bits = 0; - addr = devfdt_get_addr_size_index(dev, 0, &size); - if (addr == FDT_ADDR_T_NONE) + regs = dev_remap_addr(dev); + if (!regs) return -EINVAL; - regs = ioremap(addr, size); - - if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), - "brcm,clk-dat-low")) + if (dev_read_bool(dev, "brcm,clk-dat-low")) set_bits |= LED_CTRL_POL_MASK; - clk_div = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), - "brcm,clk-div", LED_CTRL_CLK_1); + clk_div = dev_read_u32_default(dev, "brcm,clk-div", + LED_CTRL_CLK_1); switch (clk_div) { case 8: set_bits |= LED_CTRL_CLK_8; @@ -158,21 +151,17 @@ static int bcm6358_led_probe(struct udevice *dev) struct bcm6358_led_priv *priv = dev_get_priv(dev); unsigned int pin; - addr = devfdt_get_addr_size_index(dev_get_parent(dev), 0, - &size); - if (addr == FDT_ADDR_T_NONE) + priv->regs = dev_remap_addr(dev); + if (!priv->regs) return -EINVAL; - pin = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "reg", - LEDS_MAX); + pin = dev_read_u32_default(dev, "reg", LEDS_MAX); if (pin >= LEDS_MAX) return -EINVAL; - priv->regs = ioremap(addr, size); priv->pin = pin; - if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), - "active-low")) + if (dev_read_bool(dev, "active-low")) priv->active_low = true; } @@ -181,27 +170,24 @@ static int bcm6358_led_probe(struct udevice *dev) static int bcm6358_led_bind(struct udevice *parent) { - const void *blob = gd->fdt_blob; - int node; + ofnode node; - for (node = fdt_first_subnode(blob, dev_of_offset(parent)); - node > 0; - node = fdt_next_subnode(blob, node)) { + dev_for_each_subnode(node, parent) { struct led_uc_plat *uc_plat; struct udevice *dev; const char *label; int ret; - label = fdt_getprop(blob, node, "label", NULL); + label = ofnode_read_string(node, "label"); if (!label) { debug("%s: node %s has no label\n", __func__, - fdt_get_name(blob, node, NULL)); + ofnode_get_name(node)); return -EINVAL; } ret = device_bind_driver_to_node(parent, "bcm6358-led", - fdt_get_name(blob, node, NULL), - offset_to_ofnode(node), &dev); + ofnode_get_name(node), + node, &dev); if (ret) return ret; -- 2.11.0 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot