diff options
author | Álvaro Fernández Rojas <noltari@gmail.com> | 2018-03-22 19:39:33 +0100 |
---|---|---|
committer | Daniel Schwierzeck <daniel.schwierzeck@gmail.com> | 2018-06-01 15:56:02 +0200 |
commit | a15c16f923e82d8bb8fcc9248d9054c6f55ceaf6 (patch) | |
tree | cf6d2adbc29bef15e3720e56be81e12b43542dad /drivers/led | |
parent | e7e64fa0e61b3a68d2c80b9f7d262e22823c52fa (diff) | |
download | u-boot-a15c16f923e82d8bb8fcc9248d9054c6f55ceaf6.tar.gz |
led: bcm6358: convert to use live dt
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Diffstat (limited to 'drivers/led')
-rw-r--r-- | drivers/led/led_bcm6358.c | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/drivers/led/led_bcm6358.c b/drivers/led/led_bcm6358.c index 4b1c24bd95..01b86b756e 100644 --- a/drivers/led/led_bcm6358.c +++ b/drivers/led/led_bcm6358.c @@ -31,8 +31,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; @@ -114,8 +112,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) { @@ -123,17 +119,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; @@ -157,21 +150,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; } @@ -180,27 +169,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; |