summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/pmic/as3722.c12
-rw-r--r--drivers/power/pmic/as3722_gpio.c10
-rw-r--r--drivers/power/pmic/i2c_pmic_emul.c6
-rw-r--r--drivers/power/pmic/lp873x.c4
-rw-r--r--drivers/power/pmic/lp87565.c4
-rw-r--r--drivers/power/pmic/max77686.c4
-rw-r--r--drivers/power/pmic/max8997.c4
-rw-r--r--drivers/power/pmic/max8998.c4
-rw-r--r--drivers/power/pmic/palmas.c4
-rw-r--r--drivers/power/pmic/pfuze100.c4
-rw-r--r--drivers/power/pmic/s2mps11.c4
-rw-r--r--drivers/power/pmic/s5m8767.c4
-rw-r--r--drivers/power/pmic/sandbox.c6
-rw-r--r--drivers/power/pmic/tps65090.c4
-rw-r--r--drivers/power/regulator/Kconfig20
-rw-r--r--drivers/power/regulator/Makefile1
-rw-r--r--drivers/power/regulator/fixed.c2
-rw-r--r--drivers/power/regulator/gpio-regulator.c2
-rw-r--r--drivers/power/regulator/max77686.c20
-rw-r--r--drivers/power/regulator/pbias_regulator.c301
-rw-r--r--drivers/power/regulator/sandbox.c18
21 files changed, 380 insertions, 58 deletions
diff --git a/drivers/power/pmic/as3722.c b/drivers/power/pmic/as3722.c
index 4efe8ee183..3b0427e0b9 100644
--- a/drivers/power/pmic/as3722.c
+++ b/drivers/power/pmic/as3722.c
@@ -46,14 +46,14 @@ static int as3722_read_id(struct udevice *dev, uint *idp, uint *revisionp)
ret = pmic_reg_read(dev, AS3722_ASIC_ID1);
if (ret < 0) {
- error("failed to read ID1 register: %d", ret);
+ pr_err("failed to read ID1 register: %d", ret);
return ret;
}
*idp = ret;
ret = pmic_reg_read(dev, AS3722_ASIC_ID2);
if (ret < 0) {
- error("failed to read ID2 register: %d", ret);
+ pr_err("failed to read ID2 register: %d", ret);
return ret;
}
*revisionp = ret;
@@ -71,7 +71,7 @@ int as3722_sd_set_voltage(struct udevice *dev, unsigned int sd, u8 value)
ret = pmic_reg_write(dev, AS3722_SD_VOLTAGE(sd), value);
if (ret < 0) {
- error("failed to write SD%u voltage register: %d", sd, ret);
+ pr_err("failed to write SD%u voltage register: %d", sd, ret);
return ret;
}
@@ -87,7 +87,7 @@ int as3722_ldo_set_voltage(struct udevice *dev, unsigned int ldo, u8 value)
ret = pmic_reg_write(dev, AS3722_LDO_VOLTAGE(ldo), value);
if (ret < 0) {
- error("failed to write LDO%u voltage register: %d", ldo,
+ pr_err("failed to write LDO%u voltage register: %d", ldo,
ret);
return ret;
}
@@ -102,12 +102,12 @@ static int as3722_probe(struct udevice *dev)
ret = as3722_read_id(dev, &id, &revision);
if (ret < 0) {
- error("failed to read ID: %d", ret);
+ pr_err("failed to read ID: %d", ret);
return ret;
}
if (id != AS3722_DEVICE_ID) {
- error("unknown device");
+ pr_err("unknown device");
return -ENOENT;
}
diff --git a/drivers/power/pmic/as3722_gpio.c b/drivers/power/pmic/as3722_gpio.c
index d0b681ca4a..5cf4cb6b51 100644
--- a/drivers/power/pmic/as3722_gpio.c
+++ b/drivers/power/pmic/as3722_gpio.c
@@ -26,7 +26,7 @@ int as3722_gpio_configure(struct udevice *pmic, unsigned int gpio,
err = pmic_reg_write(pmic, AS3722_GPIO_CONTROL(gpio), value);
if (err) {
- error("failed to configure GPIO#%u: %d", gpio, err);
+ pr_err("failed to configure GPIO#%u: %d", gpio, err);
return err;
}
@@ -46,7 +46,7 @@ static int as3722_gpio_set_value(struct udevice *dev, unsigned int gpio,
err = pmic_reg_read(pmic, AS3722_GPIO_SIGNAL_OUT);
if (err < 0) {
- error("failed to read GPIO signal out register: %d", err);
+ pr_err("failed to read GPIO signal out register: %d", err);
return err;
}
value = err;
@@ -61,7 +61,7 @@ static int as3722_gpio_set_value(struct udevice *dev, unsigned int gpio,
err = pmic_reg_write(pmic, AS3722_GPIO_SIGNAL_OUT, value);
if (err) {
- error("failed to set GPIO#%u %s: %d", gpio, l, err);
+ pr_err("failed to set GPIO#%u %s: %d", gpio, l, err);
return err;
}
@@ -84,13 +84,13 @@ int as3722_gpio_direction_output(struct udevice *dev, unsigned int gpio,
err = pmic_reg_write(pmic, AS3722_GPIO_CONTROL(gpio), value);
if (err) {
- error("failed to configure GPIO#%u as output: %d", gpio, err);
+ pr_err("failed to configure GPIO#%u as output: %d", gpio, err);
return err;
}
err = as3722_gpio_set_value(pmic, gpio, value);
if (err < 0) {
- error("failed to set GPIO#%u high: %d", gpio, err);
+ pr_err("failed to set GPIO#%u high: %d", gpio, err);
return err;
}
diff --git a/drivers/power/pmic/i2c_pmic_emul.c b/drivers/power/pmic/i2c_pmic_emul.c
index 2d35d09d45..38a2a04f17 100644
--- a/drivers/power/pmic/i2c_pmic_emul.c
+++ b/drivers/power/pmic/i2c_pmic_emul.c
@@ -31,7 +31,7 @@ static int sandbox_i2c_pmic_read_data(struct udevice *emul, uchar chip,
struct sandbox_i2c_pmic_plat_data *plat = dev_get_platdata(emul);
if (plat->rw_reg + len > SANDBOX_PMIC_REG_COUNT) {
- error("Request exceeds PMIC register range! Max register: %#x",
+ pr_err("Request exceeds PMIC register range! Max register: %#x",
SANDBOX_PMIC_REG_COUNT);
return -EFAULT;
}
@@ -68,7 +68,7 @@ static int sandbox_i2c_pmic_write_data(struct udevice *emul, uchar chip,
len--;
if (plat->rw_reg + len > SANDBOX_PMIC_REG_COUNT) {
- error("Request exceeds PMIC register range! Max register: %#x",
+ pr_err("Request exceeds PMIC register range! Max register: %#x",
SANDBOX_PMIC_REG_COUNT);
}
@@ -111,7 +111,7 @@ static int sandbox_i2c_pmic_ofdata_to_platdata(struct udevice *emul)
SANDBOX_PMIC_REG_COUNT);
if (!reg_defaults) {
- error("Property \"reg-defaults\" not found for device: %s!",
+ pr_err("Property \"reg-defaults\" not found for device: %s!",
emul->name);
return -EINVAL;
}
diff --git a/drivers/power/pmic/lp873x.c b/drivers/power/pmic/lp873x.c
index f505468313..95c2b7e8c7 100644
--- a/drivers/power/pmic/lp873x.c
+++ b/drivers/power/pmic/lp873x.c
@@ -27,7 +27,7 @@ static int lp873x_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- error("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!", dev, reg);
return -EIO;
}
@@ -37,7 +37,7 @@ static int lp873x_write(struct udevice *dev, uint reg, const uint8_t *buff,
static int lp873x_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- error("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!", dev, reg);
return -EIO;
}
diff --git a/drivers/power/pmic/lp87565.c b/drivers/power/pmic/lp87565.c
index 782a46c4cc..506769e362 100644
--- a/drivers/power/pmic/lp87565.c
+++ b/drivers/power/pmic/lp87565.c
@@ -29,7 +29,7 @@ static int lp87565_write(struct udevice *dev, uint reg, const uint8_t *buff,
ret = dm_i2c_write(dev, reg, buff, len);
if (ret)
- error("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!", dev, reg);
return ret;
}
@@ -40,7 +40,7 @@ static int lp87565_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
ret = dm_i2c_read(dev, reg, buff, len);
if (ret)
- error("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!", dev, reg);
return ret;
}
diff --git a/drivers/power/pmic/max77686.c b/drivers/power/pmic/max77686.c
index ceca9f96a7..b3ed84992f 100644
--- a/drivers/power/pmic/max77686.c
+++ b/drivers/power/pmic/max77686.c
@@ -31,7 +31,7 @@ static int max77686_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- error("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!", dev, reg);
return -EIO;
}
@@ -41,7 +41,7 @@ static int max77686_write(struct udevice *dev, uint reg, const uint8_t *buff,
static int max77686_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- error("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!", dev, reg);
return -EIO;
}
diff --git a/drivers/power/pmic/max8997.c b/drivers/power/pmic/max8997.c
index f749d7debf..5ebeb8a316 100644
--- a/drivers/power/pmic/max8997.c
+++ b/drivers/power/pmic/max8997.c
@@ -26,7 +26,7 @@ static int max8997_write(struct udevice *dev, uint reg, const uint8_t *buff,
ret = dm_i2c_write(dev, reg, buff, len);
if (ret)
- error("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!", dev, reg);
return ret;
}
@@ -37,7 +37,7 @@ static int max8997_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
ret = dm_i2c_read(dev, reg, buff, len);
if (ret)
- error("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!", dev, reg);
return ret;
}
diff --git a/drivers/power/pmic/max8998.c b/drivers/power/pmic/max8998.c
index 7c4773c7b3..a7e04699e8 100644
--- a/drivers/power/pmic/max8998.c
+++ b/drivers/power/pmic/max8998.c
@@ -26,7 +26,7 @@ static int max8998_write(struct udevice *dev, uint reg, const uint8_t *buff,
ret = dm_i2c_write(dev, reg, buff, len);
if (ret)
- error("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!", dev, reg);
return ret;
}
@@ -37,7 +37,7 @@ static int max8998_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
ret = dm_i2c_read(dev, reg, buff, len);
if (ret)
- error("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!", dev, reg);
return ret;
}
diff --git a/drivers/power/pmic/palmas.c b/drivers/power/pmic/palmas.c
index 804c0d13a0..1e1ecb382e 100644
--- a/drivers/power/pmic/palmas.c
+++ b/drivers/power/pmic/palmas.c
@@ -27,7 +27,7 @@ static int palmas_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- error("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!", dev, reg);
return -EIO;
}
@@ -37,7 +37,7 @@ static int palmas_write(struct udevice *dev, uint reg, const uint8_t *buff,
static int palmas_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- error("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!", dev, reg);
return -EIO;
}
diff --git a/drivers/power/pmic/pfuze100.c b/drivers/power/pmic/pfuze100.c
index 5f361c7696..a06cbc07d4 100644
--- a/drivers/power/pmic/pfuze100.c
+++ b/drivers/power/pmic/pfuze100.c
@@ -33,7 +33,7 @@ static int pfuze100_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- error("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!", dev, reg);
return -EIO;
}
@@ -43,7 +43,7 @@ static int pfuze100_write(struct udevice *dev, uint reg, const uint8_t *buff,
static int pfuze100_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- error("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!", dev, reg);
return -EIO;
}
diff --git a/drivers/power/pmic/s2mps11.c b/drivers/power/pmic/s2mps11.c
index 9d83059c40..522105e5ff 100644
--- a/drivers/power/pmic/s2mps11.c
+++ b/drivers/power/pmic/s2mps11.c
@@ -27,7 +27,7 @@ static int s2mps11_write(struct udevice *dev, uint reg, const uint8_t *buff,
ret = dm_i2c_write(dev, reg, buff, len);
if (ret)
- error("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!", dev, reg);
return ret;
}
@@ -38,7 +38,7 @@ static int s2mps11_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
ret = dm_i2c_read(dev, reg, buff, len);
if (ret)
- error("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!", dev, reg);
return ret;
}
diff --git a/drivers/power/pmic/s5m8767.c b/drivers/power/pmic/s5m8767.c
index f8ae5ea2db..3812e240ab 100644
--- a/drivers/power/pmic/s5m8767.c
+++ b/drivers/power/pmic/s5m8767.c
@@ -30,7 +30,7 @@ static int s5m8767_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- error("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!", dev, reg);
return -EIO;
}
@@ -40,7 +40,7 @@ static int s5m8767_write(struct udevice *dev, uint reg, const uint8_t *buff,
static int s5m8767_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- error("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!", dev, reg);
return -EIO;
}
diff --git a/drivers/power/pmic/sandbox.c b/drivers/power/pmic/sandbox.c
index 6763303c66..e8d6faca16 100644
--- a/drivers/power/pmic/sandbox.c
+++ b/drivers/power/pmic/sandbox.c
@@ -31,7 +31,7 @@ static int sandbox_pmic_write(struct udevice *dev, uint reg,
const uint8_t *buff, int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- error("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!", dev, reg);
return -EIO;
}
@@ -42,7 +42,7 @@ static int sandbox_pmic_read(struct udevice *dev, uint reg,
uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- error("read error from device: %p register: %#x!", dev, reg);
+ pr_err("read error from device: %p register: %#x!", dev, reg);
return -EIO;
}
@@ -52,7 +52,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_ofnode(dev), pmic_children_info))
- error("%s:%d PMIC: %s - no child found!", __func__, __LINE__,
+ pr_err("%s:%d PMIC: %s - no child found!", __func__, __LINE__,
dev->name);
/* Always return success for this device - allows for PMIC I/O */
diff --git a/drivers/power/pmic/tps65090.c b/drivers/power/pmic/tps65090.c
index 4565e3b54c..ee5358bced 100644
--- a/drivers/power/pmic/tps65090.c
+++ b/drivers/power/pmic/tps65090.c
@@ -29,7 +29,7 @@ static int tps65090_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- error("write error to device: %p register: %#x!", dev, reg);
+ pr_err("write error to device: %p register: %#x!", dev, reg);
return -EIO;
}
@@ -42,7 +42,7 @@ static int tps65090_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
ret = dm_i2c_read(dev, reg, buff, len);
if (ret) {
- error("read error %d from device: %p register: %#x!", ret, dev,
+ pr_err("read error %d from device: %p register: %#x!", ret, dev,
reg);
return -EIO;
}
diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
index c82a936e8a..8892fa14e0 100644
--- a/drivers/power/regulator/Kconfig
+++ b/drivers/power/regulator/Kconfig
@@ -77,6 +77,13 @@ config DM_REGULATOR_FIXED
features for fixed value regulators. The driver implements get/set api
for enable and get only for voltage value.
+config SPL_DM_REGULATOR_FIXED
+ bool "Enable Driver Model for REGULATOR Fixed value in SPL"
+ depends on DM_REGULATOR_FIXED
+ ---help---
+ This config enables implementation of driver-model regulator uclass
+ features for fixed value regulators in SPL.
+
config DM_REGULATOR_GPIO
bool "Enable Driver Model for GPIO REGULATOR"
depends on DM_REGULATOR
@@ -151,6 +158,19 @@ config DM_REGULATOR_PALMAS
features for REGULATOR PALMAS and the family of PALMAS PMICs.
The driver implements get/set api for: value and enable.
+config DM_REGULATOR_PBIAS
+ bool "Enable driver for PBIAS regulator"
+ depends on DM_REGULATOR
+ select REGMAP
+ select SYSCON
+ ---help---
+ This enables implementation of driver-model regulator uclass
+ features for pseudo-regulator PBIAS found in the OMAP SOCs.
+ This pseudo-regulator is used to provide a BIAS voltage to MMC1
+ signal pads and must be configured properly during a voltage switch.
+ Voltage switching is required by some operating modes of SDcards and
+ eMMC.
+
config DM_REGULATOR_LP873X
bool "Enable driver for LP873X PMIC regulators"
depends on PMIC_LP873X
diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile
index 18fb870e43..6c149a9263 100644
--- a/drivers/power/regulator/Makefile
+++ b/drivers/power/regulator/Makefile
@@ -18,5 +18,6 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o
obj-$(CONFIG_$(SPL_)DM_REGULATOR_PALMAS) += palmas_regulator.o
+obj-$(CONFIG_$(SPL_)DM_REGULATOR_PBIAS) += pbias_regulator.o
obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o
obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o
diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c
index 35c292222b..97b4a98bf0 100644
--- a/drivers/power/regulator/fixed.c
+++ b/drivers/power/regulator/fixed.c
@@ -117,7 +117,7 @@ static int fixed_regulator_set_enable(struct udevice *dev, bool enable)
ret = dm_gpio_set_value(&dev_pdata->gpio, enable);
if (ret) {
- error("Can't set regulator : %s gpio to: %d\n", dev->name,
+ pr_err("Can't set regulator : %s gpio to: %d\n", dev->name,
enable);
return ret;
}
diff --git a/drivers/power/regulator/gpio-regulator.c b/drivers/power/regulator/gpio-regulator.c
index 42391c69b4..1031a0362b 100644
--- a/drivers/power/regulator/gpio-regulator.c
+++ b/drivers/power/regulator/gpio-regulator.c
@@ -109,7 +109,7 @@ static int gpio_regulator_set_value(struct udevice *dev, int uV)
ret = dm_gpio_set_value(&dev_pdata->gpio, enable);
if (ret) {
- error("Can't set regulator : %s gpio to: %d\n", dev->name,
+ pr_err("Can't set regulator : %s gpio to: %d\n", dev->name,
enable);
return ret;
}
diff --git a/drivers/power/regulator/max77686.c b/drivers/power/regulator/max77686.c
index 8780806cff..2212d36ed6 100644
--- a/drivers/power/regulator/max77686.c
+++ b/drivers/power/regulator/max77686.c
@@ -98,7 +98,7 @@ static int max77686_buck_volt2hex(int buck, int uV)
if (hex >= 0 && hex <= hex_max)
return hex;
- error("Value: %d uV is wrong for BUCK%d", uV, buck);
+ pr_err("Value: %d uV is wrong for BUCK%d", uV, buck);
return -EINVAL;
}
@@ -134,7 +134,7 @@ static int max77686_buck_hex2volt(int buck, int hex)
return uV;
bad_hex:
- error("Value: %#x is wrong for BUCK%d", hex, buck);
+ pr_err("Value: %#x is wrong for BUCK%d", hex, buck);
return -EINVAL;
}
@@ -160,7 +160,7 @@ static int max77686_ldo_volt2hex(int ldo, int uV)
if (hex >= 0 && hex <= MAX77686_LDO_VOLT_MAX_HEX)
return hex;
- error("Value: %d uV is wrong for LDO%d", uV, ldo);
+ pr_err("Value: %d uV is wrong for LDO%d", uV, ldo);
return -EINVAL;
}
@@ -189,7 +189,7 @@ static int max77686_ldo_hex2volt(int ldo, int hex)
return uV;
bad_hex:
- error("Value: %#x is wrong for ldo%d", hex, ldo);
+ pr_err("Value: %#x is wrong for ldo%d", hex, ldo);
return -EINVAL;
}
@@ -328,7 +328,7 @@ static int max77686_ldo_val(struct udevice *dev, int op, int *uV)
ldo = dev->driver_data;
if (ldo < 1 || ldo > MAX77686_LDO_NUM) {
- error("Wrong ldo number: %d", ldo);
+ pr_err("Wrong ldo number: %d", ldo);
return -EINVAL;
}
@@ -366,7 +366,7 @@ static int max77686_buck_val(struct udevice *dev, int op, int *uV)
buck = dev->driver_data;
if (buck < 1 || buck > MAX77686_BUCK_NUM) {
- error("Wrong buck number: %d", buck);
+ pr_err("Wrong buck number: %d", buck);
return -EINVAL;
}
@@ -423,7 +423,7 @@ static int max77686_ldo_mode(struct udevice *dev, int op, int *opmode)
ldo = dev->driver_data;
if (ldo < 1 || ldo > MAX77686_LDO_NUM) {
- error("Wrong ldo number: %d", ldo);
+ pr_err("Wrong ldo number: %d", ldo);
return -EINVAL;
}
@@ -493,7 +493,7 @@ static int max77686_ldo_mode(struct udevice *dev, int op, int *opmode)
}
if (mode == 0xff) {
- error("Wrong mode: %d for ldo%d", *opmode, ldo);
+ pr_err("Wrong mode: %d for ldo%d", *opmode, ldo);
return -EINVAL;
}
@@ -545,7 +545,7 @@ static int max77686_buck_mode(struct udevice *dev, int op, int *opmode)
buck = dev->driver_data;
if (buck < 1 || buck > MAX77686_BUCK_NUM) {
- error("Wrong buck number: %d", buck);
+ pr_err("Wrong buck number: %d", buck);
return -EINVAL;
}
@@ -614,7 +614,7 @@ static int max77686_buck_mode(struct udevice *dev, int op, int *opmode)
}
if (mode == 0xff) {
- error("Wrong mode: %d for buck: %d\n", *opmode, buck);
+ pr_err("Wrong mode: %d for buck: %d\n", *opmode, buck);
return -EINVAL;
}
diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c
new file mode 100644
index 0000000000..116b7f480a
--- /dev/null
+++ b/drivers/power/regulator/pbias_regulator.c
@@ -0,0 +1,301 @@
+/*
+ * (C) Copyright 2016 Texas Instruments Incorporated, <www.ti.com>
+ * Jean-Jacques Hiblot <jjhiblot@ti.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <dm.h>
+#include <power/pmic.h>
+#include <power/regulator.h>
+#include <regmap.h>
+#include <syscon.h>
+#include <linux/bitops.h>
+#include <linux/ioport.h>
+#include <dm/read.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct pbias_reg_info {
+ u32 enable;
+ u32 enable_mask;
+ u32 disable_val;
+ u32 vmode;
+ unsigned int enable_time;
+ char *name;
+};
+
+struct pbias_priv {
+ struct regmap *regmap;
+ int offset;
+};
+
+static const struct pmic_child_info pmic_children_info[] = {
+ { .prefix = "pbias", .driver = "pbias_regulator"},
+ { },
+};
+
+static int pbias_write(struct udevice *dev, uint reg, const uint8_t *buff,
+ int len)
+{
+ struct pbias_priv *priv = dev_get_priv(dev);
+ u32 val = *(u32 *)buff;
+
+ if (len != 4)
+ return -EINVAL;
+
+ return regmap_write(priv->regmap, priv->offset, val);
+}
+
+static int pbias_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
+{
+ struct pbias_priv *priv = dev_get_priv(dev);
+
+ if (len != 4)
+ return -EINVAL;
+
+ return regmap_read(priv->regmap, priv->offset, (u32 *)buff);
+}
+
+static int pbias_ofdata_to_platdata(struct udevice *dev)
+{
+ struct pbias_priv *priv = dev_get_priv(dev);
+ struct udevice *syscon;
+ struct regmap *regmap;
+ struct resource res;
+ int err;
+
+ err = uclass_get_device_by_phandle(UCLASS_SYSCON, dev,
+ "syscon", &syscon);
+ if (err) {
+ pr_err("%s: unable to find syscon device (%d)\n", __func__,
+ err);
+ return err;
+ }
+
+ regmap = syscon_get_regmap(syscon);
+ if (IS_ERR(regmap)) {
+ pr_err("%s: unable to find regmap (%ld)\n", __func__,
+ PTR_ERR(regmap));
+ return PTR_ERR(regmap);
+ }
+ priv->regmap = regmap;
+
+ err = dev_read_resource(dev, 0, &res);
+ if (err) {
+ pr_err("%s: unable to find offset (%d)\n", __func__, err);
+ return err;
+ }
+ priv->offset = res.start;
+
+ return 0;
+}
+
+static int pbias_bind(struct udevice *dev)
+{
+ int children;
+
+ children = pmic_bind_children(dev, dev->node, pmic_children_info);
+ if (!children)
+ debug("%s: %s - no child found\n", __func__, dev->name);
+
+ return 0;
+}
+
+static struct dm_pmic_ops pbias_ops = {
+ .read = pbias_read,
+ .write = pbias_write,
+};
+
+static const struct udevice_id pbias_ids[] = {
+ { .compatible = "ti,pbias-dra7" },
+ { }
+};
+
+U_BOOT_DRIVER(pbias_pmic) = {
+ .name = "pbias_pmic",
+ .id = UCLASS_PMIC,
+ .of_match = pbias_ids,
+ .bind = pbias_bind,
+ .ops = &pbias_ops,
+ .ofdata_to_platdata = pbias_ofdata_to_platdata,
+ .priv_auto_alloc_size = sizeof(struct pbias_priv),
+};
+
+static const struct pbias_reg_info pbias_mmc_omap2430 = {
+ .enable = BIT(1),
+ .enable_mask = BIT(1),
+ .vmode = BIT(0),
+ .disable_val = 0,
+ .enable_time = 100,
+ .name = "pbias_mmc_omap2430"
+};
+
+static const struct pbias_reg_info pbias_sim_omap3 = {
+ .enable = BIT(9),
+ .enable_mask = BIT(9),
+ .vmode = BIT(8),
+ .enable_time = 100,
+ .name = "pbias_sim_omap3"
+};
+
+static const struct pbias_reg_info pbias_mmc_omap4 = {
+ .enable = BIT(26) | BIT(22),
+ .enable_mask = BIT(26) | BIT(25) | BIT(22),
+ .disable_val = BIT(25),
+ .vmode = BIT(21),
+ .enable_time = 100,
+ .name = "pbias_mmc_omap4"
+};
+
+static const struct pbias_reg_info pbias_mmc_omap5 = {
+ .enable = BIT(27) | BIT(26),
+ .enable_mask = BIT(27) | BIT(25) | BIT(26),
+ .disable_val = BIT(25),
+ .vmode = BIT(21),
+ .enable_time = 100,
+ .name = "pbias_mmc_omap5"
+};
+
+static const struct pbias_reg_info *pbias_reg_infos[] = {
+ &pbias_mmc_omap5,
+ &pbias_mmc_omap4,
+ &pbias_sim_omap3,
+ &pbias_mmc_omap2430,
+ NULL
+};
+
+static int pbias_regulator_probe(struct udevice *dev)
+{
+ const struct pbias_reg_info **p = pbias_reg_infos;
+ struct dm_regulator_uclass_platdata *uc_pdata;
+
+ uc_pdata = dev_get_uclass_platdata(dev);
+
+ while (*p) {
+ int rc;
+
+ rc = dev_read_stringlist_search(dev, "regulator-name",
+ (*p)->name);
+ if (rc >= 0) {
+ debug("found regulator %s\n", (*p)->name);
+ break;
+ } else if (rc != -ENODATA) {
+ return rc;
+ }
+ p++;
+ }
+ if (!*p) {
+ int i = 0;
+ const char *s;
+
+ debug("regulator ");
+ while (dev_read_string_index(dev, "regulator-name", i++, &s) >= 0)
+ debug("%s'%s' ", (i > 1) ? ", " : "", s);
+ debug("%s not supported\n", (i > 2) ? "are" : "is");
+ return -EINVAL;
+ }
+
+ uc_pdata->type = REGULATOR_TYPE_OTHER;
+ dev->priv = (void *)*p;
+
+ return 0;
+}
+
+static int pbias_regulator_get_value(struct udevice *dev)
+{
+ const struct pbias_reg_info *p = dev_get_priv(dev);
+ int rc;
+ u32 reg;
+
+ rc = pmic_read(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
+ if (rc)
+ return rc;
+
+ debug("%s voltage id %s\n", p->name,
+ (reg & p->vmode) ? "3.0v" : "1.8v");
+ return (reg & p->vmode) ? 3000000 : 1800000;
+}
+
+static int pbias_regulator_set_value(struct udevice *dev, int uV)
+{
+ const struct pbias_reg_info *p = dev_get_priv(dev);
+ int rc;
+ u32 reg;
+
+ debug("Setting %s voltage to %s\n", p->name,
+ (reg & p->vmode) ? "3.0v" : "1.8v");
+
+ rc = pmic_read(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
+ if (rc)
+ return rc;
+
+ if (uV == 3000000)
+ reg |= p->vmode;
+ else if (uV == 1800000)
+ reg &= ~p->vmode;
+ else
+ return -EINVAL;
+
+ return pmic_write(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
+}
+
+static int pbias_regulator_get_enable(struct udevice *dev)
+{
+ const struct pbias_reg_info *p = dev_get_priv(dev);
+ int rc;
+ u32 reg;
+
+ rc = pmic_read(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
+ if (rc)
+ return rc;
+
+ debug("%s id %s\n", p->name,
+ (reg & p->enable_mask) == (p->disable_val) ? "on" : "off");
+
+ return (reg & p->enable_mask) == (p->disable_val);
+}
+
+static int pbias_regulator_set_enable(struct udevice *dev, bool enable)
+{
+ const struct pbias_reg_info *p = dev_get_priv(dev);
+ int rc;
+ u32 reg;
+
+ debug("Turning %s %s\n", enable ? "on" : "off", p->name);
+
+ rc = pmic_read(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
+ if (rc)
+ return rc;
+
+ reg &= ~p->enable_mask;
+ if (enable)
+ reg |= p->enable;
+ else
+ reg |= p->disable_val;
+
+ rc = pmic_write(dev->parent, 0, (uint8_t *)&reg, sizeof(reg));
+ if (rc)
+ return rc;
+
+ if (enable)
+ udelay(p->enable_time);
+
+ return 0;
+}
+
+static const struct dm_regulator_ops pbias_regulator_ops = {
+ .get_value = pbias_regulator_get_value,
+ .set_value = pbias_regulator_set_value,
+ .get_enable = pbias_regulator_get_enable,
+ .set_enable = pbias_regulator_set_enable,
+};
+
+U_BOOT_DRIVER(pbias_regulator) = {
+ .name = "pbias_regulator",
+ .id = UCLASS_REGULATOR,
+ .ops = &pbias_regulator_ops,
+ .probe = pbias_regulator_probe,
+};
diff --git a/drivers/power/regulator/sandbox.c b/drivers/power/regulator/sandbox.c
index 06c09fd051..f980a17389 100644
--- a/drivers/power/regulator/sandbox.c
+++ b/drivers/power/regulator/sandbox.c
@@ -87,7 +87,7 @@ int out_get_value(struct udevice *dev, int output_count, int reg_type,
int ret;
if (dev->driver_data > output_count) {
- error("Unknown regulator number: %lu for PMIC %s!",
+ pr_err("Unknown regulator number: %lu for PMIC %s!",
dev->driver_data, dev->name);
return -EINVAL;
}
@@ -95,7 +95,7 @@ int out_get_value(struct udevice *dev, int output_count, int reg_type,
reg = (dev->driver_data - 1) * OUT_REG_COUNT + reg_type;
ret = pmic_read(dev->parent, reg, &reg_val, 1);
if (ret) {
- error("PMIC read failed: %d\n", ret);
+ pr_err("PMIC read failed: %d\n", ret);
return ret;
}
@@ -115,14 +115,14 @@ static int out_set_value(struct udevice *dev, int output_count, int reg_type,
int max_value;
if (dev->driver_data > output_count) {
- error("Unknown regulator number: %lu for PMIC %s!",
+ pr_err("Unknown regulator number: %lu for PMIC %s!",
dev->driver_data, dev->name);
return -EINVAL;
}
max_value = range[dev->driver_data - 1].max;
if (value > max_value) {
- error("Wrong value for %s: %lu. Max is: %d.",
+ pr_err("Wrong value for %s: %lu. Max is: %d.",
dev->name, dev->driver_data, max_value);
return -EINVAL;
}
@@ -134,7 +134,7 @@ static int out_set_value(struct udevice *dev, int output_count, int reg_type,
reg = (dev->driver_data - 1) * OUT_REG_COUNT + reg_type;
ret = pmic_write(dev->parent, reg, &reg_val, 1);
if (ret) {
- error("PMIC write failed: %d\n", ret);
+ pr_err("PMIC write failed: %d\n", ret);
return ret;
}
@@ -154,7 +154,7 @@ static int out_get_mode(struct udevice *dev)
reg = (dev->driver_data - 1) * OUT_REG_COUNT + OUT_REG_OM;
ret = pmic_read(dev->parent, reg, &reg_val, 1);
if (ret) {
- error("PMIC read failed: %d\n", ret);
+ pr_err("PMIC read failed: %d\n", ret);
return ret;
}
@@ -163,7 +163,7 @@ static int out_get_mode(struct udevice *dev)
return uc_pdata->mode[i].id;
}
- error("Unknown operation mode for %s!", dev->name);
+ pr_err("Unknown operation mode for %s!", dev->name);
return -EINVAL;
}
@@ -188,14 +188,14 @@ static int out_set_mode(struct udevice *dev, int mode)
}
if (reg_val == -1) {
- error("Unknown operation mode for %s!", dev->name);
+ pr_err("Unknown operation mode for %s!", dev->name);
return -EINVAL;
}
reg = (dev->driver_data - 1) * OUT_REG_COUNT + OUT_REG_OM;
ret = pmic_write(dev->parent, reg, (uint8_t *)&reg_val, 1);
if (ret) {
- error("PMIC write failed: %d\n", ret);
+ pr_err("PMIC write failed: %d\n", ret);
return ret;
}