@@ -586,9 +586,10 @@ void sunxi_board_init(void)
defined CONFIG_AXP221_POWER || defined CONFIG_AXP305_POWER || \
defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER || \
defined CONFIG_AXP313_POWER || defined CONFIG_AXP717_POWER || \
- defined CONFIG_AXP803_POWER
+ defined CONFIG_AXP803_POWER || defined CONFIG_AXP318W_POWER
power_failed = axp_init();
+#ifdef AXP_POWER_STATUS
if (IS_ENABLED(CONFIG_AXP_DISABLE_BOOT_ON_POWERON) && !power_failed) {
u8 boot_reason;
@@ -598,6 +599,7 @@ void sunxi_board_init(void)
pmic_bus_write(0x32, BIT(7));
}
}
+#endif
#ifdef CONFIG_AXP_DCDC1_VOLT
power_failed |= axp_set_dcdc1(CONFIG_AXP_DCDC1_VOLT);
@@ -614,6 +616,12 @@ void sunxi_board_init(void)
#ifdef CONFIG_AXP_DCDC5_VOLT
power_failed |= axp_set_dcdc5(CONFIG_AXP_DCDC5_VOLT);
#endif
+#ifdef CONFIG_AXP_DCDC6_VOLT
+ power_failed |= axp_set_dcdc6(CONFIG_AXP_DCDC6_VOLT);
+#endif
+#ifdef CONFIG_AXP_DCDC7_VOLT
+ power_failed |= axp_set_dcdc7(CONFIG_AXP_DCDC7_VOLT);
+#endif
#ifdef CONFIG_AXP_ALDO1_VOLT
power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
@@ -628,6 +636,19 @@ void sunxi_board_init(void)
power_failed |= axp_set_aldo4(CONFIG_AXP_ALDO4_VOLT);
#endif
+#ifdef CONFIG_AXP_BLDO1_VOLT
+ power_failed |= axp_set_bldo(1, CONFIG_AXP_BLDO1_VOLT);
+#endif
+#ifdef CONFIG_AXP_BLDO2_VOLT
+ power_failed |= axp_set_bldo(2, CONFIG_AXP_BLDO2_VOLT);
+#endif
+#ifdef CONFIG_AXP_BLDO3_VOLT
+ power_failed |= axp_set_bldo(3, CONFIG_AXP_BLDO3_VOLT);
+#endif
+#ifdef CONFIG_AXP_BLDO4_VOLT
+ power_failed |= axp_set_bldo(4, CONFIG_AXP_BLDO4_VOLT);
+#endif
+
#ifdef CONFIG_AXP_DLDO1_VOLT
power_failed |= axp_set_dldo(1, CONFIG_AXP_DLDO1_VOLT);
power_failed |= axp_set_dldo(2, CONFIG_AXP_DLDO2_VOLT);
@@ -171,12 +171,15 @@ config AXP_I2C_ADDRESS
config AXP_DCDC1_VOLT
int "axp pmic dcdc1 voltage"
- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP803_POWER
+ depends on AXP221_POWER || AXP809_POWER || AXP818_POWER || \
+ AXP803_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 3300 if AXP818_POWER || MACH_SUN8I_R40 || AXP803_POWER
default 3000 if MACH_SUN6I || MACH_SUN8I || MACH_SUN9I
help
Set the voltage (mV) to program the axp pmic dcdc1 at, set to 0 to
- disable dcdc1. On A23 / A31 / A33 (axp221) boards dcdc1 is used for
+ disable dcdc1, or -1 on AXP318W to leave the OTP default untouched.
+ On A23 / A31 / A33 (axp221) boards dcdc1 is used for
generic 3.3V IO voltage for external devices like the lcd-panal and
sdcard interfaces, etc. On most boards dcdc1 is undervolted to 3.0V to
save battery. On A31 devices dcdc1 is also used for VCC-IO. On A83T
@@ -185,7 +188,10 @@ config AXP_DCDC1_VOLT
config AXP_DCDC2_VOLT
int "axp pmic dcdc2 voltage"
- depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP313_POWER || AXP717_POWER || AXP803_POWER
+ depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || \
+ AXP809_POWER || AXP818_POWER || AXP313_POWER || \
+ AXP717_POWER || AXP803_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 900 if AXP818_POWER
default 1400 if AXP152_POWER || AXP209_POWER
default 1000 if AXP313_POWER
@@ -207,7 +213,10 @@ config AXP_DCDC2_VOLT
config AXP_DCDC3_VOLT
int "axp pmic dcdc3 voltage"
- depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP313_POWER || AXP717_POWER
+ depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || \
+ AXP809_POWER || AXP818_POWER || AXP313_POWER || \
+ AXP717_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 900 if AXP809_POWER || AXP818_POWER
default 1500 if AXP152_POWER
default 1250 if AXP209_POWER
@@ -229,7 +238,9 @@ config AXP_DCDC3_VOLT
config AXP_DCDC4_VOLT
int "axp pmic dcdc4 voltage"
- depends on AXP152_POWER || AXP221_POWER || AXP809_POWER || AXP305_POWER
+ depends on AXP152_POWER || AXP221_POWER || AXP809_POWER || \
+ AXP305_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 1250 if AXP152_POWER
default 1200 if MACH_SUN6I
default 0 if MACH_SUN8I
@@ -247,7 +258,9 @@ config AXP_DCDC4_VOLT
config AXP_DCDC5_VOLT
int "axp pmic dcdc5 voltage"
- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP803_POWER
+ depends on AXP221_POWER || AXP809_POWER || AXP818_POWER || \
+ AXP803_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 1500 if MACH_SUN6I || MACH_SUN8I || MACH_SUN9I
help
Set the voltage (mV) to program the axp pmic dcdc5 at, set to 0 to
@@ -255,9 +268,28 @@ config AXP_DCDC5_VOLT
On A23 / A31 / A33 / A80 / A83T / R40 boards dcdc5 is VCC-DRAM and
should be 1.5V, 1.35V if DDR3L is used.
+config AXP_DCDC6_VOLT
+ int "axp pmic dcdc6 voltage"
+ depends on AXP318W_POWER
+ default -1
+ help
+ Set the voltage (mV) to program the axp pmic dcdc6 at, set to 0 to
+ disable dcdc6, or -1 to leave the OTP default untouched.
+ On the Orange Pi 4 Pro, dcdc6 supplies VDDQ-DRAM (0.5V-0.56V).
+
+config AXP_DCDC7_VOLT
+ int "axp pmic dcdc7 voltage"
+ depends on AXP318W_POWER
+ default -1
+ help
+ Set the voltage (mV) to program the axp pmic dcdc7 at, set to 0 to
+ disable dcdc7, or -1 to leave the OTP default untouched.
+ On the Orange Pi 4 Pro, dcdc7 supplies VDD2-DRAM (1.05V-1.08V).
+
config AXP_ALDO1_VOLT
int "axp pmic (a)ldo1 voltage"
- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER
+ depends on AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 0 if MACH_SUN6I || MACH_SUN8I_R40
default 1800 if MACH_SUN8I_A83T
default 3000 if MACH_SUN8I || MACH_SUN9I
@@ -272,7 +304,9 @@ config AXP_ALDO1_VOLT
config AXP_ALDO2_VOLT
int "axp pmic (a)ldo2 voltage"
- depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER
+ depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || \
+ AXP809_POWER || AXP818_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 3000 if AXP152_POWER || AXP209_POWER
default 0 if MACH_SUN6I || MACH_SUN9I
default 1800 if MACH_SUN8I_A83T
@@ -290,7 +324,9 @@ config AXP_ALDO2_VOLT
config AXP_ALDO3_VOLT
int "axp pmic (a)ldo3 voltage"
- depends on AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER
+ depends on AXP209_POWER || AXP221_POWER || AXP809_POWER || \
+ AXP818_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 0 if AXP209_POWER || MACH_SUN9I
default 3000 if MACH_SUN6I || MACH_SUN8I
help
@@ -347,16 +383,50 @@ config AXP_ALDO3_INRUSH_QUIRK
config AXP_ALDO4_VOLT
int "axp pmic (a)ldo4 voltage"
- depends on AXP209_POWER
+ depends on AXP209_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 0 if AXP209_POWER
help
Set the voltage (mV) to program the axp pmic aldo4 at, set to 0 to
disable aldo4.
On A10(s) / A13 / A20 boards aldo4 should be 2.8V.
+config AXP_BLDO1_VOLT
+ int "axp pmic bldo1 voltage"
+ depends on AXP318W_POWER
+ default -1
+ help
+ Set the voltage (mV) to program the axp pmic bldo1 at, set to 0 to
+ disable bldo1, or -1 to leave the OTP default untouched.
+
+config AXP_BLDO2_VOLT
+ int "axp pmic bldo2 voltage"
+ depends on AXP318W_POWER
+ default -1
+ help
+ Set the voltage (mV) to program the axp pmic bldo2 at, set to 0 to
+ disable bldo2, or -1 to leave the OTP default untouched.
+
+config AXP_BLDO3_VOLT
+ int "axp pmic bldo3 voltage"
+ depends on AXP318W_POWER
+ default -1
+ help
+ Set the voltage (mV) to program the axp pmic bldo3 at, set to 0 to
+ disable bldo3, or -1 to leave the OTP default untouched.
+
+config AXP_BLDO4_VOLT
+ int "axp pmic bldo4 voltage"
+ depends on AXP318W_POWER
+ default -1
+ help
+ Set the voltage (mV) to program the axp pmic bldo4 at, set to 0 to
+ disable bldo4, or -1 to leave the OTP default untouched.
+
config AXP_DLDO1_VOLT
int "axp pmic dldo1 voltage"
- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER
+ depends on AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 0
help
Set the voltage (mV) to program the axp pmic dldo1 at, set to 0 to
@@ -366,7 +436,8 @@ config AXP_DLDO1_VOLT
config AXP_DLDO2_VOLT
int "axp pmic dldo2 voltage"
- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER
+ depends on AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 3000 if MACH_SUN9I
default 0
help
@@ -376,7 +447,8 @@ config AXP_DLDO2_VOLT
config AXP_DLDO3_VOLT
int "axp pmic dldo3 voltage"
- depends on AXP221_POWER || AXP818_POWER
+ depends on AXP221_POWER || AXP818_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 0
help
Set the voltage (mV) to program the axp pmic dldo3 at, set to 0 to
@@ -384,7 +456,8 @@ config AXP_DLDO3_VOLT
config AXP_DLDO4_VOLT
int "axp pmic dldo4 voltage"
- depends on AXP221_POWER || AXP818_POWER
+ depends on AXP221_POWER || AXP818_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 0
help
Set the voltage (mV) to program the axp pmic dldo4 at, set to 0 to
@@ -392,7 +465,8 @@ config AXP_DLDO4_VOLT
config AXP_ELDO1_VOLT
int "axp pmic eldo1 voltage"
- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER
+ depends on AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 0
help
Set the voltage (mV) to program the axp pmic eldo1 at, set to 0 to
@@ -400,7 +474,8 @@ config AXP_ELDO1_VOLT
config AXP_ELDO2_VOLT
int "axp pmic eldo2 voltage"
- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER
+ depends on AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 0
help
Set the voltage (mV) to program the axp pmic eldo2 at, set to 0 to
@@ -408,7 +483,8 @@ config AXP_ELDO2_VOLT
config AXP_ELDO3_VOLT
int "axp pmic eldo3 voltage"
- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER
+ depends on AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP318W_POWER
+ default -1 if AXP318W_POWER
default 3000 if MACH_SUN9I
default 0
help
@@ -81,10 +81,45 @@ static const struct axp_reg_desc_spl axp_spl_dcdc_regulators[] = {
{ 0x11, BIT(0), 0x1a, 0x7f, 500, 1840, 10, 70 },
};
+static const struct axp_reg_desc_spl axp_spl_aldo_regulators[] = {
+ { 0x20, BIT(0), 0x24, 0x1f, 500, 3400, 100, NA },
+ { 0x20, BIT(1), 0x25, 0x1f, 500, 3400, 100, NA },
+ { 0x20, BIT(2), 0x26, 0x1f, 500, 3400, 100, NA },
+ { 0x20, BIT(3), 0x27, 0x1f, 500, 3400, 100, NA },
+ { 0x20, BIT(4), 0x28, 0x1f, 500, 3400, 100, NA },
+ { 0x20, BIT(5), 0x29, 0x1f, 500, 3400, 100, NA },
+};
+
+static const struct axp_reg_desc_spl axp_spl_bldo_regulators[] = {
+ { 0x20, BIT(6), 0x2a, 0x1f, 500, 3400, 100, NA },
+ { 0x20, BIT(7), 0x2b, 0x1f, 500, 3400, 100, NA },
+ { 0x21, BIT(0), 0x2c, 0x1f, 500, 3400, 100, NA },
+ { 0x21, BIT(1), 0x2d, 0x1f, 500, 3400, 100, NA },
+ { 0x21, BIT(2), 0x2e, 0x1f, 500, 3400, 100, NA },
+};
+
+static const struct axp_reg_desc_spl axp_spl_dldo_regulators[] = {
+ { 0x22, BIT(0), 0x34, 0x1f, 500, 3400, 100, NA },
+ { 0x22, BIT(1), 0x35, 0x1f, 500, 3400, 100, NA },
+ { 0x22, BIT(2), 0x36, 0x1f, 500, 3400, 100, NA },
+ { 0x22, BIT(3), 0x37, 0x1f, 500, 3400, 100, NA },
+ { 0x22, BIT(4), 0x38, 0x1f, 500, 3400, 100, NA },
+ { 0x22, BIT(5), 0x39, 0x1f, 500, 3400, 100, NA },
+};
+
+static const struct axp_reg_desc_spl axp_spl_eldo_regulators[] = {
+ { 0x22, BIT(6), 0x3a, 0x3f, 500, 1500, 25, NA },
+ { 0x22, BIT(7), 0x3b, 0x3f, 500, 1500, 25, NA },
+ { 0x23, BIT(0), 0x3c, 0x3f, 500, 1500, 25, NA },
+ { 0x23, BIT(1), 0x3d, 0x3f, 500, 1500, 25, NA },
+ { 0x23, BIT(2), 0x3e, 0x3f, 500, 1500, 25, NA },
+ { 0x23, BIT(3), 0x3f, 0x3f, 500, 1500, 25, NA },
+};
+
#define AXP_CHIP_VERSION 0
#define AXP_CHIP_VERSION_MASK 0
#define AXP_CHIP_ID 0
-#define AXP_SHUTDOWN_REG 0x55
+#define AXP_SHUTDOWN_REG AXP318_SHUTDOWN
#define AXP_SHUTDOWN_MASK BIT(7)
#elif defined(CONFIG_AXP305_POWER) /* AXP305 */
@@ -127,26 +162,38 @@ static u8 axp_mvolt_to_cfg(int mvolt, const struct axp_reg_desc_spl *reg)
return reg->split + mvolt / (reg->step_mV * 2);
}
-static int axp_set_dcdc(int dcdc_num, unsigned int mvolt)
+static int axp_set_reg(const struct axp_reg_desc_spl *reg, unsigned int mvolt)
{
- const struct axp_reg_desc_spl *reg;
+ u8 cfg, val;
int ret;
- if (dcdc_num < 1 || dcdc_num > ARRAY_SIZE(axp_spl_dcdc_regulators))
- return -EINVAL;
-
- reg = &axp_spl_dcdc_regulators[dcdc_num - 1];
+ if (mvolt == (unsigned int)-1)
+ return 0;
if (mvolt == 0)
return pmic_bus_clrbits(reg->enable_reg, reg->enable_mask);
- ret = pmic_bus_write(reg->volt_reg, axp_mvolt_to_cfg(mvolt, reg));
+ cfg = axp_mvolt_to_cfg(mvolt, reg);
+ ret = pmic_bus_read(reg->volt_reg, &val);
+ if (ret)
+ return ret;
+
+ val = (val & ~reg->volt_mask) | (cfg & reg->volt_mask);
+ ret = pmic_bus_write(reg->volt_reg, val);
if (ret)
return ret;
return pmic_bus_setbits(reg->enable_reg, reg->enable_mask);
}
+static int axp_set_dcdc(int dcdc_num, unsigned int mvolt)
+{
+ if (dcdc_num < 1 || dcdc_num > ARRAY_SIZE(axp_spl_dcdc_regulators))
+ return -EINVAL;
+
+ return axp_set_reg(&axp_spl_dcdc_regulators[dcdc_num - 1], mvolt);
+}
+
int axp_set_dcdc1(unsigned int mvolt)
{
return axp_set_dcdc(1, mvolt);
@@ -172,6 +219,62 @@ int axp_set_dcdc5(unsigned int mvolt)
return axp_set_dcdc(5, mvolt);
}
+#ifdef CONFIG_AXP318W_POWER
+int axp_set_dcdc6(unsigned int mvolt)
+{
+ return axp_set_dcdc(6, mvolt);
+}
+
+int axp_set_dcdc7(unsigned int mvolt)
+{
+ return axp_set_dcdc(7, mvolt);
+}
+
+int axp_set_aldo1(unsigned int mvolt)
+{
+ return axp_set_reg(&axp_spl_aldo_regulators[0], mvolt);
+}
+
+int axp_set_aldo2(unsigned int mvolt)
+{
+ return axp_set_reg(&axp_spl_aldo_regulators[1], mvolt);
+}
+
+int axp_set_aldo3(unsigned int mvolt)
+{
+ return axp_set_reg(&axp_spl_aldo_regulators[2], mvolt);
+}
+
+int axp_set_aldo4(unsigned int mvolt)
+{
+ return axp_set_reg(&axp_spl_aldo_regulators[3], mvolt);
+}
+
+int axp_set_bldo(int bldo_num, unsigned int mvolt)
+{
+ if (bldo_num < 1 || bldo_num > ARRAY_SIZE(axp_spl_bldo_regulators))
+ return -EINVAL;
+
+ return axp_set_reg(&axp_spl_bldo_regulators[bldo_num - 1], mvolt);
+}
+
+int axp_set_dldo(int dldo_num, unsigned int mvolt)
+{
+ if (dldo_num < 1 || dldo_num > ARRAY_SIZE(axp_spl_dldo_regulators))
+ return -EINVAL;
+
+ return axp_set_reg(&axp_spl_dldo_regulators[dldo_num - 1], mvolt);
+}
+
+int axp_set_eldo(int eldo_num, unsigned int mvolt)
+{
+ if (eldo_num < 1 || eldo_num > ARRAY_SIZE(axp_spl_eldo_regulators))
+ return -EINVAL;
+
+ return axp_set_reg(&axp_spl_eldo_regulators[eldo_num - 1], mvolt);
+}
+#endif
+
int axp_init(void)
{
int ret = pmic_bus_init();
@@ -49,10 +49,13 @@ int axp_set_dcdc2(unsigned int mvolt);
int axp_set_dcdc3(unsigned int mvolt);
int axp_set_dcdc4(unsigned int mvolt);
int axp_set_dcdc5(unsigned int mvolt);
+int axp_set_dcdc6(unsigned int mvolt);
+int axp_set_dcdc7(unsigned int mvolt);
int axp_set_aldo1(unsigned int mvolt);
int axp_set_aldo2(unsigned int mvolt);
int axp_set_aldo3(unsigned int mvolt);
int axp_set_aldo4(unsigned int mvolt);
+int axp_set_bldo(int bldo_num, unsigned int mvolt);
int axp_set_dldo(int dldo_num, unsigned int mvolt);
int axp_set_eldo(int eldo_num, unsigned int mvolt);
int axp_set_fldo(int fldo_num, unsigned int mvolt);