Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Voltage regulator support for AMS AS3722 PMIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2013 ams
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Author: Florian Lobmaier <florian.lobmaier@ams.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Author: Laxman Dewangan <ldewangan@nvidia.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/mfd/as3722.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/of_platform.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/regulator/driver.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/regulator/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/regulator/of_regulator.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) /* Regulator IDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) enum as3722_regulators_id {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	AS3722_REGULATOR_ID_SD0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	AS3722_REGULATOR_ID_SD1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	AS3722_REGULATOR_ID_SD2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	AS3722_REGULATOR_ID_SD3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	AS3722_REGULATOR_ID_SD4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	AS3722_REGULATOR_ID_SD5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	AS3722_REGULATOR_ID_SD6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	AS3722_REGULATOR_ID_LDO0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	AS3722_REGULATOR_ID_LDO1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	AS3722_REGULATOR_ID_LDO2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	AS3722_REGULATOR_ID_LDO3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	AS3722_REGULATOR_ID_LDO4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	AS3722_REGULATOR_ID_LDO5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	AS3722_REGULATOR_ID_LDO6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	AS3722_REGULATOR_ID_LDO7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	AS3722_REGULATOR_ID_LDO9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	AS3722_REGULATOR_ID_LDO10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	AS3722_REGULATOR_ID_LDO11,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	AS3722_REGULATOR_ID_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) struct as3722_register_mapping {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	u8 regulator_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	const char *sname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	u8 vsel_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	u8 vsel_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	int n_voltages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	u32 enable_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	u8 enable_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	u32 control_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	u8 mode_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	u32 sleep_ctrl_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	u8 sleep_ctrl_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) struct as3722_regulator_config_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct regulator_init_data *reg_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	bool enable_tracking;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	int ext_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) struct as3722_regulators {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	struct as3722 *as3722;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	struct regulator_desc desc[AS3722_REGULATOR_ID_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	struct as3722_regulator_config_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			reg_config_data[AS3722_REGULATOR_ID_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static const struct as3722_register_mapping as3722_reg_lookup[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		.regulator_id = AS3722_REGULATOR_ID_SD0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		.name = "as3722-sd0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		.vsel_reg = AS3722_SD0_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		.vsel_mask = AS3722_SD_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		.enable_reg = AS3722_SD_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		.enable_mask = AS3722_SDn_CTRL(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		.sleep_ctrl_mask = AS3722_SD0_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		.control_reg = AS3722_SD0_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		.mode_mask = AS3722_SD0_MODE_FAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		.regulator_id = AS3722_REGULATOR_ID_SD1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		.name = "as3722-sd1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		.vsel_reg = AS3722_SD1_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		.vsel_mask = AS3722_SD_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		.enable_reg = AS3722_SD_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		.enable_mask = AS3722_SDn_CTRL(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		.sleep_ctrl_mask = AS3722_SD1_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		.control_reg = AS3722_SD1_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		.mode_mask = AS3722_SD1_MODE_FAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		.regulator_id = AS3722_REGULATOR_ID_SD2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		.name = "as3722-sd2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		.sname = "vsup-sd2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		.vsel_reg = AS3722_SD2_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		.vsel_mask = AS3722_SD_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		.enable_reg = AS3722_SD_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		.enable_mask = AS3722_SDn_CTRL(2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		.sleep_ctrl_mask = AS3722_SD2_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		.control_reg = AS3722_SD23_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		.mode_mask = AS3722_SD2_MODE_FAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		.n_voltages = AS3722_SD2_VSEL_MAX + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		.regulator_id = AS3722_REGULATOR_ID_SD3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		.name = "as3722-sd3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		.sname = "vsup-sd3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		.vsel_reg = AS3722_SD3_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		.vsel_mask = AS3722_SD_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		.enable_reg = AS3722_SD_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		.enable_mask = AS3722_SDn_CTRL(3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		.sleep_ctrl_mask = AS3722_SD3_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		.control_reg = AS3722_SD23_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		.mode_mask = AS3722_SD3_MODE_FAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		.n_voltages = AS3722_SD2_VSEL_MAX + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		.regulator_id = AS3722_REGULATOR_ID_SD4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		.name = "as3722-sd4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		.sname = "vsup-sd4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		.vsel_reg = AS3722_SD4_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		.vsel_mask = AS3722_SD_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		.enable_reg = AS3722_SD_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		.enable_mask = AS3722_SDn_CTRL(4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL2_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		.sleep_ctrl_mask = AS3722_SD4_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		.control_reg = AS3722_SD4_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		.mode_mask = AS3722_SD4_MODE_FAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		.n_voltages = AS3722_SD2_VSEL_MAX + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		.regulator_id = AS3722_REGULATOR_ID_SD5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		.name = "as3722-sd5",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		.sname = "vsup-sd5",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		.vsel_reg = AS3722_SD5_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		.vsel_mask = AS3722_SD_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		.enable_reg = AS3722_SD_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		.enable_mask = AS3722_SDn_CTRL(5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL2_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		.sleep_ctrl_mask = AS3722_SD5_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		.control_reg = AS3722_SD5_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		.mode_mask = AS3722_SD5_MODE_FAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		.n_voltages = AS3722_SD2_VSEL_MAX + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		.regulator_id = AS3722_REGULATOR_ID_SD6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		.name = "as3722-sd6",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		.vsel_reg = AS3722_SD6_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		.vsel_mask = AS3722_SD_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		.enable_reg = AS3722_SD_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		.enable_mask = AS3722_SDn_CTRL(6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL2_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		.sleep_ctrl_mask = AS3722_SD6_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		.control_reg = AS3722_SD6_CONTROL_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		.mode_mask = AS3722_SD6_MODE_FAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		.regulator_id = AS3722_REGULATOR_ID_LDO0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		.name = "as3722-ldo0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		.sname = "vin-ldo0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		.vsel_reg = AS3722_LDO0_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		.vsel_mask = AS3722_LDO0_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		.enable_reg = AS3722_LDOCONTROL0_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		.enable_mask = AS3722_LDO0_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		.sleep_ctrl_mask = AS3722_LDO0_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		.n_voltages = AS3722_LDO0_NUM_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		.regulator_id = AS3722_REGULATOR_ID_LDO1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		.name = "as3722-ldo1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		.sname = "vin-ldo1-6",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		.vsel_reg = AS3722_LDO1_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		.vsel_mask = AS3722_LDO_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		.enable_reg = AS3722_LDOCONTROL0_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		.enable_mask = AS3722_LDO1_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		.sleep_ctrl_mask = AS3722_LDO1_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		.n_voltages = AS3722_LDO_NUM_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		.regulator_id = AS3722_REGULATOR_ID_LDO2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		.name = "as3722-ldo2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		.sname = "vin-ldo2-5-7",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		.vsel_reg = AS3722_LDO2_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		.vsel_mask = AS3722_LDO_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		.enable_reg = AS3722_LDOCONTROL0_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		.enable_mask = AS3722_LDO2_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		.sleep_ctrl_mask = AS3722_LDO2_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		.n_voltages = AS3722_LDO_NUM_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		.regulator_id = AS3722_REGULATOR_ID_LDO3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		.name = "as3722-ldo3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		.sname = "vin-ldo3-4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		.vsel_reg = AS3722_LDO3_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		.vsel_mask = AS3722_LDO3_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		.enable_reg = AS3722_LDOCONTROL0_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		.enable_mask = AS3722_LDO3_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		.sleep_ctrl_mask = AS3722_LDO3_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		.n_voltages = AS3722_LDO3_NUM_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		.regulator_id = AS3722_REGULATOR_ID_LDO4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		.name = "as3722-ldo4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		.sname = "vin-ldo3-4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		.vsel_reg = AS3722_LDO4_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		.vsel_mask = AS3722_LDO_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		.enable_reg = AS3722_LDOCONTROL0_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		.enable_mask = AS3722_LDO4_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		.sleep_ctrl_mask = AS3722_LDO4_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		.n_voltages = AS3722_LDO_NUM_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		.regulator_id = AS3722_REGULATOR_ID_LDO5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		.name = "as3722-ldo5",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		.sname = "vin-ldo2-5-7",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		.vsel_reg = AS3722_LDO5_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		.vsel_mask = AS3722_LDO_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		.enable_reg = AS3722_LDOCONTROL0_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		.enable_mask = AS3722_LDO5_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		.sleep_ctrl_mask = AS3722_LDO5_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		.n_voltages = AS3722_LDO_NUM_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		.regulator_id = AS3722_REGULATOR_ID_LDO6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		.name = "as3722-ldo6",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		.sname = "vin-ldo1-6",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		.vsel_reg = AS3722_LDO6_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		.vsel_mask = AS3722_LDO_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		.enable_reg = AS3722_LDOCONTROL0_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		.enable_mask = AS3722_LDO6_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		.sleep_ctrl_mask = AS3722_LDO6_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		.n_voltages = AS3722_LDO_NUM_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		.regulator_id = AS3722_REGULATOR_ID_LDO7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		.name = "as3722-ldo7",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		.sname = "vin-ldo2-5-7",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		.vsel_reg = AS3722_LDO7_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		.vsel_mask = AS3722_LDO_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		.enable_reg = AS3722_LDOCONTROL0_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		.enable_mask = AS3722_LDO7_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		.sleep_ctrl_mask = AS3722_LDO7_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		.n_voltages = AS3722_LDO_NUM_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		.regulator_id = AS3722_REGULATOR_ID_LDO9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		.name = "as3722-ldo9",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		.sname = "vin-ldo9-10",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		.vsel_reg = AS3722_LDO9_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		.vsel_mask = AS3722_LDO_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		.enable_reg = AS3722_LDOCONTROL1_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		.enable_mask = AS3722_LDO9_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL5_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		.sleep_ctrl_mask = AS3722_LDO9_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		.n_voltages = AS3722_LDO_NUM_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		.regulator_id = AS3722_REGULATOR_ID_LDO10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		.name = "as3722-ldo10",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		.sname = "vin-ldo9-10",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		.vsel_reg = AS3722_LDO10_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		.vsel_mask = AS3722_LDO_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		.enable_reg = AS3722_LDOCONTROL1_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		.enable_mask = AS3722_LDO10_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL5_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		.sleep_ctrl_mask = AS3722_LDO10_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		.n_voltages = AS3722_LDO_NUM_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		.regulator_id = AS3722_REGULATOR_ID_LDO11,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		.name = "as3722-ldo11",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		.sname = "vin-ldo11",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		.vsel_reg = AS3722_LDO11_VOLTAGE_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		.vsel_mask = AS3722_LDO_VSEL_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		.enable_reg = AS3722_LDOCONTROL1_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		.enable_mask = AS3722_LDO11_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		.sleep_ctrl_reg = AS3722_ENABLE_CTRL5_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		.sleep_ctrl_mask = AS3722_LDO11_EXT_ENABLE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		.n_voltages = AS3722_LDO_NUM_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) static const unsigned int as3722_ldo_current[] = { 150000, 300000 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) static const unsigned int as3722_sd016_current[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	2500000, 3000000, 3500000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) static const struct regulator_ops as3722_ldo0_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	.is_enabled = regulator_is_enabled_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	.enable = regulator_enable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	.disable = regulator_disable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	.list_voltage = regulator_list_voltage_linear,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	.get_current_limit = regulator_get_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	.set_current_limit = regulator_set_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) static const struct regulator_ops as3722_ldo0_extcntrl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	.list_voltage = regulator_list_voltage_linear,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	.get_current_limit = regulator_get_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	.set_current_limit = regulator_set_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) static int as3722_ldo3_set_tracking_mode(struct as3722_regulators *as3722_reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		int id, u8 mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	struct as3722 *as3722 = as3722_reg->as3722;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	switch (mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	case AS3722_LDO3_MODE_PMOS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	case AS3722_LDO3_MODE_PMOS_TRACKING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	case AS3722_LDO3_MODE_NMOS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	case AS3722_LDO3_MODE_SWITCH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		return as3722_update_bits(as3722,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 			as3722_reg_lookup[id].vsel_reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 			AS3722_LDO3_MODE_MASK, mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) static int as3722_ldo3_get_current_limit(struct regulator_dev *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	return 150000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) static const struct regulator_ops as3722_ldo3_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	.is_enabled = regulator_is_enabled_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	.enable = regulator_enable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	.disable = regulator_disable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	.list_voltage = regulator_list_voltage_linear,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	.get_current_limit = as3722_ldo3_get_current_limit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) static const struct regulator_ops as3722_ldo3_extcntrl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	.list_voltage = regulator_list_voltage_linear,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	.get_current_limit = as3722_ldo3_get_current_limit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) static const struct regulator_ops as3722_ldo6_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	.is_enabled = regulator_is_enabled_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	.enable = regulator_enable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	.disable = regulator_disable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	.map_voltage = regulator_map_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	.list_voltage = regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	.get_current_limit = regulator_get_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	.set_current_limit = regulator_set_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	.get_bypass = regulator_get_bypass_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	.set_bypass = regulator_set_bypass_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) static const struct regulator_ops as3722_ldo6_extcntrl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	.map_voltage = regulator_map_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	.list_voltage = regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	.get_current_limit = regulator_get_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	.set_current_limit = regulator_set_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	.get_bypass = regulator_get_bypass_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	.set_bypass = regulator_set_bypass_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) static const struct linear_range as3722_ldo_ranges[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	REGULATOR_LINEAR_RANGE(0, 0x00, 0x00, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	REGULATOR_LINEAR_RANGE(825000, 0x01, 0x24, 25000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	REGULATOR_LINEAR_RANGE(1725000, 0x40, 0x7F, 25000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) static const struct regulator_ops as3722_ldo_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	.is_enabled = regulator_is_enabled_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	.enable = regulator_enable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	.disable = regulator_disable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	.map_voltage = regulator_map_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	.list_voltage = regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	.get_current_limit = regulator_get_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	.set_current_limit = regulator_set_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) static const struct regulator_ops as3722_ldo_extcntrl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	.map_voltage = regulator_map_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	.list_voltage = regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	.get_current_limit = regulator_get_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	.set_current_limit = regulator_set_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) static unsigned int as3722_sd_get_mode(struct regulator_dev *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	struct as3722 *as3722 = as3722_regs->as3722;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	int id = rdev_get_id(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	if (!as3722_reg_lookup[id].control_reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 		return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	ret = as3722_read(as3722, as3722_reg_lookup[id].control_reg, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 		dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 			as3722_reg_lookup[id].control_reg, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	if (val & as3722_reg_lookup[id].mode_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		return REGULATOR_MODE_FAST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 		return REGULATOR_MODE_NORMAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) static int as3722_sd_set_mode(struct regulator_dev *rdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		unsigned int mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	struct as3722 *as3722 = as3722_regs->as3722;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	u8 id = rdev_get_id(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	u8 val = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	if (!as3722_reg_lookup[id].control_reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 		return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	switch (mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	case REGULATOR_MODE_FAST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 		val = as3722_reg_lookup[id].mode_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	case REGULATOR_MODE_NORMAL: /* fall down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	ret = as3722_update_bits(as3722, as3722_reg_lookup[id].control_reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 			as3722_reg_lookup[id].mode_mask, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		dev_err(as3722_regs->dev, "Reg 0x%02x update failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 			as3722_reg_lookup[id].control_reg, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) static bool as3722_sd0_is_low_voltage(struct as3722_regulators *as3722_regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	unsigned val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	err = as3722_read(as3722_regs->as3722, AS3722_FUSE7_REG, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 		dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 			AS3722_FUSE7_REG, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	if (val & AS3722_FUSE7_SD0_LOW_VOLTAGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) static const struct linear_range as3722_sd2345_ranges[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	REGULATOR_LINEAR_RANGE(0, 0x00, 0x00, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7F, 50000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) static const struct regulator_ops as3722_sd016_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	.is_enabled = regulator_is_enabled_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	.enable = regulator_enable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	.disable = regulator_disable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	.list_voltage = regulator_list_voltage_linear,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	.map_voltage = regulator_map_voltage_linear,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	.get_current_limit = regulator_get_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	.set_current_limit = regulator_set_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	.get_mode = as3722_sd_get_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	.set_mode = as3722_sd_set_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) static const struct regulator_ops as3722_sd016_extcntrl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	.list_voltage = regulator_list_voltage_linear,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	.map_voltage = regulator_map_voltage_linear,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	.get_current_limit = regulator_get_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	.set_current_limit = regulator_set_current_limit_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	.get_mode = as3722_sd_get_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	.set_mode = as3722_sd_set_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) static const struct regulator_ops as3722_sd2345_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	.is_enabled = regulator_is_enabled_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 	.enable = regulator_enable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	.disable = regulator_disable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	.list_voltage = regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	.map_voltage = regulator_map_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	.get_mode = as3722_sd_get_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	.set_mode = as3722_sd_set_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) static const struct regulator_ops as3722_sd2345_extcntrl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 	.list_voltage = regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 	.map_voltage = regulator_map_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	.get_mode = as3722_sd_get_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	.set_mode = as3722_sd_set_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) static int as3722_extreg_init(struct as3722_regulators *as3722_regs, int id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 		int ext_pwr_ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 	unsigned int val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	if ((ext_pwr_ctrl < AS3722_EXT_CONTROL_ENABLE1) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 		(ext_pwr_ctrl > AS3722_EXT_CONTROL_ENABLE3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	val =  ext_pwr_ctrl << (ffs(as3722_reg_lookup[id].sleep_ctrl_mask) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	ret = as3722_update_bits(as3722_regs->as3722,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 			as3722_reg_lookup[id].sleep_ctrl_reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 			as3722_reg_lookup[id].sleep_ctrl_mask, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 		dev_err(as3722_regs->dev, "Reg 0x%02x update failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 			as3722_reg_lookup[id].sleep_ctrl_reg, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) static struct of_regulator_match as3722_regulator_matches[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	{ .name = "sd0", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	{ .name = "sd1", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	{ .name = "sd2", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 	{ .name = "sd3", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	{ .name = "sd4", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	{ .name = "sd5", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	{ .name = "sd6", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	{ .name = "ldo0", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	{ .name = "ldo1", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 	{ .name = "ldo2", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 	{ .name = "ldo3", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	{ .name = "ldo4", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 	{ .name = "ldo5", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	{ .name = "ldo6", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	{ .name = "ldo7", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	{ .name = "ldo9", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	{ .name = "ldo10", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	{ .name = "ldo11", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) static int as3722_get_regulator_dt_data(struct platform_device *pdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 		struct as3722_regulators *as3722_regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 	struct device_node *np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	struct as3722_regulator_config_data *reg_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	u32 prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	np = of_get_child_by_name(pdev->dev.parent->of_node, "regulators");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	if (!np) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 		dev_err(&pdev->dev, "Device is not having regulators node\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	pdev->dev.of_node = np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 	ret = of_regulator_match(&pdev->dev, np, as3722_regulator_matches,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 			ARRAY_SIZE(as3722_regulator_matches));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 	of_node_put(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 		dev_err(&pdev->dev, "Parsing of regulator node failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	for (id = 0; id < ARRAY_SIZE(as3722_regulator_matches); ++id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 		struct device_node *reg_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 		reg_config = &as3722_regs->reg_config_data[id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 		reg_config->reg_init = as3722_regulator_matches[id].init_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 		reg_node = as3722_regulator_matches[id].of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 		if (!reg_config->reg_init || !reg_node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 		ret = of_property_read_u32(reg_node, "ams,ext-control", &prop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 		if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 			if (prop < 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 				reg_config->ext_control = prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 				dev_warn(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 					"ext-control have invalid option: %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 					prop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 		reg_config->enable_tracking =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 			of_property_read_bool(reg_node, "ams,enable-tracking");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) static int as3722_regulator_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 	struct as3722 *as3722 = dev_get_drvdata(pdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	struct as3722_regulators *as3722_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 	struct as3722_regulator_config_data *reg_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 	struct regulator_dev *rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 	struct regulator_config config = { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	const struct regulator_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	as3722_regs = devm_kzalloc(&pdev->dev, sizeof(*as3722_regs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 				GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	if (!as3722_regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	as3722_regs->dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 	as3722_regs->as3722 = as3722;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 	platform_set_drvdata(pdev, as3722_regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	ret = as3722_get_regulator_dt_data(pdev, as3722_regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	config.dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 	config.driver_data = as3722_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	config.regmap = as3722->regmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	for (id = 0; id < AS3722_REGULATOR_ID_MAX; id++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 		struct regulator_desc *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 		desc = &as3722_regs->desc[id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 		reg_config = &as3722_regs->reg_config_data[id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 		desc->name = as3722_reg_lookup[id].name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 		desc->supply_name = as3722_reg_lookup[id].sname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 		desc->id = as3722_reg_lookup[id].regulator_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 		desc->n_voltages = as3722_reg_lookup[id].n_voltages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 		desc->type = REGULATOR_VOLTAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 		desc->owner = THIS_MODULE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 		desc->enable_reg = as3722_reg_lookup[id].enable_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 		desc->enable_mask = as3722_reg_lookup[id].enable_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 		desc->vsel_reg = as3722_reg_lookup[id].vsel_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 		desc->vsel_mask = as3722_reg_lookup[id].vsel_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 		switch (id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 		case AS3722_REGULATOR_ID_LDO0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 			if (reg_config->ext_control)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 				ops = &as3722_ldo0_extcntrl_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 				ops = &as3722_ldo0_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 			desc->min_uV = 825000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 			desc->uV_step = 25000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 			desc->linear_min_sel = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 			desc->enable_time = 500;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 			desc->curr_table = as3722_ldo_current;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 			desc->n_current_limits = ARRAY_SIZE(as3722_ldo_current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 			desc->csel_reg = as3722_reg_lookup[id].vsel_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 			desc->csel_mask = AS3722_LDO_ILIMIT_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 		case AS3722_REGULATOR_ID_LDO3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 			if (reg_config->ext_control)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 				ops = &as3722_ldo3_extcntrl_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 				ops = &as3722_ldo3_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 			desc->min_uV = 620000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 			desc->uV_step = 20000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 			desc->linear_min_sel = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 			desc->enable_time = 500;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 			if (reg_config->enable_tracking) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 				ret = as3722_ldo3_set_tracking_mode(as3722_regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 					id, AS3722_LDO3_MODE_PMOS_TRACKING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 				if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 					dev_err(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 						"LDO3 tracking failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 						ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 					return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 		case AS3722_REGULATOR_ID_LDO6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 			if (reg_config->ext_control)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 				ops = &as3722_ldo6_extcntrl_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 				ops = &as3722_ldo6_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 			desc->enable_time = 500;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 			desc->bypass_reg = AS3722_LDO6_VOLTAGE_REG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 			desc->bypass_mask = AS3722_LDO_VSEL_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 			desc->bypass_val_on = AS3722_LDO6_VSEL_BYPASS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 			desc->bypass_val_off = AS3722_LDO6_VSEL_BYPASS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 			desc->linear_ranges = as3722_ldo_ranges;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 			desc->n_linear_ranges = ARRAY_SIZE(as3722_ldo_ranges);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 			desc->curr_table = as3722_ldo_current;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 			desc->n_current_limits = ARRAY_SIZE(as3722_ldo_current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 			desc->csel_reg = as3722_reg_lookup[id].vsel_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 			desc->csel_mask = AS3722_LDO_ILIMIT_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 		case AS3722_REGULATOR_ID_SD0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 		case AS3722_REGULATOR_ID_SD1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 		case AS3722_REGULATOR_ID_SD6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 			if (reg_config->ext_control)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) 				ops = &as3722_sd016_extcntrl_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 				ops = &as3722_sd016_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 			if (id == AS3722_REGULATOR_ID_SD0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 			    as3722_sd0_is_low_voltage(as3722_regs)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 				as3722_regs->desc[id].n_voltages =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 					AS3722_SD0_VSEL_LOW_VOL_MAX + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 				as3722_regs->desc[id].min_uV = 410000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) 				as3722_regs->desc[id].n_voltages =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) 					AS3722_SD0_VSEL_MAX + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) 				as3722_regs->desc[id].min_uV = 610000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 			desc->uV_step = 10000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) 			desc->linear_min_sel = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 			desc->enable_time = 600;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) 			desc->curr_table = as3722_sd016_current;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) 			desc->n_current_limits =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) 				ARRAY_SIZE(as3722_sd016_current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) 			if (id == AS3722_REGULATOR_ID_SD0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) 				desc->csel_reg = AS3722_OVCURRENT_REG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) 				desc->csel_mask =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) 					AS3722_OVCURRENT_SD0_TRIP_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) 			} else if (id == AS3722_REGULATOR_ID_SD1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) 				desc->csel_reg = AS3722_OVCURRENT_REG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) 				desc->csel_mask =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) 					AS3722_OVCURRENT_SD1_TRIP_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) 			} else if (id == AS3722_REGULATOR_ID_SD6) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) 				desc->csel_reg = AS3722_OVCURRENT_DEB_REG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) 				desc->csel_mask =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) 					AS3722_OVCURRENT_SD6_TRIP_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) 		case AS3722_REGULATOR_ID_SD2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) 		case AS3722_REGULATOR_ID_SD3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) 		case AS3722_REGULATOR_ID_SD4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) 		case AS3722_REGULATOR_ID_SD5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) 			if (reg_config->ext_control)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) 				ops = &as3722_sd2345_extcntrl_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) 				ops = &as3722_sd2345_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) 			desc->linear_ranges = as3722_sd2345_ranges;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) 			desc->n_linear_ranges =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) 					ARRAY_SIZE(as3722_sd2345_ranges);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) 			if (reg_config->ext_control)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) 				ops = &as3722_ldo_extcntrl_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) 				ops = &as3722_ldo_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) 			desc->enable_time = 500;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) 			desc->linear_ranges = as3722_ldo_ranges;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) 			desc->n_linear_ranges = ARRAY_SIZE(as3722_ldo_ranges);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) 			desc->curr_table = as3722_ldo_current;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) 			desc->n_current_limits = ARRAY_SIZE(as3722_ldo_current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) 			desc->csel_reg = as3722_reg_lookup[id].vsel_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) 			desc->csel_mask = AS3722_LDO_ILIMIT_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) 		desc->ops = ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) 		config.init_data = reg_config->reg_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) 		config.of_node = as3722_regulator_matches[id].of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) 		rdev = devm_regulator_register(&pdev->dev, desc, &config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) 		if (IS_ERR(rdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) 			ret = PTR_ERR(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) 			dev_err(&pdev->dev, "regulator %d register failed %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) 				id, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) 		if (reg_config->ext_control) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) 			ret = regulator_enable_regmap(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) 			if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) 				dev_err(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) 					"Regulator %d enable failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 					id, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) 				return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) 			ret = as3722_extreg_init(as3722_regs, id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) 					reg_config->ext_control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) 			if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) 				dev_err(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) 					"AS3722 ext control failed: %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) 				return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) static const struct of_device_id of_as3722_regulator_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) 	{ .compatible = "ams,as3722-regulator", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) 	{},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) MODULE_DEVICE_TABLE(of, of_as3722_regulator_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) static struct platform_driver as3722_regulator_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) 		.name = "as3722-regulator",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) 		.of_match_table = of_as3722_regulator_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) 	.probe = as3722_regulator_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) module_platform_driver(as3722_regulator_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) MODULE_ALIAS("platform:as3722-regulator");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) MODULE_DESCRIPTION("AS3722 regulator driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) MODULE_AUTHOR("Florian Lobmaier <florian.lobmaier@ams.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) MODULE_LICENSE("GPL");