From: "Álvaro Fernández Rojas" <noltari@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] led: bcm6358: convert to use live dt
Date: Sat, 17 Mar 2018 12:25:29 +0100 [thread overview]
Message-ID: <20180317112530.9608-1-noltari@gmail.com> (raw)
Signed-off-by: Álvaro Fernández Rojas <noltari@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) {
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
next reply other threads:[~2018-03-17 11:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-17 11:25 Álvaro Fernández Rojas [this message]
2018-03-17 11:25 ` [U-Boot] [PATCH 2/2] led: bcm6328: convert to use live dt Álvaro Fernández Rojas
2018-03-19 17:59 ` Simon Glass
2018-03-19 17:59 ` [U-Boot] [PATCH 1/2] led: bcm6358: " Simon Glass
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=20180317112530.9608-1-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