public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Álvaro Fernández Rojas" <noltari@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 08/17] led: bcm6328: convert to use live dt
Date: Thu, 22 Mar 2018 19:39:34 +0100	[thread overview]
Message-ID: <20180322183943.5466-9-noltari@gmail.com> (raw)
In-Reply-To: <20180322183943.5466-1-noltari@gmail.com>

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 v2: Introduce changes suggested by Daniel Schwierzeck:
  - Use generic dev_remap_addr function.

 drivers/led/led_bcm6328.c | 52 ++++++++++++++++-------------------------------
 1 file changed, 17 insertions(+), 35 deletions(-)

diff --git a/drivers/led/led_bcm6328.c b/drivers/led/led_bcm6328.c
index 5d545c5096..a8cc5c5167 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;
@@ -150,34 +148,25 @@ static const struct led_ops bcm6328_led_ops = {
 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);
-		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,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 +174,14 @@ 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);
-		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);
 		if (pin < 8) {
 			/* LEDs 0-7 (bits 47:32) */
 			priv->mode = priv->regs + LED_MODE_REG_HI;
@@ -206,8 +192,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 +201,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

  parent reply	other threads:[~2018-03-22 18:39 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22 18:39 [U-Boot] [PATCH v2 00/17] bmips: convert to use live-dt Álvaro Fernández Rojas
2018-03-22 18:39 ` [U-Boot] [PATCH v2 01/17] dm: core: add functions to get memory-mapped I/O addreses Álvaro Fernández Rojas
2018-03-23 14:34   ` Daniel Schwierzeck
2018-03-23 17:15     ` Álvaro Fernández Rojas
2018-03-23 17:36       ` Daniel Schwierzeck
2018-03-23 17:45   ` Daniel Schwierzeck
2018-04-06 12:45   ` Daniel Schwierzeck
2018-04-08 13:50     ` Simon Glass
2018-03-22 18:39 ` [U-Boot] [PATCH v2 02/17] watchdog: bcm6345: convert to use live dt Álvaro Fernández Rojas
2018-03-23 17:46   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 03/17] serial: " Álvaro Fernández Rojas
2018-03-23 17:46   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 04/17] clk: " Álvaro Fernández Rojas
2018-03-23 17:47   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 05/17] reset: " Álvaro Fernández Rojas
2018-03-23 17:47   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 06/17] gpio: " Álvaro Fernández Rojas
2018-03-23 17:48   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 07/17] led: bcm6358: " Álvaro Fernández Rojas
2018-03-23 17:50   ` Daniel Schwierzeck
2018-03-22 18:39 ` Álvaro Fernández Rojas [this message]
2018-03-23 17:51   ` [U-Boot] [PATCH v2 08/17] led: bcm6328: " Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 09/17] power: domain: " Álvaro Fernández Rojas
2018-03-23 17:52   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 10/17] spi: bcm63xx_spi: " Álvaro Fernández Rojas
2018-03-23 17:52   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 11/17] spi: bcm63xx_hsspi: " Álvaro Fernández Rojas
2018-03-23 17:53   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 12/17] ram: bmips: " Álvaro Fernández Rojas
2018-03-23 17:54   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 13/17] cpu: " Álvaro Fernández Rojas
2018-03-23 17:55   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 14/17] phy: bcm6348-usbh: " Álvaro Fernández Rojas
2018-03-23 18:00   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 15/17] phy: bcm6358-usbh: " Álvaro Fernández Rojas
2018-03-23 18:01   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 16/17] phy: bcm6368-usbh: " Álvaro Fernández Rojas
2018-03-23 18:01   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 17/17] phy: bcm6318-usbh: " Álvaro Fernández Rojas
2018-03-23 18:02   ` Daniel Schwierzeck
2018-05-06 19:36 ` [U-Boot] [PATCH v2 00/17] bmips: convert to use live-dt Daniel Schwierzeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180322183943.5466-9-noltari@gmail.com \
    --to=noltari@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox