sunxi: power: add AXP803 support
2017?1?6? 05:59? Maxime Ripard <[email protected]>???
Quoted 730 lines · Icenowy Zheng
Quoted 23 lines
The A64 uses the AXP803 as its PMIC.
Signed-off-by Icenowy Zheng <[email protected]>---
? arch/arm/mach-sunxi/Makefile?? |?? 3 + ? arch/arm/mach-sunxi/pmic_bus.c |?? 6 +- ? arch/arm/mach-sunxi/rsb.c????? |?? 2 +- ? board/sunxi/board.c??????????? |? 31 ++--- ? drivers/power/Kconfig????????? |? 87 ++++++++------ ? drivers/power/Makefile???????? |?? 1 + ? drivers/power/axp803.c???????? | 255 +++++++++++++++++++++++++++++++++++++++++ ? drivers/power/axp818.c???????? |?? 2 +- ? include/axp803.h?????????????? |? 73 ++++++++++++ ? include/axp_pmic.h???????????? |?? 3 +? 10 files changed, 413 insertions(+), 50 deletions(-) ? create mode 100644
drivers/power/axp803.c
? create mode 100644include/axp803.harch/arm/mach-sunxi/Makefile +0
-0@@ -19,9 +19,11 @@ endifQuoted 4 lines
? obj-$(CONFIG_MACH_SUN6I) += prcm.o
? obj-$(CONFIG_MACH_SUN8I) += prcm.o
? obj-$(CONFIG_MACH_SUN9I) += prcm.o
+obj-$(CONFIG_MACH_SUN50I) += prcm.oIntroducing a PRCM config option that would be selected by the various MACH_* seems like a better option.
Quoted 4 lines
? obj-$(CONFIG_MACH_SUN6I) += p2wi.o
? obj-$(CONFIG_MACH_SUN8I) += rsb.o
? obj-$(CONFIG_MACH_SUN9I) += rsb.o
+obj-$(CONFIG_MACH_SUN50I) += rsb.oDitto.
Quoted 19 lines
? obj-$(CONFIG_MACH_SUN4I) += clock_sun4i.o
? obj-$(CONFIG_MACH_SUN5I) += clock_sun4i.o
? obj-$(CONFIG_MACH_SUN6I) += clock_sun6i.oarch/arm/mach-sunxi/Makefile +0
-0@@ -37,6 +39,7 @@ obj-$(CONFIG_MACH_SUN9I) += clock_sun9i.o gtbus_sun9i.o? obj-$(CONFIG_AXP152_POWER) += pmic_bus.o
? obj-$(CONFIG_AXP209_POWER) += pmic_bus.o
? obj-$(CONFIG_AXP221_POWER) += pmic_bus.o
+obj-$(CONFIG_AXP803_POWER) += pmic_bus.o
? obj-$(CONFIG_AXP809_POWER) += pmic_bus.o
? obj-$(CONFIG_AXP818_POWER) += pmic_bus.o
?arch/arm/mach-sunxi/pmic_bus.c +0
-0@@ -36,7 +36,7 @@ int pmic_bus_init(void) ? if (!needs_init) ? return 0;?
arch/arm/mach-sunxi/pmic_bus.c
Quoted 2 lines
arch/arm/mach-sunxi/pmic_bus.c +1
-1-#if definedCONFIG_AXP221_POWER || definedCONFIG_AXP809_POWER || definedCONFIG_AXP818_POWER +#if definedCONFIG_AXP221_POWER || definedCONFIG_AXP803_POWER || definedCONFIG_AXP809_POWER || definedCONFIG_AXP818_POWER And you need to wrap your line here.
arch/arm/mach-sunxi/pmic_bus.c
Quoted 9 lines
? # ifdef
CONFIG_MACH_SUN6I
?p2wi_init();
? ret = p2wi_change_to_p2wi_mode(AXP221_CHIP_ADDR,AXP221_CTRL_ADDR,arch/arm/mach-sunxi/pmic_bus.c +0
-0@@ -62,7 +62,7 @@ int pmic_bus_read(u8 reg, u8 *data) ? return i2c_read(AXP152_I2C_ADDR, reg, 1, data, 1);? #elif defined
CONFIG_AXP209_POWER
? returni2c_read(AXP209_I2C_ADDR, reg, 1, data, 1);arch/arm/mach-sunxi/pmic_bus.c +1
-1-#elif definedCONFIG_AXP221_POWER || definedCONFIG_AXP809_POWER || definedCONFIG_AXP818_POWER +#elif definedCONFIG_AXP221_POWER || definedCONFIG_AXP803_POWER || definedCONFIG_AXP809_POWER || definedCONFIG_AXP818_POWER Ditto
arch/arm/mach-sunxi/pmic_bus.c
Quoted 9 lines
? # ifdef
CONFIG_MACH_SUN6I
? returnp2wi_read(reg, data);
? # elsearch/arm/mach-sunxi/pmic_bus.c +0
-0@@ -77,7 +77,7 @@ int pmic_bus_write(u8 reg, u8 data) ? return i2c_write(AXP152_I2C_ADDR, reg, 1, &data, 1);? #elif defined
CONFIG_AXP209_POWER
? returni2c_write(AXP209_I2C_ADDR, reg, 1, &data, 1);arch/arm/mach-sunxi/pmic_bus.c +1
-1-#elif definedCONFIG_AXP221_POWER || definedCONFIG_AXP809_POWER || definedCONFIG_AXP818_POWER +#elif definedCONFIG_AXP221_POWER || definedCONFIG_AXP803_POWER || definedCONFIG_AXP809_POWER || definedCONFIG_AXP818_POWER Ditto
Quoted 160 lines
? # ifdef
CONFIG_MACH_SUN6I
? returnp2wi_write(reg, data);
? # elsearch/arm/mach-sunxi/rsb.c +0
-0@@ -20,7 +20,7 @@ static int rsb_set_device_mode(void);?
? static voidrsb_cfg_io(void)
? {arch/arm/mach-sunxi/rsb.c +1
-1-#ifdef CONFIG_MACH_SUN8I +#if definedCONFIG_MACH_SUN8I || definedCONFIG_MACH_SUN50I ?
sunxi_gpio_set_cfgpin(SUNXI_GPL(0), SUN8I_GPL_R_RSB); ?sunxi_gpio_set_cfgpin(SUNXI_GPL(1), SUN8I_GPL_R_RSB); ?sunxi_gpio_set_pull(SUNXI_GPL(0), 1);board/sunxi/board.c +0
-0@@ -487,26 +487,27 @@ void sunxi_board_init(void)? #endif
?
? #if definedCONFIG_AXP152_POWER|| definedCONFIG_AXP209_POWER|| \
- definedCONFIG_AXP221_POWER|| definedCONFIG_AXP809_POWER|| \
- definedCONFIG_AXP818_POWER+ defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || \ + defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER?
power_failed=axp_init();
?board/sunxi/board.c +2
-2-#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \ - definedCONFIG_AXP818_POWER +#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || \ + definedCONFIG_AXP809_POWER || definedCONFIG_AXP818_POWER ?
power_failed|=axp_set_dcdc1(CONFIG_AXP_DCDC1_VOLT); ? #endif
?power_failed|=axp_set_dcdc2(CONFIG_AXP_DCDC2_VOLT); ?power_failed|=axp_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);board/sunxi/board.c +2
-1-#if !defined(CONFIG_AXP209_POWER ) && !defined(CONFIG_AXP818_POWER ) +#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP803_POWER) && \ + !defined(CONFIG_AXP818_POWER )?
power_failed|=axp_set_dcdc4(CONFIG_AXP_DCDC4_VOLT); ? #endifboard/sunxi/board.c +2
-2-#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \ - definedCONFIG_AXP818_POWER +#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || \ + definedCONFIG_AXP809_POWER || definedCONFIG_AXP818_POWER ?
power_failed|=axp_set_dcdc5(CONFIG_AXP_DCDC5_VOLT); ? #endif
?board/sunxi/board.c +2
-2-#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \ - definedCONFIG_AXP818_POWER +#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || \ + definedCONFIG_AXP809_POWER || definedCONFIG_AXP818_POWER ?
power_failed|=axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT); ? #endif
?power_failed|=axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);board/sunxi/board.c +0
-0@@ -517,8 +518,8 @@ void sunxi_board_init(void) ? power_failed |= axp_set_aldo4(CONFIG_AXP_ALDO4_VOLT);? #endif
?board/sunxi/board.c +2
-2-#if defined(CONFIG_AXP221_POWER) || defined(CONFIG_AXP809_POWER) || \ - defined(CONFIG_AXP818_POWER ) +#if defined(CONFIG_AXP221_POWER) || defined(CONFIG_AXP803_POWER) || \ + defined(CONFIG_AXP809_POWER ) || defined(CONFIG_AXP818_POWER )?
power_failed|=axp_set_dldo(1, CONFIG_AXP_DLDO1_VOLT); ?power_failed|=axp_set_dldo(2, CONFIG_AXP_DLDO2_VOLT); ? #if !definedCONFIG_AXP809_POWERboard/sunxi/board.c +0
-0@@ -530,13 +531,17 @@ void sunxi_board_init(void) ? power_failed |= axp_set_eldo(3, CONFIG_AXP_ELDO3_VOLT);? #endif
?board/sunxi/board.c +1
-1-#ifdef CONFIG_AXP818_POWER +#if definedCONFIG_AXP803_POWER || definedCONFIG_AXP818_POWER ?
power_failed|=axp_set_fldo(1, CONFIG_AXP_FLDO1_VOLT); ?power_failed|=axp_set_fldo(2, CONFIG_AXP_FLDO2_VOLT);board/sunxi/board.c +3
-0+#endif + +#ifdef CONFIG_AXP818_POWER ?
power_failed|=axp_set_fldo(3, CONFIG_AXP_FLDO3_VOLT); ? #endif
?board/sunxi/board.c +2
-1-#if definedCONFIG_AXP809_POWER || definedCONFIG_AXP818_POWER +#if defined CONFIG_AXP803_POWER || defined CONFIG_AXP809_POWER || \ + definedCONFIG_AXP818_POWER ?
power_failed|= axp_set_sw(IS_ENABLED(CONFIG_AXP_SW_ON)); ? #endif
? #endifdrivers/power/Kconfig +0
-0@@ -11,8 +11,9 @@ choice? depends on
ARCH_SUNXI? default AXP209_POWER if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I ? default AXP221_POWER if MACH_SUN6I || MACH_SUN8I_A23 || MACH_SUN8I_A33+ default
AXP803_POWERifMACH_SUN50I
? defaultAXP818_POWERifMACH_SUN8I_A83T
- defaultSUNXI_NO_PMICifMACH_SUN8I_H3||MACH_SUN50I
+ defaultSUNXI_NO_PMICifMACH_SUN8I_H3
?
? configSUNXI_NO_PMIC
? bool "board without a pmic"drivers/power/Kconfig +0
-0@@ -43,6 +44,13 @@ config AXP221_POWER? Select this to enable support for the axp221/axp223 pmic found on most ? A23 and A31 boards.
?
+configAXP803_POWER
+ bool "axp803 pmic support"
+ depends onMACH_SUN50I
+ selectCMD_POWEROFF
+ ---help---
+ Say y here to enable support for the axp803 pmic found on A64 boards. +
? configAXP809_POWER
? bool "axp809 pmic support"
? depends onMACH_SUN9Idrivers/power/Kconfig +0
-0@@ -69,25 +77,25 @@ endchoice?
? configAXP_DCDC1_VOLT
? int "axp pmic dcdc1 voltage"
- depends onAXP221_POWER||AXP809_POWER||AXP818_POWER
- default 3300 ifAXP818_POWER
+ depends onAXP221_POWER||AXP803_POWER||AXP809_POWER||AXP818_POWER
+ default 3300 ifAXP818_POWER||MACH_SUN50I
? default 3000 ifMACH_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 ? 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
- dcdc1 is used for VCC-IO, nand, usb0, sd , etc. On A80 dcdc1 normally
- powers some of the pingroups, NAND/eMMC, SD/MMC, and USB OTG.
+ save battery. On A31 devices dcdc1 is also used for VCC-IO. On A83T and
+ A64 dcdc1 is used for VCC-IO, nand, usb0, sd , etc. On A80 dcdc1
+ normally powers some of the pingroups, NAND/eMMC, SD/MMC, and USB OTG. ?
? configAXP_DCDC2_VOLT
? int "axp pmic dcdc2 voltage"- depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER + depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP803_POWER || AXP809_POWER || AXP818_POWER? default 900 if
AXP818_POWER
? default 1400 ifAXP152_POWER||AXP209_POWER
? default 1200 ifMACH_SUN6I
- default 1100 ifMACH_SUN8I
+ default 1100 ifMACH_SUN8I||MACH_SUN50I
? default 0 ifMACH_SUN9I
? ---help---
? Set the voltage (mV) to program the axp pmic dcdc2 at, set to 0 todrivers/power/Kconfig +0
-0@@ -97,15 +105,17 @@ config AXP_DCDC2_VOLT? On A23/A33 boards dcdc2 is used for VDD-SYS and should be 1.1V. ? On A80 boards dcdc2 powers the GPU and can be left off.
? On A83T boards dcdc2 is used for VDD-CPUA(cluster 0) and should be 0.9V.
+ On A64 boards dcdc2 is used with dcdc3 for VDD-CPU and should be 1.1V. ?
? configAXP_DCDC3_VOLT
? int "axp pmic dcdc3 voltage"- depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER + depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP803_POWER || AXP809_POWER || AXP818_POWERQuoted 7 lines
? default 900 if
AXP809_POWER||AXP818_POWER
? default 1500 ifAXP152_POWER
? default 1250 ifAXP209_POWER
? default 1200 ifMACH_SUN6I||MACH_SUN8I
- ---help---
+ default 1100 ifMACH_SUN50I
+---help---Why is that change needed?
Quoted 53 lines
? Set the voltage (mV) to program the axp pmic dcdc3 at, set to 0 to ? disable dcdc3.
? On A10(s) / A13 / A20 boards with an axp209 dcdc3 is VDD-INT-DLL anddrivers/power/Kconfig +0
-0@@ -114,39 +124,42 @@ config AXP_DCDC3_VOLT? On A23 / A31 / A33 boards dcdc3 is VDD-CPU and should be 1.2V. ? On A80 boards dcdc3 is used for VDD-CPUA(cluster 0) and should be 0.9V. ? On A83T boards dcdc3 is used for VDD-CPUB(cluster 1) and should be 0.9V.
+ On A64 boards dcdc3 is used with dcdc2 for VDD-CPU and should be 1.1V. ?
? configAXP_DCDC4_VOLT
? int "axp pmic dcdc4 voltage"- depends on AXP152_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER + depends on AXP152_POWER || AXP221_POWER || AXP803_POWER || AXP809_POWER || AXP818_POWER? default 1250 if
AXP152_POWER
? default 1200 ifMACH_SUN6I
? default 0 ifMACH_SUN8I
? default 900 ifMACH_SUN9I
+ default 0 ifMACH_SUN50I
? ---help---
? Set the voltage (mV) to program the axp pmic dcdc4 at, set to 0 to ? disable dcdc4.
? On A10s boards with an axp152 dcdc4 is VDD-INT-DLL and should be 1.25V. ? On A31 boards dcdc4 is used for VDD-SYS and should be 1.2V.
- On A23 / A33 boards dcdc4 is unused and should be disabled.
+ On A23 / A33 / A64 boards dcdc4 is unused and should be disabled. ? On A80 boards dcdc4 powers VDD-SYS, HDMI, USB OTG and should be 0.9V. ? On A83T boards dcdc4 is used for VDD-GPU.
?
? configAXP_DCDC5_VOLT
? int "axp pmic dcdc5 voltage"- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER - default 1500 if MACH_SUN6I || MACH_SUN8I || MACH_SUN9I + depends on AXP221_POWER || AXP803_POWER || AXP809_POWER || AXP818_POWER + default 1500 if MACH_SUN6I || MACH_SUN8I || MACH_SUN9I || MACH_SUN50I? ---help---
? Set the voltage (mV) to program the axp pmic dcdc5 at, set to 0 to ? disable dcdc5.
- On A23 / A31 / A33 / A80 / A83T boards dcdc5 is VCC-DRAM and
+ On A23 / A31 / A33 / A64 / A80 / A83T boards dcdc5 is VCC-DRAM and ? should be 1.5V, 1.35V if DDR3L is used.
?
? configAXP_ALDO1_VOLT
? int "axp pmic (a)ldo1 voltage"- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER + depends on AXP221_POWER || AXP803_POWER || AXP809_POWER || AXP818_POWER? default 0 if
MACH_SUN6I
? default 1800 ifMACH_SUN8I_A83T
? default 3000 ifMACH_SUN8I||MACH_SUN9I
+ default 2800 ifMACH_SUN50I
? ---help---
? Set the voltage (mV) to program the axp pmic aldo1 at, set to 0 to ? disable aldo1.drivers/power/Kconfig +0
-0@@ -155,14 +168,16 @@ config AXP_ALDO1_VOLTQuoted 4 lines
? On A80 boards aldo1 powers the USB hosts and should be 3.0V. ? On A83T / H8 boards aldo1 is used for MIPI CSI, DSI, HDMI, EFUSE, and ? should be 1.8V.
+ On A64 boards aldo1 powers PE pingroup and CSI and should be 2.8V.That depends on the usage of these pins, and there's no such requirements from the SoC, this is a board design choice.
Quoted 81 lines
?
? configAXP_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 || AXP803_POWER || AXP809_POWER || AXP818_POWER? default 3000 if
AXP152_POWER||AXP209_POWER
? default 0 ifMACH_SUN6I||MACH_SUN9I
? default 1800 ifMACH_SUN8I_A83T
? default 2500 ifMACH_SUN8I
+ default 1800 ifMACH_SUN50I
? ---help---
? Set the voltage (mV) to program the axp pmic aldo2 at, set to 0 to ? disable aldo2.drivers/power/Kconfig +0
-0@@ -173,17 +188,19 @@ config AXP_ALDO2_VOLT? On A80 boards aldo2 powers PB pingroup and camera IO and can be left off. ? On A83T / H8 boards aldo2 powers VDD-DLL, VCC18-PLL, CPVDD, VDD18-ADC, ? LPDDR2, and the codec. It should be 1.8V.
+ On A64 boards aldo2 powers PL pingroup and should be 1.8V.
?
? configAXP_ALDO3_VOLT
? int "axp pmic (a)ldo3 voltage"- depends on AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER + depends on AXP209_POWER || AXP221_POWER || AXP803_POWER || AXP809_POWER || AXP818_POWER ? default 0 if AXP209_POWER || MACH_SUN9I - default 3000 if MACH_SUN6I || MACH_SUN8I + default 3000 if MACH_SUN6I || MACH_SUN8I || MACH_SUN50I? ---help---
? Set the voltage (mV) to program the axp pmic aldo3 at, set to 0 to ? disable aldo3.
? On A10(s) / A13 / A20 boards aldo3 should be 2.8V.
- On A23 / A31 / A33 boards aldo3 is VCC-PLL and AVCC and should be 3.0V.
+ On A23 / A31 / A33 / A64 boards aldo3 is VCC-PLL and AVCC
+ and should be 3.0V.
? On A80 boards aldo3 is normally not used.
? On A83T / H8 boards aldo3 is AVCC, VCC-PL, and VCC-LED, and should be ? 3.0V.drivers/power/Kconfig +0
-0@@ -199,17 +216,19 @@ config AXP_ALDO4_VOLT?
? configAXP_DLDO1_VOLT
? int "axp pmic dldo1 voltage"- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER + depends on AXP221_POWER || AXP803_POWER || AXP809_POWER || AXP818_POWER+ default 3300 if
MACH_SUN50I
? default 0
? ---help---
? Set the voltage (mV) to program the axp pmic dldo1 at, set to 0 to ? disable dldo1. On sun6i (A31) boards with ethernet dldo1 is often used ? to power the ethernet phy. On A23, A33 and A80 boards this is often
- used to power the wifi.
+ used to power the wifi. On A64 boards this is often used to power the
+ HDMI.
?
? configAXP_DLDO2_VOLT
? int "axp pmic dldo2 voltage"- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER + depends on AXP221_POWER || AXP803_POWER || AXP809_POWER || AXP818_POWER? default 3000 if
MACH_SUN9I
? default 0
? ---help---drivers/power/Kconfig +0
-0@@ -219,7 +238,7 @@ config AXP_DLDO2_VOLT?
? configAXP_DLDO3_VOLT
? int "axp pmic dldo3 voltage"- depends on AXP221_POWER || AXP818_POWER + depends on AXP221_POWER || AXP803_POWER || AXP818_POWER? default 0
? ---help---
? Set the voltage (mV) to program the axp pmic dldo3 at, set to 0 todrivers/power/Kconfig +0
-0@@ -227,7 +246,7 @@ config AXP_DLDO3_VOLT?
? configAXP_DLDO4_VOLT
? int "axp pmic dldo4 voltage"- depends on AXP221_POWER || AXP818_POWER + depends on AXP221_POWER || AXP803_POWER || AXP818_POWER? default 0
? ---help---
? Set the voltage (mV) to program the axp pmic dldo4 at, set to 0 todrivers/power/Kconfig +0
-0@@ -235,15 +254,17 @@ config AXP_DLDO4_VOLT?
? configAXP_ELDO1_VOLT
? int "axp pmic eldo1 voltage"Quoted 8 lines
- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER + depends on AXP221_POWER || AXP803_POWER || AXP809_POWER || AXP818_POWER+ default 1800 if
MACH_SUN50I
? default 0
? ---help---
? Set the voltage (mV) to program the axp pmic eldo1 at, set to 0 to ? disable eldo1.
+ On A64 boards it's used for the codec and should be 1.8V.Again, there's no particular reason to make that comment.
Quoted 319 lines
?
? configAXP_ELDO2_VOLT
? int "axp pmic eldo2 voltage"- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER + depends on AXP221_POWER || AXP803_POWER || AXP809_POWER || AXP818_POWER? default 0
? ---help---
? Set the voltage (mV) to program the axp pmic eldo2 at, set to 0 todrivers/power/Kconfig +0
-0@@ -251,7 +272,7 @@ config AXP_ELDO2_VOLT?
? configAXP_ELDO3_VOLT
? int "axp pmic eldo3 voltage"- depends on AXP221_POWER || AXP809_POWER || AXP818_POWER + depends on AXP221_POWER || AXP803_POWER || AXP809_POWER || AXP818_POWER? default 3000 if
MACH_SUN9I
? default 0
? ---help---drivers/power/Kconfig +0
-0@@ -263,8 +284,8 @@ config AXP_ELDO3_VOLT?
? configAXP_FLDO1_VOLT
? int "axp pmic fldo1 voltage"
- depends onAXP818_POWER
- default 0 ifMACH_SUN8I_A83T
+ depends onAXP803_POWER||AXP818_POWER
+ default 0
? ---help---
? Set the voltage (mV) to program the axp pmic fldo1 at, set to 0 to ? disable fldo1.drivers/power/Kconfig +0
-0@@ -273,11 +294,13 @@ config AXP_FLDO1_VOLT?
? configAXP_FLDO2_VOLT
? int "axp pmic fldo2 voltage"
- depends onAXP818_POWER
+ depends onAXP803_POWER||AXP818_POWER
+ default 1100 ifMACH_SUN50I
? default 900 ifMACH_SUN8I_A83T
? ---help---
? Set the voltage (mV) to program the axp pmic fldo2 at, set to 0 to ? disable fldo2.
+ On A64 boards fldo2 is VCC-CPUS and should be 1.1V.
? On A83T / H8 boards fldo2 is VCC-CPUS and should be 0.9V. ?
? configAXP_FLDO3_VOLTdrivers/power/Kconfig +0
-0@@ -290,7 +313,7 @@ config AXP_FLDO3_VOLT?
? configAXP_SW_ON
? bool "axp pmic sw on"- depends on AXP809_POWER || AXP818_POWER + depends on AXP803_POWER || AXP809_POWER || AXP818_POWER? default n
? ---help---
? Enable to turn on axp pmic sw.drivers/power/Makefile +0
-0@@ -9,6 +9,7 @@ obj-$(CONFIG_AS3722_POWER) += as3722.o? obj-$(CONFIG_AXP152_POWER) += axp152.o
? obj-$(CONFIG_AXP209_POWER) += axp209.o
? obj-$(CONFIG_AXP221_POWER) += axp221.o
+obj-$(CONFIG_AXP803_POWER) += axp803.o
? obj-$(CONFIG_AXP809_POWER) += axp809.o
? obj-$(CONFIG_AXP818_POWER) += axp818.o
? obj-$(CONFIG_EXYNOS_TMU) += exynos-tmu.odrivers/power/axp803.c new file +249
-0@@ -0,0 +1,255 @@ +/* +* AXP803 driver based on AXP818 driver +* +* Based on axp818.c +* (C) Copyright 2015 Vishnu Patekar <[email protected]> +* +* Based on axp221.c +* (C) Copyright 2014 Hans de Goede <[email protected]> +* (C) Copyright 2013 Oliver Schinagl <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <errno.h> +#include <asm/arch/gpio.h> +#include <asm/arch/pmic_bus.h> +#include <axp_pmic.h> + +static u8 axp803_mvolt_to_cfg (int mvolt,int min,int max,int div) +{ +if (mvolt < min) + mvolt = min; +else if (mvolt > max) + mvolt = max; + + return? (mvolt - min) / div; +} + +int axp_set_dcdc1 (unsigned int mvolt) +{ +int ret; +u8 cfg =axp803_mvolt_to_cfg (mvolt,1600 ,3400 ,100 ); + +if (mvolt ==0 ) +return pmic_bus_clrbits (AXP803_OUTPUT_CTRL1 , +AXP803_OUTPUT_CTRL1_DCDC1_EN ); + + ret =pmic_bus_write (AXP803_DCDC1_CTRL , cfg); +if (ret) +return ret; + +return pmic_bus_setbits (AXP803_OUTPUT_CTRL1 , +AXP803_OUTPUT_CTRL1_DCDC1_EN ); +} + +int axp_set_dcdc2 (unsigned int mvolt) +{ +int ret; +u8 cfg; + +if (mvolt >=1220 ) + cfg =70 +axp803_mvolt_to_cfg (mvolt,1220 ,1300 ,20 ); +else + cfg =axp803_mvolt_to_cfg (mvolt,500 ,1200 ,10 ); + +if (mvolt ==0 ) +return pmic_bus_clrbits (AXP803_OUTPUT_CTRL1 , +AXP803_OUTPUT_CTRL1_DCDC2_EN ); + + ret =pmic_bus_write (AXP803_DCDC2_CTRL , cfg); +if (ret) +return ret; + +return pmic_bus_setbits (AXP803_OUTPUT_CTRL1 , +AXP803_OUTPUT_CTRL1_DCDC2_EN ); +} + +int axp_set_dcdc3 (unsigned int mvolt) +{ +int ret; +u8 cfg; + +if (mvolt >=1220 ) + cfg =70 +axp803_mvolt_to_cfg (mvolt,1220 ,1300 ,20 ); +else + cfg =axp803_mvolt_to_cfg (mvolt,500 ,1200 ,10 ); + +if (mvolt ==0 ) +return pmic_bus_clrbits (AXP803_OUTPUT_CTRL1 , +AXP803_OUTPUT_CTRL1_DCDC3_EN ); + + ret =pmic_bus_write (AXP803_DCDC3_CTRL , cfg); +if (ret) +return ret; + +return pmic_bus_setbits (AXP803_OUTPUT_CTRL1 , +AXP803_OUTPUT_CTRL1_DCDC3_EN ); +} + +int axp_set_dcdc5 (unsigned int mvolt) +{ +int ret; +u8 cfg; + +if (mvolt >=1140 ) + cfg =32 +axp803_mvolt_to_cfg (mvolt,1140 ,1840 ,20 ); +else + cfg =axp803_mvolt_to_cfg (mvolt,800 ,1120 ,10 ); + +if (mvolt ==0 ) +return pmic_bus_clrbits (AXP803_OUTPUT_CTRL1 , +AXP803_OUTPUT_CTRL1_DCDC5_EN ); + + ret =pmic_bus_write (AXP803_DCDC5_CTRL , cfg); +if (ret) +return ret; + +return pmic_bus_setbits (AXP803_OUTPUT_CTRL1 , +AXP803_OUTPUT_CTRL1_DCDC5_EN ); +} + +int axp_set_aldo (int aldo_num,unsigned int mvolt) +{ +int ret; +u8 cfg; + +if (aldo_num <1 || aldo_num >3 ) +return -EINVAL ; + +if (mvolt ==0 ) +return pmic_bus_clrbits (AXP803_OUTPUT_CTRL3 , +AXP803_OUTPUT_CTRL3_ALDO1_EN << (aldo_num -1 )); + + cfg =axp803_mvolt_to_cfg (mvolt,700 ,3300 ,100 ); + ret =pmic_bus_write (AXP803_ALDO1_CTRL + (aldo_num -1 ), cfg); +if (ret) +return ret; + +return pmic_bus_setbits (AXP803_OUTPUT_CTRL3 , +AXP803_OUTPUT_CTRL3_ALDO1_EN << (aldo_num -1 )); +} + +/* TODO: re-work other AXP drivers to consolidate ALDO functions. */ +int axp_set_aldo1 (unsigned int mvolt) +{ +return axp_set_aldo (1 , mvolt); +} + +int axp_set_aldo2 (unsigned int mvolt) +{ +return axp_set_aldo (2 , mvolt); +} + +int axp_set_aldo3 (unsigned int mvolt) +{ +return axp_set_aldo (3 , mvolt); +} + +int axp_set_dldo (int dldo_num,unsigned int mvolt) +{ +int ret; +u8 cfg; + +if (dldo_num <1 || dldo_num >4 ) +return -EINVAL ; + +if (mvolt ==0 ) +return pmic_bus_clrbits (AXP803_OUTPUT_CTRL2 , +AXP803_OUTPUT_CTRL2_DLDO1_EN << (dldo_num -1 )); + + cfg =axp803_mvolt_to_cfg (mvolt,700 ,3300 ,100 ); +if (dldo_num ==2 && mvolt >3300 ) + cfg +=1 +axp803_mvolt_to_cfg (mvolt,3400 ,4200 ,200 ); + ret =pmic_bus_write (AXP803_DLDO1_CTRL + (dldo_num -1 ), cfg); +if (ret) +return ret; + +return pmic_bus_setbits (AXP803_OUTPUT_CTRL2 , +AXP803_OUTPUT_CTRL2_DLDO1_EN << (dldo_num -1 )); +} + +int axp_set_eldo (int eldo_num,unsigned int mvolt) +{ +int ret; +u8 cfg; + +if (eldo_num <1 || eldo_num >3 ) +return -EINVAL ; + +if (mvolt ==0 ) +return pmic_bus_clrbits (AXP803_OUTPUT_CTRL2 , +AXP803_OUTPUT_CTRL2_ELDO1_EN << (eldo_num -1 )); + + cfg =axp803_mvolt_to_cfg (mvolt,700 ,1900 ,50 ); + ret =pmic_bus_write (AXP803_ELDO1_CTRL + (eldo_num -1 ), cfg); +if (ret) +return ret; + +return pmic_bus_setbits (AXP803_OUTPUT_CTRL2 , +AXP803_OUTPUT_CTRL2_ELDO1_EN << (eldo_num -1 )); +} + +int axp_set_fldo (int fldo_num,unsigned int mvolt) +{ +int ret; +u8 cfg; + +if (fldo_num <1 || fldo_num >2 ) +return -EINVAL ; + +if (mvolt ==0 ) +return pmic_bus_clrbits (AXP803_OUTPUT_CTRL3 , +AXP803_OUTPUT_CTRL3_FLDO1_EN << (fldo_num -1 )); + + cfg =axp803_mvolt_to_cfg (mvolt,700 ,1450 ,50 ); + ret =pmic_bus_write (AXP803_FLDO1_CTRL + (fldo_num -1 ), cfg); +if (ret) +return ret; + +return pmic_bus_setbits (AXP803_OUTPUT_CTRL3 , +AXP803_OUTPUT_CTRL3_FLDO1_EN << (fldo_num -1 )); +} + +int axp_set_sw (bool on) +{ +if (on) +return pmic_bus_setbits (AXP803_OUTPUT_CTRL2 , +AXP803_OUTPUT_CTRL2_SW_EN ); + +return pmic_bus_clrbits (AXP803_OUTPUT_CTRL2 , +AXP803_OUTPUT_CTRL2_SW_EN ); +} + +int axp_init (void ) +{ +u8 axp_chip_id; +int ret; + + ret =pmic_bus_init (); +if (ret) +return ret; + + ret =pmic_bus_read (AXP803_CHIP_ID , &axp_chip_id); +if (ret) +return ret; + +if (!(axp_chip_id ==0x51 )) +return -ENODEV ; +else +return ret; + +return 0 ; +} + +int do_poweroff (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +pmic_bus_write (AXP803_SHUTDOWN ,AXP803_SHUTDOWN_POWEROFF ); +
Quoted 8 lines
drivers/power/axp803.c line 255
Quoted 6 lines
drivers/power/axp803.c new file +6
-0+/* infinite loop during shutdown */ +while (1 ) {} + +/* not reached */ +return 0 ; +}Is there any difference with the AXP818 driver?
FLDO3 is missing.
Quoted 13 lines
drivers/power/axp818.c int axp_set_dldo(int dldo_num, unsigned int mvolt) · line 165
Quoted 11 lines
drivers/power/axp818.c +1
-1@@ -162,7 +162,7 @@ int axp_set_dldo(int dldo_num, unsigned int mvolt) ? cfg = axp818_mvolt_to_cfg(mvolt, 700, 3300, 100); ? if (dldo_num == 2 && mvolt > 3300) ? cfg += 1 + axp818_mvolt_to_cfg(mvolt, 3400, 4200, 200); - ret = pmic_bus_write(AXP818_ELDO1_CTRL + (dldo_num - 1), cfg); + ret = pmic_bus_write(AXP818_DLDO1_CTRL + (dldo_num - 1), cfg);Why is that change necesary?
Oops... It should be another bugfix...
Quoted 15 lines
Overall there is need to split this patch into several chunks, to enable the RSB, PRCM, to add the new driver, and then enable it.
Maxime
Signature · 8 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe at googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Quoted 260 lines · Icenowy Zheng
Quoted 251 lines
Quoted 251 lines
+++
b/drivers/power/axp803.c(quoted diff) +249
-0@@ -0,0 +1,255 @@ +/* + * AXP803 driver based on AXP818 driver + * + * Based on axp818.c + * (C) Copyright 2015 Vishnu Patekar <[email protected]> + * + * Based on axp221.c + * (C) Copyright 2014 Hans de Goede <[email protected]> + * (C) Copyright 2013 Oliver Schinagl <[email protected]> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <errno.h> +#include <asm/arch/gpio.h> +#include <asm/arch/pmic_bus.h> +#include <axp_pmic.h> + +static u8 axp803_mvolt_to_cfg(int mvolt, int min, int max, int div) +{ + if (mvolt < min) + mvolt = min; + else if (mvolt > max) + mvolt = max; + + return? (mvolt - min) / div; +} + +int axp_set_dcdc1(unsigned int mvolt) +{ + int ret; + u8 cfg = axp803_mvolt_to_cfg(mvolt, 1600, 3400, 100); + + if (mvolt == 0) + return pmic_bus_clrbits(AXP803_OUTPUT_CTRL1, + AXP803_OUTPUT_CTRL1_DCDC1_EN); + + ret = pmic_bus_write(AXP803_DCDC1_CTRL, cfg); + if (ret) + return ret; + + return pmic_bus_setbits(AXP803_OUTPUT_CTRL1, + AXP803_OUTPUT_CTRL1_DCDC1_EN); +} + +int axp_set_dcdc2(unsigned int mvolt) +{ + int ret; + u8 cfg; + + if (mvolt >= 1220) + cfg = 70 + axp803_mvolt_to_cfg(mvolt, 1220, 1300, 20); + else + cfg = axp803_mvolt_to_cfg(mvolt, 500, 1200, 10); + + if (mvolt == 0) + return pmic_bus_clrbits(AXP803_OUTPUT_CTRL1, + AXP803_OUTPUT_CTRL1_DCDC2_EN); + + ret = pmic_bus_write(AXP803_DCDC2_CTRL, cfg); + if (ret) + return ret; + + return pmic_bus_setbits(AXP803_OUTPUT_CTRL1, + AXP803_OUTPUT_CTRL1_DCDC2_EN); +} + +int axp_set_dcdc3(unsigned int mvolt) +{ + int ret; + u8 cfg; + + if (mvolt >= 1220) + cfg = 70 + axp803_mvolt_to_cfg(mvolt, 1220, 1300, 20); + else + cfg = axp803_mvolt_to_cfg(mvolt, 500, 1200, 10); + + if (mvolt == 0) + return pmic_bus_clrbits(AXP803_OUTPUT_CTRL1, + AXP803_OUTPUT_CTRL1_DCDC3_EN); + + ret = pmic_bus_write(AXP803_DCDC3_CTRL, cfg); + if (ret) + return ret; + + return pmic_bus_setbits(AXP803_OUTPUT_CTRL1, + AXP803_OUTPUT_CTRL1_DCDC3_EN); +} + +int axp_set_dcdc5(unsigned int mvolt) +{ + int ret; + u8 cfg; + + if (mvolt >= 1140) + cfg = 32 + axp803_mvolt_to_cfg(mvolt, 1140, 1840, 20); + else + cfg = axp803_mvolt_to_cfg(mvolt, 800, 1120, 10); + + if (mvolt == 0) + return pmic_bus_clrbits(AXP803_OUTPUT_CTRL1, + AXP803_OUTPUT_CTRL1_DCDC5_EN); + + ret = pmic_bus_write(AXP803_DCDC5_CTRL, cfg); + if (ret) + return ret; + + return pmic_bus_setbits(AXP803_OUTPUT_CTRL1, + AXP803_OUTPUT_CTRL1_DCDC5_EN); +} + +int axp_set_aldo(int aldo_num, unsigned int mvolt) +{ + int ret; + u8 cfg; + + if (aldo_num < 1 || aldo_num > 3) + return -EINVAL; + + if (mvolt == 0) + return pmic_bus_clrbits(AXP803_OUTPUT_CTRL3, + AXP803_OUTPUT_CTRL3_ALDO1_EN << (aldo_num - 1)); + + cfg = axp803_mvolt_to_cfg(mvolt, 700, 3300, 100); + ret = pmic_bus_write(AXP803_ALDO1_CTRL + (aldo_num - 1), cfg); + if (ret) + return ret; + + return pmic_bus_setbits(AXP803_OUTPUT_CTRL3, + AXP803_OUTPUT_CTRL3_ALDO1_EN << (aldo_num - 1)); +} + +/* TODO: re-work other AXP drivers to consolidate ALDO functions. */ +int axp_set_aldo1(unsigned int mvolt) +{ + return axp_set_aldo(1, mvolt); +} + +int axp_set_aldo2(unsigned int mvolt) +{ + return axp_set_aldo(2, mvolt); +} + +int axp_set_aldo3(unsigned int mvolt) +{ + return axp_set_aldo(3, mvolt); +} + +int axp_set_dldo(int dldo_num, unsigned int mvolt) +{ + int ret; + u8 cfg; + + if (dldo_num < 1 || dldo_num > 4) + return -EINVAL; + + if (mvolt == 0) + return pmic_bus_clrbits(AXP803_OUTPUT_CTRL2, + AXP803_OUTPUT_CTRL2_DLDO1_EN << (dldo_num - 1)); + + cfg = axp803_mvolt_to_cfg(mvolt, 700, 3300, 100); + if (dldo_num == 2 && mvolt > 3300) + cfg += 1 + axp803_mvolt_to_cfg(mvolt, 3400, 4200, 200); + ret = pmic_bus_write(AXP803_DLDO1_CTRL + (dldo_num - 1), cfg); + if (ret) + return ret; + + return pmic_bus_setbits(AXP803_OUTPUT_CTRL2, + AXP803_OUTPUT_CTRL2_DLDO1_EN << (dldo_num - 1)); +} + +int axp_set_eldo(int eldo_num, unsigned int mvolt) +{ + int ret; + u8 cfg; + + if (eldo_num < 1 || eldo_num > 3) + return -EINVAL; + + if (mvolt == 0) + return pmic_bus_clrbits(AXP803_OUTPUT_CTRL2, + AXP803_OUTPUT_CTRL2_ELDO1_EN << (eldo_num - 1)); + + cfg = axp803_mvolt_to_cfg(mvolt, 700, 1900, 50); + ret = pmic_bus_write(AXP803_ELDO1_CTRL + (eldo_num - 1), cfg); + if (ret) + return ret; + + return pmic_bus_setbits(AXP803_OUTPUT_CTRL2, + AXP803_OUTPUT_CTRL2_ELDO1_EN << (eldo_num - 1)); +} + +int axp_set_fldo(int fldo_num, unsigned int mvolt) +{ + int ret; + u8 cfg; + + if (fldo_num < 1 || fldo_num > 2) + return -EINVAL; + + if (mvolt == 0) + return pmic_bus_clrbits(AXP803_OUTPUT_CTRL3, + AXP803_OUTPUT_CTRL3_FLDO1_EN << (fldo_num - 1)); + + cfg = axp803_mvolt_to_cfg(mvolt, 700, 1450, 50); + ret = pmic_bus_write(AXP803_FLDO1_CTRL + (fldo_num - 1), cfg); + if (ret) + return ret; + + return pmic_bus_setbits(AXP803_OUTPUT_CTRL3, + AXP803_OUTPUT_CTRL3_FLDO1_EN << (fldo_num - 1)); +} + +int axp_set_sw(bool on) +{ + if (on) + return pmic_bus_setbits(AXP803_OUTPUT_CTRL2, + AXP803_OUTPUT_CTRL2_SW_EN); + + return pmic_bus_clrbits(AXP803_OUTPUT_CTRL2, + AXP803_OUTPUT_CTRL2_SW_EN); +} + +int axp_init(void) +{ + u8 axp_chip_id; + int ret; + + ret = pmic_bus_init(); + if (ret) + return ret; + + ret = pmic_bus_read(AXP803_CHIP_ID, &axp_chip_id); + if (ret) + return ret; + + if (!(axp_chip_id == 0x51)) + return -ENODEV; + else + return ret; + + return 0; +} + +int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + pmic_bus_write(AXP803_SHUTDOWN, AXP803_SHUTDOWN_POWEROFF); +Quoted 8 lines
Review line 255
Quoted 6 lines
(quoted diff) +6
-0+ /* infinite loop during shutdown */ + while (1) {} + + /* not reached */ + return 0; +}Is there any difference with the AXP818 driver?
Quoted 1 line
FLDO3 is missing.
If that's the only reason, then it's not really needed to duplicate the whole code... Simply put the FLDO3 handling code in a return, or add a test using a if (IS_ENABLED()) ...
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170109/96c63217/attachment.sig>