[U-Boot] [PATCH 1/2] led: bcm6358: convert to use live dt
Simon Glass
sjg at chromium.org
Mon Mar 19 17:59:13 UTC 2018
Hi Alvaro,
On 17 March 2018 at 05:25, Álvaro Fernández Rojas <noltari at gmail.com> wrote:
> Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
> ---
> drivers/led/led_bcm6358.c | 40 +++++++++++++++-------------------------
> 1 file changed, 15 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/led/led_bcm6358.c b/drivers/led/led_bcm6358.c
> index e8a3b64e68..c7a829ad57 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;
> @@ -116,7 +114,6 @@ 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 +121,16 @@ 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);
> + addr = dev_read_addr(dev);
> if (addr == FDT_ADDR_T_NONE)
> return -EINVAL;
>
> - regs = ioremap(addr, size);
> + regs = ioremap(addr, 0);
>
> - 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 +154,18 @@ 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);
> + addr = dev_read_addr(dev_get_parent(dev));
> if (addr == FDT_ADDR_T_NONE)
> 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->regs = ioremap(addr, 0);
> 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 +174,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)) {
> + ev_for_each_subnode(node, parent) {
Should that be dev_for_each_subnode() ?
> 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
>
Regards,
Simon
More information about the U-Boot
mailing list