[U-Boot] [PATCH 2/2] led: bcm6328: convert to use live dt

Álvaro Fernández Rojas noltari at gmail.com
Sat Mar 17 11:25:30 UTC 2018


Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
---
 drivers/led/led_bcm6328.c | 48 +++++++++++++++++------------------------------
 1 file changed, 17 insertions(+), 31 deletions(-)

diff --git a/drivers/led/led_bcm6328.c b/drivers/led/led_bcm6328.c
index 5d545c5096..0994229bce 100644
--- a/drivers/led/led_bcm6328.c
+++ b/drivers/led/led_bcm6328.c
@@ -38,8 +38,6 @@
 #define LED_MODE_OFF			3
 #define LED_MODE_MASK			0x3
 
-DECLARE_GLOBAL_DATA_PTR;
-
 struct bcm6328_led_priv {
 	void __iomem *regs;
 	void __iomem *mode;
@@ -151,33 +149,27 @@ static int bcm6328_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) {
 		void __iomem *regs;
 		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,serial-leds"))
+		if (dev_read_bool(dev, "brcm,serial-leds"))
 			set_bits |= LED_INIT_SLEDEN_MASK;
-		if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
-				    "brcm,serial-mux"))
+		if (dev_read_bool(dev, "brcm,serial-mux"))
 			set_bits |= LED_INIT_SLEDMUX_MASK;
-		if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
-				    "brcm,serial-clk-low"))
+		if (dev_read_bool(dev, "brcm,serial-clk-low"))
 			set_bits |= LED_INIT_SLEDCLKNPOL_MASK;
-		if (!fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
-				     "brcm,serial-dat-low"))
+		if (!dev_read_bool(dev, "brcm,serial-dat-low"))
 			set_bits |= LED_INIT_SLEDDATANPOL_MASK;
-		if (!fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
-				     "brcm,serial-shift-inv"))
+		if (!dev_read_bool(dev, "brcm,serial-shift-inv"))
 			set_bits |= LED_INIT_SLEDSHIFTDIR_MASK;
 
 		clrsetbits_be32(regs + LED_INIT_REG, ~0, set_bits);
@@ -185,17 +177,15 @@ static int bcm6328_led_probe(struct udevice *dev)
 		struct bcm6328_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);
 		if (pin < 8) {
 			/* LEDs 0-7 (bits 47:32) */
 			priv->mode = priv->regs + LED_MODE_REG_HI;
@@ -206,8 +196,7 @@ static int bcm6328_led_probe(struct udevice *dev)
 			priv->shift = ((pin - 8) << 1);
 		}
 
-		if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
-				    "active-low"))
+		if (dev_read_bool(dev, "active-low"))
 			priv->active_low = true;
 	}
 
@@ -216,27 +205,24 @@ static int bcm6328_led_probe(struct udevice *dev)
 
 static int bcm6328_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, "bcm6328-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



More information about the U-Boot mailing list