Commit 505cf475 authored by Jaehoon Chung's avatar Jaehoon Chung

power: change from meaningless value to error number

'-1' is absolutely meaningless value.
This patch changed from meaningless value to error number.
Signed-off-by: 's avatarJaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: 's avatarSimon Glass <sjg@chromium.org>
parent 9c720c81
...@@ -75,7 +75,7 @@ int axp_init(void) ...@@ -75,7 +75,7 @@ int axp_init(void)
return rc; return rc;
if (ver != 0x05) if (ver != 0x05)
return -1; return -EINVAL;
return 0; return 0;
} }
......
...@@ -158,7 +158,7 @@ int axp_init(void) ...@@ -158,7 +158,7 @@ int axp_init(void)
ver &= 0x0f; ver &= 0x0f;
if (ver != 0x1) if (ver != 0x1)
return -1; return -EINVAL;
/* Mask all interrupts */ /* Mask all interrupts */
for (i = AXP209_IRQ_ENABLE1; i <= AXP209_IRQ_ENABLE5; i++) { for (i = AXP209_IRQ_ENABLE1; i <= AXP209_IRQ_ENABLE5; i++) {
......
...@@ -18,7 +18,7 @@ static int power_battery_charge(struct pmic *bat) ...@@ -18,7 +18,7 @@ static int power_battery_charge(struct pmic *bat)
struct power_battery *p_bat = bat->pbat; struct power_battery *p_bat = bat->pbat;
if (bat->chrg->chrg_state(p_bat->chrg, PMIC_CHARGER_ENABLE, 450)) if (bat->chrg->chrg_state(p_bat->chrg, PMIC_CHARGER_ENABLE, 450))
return -1; return -EINVAL;
return 0; return 0;
} }
......
...@@ -190,7 +190,7 @@ static int get_tmu_fdt_values(struct tmu_info *info, const void *blob) ...@@ -190,7 +190,7 @@ static int get_tmu_fdt_values(struct tmu_info *info, const void *blob)
COMPAT_SAMSUNG_EXYNOS_TMU); COMPAT_SAMSUNG_EXYNOS_TMU);
if (node < 0) { if (node < 0) {
debug("EXYNOS_TMU: No node for tmu in device tree\n"); debug("EXYNOS_TMU: No node for tmu in device tree\n");
return -1; return -ENODEV;
} }
/* /*
...@@ -202,7 +202,7 @@ static int get_tmu_fdt_values(struct tmu_info *info, const void *blob) ...@@ -202,7 +202,7 @@ static int get_tmu_fdt_values(struct tmu_info *info, const void *blob)
addr = fdtdec_get_addr(blob, node, "reg"); addr = fdtdec_get_addr(blob, node, "reg");
if (addr == FDT_ADDR_T_NONE) { if (addr == FDT_ADDR_T_NONE) {
debug("%s: Missing tmu-base\n", __func__); debug("%s: Missing tmu-base\n", __func__);
return -1; return -ENODEV;
} }
info->tmu_base = (struct exynos5_tmu_reg *)addr; info->tmu_base = (struct exynos5_tmu_reg *)addr;
...@@ -246,11 +246,11 @@ static int get_tmu_fdt_values(struct tmu_info *info, const void *blob) ...@@ -246,11 +246,11 @@ static int get_tmu_fdt_values(struct tmu_info *info, const void *blob)
if (error) { if (error) {
debug("fail to get tmu node properties\n"); debug("fail to get tmu node properties\n");
return -1; return -EINVAL;
} }
#else #else
/* Non DT support may never be added. Just in case */ /* Non DT support may never be added. Just in case */
return -1; return -ENODEV;
#endif #endif
return 0; return 0;
......
...@@ -199,7 +199,7 @@ static int power_update_battery(struct pmic *p, struct pmic *bat) ...@@ -199,7 +199,7 @@ static int power_update_battery(struct pmic *p, struct pmic *bat)
if (pmic_probe(p)) { if (pmic_probe(p)) {
puts("Can't find max17042 fuel gauge\n"); puts("Can't find max17042 fuel gauge\n");
return -1; return -ENODEV;
} }
ret |= pmic_reg_read(p, MAX17042_VFSOC, &val); ret |= pmic_reg_read(p, MAX17042_VFSOC, &val);
...@@ -224,7 +224,7 @@ static int power_check_battery(struct pmic *p, struct pmic *bat) ...@@ -224,7 +224,7 @@ static int power_check_battery(struct pmic *p, struct pmic *bat)
if (pmic_probe(p)) { if (pmic_probe(p)) {
puts("Can't find max17042 fuel gauge\n"); puts("Can't find max17042 fuel gauge\n");
return -1; return -ENODEV;
} }
ret |= pmic_reg_read(p, MAX17042_STATUS, &val); ret |= pmic_reg_read(p, MAX17042_STATUS, &val);
......
...@@ -52,7 +52,7 @@ static int power_update_battery(struct pmic *p, struct pmic *bat) ...@@ -52,7 +52,7 @@ static int power_update_battery(struct pmic *p, struct pmic *bat)
if (pmic_probe(p)) { if (pmic_probe(p)) {
puts("Can't find max77693 fuel gauge\n"); puts("Can't find max77693 fuel gauge\n");
return -1; return -ENODEV;
} }
ret = max77693_get_soc(&pb->bat->state_of_chrg); ret = max77693_get_soc(&pb->bat->state_of_chrg);
...@@ -74,7 +74,7 @@ static int power_check_battery(struct pmic *p, struct pmic *bat) ...@@ -74,7 +74,7 @@ static int power_check_battery(struct pmic *p, struct pmic *bat)
if (pmic_probe(p)) { if (pmic_probe(p)) {
puts("Can't find max77693 fuel gauge\n"); puts("Can't find max77693 fuel gauge\n");
return -1; return -ENODEV;
} }
ret = pmic_reg_read(p, MAX77693_STATUS, &val); ret = pmic_reg_read(p, MAX77693_STATUS, &val);
......
...@@ -16,7 +16,7 @@ static int max77693_charger_state(struct pmic *p, int state, int current) ...@@ -16,7 +16,7 @@ static int max77693_charger_state(struct pmic *p, int state, int current)
unsigned int val; unsigned int val;
if (pmic_probe(p)) if (pmic_probe(p))
return -1; return -ENODEV;
/* unlock write capability */ /* unlock write capability */
val = MAX77693_CHG_UNLOCK; val = MAX77693_CHG_UNLOCK;
...@@ -27,13 +27,13 @@ static int max77693_charger_state(struct pmic *p, int state, int current) ...@@ -27,13 +27,13 @@ static int max77693_charger_state(struct pmic *p, int state, int current)
pmic_reg_read(p, MAX77693_CHG_CNFG_00, &val); pmic_reg_read(p, MAX77693_CHG_CNFG_00, &val);
val &= ~0x01; val &= ~0x01;
pmic_reg_write(p, MAX77693_CHG_CNFG_00, val); pmic_reg_write(p, MAX77693_CHG_CNFG_00, val);
return -1; return -ENOTSUPP;
} }
if (current < CHARGER_MIN_CURRENT || current > CHARGER_MAX_CURRENT) { if (current < CHARGER_MIN_CURRENT || current > CHARGER_MAX_CURRENT) {
printf("%s: Wrong charge current: %d [mA]\n", printf("%s: Wrong charge current: %d [mA]\n",
__func__, current); __func__, current);
return -1; return -EINVAL;
} }
/* set charging current */ /* set charging current */
...@@ -59,7 +59,7 @@ static int max77693_charger_bat_present(struct pmic *p) ...@@ -59,7 +59,7 @@ static int max77693_charger_bat_present(struct pmic *p)
unsigned int val; unsigned int val;
if (pmic_probe(p)) if (pmic_probe(p))
return -1; return -ENODEV;
pmic_reg_read(p, MAX77693_CHG_INT_OK, &val); pmic_reg_read(p, MAX77693_CHG_INT_OK, &val);
......
...@@ -47,20 +47,23 @@ int palmas_mmc1_poweron_ldo(uint voltage) ...@@ -47,20 +47,23 @@ int palmas_mmc1_poweron_ldo(uint voltage)
u8 val = 0; u8 val = 0;
#if defined(CONFIG_DRA7XX) #if defined(CONFIG_DRA7XX)
int ret;
/* /*
* Currently valid for the dra7xx_evm board: * Currently valid for the dra7xx_evm board:
* Set TPS659038 LDO1 to 3.0 V * Set TPS659038 LDO1 to 3.0 V
*/ */
val = LDO_VOLT_3V0; val = LDO_VOLT_3V0;
if (palmas_i2c_write_u8(TPS65903X_CHIP_P1, LDO1_VOLTAGE, val)) { ret = palmas_i2c_write_u8(TPS65903X_CHIP_P1, LDO1_VOLTAGE, val);
if (ret) {
printf("tps65903x: could not set LDO1 voltage.\n"); printf("tps65903x: could not set LDO1 voltage.\n");
return 1; return ret;
} }
/* TURN ON LDO1 */ /* TURN ON LDO1 */
val = RSC_MODE_SLEEP | RSC_MODE_ACTIVE; val = RSC_MODE_SLEEP | RSC_MODE_ACTIVE;
if (palmas_i2c_write_u8(TPS65903X_CHIP_P1, LDO1_CTRL, val)) { ret = palmas_i2c_write_u8(TPS65903X_CHIP_P1, LDO1_CTRL, val);
if (ret) {
printf("tps65903x: could not turn on LDO1.\n"); printf("tps65903x: could not turn on LDO1.\n");
return 1; return ret;
} }
return 0; return 0;
#else #else
......
...@@ -26,7 +26,7 @@ void hi6553_writeb(u32 offset, uint8_t value) ...@@ -26,7 +26,7 @@ void hi6553_writeb(u32 offset, uint8_t value)
int pmic_reg_write(struct pmic *p, u32 reg, u32 val) int pmic_reg_write(struct pmic *p, u32 reg, u32 val)
{ {
if (check_reg(p, reg)) if (check_reg(p, reg))
return -1; return -EINVAL;
hi6553_writeb(reg, (uint8_t)val); hi6553_writeb(reg, (uint8_t)val);
...@@ -36,7 +36,7 @@ int pmic_reg_write(struct pmic *p, u32 reg, u32 val) ...@@ -36,7 +36,7 @@ int pmic_reg_write(struct pmic *p, u32 reg, u32 val)
int pmic_reg_read(struct pmic *p, u32 reg, u32 *val) int pmic_reg_read(struct pmic *p, u32 reg, u32 *val)
{ {
if (check_reg(p, reg)) if (check_reg(p, reg))
return -1; return -EINVAL;
*val = (u32)hi6553_readb(reg); *val = (u32)hi6553_readb(reg);
......
...@@ -67,14 +67,14 @@ int max77686_set_ldo_voltage(struct pmic *p, int ldo, ulong uV) ...@@ -67,14 +67,14 @@ int max77686_set_ldo_voltage(struct pmic *p, int ldo, ulong uV)
if (ldo < 1 || ldo > 26) { if (ldo < 1 || ldo > 26) {
printf("%s: %d is wrong ldo number\n", __func__, ldo); printf("%s: %d is wrong ldo number\n", __func__, ldo);
return -1; return -EINVAL;
} }
adr = MAX77686_REG_PMIC_LDO1CTRL1 + ldo - 1; adr = MAX77686_REG_PMIC_LDO1CTRL1 + ldo - 1;
hex = max77686_ldo_volt2hex(ldo, uV); hex = max77686_ldo_volt2hex(ldo, uV);
if (!hex) if (!hex)
return -1; return -EINVAL;
ret = pmic_reg_read(p, adr, &val); ret = pmic_reg_read(p, adr, &val);
if (ret) if (ret)
...@@ -120,7 +120,7 @@ int max77686_set_ldo_mode(struct pmic *p, int ldo, char opmode) ...@@ -120,7 +120,7 @@ int max77686_set_ldo_mode(struct pmic *p, int ldo, char opmode)
if (ldo < 1 || 26 < ldo) { if (ldo < 1 || 26 < ldo) {
printf("%s: %d is wrong ldo number\n", __func__, ldo); printf("%s: %d is wrong ldo number\n", __func__, ldo);
return -1; return -EINVAL;
} }
adr = MAX77686_REG_PMIC_LDO1CTRL1 + ldo - 1; adr = MAX77686_REG_PMIC_LDO1CTRL1 + ldo - 1;
...@@ -161,7 +161,7 @@ int max77686_set_ldo_mode(struct pmic *p, int ldo, char opmode) ...@@ -161,7 +161,7 @@ int max77686_set_ldo_mode(struct pmic *p, int ldo, char opmode)
if (mode == 0xff) { if (mode == 0xff) {
printf("%s: %d is not supported on LDO%d\n", printf("%s: %d is not supported on LDO%d\n",
__func__, opmode, ldo); __func__, opmode, ldo);
return -1; return -ENOTSUPP;
} }
ret = pmic_reg_read(p, adr, &val); ret = pmic_reg_read(p, adr, &val);
...@@ -182,7 +182,7 @@ int max77686_set_buck_mode(struct pmic *p, int buck, char opmode) ...@@ -182,7 +182,7 @@ int max77686_set_buck_mode(struct pmic *p, int buck, char opmode)
size = ARRAY_SIZE(max77686_buck_addr); size = ARRAY_SIZE(max77686_buck_addr);
if (buck >= size) { if (buck >= size) {
printf("%s: %d is wrong buck number\n", __func__, buck); printf("%s: %d is wrong buck number\n", __func__, buck);
return -1; return -EINVAL;
} }
adr = max77686_buck_addr[buck]; adr = max77686_buck_addr[buck];
...@@ -238,7 +238,7 @@ int max77686_set_buck_mode(struct pmic *p, int buck, char opmode) ...@@ -238,7 +238,7 @@ int max77686_set_buck_mode(struct pmic *p, int buck, char opmode)
if (mode == 0xff) { if (mode == 0xff) {
printf("%s: %d is not supported on BUCK%d\n", printf("%s: %d is not supported on BUCK%d\n",
__func__, opmode, buck); __func__, opmode, buck);
return -1; return -ENOTSUPP;
} }
ret = pmic_reg_read(p, adr, &val); ret = pmic_reg_read(p, adr, &val);
...@@ -271,20 +271,20 @@ int pmic_init(unsigned char bus) ...@@ -271,20 +271,20 @@ int pmic_init(unsigned char bus)
if (node < 0) { if (node < 0) {
debug("PMIC: No node for PMIC Chip in device tree\n"); debug("PMIC: No node for PMIC Chip in device tree\n");
debug("node = %d\n", node); debug("node = %d\n", node);
return -1; return -ENODEV;
} }
parent = fdt_parent_offset(blob, node); parent = fdt_parent_offset(blob, node);
if (parent < 0) { if (parent < 0) {
debug("%s: Cannot find node parent\n", __func__); debug("%s: Cannot find node parent\n", __func__);
return -1; return -ENODEV;
} }
/* tmp since p->bus is unsigned */ /* tmp since p->bus is unsigned */
tmp = i2c_get_bus_num_fdt(parent); tmp = i2c_get_bus_num_fdt(parent);
if (tmp < 0) { if (tmp < 0) {
debug("%s: Cannot find I2C bus\n", __func__); debug("%s: Cannot find I2C bus\n", __func__);
return -1; return -ENODEV;
} }
p->bus = tmp; p->bus = tmp;
p->hw.i2c.addr = fdtdec_get_int(blob, node, "reg", 9); p->hw.i2c.addr = fdtdec_get_int(blob, node, "reg", 9);
......
...@@ -33,7 +33,7 @@ static int pmic_charger_state(struct pmic *p, int state, int current) ...@@ -33,7 +33,7 @@ static int pmic_charger_state(struct pmic *p, int state, int current)
u32 val = 0; u32 val = 0;
if (pmic_probe(p)) if (pmic_probe(p))
return -1; return -ENODEV;
if (state == PMIC_CHARGER_DISABLE) { if (state == PMIC_CHARGER_DISABLE) {
puts("Disable the charger.\n"); puts("Disable the charger.\n");
...@@ -41,13 +41,13 @@ static int pmic_charger_state(struct pmic *p, int state, int current) ...@@ -41,13 +41,13 @@ static int pmic_charger_state(struct pmic *p, int state, int current)
val &= ~(MBCHOSTEN | VCHGR_FC); val &= ~(MBCHOSTEN | VCHGR_FC);
pmic_reg_write(p, MAX8997_REG_MBCCTRL2, val); pmic_reg_write(p, MAX8997_REG_MBCCTRL2, val);
return -1; return -ENOTSUPP;
} }
if (current < CHARGER_MIN_CURRENT || current > CHARGER_MAX_CURRENT) { if (current < CHARGER_MIN_CURRENT || current > CHARGER_MAX_CURRENT) {
printf("%s: Wrong charge current: %d [mA]\n", printf("%s: Wrong charge current: %d [mA]\n",
__func__, current); __func__, current);
return -1; return -EINVAL;
} }
fc = (current - CHARGER_MIN_CURRENT) / CHARGER_CURRENT_RESOLUTION; fc = (current - CHARGER_MIN_CURRENT) / CHARGER_CURRENT_RESOLUTION;
...@@ -71,7 +71,7 @@ static int pmic_charger_bat_present(struct pmic *p) ...@@ -71,7 +71,7 @@ static int pmic_charger_bat_present(struct pmic *p)
u32 val; u32 val;
if (pmic_probe(p)) if (pmic_probe(p))
return -1; return -ENODEV;
pmic_reg_read(p, MAX8997_REG_STATUS4, &val); pmic_reg_read(p, MAX8997_REG_STATUS4, &val);
......
...@@ -23,7 +23,7 @@ int check_reg(struct pmic *p, u32 reg) ...@@ -23,7 +23,7 @@ int check_reg(struct pmic *p, u32 reg)
if (reg >= p->number_of_regs) { if (reg >= p->number_of_regs) {
printf("<reg num> = %d is invalid. Should be less than %d\n", printf("<reg num> = %d is invalid. Should be less than %d\n",
reg, p->number_of_regs); reg, p->number_of_regs);
return -1; return -EINVAL;
} }
return 0; return 0;
...@@ -34,7 +34,7 @@ int pmic_set_output(struct pmic *p, u32 reg, int out, int on) ...@@ -34,7 +34,7 @@ int pmic_set_output(struct pmic *p, u32 reg, int out, int on)
u32 val; u32 val;
if (pmic_reg_read(p, reg, &val)) if (pmic_reg_read(p, reg, &val))
return -1; return -ENOTSUPP;
if (on) if (on)
val |= out; val |= out;
...@@ -42,7 +42,7 @@ int pmic_set_output(struct pmic *p, u32 reg, int out, int on) ...@@ -42,7 +42,7 @@ int pmic_set_output(struct pmic *p, u32 reg, int out, int on)
val &= ~out; val &= ~out;
if (pmic_reg_write(p, reg, val)) if (pmic_reg_write(p, reg, val))
return -1; return -ENOTSUPP;
return 0; return 0;
} }
...@@ -59,7 +59,7 @@ static int pmic_dump(struct pmic *p) ...@@ -59,7 +59,7 @@ static int pmic_dump(struct pmic *p)
if (!p) { if (!p) {
puts("Wrong PMIC name!\n"); puts("Wrong PMIC name!\n");
return -1; return -ENODEV;
} }
pmic_show_info(p); pmic_show_info(p);
......
...@@ -19,9 +19,10 @@ ...@@ -19,9 +19,10 @@
int pmic_reg_write(struct pmic *p, u32 reg, u32 val) int pmic_reg_write(struct pmic *p, u32 reg, u32 val)
{ {
unsigned char buf[4] = { 0 }; unsigned char buf[4] = { 0 };
int ret;
if (check_reg(p, reg)) if (check_reg(p, reg))
return -1; return -EINVAL;
I2C_SET_BUS(p->bus); I2C_SET_BUS(p->bus);
...@@ -51,27 +52,26 @@ int pmic_reg_write(struct pmic *p, u32 reg, u32 val) ...@@ -51,27 +52,26 @@ int pmic_reg_write(struct pmic *p, u32 reg, u32 val)
break; break;
default: default:
printf("%s: invalid tx_num: %d", __func__, pmic_i2c_tx_num); printf("%s: invalid tx_num: %d", __func__, pmic_i2c_tx_num);
return -1; return -EINVAL;
} }
if (i2c_write(pmic_i2c_addr, reg, 1, buf, pmic_i2c_tx_num)) return i2c_write(pmic_i2c_addr, reg, 1, buf, pmic_i2c_tx_num);
return -1;
return 0;
} }
int pmic_reg_read(struct pmic *p, u32 reg, u32 *val) int pmic_reg_read(struct pmic *p, u32 reg, u32 *val)
{ {
unsigned char buf[4] = { 0 }; unsigned char buf[4] = { 0 };
u32 ret_val = 0; u32 ret_val = 0;
int ret;
if (check_reg(p, reg)) if (check_reg(p, reg))
return -1; return -EINVAL;
I2C_SET_BUS(p->bus); I2C_SET_BUS(p->bus);
if (i2c_read(pmic_i2c_addr, reg, 1, buf, pmic_i2c_tx_num)) ret = i2c_read(pmic_i2c_addr, reg, 1, buf, pmic_i2c_tx_num);
return -1; if (ret)
return ret;
switch (pmic_i2c_tx_num) { switch (pmic_i2c_tx_num) {
case 3: case 3:
...@@ -93,7 +93,7 @@ int pmic_reg_read(struct pmic *p, u32 reg, u32 *val) ...@@ -93,7 +93,7 @@ int pmic_reg_read(struct pmic *p, u32 reg, u32 *val)
break; break;
default: default:
printf("%s: invalid tx_num: %d", __func__, pmic_i2c_tx_num); printf("%s: invalid tx_num: %d", __func__, pmic_i2c_tx_num);
return -1; return -EINVAL;
} }
memcpy(val, &ret_val, sizeof(ret_val)); memcpy(val, &ret_val, sizeof(ret_val));
...@@ -106,7 +106,7 @@ int pmic_probe(struct pmic *p) ...@@ -106,7 +106,7 @@ int pmic_probe(struct pmic *p)
debug("Bus: %d PMIC:%s probed!\n", p->bus, p->name); debug("Bus: %d PMIC:%s probed!\n", p->bus, p->name);
if (i2c_probe(pmic_i2c_addr)) { if (i2c_probe(pmic_i2c_addr)) {
printf("Can't find PMIC:%s\n", p->name); printf("Can't find PMIC:%s\n", p->name);
return -1; return -ENODEV;
} }
return 0; return 0;
......
...@@ -27,14 +27,14 @@ static u32 pmic_reg(struct pmic *p, u32 reg, u32 *val, u32 write) ...@@ -27,14 +27,14 @@ static u32 pmic_reg(struct pmic *p, u32 reg, u32 *val, u32 write)
p->hw.spi.mode); p->hw.spi.mode);
if (!slave) if (!slave)
return -1; return -ENODEV;
} }
if (check_reg(p, reg)) if (check_reg(p, reg))
return -1; return -EINVAL;
if (spi_claim_bus(slave)) if (spi_claim_bus(slave))
return -1; return -EBUSY;
pmic_tx = p->hw.spi.prepare_tx(reg, val, write); pmic_tx = p->hw.spi.prepare_tx(reg, val, write);
...@@ -59,21 +59,15 @@ static u32 pmic_reg(struct pmic *p, u32 reg, u32 *val, u32 write) ...@@ -59,21 +59,15 @@ static u32 pmic_reg(struct pmic *p, u32 reg, u32 *val, u32 write)
err: err:
spi_release_bus(slave); spi_release_bus(slave);
return -1; return -ENOTSUPP;
} }
int pmic_reg_write(struct pmic *p, u32 reg, u32 val) int pmic_reg_write(struct pmic *p, u32 reg, u32 val)
{ {
if (pmic_reg(p, reg, &val, 1)) return pmic_reg(p, reg, &val, 1);
return -1;
return 0;
} }
int pmic_reg_read(struct pmic *p, u32 reg, u32 *val) int pmic_reg_read(struct pmic *p, u32 reg, u32 *val)
{ {
if (pmic_reg(p, reg, val, 0)) return pmic_reg(p, reg, val, 0);
return -1;
return 0;
} }
...@@ -97,14 +97,14 @@ static int read_voltages(int *sm0, int *sm1) ...@@ -97,14 +97,14 @@ static int read_voltages(int *sm0, int *sm1)
ctrl1 = tps6586x_read(SUPPLY_CONTROL1); ctrl1 = tps6586x_read(SUPPLY_CONTROL1);
ctrl2 = tps6586x_read(SUPPLY_CONTROL2); ctrl2 = tps6586x_read(SUPPLY_CONTROL2);
if (ctrl1 == -1 || ctrl2 == -1) if (ctrl1 == -1 || ctrl2 == -1)
return -1; return -ENOTSUPP;
/* Figure out whether V1 or V2 is selected */ /* Figure out whether V1 or V2 is selected */
is_v2 = (ctrl1 | ctrl2) & CTRL_SM0_SUPPLY2; is_v2 = (ctrl1 | ctrl2) & CTRL_SM0_SUPPLY2;
*sm0 = tps6586x_read(is_v2 ? SM0_VOLTAGE_V2 : SM0_VOLTAGE_V1); *sm0 = tps6586x_read(is_v2 ? SM0_VOLTAGE_V2 : SM0_VOLTAGE_V1);
*sm1 = tps6586x_read(is_v2 ? SM1_VOLTAGE_V2 : SM1_VOLTAGE_V1); *sm1 = tps6586x_read(is_v2 ? SM1_VOLTAGE_V2 : SM1_VOLTAGE_V1);
if (*sm0 == -1 || *sm1 == -1) if (*sm0 == -1 || *sm1 == -1)
return -1; return -ENOTSUPP;
return 0; return 0;
} }
...@@ -129,7 +129,7 @@ static int set_voltage(int reg, int data, int rate) ...@@ -129,7 +129,7 @@ static int set_voltage(int reg, int data, int rate)
/* write v1, v2 and rate, then trigger */ /* write v1, v2 and rate, then trigger */
if (tps6586x_write(reg, buff, 3) || if (tps6586x_write(reg, buff, 3) ||
tps6586x_write(SUPPLY_CONTROL1, &control_bit, 1)) tps6586x_write(SUPPLY_CONTROL1, &control_bit, 1))
return -1; return -ENOTSUPP;
return 0; return 0;
} }
...@@ -177,7 +177,7 @@ int tps6586x_adjust_sm0_sm1(int sm0_target, int sm1_target, int step, int rate, ...@@ -177,7 +177,7 @@ int tps6586x_adjust_sm0_sm1(int sm0_target, int sm1_target, int step, int rate,
/* get current voltage settings */ /* get current voltage settings */
if (read_voltages(&sm0, &sm1)) { if (read_voltages(&sm0, &sm1)) {
debug("%s: Cannot read voltage settings\n", __func__); debug("%s: Cannot read voltage settings\n", __func__);
return -1; return -EINVAL;
} }
/* /*
...@@ -189,7 +189,7 @@ int tps6586x_adjust_sm0_sm1(int sm0_target, int sm1_target, int step, int rate, ...@@ -189,7 +189,7 @@ int tps6586x_adjust_sm0_sm1(int sm0_target, int sm1_target, int step, int rate,
if (min_sm0_over_sm1 != -1 && sm0 < sm1 + min_sm0_over_sm1) { if (min_sm0_over_sm1 != -1 && sm0 < sm1 + min_sm0_over_sm1) {
debug("%s: SM0 is %d, SM1 is %d, but min_sm0_over_sm1 is %d\n", debug("%s: SM0 is %d, SM1 is %d, but min_sm0_over_sm1 is %d\n",
__func__, sm0, sm1, min_sm0_over_sm1); __func__, sm0, sm1, min_sm0_over_sm1);
return -1; return -EINVAL;
} }
/* /*
...@@ -240,7 +240,7 @@ int tps6586x_adjust_sm0_sm1(int sm0_target, int sm1_target, int step, int rate, ...@@ -240,7 +240,7 @@ int tps6586x_adjust_sm0_sm1(int sm0_target, int sm1_target, int step, int rate,
} }
debug("%d-%d %d-%d done\n", sm0, sm0_target, sm1, sm1_target); debug("%d-%d %d-%d done\n", sm0, sm0_target, sm1, sm1_target);
return bad ? -1 : 0; return bad ? -EINVAL : 0;
} }
int tps6586x_init(struct udevice *dev) int tps6586x_init(struct udevice *dev)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment