18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * AXP20x regulators driver. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2013 Carlo Caione <carlo@caione.org> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General 78c2ecf20Sopenharmony_ci * Public License. See the file "COPYING" in the main directory of this 88c2ecf20Sopenharmony_ci * archive for more details. 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, 118c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 128c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 138c2ecf20Sopenharmony_ci * GNU General Public License for more details. 148c2ecf20Sopenharmony_ci */ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <linux/bitops.h> 178c2ecf20Sopenharmony_ci#include <linux/delay.h> 188c2ecf20Sopenharmony_ci#include <linux/err.h> 198c2ecf20Sopenharmony_ci#include <linux/init.h> 208c2ecf20Sopenharmony_ci#include <linux/mfd/axp20x.h> 218c2ecf20Sopenharmony_ci#include <linux/module.h> 228c2ecf20Sopenharmony_ci#include <linux/of.h> 238c2ecf20Sopenharmony_ci#include <linux/of_device.h> 248c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 258c2ecf20Sopenharmony_ci#include <linux/regmap.h> 268c2ecf20Sopenharmony_ci#include <linux/regulator/driver.h> 278c2ecf20Sopenharmony_ci#include <linux/regulator/machine.h> 288c2ecf20Sopenharmony_ci#include <linux/regulator/of_regulator.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define AXP20X_GPIO0_FUNC_MASK GENMASK(3, 0) 318c2ecf20Sopenharmony_ci#define AXP20X_GPIO1_FUNC_MASK GENMASK(3, 0) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define AXP20X_IO_ENABLED 0x03 348c2ecf20Sopenharmony_ci#define AXP20X_IO_DISABLED 0x07 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define AXP20X_WORKMODE_DCDC2_MASK BIT_MASK(2) 378c2ecf20Sopenharmony_ci#define AXP20X_WORKMODE_DCDC3_MASK BIT_MASK(1) 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define AXP20X_FREQ_DCDC_MASK GENMASK(3, 0) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define AXP20X_VBUS_IPSOUT_MGMT_MASK BIT_MASK(2) 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define AXP20X_DCDC2_V_OUT_MASK GENMASK(5, 0) 448c2ecf20Sopenharmony_ci#define AXP20X_DCDC3_V_OUT_MASK GENMASK(7, 0) 458c2ecf20Sopenharmony_ci#define AXP20X_LDO2_V_OUT_MASK GENMASK(7, 4) 468c2ecf20Sopenharmony_ci#define AXP20X_LDO3_V_OUT_MASK GENMASK(6, 0) 478c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_MASK GENMASK(3, 0) 488c2ecf20Sopenharmony_ci#define AXP20X_LDO5_V_OUT_MASK GENMASK(7, 4) 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define AXP20X_PWR_OUT_EXTEN_MASK BIT_MASK(0) 518c2ecf20Sopenharmony_ci#define AXP20X_PWR_OUT_DCDC3_MASK BIT_MASK(1) 528c2ecf20Sopenharmony_ci#define AXP20X_PWR_OUT_LDO2_MASK BIT_MASK(2) 538c2ecf20Sopenharmony_ci#define AXP20X_PWR_OUT_LDO4_MASK BIT_MASK(3) 548c2ecf20Sopenharmony_ci#define AXP20X_PWR_OUT_DCDC2_MASK BIT_MASK(4) 558c2ecf20Sopenharmony_ci#define AXP20X_PWR_OUT_LDO3_MASK BIT_MASK(6) 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK BIT_MASK(0) 588c2ecf20Sopenharmony_ci#define AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE(x) \ 598c2ecf20Sopenharmony_ci ((x) << 0) 608c2ecf20Sopenharmony_ci#define AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK BIT_MASK(1) 618c2ecf20Sopenharmony_ci#define AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(x) \ 628c2ecf20Sopenharmony_ci ((x) << 1) 638c2ecf20Sopenharmony_ci#define AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK BIT_MASK(2) 648c2ecf20Sopenharmony_ci#define AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN BIT(2) 658c2ecf20Sopenharmony_ci#define AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK BIT_MASK(3) 668c2ecf20Sopenharmony_ci#define AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN BIT(3) 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_1250mV_START 0x0 698c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_1250mV_STEPS 0 708c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_1250mV_END \ 718c2ecf20Sopenharmony_ci (AXP20X_LDO4_V_OUT_1250mV_START + AXP20X_LDO4_V_OUT_1250mV_STEPS) 728c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_1300mV_START 0x1 738c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_1300mV_STEPS 7 748c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_1300mV_END \ 758c2ecf20Sopenharmony_ci (AXP20X_LDO4_V_OUT_1300mV_START + AXP20X_LDO4_V_OUT_1300mV_STEPS) 768c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_2500mV_START 0x9 778c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_2500mV_STEPS 0 788c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_2500mV_END \ 798c2ecf20Sopenharmony_ci (AXP20X_LDO4_V_OUT_2500mV_START + AXP20X_LDO4_V_OUT_2500mV_STEPS) 808c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_2700mV_START 0xa 818c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_2700mV_STEPS 1 828c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_2700mV_END \ 838c2ecf20Sopenharmony_ci (AXP20X_LDO4_V_OUT_2700mV_START + AXP20X_LDO4_V_OUT_2700mV_STEPS) 848c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_3000mV_START 0xc 858c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_3000mV_STEPS 3 868c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_3000mV_END \ 878c2ecf20Sopenharmony_ci (AXP20X_LDO4_V_OUT_3000mV_START + AXP20X_LDO4_V_OUT_3000mV_STEPS) 888c2ecf20Sopenharmony_ci#define AXP20X_LDO4_V_OUT_NUM_VOLTAGES 16 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define AXP22X_IO_ENABLED 0x03 918c2ecf20Sopenharmony_ci#define AXP22X_IO_DISABLED 0x04 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#define AXP22X_WORKMODE_DCDCX_MASK(x) BIT_MASK(x) 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define AXP22X_MISC_N_VBUSEN_FUNC BIT(4) 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#define AXP22X_DCDC1_V_OUT_MASK GENMASK(4, 0) 988c2ecf20Sopenharmony_ci#define AXP22X_DCDC2_V_OUT_MASK GENMASK(5, 0) 998c2ecf20Sopenharmony_ci#define AXP22X_DCDC3_V_OUT_MASK GENMASK(5, 0) 1008c2ecf20Sopenharmony_ci#define AXP22X_DCDC4_V_OUT_MASK GENMASK(5, 0) 1018c2ecf20Sopenharmony_ci#define AXP22X_DCDC5_V_OUT_MASK GENMASK(4, 0) 1028c2ecf20Sopenharmony_ci#define AXP22X_DC5LDO_V_OUT_MASK GENMASK(2, 0) 1038c2ecf20Sopenharmony_ci#define AXP22X_ALDO1_V_OUT_MASK GENMASK(4, 0) 1048c2ecf20Sopenharmony_ci#define AXP22X_ALDO2_V_OUT_MASK GENMASK(4, 0) 1058c2ecf20Sopenharmony_ci#define AXP22X_ALDO3_V_OUT_MASK GENMASK(4, 0) 1068c2ecf20Sopenharmony_ci#define AXP22X_DLDO1_V_OUT_MASK GENMASK(4, 0) 1078c2ecf20Sopenharmony_ci#define AXP22X_DLDO2_V_OUT_MASK GENMASK(4, 0) 1088c2ecf20Sopenharmony_ci#define AXP22X_DLDO3_V_OUT_MASK GENMASK(4, 0) 1098c2ecf20Sopenharmony_ci#define AXP22X_DLDO4_V_OUT_MASK GENMASK(4, 0) 1108c2ecf20Sopenharmony_ci#define AXP22X_ELDO1_V_OUT_MASK GENMASK(4, 0) 1118c2ecf20Sopenharmony_ci#define AXP22X_ELDO2_V_OUT_MASK GENMASK(4, 0) 1128c2ecf20Sopenharmony_ci#define AXP22X_ELDO3_V_OUT_MASK GENMASK(4, 0) 1138c2ecf20Sopenharmony_ci#define AXP22X_LDO_IO0_V_OUT_MASK GENMASK(4, 0) 1148c2ecf20Sopenharmony_ci#define AXP22X_LDO_IO1_V_OUT_MASK GENMASK(4, 0) 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_DC5LDO_MASK BIT_MASK(0) 1178c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_DCDC1_MASK BIT_MASK(1) 1188c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_DCDC2_MASK BIT_MASK(2) 1198c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_DCDC3_MASK BIT_MASK(3) 1208c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_DCDC4_MASK BIT_MASK(4) 1218c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_DCDC5_MASK BIT_MASK(5) 1228c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_ALDO1_MASK BIT_MASK(6) 1238c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_ALDO2_MASK BIT_MASK(7) 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_SW_MASK BIT_MASK(6) 1268c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_DC1SW_MASK BIT_MASK(7) 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_ELDO1_MASK BIT_MASK(0) 1298c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_ELDO2_MASK BIT_MASK(1) 1308c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_ELDO3_MASK BIT_MASK(2) 1318c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_DLDO1_MASK BIT_MASK(3) 1328c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_DLDO2_MASK BIT_MASK(4) 1338c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_DLDO3_MASK BIT_MASK(5) 1348c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_DLDO4_MASK BIT_MASK(6) 1358c2ecf20Sopenharmony_ci#define AXP22X_PWR_OUT_ALDO3_MASK BIT_MASK(7) 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci#define AXP803_PWR_OUT_DCDC1_MASK BIT_MASK(0) 1388c2ecf20Sopenharmony_ci#define AXP803_PWR_OUT_DCDC2_MASK BIT_MASK(1) 1398c2ecf20Sopenharmony_ci#define AXP803_PWR_OUT_DCDC3_MASK BIT_MASK(2) 1408c2ecf20Sopenharmony_ci#define AXP803_PWR_OUT_DCDC4_MASK BIT_MASK(3) 1418c2ecf20Sopenharmony_ci#define AXP803_PWR_OUT_DCDC5_MASK BIT_MASK(4) 1428c2ecf20Sopenharmony_ci#define AXP803_PWR_OUT_DCDC6_MASK BIT_MASK(5) 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci#define AXP803_PWR_OUT_FLDO1_MASK BIT_MASK(2) 1458c2ecf20Sopenharmony_ci#define AXP803_PWR_OUT_FLDO2_MASK BIT_MASK(3) 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci#define AXP803_DCDC1_V_OUT_MASK GENMASK(4, 0) 1488c2ecf20Sopenharmony_ci#define AXP803_DCDC2_V_OUT_MASK GENMASK(6, 0) 1498c2ecf20Sopenharmony_ci#define AXP803_DCDC3_V_OUT_MASK GENMASK(6, 0) 1508c2ecf20Sopenharmony_ci#define AXP803_DCDC4_V_OUT_MASK GENMASK(6, 0) 1518c2ecf20Sopenharmony_ci#define AXP803_DCDC5_V_OUT_MASK GENMASK(6, 0) 1528c2ecf20Sopenharmony_ci#define AXP803_DCDC6_V_OUT_MASK GENMASK(6, 0) 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci#define AXP803_FLDO1_V_OUT_MASK GENMASK(3, 0) 1558c2ecf20Sopenharmony_ci#define AXP803_FLDO2_V_OUT_MASK GENMASK(3, 0) 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci#define AXP803_DCDC23_POLYPHASE_DUAL BIT(6) 1588c2ecf20Sopenharmony_ci#define AXP803_DCDC56_POLYPHASE_DUAL BIT(5) 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci#define AXP803_DCDC234_500mV_START 0x00 1618c2ecf20Sopenharmony_ci#define AXP803_DCDC234_500mV_STEPS 70 1628c2ecf20Sopenharmony_ci#define AXP803_DCDC234_500mV_END \ 1638c2ecf20Sopenharmony_ci (AXP803_DCDC234_500mV_START + AXP803_DCDC234_500mV_STEPS) 1648c2ecf20Sopenharmony_ci#define AXP803_DCDC234_1220mV_START 0x47 1658c2ecf20Sopenharmony_ci#define AXP803_DCDC234_1220mV_STEPS 4 1668c2ecf20Sopenharmony_ci#define AXP803_DCDC234_1220mV_END \ 1678c2ecf20Sopenharmony_ci (AXP803_DCDC234_1220mV_START + AXP803_DCDC234_1220mV_STEPS) 1688c2ecf20Sopenharmony_ci#define AXP803_DCDC234_NUM_VOLTAGES 76 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci#define AXP803_DCDC5_800mV_START 0x00 1718c2ecf20Sopenharmony_ci#define AXP803_DCDC5_800mV_STEPS 32 1728c2ecf20Sopenharmony_ci#define AXP803_DCDC5_800mV_END \ 1738c2ecf20Sopenharmony_ci (AXP803_DCDC5_800mV_START + AXP803_DCDC5_800mV_STEPS) 1748c2ecf20Sopenharmony_ci#define AXP803_DCDC5_1140mV_START 0x21 1758c2ecf20Sopenharmony_ci#define AXP803_DCDC5_1140mV_STEPS 35 1768c2ecf20Sopenharmony_ci#define AXP803_DCDC5_1140mV_END \ 1778c2ecf20Sopenharmony_ci (AXP803_DCDC5_1140mV_START + AXP803_DCDC5_1140mV_STEPS) 1788c2ecf20Sopenharmony_ci#define AXP803_DCDC5_NUM_VOLTAGES 69 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci#define AXP803_DCDC6_600mV_START 0x00 1818c2ecf20Sopenharmony_ci#define AXP803_DCDC6_600mV_STEPS 50 1828c2ecf20Sopenharmony_ci#define AXP803_DCDC6_600mV_END \ 1838c2ecf20Sopenharmony_ci (AXP803_DCDC6_600mV_START + AXP803_DCDC6_600mV_STEPS) 1848c2ecf20Sopenharmony_ci#define AXP803_DCDC6_1120mV_START 0x33 1858c2ecf20Sopenharmony_ci#define AXP803_DCDC6_1120mV_STEPS 20 1868c2ecf20Sopenharmony_ci#define AXP803_DCDC6_1120mV_END \ 1878c2ecf20Sopenharmony_ci (AXP803_DCDC6_1120mV_START + AXP803_DCDC6_1120mV_STEPS) 1888c2ecf20Sopenharmony_ci#define AXP803_DCDC6_NUM_VOLTAGES 72 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci#define AXP803_DLDO2_700mV_START 0x00 1918c2ecf20Sopenharmony_ci#define AXP803_DLDO2_700mV_STEPS 26 1928c2ecf20Sopenharmony_ci#define AXP803_DLDO2_700mV_END \ 1938c2ecf20Sopenharmony_ci (AXP803_DLDO2_700mV_START + AXP803_DLDO2_700mV_STEPS) 1948c2ecf20Sopenharmony_ci#define AXP803_DLDO2_3400mV_START 0x1b 1958c2ecf20Sopenharmony_ci#define AXP803_DLDO2_3400mV_STEPS 4 1968c2ecf20Sopenharmony_ci#define AXP803_DLDO2_3400mV_END \ 1978c2ecf20Sopenharmony_ci (AXP803_DLDO2_3400mV_START + AXP803_DLDO2_3400mV_STEPS) 1988c2ecf20Sopenharmony_ci#define AXP803_DLDO2_NUM_VOLTAGES 32 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci#define AXP806_DCDCA_V_CTRL_MASK GENMASK(6, 0) 2018c2ecf20Sopenharmony_ci#define AXP806_DCDCB_V_CTRL_MASK GENMASK(4, 0) 2028c2ecf20Sopenharmony_ci#define AXP806_DCDCC_V_CTRL_MASK GENMASK(6, 0) 2038c2ecf20Sopenharmony_ci#define AXP806_DCDCD_V_CTRL_MASK GENMASK(5, 0) 2048c2ecf20Sopenharmony_ci#define AXP806_DCDCE_V_CTRL_MASK GENMASK(4, 0) 2058c2ecf20Sopenharmony_ci#define AXP806_ALDO1_V_CTRL_MASK GENMASK(4, 0) 2068c2ecf20Sopenharmony_ci#define AXP806_ALDO2_V_CTRL_MASK GENMASK(4, 0) 2078c2ecf20Sopenharmony_ci#define AXP806_ALDO3_V_CTRL_MASK GENMASK(4, 0) 2088c2ecf20Sopenharmony_ci#define AXP806_BLDO1_V_CTRL_MASK GENMASK(3, 0) 2098c2ecf20Sopenharmony_ci#define AXP806_BLDO2_V_CTRL_MASK GENMASK(3, 0) 2108c2ecf20Sopenharmony_ci#define AXP806_BLDO3_V_CTRL_MASK GENMASK(3, 0) 2118c2ecf20Sopenharmony_ci#define AXP806_BLDO4_V_CTRL_MASK GENMASK(3, 0) 2128c2ecf20Sopenharmony_ci#define AXP806_CLDO1_V_CTRL_MASK GENMASK(4, 0) 2138c2ecf20Sopenharmony_ci#define AXP806_CLDO2_V_CTRL_MASK GENMASK(4, 0) 2148c2ecf20Sopenharmony_ci#define AXP806_CLDO3_V_CTRL_MASK GENMASK(4, 0) 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_DCDCA_MASK BIT_MASK(0) 2178c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_DCDCB_MASK BIT_MASK(1) 2188c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_DCDCC_MASK BIT_MASK(2) 2198c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_DCDCD_MASK BIT_MASK(3) 2208c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_DCDCE_MASK BIT_MASK(4) 2218c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_ALDO1_MASK BIT_MASK(5) 2228c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_ALDO2_MASK BIT_MASK(6) 2238c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_ALDO3_MASK BIT_MASK(7) 2248c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_BLDO1_MASK BIT_MASK(0) 2258c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_BLDO2_MASK BIT_MASK(1) 2268c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_BLDO3_MASK BIT_MASK(2) 2278c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_BLDO4_MASK BIT_MASK(3) 2288c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_CLDO1_MASK BIT_MASK(4) 2298c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_CLDO2_MASK BIT_MASK(5) 2308c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_CLDO3_MASK BIT_MASK(6) 2318c2ecf20Sopenharmony_ci#define AXP806_PWR_OUT_SW_MASK BIT_MASK(7) 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci#define AXP806_DCDCAB_POLYPHASE_DUAL 0x40 2348c2ecf20Sopenharmony_ci#define AXP806_DCDCABC_POLYPHASE_TRI 0x80 2358c2ecf20Sopenharmony_ci#define AXP806_DCDCABC_POLYPHASE_MASK GENMASK(7, 6) 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci#define AXP806_DCDCDE_POLYPHASE_DUAL BIT(5) 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci#define AXP806_DCDCA_600mV_START 0x00 2408c2ecf20Sopenharmony_ci#define AXP806_DCDCA_600mV_STEPS 50 2418c2ecf20Sopenharmony_ci#define AXP806_DCDCA_600mV_END \ 2428c2ecf20Sopenharmony_ci (AXP806_DCDCA_600mV_START + AXP806_DCDCA_600mV_STEPS) 2438c2ecf20Sopenharmony_ci#define AXP806_DCDCA_1120mV_START 0x33 2448c2ecf20Sopenharmony_ci#define AXP806_DCDCA_1120mV_STEPS 20 2458c2ecf20Sopenharmony_ci#define AXP806_DCDCA_1120mV_END \ 2468c2ecf20Sopenharmony_ci (AXP806_DCDCA_1120mV_START + AXP806_DCDCA_1120mV_STEPS) 2478c2ecf20Sopenharmony_ci#define AXP806_DCDCA_NUM_VOLTAGES 72 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci#define AXP806_DCDCD_600mV_START 0x00 2508c2ecf20Sopenharmony_ci#define AXP806_DCDCD_600mV_STEPS 45 2518c2ecf20Sopenharmony_ci#define AXP806_DCDCD_600mV_END \ 2528c2ecf20Sopenharmony_ci (AXP806_DCDCD_600mV_START + AXP806_DCDCD_600mV_STEPS) 2538c2ecf20Sopenharmony_ci#define AXP806_DCDCD_1600mV_START 0x2e 2548c2ecf20Sopenharmony_ci#define AXP806_DCDCD_1600mV_STEPS 17 2558c2ecf20Sopenharmony_ci#define AXP806_DCDCD_1600mV_END \ 2568c2ecf20Sopenharmony_ci (AXP806_DCDCD_1600mV_START + AXP806_DCDCD_1600mV_STEPS) 2578c2ecf20Sopenharmony_ci#define AXP806_DCDCD_NUM_VOLTAGES 64 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci#define AXP809_DCDC4_600mV_START 0x00 2608c2ecf20Sopenharmony_ci#define AXP809_DCDC4_600mV_STEPS 47 2618c2ecf20Sopenharmony_ci#define AXP809_DCDC4_600mV_END \ 2628c2ecf20Sopenharmony_ci (AXP809_DCDC4_600mV_START + AXP809_DCDC4_600mV_STEPS) 2638c2ecf20Sopenharmony_ci#define AXP809_DCDC4_1800mV_START 0x30 2648c2ecf20Sopenharmony_ci#define AXP809_DCDC4_1800mV_STEPS 8 2658c2ecf20Sopenharmony_ci#define AXP809_DCDC4_1800mV_END \ 2668c2ecf20Sopenharmony_ci (AXP809_DCDC4_1800mV_START + AXP809_DCDC4_1800mV_STEPS) 2678c2ecf20Sopenharmony_ci#define AXP809_DCDC4_NUM_VOLTAGES 57 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci#define AXP813_DCDC7_V_OUT_MASK GENMASK(6, 0) 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci#define AXP813_PWR_OUT_DCDC7_MASK BIT_MASK(6) 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci#define AXP_DESC_IO(_family, _id, _match, _supply, _min, _max, _step, _vreg, \ 2748c2ecf20Sopenharmony_ci _vmask, _ereg, _emask, _enable_val, _disable_val) \ 2758c2ecf20Sopenharmony_ci [_family##_##_id] = { \ 2768c2ecf20Sopenharmony_ci .name = (_match), \ 2778c2ecf20Sopenharmony_ci .supply_name = (_supply), \ 2788c2ecf20Sopenharmony_ci .of_match = of_match_ptr(_match), \ 2798c2ecf20Sopenharmony_ci .regulators_node = of_match_ptr("regulators"), \ 2808c2ecf20Sopenharmony_ci .type = REGULATOR_VOLTAGE, \ 2818c2ecf20Sopenharmony_ci .id = _family##_##_id, \ 2828c2ecf20Sopenharmony_ci .n_voltages = (((_max) - (_min)) / (_step) + 1), \ 2838c2ecf20Sopenharmony_ci .owner = THIS_MODULE, \ 2848c2ecf20Sopenharmony_ci .min_uV = (_min) * 1000, \ 2858c2ecf20Sopenharmony_ci .uV_step = (_step) * 1000, \ 2868c2ecf20Sopenharmony_ci .vsel_reg = (_vreg), \ 2878c2ecf20Sopenharmony_ci .vsel_mask = (_vmask), \ 2888c2ecf20Sopenharmony_ci .enable_reg = (_ereg), \ 2898c2ecf20Sopenharmony_ci .enable_mask = (_emask), \ 2908c2ecf20Sopenharmony_ci .enable_val = (_enable_val), \ 2918c2ecf20Sopenharmony_ci .disable_val = (_disable_val), \ 2928c2ecf20Sopenharmony_ci .ops = &axp20x_ops, \ 2938c2ecf20Sopenharmony_ci } 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci#define AXP_DESC(_family, _id, _match, _supply, _min, _max, _step, _vreg, \ 2968c2ecf20Sopenharmony_ci _vmask, _ereg, _emask) \ 2978c2ecf20Sopenharmony_ci [_family##_##_id] = { \ 2988c2ecf20Sopenharmony_ci .name = (_match), \ 2998c2ecf20Sopenharmony_ci .supply_name = (_supply), \ 3008c2ecf20Sopenharmony_ci .of_match = of_match_ptr(_match), \ 3018c2ecf20Sopenharmony_ci .regulators_node = of_match_ptr("regulators"), \ 3028c2ecf20Sopenharmony_ci .type = REGULATOR_VOLTAGE, \ 3038c2ecf20Sopenharmony_ci .id = _family##_##_id, \ 3048c2ecf20Sopenharmony_ci .n_voltages = (((_max) - (_min)) / (_step) + 1), \ 3058c2ecf20Sopenharmony_ci .owner = THIS_MODULE, \ 3068c2ecf20Sopenharmony_ci .min_uV = (_min) * 1000, \ 3078c2ecf20Sopenharmony_ci .uV_step = (_step) * 1000, \ 3088c2ecf20Sopenharmony_ci .vsel_reg = (_vreg), \ 3098c2ecf20Sopenharmony_ci .vsel_mask = (_vmask), \ 3108c2ecf20Sopenharmony_ci .enable_reg = (_ereg), \ 3118c2ecf20Sopenharmony_ci .enable_mask = (_emask), \ 3128c2ecf20Sopenharmony_ci .ops = &axp20x_ops, \ 3138c2ecf20Sopenharmony_ci } 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci#define AXP_DESC_SW(_family, _id, _match, _supply, _ereg, _emask) \ 3168c2ecf20Sopenharmony_ci [_family##_##_id] = { \ 3178c2ecf20Sopenharmony_ci .name = (_match), \ 3188c2ecf20Sopenharmony_ci .supply_name = (_supply), \ 3198c2ecf20Sopenharmony_ci .of_match = of_match_ptr(_match), \ 3208c2ecf20Sopenharmony_ci .regulators_node = of_match_ptr("regulators"), \ 3218c2ecf20Sopenharmony_ci .type = REGULATOR_VOLTAGE, \ 3228c2ecf20Sopenharmony_ci .id = _family##_##_id, \ 3238c2ecf20Sopenharmony_ci .owner = THIS_MODULE, \ 3248c2ecf20Sopenharmony_ci .enable_reg = (_ereg), \ 3258c2ecf20Sopenharmony_ci .enable_mask = (_emask), \ 3268c2ecf20Sopenharmony_ci .ops = &axp20x_ops_sw, \ 3278c2ecf20Sopenharmony_ci } 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci#define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt) \ 3308c2ecf20Sopenharmony_ci [_family##_##_id] = { \ 3318c2ecf20Sopenharmony_ci .name = (_match), \ 3328c2ecf20Sopenharmony_ci .supply_name = (_supply), \ 3338c2ecf20Sopenharmony_ci .of_match = of_match_ptr(_match), \ 3348c2ecf20Sopenharmony_ci .regulators_node = of_match_ptr("regulators"), \ 3358c2ecf20Sopenharmony_ci .type = REGULATOR_VOLTAGE, \ 3368c2ecf20Sopenharmony_ci .id = _family##_##_id, \ 3378c2ecf20Sopenharmony_ci .n_voltages = 1, \ 3388c2ecf20Sopenharmony_ci .owner = THIS_MODULE, \ 3398c2ecf20Sopenharmony_ci .min_uV = (_volt) * 1000, \ 3408c2ecf20Sopenharmony_ci .ops = &axp20x_ops_fixed \ 3418c2ecf20Sopenharmony_ci } 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci#define AXP_DESC_RANGES(_family, _id, _match, _supply, _ranges, _n_voltages, \ 3448c2ecf20Sopenharmony_ci _vreg, _vmask, _ereg, _emask) \ 3458c2ecf20Sopenharmony_ci [_family##_##_id] = { \ 3468c2ecf20Sopenharmony_ci .name = (_match), \ 3478c2ecf20Sopenharmony_ci .supply_name = (_supply), \ 3488c2ecf20Sopenharmony_ci .of_match = of_match_ptr(_match), \ 3498c2ecf20Sopenharmony_ci .regulators_node = of_match_ptr("regulators"), \ 3508c2ecf20Sopenharmony_ci .type = REGULATOR_VOLTAGE, \ 3518c2ecf20Sopenharmony_ci .id = _family##_##_id, \ 3528c2ecf20Sopenharmony_ci .n_voltages = (_n_voltages), \ 3538c2ecf20Sopenharmony_ci .owner = THIS_MODULE, \ 3548c2ecf20Sopenharmony_ci .vsel_reg = (_vreg), \ 3558c2ecf20Sopenharmony_ci .vsel_mask = (_vmask), \ 3568c2ecf20Sopenharmony_ci .enable_reg = (_ereg), \ 3578c2ecf20Sopenharmony_ci .enable_mask = (_emask), \ 3588c2ecf20Sopenharmony_ci .linear_ranges = (_ranges), \ 3598c2ecf20Sopenharmony_ci .n_linear_ranges = ARRAY_SIZE(_ranges), \ 3608c2ecf20Sopenharmony_ci .ops = &axp20x_ops_range, \ 3618c2ecf20Sopenharmony_ci } 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_cistatic const int axp209_dcdc2_ldo3_slew_rates[] = { 3648c2ecf20Sopenharmony_ci 1600, 3658c2ecf20Sopenharmony_ci 800, 3668c2ecf20Sopenharmony_ci}; 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_cistatic int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) 3698c2ecf20Sopenharmony_ci{ 3708c2ecf20Sopenharmony_ci struct axp20x_dev *axp20x = rdev_get_drvdata(rdev); 3718c2ecf20Sopenharmony_ci int id = rdev_get_id(rdev); 3728c2ecf20Sopenharmony_ci u8 reg, mask, enable, cfg = 0xff; 3738c2ecf20Sopenharmony_ci const int *slew_rates; 3748c2ecf20Sopenharmony_ci int rate_count = 0; 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci switch (axp20x->variant) { 3778c2ecf20Sopenharmony_ci case AXP209_ID: 3788c2ecf20Sopenharmony_ci if (id == AXP20X_DCDC2) { 3798c2ecf20Sopenharmony_ci slew_rates = axp209_dcdc2_ldo3_slew_rates; 3808c2ecf20Sopenharmony_ci rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates); 3818c2ecf20Sopenharmony_ci reg = AXP20X_DCDC2_LDO3_V_RAMP; 3828c2ecf20Sopenharmony_ci mask = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK | 3838c2ecf20Sopenharmony_ci AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK; 3848c2ecf20Sopenharmony_ci enable = (ramp > 0) ? 3858c2ecf20Sopenharmony_ci AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN : 0; 3868c2ecf20Sopenharmony_ci break; 3878c2ecf20Sopenharmony_ci } 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci if (id == AXP20X_LDO3) { 3908c2ecf20Sopenharmony_ci slew_rates = axp209_dcdc2_ldo3_slew_rates; 3918c2ecf20Sopenharmony_ci rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates); 3928c2ecf20Sopenharmony_ci reg = AXP20X_DCDC2_LDO3_V_RAMP; 3938c2ecf20Sopenharmony_ci mask = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK | 3948c2ecf20Sopenharmony_ci AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK; 3958c2ecf20Sopenharmony_ci enable = (ramp > 0) ? 3968c2ecf20Sopenharmony_ci AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN : 0; 3978c2ecf20Sopenharmony_ci break; 3988c2ecf20Sopenharmony_ci } 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci if (rate_count > 0) 4018c2ecf20Sopenharmony_ci break; 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_ci fallthrough; 4048c2ecf20Sopenharmony_ci default: 4058c2ecf20Sopenharmony_ci /* Not supported for this regulator */ 4068c2ecf20Sopenharmony_ci return -ENOTSUPP; 4078c2ecf20Sopenharmony_ci } 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_ci if (ramp == 0) { 4108c2ecf20Sopenharmony_ci cfg = enable; 4118c2ecf20Sopenharmony_ci } else { 4128c2ecf20Sopenharmony_ci int i; 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci for (i = 0; i < rate_count; i++) { 4158c2ecf20Sopenharmony_ci if (ramp > slew_rates[i]) 4168c2ecf20Sopenharmony_ci break; 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci if (id == AXP20X_DCDC2) 4198c2ecf20Sopenharmony_ci cfg = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE(i); 4208c2ecf20Sopenharmony_ci else 4218c2ecf20Sopenharmony_ci cfg = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(i); 4228c2ecf20Sopenharmony_ci } 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_ci if (cfg == 0xff) { 4258c2ecf20Sopenharmony_ci dev_err(axp20x->dev, "unsupported ramp value %d", ramp); 4268c2ecf20Sopenharmony_ci return -EINVAL; 4278c2ecf20Sopenharmony_ci } 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ci cfg |= enable; 4308c2ecf20Sopenharmony_ci } 4318c2ecf20Sopenharmony_ci 4328c2ecf20Sopenharmony_ci return regmap_update_bits(axp20x->regmap, reg, mask, cfg); 4338c2ecf20Sopenharmony_ci} 4348c2ecf20Sopenharmony_ci 4358c2ecf20Sopenharmony_cistatic int axp20x_regulator_enable_regmap(struct regulator_dev *rdev) 4368c2ecf20Sopenharmony_ci{ 4378c2ecf20Sopenharmony_ci struct axp20x_dev *axp20x = rdev_get_drvdata(rdev); 4388c2ecf20Sopenharmony_ci int id = rdev_get_id(rdev); 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci switch (axp20x->variant) { 4418c2ecf20Sopenharmony_ci case AXP209_ID: 4428c2ecf20Sopenharmony_ci if ((id == AXP20X_LDO3) && 4438c2ecf20Sopenharmony_ci rdev->constraints && rdev->constraints->soft_start) { 4448c2ecf20Sopenharmony_ci int v_out; 4458c2ecf20Sopenharmony_ci int ret; 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci /* 4488c2ecf20Sopenharmony_ci * On some boards, the LDO3 can be overloaded when 4498c2ecf20Sopenharmony_ci * turning on, causing the entire PMIC to shutdown 4508c2ecf20Sopenharmony_ci * without warning. Turning it on at the minimal voltage 4518c2ecf20Sopenharmony_ci * and then setting the voltage to the requested value 4528c2ecf20Sopenharmony_ci * works reliably. 4538c2ecf20Sopenharmony_ci */ 4548c2ecf20Sopenharmony_ci if (regulator_is_enabled_regmap(rdev)) 4558c2ecf20Sopenharmony_ci break; 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci v_out = regulator_get_voltage_sel_regmap(rdev); 4588c2ecf20Sopenharmony_ci if (v_out < 0) 4598c2ecf20Sopenharmony_ci return v_out; 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_ci if (v_out == 0) 4628c2ecf20Sopenharmony_ci break; 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci ret = regulator_set_voltage_sel_regmap(rdev, 0x00); 4658c2ecf20Sopenharmony_ci /* 4668c2ecf20Sopenharmony_ci * A small pause is needed between 4678c2ecf20Sopenharmony_ci * setting the voltage and enabling the LDO to give the 4688c2ecf20Sopenharmony_ci * internal state machine time to process the request. 4698c2ecf20Sopenharmony_ci */ 4708c2ecf20Sopenharmony_ci usleep_range(1000, 5000); 4718c2ecf20Sopenharmony_ci ret |= regulator_enable_regmap(rdev); 4728c2ecf20Sopenharmony_ci ret |= regulator_set_voltage_sel_regmap(rdev, v_out); 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci return ret; 4758c2ecf20Sopenharmony_ci } 4768c2ecf20Sopenharmony_ci break; 4778c2ecf20Sopenharmony_ci default: 4788c2ecf20Sopenharmony_ci /* No quirks */ 4798c2ecf20Sopenharmony_ci break; 4808c2ecf20Sopenharmony_ci } 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_ci return regulator_enable_regmap(rdev); 4838c2ecf20Sopenharmony_ci}; 4848c2ecf20Sopenharmony_ci 4858c2ecf20Sopenharmony_cistatic const struct regulator_ops axp20x_ops_fixed = { 4868c2ecf20Sopenharmony_ci .list_voltage = regulator_list_voltage_linear, 4878c2ecf20Sopenharmony_ci}; 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_cistatic const struct regulator_ops axp20x_ops_range = { 4908c2ecf20Sopenharmony_ci .set_voltage_sel = regulator_set_voltage_sel_regmap, 4918c2ecf20Sopenharmony_ci .get_voltage_sel = regulator_get_voltage_sel_regmap, 4928c2ecf20Sopenharmony_ci .list_voltage = regulator_list_voltage_linear_range, 4938c2ecf20Sopenharmony_ci .enable = regulator_enable_regmap, 4948c2ecf20Sopenharmony_ci .disable = regulator_disable_regmap, 4958c2ecf20Sopenharmony_ci .is_enabled = regulator_is_enabled_regmap, 4968c2ecf20Sopenharmony_ci}; 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_cistatic const struct regulator_ops axp20x_ops = { 4998c2ecf20Sopenharmony_ci .set_voltage_sel = regulator_set_voltage_sel_regmap, 5008c2ecf20Sopenharmony_ci .get_voltage_sel = regulator_get_voltage_sel_regmap, 5018c2ecf20Sopenharmony_ci .list_voltage = regulator_list_voltage_linear, 5028c2ecf20Sopenharmony_ci .enable = axp20x_regulator_enable_regmap, 5038c2ecf20Sopenharmony_ci .disable = regulator_disable_regmap, 5048c2ecf20Sopenharmony_ci .is_enabled = regulator_is_enabled_regmap, 5058c2ecf20Sopenharmony_ci .set_ramp_delay = axp20x_set_ramp_delay, 5068c2ecf20Sopenharmony_ci}; 5078c2ecf20Sopenharmony_ci 5088c2ecf20Sopenharmony_cistatic const struct regulator_ops axp20x_ops_sw = { 5098c2ecf20Sopenharmony_ci .enable = regulator_enable_regmap, 5108c2ecf20Sopenharmony_ci .disable = regulator_disable_regmap, 5118c2ecf20Sopenharmony_ci .is_enabled = regulator_is_enabled_regmap, 5128c2ecf20Sopenharmony_ci}; 5138c2ecf20Sopenharmony_ci 5148c2ecf20Sopenharmony_cistatic const struct linear_range axp20x_ldo4_ranges[] = { 5158c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(1250000, 5168c2ecf20Sopenharmony_ci AXP20X_LDO4_V_OUT_1250mV_START, 5178c2ecf20Sopenharmony_ci AXP20X_LDO4_V_OUT_1250mV_END, 5188c2ecf20Sopenharmony_ci 0), 5198c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(1300000, 5208c2ecf20Sopenharmony_ci AXP20X_LDO4_V_OUT_1300mV_START, 5218c2ecf20Sopenharmony_ci AXP20X_LDO4_V_OUT_1300mV_END, 5228c2ecf20Sopenharmony_ci 100000), 5238c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(2500000, 5248c2ecf20Sopenharmony_ci AXP20X_LDO4_V_OUT_2500mV_START, 5258c2ecf20Sopenharmony_ci AXP20X_LDO4_V_OUT_2500mV_END, 5268c2ecf20Sopenharmony_ci 0), 5278c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(2700000, 5288c2ecf20Sopenharmony_ci AXP20X_LDO4_V_OUT_2700mV_START, 5298c2ecf20Sopenharmony_ci AXP20X_LDO4_V_OUT_2700mV_END, 5308c2ecf20Sopenharmony_ci 100000), 5318c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(3000000, 5328c2ecf20Sopenharmony_ci AXP20X_LDO4_V_OUT_3000mV_START, 5338c2ecf20Sopenharmony_ci AXP20X_LDO4_V_OUT_3000mV_END, 5348c2ecf20Sopenharmony_ci 100000), 5358c2ecf20Sopenharmony_ci}; 5368c2ecf20Sopenharmony_ci 5378c2ecf20Sopenharmony_cistatic const struct regulator_desc axp20x_regulators[] = { 5388c2ecf20Sopenharmony_ci AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25, 5398c2ecf20Sopenharmony_ci AXP20X_DCDC2_V_OUT, AXP20X_DCDC2_V_OUT_MASK, 5408c2ecf20Sopenharmony_ci AXP20X_PWR_OUT_CTRL, AXP20X_PWR_OUT_DCDC2_MASK), 5418c2ecf20Sopenharmony_ci AXP_DESC(AXP20X, DCDC3, "dcdc3", "vin3", 700, 3500, 25, 5428c2ecf20Sopenharmony_ci AXP20X_DCDC3_V_OUT, AXP20X_DCDC3_V_OUT_MASK, 5438c2ecf20Sopenharmony_ci AXP20X_PWR_OUT_CTRL, AXP20X_PWR_OUT_DCDC3_MASK), 5448c2ecf20Sopenharmony_ci AXP_DESC_FIXED(AXP20X, LDO1, "ldo1", "acin", 1300), 5458c2ecf20Sopenharmony_ci AXP_DESC(AXP20X, LDO2, "ldo2", "ldo24in", 1800, 3300, 100, 5468c2ecf20Sopenharmony_ci AXP20X_LDO24_V_OUT, AXP20X_LDO2_V_OUT_MASK, 5478c2ecf20Sopenharmony_ci AXP20X_PWR_OUT_CTRL, AXP20X_PWR_OUT_LDO2_MASK), 5488c2ecf20Sopenharmony_ci AXP_DESC(AXP20X, LDO3, "ldo3", "ldo3in", 700, 3500, 25, 5498c2ecf20Sopenharmony_ci AXP20X_LDO3_V_OUT, AXP20X_LDO3_V_OUT_MASK, 5508c2ecf20Sopenharmony_ci AXP20X_PWR_OUT_CTRL, AXP20X_PWR_OUT_LDO3_MASK), 5518c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP20X, LDO4, "ldo4", "ldo24in", 5528c2ecf20Sopenharmony_ci axp20x_ldo4_ranges, AXP20X_LDO4_V_OUT_NUM_VOLTAGES, 5538c2ecf20Sopenharmony_ci AXP20X_LDO24_V_OUT, AXP20X_LDO4_V_OUT_MASK, 5548c2ecf20Sopenharmony_ci AXP20X_PWR_OUT_CTRL, AXP20X_PWR_OUT_LDO4_MASK), 5558c2ecf20Sopenharmony_ci AXP_DESC_IO(AXP20X, LDO5, "ldo5", "ldo5in", 1800, 3300, 100, 5568c2ecf20Sopenharmony_ci AXP20X_LDO5_V_OUT, AXP20X_LDO5_V_OUT_MASK, 5578c2ecf20Sopenharmony_ci AXP20X_GPIO0_CTRL, AXP20X_GPIO0_FUNC_MASK, 5588c2ecf20Sopenharmony_ci AXP20X_IO_ENABLED, AXP20X_IO_DISABLED), 5598c2ecf20Sopenharmony_ci}; 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_cistatic const struct regulator_desc axp22x_regulators[] = { 5628c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, DCDC1, "dcdc1", "vin1", 1600, 3400, 100, 5638c2ecf20Sopenharmony_ci AXP22X_DCDC1_V_OUT, AXP22X_DCDC1_V_OUT_MASK, 5648c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC1_MASK), 5658c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, DCDC2, "dcdc2", "vin2", 600, 1540, 20, 5668c2ecf20Sopenharmony_ci AXP22X_DCDC2_V_OUT, AXP22X_DCDC2_V_OUT_MASK, 5678c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC2_MASK), 5688c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, DCDC3, "dcdc3", "vin3", 600, 1860, 20, 5698c2ecf20Sopenharmony_ci AXP22X_DCDC3_V_OUT, AXP22X_DCDC3_V_OUT_MASK, 5708c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC3_MASK), 5718c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, DCDC4, "dcdc4", "vin4", 600, 1540, 20, 5728c2ecf20Sopenharmony_ci AXP22X_DCDC4_V_OUT, AXP22X_DCDC4_V_OUT_MASK, 5738c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC4_MASK), 5748c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, DCDC5, "dcdc5", "vin5", 1000, 2550, 50, 5758c2ecf20Sopenharmony_ci AXP22X_DCDC5_V_OUT, AXP22X_DCDC5_V_OUT_MASK, 5768c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC5_MASK), 5778c2ecf20Sopenharmony_ci /* secondary switchable output of DCDC1 */ 5788c2ecf20Sopenharmony_ci AXP_DESC_SW(AXP22X, DC1SW, "dc1sw", NULL, 5798c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DC1SW_MASK), 5808c2ecf20Sopenharmony_ci /* LDO regulator internally chained to DCDC5 */ 5818c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, DC5LDO, "dc5ldo", NULL, 700, 1400, 100, 5828c2ecf20Sopenharmony_ci AXP22X_DC5LDO_V_OUT, AXP22X_DC5LDO_V_OUT_MASK, 5838c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DC5LDO_MASK), 5848c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, ALDO1, "aldo1", "aldoin", 700, 3300, 100, 5858c2ecf20Sopenharmony_ci AXP22X_ALDO1_V_OUT, AXP22X_ALDO1_V_OUT_MASK, 5868c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_ALDO1_MASK), 5878c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, ALDO2, "aldo2", "aldoin", 700, 3300, 100, 5888c2ecf20Sopenharmony_ci AXP22X_ALDO2_V_OUT, AXP22X_ALDO2_V_OUT_MASK, 5898c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_ALDO2_MASK), 5908c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, ALDO3, "aldo3", "aldoin", 700, 3300, 100, 5918c2ecf20Sopenharmony_ci AXP22X_ALDO3_V_OUT, AXP22X_ALDO3_V_OUT_MASK, 5928c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL3, AXP22X_PWR_OUT_ALDO3_MASK), 5938c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, DLDO1, "dldo1", "dldoin", 700, 3300, 100, 5948c2ecf20Sopenharmony_ci AXP22X_DLDO1_V_OUT, AXP22X_DLDO1_V_OUT_MASK, 5958c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO1_MASK), 5968c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, DLDO2, "dldo2", "dldoin", 700, 3300, 100, 5978c2ecf20Sopenharmony_ci AXP22X_DLDO2_V_OUT, AXP22X_DLDO2_V_OUT_MASK, 5988c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO2_MASK), 5998c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, DLDO3, "dldo3", "dldoin", 700, 3300, 100, 6008c2ecf20Sopenharmony_ci AXP22X_DLDO3_V_OUT, AXP22X_DLDO3_V_OUT_MASK, 6018c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO3_MASK), 6028c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, DLDO4, "dldo4", "dldoin", 700, 3300, 100, 6038c2ecf20Sopenharmony_ci AXP22X_DLDO4_V_OUT, AXP22X_DLDO4_V_OUT_MASK, 6048c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO4_MASK), 6058c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, ELDO1, "eldo1", "eldoin", 700, 3300, 100, 6068c2ecf20Sopenharmony_ci AXP22X_ELDO1_V_OUT, AXP22X_ELDO1_V_OUT_MASK, 6078c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK), 6088c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, ELDO2, "eldo2", "eldoin", 700, 3300, 100, 6098c2ecf20Sopenharmony_ci AXP22X_ELDO2_V_OUT, AXP22X_ELDO2_V_OUT_MASK, 6108c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO2_MASK), 6118c2ecf20Sopenharmony_ci AXP_DESC(AXP22X, ELDO3, "eldo3", "eldoin", 700, 3300, 100, 6128c2ecf20Sopenharmony_ci AXP22X_ELDO3_V_OUT, AXP22X_ELDO3_V_OUT_MASK, 6138c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO3_MASK), 6148c2ecf20Sopenharmony_ci /* Note the datasheet only guarantees reliable operation up to 6158c2ecf20Sopenharmony_ci * 3.3V, this needs to be enforced via dts provided constraints */ 6168c2ecf20Sopenharmony_ci AXP_DESC_IO(AXP22X, LDO_IO0, "ldo_io0", "ips", 700, 3800, 100, 6178c2ecf20Sopenharmony_ci AXP22X_LDO_IO0_V_OUT, AXP22X_LDO_IO0_V_OUT_MASK, 6188c2ecf20Sopenharmony_ci AXP20X_GPIO0_CTRL, AXP20X_GPIO0_FUNC_MASK, 6198c2ecf20Sopenharmony_ci AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), 6208c2ecf20Sopenharmony_ci /* Note the datasheet only guarantees reliable operation up to 6218c2ecf20Sopenharmony_ci * 3.3V, this needs to be enforced via dts provided constraints */ 6228c2ecf20Sopenharmony_ci AXP_DESC_IO(AXP22X, LDO_IO1, "ldo_io1", "ips", 700, 3800, 100, 6238c2ecf20Sopenharmony_ci AXP22X_LDO_IO1_V_OUT, AXP22X_LDO_IO1_V_OUT_MASK, 6248c2ecf20Sopenharmony_ci AXP20X_GPIO1_CTRL, AXP20X_GPIO1_FUNC_MASK, 6258c2ecf20Sopenharmony_ci AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), 6268c2ecf20Sopenharmony_ci AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtc_ldo", "ips", 3000), 6278c2ecf20Sopenharmony_ci}; 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_cistatic const struct regulator_desc axp22x_drivevbus_regulator = { 6308c2ecf20Sopenharmony_ci .name = "drivevbus", 6318c2ecf20Sopenharmony_ci .supply_name = "drivevbus", 6328c2ecf20Sopenharmony_ci .of_match = of_match_ptr("drivevbus"), 6338c2ecf20Sopenharmony_ci .regulators_node = of_match_ptr("regulators"), 6348c2ecf20Sopenharmony_ci .type = REGULATOR_VOLTAGE, 6358c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 6368c2ecf20Sopenharmony_ci .enable_reg = AXP20X_VBUS_IPSOUT_MGMT, 6378c2ecf20Sopenharmony_ci .enable_mask = AXP20X_VBUS_IPSOUT_MGMT_MASK, 6388c2ecf20Sopenharmony_ci .ops = &axp20x_ops_sw, 6398c2ecf20Sopenharmony_ci}; 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_ci/* DCDC ranges shared with AXP813 */ 6428c2ecf20Sopenharmony_cistatic const struct linear_range axp803_dcdc234_ranges[] = { 6438c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(500000, 6448c2ecf20Sopenharmony_ci AXP803_DCDC234_500mV_START, 6458c2ecf20Sopenharmony_ci AXP803_DCDC234_500mV_END, 6468c2ecf20Sopenharmony_ci 10000), 6478c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(1220000, 6488c2ecf20Sopenharmony_ci AXP803_DCDC234_1220mV_START, 6498c2ecf20Sopenharmony_ci AXP803_DCDC234_1220mV_END, 6508c2ecf20Sopenharmony_ci 20000), 6518c2ecf20Sopenharmony_ci}; 6528c2ecf20Sopenharmony_ci 6538c2ecf20Sopenharmony_cistatic const struct linear_range axp803_dcdc5_ranges[] = { 6548c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(800000, 6558c2ecf20Sopenharmony_ci AXP803_DCDC5_800mV_START, 6568c2ecf20Sopenharmony_ci AXP803_DCDC5_800mV_END, 6578c2ecf20Sopenharmony_ci 10000), 6588c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(1140000, 6598c2ecf20Sopenharmony_ci AXP803_DCDC5_1140mV_START, 6608c2ecf20Sopenharmony_ci AXP803_DCDC5_1140mV_END, 6618c2ecf20Sopenharmony_ci 20000), 6628c2ecf20Sopenharmony_ci}; 6638c2ecf20Sopenharmony_ci 6648c2ecf20Sopenharmony_cistatic const struct linear_range axp803_dcdc6_ranges[] = { 6658c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(600000, 6668c2ecf20Sopenharmony_ci AXP803_DCDC6_600mV_START, 6678c2ecf20Sopenharmony_ci AXP803_DCDC6_600mV_END, 6688c2ecf20Sopenharmony_ci 10000), 6698c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(1120000, 6708c2ecf20Sopenharmony_ci AXP803_DCDC6_1120mV_START, 6718c2ecf20Sopenharmony_ci AXP803_DCDC6_1120mV_END, 6728c2ecf20Sopenharmony_ci 20000), 6738c2ecf20Sopenharmony_ci}; 6748c2ecf20Sopenharmony_ci 6758c2ecf20Sopenharmony_ci/* AXP806's CLDO2 and AXP809's DLDO1 share the same range */ 6768c2ecf20Sopenharmony_cistatic const struct linear_range axp803_dldo2_ranges[] = { 6778c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(700000, 6788c2ecf20Sopenharmony_ci AXP803_DLDO2_700mV_START, 6798c2ecf20Sopenharmony_ci AXP803_DLDO2_700mV_END, 6808c2ecf20Sopenharmony_ci 100000), 6818c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(3400000, 6828c2ecf20Sopenharmony_ci AXP803_DLDO2_3400mV_START, 6838c2ecf20Sopenharmony_ci AXP803_DLDO2_3400mV_END, 6848c2ecf20Sopenharmony_ci 200000), 6858c2ecf20Sopenharmony_ci}; 6868c2ecf20Sopenharmony_ci 6878c2ecf20Sopenharmony_cistatic const struct regulator_desc axp803_regulators[] = { 6888c2ecf20Sopenharmony_ci AXP_DESC(AXP803, DCDC1, "dcdc1", "vin1", 1600, 3400, 100, 6898c2ecf20Sopenharmony_ci AXP803_DCDC1_V_OUT, AXP803_DCDC1_V_OUT_MASK, 6908c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC1_MASK), 6918c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP803, DCDC2, "dcdc2", "vin2", 6928c2ecf20Sopenharmony_ci axp803_dcdc234_ranges, AXP803_DCDC234_NUM_VOLTAGES, 6938c2ecf20Sopenharmony_ci AXP803_DCDC2_V_OUT, AXP803_DCDC2_V_OUT_MASK, 6948c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC2_MASK), 6958c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP803, DCDC3, "dcdc3", "vin3", 6968c2ecf20Sopenharmony_ci axp803_dcdc234_ranges, AXP803_DCDC234_NUM_VOLTAGES, 6978c2ecf20Sopenharmony_ci AXP803_DCDC3_V_OUT, AXP803_DCDC3_V_OUT_MASK, 6988c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC3_MASK), 6998c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP803, DCDC4, "dcdc4", "vin4", 7008c2ecf20Sopenharmony_ci axp803_dcdc234_ranges, AXP803_DCDC234_NUM_VOLTAGES, 7018c2ecf20Sopenharmony_ci AXP803_DCDC4_V_OUT, AXP803_DCDC4_V_OUT_MASK, 7028c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC4_MASK), 7038c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP803, DCDC5, "dcdc5", "vin5", 7048c2ecf20Sopenharmony_ci axp803_dcdc5_ranges, AXP803_DCDC5_NUM_VOLTAGES, 7058c2ecf20Sopenharmony_ci AXP803_DCDC5_V_OUT, AXP803_DCDC5_V_OUT_MASK, 7068c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC5_MASK), 7078c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP803, DCDC6, "dcdc6", "vin6", 7088c2ecf20Sopenharmony_ci axp803_dcdc6_ranges, AXP803_DCDC6_NUM_VOLTAGES, 7098c2ecf20Sopenharmony_ci AXP803_DCDC6_V_OUT, AXP803_DCDC6_V_OUT_MASK, 7108c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC6_MASK), 7118c2ecf20Sopenharmony_ci /* secondary switchable output of DCDC1 */ 7128c2ecf20Sopenharmony_ci AXP_DESC_SW(AXP803, DC1SW, "dc1sw", NULL, 7138c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DC1SW_MASK), 7148c2ecf20Sopenharmony_ci AXP_DESC(AXP803, ALDO1, "aldo1", "aldoin", 700, 3300, 100, 7158c2ecf20Sopenharmony_ci AXP22X_ALDO1_V_OUT, AXP22X_ALDO1_V_OUT_MASK, 7168c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL3, AXP806_PWR_OUT_ALDO1_MASK), 7178c2ecf20Sopenharmony_ci AXP_DESC(AXP803, ALDO2, "aldo2", "aldoin", 700, 3300, 100, 7188c2ecf20Sopenharmony_ci AXP22X_ALDO2_V_OUT, AXP22X_ALDO2_V_OUT_MASK, 7198c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL3, AXP806_PWR_OUT_ALDO2_MASK), 7208c2ecf20Sopenharmony_ci AXP_DESC(AXP803, ALDO3, "aldo3", "aldoin", 700, 3300, 100, 7218c2ecf20Sopenharmony_ci AXP22X_ALDO3_V_OUT, AXP22X_ALDO3_V_OUT_MASK, 7228c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL3, AXP806_PWR_OUT_ALDO3_MASK), 7238c2ecf20Sopenharmony_ci AXP_DESC(AXP803, DLDO1, "dldo1", "dldoin", 700, 3300, 100, 7248c2ecf20Sopenharmony_ci AXP22X_DLDO1_V_OUT, AXP22X_DLDO1_V_OUT_MASK, 7258c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO1_MASK), 7268c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP803, DLDO2, "dldo2", "dldoin", 7278c2ecf20Sopenharmony_ci axp803_dldo2_ranges, AXP803_DLDO2_NUM_VOLTAGES, 7288c2ecf20Sopenharmony_ci AXP22X_DLDO2_V_OUT, AXP22X_DLDO2_V_OUT_MASK, 7298c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO2_MASK), 7308c2ecf20Sopenharmony_ci AXP_DESC(AXP803, DLDO3, "dldo3", "dldoin", 700, 3300, 100, 7318c2ecf20Sopenharmony_ci AXP22X_DLDO3_V_OUT, AXP22X_DLDO3_V_OUT_MASK, 7328c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO3_MASK), 7338c2ecf20Sopenharmony_ci AXP_DESC(AXP803, DLDO4, "dldo4", "dldoin", 700, 3300, 100, 7348c2ecf20Sopenharmony_ci AXP22X_DLDO4_V_OUT, AXP22X_DLDO4_V_OUT_MASK, 7358c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO4_MASK), 7368c2ecf20Sopenharmony_ci AXP_DESC(AXP803, ELDO1, "eldo1", "eldoin", 700, 1900, 50, 7378c2ecf20Sopenharmony_ci AXP22X_ELDO1_V_OUT, AXP22X_ELDO1_V_OUT_MASK, 7388c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK), 7398c2ecf20Sopenharmony_ci AXP_DESC(AXP803, ELDO2, "eldo2", "eldoin", 700, 1900, 50, 7408c2ecf20Sopenharmony_ci AXP22X_ELDO2_V_OUT, AXP22X_ELDO2_V_OUT_MASK, 7418c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO2_MASK), 7428c2ecf20Sopenharmony_ci AXP_DESC(AXP803, ELDO3, "eldo3", "eldoin", 700, 1900, 50, 7438c2ecf20Sopenharmony_ci AXP22X_ELDO3_V_OUT, AXP22X_ELDO3_V_OUT_MASK, 7448c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO3_MASK), 7458c2ecf20Sopenharmony_ci AXP_DESC(AXP803, FLDO1, "fldo1", "fldoin", 700, 1450, 50, 7468c2ecf20Sopenharmony_ci AXP803_FLDO1_V_OUT, AXP803_FLDO1_V_OUT_MASK, 7478c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL3, AXP803_PWR_OUT_FLDO1_MASK), 7488c2ecf20Sopenharmony_ci AXP_DESC(AXP803, FLDO2, "fldo2", "fldoin", 700, 1450, 50, 7498c2ecf20Sopenharmony_ci AXP803_FLDO2_V_OUT, AXP803_FLDO2_V_OUT_MASK, 7508c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL3, AXP803_PWR_OUT_FLDO2_MASK), 7518c2ecf20Sopenharmony_ci AXP_DESC_IO(AXP803, LDO_IO0, "ldo-io0", "ips", 700, 3300, 100, 7528c2ecf20Sopenharmony_ci AXP22X_LDO_IO0_V_OUT, AXP22X_LDO_IO0_V_OUT_MASK, 7538c2ecf20Sopenharmony_ci AXP20X_GPIO0_CTRL, AXP20X_GPIO0_FUNC_MASK, 7548c2ecf20Sopenharmony_ci AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), 7558c2ecf20Sopenharmony_ci AXP_DESC_IO(AXP803, LDO_IO1, "ldo-io1", "ips", 700, 3300, 100, 7568c2ecf20Sopenharmony_ci AXP22X_LDO_IO1_V_OUT, AXP22X_LDO_IO1_V_OUT_MASK, 7578c2ecf20Sopenharmony_ci AXP20X_GPIO1_CTRL, AXP20X_GPIO1_FUNC_MASK, 7588c2ecf20Sopenharmony_ci AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), 7598c2ecf20Sopenharmony_ci AXP_DESC_FIXED(AXP803, RTC_LDO, "rtc-ldo", "ips", 3000), 7608c2ecf20Sopenharmony_ci}; 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_cistatic const struct linear_range axp806_dcdca_ranges[] = { 7638c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(600000, 7648c2ecf20Sopenharmony_ci AXP806_DCDCA_600mV_START, 7658c2ecf20Sopenharmony_ci AXP806_DCDCA_600mV_END, 7668c2ecf20Sopenharmony_ci 10000), 7678c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(1120000, 7688c2ecf20Sopenharmony_ci AXP806_DCDCA_1120mV_START, 7698c2ecf20Sopenharmony_ci AXP806_DCDCA_1120mV_END, 7708c2ecf20Sopenharmony_ci 20000), 7718c2ecf20Sopenharmony_ci}; 7728c2ecf20Sopenharmony_ci 7738c2ecf20Sopenharmony_cistatic const struct linear_range axp806_dcdcd_ranges[] = { 7748c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(600000, 7758c2ecf20Sopenharmony_ci AXP806_DCDCD_600mV_START, 7768c2ecf20Sopenharmony_ci AXP806_DCDCD_600mV_END, 7778c2ecf20Sopenharmony_ci 20000), 7788c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(1600000, 7798c2ecf20Sopenharmony_ci AXP806_DCDCD_1600mV_START, 7808c2ecf20Sopenharmony_ci AXP806_DCDCD_1600mV_END, 7818c2ecf20Sopenharmony_ci 100000), 7828c2ecf20Sopenharmony_ci}; 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_cistatic const struct regulator_desc axp806_regulators[] = { 7858c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP806, DCDCA, "dcdca", "vina", 7868c2ecf20Sopenharmony_ci axp806_dcdca_ranges, AXP806_DCDCA_NUM_VOLTAGES, 7878c2ecf20Sopenharmony_ci AXP806_DCDCA_V_CTRL, AXP806_DCDCA_V_CTRL_MASK, 7888c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_DCDCA_MASK), 7898c2ecf20Sopenharmony_ci AXP_DESC(AXP806, DCDCB, "dcdcb", "vinb", 1000, 2550, 50, 7908c2ecf20Sopenharmony_ci AXP806_DCDCB_V_CTRL, AXP806_DCDCB_V_CTRL_MASK, 7918c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_DCDCB_MASK), 7928c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP806, DCDCC, "dcdcc", "vinc", 7938c2ecf20Sopenharmony_ci axp806_dcdca_ranges, AXP806_DCDCA_NUM_VOLTAGES, 7948c2ecf20Sopenharmony_ci AXP806_DCDCC_V_CTRL, AXP806_DCDCC_V_CTRL_MASK, 7958c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_DCDCC_MASK), 7968c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP806, DCDCD, "dcdcd", "vind", 7978c2ecf20Sopenharmony_ci axp806_dcdcd_ranges, AXP806_DCDCD_NUM_VOLTAGES, 7988c2ecf20Sopenharmony_ci AXP806_DCDCD_V_CTRL, AXP806_DCDCD_V_CTRL_MASK, 7998c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_DCDCD_MASK), 8008c2ecf20Sopenharmony_ci AXP_DESC(AXP806, DCDCE, "dcdce", "vine", 1100, 3400, 100, 8018c2ecf20Sopenharmony_ci AXP806_DCDCE_V_CTRL, AXP806_DCDCE_V_CTRL_MASK, 8028c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_DCDCE_MASK), 8038c2ecf20Sopenharmony_ci AXP_DESC(AXP806, ALDO1, "aldo1", "aldoin", 700, 3300, 100, 8048c2ecf20Sopenharmony_ci AXP806_ALDO1_V_CTRL, AXP806_ALDO1_V_CTRL_MASK, 8058c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_ALDO1_MASK), 8068c2ecf20Sopenharmony_ci AXP_DESC(AXP806, ALDO2, "aldo2", "aldoin", 700, 3400, 100, 8078c2ecf20Sopenharmony_ci AXP806_ALDO2_V_CTRL, AXP806_ALDO2_V_CTRL_MASK, 8088c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_ALDO2_MASK), 8098c2ecf20Sopenharmony_ci AXP_DESC(AXP806, ALDO3, "aldo3", "aldoin", 700, 3300, 100, 8108c2ecf20Sopenharmony_ci AXP806_ALDO3_V_CTRL, AXP806_ALDO3_V_CTRL_MASK, 8118c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_ALDO3_MASK), 8128c2ecf20Sopenharmony_ci AXP_DESC(AXP806, BLDO1, "bldo1", "bldoin", 700, 1900, 100, 8138c2ecf20Sopenharmony_ci AXP806_BLDO1_V_CTRL, AXP806_BLDO1_V_CTRL_MASK, 8148c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_BLDO1_MASK), 8158c2ecf20Sopenharmony_ci AXP_DESC(AXP806, BLDO2, "bldo2", "bldoin", 700, 1900, 100, 8168c2ecf20Sopenharmony_ci AXP806_BLDO2_V_CTRL, AXP806_BLDO2_V_CTRL_MASK, 8178c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_BLDO2_MASK), 8188c2ecf20Sopenharmony_ci AXP_DESC(AXP806, BLDO3, "bldo3", "bldoin", 700, 1900, 100, 8198c2ecf20Sopenharmony_ci AXP806_BLDO3_V_CTRL, AXP806_BLDO3_V_CTRL_MASK, 8208c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_BLDO3_MASK), 8218c2ecf20Sopenharmony_ci AXP_DESC(AXP806, BLDO4, "bldo4", "bldoin", 700, 1900, 100, 8228c2ecf20Sopenharmony_ci AXP806_BLDO4_V_CTRL, AXP806_BLDO4_V_CTRL_MASK, 8238c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_BLDO4_MASK), 8248c2ecf20Sopenharmony_ci AXP_DESC(AXP806, CLDO1, "cldo1", "cldoin", 700, 3300, 100, 8258c2ecf20Sopenharmony_ci AXP806_CLDO1_V_CTRL, AXP806_CLDO1_V_CTRL_MASK, 8268c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_CLDO1_MASK), 8278c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP806, CLDO2, "cldo2", "cldoin", 8288c2ecf20Sopenharmony_ci axp803_dldo2_ranges, AXP803_DLDO2_NUM_VOLTAGES, 8298c2ecf20Sopenharmony_ci AXP806_CLDO2_V_CTRL, AXP806_CLDO2_V_CTRL_MASK, 8308c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_CLDO2_MASK), 8318c2ecf20Sopenharmony_ci AXP_DESC(AXP806, CLDO3, "cldo3", "cldoin", 700, 3300, 100, 8328c2ecf20Sopenharmony_ci AXP806_CLDO3_V_CTRL, AXP806_CLDO3_V_CTRL_MASK, 8338c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_CLDO3_MASK), 8348c2ecf20Sopenharmony_ci AXP_DESC_SW(AXP806, SW, "sw", "swin", 8358c2ecf20Sopenharmony_ci AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_SW_MASK), 8368c2ecf20Sopenharmony_ci}; 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_cistatic const struct linear_range axp809_dcdc4_ranges[] = { 8398c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(600000, 8408c2ecf20Sopenharmony_ci AXP809_DCDC4_600mV_START, 8418c2ecf20Sopenharmony_ci AXP809_DCDC4_600mV_END, 8428c2ecf20Sopenharmony_ci 20000), 8438c2ecf20Sopenharmony_ci REGULATOR_LINEAR_RANGE(1800000, 8448c2ecf20Sopenharmony_ci AXP809_DCDC4_1800mV_START, 8458c2ecf20Sopenharmony_ci AXP809_DCDC4_1800mV_END, 8468c2ecf20Sopenharmony_ci 100000), 8478c2ecf20Sopenharmony_ci}; 8488c2ecf20Sopenharmony_ci 8498c2ecf20Sopenharmony_cistatic const struct regulator_desc axp809_regulators[] = { 8508c2ecf20Sopenharmony_ci AXP_DESC(AXP809, DCDC1, "dcdc1", "vin1", 1600, 3400, 100, 8518c2ecf20Sopenharmony_ci AXP22X_DCDC1_V_OUT, AXP22X_DCDC1_V_OUT_MASK, 8528c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC1_MASK), 8538c2ecf20Sopenharmony_ci AXP_DESC(AXP809, DCDC2, "dcdc2", "vin2", 600, 1540, 20, 8548c2ecf20Sopenharmony_ci AXP22X_DCDC2_V_OUT, AXP22X_DCDC2_V_OUT_MASK, 8558c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC2_MASK), 8568c2ecf20Sopenharmony_ci AXP_DESC(AXP809, DCDC3, "dcdc3", "vin3", 600, 1860, 20, 8578c2ecf20Sopenharmony_ci AXP22X_DCDC3_V_OUT, AXP22X_DCDC3_V_OUT_MASK, 8588c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC3_MASK), 8598c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP809, DCDC4, "dcdc4", "vin4", 8608c2ecf20Sopenharmony_ci axp809_dcdc4_ranges, AXP809_DCDC4_NUM_VOLTAGES, 8618c2ecf20Sopenharmony_ci AXP22X_DCDC4_V_OUT, AXP22X_DCDC4_V_OUT_MASK, 8628c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC4_MASK), 8638c2ecf20Sopenharmony_ci AXP_DESC(AXP809, DCDC5, "dcdc5", "vin5", 1000, 2550, 50, 8648c2ecf20Sopenharmony_ci AXP22X_DCDC5_V_OUT, AXP22X_DCDC5_V_OUT_MASK, 8658c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC5_MASK), 8668c2ecf20Sopenharmony_ci /* secondary switchable output of DCDC1 */ 8678c2ecf20Sopenharmony_ci AXP_DESC_SW(AXP809, DC1SW, "dc1sw", NULL, 8688c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DC1SW_MASK), 8698c2ecf20Sopenharmony_ci /* LDO regulator internally chained to DCDC5 */ 8708c2ecf20Sopenharmony_ci AXP_DESC(AXP809, DC5LDO, "dc5ldo", NULL, 700, 1400, 100, 8718c2ecf20Sopenharmony_ci AXP22X_DC5LDO_V_OUT, AXP22X_DC5LDO_V_OUT_MASK, 8728c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DC5LDO_MASK), 8738c2ecf20Sopenharmony_ci AXP_DESC(AXP809, ALDO1, "aldo1", "aldoin", 700, 3300, 100, 8748c2ecf20Sopenharmony_ci AXP22X_ALDO1_V_OUT, AXP22X_ALDO1_V_OUT_MASK, 8758c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_ALDO1_MASK), 8768c2ecf20Sopenharmony_ci AXP_DESC(AXP809, ALDO2, "aldo2", "aldoin", 700, 3300, 100, 8778c2ecf20Sopenharmony_ci AXP22X_ALDO2_V_OUT, AXP22X_ALDO2_V_OUT_MASK, 8788c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_ALDO2_MASK), 8798c2ecf20Sopenharmony_ci AXP_DESC(AXP809, ALDO3, "aldo3", "aldoin", 700, 3300, 100, 8808c2ecf20Sopenharmony_ci AXP22X_ALDO3_V_OUT, AXP22X_ALDO3_V_OUT_MASK, 8818c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ALDO3_MASK), 8828c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP809, DLDO1, "dldo1", "dldoin", 8838c2ecf20Sopenharmony_ci axp803_dldo2_ranges, AXP803_DLDO2_NUM_VOLTAGES, 8848c2ecf20Sopenharmony_ci AXP22X_DLDO1_V_OUT, AXP22X_DLDO1_V_OUT_MASK, 8858c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO1_MASK), 8868c2ecf20Sopenharmony_ci AXP_DESC(AXP809, DLDO2, "dldo2", "dldoin", 700, 3300, 100, 8878c2ecf20Sopenharmony_ci AXP22X_DLDO2_V_OUT, AXP22X_DLDO2_V_OUT_MASK, 8888c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO2_MASK), 8898c2ecf20Sopenharmony_ci AXP_DESC(AXP809, ELDO1, "eldo1", "eldoin", 700, 3300, 100, 8908c2ecf20Sopenharmony_ci AXP22X_ELDO1_V_OUT, AXP22X_ELDO1_V_OUT_MASK, 8918c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK), 8928c2ecf20Sopenharmony_ci AXP_DESC(AXP809, ELDO2, "eldo2", "eldoin", 700, 3300, 100, 8938c2ecf20Sopenharmony_ci AXP22X_ELDO2_V_OUT, AXP22X_ELDO2_V_OUT_MASK, 8948c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO2_MASK), 8958c2ecf20Sopenharmony_ci AXP_DESC(AXP809, ELDO3, "eldo3", "eldoin", 700, 3300, 100, 8968c2ecf20Sopenharmony_ci AXP22X_ELDO3_V_OUT, AXP22X_ELDO3_V_OUT_MASK, 8978c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO3_MASK), 8988c2ecf20Sopenharmony_ci /* 8998c2ecf20Sopenharmony_ci * Note the datasheet only guarantees reliable operation up to 9008c2ecf20Sopenharmony_ci * 3.3V, this needs to be enforced via dts provided constraints 9018c2ecf20Sopenharmony_ci */ 9028c2ecf20Sopenharmony_ci AXP_DESC_IO(AXP809, LDO_IO0, "ldo_io0", "ips", 700, 3800, 100, 9038c2ecf20Sopenharmony_ci AXP22X_LDO_IO0_V_OUT, AXP22X_LDO_IO0_V_OUT_MASK, 9048c2ecf20Sopenharmony_ci AXP20X_GPIO0_CTRL, AXP20X_GPIO0_FUNC_MASK, 9058c2ecf20Sopenharmony_ci AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), 9068c2ecf20Sopenharmony_ci /* 9078c2ecf20Sopenharmony_ci * Note the datasheet only guarantees reliable operation up to 9088c2ecf20Sopenharmony_ci * 3.3V, this needs to be enforced via dts provided constraints 9098c2ecf20Sopenharmony_ci */ 9108c2ecf20Sopenharmony_ci AXP_DESC_IO(AXP809, LDO_IO1, "ldo_io1", "ips", 700, 3800, 100, 9118c2ecf20Sopenharmony_ci AXP22X_LDO_IO1_V_OUT, AXP22X_LDO_IO1_V_OUT_MASK, 9128c2ecf20Sopenharmony_ci AXP20X_GPIO1_CTRL, AXP20X_GPIO1_FUNC_MASK, 9138c2ecf20Sopenharmony_ci AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), 9148c2ecf20Sopenharmony_ci AXP_DESC_FIXED(AXP809, RTC_LDO, "rtc_ldo", "ips", 1800), 9158c2ecf20Sopenharmony_ci AXP_DESC_SW(AXP809, SW, "sw", "swin", 9168c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_SW_MASK), 9178c2ecf20Sopenharmony_ci}; 9188c2ecf20Sopenharmony_ci 9198c2ecf20Sopenharmony_cistatic const struct regulator_desc axp813_regulators[] = { 9208c2ecf20Sopenharmony_ci AXP_DESC(AXP813, DCDC1, "dcdc1", "vin1", 1600, 3400, 100, 9218c2ecf20Sopenharmony_ci AXP803_DCDC1_V_OUT, AXP803_DCDC1_V_OUT_MASK, 9228c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC1_MASK), 9238c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP813, DCDC2, "dcdc2", "vin2", 9248c2ecf20Sopenharmony_ci axp803_dcdc234_ranges, AXP803_DCDC234_NUM_VOLTAGES, 9258c2ecf20Sopenharmony_ci AXP803_DCDC2_V_OUT, AXP803_DCDC2_V_OUT_MASK, 9268c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC2_MASK), 9278c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP813, DCDC3, "dcdc3", "vin3", 9288c2ecf20Sopenharmony_ci axp803_dcdc234_ranges, AXP803_DCDC234_NUM_VOLTAGES, 9298c2ecf20Sopenharmony_ci AXP803_DCDC3_V_OUT, AXP803_DCDC3_V_OUT_MASK, 9308c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC3_MASK), 9318c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP813, DCDC4, "dcdc4", "vin4", 9328c2ecf20Sopenharmony_ci axp803_dcdc234_ranges, AXP803_DCDC234_NUM_VOLTAGES, 9338c2ecf20Sopenharmony_ci AXP803_DCDC4_V_OUT, AXP803_DCDC4_V_OUT_MASK, 9348c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC4_MASK), 9358c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP813, DCDC5, "dcdc5", "vin5", 9368c2ecf20Sopenharmony_ci axp803_dcdc5_ranges, AXP803_DCDC5_NUM_VOLTAGES, 9378c2ecf20Sopenharmony_ci AXP803_DCDC5_V_OUT, AXP803_DCDC5_V_OUT_MASK, 9388c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC5_MASK), 9398c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP813, DCDC6, "dcdc6", "vin6", 9408c2ecf20Sopenharmony_ci axp803_dcdc6_ranges, AXP803_DCDC6_NUM_VOLTAGES, 9418c2ecf20Sopenharmony_ci AXP803_DCDC6_V_OUT, AXP803_DCDC6_V_OUT_MASK, 9428c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC6_MASK), 9438c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP813, DCDC7, "dcdc7", "vin7", 9448c2ecf20Sopenharmony_ci axp803_dcdc6_ranges, AXP803_DCDC6_NUM_VOLTAGES, 9458c2ecf20Sopenharmony_ci AXP813_DCDC7_V_OUT, AXP813_DCDC7_V_OUT_MASK, 9468c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL1, AXP813_PWR_OUT_DCDC7_MASK), 9478c2ecf20Sopenharmony_ci AXP_DESC(AXP813, ALDO1, "aldo1", "aldoin", 700, 3300, 100, 9488c2ecf20Sopenharmony_ci AXP22X_ALDO1_V_OUT, AXP22X_ALDO1_V_OUT_MASK, 9498c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL3, AXP806_PWR_OUT_ALDO1_MASK), 9508c2ecf20Sopenharmony_ci AXP_DESC(AXP813, ALDO2, "aldo2", "aldoin", 700, 3300, 100, 9518c2ecf20Sopenharmony_ci AXP22X_ALDO2_V_OUT, AXP22X_ALDO2_V_OUT_MASK, 9528c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL3, AXP806_PWR_OUT_ALDO2_MASK), 9538c2ecf20Sopenharmony_ci AXP_DESC(AXP813, ALDO3, "aldo3", "aldoin", 700, 3300, 100, 9548c2ecf20Sopenharmony_ci AXP22X_ALDO3_V_OUT, AXP22X_ALDO3_V_OUT_MASK, 9558c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL3, AXP806_PWR_OUT_ALDO3_MASK), 9568c2ecf20Sopenharmony_ci AXP_DESC(AXP813, DLDO1, "dldo1", "dldoin", 700, 3300, 100, 9578c2ecf20Sopenharmony_ci AXP22X_DLDO1_V_OUT, AXP22X_DLDO1_V_OUT_MASK, 9588c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO1_MASK), 9598c2ecf20Sopenharmony_ci AXP_DESC_RANGES(AXP813, DLDO2, "dldo2", "dldoin", 9608c2ecf20Sopenharmony_ci axp803_dldo2_ranges, AXP803_DLDO2_NUM_VOLTAGES, 9618c2ecf20Sopenharmony_ci AXP22X_DLDO2_V_OUT, AXP22X_DLDO2_V_OUT_MASK, 9628c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO2_MASK), 9638c2ecf20Sopenharmony_ci AXP_DESC(AXP813, DLDO3, "dldo3", "dldoin", 700, 3300, 100, 9648c2ecf20Sopenharmony_ci AXP22X_DLDO3_V_OUT, AXP22X_DLDO3_V_OUT_MASK, 9658c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO3_MASK), 9668c2ecf20Sopenharmony_ci AXP_DESC(AXP813, DLDO4, "dldo4", "dldoin", 700, 3300, 100, 9678c2ecf20Sopenharmony_ci AXP22X_DLDO4_V_OUT, AXP22X_DLDO4_V_OUT_MASK, 9688c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO4_MASK), 9698c2ecf20Sopenharmony_ci AXP_DESC(AXP813, ELDO1, "eldo1", "eldoin", 700, 1900, 50, 9708c2ecf20Sopenharmony_ci AXP22X_ELDO1_V_OUT, AXP22X_ELDO1_V_OUT_MASK, 9718c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK), 9728c2ecf20Sopenharmony_ci AXP_DESC(AXP813, ELDO2, "eldo2", "eldoin", 700, 1900, 50, 9738c2ecf20Sopenharmony_ci AXP22X_ELDO2_V_OUT, AXP22X_ELDO2_V_OUT_MASK, 9748c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO2_MASK), 9758c2ecf20Sopenharmony_ci AXP_DESC(AXP813, ELDO3, "eldo3", "eldoin", 700, 1900, 50, 9768c2ecf20Sopenharmony_ci AXP22X_ELDO3_V_OUT, AXP22X_ELDO3_V_OUT_MASK, 9778c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO3_MASK), 9788c2ecf20Sopenharmony_ci /* to do / check ... */ 9798c2ecf20Sopenharmony_ci AXP_DESC(AXP813, FLDO1, "fldo1", "fldoin", 700, 1450, 50, 9808c2ecf20Sopenharmony_ci AXP803_FLDO1_V_OUT, AXP803_FLDO1_V_OUT_MASK, 9818c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL3, AXP803_PWR_OUT_FLDO1_MASK), 9828c2ecf20Sopenharmony_ci AXP_DESC(AXP813, FLDO2, "fldo2", "fldoin", 700, 1450, 50, 9838c2ecf20Sopenharmony_ci AXP803_FLDO2_V_OUT, AXP803_FLDO2_V_OUT_MASK, 9848c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL3, AXP803_PWR_OUT_FLDO2_MASK), 9858c2ecf20Sopenharmony_ci /* 9868c2ecf20Sopenharmony_ci * TODO: FLDO3 = {DCDC5, FLDOIN} / 2 9878c2ecf20Sopenharmony_ci * 9888c2ecf20Sopenharmony_ci * This means FLDO3 effectively switches supplies at runtime, 9898c2ecf20Sopenharmony_ci * something the regulator subsystem does not support. 9908c2ecf20Sopenharmony_ci */ 9918c2ecf20Sopenharmony_ci AXP_DESC_FIXED(AXP813, RTC_LDO, "rtc-ldo", "ips", 1800), 9928c2ecf20Sopenharmony_ci AXP_DESC_IO(AXP813, LDO_IO0, "ldo-io0", "ips", 700, 3300, 100, 9938c2ecf20Sopenharmony_ci AXP22X_LDO_IO0_V_OUT, AXP22X_LDO_IO0_V_OUT_MASK, 9948c2ecf20Sopenharmony_ci AXP20X_GPIO0_CTRL, AXP20X_GPIO0_FUNC_MASK, 9958c2ecf20Sopenharmony_ci AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), 9968c2ecf20Sopenharmony_ci AXP_DESC_IO(AXP813, LDO_IO1, "ldo-io1", "ips", 700, 3300, 100, 9978c2ecf20Sopenharmony_ci AXP22X_LDO_IO1_V_OUT, AXP22X_LDO_IO1_V_OUT_MASK, 9988c2ecf20Sopenharmony_ci AXP20X_GPIO1_CTRL, AXP20X_GPIO1_FUNC_MASK, 9998c2ecf20Sopenharmony_ci AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), 10008c2ecf20Sopenharmony_ci AXP_DESC_SW(AXP813, SW, "sw", "swin", 10018c2ecf20Sopenharmony_ci AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DC1SW_MASK), 10028c2ecf20Sopenharmony_ci}; 10038c2ecf20Sopenharmony_ci 10048c2ecf20Sopenharmony_cistatic int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) 10058c2ecf20Sopenharmony_ci{ 10068c2ecf20Sopenharmony_ci struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); 10078c2ecf20Sopenharmony_ci unsigned int reg = AXP20X_DCDC_FREQ; 10088c2ecf20Sopenharmony_ci u32 min, max, def, step; 10098c2ecf20Sopenharmony_ci 10108c2ecf20Sopenharmony_ci switch (axp20x->variant) { 10118c2ecf20Sopenharmony_ci case AXP202_ID: 10128c2ecf20Sopenharmony_ci case AXP209_ID: 10138c2ecf20Sopenharmony_ci min = 750; 10148c2ecf20Sopenharmony_ci max = 1875; 10158c2ecf20Sopenharmony_ci def = 1500; 10168c2ecf20Sopenharmony_ci step = 75; 10178c2ecf20Sopenharmony_ci break; 10188c2ecf20Sopenharmony_ci case AXP803_ID: 10198c2ecf20Sopenharmony_ci case AXP813_ID: 10208c2ecf20Sopenharmony_ci /* 10218c2ecf20Sopenharmony_ci * AXP803/AXP813 DCDC work frequency setting has the same 10228c2ecf20Sopenharmony_ci * range and step as AXP22X, but at a different register. 10238c2ecf20Sopenharmony_ci * (See include/linux/mfd/axp20x.h) 10248c2ecf20Sopenharmony_ci */ 10258c2ecf20Sopenharmony_ci reg = AXP803_DCDC_FREQ_CTRL; 10268c2ecf20Sopenharmony_ci fallthrough; /* to the check below */ 10278c2ecf20Sopenharmony_ci case AXP806_ID: 10288c2ecf20Sopenharmony_ci /* 10298c2ecf20Sopenharmony_ci * AXP806 also have DCDC work frequency setting register at a 10308c2ecf20Sopenharmony_ci * different position. 10318c2ecf20Sopenharmony_ci */ 10328c2ecf20Sopenharmony_ci if (axp20x->variant == AXP806_ID) 10338c2ecf20Sopenharmony_ci reg = AXP806_DCDC_FREQ_CTRL; 10348c2ecf20Sopenharmony_ci fallthrough; 10358c2ecf20Sopenharmony_ci case AXP221_ID: 10368c2ecf20Sopenharmony_ci case AXP223_ID: 10378c2ecf20Sopenharmony_ci case AXP809_ID: 10388c2ecf20Sopenharmony_ci min = 1800; 10398c2ecf20Sopenharmony_ci max = 4050; 10408c2ecf20Sopenharmony_ci def = 3000; 10418c2ecf20Sopenharmony_ci step = 150; 10428c2ecf20Sopenharmony_ci break; 10438c2ecf20Sopenharmony_ci default: 10448c2ecf20Sopenharmony_ci dev_err(&pdev->dev, 10458c2ecf20Sopenharmony_ci "Setting DCDC frequency for unsupported AXP variant\n"); 10468c2ecf20Sopenharmony_ci return -EINVAL; 10478c2ecf20Sopenharmony_ci } 10488c2ecf20Sopenharmony_ci 10498c2ecf20Sopenharmony_ci if (dcdcfreq == 0) 10508c2ecf20Sopenharmony_ci dcdcfreq = def; 10518c2ecf20Sopenharmony_ci 10528c2ecf20Sopenharmony_ci if (dcdcfreq < min) { 10538c2ecf20Sopenharmony_ci dcdcfreq = min; 10548c2ecf20Sopenharmony_ci dev_warn(&pdev->dev, "DCDC frequency too low. Set to %ukHz\n", 10558c2ecf20Sopenharmony_ci min); 10568c2ecf20Sopenharmony_ci } 10578c2ecf20Sopenharmony_ci 10588c2ecf20Sopenharmony_ci if (dcdcfreq > max) { 10598c2ecf20Sopenharmony_ci dcdcfreq = max; 10608c2ecf20Sopenharmony_ci dev_warn(&pdev->dev, "DCDC frequency too high. Set to %ukHz\n", 10618c2ecf20Sopenharmony_ci max); 10628c2ecf20Sopenharmony_ci } 10638c2ecf20Sopenharmony_ci 10648c2ecf20Sopenharmony_ci dcdcfreq = (dcdcfreq - min) / step; 10658c2ecf20Sopenharmony_ci 10668c2ecf20Sopenharmony_ci return regmap_update_bits(axp20x->regmap, reg, 10678c2ecf20Sopenharmony_ci AXP20X_FREQ_DCDC_MASK, dcdcfreq); 10688c2ecf20Sopenharmony_ci} 10698c2ecf20Sopenharmony_ci 10708c2ecf20Sopenharmony_cistatic int axp20x_regulator_parse_dt(struct platform_device *pdev) 10718c2ecf20Sopenharmony_ci{ 10728c2ecf20Sopenharmony_ci struct device_node *np, *regulators; 10738c2ecf20Sopenharmony_ci int ret = 0; 10748c2ecf20Sopenharmony_ci u32 dcdcfreq = 0; 10758c2ecf20Sopenharmony_ci 10768c2ecf20Sopenharmony_ci np = of_node_get(pdev->dev.parent->of_node); 10778c2ecf20Sopenharmony_ci if (!np) 10788c2ecf20Sopenharmony_ci return 0; 10798c2ecf20Sopenharmony_ci 10808c2ecf20Sopenharmony_ci regulators = of_get_child_by_name(np, "regulators"); 10818c2ecf20Sopenharmony_ci if (!regulators) { 10828c2ecf20Sopenharmony_ci dev_warn(&pdev->dev, "regulators node not found\n"); 10838c2ecf20Sopenharmony_ci } else { 10848c2ecf20Sopenharmony_ci of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq); 10858c2ecf20Sopenharmony_ci ret = axp20x_set_dcdc_freq(pdev, dcdcfreq); 10868c2ecf20Sopenharmony_ci if (ret < 0) { 10878c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "Error setting dcdc frequency: %d\n", ret); 10888c2ecf20Sopenharmony_ci } 10898c2ecf20Sopenharmony_ci of_node_put(regulators); 10908c2ecf20Sopenharmony_ci } 10918c2ecf20Sopenharmony_ci 10928c2ecf20Sopenharmony_ci of_node_put(np); 10938c2ecf20Sopenharmony_ci return ret; 10948c2ecf20Sopenharmony_ci} 10958c2ecf20Sopenharmony_ci 10968c2ecf20Sopenharmony_cistatic int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode) 10978c2ecf20Sopenharmony_ci{ 10988c2ecf20Sopenharmony_ci struct axp20x_dev *axp20x = rdev_get_drvdata(rdev); 10998c2ecf20Sopenharmony_ci unsigned int reg = AXP20X_DCDC_MODE; 11008c2ecf20Sopenharmony_ci unsigned int mask; 11018c2ecf20Sopenharmony_ci 11028c2ecf20Sopenharmony_ci switch (axp20x->variant) { 11038c2ecf20Sopenharmony_ci case AXP202_ID: 11048c2ecf20Sopenharmony_ci case AXP209_ID: 11058c2ecf20Sopenharmony_ci if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3)) 11068c2ecf20Sopenharmony_ci return -EINVAL; 11078c2ecf20Sopenharmony_ci 11088c2ecf20Sopenharmony_ci mask = AXP20X_WORKMODE_DCDC2_MASK; 11098c2ecf20Sopenharmony_ci if (id == AXP20X_DCDC3) 11108c2ecf20Sopenharmony_ci mask = AXP20X_WORKMODE_DCDC3_MASK; 11118c2ecf20Sopenharmony_ci 11128c2ecf20Sopenharmony_ci workmode <<= ffs(mask) - 1; 11138c2ecf20Sopenharmony_ci break; 11148c2ecf20Sopenharmony_ci 11158c2ecf20Sopenharmony_ci case AXP806_ID: 11168c2ecf20Sopenharmony_ci /* 11178c2ecf20Sopenharmony_ci * AXP806 DCDC regulator IDs have the same range as AXP22X. 11188c2ecf20Sopenharmony_ci * (See include/linux/mfd/axp20x.h) 11198c2ecf20Sopenharmony_ci */ 11208c2ecf20Sopenharmony_ci reg = AXP806_DCDC_MODE_CTRL2; 11218c2ecf20Sopenharmony_ci fallthrough; /* to the check below */ 11228c2ecf20Sopenharmony_ci case AXP221_ID: 11238c2ecf20Sopenharmony_ci case AXP223_ID: 11248c2ecf20Sopenharmony_ci case AXP809_ID: 11258c2ecf20Sopenharmony_ci if (id < AXP22X_DCDC1 || id > AXP22X_DCDC5) 11268c2ecf20Sopenharmony_ci return -EINVAL; 11278c2ecf20Sopenharmony_ci 11288c2ecf20Sopenharmony_ci mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP22X_DCDC1); 11298c2ecf20Sopenharmony_ci workmode <<= id - AXP22X_DCDC1; 11308c2ecf20Sopenharmony_ci break; 11318c2ecf20Sopenharmony_ci 11328c2ecf20Sopenharmony_ci case AXP803_ID: 11338c2ecf20Sopenharmony_ci if (id < AXP803_DCDC1 || id > AXP803_DCDC6) 11348c2ecf20Sopenharmony_ci return -EINVAL; 11358c2ecf20Sopenharmony_ci 11368c2ecf20Sopenharmony_ci mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP803_DCDC1); 11378c2ecf20Sopenharmony_ci workmode <<= id - AXP803_DCDC1; 11388c2ecf20Sopenharmony_ci break; 11398c2ecf20Sopenharmony_ci 11408c2ecf20Sopenharmony_ci case AXP813_ID: 11418c2ecf20Sopenharmony_ci if (id < AXP813_DCDC1 || id > AXP813_DCDC7) 11428c2ecf20Sopenharmony_ci return -EINVAL; 11438c2ecf20Sopenharmony_ci 11448c2ecf20Sopenharmony_ci mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP813_DCDC1); 11458c2ecf20Sopenharmony_ci workmode <<= id - AXP813_DCDC1; 11468c2ecf20Sopenharmony_ci break; 11478c2ecf20Sopenharmony_ci 11488c2ecf20Sopenharmony_ci default: 11498c2ecf20Sopenharmony_ci /* should not happen */ 11508c2ecf20Sopenharmony_ci WARN_ON(1); 11518c2ecf20Sopenharmony_ci return -EINVAL; 11528c2ecf20Sopenharmony_ci } 11538c2ecf20Sopenharmony_ci 11548c2ecf20Sopenharmony_ci return regmap_update_bits(rdev->regmap, reg, mask, workmode); 11558c2ecf20Sopenharmony_ci} 11568c2ecf20Sopenharmony_ci 11578c2ecf20Sopenharmony_ci/* 11588c2ecf20Sopenharmony_ci * This function checks whether a regulator is part of a poly-phase 11598c2ecf20Sopenharmony_ci * output setup based on the registers settings. Returns true if it is. 11608c2ecf20Sopenharmony_ci */ 11618c2ecf20Sopenharmony_cistatic bool axp20x_is_polyphase_slave(struct axp20x_dev *axp20x, int id) 11628c2ecf20Sopenharmony_ci{ 11638c2ecf20Sopenharmony_ci u32 reg = 0; 11648c2ecf20Sopenharmony_ci 11658c2ecf20Sopenharmony_ci /* 11668c2ecf20Sopenharmony_ci * Currently in our supported AXP variants, only AXP803, AXP806, 11678c2ecf20Sopenharmony_ci * and AXP813 have polyphase regulators. 11688c2ecf20Sopenharmony_ci */ 11698c2ecf20Sopenharmony_ci switch (axp20x->variant) { 11708c2ecf20Sopenharmony_ci case AXP803_ID: 11718c2ecf20Sopenharmony_ci case AXP813_ID: 11728c2ecf20Sopenharmony_ci regmap_read(axp20x->regmap, AXP803_POLYPHASE_CTRL, ®); 11738c2ecf20Sopenharmony_ci 11748c2ecf20Sopenharmony_ci switch (id) { 11758c2ecf20Sopenharmony_ci case AXP803_DCDC3: 11768c2ecf20Sopenharmony_ci return !!(reg & AXP803_DCDC23_POLYPHASE_DUAL); 11778c2ecf20Sopenharmony_ci case AXP803_DCDC6: 11788c2ecf20Sopenharmony_ci return !!(reg & AXP803_DCDC56_POLYPHASE_DUAL); 11798c2ecf20Sopenharmony_ci } 11808c2ecf20Sopenharmony_ci break; 11818c2ecf20Sopenharmony_ci 11828c2ecf20Sopenharmony_ci case AXP806_ID: 11838c2ecf20Sopenharmony_ci regmap_read(axp20x->regmap, AXP806_DCDC_MODE_CTRL2, ®); 11848c2ecf20Sopenharmony_ci 11858c2ecf20Sopenharmony_ci switch (id) { 11868c2ecf20Sopenharmony_ci case AXP806_DCDCB: 11878c2ecf20Sopenharmony_ci return (((reg & AXP806_DCDCABC_POLYPHASE_MASK) == 11888c2ecf20Sopenharmony_ci AXP806_DCDCAB_POLYPHASE_DUAL) || 11898c2ecf20Sopenharmony_ci ((reg & AXP806_DCDCABC_POLYPHASE_MASK) == 11908c2ecf20Sopenharmony_ci AXP806_DCDCABC_POLYPHASE_TRI)); 11918c2ecf20Sopenharmony_ci case AXP806_DCDCC: 11928c2ecf20Sopenharmony_ci return ((reg & AXP806_DCDCABC_POLYPHASE_MASK) == 11938c2ecf20Sopenharmony_ci AXP806_DCDCABC_POLYPHASE_TRI); 11948c2ecf20Sopenharmony_ci case AXP806_DCDCE: 11958c2ecf20Sopenharmony_ci return !!(reg & AXP806_DCDCDE_POLYPHASE_DUAL); 11968c2ecf20Sopenharmony_ci } 11978c2ecf20Sopenharmony_ci break; 11988c2ecf20Sopenharmony_ci 11998c2ecf20Sopenharmony_ci default: 12008c2ecf20Sopenharmony_ci return false; 12018c2ecf20Sopenharmony_ci } 12028c2ecf20Sopenharmony_ci 12038c2ecf20Sopenharmony_ci return false; 12048c2ecf20Sopenharmony_ci} 12058c2ecf20Sopenharmony_ci 12068c2ecf20Sopenharmony_cistatic int axp20x_regulator_probe(struct platform_device *pdev) 12078c2ecf20Sopenharmony_ci{ 12088c2ecf20Sopenharmony_ci struct regulator_dev *rdev; 12098c2ecf20Sopenharmony_ci struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); 12108c2ecf20Sopenharmony_ci const struct regulator_desc *regulators; 12118c2ecf20Sopenharmony_ci struct regulator_config config = { 12128c2ecf20Sopenharmony_ci .dev = pdev->dev.parent, 12138c2ecf20Sopenharmony_ci .regmap = axp20x->regmap, 12148c2ecf20Sopenharmony_ci .driver_data = axp20x, 12158c2ecf20Sopenharmony_ci }; 12168c2ecf20Sopenharmony_ci int ret, i, nregulators; 12178c2ecf20Sopenharmony_ci u32 workmode; 12188c2ecf20Sopenharmony_ci const char *dcdc1_name = axp22x_regulators[AXP22X_DCDC1].name; 12198c2ecf20Sopenharmony_ci const char *dcdc5_name = axp22x_regulators[AXP22X_DCDC5].name; 12208c2ecf20Sopenharmony_ci bool drivevbus = false; 12218c2ecf20Sopenharmony_ci 12228c2ecf20Sopenharmony_ci switch (axp20x->variant) { 12238c2ecf20Sopenharmony_ci case AXP202_ID: 12248c2ecf20Sopenharmony_ci case AXP209_ID: 12258c2ecf20Sopenharmony_ci regulators = axp20x_regulators; 12268c2ecf20Sopenharmony_ci nregulators = AXP20X_REG_ID_MAX; 12278c2ecf20Sopenharmony_ci break; 12288c2ecf20Sopenharmony_ci case AXP221_ID: 12298c2ecf20Sopenharmony_ci case AXP223_ID: 12308c2ecf20Sopenharmony_ci regulators = axp22x_regulators; 12318c2ecf20Sopenharmony_ci nregulators = AXP22X_REG_ID_MAX; 12328c2ecf20Sopenharmony_ci drivevbus = of_property_read_bool(pdev->dev.parent->of_node, 12338c2ecf20Sopenharmony_ci "x-powers,drive-vbus-en"); 12348c2ecf20Sopenharmony_ci break; 12358c2ecf20Sopenharmony_ci case AXP803_ID: 12368c2ecf20Sopenharmony_ci regulators = axp803_regulators; 12378c2ecf20Sopenharmony_ci nregulators = AXP803_REG_ID_MAX; 12388c2ecf20Sopenharmony_ci drivevbus = of_property_read_bool(pdev->dev.parent->of_node, 12398c2ecf20Sopenharmony_ci "x-powers,drive-vbus-en"); 12408c2ecf20Sopenharmony_ci break; 12418c2ecf20Sopenharmony_ci case AXP806_ID: 12428c2ecf20Sopenharmony_ci regulators = axp806_regulators; 12438c2ecf20Sopenharmony_ci nregulators = AXP806_REG_ID_MAX; 12448c2ecf20Sopenharmony_ci break; 12458c2ecf20Sopenharmony_ci case AXP809_ID: 12468c2ecf20Sopenharmony_ci regulators = axp809_regulators; 12478c2ecf20Sopenharmony_ci nregulators = AXP809_REG_ID_MAX; 12488c2ecf20Sopenharmony_ci break; 12498c2ecf20Sopenharmony_ci case AXP813_ID: 12508c2ecf20Sopenharmony_ci regulators = axp813_regulators; 12518c2ecf20Sopenharmony_ci nregulators = AXP813_REG_ID_MAX; 12528c2ecf20Sopenharmony_ci drivevbus = of_property_read_bool(pdev->dev.parent->of_node, 12538c2ecf20Sopenharmony_ci "x-powers,drive-vbus-en"); 12548c2ecf20Sopenharmony_ci break; 12558c2ecf20Sopenharmony_ci default: 12568c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n", 12578c2ecf20Sopenharmony_ci axp20x->variant); 12588c2ecf20Sopenharmony_ci return -EINVAL; 12598c2ecf20Sopenharmony_ci } 12608c2ecf20Sopenharmony_ci 12618c2ecf20Sopenharmony_ci /* This only sets the dcdc freq. Ignore any errors */ 12628c2ecf20Sopenharmony_ci axp20x_regulator_parse_dt(pdev); 12638c2ecf20Sopenharmony_ci 12648c2ecf20Sopenharmony_ci for (i = 0; i < nregulators; i++) { 12658c2ecf20Sopenharmony_ci const struct regulator_desc *desc = ®ulators[i]; 12668c2ecf20Sopenharmony_ci struct regulator_desc *new_desc; 12678c2ecf20Sopenharmony_ci 12688c2ecf20Sopenharmony_ci /* 12698c2ecf20Sopenharmony_ci * If this regulator is a slave in a poly-phase setup, 12708c2ecf20Sopenharmony_ci * skip it, as its controls are bound to the master 12718c2ecf20Sopenharmony_ci * regulator and won't work. 12728c2ecf20Sopenharmony_ci */ 12738c2ecf20Sopenharmony_ci if (axp20x_is_polyphase_slave(axp20x, i)) 12748c2ecf20Sopenharmony_ci continue; 12758c2ecf20Sopenharmony_ci 12768c2ecf20Sopenharmony_ci /* Support for AXP813's FLDO3 is not implemented */ 12778c2ecf20Sopenharmony_ci if (axp20x->variant == AXP813_ID && i == AXP813_FLDO3) 12788c2ecf20Sopenharmony_ci continue; 12798c2ecf20Sopenharmony_ci 12808c2ecf20Sopenharmony_ci /* 12818c2ecf20Sopenharmony_ci * Regulators DC1SW and DC5LDO are connected internally, 12828c2ecf20Sopenharmony_ci * so we have to handle their supply names separately. 12838c2ecf20Sopenharmony_ci * 12848c2ecf20Sopenharmony_ci * We always register the regulators in proper sequence, 12858c2ecf20Sopenharmony_ci * so the supply names are correctly read. See the last 12868c2ecf20Sopenharmony_ci * part of this loop to see where we save the DT defined 12878c2ecf20Sopenharmony_ci * name. 12888c2ecf20Sopenharmony_ci */ 12898c2ecf20Sopenharmony_ci if ((regulators == axp22x_regulators && i == AXP22X_DC1SW) || 12908c2ecf20Sopenharmony_ci (regulators == axp803_regulators && i == AXP803_DC1SW) || 12918c2ecf20Sopenharmony_ci (regulators == axp809_regulators && i == AXP809_DC1SW)) { 12928c2ecf20Sopenharmony_ci new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc), 12938c2ecf20Sopenharmony_ci GFP_KERNEL); 12948c2ecf20Sopenharmony_ci if (!new_desc) 12958c2ecf20Sopenharmony_ci return -ENOMEM; 12968c2ecf20Sopenharmony_ci 12978c2ecf20Sopenharmony_ci *new_desc = regulators[i]; 12988c2ecf20Sopenharmony_ci new_desc->supply_name = dcdc1_name; 12998c2ecf20Sopenharmony_ci desc = new_desc; 13008c2ecf20Sopenharmony_ci } 13018c2ecf20Sopenharmony_ci 13028c2ecf20Sopenharmony_ci if ((regulators == axp22x_regulators && i == AXP22X_DC5LDO) || 13038c2ecf20Sopenharmony_ci (regulators == axp809_regulators && i == AXP809_DC5LDO)) { 13048c2ecf20Sopenharmony_ci new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc), 13058c2ecf20Sopenharmony_ci GFP_KERNEL); 13068c2ecf20Sopenharmony_ci if (!new_desc) 13078c2ecf20Sopenharmony_ci return -ENOMEM; 13088c2ecf20Sopenharmony_ci 13098c2ecf20Sopenharmony_ci *new_desc = regulators[i]; 13108c2ecf20Sopenharmony_ci new_desc->supply_name = dcdc5_name; 13118c2ecf20Sopenharmony_ci desc = new_desc; 13128c2ecf20Sopenharmony_ci } 13138c2ecf20Sopenharmony_ci 13148c2ecf20Sopenharmony_ci rdev = devm_regulator_register(&pdev->dev, desc, &config); 13158c2ecf20Sopenharmony_ci if (IS_ERR(rdev)) { 13168c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "Failed to register %s\n", 13178c2ecf20Sopenharmony_ci regulators[i].name); 13188c2ecf20Sopenharmony_ci 13198c2ecf20Sopenharmony_ci return PTR_ERR(rdev); 13208c2ecf20Sopenharmony_ci } 13218c2ecf20Sopenharmony_ci 13228c2ecf20Sopenharmony_ci ret = of_property_read_u32(rdev->dev.of_node, 13238c2ecf20Sopenharmony_ci "x-powers,dcdc-workmode", 13248c2ecf20Sopenharmony_ci &workmode); 13258c2ecf20Sopenharmony_ci if (!ret) { 13268c2ecf20Sopenharmony_ci if (axp20x_set_dcdc_workmode(rdev, i, workmode)) 13278c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "Failed to set workmode on %s\n", 13288c2ecf20Sopenharmony_ci rdev->desc->name); 13298c2ecf20Sopenharmony_ci } 13308c2ecf20Sopenharmony_ci 13318c2ecf20Sopenharmony_ci /* 13328c2ecf20Sopenharmony_ci * Save AXP22X DCDC1 / DCDC5 regulator names for later. 13338c2ecf20Sopenharmony_ci */ 13348c2ecf20Sopenharmony_ci if ((regulators == axp22x_regulators && i == AXP22X_DCDC1) || 13358c2ecf20Sopenharmony_ci (regulators == axp809_regulators && i == AXP809_DCDC1)) 13368c2ecf20Sopenharmony_ci of_property_read_string(rdev->dev.of_node, 13378c2ecf20Sopenharmony_ci "regulator-name", 13388c2ecf20Sopenharmony_ci &dcdc1_name); 13398c2ecf20Sopenharmony_ci 13408c2ecf20Sopenharmony_ci if ((regulators == axp22x_regulators && i == AXP22X_DCDC5) || 13418c2ecf20Sopenharmony_ci (regulators == axp809_regulators && i == AXP809_DCDC5)) 13428c2ecf20Sopenharmony_ci of_property_read_string(rdev->dev.of_node, 13438c2ecf20Sopenharmony_ci "regulator-name", 13448c2ecf20Sopenharmony_ci &dcdc5_name); 13458c2ecf20Sopenharmony_ci } 13468c2ecf20Sopenharmony_ci 13478c2ecf20Sopenharmony_ci if (drivevbus) { 13488c2ecf20Sopenharmony_ci /* Change N_VBUSEN sense pin to DRIVEVBUS output pin */ 13498c2ecf20Sopenharmony_ci regmap_update_bits(axp20x->regmap, AXP20X_OVER_TMP, 13508c2ecf20Sopenharmony_ci AXP22X_MISC_N_VBUSEN_FUNC, 0); 13518c2ecf20Sopenharmony_ci rdev = devm_regulator_register(&pdev->dev, 13528c2ecf20Sopenharmony_ci &axp22x_drivevbus_regulator, 13538c2ecf20Sopenharmony_ci &config); 13548c2ecf20Sopenharmony_ci if (IS_ERR(rdev)) { 13558c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "Failed to register drivevbus\n"); 13568c2ecf20Sopenharmony_ci return PTR_ERR(rdev); 13578c2ecf20Sopenharmony_ci } 13588c2ecf20Sopenharmony_ci } 13598c2ecf20Sopenharmony_ci 13608c2ecf20Sopenharmony_ci return 0; 13618c2ecf20Sopenharmony_ci} 13628c2ecf20Sopenharmony_ci 13638c2ecf20Sopenharmony_cistatic struct platform_driver axp20x_regulator_driver = { 13648c2ecf20Sopenharmony_ci .probe = axp20x_regulator_probe, 13658c2ecf20Sopenharmony_ci .driver = { 13668c2ecf20Sopenharmony_ci .name = "axp20x-regulator", 13678c2ecf20Sopenharmony_ci }, 13688c2ecf20Sopenharmony_ci}; 13698c2ecf20Sopenharmony_ci 13708c2ecf20Sopenharmony_cimodule_platform_driver(axp20x_regulator_driver); 13718c2ecf20Sopenharmony_ci 13728c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 13738c2ecf20Sopenharmony_ciMODULE_AUTHOR("Carlo Caione <carlo@caione.org>"); 13748c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Regulator Driver for AXP20X PMIC"); 13758c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:axp20x-regulator"); 1376