* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
-#include <i2c.h>
+#include <asm/arch/pmic_bus.h>
#include <axp_pmic.h>
-static int axp152_write(enum axp152_reg reg, u8 val)
-{
- return i2c_write(0x30, reg, 1, &val, 1);
-}
-
-static int axp152_read(enum axp152_reg reg, u8 *val)
-{
- return i2c_read(0x30, reg, 1, val, 1);
-}
-
static u8 axp152_mvolt_to_target(int mvolt, int min, int max, int div)
{
if (mvolt < min)
target = axp152_mvolt_to_target(mvolt, 700, 2275, 25);
/* Do we really need to be this gentle? It has built-in voltage slope */
- while ((rc = axp152_read(AXP152_DCDC2_VOLTAGE, ¤t)) == 0 &&
+ while ((rc = pmic_bus_read(AXP152_DCDC2_VOLTAGE, ¤t)) == 0 &&
current != target) {
if (current < target)
current++;
else
current--;
- rc = axp152_write(AXP152_DCDC2_VOLTAGE, current);
+ rc = pmic_bus_write(AXP152_DCDC2_VOLTAGE, current);
if (rc)
break;
}
{
u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 50);
- return axp152_write(AXP152_DCDC3_VOLTAGE, target);
+ return pmic_bus_write(AXP152_DCDC3_VOLTAGE, target);
}
int axp_set_dcdc4(unsigned int mvolt)
{
u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 25);
- return axp152_write(AXP152_DCDC4_VOLTAGE, target);
+ return pmic_bus_write(AXP152_DCDC4_VOLTAGE, target);
}
int axp_set_aldo2(unsigned int mvolt)
{
u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 100);
- return axp152_write(AXP152_LDO2_VOLTAGE, target);
+ return pmic_bus_write(AXP152_LDO2_VOLTAGE, target);
}
int axp_init(void)
u8 ver;
int rc;
- rc = axp152_read(AXP152_CHIP_VERSION, &ver);
+ rc = pmic_bus_init();
+ if (rc)
+ return rc;
+
+ rc = pmic_bus_read(AXP152_CHIP_VERSION, &ver);
if (rc)
return rc;
*/
#include <common.h>
-#include <i2c.h>
+#include <asm/arch/pmic_bus.h>
#include <axp_pmic.h>
-static int axp209_write(enum axp209_reg reg, u8 val)
-{
- return i2c_write(0x34, reg, 1, &val, 1);
-}
-
-static int axp209_read(enum axp209_reg reg, u8 *val)
-{
- return i2c_read(0x34, reg, 1, val, 1);
-}
-
static u8 axp209_mvolt_to_cfg(int mvolt, int min, int max, int div)
{
if (mvolt < min)
cfg = axp209_mvolt_to_cfg(mvolt, 700, 2275, 25);
/* Do we really need to be this gentle? It has built-in voltage slope */
- while ((rc = axp209_read(AXP209_DCDC2_VOLTAGE, ¤t)) == 0 &&
+ while ((rc = pmic_bus_read(AXP209_DCDC2_VOLTAGE, ¤t)) == 0 &&
current != cfg) {
if (current < cfg)
current++;
else
current--;
- rc = axp209_write(AXP209_DCDC2_VOLTAGE, current);
+ rc = pmic_bus_write(AXP209_DCDC2_VOLTAGE, current);
if (rc)
break;
}
{
u8 cfg = axp209_mvolt_to_cfg(mvolt, 700, 3500, 25);
- return axp209_write(AXP209_DCDC3_VOLTAGE, cfg);
+ return pmic_bus_write(AXP209_DCDC3_VOLTAGE, cfg);
}
int axp_set_aldo2(unsigned int mvolt)
cfg = axp209_mvolt_to_cfg(mvolt, 1800, 3300, 100);
- rc = axp209_read(AXP209_LDO24_VOLTAGE, ®);
+ rc = pmic_bus_read(AXP209_LDO24_VOLTAGE, ®);
if (rc)
return rc;
/* LDO2 configuration is in upper 4 bits */
reg = (reg & 0x0f) | (cfg << 4);
- return axp209_write(AXP209_LDO24_VOLTAGE, reg);
+ return pmic_bus_write(AXP209_LDO24_VOLTAGE, reg);
}
int axp_set_aldo3(unsigned int mvolt)
else
cfg = axp209_mvolt_to_cfg(mvolt, 700, 3500, 25);
- return axp209_write(AXP209_LDO3_VOLTAGE, cfg);
+ return pmic_bus_write(AXP209_LDO3_VOLTAGE, cfg);
}
int axp_set_aldo4(unsigned int mvolt)
/* Translate mvolt to register cfg value, requested <= selected */
for (cfg = 15; vindex[cfg] > mvolt && cfg > 0; cfg--);
- rc = axp209_read(AXP209_LDO24_VOLTAGE, ®);
+ rc = pmic_bus_read(AXP209_LDO24_VOLTAGE, ®);
if (rc)
return rc;
/* LDO4 configuration is in lower 4 bits */
reg = (reg & 0xf0) | (cfg << 0);
- return axp209_write(AXP209_LDO24_VOLTAGE, reg);
+ return pmic_bus_write(AXP209_LDO24_VOLTAGE, reg);
}
int axp_init(void)
u8 ver;
int i, rc;
- rc = axp209_read(AXP209_CHIP_VERSION, &ver);
+ rc = pmic_bus_init();
+ if (rc)
+ return rc;
+
+ rc = pmic_bus_read(AXP209_CHIP_VERSION, &ver);
if (rc)
return rc;
/* Mask all interrupts */
for (i = AXP209_IRQ_ENABLE1; i <= AXP209_IRQ_ENABLE5; i++) {
- rc = axp209_write(i, 0);
+ rc = pmic_bus_write(i, 0);
if (rc)
return rc;
}