Re: [U-Boot] [PATCH v3 42/72] dm: pmic: Convert uclass to livetree

2017-05-24 Thread sjg
Update the pmic uclass and all pmics to support a live device tree.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 drivers/power/pmic/act8846.c |  8 +++-
 drivers/power/pmic/lp873x.c  | 12 +---
 drivers/power/pmic/max77686.c|  8 +++-
 drivers/power/pmic/palmas.c  | 16 +++-
 drivers/power/pmic/pfuze100.c|  8 +++-
 drivers/power/pmic/pmic-uclass.c | 22 ++
 drivers/power/pmic/rk8xx.c   |  8 +++-
 drivers/power/pmic/s5m8767.c |  7 +++
 drivers/power/pmic/sandbox.c |  2 +-
 drivers/power/pmic/tps65090.c|  8 +++-
 include/power/pmic.h |  2 +-
 11 files changed, 42 insertions(+), 59 deletions(-)

Applied to u-boot-dm
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 42/72] dm: pmic: Convert uclass to livetree

2017-05-18 Thread Simon Glass
Update the pmic uclass and all pmics to support a live device tree.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 drivers/power/pmic/act8846.c |  8 +++-
 drivers/power/pmic/lp873x.c  | 12 +---
 drivers/power/pmic/max77686.c|  8 +++-
 drivers/power/pmic/palmas.c  | 16 +++-
 drivers/power/pmic/pfuze100.c|  8 +++-
 drivers/power/pmic/pmic-uclass.c | 22 ++
 drivers/power/pmic/rk8xx.c   |  8 +++-
 drivers/power/pmic/s5m8767.c |  7 +++
 drivers/power/pmic/sandbox.c |  2 +-
 drivers/power/pmic/tps65090.c|  8 +++-
 include/power/pmic.h |  2 +-
 11 files changed, 42 insertions(+), 59 deletions(-)

diff --git a/drivers/power/pmic/act8846.c b/drivers/power/pmic/act8846.c
index 15da12edea..a6b0940956 100644
--- a/drivers/power/pmic/act8846.c
+++ b/drivers/power/pmic/act8846.c
@@ -48,13 +48,11 @@ static int act8846_read(struct udevice *dev, uint reg, 
uint8_t *buff, int len)
 
 static int act8846_bind(struct udevice *dev)
 {
-   const void *blob = gd->fdt_blob;
-   int regulators_node;
+   ofnode regulators_node;
int children;
 
-   regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
-"regulators");
-   if (regulators_node <= 0) {
+   regulators_node = dev_read_subnode(dev, "regulators");
+   if (!ofnode_valid(regulators_node)) {
debug("%s: %s regulators subnode not found!", __func__,
  dev->name);
return -ENXIO;
diff --git a/drivers/power/pmic/lp873x.c b/drivers/power/pmic/lp873x.c
index d8f30df371..f505468313 100644
--- a/drivers/power/pmic/lp873x.c
+++ b/drivers/power/pmic/lp873x.c
@@ -46,15 +46,13 @@ static int lp873x_read(struct udevice *dev, uint reg, 
uint8_t *buff, int len)
 
 static int lp873x_bind(struct udevice *dev)
 {
-   int regulators_node;
-   const void *blob = gd->fdt_blob;
+   ofnode regulators_node;
int children;
-   int node = dev_of_offset(dev);
 
-   regulators_node = fdt_subnode_offset(blob, node, "regulators");
-
-   if (regulators_node <= 0) {
-   printf("%s: %s reg subnode not found!", __func__, dev->name);
+   regulators_node = dev_read_subnode(dev, "regulators");
+   if (!ofnode_valid(regulators_node)) {
+   debug("%s: %s regulators subnode not found!", __func__,
+ dev->name);
return -ENXIO;
}
 
diff --git a/drivers/power/pmic/max77686.c b/drivers/power/pmic/max77686.c
index 8295fab3f0..ceca9f96a7 100644
--- a/drivers/power/pmic/max77686.c
+++ b/drivers/power/pmic/max77686.c
@@ -50,13 +50,11 @@ static int max77686_read(struct udevice *dev, uint reg, 
uint8_t *buff, int len)
 
 static int max77686_bind(struct udevice *dev)
 {
-   int regulators_node;
-   const void *blob = gd->fdt_blob;
+   ofnode regulators_node;
int children;
 
-   regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
-"voltage-regulators");
-   if (regulators_node <= 0) {
+   regulators_node = dev_read_subnode(dev, "voltage-regulators");
+   if (!ofnode_valid(regulators_node)) {
debug("%s: %s regulators subnode not found!", __func__,
 dev->name);
return -ENXIO;
diff --git a/drivers/power/pmic/palmas.c b/drivers/power/pmic/palmas.c
index f5a23073c4..804c0d13a0 100644
--- a/drivers/power/pmic/palmas.c
+++ b/drivers/power/pmic/palmas.c
@@ -46,17 +46,15 @@ static int palmas_read(struct udevice *dev, uint reg, 
uint8_t *buff, int len)
 
 static int palmas_bind(struct udevice *dev)
 {
-   int pmic_node = -1, regulators_node;
-   const void *blob = gd->fdt_blob;
+   ofnode pmic_node = ofnode_null(), regulators_node;
+   ofnode subnode;
int children;
-   int node = dev_of_offset(dev);
-   int subnode, len;
 
-   fdt_for_each_subnode(subnode, blob, node) {
+   dev_for_each_subnode(subnode, dev) {
const char *name;
char *temp;
 
-   name = fdt_get_name(blob, subnode, &len);
+   name = ofnode_get_name(subnode);
temp = strstr(name, "pmic");
if (temp) {
pmic_node = subnode;
@@ -64,14 +62,14 @@ static int palmas_bind(struct udevice *dev)
}
}
 
-   if (pmic_node <= 0) {
+   if (!ofnode_valid(pmic_node)) {
debug("%s: %s pmic subnode not found!", __func__, dev->name);
return -ENXIO;
}
 
-   regulators_node = fdt_subnode_offset(blob, pmic_node, "regulators");
+   regulators_node = ofnode_find_subnode(pmic_node, "regulators");
 
-   if (regulators_node <= 0) {
+   if (!ofnode_valid(regulators_node)) {
debug("%s: %s reg subnode