summaryrefslogtreecommitdiff
path: root/drivers/power/pmic
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power/pmic')
-rw-r--r--drivers/power/pmic/Kconfig7
-rw-r--r--drivers/power/pmic/Makefile1
-rw-r--r--drivers/power/pmic/act8846.c8
-rw-r--r--drivers/power/pmic/i2c_pmic_emul.c6
-rw-r--r--drivers/power/pmic/lp873x.c12
-rw-r--r--drivers/power/pmic/lp87565.c87
-rw-r--r--drivers/power/pmic/max77686.c8
-rw-r--r--drivers/power/pmic/palmas.c16
-rw-r--r--drivers/power/pmic/pfuze100.c8
-rw-r--r--drivers/power/pmic/pm8916.c2
-rw-r--r--drivers/power/pmic/pmic-uclass.c22
-rw-r--r--drivers/power/pmic/pmic_tps65218.c3
-rw-r--r--drivers/power/pmic/rk8xx.c9
-rw-r--r--drivers/power/pmic/s5m8767.c7
-rw-r--r--drivers/power/pmic/sandbox.c2
-rw-r--r--drivers/power/pmic/tps65090.c8
16 files changed, 142 insertions, 64 deletions
diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig
index 3f50c12..e3f9e4d 100644
--- a/drivers/power/pmic/Kconfig
+++ b/drivers/power/pmic/Kconfig
@@ -188,6 +188,13 @@ config PMIC_LP873X
The LP873X is a PMIC containing couple of LDOs and couple of SMPS.
This driver binds the pmic children.
+config PMIC_LP87565
+ bool "Enable driver for Texas Instruments LP87565 PMIC"
+ depends on DM_PMIC
+ ---help---
+ The LP87565 is a PMIC containing a bunch of SMPS.
+ This driver binds the pmic children.
+
config POWER_MC34VR500
bool "Enable driver for Freescale MC34VR500 PMIC"
---help---
diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index f409e3a..f488799 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_PMIC_TPS65090) += tps65090.o
obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o
obj-$(CONFIG_$(SPL_)PMIC_PALMAS) += palmas.o
obj-$(CONFIG_$(SPL_)PMIC_LP873X) += lp873x.o
+obj-$(CONFIG_$(SPL_)PMIC_LP87565) += lp87565.o
obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o
obj-$(CONFIG_POWER_MAX77696) += pmic_max77696.o
diff --git a/drivers/power/pmic/act8846.c b/drivers/power/pmic/act8846.c
index 15da12e..a6b0940 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/i2c_pmic_emul.c b/drivers/power/pmic/i2c_pmic_emul.c
index 4f92e3d..2d35d09 100644
--- a/drivers/power/pmic/i2c_pmic_emul.c
+++ b/drivers/power/pmic/i2c_pmic_emul.c
@@ -6,7 +6,6 @@
*/
#include <common.h>
-#include <fdtdec.h>
#include <errno.h>
#include <dm.h>
#include <i2c.h>
@@ -108,9 +107,8 @@ static int sandbox_i2c_pmic_ofdata_to_platdata(struct udevice *emul)
debug("%s:%d Setting PMIC default registers\n", __func__, __LINE__);
- reg_defaults = fdtdec_locate_byte_array(gd->fdt_blob,
- dev_of_offset(emul), "reg-defaults",
- SANDBOX_PMIC_REG_COUNT);
+ reg_defaults = dev_read_u8_array_ptr(emul, "reg-defaults",
+ SANDBOX_PMIC_REG_COUNT);
if (!reg_defaults) {
error("Property \"reg-defaults\" not found for device: %s!",
diff --git a/drivers/power/pmic/lp873x.c b/drivers/power/pmic/lp873x.c
index d8f30df..f505468 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/lp87565.c b/drivers/power/pmic/lp87565.c
new file mode 100644
index 0000000..782a46c
--- /dev/null
+++ b/drivers/power/pmic/lp87565.c
@@ -0,0 +1,87 @@
+/*
+ * (C) Copyright 2017 Texas Instruments Incorporated, <www.ti.com>
+ * Keerthy <j-keerthy@ti.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <fdtdec.h>
+#include <errno.h>
+#include <dm.h>
+#include <i2c.h>
+#include <power/pmic.h>
+#include <power/regulator.h>
+#include <power/lp87565.h>
+#include <dm/device.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct pmic_child_info pmic_children_info[] = {
+ { .prefix = "buck", .driver = LP87565_BUCK_DRIVER },
+ { },
+};
+
+static int lp87565_write(struct udevice *dev, uint reg, const uint8_t *buff,
+ int len)
+{
+ int ret;
+
+ ret = dm_i2c_write(dev, reg, buff, len);
+ if (ret)
+ error("write error to device: %p register: %#x!", dev, reg);
+
+ return ret;
+}
+
+static int lp87565_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
+{
+ int ret;
+
+ ret = dm_i2c_read(dev, reg, buff, len);
+ if (ret)
+ error("read error from device: %p register: %#x!", dev, reg);
+
+ return ret;
+}
+
+static int lp87565_bind(struct udevice *dev)
+{
+ ofnode regulators_node;
+ int children;
+
+ regulators_node = dev_read_subnode(dev, "regulators");
+ if (!ofnode_valid(regulators_node)) {
+ debug("%s: %s regulators subnode not found!", __func__,
+ dev->name);
+ return -ENXIO;
+ }
+
+ debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
+
+ children = pmic_bind_children(dev, regulators_node, pmic_children_info);
+ if (!children)
+ printf("%s: %s - no child found\n", __func__, dev->name);
+
+ /* Always return success for this device */
+ return 0;
+}
+
+static struct dm_pmic_ops lp87565_ops = {
+ .read = lp87565_read,
+ .write = lp87565_write,
+};
+
+static const struct udevice_id lp87565_ids[] = {
+ { .compatible = "ti,lp87565", .data = LP87565 },
+ { .compatible = "ti,lp87565-q1", .data = LP87565_Q1 },
+ { }
+};
+
+U_BOOT_DRIVER(pmic_lp87565) = {
+ .name = "lp87565_pmic",
+ .id = UCLASS_PMIC,
+ .of_match = lp87565_ids,
+ .bind = lp87565_bind,
+ .ops = &lp87565_ops,
+};
diff --git a/drivers/power/pmic/max77686.c b/drivers/power/pmic/max77686.c
index 8295fab..ceca9f9 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 f5a2307..804c0d1 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 not found!", __func__, dev->name);
return -ENXIO;
}
diff --git a/drivers/power/pmic/pfuze100.c b/drivers/power/pmic/pfuze100.c
index 90a43f2..5f361c7 100644
--- a/drivers/power/pmic/pfuze100.c
+++ b/drivers/power/pmic/pfuze100.c
@@ -52,13 +52,11 @@ static int pfuze100_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
static int pfuze100_bind(struct udevice *dev)
{
+ ofnode regulators_node;
int children;
- int regulators_node;
- const void *blob = gd->fdt_blob;
- 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/pm8916.c b/drivers/power/pmic/pm8916.c
index 2b65c69..a048bbe 100644
--- a/drivers/power/pmic/pm8916.c
+++ b/drivers/power/pmic/pm8916.c
@@ -70,7 +70,7 @@ static int pm8916_probe(struct udevice *dev)
{
struct pm8916_priv *priv = dev_get_priv(dev);
- priv->usid = dev_get_addr(dev);
+ priv->usid = dev_read_addr(dev);
if (priv->usid == FDT_ADDR_T_NONE)
return -EINVAL;
diff --git a/drivers/power/pmic/pmic-uclass.c b/drivers/power/pmic/pmic-uclass.c
index 0f7fa51..953bbe5 100644
--- a/drivers/power/pmic/pmic-uclass.c
+++ b/drivers/power/pmic/pmic-uclass.c
@@ -19,29 +19,27 @@
DECLARE_GLOBAL_DATA_PTR;
#if CONFIG_IS_ENABLED(PMIC_CHILDREN)
-int pmic_bind_children(struct udevice *pmic, int offset,
+int pmic_bind_children(struct udevice *pmic, ofnode parent,
const struct pmic_child_info *child_info)
{
const struct pmic_child_info *info;
- const void *blob = gd->fdt_blob;
struct driver *drv;
struct udevice *child;
const char *node_name;
int bind_count = 0;
- int node;
+ ofnode node;
int prefix_len;
int ret;
debug("%s for '%s' at node offset: %d\n", __func__, pmic->name,
dev_of_offset(pmic));
- for (node = fdt_first_subnode(blob, offset);
- node > 0;
- node = fdt_next_subnode(blob, node)) {
- node_name = fdt_get_name(blob, node, NULL);
+ for (node = ofnode_first_subnode(parent);
+ ofnode_valid(node);
+ node = ofnode_next_subnode(node)) {
+ node_name = ofnode_get_name(node);
- debug("* Found child node: '%s' at offset:%d\n", node_name,
- node);
+ debug("* Found child node: '%s'\n", node_name);
child = NULL;
for (info = child_info; info->prefix && info->driver; info++) {
@@ -60,8 +58,8 @@ int pmic_bind_children(struct udevice *pmic, int offset,
debug(" - found child driver: '%s'\n", drv->name);
- ret = device_bind(pmic, drv, node_name, NULL,
- node, &child);
+ ret = device_bind_with_driver_data(pmic, drv, node_name,
+ 0, node, &child);
if (ret) {
debug(" - child binding error: %d\n", ret);
continue;
@@ -82,7 +80,7 @@ int pmic_bind_children(struct udevice *pmic, int offset,
debug(" - compatible prefix not found\n");
}
- debug("Bound: %d childs for PMIC: '%s'\n", bind_count, pmic->name);
+ debug("Bound: %d children for PMIC: '%s'\n", bind_count, pmic->name);
return bind_count;
}
#endif
diff --git a/drivers/power/pmic/pmic_tps65218.c b/drivers/power/pmic/pmic_tps65218.c
index c5e768a..911f639 100644
--- a/drivers/power/pmic/pmic_tps65218.c
+++ b/drivers/power/pmic/pmic_tps65218.c
@@ -96,7 +96,8 @@ int tps65218_reg_write(uchar prot_level, uchar dest_reg, uchar dest_val,
int tps65218_voltage_update(uchar dc_cntrl_reg, uchar volt_sel)
{
if ((dc_cntrl_reg != TPS65218_DCDC1) &&
- (dc_cntrl_reg != TPS65218_DCDC2))
+ (dc_cntrl_reg != TPS65218_DCDC2) &&
+ (dc_cntrl_reg != TPS65218_DCDC3))
return 1;
/* set voltage level */
diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index 394e2ff..eb3ec0f 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -57,13 +57,11 @@ static int rk8xx_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
#if CONFIG_IS_ENABLED(PMIC_CHILDREN)
static int rk8xx_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;
@@ -113,6 +111,7 @@ U_BOOT_DRIVER(pmic_rk8xx) = {
#if CONFIG_IS_ENABLED(PMIC_CHILDREN)
.bind = rk8xx_bind,
#endif
+ .priv_auto_alloc_size = sizeof(struct rk8xx_priv),
.probe = rk8xx_probe,
.ops = &rk8xx_ops,
};
diff --git a/drivers/power/pmic/s5m8767.c b/drivers/power/pmic/s5m8767.c
index 25d673b..f8ae5ea 100644
--- a/drivers/power/pmic/s5m8767.c
+++ b/drivers/power/pmic/s5m8767.c
@@ -54,12 +54,11 @@ int s5m8767_enable_32khz_cp(struct udevice *dev)
static int s5m8767_bind(struct udevice *dev)
{
- int node;
- const void *blob = gd->fdt_blob;
int children;
+ ofnode node;
- node = fdt_subnode_offset(blob, dev_of_offset(dev), "regulators");
- if (node <= 0) {
+ node = dev_read_subnode(dev, "regulators");
+ if (!ofnode_valid(node)) {
debug("%s: %s regulators subnode not found!", __func__,
dev->name);
return -ENXIO;
diff --git a/drivers/power/pmic/sandbox.c b/drivers/power/pmic/sandbox.c
index b4e412e..6763303 100644
--- a/drivers/power/pmic/sandbox.c
+++ b/drivers/power/pmic/sandbox.c
@@ -51,7 +51,7 @@ static int sandbox_pmic_read(struct udevice *dev, uint reg,
static int sandbox_pmic_bind(struct udevice *dev)
{
- if (!pmic_bind_children(dev, dev_of_offset(dev), pmic_children_info))
+ if (!pmic_bind_children(dev, dev_ofnode(dev), pmic_children_info))
error("%s:%d PMIC: %s - no child found!", __func__, __LINE__,
dev->name);
diff --git a/drivers/power/pmic/tps65090.c b/drivers/power/pmic/tps65090.c
index b30a7f0..4565e3b 100644
--- a/drivers/power/pmic/tps65090.c
+++ b/drivers/power/pmic/tps65090.c
@@ -52,13 +52,11 @@ static int tps65090_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
static int tps65090_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),
- "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;