sunxi: power: add support for sy8106a driver
PATCH v2 1/1 sunxi: power: add support for sy8106a driver
SY8106A is a PMIC which is used on the Allwinner H3 Orange Pi Pc and Plus board. The VOUT1_SEL register is implemented to set the default V-CPU voltage to 1200 mV.
This driver is required to retain the SY8106A V-CPU voltage after a software reset. On cold boot the default SY8106A output voltage is selected by a pair of resistors and happens to be 1.2V on the Orange Pi PC and Plus.
---
Changes in v2
- Fixed typo in commit message thea => the.
- Made config R_I2C_ENABLE depend on SY8106A_POWER.
- Removed 'default n' from config R_I2C_ENABLE
- Changed SY8106A_POWER description from "most" to "some" boards.
- Added license/copyright to include/sy8106a.h and drivers/power/sy8106a.c.
--- board/sunxi/Kconfig | 5 ++++- board/sunxi/board.c | 5 +++++ configs/orangepi_pc_defconfig | 2 +- drivers/power/Kconfig | 16 ++++++++++++++++ drivers/power/Makefile | 1 + drivers/power/sy8106a.c | 29 +++++++++++++++++++++++++++++ include/configs/sunxi-common.h | 6 ++++-- include/sy8106a.h | 11 +++++++++++ 8 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 drivers/power/sy8106a.c create mode 100644 include/sy8106a.h
board/sunxi/Kconfig +4 -1
@@ -372,11 +372,14 @@ config I2C3_ENABLE See I2C0_ENABLE help text. endif +if SUNXI_GEN_SUN6I config R_I2C_ENABLE bool "Enable the PRCM I2C/TWI controller" - default n + # This is used for the pmic on H3 + default y if SY8106A_POWER ---help--- Set this to y to enable the I2C controller which is part of the PRCM. +endif if MACH_SUN7I config I2C4_ENABLE
board/sunxi/board.c +5 -0
@@ -25,6 +25,7 @@#include <asm/io.h> #include <nand.h> #include <net.h> +#include <sy8106a.h> #if definedCONFIG_VIDEO_LCD_PANEL_I2C && !(definedCONFIG_SPL_BUILD )/* So that we can use pin names in Kconfig and sunxi_name_to_gpio() */
@@ -436,6 +437,10 @@ void sunxi_board_init(void)int power_failed =0 ;unsigned long ramsize; +#ifdef CONFIG_SY8106A_POWER + power_failed =sy8106a_set_vout1 (CONFIG_SY8106A_VOUT1_VOLT ); +#endif +#if definedCONFIG_AXP152_POWER || definedCONFIG_AXP209_POWER || \ definedCONFIG_AXP221_POWER || definedCONFIG_AXP818_POWER power_failed =axp_init ();
configs/orangepi_pc_defconfig +1 -1
@@ -12,4 +12,4 @@ CONFIG_SPL=y # CONFIG_CMD_FLASH is not set # CONFIG_CMD_FPGA is not set CONFIG_CMD_GPIO=y -CONFIG_R_I2C_ENABLE=y +CONFIG_SY8106A_POWER=y
drivers/power/Kconfig +16 -0
@@ -48,6 +48,13 @@ config AXP818_POWER Say y here to enable support for the axp818 pmic found on A83T dev board. +config SY8106A_POWER + boolean "SY8106A pmic support" + depends on MACH_SUN8I_H3 + ---help--- + Select this to enable support for the SY8106A pmic found on some + H3 boards. + endchoice config AXP_DCDC1_VOLT
@@ -232,4 +239,13 @@ config AXP_ELDO3_VOLT 1.2V for the SSD2828 chip (converter of parallel LCD interface into MIPI DSI). +config SY8106A_VOUT1_VOLT + int "SY8106A pmic VOUT1 voltage" + depends on SY8106A_POWER + default 1200 + ---help--- + Set the voltage (mV) to program the SY8106A pmic VOUT1. This + is typically used to power the VDD-CPU and should be 1200mV. + Values can range from 680mV till 1950mV. + endmenu
drivers/power/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_AXP221_POWER) += axp221.o obj-$(CONFIG_AXP818_POWER) += axp818.o obj-$(CONFIG_EXYNOS_TMU) += exynos-tmu.o obj-$(CONFIG_FTPMU010_POWER) += ftpmu010.o +obj-$(CONFIG_SY8106A_POWER) += sy8106a.o obj-$(CONFIG_TPS6586X_POWER) += tps6586x.o obj-$(CONFIG_TWL4030_POWER) += twl4030.o obj-$(CONFIG_TWL6030_POWER) += twl6030.o
drivers/power/sy8106a.c new file +29 -0
@@ -0,0 +1,29 @@ +/* +* (C) Copyright 2016 +* Jelle van der Waa <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#include <common.h> +#include <i2c.h> +#include <sy8106a.h> + +#define SY8106A_I2C_ADDR 0x65 +#define SY8106A_VOUT1_SEL 1 +#define SY8106A_VOUT1_SEL_ENABLE (1 << 7) + +static u8 sy8106a_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 sy8106a_set_vout1 (unsigned int mvolt) +{ +u8 data =sy8106a_mvolt_to_cfg (mvolt,680 ,1950 ,10 ) |SY8106A_VOUT1_SEL_ENABLE ; +return i2c_write (SY8106A_I2C_ADDR ,SY8106A_VOUT1_SEL ,1 , &data,1 ); +}
include/configs/sunxi-common.h +4 -2
@@ -206,7 +206,8 @@#define CONFIG_SPL_STACK LOW_LEVEL_SRAM_STACK/* I2C */ -#if definedCONFIG_AXP152_POWER || definedCONFIG_AXP209_POWER +#if definedCONFIG_AXP152_POWER || definedCONFIG_AXP209_POWER || \ + definedCONFIG_SY8106A_POWER #define CONFIG_SPL_I2C_SUPPORT #endif
@@ -240,7 +241,8 @@ extern int soft_i2c_gpio_scl;/* PMU */ #if definedCONFIG_AXP152_POWER || definedCONFIG_AXP209_POWER || \ - definedCONFIG_AXP221_POWER || definedCONFIG_AXP818_POWER + definedCONFIG_AXP221_POWER || definedCONFIG_AXP818_POWER || \ + definedCONFIG_SY8106A_POWER #define CONFIG_SPL_POWER_SUPPORT #endif
include/sy8106a.h new file +11 -0
@@ -0,0 +1,11 @@ +/* +* (C) Copyright 2016 +* Jelle van der Waa <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#ifndef _SY8106A_PMIC_H_ + +int sy8106a_set_vout1 (unsigned int mvolt); + +#endif
Signature · 1 line
2.7.1
PATCH v2 1/1 sunxi: power: add support for sy8106a driver
Hi,
Quoted 14 lines · Jelle van der Waa
SY8106A is a PMIC which is used on the Allwinner H3 Orange Pi Pc and Plus board. The
VOUT1_SELregister is implemented to set the default V-CPU voltage to 1200 mV.This driver is required to retain the SY8106A V-CPU voltage after a software reset. On cold boot the default SY8106A output voltage is selected by a pair of resistors and happens to be 1.2V on the Orange Pi PC and Plus.
Signed-off-by Jelle van der Waa <[email protected]>Signed-off-by Hans de Goede <[email protected]>Tested-by Siarhei Siamashka <[email protected]>
Quoted 8 lines
---
Changes in v2
- Fixed typo in commit message thea => the.
- Made configR_I2C_ENABLEdepend onSY8106A_POWER.
- Removed 'default n' from configR_I2C_ENABLE
- ChangedSY8106A_POWERdescription from "most" to "some" boards.
- Added license/copyright toinclude/sy8106a.handdrivers/power/sy8106a.c.
Thanks, I've merged this (with a slightly improved commit msg) into my tree and it will be part of my next pull-req.
Regards,
Hans
Quoted 187 lines
--- board/sunxi/Kconfig | 5 ++++- board/sunxi/board.c | 5 +++++ configs/orangepi_pc_defconfig | 2 +- drivers/power/Kconfig | 16 ++++++++++++++++ drivers/power/Makefile | 1 + drivers/power/sy8106a.c | 29 +++++++++++++++++++++++++++++ include/configs/sunxi-common.h | 6 ++++-- include/sy8106a.h | 11 +++++++++++ 8 files changed, 71 insertions(+), 4 deletions(-)create mode 100644
drivers/power/sy8106a.c
create mode 100644include/sy8106a.hboard/sunxi/Kconfig +4
-1@@ -372,11 +372,14 @@ config I2C3_ENABLE See I2C0_ENABLE help text. endif +if SUNXI_GEN_SUN6I config R_I2C_ENABLE bool "Enable the PRCM I2C/TWI controller" - default n + # This is used for the pmic on H3 + default y if SY8106A_POWER ---help--- Set this to y to enable the I2C controller which is part of the PRCM. +endif if MACH_SUN7I config I2C4_ENABLEboard/sunxi/board.c +5
-0@@ -25,6 +25,7 @@#include <asm/io.h> #include <nand.h> #include <net.h> +#include <sy8106a.h> #if definedCONFIG_VIDEO_LCD_PANEL_I2C && !(definedCONFIG_SPL_BUILD )/* So that we can use pin names in Kconfig and sunxi_name_to_gpio() */ @@ -436,6 +437,10 @@ void sunxi_board_init(void)int power_failed =0 ;unsigned long ramsize; +#ifdef CONFIG_SY8106A_POWER + power_failed =sy8106a_set_vout1 (CONFIG_SY8106A_VOUT1_VOLT ); +#endif +#if definedCONFIG_AXP152_POWER || definedCONFIG_AXP209_POWER || \ definedCONFIG_AXP221_POWER || definedCONFIG_AXP818_POWER power_failed =axp_init ();configs/orangepi_pc_defconfig +1
-1@@ -12,4 +12,4 @@ CONFIG_SPL=y # CONFIG_CMD_FLASH is not set # CONFIG_CMD_FPGA is not set CONFIG_CMD_GPIO=y -CONFIG_R_I2C_ENABLE=y +CONFIG_SY8106A_POWER=ydrivers/power/Kconfig +16
-0@@ -48,6 +48,13 @@ config AXP818_POWER Say y here to enable support for the axp818 pmic found on A83T dev board. +config SY8106A_POWER + boolean "SY8106A pmic support" + depends on MACH_SUN8I_H3 + ---help--- + Select this to enable support for the SY8106A pmic found on some + H3 boards. + endchoice config AXP_DCDC1_VOLT@@ -232,4 +239,13 @@ config AXP_ELDO3_VOLT 1.2V for the SSD2828 chip (converter of parallel LCD interface into MIPI DSI). +config SY8106A_VOUT1_VOLT + int "SY8106A pmic VOUT1 voltage" + depends on SY8106A_POWER + default 1200 + ---help--- + Set the voltage (mV) to program the SY8106A pmic VOUT1. This + is typically used to power the VDD-CPU and should be 1200mV. + Values can range from 680mV till 1950mV. + endmenudrivers/power/Makefile +1
-0@@ -12,6 +12,7 @@ obj-$(CONFIG_AXP221_POWER) += axp221.o obj-$(CONFIG_AXP818_POWER) += axp818.o obj-$(CONFIG_EXYNOS_TMU) += exynos-tmu.o obj-$(CONFIG_FTPMU010_POWER) += ftpmu010.o +obj-$(CONFIG_SY8106A_POWER) += sy8106a.o obj-$(CONFIG_TPS6586X_POWER) += tps6586x.o obj-$(CONFIG_TWL4030_POWER) += twl4030.o obj-$(CONFIG_TWL6030_POWER) += twl6030.odrivers/power/sy8106a.c new file +29
-0@@ -0,0 +1,29 @@ +/* +* (C) Copyright 2016 +* Jelle van der Waa <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#include <common.h> +#include <i2c.h> +#include <sy8106a.h> + +#define SY8106A_I2C_ADDR 0x65 +#define SY8106A_VOUT1_SEL 1 +#define SY8106A_VOUT1_SEL_ENABLE (1 << 7) + +static u8 sy8106a_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 sy8106a_set_vout1 (unsigned int mvolt) +{ +u8 data =sy8106a_mvolt_to_cfg (mvolt,680 ,1950 ,10 ) |SY8106A_VOUT1_SEL_ENABLE ; +return i2c_write (SY8106A_I2C_ADDR ,SY8106A_VOUT1_SEL ,1 , &data,1 ); +}include/configs/sunxi-common.h +4
-2@@ -206,7 +206,8 @@#define CONFIG_SPL_STACK LOW_LEVEL_SRAM_STACK/* I2C */ -#if definedCONFIG_AXP152_POWER || definedCONFIG_AXP209_POWER +#if definedCONFIG_AXP152_POWER || definedCONFIG_AXP209_POWER || \ + definedCONFIG_SY8106A_POWER #define CONFIG_SPL_I2C_SUPPORT #endif @@ -240,7 +241,8 @@ extern int soft_i2c_gpio_scl;/* PMU */ #if definedCONFIG_AXP152_POWER || definedCONFIG_AXP209_POWER || \ - definedCONFIG_AXP221_POWER || definedCONFIG_AXP818_POWER + definedCONFIG_AXP221_POWER || definedCONFIG_AXP818_POWER || \ + definedCONFIG_SY8106A_POWER #define CONFIG_SPL_POWER_SUPPORT #endif include/sy8106a.h new file +11
-0@@ -0,0 +1,11 @@ +/* +* (C) Copyright 2016 +* Jelle van der Waa <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#ifndef _SY8106A_PMIC_H_ + +int sy8106a_set_vout1 (unsigned int mvolt); + +#endif