Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1 | /* |
| 2 | * AXP20x regulators driver. |
| 3 | * |
| 4 | * Copyright (C) 2013 Carlo Caione <carlo@caione.org> |
| 5 | * |
| 6 | * This file is subject to the terms and conditions of the GNU General |
| 7 | * Public License. See the file "COPYING" in the main directory of this |
| 8 | * archive for more details. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 16 | #include <linux/bitops.h> |
Olliver Schinagl | 77e3e3b | 2018-12-11 17:17:08 +0200 | [diff] [blame^] | 17 | #include <linux/delay.h> |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 18 | #include <linux/err.h> |
| 19 | #include <linux/init.h> |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 20 | #include <linux/mfd/axp20x.h> |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 21 | #include <linux/module.h> |
| 22 | #include <linux/of.h> |
| 23 | #include <linux/of_device.h> |
| 24 | #include <linux/platform_device.h> |
| 25 | #include <linux/regmap.h> |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 26 | #include <linux/regulator/driver.h> |
Olliver Schinagl | 77e3e3b | 2018-12-11 17:17:08 +0200 | [diff] [blame^] | 27 | #include <linux/regulator/machine.h> |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 28 | #include <linux/regulator/of_regulator.h> |
| 29 | |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 30 | #define AXP20X_GPIO0_FUNC_MASK GENMASK(3, 0) |
| 31 | #define AXP20X_GPIO1_FUNC_MASK GENMASK(3, 0) |
| 32 | |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 33 | #define AXP20X_IO_ENABLED 0x03 |
| 34 | #define AXP20X_IO_DISABLED 0x07 |
| 35 | |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 36 | #define AXP20X_WORKMODE_DCDC2_MASK BIT_MASK(2) |
| 37 | #define AXP20X_WORKMODE_DCDC3_MASK BIT_MASK(1) |
| 38 | |
| 39 | #define AXP20X_FREQ_DCDC_MASK GENMASK(3, 0) |
| 40 | |
| 41 | #define AXP20X_VBUS_IPSOUT_MGMT_MASK BIT_MASK(2) |
| 42 | |
| 43 | #define AXP20X_DCDC2_V_OUT_MASK GENMASK(5, 0) |
| 44 | #define AXP20X_DCDC3_V_OUT_MASK GENMASK(7, 0) |
| 45 | #define AXP20X_LDO24_V_OUT_MASK GENMASK(7, 4) |
| 46 | #define AXP20X_LDO3_V_OUT_MASK GENMASK(6, 0) |
| 47 | #define AXP20X_LDO5_V_OUT_MASK GENMASK(7, 4) |
| 48 | |
| 49 | #define AXP20X_PWR_OUT_EXTEN_MASK BIT_MASK(0) |
| 50 | #define AXP20X_PWR_OUT_DCDC3_MASK BIT_MASK(1) |
| 51 | #define AXP20X_PWR_OUT_LDO2_MASK BIT_MASK(2) |
| 52 | #define AXP20X_PWR_OUT_LDO4_MASK BIT_MASK(3) |
| 53 | #define AXP20X_PWR_OUT_DCDC2_MASK BIT_MASK(4) |
| 54 | #define AXP20X_PWR_OUT_LDO3_MASK BIT_MASK(6) |
| 55 | |
Olliver Schinagl | d29f54d | 2018-12-11 17:17:06 +0200 | [diff] [blame] | 56 | #define AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK BIT_MASK(0) |
| 57 | #define AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE(x) \ |
| 58 | ((x) << 0) |
| 59 | #define AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK BIT_MASK(1) |
| 60 | #define AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(x) \ |
| 61 | ((x) << 1) |
| 62 | #define AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK BIT_MASK(2) |
| 63 | #define AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN BIT(2) |
| 64 | #define AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK BIT_MASK(3) |
| 65 | #define AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN BIT(3) |
| 66 | |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 67 | #define AXP20X_LDO4_V_OUT_1250mV_START 0x0 |
| 68 | #define AXP20X_LDO4_V_OUT_1250mV_STEPS 0 |
| 69 | #define AXP20X_LDO4_V_OUT_1250mV_END \ |
| 70 | (AXP20X_LDO4_V_OUT_1250mV_START + AXP20X_LDO4_V_OUT_1250mV_STEPS) |
| 71 | #define AXP20X_LDO4_V_OUT_1300mV_START 0x1 |
| 72 | #define AXP20X_LDO4_V_OUT_1300mV_STEPS 7 |
| 73 | #define AXP20X_LDO4_V_OUT_1300mV_END \ |
| 74 | (AXP20X_LDO4_V_OUT_1300mV_START + AXP20X_LDO4_V_OUT_1300mV_STEPS) |
| 75 | #define AXP20X_LDO4_V_OUT_2500mV_START 0x9 |
| 76 | #define AXP20X_LDO4_V_OUT_2500mV_STEPS 0 |
| 77 | #define AXP20X_LDO4_V_OUT_2500mV_END \ |
| 78 | (AXP20X_LDO4_V_OUT_2500mV_START + AXP20X_LDO4_V_OUT_2500mV_STEPS) |
| 79 | #define AXP20X_LDO4_V_OUT_2700mV_START 0xa |
| 80 | #define AXP20X_LDO4_V_OUT_2700mV_STEPS 1 |
| 81 | #define AXP20X_LDO4_V_OUT_2700mV_END \ |
| 82 | (AXP20X_LDO4_V_OUT_2700mV_START + AXP20X_LDO4_V_OUT_2700mV_STEPS) |
| 83 | #define AXP20X_LDO4_V_OUT_3000mV_START 0xc |
| 84 | #define AXP20X_LDO4_V_OUT_3000mV_STEPS 3 |
| 85 | #define AXP20X_LDO4_V_OUT_3000mV_END \ |
| 86 | (AXP20X_LDO4_V_OUT_3000mV_START + AXP20X_LDO4_V_OUT_3000mV_STEPS) |
| 87 | #define AXP20X_LDO4_V_OUT_NUM_VOLTAGES 16 |
| 88 | |
Chen-Yu Tsai | 3cb99e2 | 2015-12-22 17:08:06 +0800 | [diff] [blame] | 89 | #define AXP22X_IO_ENABLED 0x03 |
| 90 | #define AXP22X_IO_DISABLED 0x04 |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 91 | |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 92 | #define AXP22X_WORKMODE_DCDCX_MASK(x) BIT_MASK(x) |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 93 | |
Hans de Goede | 636e2a3 | 2016-06-03 18:59:44 +0200 | [diff] [blame] | 94 | #define AXP22X_MISC_N_VBUSEN_FUNC BIT(4) |
| 95 | |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 96 | #define AXP22X_DCDC1_V_OUT_MASK GENMASK(4, 0) |
| 97 | #define AXP22X_DCDC2_V_OUT_MASK GENMASK(5, 0) |
| 98 | #define AXP22X_DCDC3_V_OUT_MASK GENMASK(5, 0) |
| 99 | #define AXP22X_DCDC4_V_OUT_MASK GENMASK(5, 0) |
| 100 | #define AXP22X_DCDC5_V_OUT_MASK GENMASK(4, 0) |
| 101 | #define AXP22X_DC5LDO_V_OUT_MASK GENMASK(2, 0) |
| 102 | #define AXP22X_ALDO1_V_OUT_MASK GENMASK(4, 0) |
| 103 | #define AXP22X_ALDO2_V_OUT_MASK GENMASK(4, 0) |
| 104 | #define AXP22X_ALDO3_V_OUT_MASK GENMASK(4, 0) |
| 105 | #define AXP22X_DLDO1_V_OUT_MASK GENMASK(4, 0) |
| 106 | #define AXP22X_DLDO2_V_OUT_MASK GENMASK(4, 0) |
| 107 | #define AXP22X_DLDO3_V_OUT_MASK GENMASK(4, 0) |
| 108 | #define AXP22X_DLDO4_V_OUT_MASK GENMASK(4, 0) |
| 109 | #define AXP22X_ELDO1_V_OUT_MASK GENMASK(4, 0) |
| 110 | #define AXP22X_ELDO2_V_OUT_MASK GENMASK(4, 0) |
| 111 | #define AXP22X_ELDO3_V_OUT_MASK GENMASK(4, 0) |
| 112 | #define AXP22X_LDO_IO0_V_OUT_MASK GENMASK(4, 0) |
| 113 | #define AXP22X_LDO_IO1_V_OUT_MASK GENMASK(4, 0) |
| 114 | |
| 115 | #define AXP22X_PWR_OUT_DC5LDO_MASK BIT_MASK(0) |
| 116 | #define AXP22X_PWR_OUT_DCDC1_MASK BIT_MASK(1) |
| 117 | #define AXP22X_PWR_OUT_DCDC2_MASK BIT_MASK(2) |
| 118 | #define AXP22X_PWR_OUT_DCDC3_MASK BIT_MASK(3) |
| 119 | #define AXP22X_PWR_OUT_DCDC4_MASK BIT_MASK(4) |
| 120 | #define AXP22X_PWR_OUT_DCDC5_MASK BIT_MASK(5) |
| 121 | #define AXP22X_PWR_OUT_ALDO1_MASK BIT_MASK(6) |
| 122 | #define AXP22X_PWR_OUT_ALDO2_MASK BIT_MASK(7) |
| 123 | |
| 124 | #define AXP22X_PWR_OUT_SW_MASK BIT_MASK(6) |
| 125 | #define AXP22X_PWR_OUT_DC1SW_MASK BIT_MASK(7) |
| 126 | |
| 127 | #define AXP22X_PWR_OUT_ELDO1_MASK BIT_MASK(0) |
| 128 | #define AXP22X_PWR_OUT_ELDO2_MASK BIT_MASK(1) |
| 129 | #define AXP22X_PWR_OUT_ELDO3_MASK BIT_MASK(2) |
| 130 | #define AXP22X_PWR_OUT_DLDO1_MASK BIT_MASK(3) |
| 131 | #define AXP22X_PWR_OUT_DLDO2_MASK BIT_MASK(4) |
| 132 | #define AXP22X_PWR_OUT_DLDO3_MASK BIT_MASK(5) |
| 133 | #define AXP22X_PWR_OUT_DLDO4_MASK BIT_MASK(6) |
| 134 | #define AXP22X_PWR_OUT_ALDO3_MASK BIT_MASK(7) |
| 135 | |
| 136 | #define AXP803_PWR_OUT_DCDC1_MASK BIT_MASK(0) |
| 137 | #define AXP803_PWR_OUT_DCDC2_MASK BIT_MASK(1) |
| 138 | #define AXP803_PWR_OUT_DCDC3_MASK BIT_MASK(2) |
| 139 | #define AXP803_PWR_OUT_DCDC4_MASK BIT_MASK(3) |
| 140 | #define AXP803_PWR_OUT_DCDC5_MASK BIT_MASK(4) |
| 141 | #define AXP803_PWR_OUT_DCDC6_MASK BIT_MASK(5) |
| 142 | |
| 143 | #define AXP803_PWR_OUT_FLDO1_MASK BIT_MASK(2) |
| 144 | #define AXP803_PWR_OUT_FLDO2_MASK BIT_MASK(3) |
| 145 | |
| 146 | #define AXP803_DCDC1_V_OUT_MASK GENMASK(4, 0) |
| 147 | #define AXP803_DCDC2_V_OUT_MASK GENMASK(6, 0) |
| 148 | #define AXP803_DCDC3_V_OUT_MASK GENMASK(6, 0) |
| 149 | #define AXP803_DCDC4_V_OUT_MASK GENMASK(6, 0) |
| 150 | #define AXP803_DCDC5_V_OUT_MASK GENMASK(6, 0) |
| 151 | #define AXP803_DCDC6_V_OUT_MASK GENMASK(6, 0) |
| 152 | |
| 153 | #define AXP803_FLDO1_V_OUT_MASK GENMASK(3, 0) |
| 154 | #define AXP803_FLDO2_V_OUT_MASK GENMASK(3, 0) |
| 155 | |
| 156 | #define AXP803_DCDC23_POLYPHASE_DUAL BIT(6) |
| 157 | #define AXP803_DCDC56_POLYPHASE_DUAL BIT(5) |
| 158 | |
| 159 | #define AXP803_DCDC234_500mV_START 0x00 |
| 160 | #define AXP803_DCDC234_500mV_STEPS 70 |
| 161 | #define AXP803_DCDC234_500mV_END \ |
| 162 | (AXP803_DCDC234_500mV_START + AXP803_DCDC234_500mV_STEPS) |
| 163 | #define AXP803_DCDC234_1220mV_START 0x47 |
| 164 | #define AXP803_DCDC234_1220mV_STEPS 4 |
| 165 | #define AXP803_DCDC234_1220mV_END \ |
| 166 | (AXP803_DCDC234_1220mV_START + AXP803_DCDC234_1220mV_STEPS) |
| 167 | #define AXP803_DCDC234_NUM_VOLTAGES 76 |
| 168 | |
| 169 | #define AXP803_DCDC5_800mV_START 0x00 |
| 170 | #define AXP803_DCDC5_800mV_STEPS 32 |
| 171 | #define AXP803_DCDC5_800mV_END \ |
| 172 | (AXP803_DCDC5_800mV_START + AXP803_DCDC5_800mV_STEPS) |
| 173 | #define AXP803_DCDC5_1140mV_START 0x21 |
| 174 | #define AXP803_DCDC5_1140mV_STEPS 35 |
| 175 | #define AXP803_DCDC5_1140mV_END \ |
| 176 | (AXP803_DCDC5_1140mV_START + AXP803_DCDC5_1140mV_STEPS) |
| 177 | #define AXP803_DCDC5_NUM_VOLTAGES 68 |
| 178 | |
| 179 | #define AXP803_DCDC6_600mV_START 0x00 |
| 180 | #define AXP803_DCDC6_600mV_STEPS 50 |
| 181 | #define AXP803_DCDC6_600mV_END \ |
| 182 | (AXP803_DCDC6_600mV_START + AXP803_DCDC6_600mV_STEPS) |
| 183 | #define AXP803_DCDC6_1120mV_START 0x33 |
| 184 | #define AXP803_DCDC6_1120mV_STEPS 14 |
| 185 | #define AXP803_DCDC6_1120mV_END \ |
| 186 | (AXP803_DCDC6_1120mV_START + AXP803_DCDC6_1120mV_STEPS) |
| 187 | #define AXP803_DCDC6_NUM_VOLTAGES 72 |
| 188 | |
| 189 | #define AXP803_DLDO2_700mV_START 0x00 |
| 190 | #define AXP803_DLDO2_700mV_STEPS 26 |
| 191 | #define AXP803_DLDO2_700mV_END \ |
| 192 | (AXP803_DLDO2_700mV_START + AXP803_DLDO2_700mV_STEPS) |
| 193 | #define AXP803_DLDO2_3400mV_START 0x1b |
| 194 | #define AXP803_DLDO2_3400mV_STEPS 4 |
| 195 | #define AXP803_DLDO2_3400mV_END \ |
| 196 | (AXP803_DLDO2_3400mV_START + AXP803_DLDO2_3400mV_STEPS) |
| 197 | #define AXP803_DLDO2_NUM_VOLTAGES 32 |
| 198 | |
| 199 | #define AXP806_DCDCA_V_CTRL_MASK GENMASK(6, 0) |
| 200 | #define AXP806_DCDCB_V_CTRL_MASK GENMASK(4, 0) |
| 201 | #define AXP806_DCDCC_V_CTRL_MASK GENMASK(6, 0) |
| 202 | #define AXP806_DCDCD_V_CTRL_MASK GENMASK(5, 0) |
| 203 | #define AXP806_DCDCE_V_CTRL_MASK GENMASK(4, 0) |
| 204 | #define AXP806_ALDO1_V_CTRL_MASK GENMASK(4, 0) |
| 205 | #define AXP806_ALDO2_V_CTRL_MASK GENMASK(4, 0) |
| 206 | #define AXP806_ALDO3_V_CTRL_MASK GENMASK(4, 0) |
| 207 | #define AXP806_BLDO1_V_CTRL_MASK GENMASK(3, 0) |
| 208 | #define AXP806_BLDO2_V_CTRL_MASK GENMASK(3, 0) |
| 209 | #define AXP806_BLDO3_V_CTRL_MASK GENMASK(3, 0) |
| 210 | #define AXP806_BLDO4_V_CTRL_MASK GENMASK(3, 0) |
| 211 | #define AXP806_CLDO1_V_CTRL_MASK GENMASK(4, 0) |
| 212 | #define AXP806_CLDO2_V_CTRL_MASK GENMASK(4, 0) |
| 213 | #define AXP806_CLDO3_V_CTRL_MASK GENMASK(4, 0) |
| 214 | |
| 215 | #define AXP806_PWR_OUT_DCDCA_MASK BIT_MASK(0) |
| 216 | #define AXP806_PWR_OUT_DCDCB_MASK BIT_MASK(1) |
| 217 | #define AXP806_PWR_OUT_DCDCC_MASK BIT_MASK(2) |
| 218 | #define AXP806_PWR_OUT_DCDCD_MASK BIT_MASK(3) |
| 219 | #define AXP806_PWR_OUT_DCDCE_MASK BIT_MASK(4) |
| 220 | #define AXP806_PWR_OUT_ALDO1_MASK BIT_MASK(5) |
| 221 | #define AXP806_PWR_OUT_ALDO2_MASK BIT_MASK(6) |
| 222 | #define AXP806_PWR_OUT_ALDO3_MASK BIT_MASK(7) |
| 223 | #define AXP806_PWR_OUT_BLDO1_MASK BIT_MASK(0) |
| 224 | #define AXP806_PWR_OUT_BLDO2_MASK BIT_MASK(1) |
| 225 | #define AXP806_PWR_OUT_BLDO3_MASK BIT_MASK(2) |
| 226 | #define AXP806_PWR_OUT_BLDO4_MASK BIT_MASK(3) |
| 227 | #define AXP806_PWR_OUT_CLDO1_MASK BIT_MASK(4) |
| 228 | #define AXP806_PWR_OUT_CLDO2_MASK BIT_MASK(5) |
| 229 | #define AXP806_PWR_OUT_CLDO3_MASK BIT_MASK(6) |
| 230 | #define AXP806_PWR_OUT_SW_MASK BIT_MASK(7) |
| 231 | |
| 232 | #define AXP806_DCDCAB_POLYPHASE_DUAL 0x40 |
| 233 | #define AXP806_DCDCABC_POLYPHASE_TRI 0x80 |
| 234 | #define AXP806_DCDCABC_POLYPHASE_MASK GENMASK(7, 6) |
| 235 | |
| 236 | #define AXP806_DCDCDE_POLYPHASE_DUAL BIT(5) |
| 237 | |
| 238 | #define AXP806_DCDCA_600mV_START 0x00 |
| 239 | #define AXP806_DCDCA_600mV_STEPS 50 |
| 240 | #define AXP806_DCDCA_600mV_END \ |
| 241 | (AXP806_DCDCA_600mV_START + AXP806_DCDCA_600mV_STEPS) |
| 242 | #define AXP806_DCDCA_1120mV_START 0x33 |
| 243 | #define AXP806_DCDCA_1120mV_STEPS 14 |
| 244 | #define AXP806_DCDCA_1120mV_END \ |
| 245 | (AXP806_DCDCA_1120mV_START + AXP806_DCDCA_1120mV_STEPS) |
| 246 | #define AXP806_DCDCA_NUM_VOLTAGES 72 |
| 247 | |
| 248 | #define AXP806_DCDCD_600mV_START 0x00 |
| 249 | #define AXP806_DCDCD_600mV_STEPS 45 |
| 250 | #define AXP806_DCDCD_600mV_END \ |
| 251 | (AXP806_DCDCD_600mV_START + AXP806_DCDCD_600mV_STEPS) |
| 252 | #define AXP806_DCDCD_1600mV_START 0x2e |
| 253 | #define AXP806_DCDCD_1600mV_STEPS 17 |
| 254 | #define AXP806_DCDCD_1600mV_END \ |
| 255 | (AXP806_DCDCD_1600mV_START + AXP806_DCDCD_1600mV_STEPS) |
| 256 | #define AXP806_DCDCD_NUM_VOLTAGES 64 |
| 257 | |
| 258 | #define AXP809_DCDC4_600mV_START 0x00 |
| 259 | #define AXP809_DCDC4_600mV_STEPS 47 |
| 260 | #define AXP809_DCDC4_600mV_END \ |
| 261 | (AXP809_DCDC4_600mV_START + AXP809_DCDC4_600mV_STEPS) |
| 262 | #define AXP809_DCDC4_1800mV_START 0x30 |
| 263 | #define AXP809_DCDC4_1800mV_STEPS 8 |
| 264 | #define AXP809_DCDC4_1800mV_END \ |
| 265 | (AXP809_DCDC4_1800mV_START + AXP809_DCDC4_1800mV_STEPS) |
| 266 | #define AXP809_DCDC4_NUM_VOLTAGES 57 |
| 267 | |
| 268 | #define AXP813_DCDC7_V_OUT_MASK GENMASK(6, 0) |
| 269 | |
| 270 | #define AXP813_PWR_OUT_DCDC7_MASK BIT_MASK(6) |
| 271 | |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 272 | #define AXP_DESC_IO(_family, _id, _match, _supply, _min, _max, _step, _vreg, \ |
| 273 | _vmask, _ereg, _emask, _enable_val, _disable_val) \ |
| 274 | [_family##_##_id] = { \ |
Chen-Yu Tsai | e0bbb38 | 2016-02-15 18:31:22 +0800 | [diff] [blame] | 275 | .name = (_match), \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 276 | .supply_name = (_supply), \ |
Chen-Yu Tsai | 880fe82 | 2015-01-10 00:23:43 +0800 | [diff] [blame] | 277 | .of_match = of_match_ptr(_match), \ |
| 278 | .regulators_node = of_match_ptr("regulators"), \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 279 | .type = REGULATOR_VOLTAGE, \ |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 280 | .id = _family##_##_id, \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 281 | .n_voltages = (((_max) - (_min)) / (_step) + 1), \ |
| 282 | .owner = THIS_MODULE, \ |
| 283 | .min_uV = (_min) * 1000, \ |
| 284 | .uV_step = (_step) * 1000, \ |
| 285 | .vsel_reg = (_vreg), \ |
| 286 | .vsel_mask = (_vmask), \ |
| 287 | .enable_reg = (_ereg), \ |
| 288 | .enable_mask = (_emask), \ |
| 289 | .enable_val = (_enable_val), \ |
| 290 | .disable_val = (_disable_val), \ |
| 291 | .ops = &axp20x_ops, \ |
| 292 | } |
| 293 | |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 294 | #define AXP_DESC(_family, _id, _match, _supply, _min, _max, _step, _vreg, \ |
| 295 | _vmask, _ereg, _emask) \ |
| 296 | [_family##_##_id] = { \ |
Chen-Yu Tsai | e0bbb38 | 2016-02-15 18:31:22 +0800 | [diff] [blame] | 297 | .name = (_match), \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 298 | .supply_name = (_supply), \ |
Chen-Yu Tsai | 880fe82 | 2015-01-10 00:23:43 +0800 | [diff] [blame] | 299 | .of_match = of_match_ptr(_match), \ |
| 300 | .regulators_node = of_match_ptr("regulators"), \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 301 | .type = REGULATOR_VOLTAGE, \ |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 302 | .id = _family##_##_id, \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 303 | .n_voltages = (((_max) - (_min)) / (_step) + 1), \ |
| 304 | .owner = THIS_MODULE, \ |
| 305 | .min_uV = (_min) * 1000, \ |
| 306 | .uV_step = (_step) * 1000, \ |
| 307 | .vsel_reg = (_vreg), \ |
| 308 | .vsel_mask = (_vmask), \ |
| 309 | .enable_reg = (_ereg), \ |
| 310 | .enable_mask = (_emask), \ |
| 311 | .ops = &axp20x_ops, \ |
| 312 | } |
| 313 | |
Chen-Yu Tsai | 94c3904 | 2016-02-02 18:27:37 +0800 | [diff] [blame] | 314 | #define AXP_DESC_SW(_family, _id, _match, _supply, _ereg, _emask) \ |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 315 | [_family##_##_id] = { \ |
Chen-Yu Tsai | e0bbb38 | 2016-02-15 18:31:22 +0800 | [diff] [blame] | 316 | .name = (_match), \ |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 317 | .supply_name = (_supply), \ |
| 318 | .of_match = of_match_ptr(_match), \ |
| 319 | .regulators_node = of_match_ptr("regulators"), \ |
| 320 | .type = REGULATOR_VOLTAGE, \ |
| 321 | .id = _family##_##_id, \ |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 322 | .owner = THIS_MODULE, \ |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 323 | .enable_reg = (_ereg), \ |
| 324 | .enable_mask = (_emask), \ |
| 325 | .ops = &axp20x_ops_sw, \ |
| 326 | } |
| 327 | |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 328 | #define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt) \ |
| 329 | [_family##_##_id] = { \ |
Chen-Yu Tsai | e0bbb38 | 2016-02-15 18:31:22 +0800 | [diff] [blame] | 330 | .name = (_match), \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 331 | .supply_name = (_supply), \ |
Chen-Yu Tsai | 880fe82 | 2015-01-10 00:23:43 +0800 | [diff] [blame] | 332 | .of_match = of_match_ptr(_match), \ |
| 333 | .regulators_node = of_match_ptr("regulators"), \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 334 | .type = REGULATOR_VOLTAGE, \ |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 335 | .id = _family##_##_id, \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 336 | .n_voltages = 1, \ |
| 337 | .owner = THIS_MODULE, \ |
| 338 | .min_uV = (_volt) * 1000, \ |
| 339 | .ops = &axp20x_ops_fixed \ |
| 340 | } |
| 341 | |
Chen-Yu Tsai | 13d57e6 | 2016-02-02 18:27:38 +0800 | [diff] [blame] | 342 | #define AXP_DESC_RANGES(_family, _id, _match, _supply, _ranges, _n_voltages, \ |
| 343 | _vreg, _vmask, _ereg, _emask) \ |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 344 | [_family##_##_id] = { \ |
Chen-Yu Tsai | e0bbb38 | 2016-02-15 18:31:22 +0800 | [diff] [blame] | 345 | .name = (_match), \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 346 | .supply_name = (_supply), \ |
Chen-Yu Tsai | 880fe82 | 2015-01-10 00:23:43 +0800 | [diff] [blame] | 347 | .of_match = of_match_ptr(_match), \ |
| 348 | .regulators_node = of_match_ptr("regulators"), \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 349 | .type = REGULATOR_VOLTAGE, \ |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 350 | .id = _family##_##_id, \ |
Chen-Yu Tsai | 13d57e6 | 2016-02-02 18:27:38 +0800 | [diff] [blame] | 351 | .n_voltages = (_n_voltages), \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 352 | .owner = THIS_MODULE, \ |
| 353 | .vsel_reg = (_vreg), \ |
| 354 | .vsel_mask = (_vmask), \ |
| 355 | .enable_reg = (_ereg), \ |
| 356 | .enable_mask = (_emask), \ |
Chen-Yu Tsai | 13d57e6 | 2016-02-02 18:27:38 +0800 | [diff] [blame] | 357 | .linear_ranges = (_ranges), \ |
| 358 | .n_linear_ranges = ARRAY_SIZE(_ranges), \ |
| 359 | .ops = &axp20x_ops_range, \ |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 360 | } |
| 361 | |
Olliver Schinagl | d29f54d | 2018-12-11 17:17:06 +0200 | [diff] [blame] | 362 | static const int axp209_dcdc2_ldo3_slew_rates[] = { |
| 363 | 1600, |
| 364 | 800, |
| 365 | }; |
| 366 | |
| 367 | static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) |
| 368 | { |
| 369 | struct axp20x_dev *axp20x = rdev_get_drvdata(rdev); |
| 370 | const struct regulator_desc *desc = rdev->desc; |
| 371 | u8 reg, mask, enable, cfg = 0xff; |
| 372 | const int *slew_rates; |
| 373 | int rate_count = 0; |
| 374 | |
| 375 | if (!rdev) |
| 376 | return -EINVAL; |
| 377 | |
| 378 | switch (axp20x->variant) { |
| 379 | case AXP209_ID: |
| 380 | if (desc->id == AXP20X_DCDC2) { |
| 381 | rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates); |
| 382 | reg = AXP20X_DCDC2_LDO3_V_RAMP; |
| 383 | mask = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK | |
| 384 | AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK; |
| 385 | enable = (ramp > 0) ? |
| 386 | AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN : |
| 387 | !AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN; |
| 388 | break; |
| 389 | } |
| 390 | |
| 391 | if (desc->id == AXP20X_LDO3) { |
| 392 | slew_rates = axp209_dcdc2_ldo3_slew_rates; |
| 393 | rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates); |
| 394 | reg = AXP20X_DCDC2_LDO3_V_RAMP; |
| 395 | mask = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK | |
| 396 | AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK; |
| 397 | enable = (ramp > 0) ? |
| 398 | AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN : |
| 399 | !AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN; |
| 400 | break; |
| 401 | } |
| 402 | |
| 403 | if (rate_count > 0) |
| 404 | break; |
| 405 | |
| 406 | /* fall through */ |
| 407 | default: |
| 408 | /* Not supported for this regulator */ |
| 409 | return -ENOTSUPP; |
| 410 | } |
| 411 | |
| 412 | if (ramp == 0) { |
| 413 | cfg = enable; |
| 414 | } else { |
| 415 | int i; |
| 416 | |
| 417 | for (i = 0; i < rate_count; i++) { |
| 418 | if (ramp <= slew_rates[i]) |
| 419 | cfg = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(i); |
| 420 | else |
| 421 | break; |
| 422 | } |
| 423 | |
| 424 | if (cfg == 0xff) { |
| 425 | dev_err(axp20x->dev, "unsupported ramp value %d", ramp); |
| 426 | return -EINVAL; |
| 427 | } |
| 428 | |
| 429 | cfg |= enable; |
| 430 | } |
| 431 | |
| 432 | return regmap_update_bits(axp20x->regmap, reg, mask, cfg); |
| 433 | } |
| 434 | |
Olliver Schinagl | 77e3e3b | 2018-12-11 17:17:08 +0200 | [diff] [blame^] | 435 | static int axp20x_regulator_enable_regmap(struct regulator_dev *rdev) |
| 436 | { |
| 437 | struct axp20x_dev *axp20x = rdev_get_drvdata(rdev); |
| 438 | const struct regulator_desc *desc = rdev->desc; |
| 439 | |
| 440 | if (!rdev) |
| 441 | return -EINVAL; |
| 442 | |
| 443 | switch (axp20x->variant) { |
| 444 | case AXP209_ID: |
| 445 | if ((desc->id == AXP20X_LDO3) && |
| 446 | rdev->constraints && rdev->constraints->soft_start) { |
| 447 | int v_out; |
| 448 | int ret; |
| 449 | |
| 450 | /* |
| 451 | * On some boards, the LDO3 can be overloaded when |
| 452 | * turning on, causing the entire PMIC to shutdown |
| 453 | * without warning. Turning it on at the minimal voltage |
| 454 | * and then setting the voltage to the requested value |
| 455 | * works reliably. |
| 456 | */ |
| 457 | if (regulator_is_enabled_regmap(rdev)) |
| 458 | break; |
| 459 | |
| 460 | v_out = regulator_get_voltage_sel_regmap(rdev); |
| 461 | if (v_out < 0) |
| 462 | return v_out; |
| 463 | |
| 464 | if (v_out == 0) |
| 465 | break; |
| 466 | |
| 467 | ret = regulator_set_voltage_sel_regmap(rdev, 0x00); |
| 468 | /* |
| 469 | * A small pause is needed between |
| 470 | * setting the voltage and enabling the LDO to give the |
| 471 | * internal state machine time to process the request. |
| 472 | */ |
| 473 | usleep_range(1000, 5000); |
| 474 | ret |= regulator_enable_regmap(rdev); |
| 475 | ret |= regulator_set_voltage_sel_regmap(rdev, v_out); |
| 476 | |
| 477 | return ret; |
| 478 | } |
| 479 | break; |
| 480 | default: |
| 481 | /* No quirks */ |
| 482 | break; |
| 483 | } |
| 484 | |
| 485 | return regulator_enable_regmap(rdev); |
| 486 | }; |
| 487 | |
Bhumika Goyal | ef306e4 | 2017-01-28 19:28:01 +0530 | [diff] [blame] | 488 | static const struct regulator_ops axp20x_ops_fixed = { |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 489 | .list_voltage = regulator_list_voltage_linear, |
| 490 | }; |
| 491 | |
Bhumika Goyal | ef306e4 | 2017-01-28 19:28:01 +0530 | [diff] [blame] | 492 | static const struct regulator_ops axp20x_ops_range = { |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 493 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 494 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
Chen-Yu Tsai | 13d57e6 | 2016-02-02 18:27:38 +0800 | [diff] [blame] | 495 | .list_voltage = regulator_list_voltage_linear_range, |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 496 | .enable = regulator_enable_regmap, |
| 497 | .disable = regulator_disable_regmap, |
| 498 | .is_enabled = regulator_is_enabled_regmap, |
| 499 | }; |
| 500 | |
Bhumika Goyal | ef306e4 | 2017-01-28 19:28:01 +0530 | [diff] [blame] | 501 | static const struct regulator_ops axp20x_ops = { |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 502 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 503 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 504 | .list_voltage = regulator_list_voltage_linear, |
Olliver Schinagl | 77e3e3b | 2018-12-11 17:17:08 +0200 | [diff] [blame^] | 505 | .enable = axp20x_regulator_enable_regmap, |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 506 | .disable = regulator_disable_regmap, |
| 507 | .is_enabled = regulator_is_enabled_regmap, |
Olliver Schinagl | d29f54d | 2018-12-11 17:17:06 +0200 | [diff] [blame] | 508 | .set_ramp_delay = axp20x_set_ramp_delay, |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 509 | }; |
| 510 | |
Bhumika Goyal | ef306e4 | 2017-01-28 19:28:01 +0530 | [diff] [blame] | 511 | static const struct regulator_ops axp20x_ops_sw = { |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 512 | .enable = regulator_enable_regmap, |
| 513 | .disable = regulator_disable_regmap, |
| 514 | .is_enabled = regulator_is_enabled_regmap, |
| 515 | }; |
| 516 | |
Chen-Yu Tsai | 13d57e6 | 2016-02-02 18:27:38 +0800 | [diff] [blame] | 517 | static const struct regulator_linear_range axp20x_ldo4_ranges[] = { |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 518 | REGULATOR_LINEAR_RANGE(1250000, |
| 519 | AXP20X_LDO4_V_OUT_1250mV_START, |
| 520 | AXP20X_LDO4_V_OUT_1250mV_END, |
| 521 | 0), |
| 522 | REGULATOR_LINEAR_RANGE(1300000, |
| 523 | AXP20X_LDO4_V_OUT_1300mV_START, |
| 524 | AXP20X_LDO4_V_OUT_1300mV_END, |
| 525 | 100000), |
| 526 | REGULATOR_LINEAR_RANGE(2500000, |
| 527 | AXP20X_LDO4_V_OUT_2500mV_START, |
| 528 | AXP20X_LDO4_V_OUT_2500mV_END, |
| 529 | 0), |
| 530 | REGULATOR_LINEAR_RANGE(2700000, |
| 531 | AXP20X_LDO4_V_OUT_2700mV_START, |
| 532 | AXP20X_LDO4_V_OUT_2700mV_END, |
| 533 | 100000), |
| 534 | REGULATOR_LINEAR_RANGE(3000000, |
| 535 | AXP20X_LDO4_V_OUT_3000mV_START, |
| 536 | AXP20X_LDO4_V_OUT_3000mV_END, |
| 537 | 100000), |
Chen-Yu Tsai | 13d57e6 | 2016-02-02 18:27:38 +0800 | [diff] [blame] | 538 | }; |
| 539 | |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 540 | static const struct regulator_desc axp20x_regulators[] = { |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 541 | AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 542 | AXP20X_DCDC2_V_OUT, AXP20X_DCDC2_V_OUT_MASK, |
| 543 | AXP20X_PWR_OUT_CTRL, AXP20X_PWR_OUT_DCDC2_MASK), |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 544 | AXP_DESC(AXP20X, DCDC3, "dcdc3", "vin3", 700, 3500, 25, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 545 | AXP20X_DCDC3_V_OUT, AXP20X_DCDC3_V_OUT_MASK, |
| 546 | AXP20X_PWR_OUT_CTRL, AXP20X_PWR_OUT_DCDC3_MASK), |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 547 | AXP_DESC_FIXED(AXP20X, LDO1, "ldo1", "acin", 1300), |
| 548 | AXP_DESC(AXP20X, LDO2, "ldo2", "ldo24in", 1800, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 549 | AXP20X_LDO24_V_OUT, AXP20X_LDO24_V_OUT_MASK, |
| 550 | AXP20X_PWR_OUT_CTRL, AXP20X_PWR_OUT_LDO2_MASK), |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 551 | AXP_DESC(AXP20X, LDO3, "ldo3", "ldo3in", 700, 3500, 25, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 552 | AXP20X_LDO3_V_OUT, AXP20X_LDO3_V_OUT_MASK, |
| 553 | AXP20X_PWR_OUT_CTRL, AXP20X_PWR_OUT_LDO3_MASK), |
| 554 | AXP_DESC_RANGES(AXP20X, LDO4, "ldo4", "ldo24in", |
| 555 | axp20x_ldo4_ranges, AXP20X_LDO4_V_OUT_NUM_VOLTAGES, |
| 556 | AXP20X_LDO24_V_OUT, AXP20X_LDO24_V_OUT_MASK, |
| 557 | AXP20X_PWR_OUT_CTRL, AXP20X_PWR_OUT_LDO4_MASK), |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 558 | AXP_DESC_IO(AXP20X, LDO5, "ldo5", "ldo5in", 1800, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 559 | AXP20X_LDO5_V_OUT, AXP20X_LDO5_V_OUT_MASK, |
| 560 | AXP20X_GPIO0_CTRL, AXP20X_GPIO0_FUNC_MASK, |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 561 | AXP20X_IO_ENABLED, AXP20X_IO_DISABLED), |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 562 | }; |
| 563 | |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 564 | static const struct regulator_desc axp22x_regulators[] = { |
| 565 | AXP_DESC(AXP22X, DCDC1, "dcdc1", "vin1", 1600, 3400, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 566 | AXP22X_DCDC1_V_OUT, AXP22X_DCDC1_V_OUT_MASK, |
| 567 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC1_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 568 | AXP_DESC(AXP22X, DCDC2, "dcdc2", "vin2", 600, 1540, 20, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 569 | AXP22X_DCDC2_V_OUT, AXP22X_DCDC2_V_OUT_MASK, |
| 570 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC2_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 571 | AXP_DESC(AXP22X, DCDC3, "dcdc3", "vin3", 600, 1860, 20, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 572 | AXP22X_DCDC3_V_OUT, AXP22X_DCDC3_V_OUT_MASK, |
| 573 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC3_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 574 | AXP_DESC(AXP22X, DCDC4, "dcdc4", "vin4", 600, 1540, 20, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 575 | AXP22X_DCDC4_V_OUT, AXP22X_DCDC4_V_OUT, |
| 576 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC4_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 577 | AXP_DESC(AXP22X, DCDC5, "dcdc5", "vin5", 1000, 2550, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 578 | AXP22X_DCDC5_V_OUT, AXP22X_DCDC5_V_OUT_MASK, |
| 579 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC5_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 580 | /* secondary switchable output of DCDC1 */ |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 581 | AXP_DESC_SW(AXP22X, DC1SW, "dc1sw", NULL, |
| 582 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DC1SW_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 583 | /* LDO regulator internally chained to DCDC5 */ |
Chen-Yu Tsai | 7118f19 | 2015-09-30 14:39:46 +0800 | [diff] [blame] | 584 | AXP_DESC(AXP22X, DC5LDO, "dc5ldo", NULL, 700, 1400, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 585 | AXP22X_DC5LDO_V_OUT, AXP22X_DC5LDO_V_OUT_MASK, |
| 586 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DC5LDO_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 587 | AXP_DESC(AXP22X, ALDO1, "aldo1", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 588 | AXP22X_ALDO1_V_OUT, AXP22X_ALDO1_V_OUT_MASK, |
| 589 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_ALDO1_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 590 | AXP_DESC(AXP22X, ALDO2, "aldo2", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 591 | AXP22X_ALDO2_V_OUT, AXP22X_ALDO2_V_OUT_MASK, |
| 592 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_ALDO2_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 593 | AXP_DESC(AXP22X, ALDO3, "aldo3", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 594 | AXP22X_ALDO3_V_OUT, AXP22X_ALDO3_V_OUT_MASK, |
| 595 | AXP22X_PWR_OUT_CTRL3, AXP22X_PWR_OUT_ALDO3_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 596 | AXP_DESC(AXP22X, DLDO1, "dldo1", "dldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 597 | AXP22X_DLDO1_V_OUT, AXP22X_DLDO1_V_OUT_MASK, |
| 598 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO1_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 599 | AXP_DESC(AXP22X, DLDO2, "dldo2", "dldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 600 | AXP22X_DLDO2_V_OUT, AXP22X_PWR_OUT_DLDO2_MASK, |
| 601 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO2_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 602 | AXP_DESC(AXP22X, DLDO3, "dldo3", "dldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 603 | AXP22X_DLDO3_V_OUT, AXP22X_DLDO3_V_OUT_MASK, |
| 604 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO3_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 605 | AXP_DESC(AXP22X, DLDO4, "dldo4", "dldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 606 | AXP22X_DLDO4_V_OUT, AXP22X_DLDO4_V_OUT_MASK, |
| 607 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO4_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 608 | AXP_DESC(AXP22X, ELDO1, "eldo1", "eldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 609 | AXP22X_ELDO1_V_OUT, AXP22X_ELDO1_V_OUT_MASK, |
| 610 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 611 | AXP_DESC(AXP22X, ELDO2, "eldo2", "eldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 612 | AXP22X_ELDO2_V_OUT, AXP22X_ELDO2_V_OUT_MASK, |
| 613 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK), |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 614 | AXP_DESC(AXP22X, ELDO3, "eldo3", "eldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 615 | AXP22X_ELDO3_V_OUT, AXP22X_ELDO3_V_OUT_MASK, |
| 616 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO3_MASK), |
Hans de Goede | f40d489 | 2016-04-27 20:38:44 +0200 | [diff] [blame] | 617 | /* Note the datasheet only guarantees reliable operation up to |
| 618 | * 3.3V, this needs to be enforced via dts provided constraints */ |
| 619 | AXP_DESC_IO(AXP22X, LDO_IO0, "ldo_io0", "ips", 700, 3800, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 620 | AXP22X_LDO_IO0_V_OUT, AXP22X_LDO_IO0_V_OUT_MASK, |
| 621 | AXP20X_GPIO0_CTRL, AXP20X_GPIO0_FUNC_MASK, |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 622 | AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), |
Hans de Goede | f40d489 | 2016-04-27 20:38:44 +0200 | [diff] [blame] | 623 | /* Note the datasheet only guarantees reliable operation up to |
| 624 | * 3.3V, this needs to be enforced via dts provided constraints */ |
| 625 | AXP_DESC_IO(AXP22X, LDO_IO1, "ldo_io1", "ips", 700, 3800, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 626 | AXP22X_LDO_IO1_V_OUT, AXP22X_LDO_IO1_V_OUT_MASK, |
| 627 | AXP20X_GPIO1_CTRL, AXP20X_GPIO1_FUNC_MASK, |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 628 | AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), |
| 629 | AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtc_ldo", "ips", 3000), |
| 630 | }; |
| 631 | |
Hans de Goede | 636e2a3 | 2016-06-03 18:59:44 +0200 | [diff] [blame] | 632 | static const struct regulator_desc axp22x_drivevbus_regulator = { |
| 633 | .name = "drivevbus", |
| 634 | .supply_name = "drivevbus", |
| 635 | .of_match = of_match_ptr("drivevbus"), |
| 636 | .regulators_node = of_match_ptr("regulators"), |
| 637 | .type = REGULATOR_VOLTAGE, |
| 638 | .owner = THIS_MODULE, |
| 639 | .enable_reg = AXP20X_VBUS_IPSOUT_MGMT, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 640 | .enable_mask = AXP20X_VBUS_IPSOUT_MGMT_MASK, |
Hans de Goede | 636e2a3 | 2016-06-03 18:59:44 +0200 | [diff] [blame] | 641 | .ops = &axp20x_ops_sw, |
| 642 | }; |
| 643 | |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 644 | /* DCDC ranges shared with AXP813 */ |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 645 | static const struct regulator_linear_range axp803_dcdc234_ranges[] = { |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 646 | REGULATOR_LINEAR_RANGE(500000, |
| 647 | AXP803_DCDC234_500mV_START, |
| 648 | AXP803_DCDC234_500mV_END, |
| 649 | 10000), |
| 650 | REGULATOR_LINEAR_RANGE(1220000, |
| 651 | AXP803_DCDC234_1220mV_START, |
| 652 | AXP803_DCDC234_1220mV_END, |
| 653 | 20000), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 654 | }; |
| 655 | |
| 656 | static const struct regulator_linear_range axp803_dcdc5_ranges[] = { |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 657 | REGULATOR_LINEAR_RANGE(800000, |
| 658 | AXP803_DCDC5_800mV_START, |
| 659 | AXP803_DCDC5_800mV_END, |
| 660 | 10000), |
| 661 | REGULATOR_LINEAR_RANGE(1140000, |
| 662 | AXP803_DCDC5_1140mV_START, |
| 663 | AXP803_DCDC5_1140mV_END, |
| 664 | 20000), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 665 | }; |
| 666 | |
| 667 | static const struct regulator_linear_range axp803_dcdc6_ranges[] = { |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 668 | REGULATOR_LINEAR_RANGE(600000, |
| 669 | AXP803_DCDC6_600mV_START, |
| 670 | AXP803_DCDC6_600mV_END, |
| 671 | 10000), |
| 672 | REGULATOR_LINEAR_RANGE(1120000, |
| 673 | AXP803_DCDC6_1120mV_START, |
| 674 | AXP803_DCDC6_1120mV_END, |
| 675 | 20000), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 676 | }; |
| 677 | |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 678 | /* AXP806's CLDO2 and AXP809's DLDO1 share the same range */ |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 679 | static const struct regulator_linear_range axp803_dldo2_ranges[] = { |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 680 | REGULATOR_LINEAR_RANGE(700000, |
| 681 | AXP803_DLDO2_700mV_START, |
| 682 | AXP803_DLDO2_700mV_END, |
| 683 | 100000), |
| 684 | REGULATOR_LINEAR_RANGE(3400000, |
| 685 | AXP803_DLDO2_3400mV_START, |
| 686 | AXP803_DLDO2_3400mV_END, |
| 687 | 200000), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 688 | }; |
| 689 | |
| 690 | static const struct regulator_desc axp803_regulators[] = { |
| 691 | AXP_DESC(AXP803, DCDC1, "dcdc1", "vin1", 1600, 3400, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 692 | AXP803_DCDC1_V_OUT, AXP803_DCDC1_V_OUT_MASK, |
| 693 | AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC1_MASK), |
| 694 | AXP_DESC_RANGES(AXP803, DCDC2, "dcdc2", "vin2", |
| 695 | axp803_dcdc234_ranges, AXP803_DCDC234_NUM_VOLTAGES, |
| 696 | AXP803_DCDC2_V_OUT, AXP803_DCDC2_V_OUT_MASK, |
| 697 | AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC2_MASK), |
| 698 | AXP_DESC_RANGES(AXP803, DCDC3, "dcdc3", "vin3", |
| 699 | axp803_dcdc234_ranges, AXP803_DCDC234_NUM_VOLTAGES, |
| 700 | AXP803_DCDC3_V_OUT, AXP803_DCDC3_V_OUT_MASK, |
| 701 | AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC3_MASK), |
| 702 | AXP_DESC_RANGES(AXP803, DCDC4, "dcdc4", "vin4", |
| 703 | axp803_dcdc234_ranges, AXP803_DCDC234_NUM_VOLTAGES, |
| 704 | AXP803_DCDC4_V_OUT, AXP803_DCDC4_V_OUT_MASK, |
| 705 | AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC4_MASK), |
| 706 | AXP_DESC_RANGES(AXP803, DCDC5, "dcdc5", "vin5", |
| 707 | axp803_dcdc5_ranges, AXP803_DCDC5_NUM_VOLTAGES, |
| 708 | AXP803_DCDC5_V_OUT, AXP803_DCDC5_V_OUT_MASK, |
| 709 | AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC5_MASK), |
| 710 | AXP_DESC_RANGES(AXP803, DCDC6, "dcdc6", "vin6", |
| 711 | axp803_dcdc6_ranges, AXP803_DCDC6_NUM_VOLTAGES, |
| 712 | AXP803_DCDC6_V_OUT, AXP803_DCDC6_V_OUT_MASK, |
| 713 | AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC6_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 714 | /* secondary switchable output of DCDC1 */ |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 715 | AXP_DESC_SW(AXP803, DC1SW, "dc1sw", NULL, |
| 716 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DC1SW_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 717 | AXP_DESC(AXP803, ALDO1, "aldo1", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 718 | AXP22X_ALDO1_V_OUT, AXP22X_ALDO1_V_OUT_MASK, |
| 719 | AXP22X_PWR_OUT_CTRL3, AXP806_PWR_OUT_ALDO1_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 720 | AXP_DESC(AXP803, ALDO2, "aldo2", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 721 | AXP22X_ALDO2_V_OUT, AXP22X_ALDO2_V_OUT, |
| 722 | AXP22X_PWR_OUT_CTRL3, AXP806_PWR_OUT_ALDO2_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 723 | AXP_DESC(AXP803, ALDO3, "aldo3", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 724 | AXP22X_ALDO3_V_OUT, AXP22X_ALDO3_V_OUT_MASK, |
| 725 | AXP22X_PWR_OUT_CTRL3, AXP806_PWR_OUT_ALDO3_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 726 | AXP_DESC(AXP803, DLDO1, "dldo1", "dldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 727 | AXP22X_DLDO1_V_OUT, AXP22X_DLDO1_V_OUT_MASK, |
| 728 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO1_MASK), |
| 729 | AXP_DESC_RANGES(AXP803, DLDO2, "dldo2", "dldoin", |
| 730 | axp803_dldo2_ranges, AXP803_DLDO2_NUM_VOLTAGES, |
| 731 | AXP22X_DLDO2_V_OUT, AXP22X_DLDO2_V_OUT, |
| 732 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO2_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 733 | AXP_DESC(AXP803, DLDO3, "dldo3", "dldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 734 | AXP22X_DLDO3_V_OUT, AXP22X_DLDO3_V_OUT_MASK, |
| 735 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO3_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 736 | AXP_DESC(AXP803, DLDO4, "dldo4", "dldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 737 | AXP22X_DLDO4_V_OUT, AXP22X_DLDO4_V_OUT_MASK, |
| 738 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO4_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 739 | AXP_DESC(AXP803, ELDO1, "eldo1", "eldoin", 700, 1900, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 740 | AXP22X_ELDO1_V_OUT, AXP22X_ELDO1_V_OUT_MASK, |
| 741 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 742 | AXP_DESC(AXP803, ELDO2, "eldo2", "eldoin", 700, 1900, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 743 | AXP22X_ELDO2_V_OUT, AXP22X_ELDO2_V_OUT_MASK, |
| 744 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO2_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 745 | AXP_DESC(AXP803, ELDO3, "eldo3", "eldoin", 700, 1900, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 746 | AXP22X_ELDO3_V_OUT, AXP22X_ELDO3_V_OUT, |
| 747 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO3_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 748 | AXP_DESC(AXP803, FLDO1, "fldo1", "fldoin", 700, 1450, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 749 | AXP803_FLDO1_V_OUT, AXP803_FLDO1_V_OUT_MASK, |
| 750 | AXP22X_PWR_OUT_CTRL3, AXP803_PWR_OUT_FLDO1_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 751 | AXP_DESC(AXP803, FLDO2, "fldo2", "fldoin", 700, 1450, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 752 | AXP803_FLDO2_V_OUT, AXP803_FLDO2_V_OUT_MASK, |
| 753 | AXP22X_PWR_OUT_CTRL3, AXP803_PWR_OUT_FLDO2_MASK), |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 754 | AXP_DESC_IO(AXP803, LDO_IO0, "ldo-io0", "ips", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 755 | AXP22X_LDO_IO0_V_OUT, AXP22X_LDO_IO0_V_OUT_MASK, |
| 756 | AXP20X_GPIO0_CTRL, AXP20X_GPIO0_FUNC_MASK, |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 757 | AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), |
| 758 | AXP_DESC_IO(AXP803, LDO_IO1, "ldo-io1", "ips", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 759 | AXP22X_LDO_IO1_V_OUT, AXP22X_LDO_IO1_V_OUT_MASK, |
| 760 | AXP20X_GPIO1_CTRL, AXP20X_GPIO1_FUNC_MASK, |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 761 | AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), |
| 762 | AXP_DESC_FIXED(AXP803, RTC_LDO, "rtc-ldo", "ips", 3000), |
| 763 | }; |
| 764 | |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 765 | static const struct regulator_linear_range axp806_dcdca_ranges[] = { |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 766 | REGULATOR_LINEAR_RANGE(600000, |
| 767 | AXP806_DCDCA_600mV_START, |
| 768 | AXP806_DCDCA_600mV_END, |
| 769 | 10000), |
| 770 | REGULATOR_LINEAR_RANGE(1120000, |
| 771 | AXP806_DCDCA_1120mV_START, |
| 772 | AXP806_DCDCA_1120mV_END, |
| 773 | 20000), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 774 | }; |
| 775 | |
| 776 | static const struct regulator_linear_range axp806_dcdcd_ranges[] = { |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 777 | REGULATOR_LINEAR_RANGE(600000, |
| 778 | AXP806_DCDCD_600mV_START, |
| 779 | AXP806_DCDCD_600mV_END, |
| 780 | 20000), |
| 781 | REGULATOR_LINEAR_RANGE(1600000, |
| 782 | AXP806_DCDCD_600mV_START, |
| 783 | AXP806_DCDCD_600mV_END, |
| 784 | 100000), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 785 | }; |
| 786 | |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 787 | static const struct regulator_desc axp806_regulators[] = { |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 788 | AXP_DESC_RANGES(AXP806, DCDCA, "dcdca", "vina", |
| 789 | axp806_dcdca_ranges, AXP806_DCDCA_NUM_VOLTAGES, |
| 790 | AXP806_DCDCA_V_CTRL, AXP806_DCDCA_V_CTRL_MASK, |
| 791 | AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_DCDCA_MASK), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 792 | AXP_DESC(AXP806, DCDCB, "dcdcb", "vinb", 1000, 2550, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 793 | AXP806_DCDCB_V_CTRL, AXP806_DCDCB_V_CTRL, |
| 794 | AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_DCDCB_MASK), |
| 795 | AXP_DESC_RANGES(AXP806, DCDCC, "dcdcc", "vinc", |
| 796 | axp806_dcdca_ranges, AXP806_DCDCA_NUM_VOLTAGES, |
| 797 | AXP806_DCDCC_V_CTRL, AXP806_DCDCC_V_CTRL_MASK, |
| 798 | AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_DCDCC_MASK), |
| 799 | AXP_DESC_RANGES(AXP806, DCDCD, "dcdcd", "vind", |
| 800 | axp806_dcdcd_ranges, AXP806_DCDCD_NUM_VOLTAGES, |
| 801 | AXP806_DCDCD_V_CTRL, AXP806_DCDCD_V_CTRL_MASK, |
| 802 | AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_DCDCD_MASK), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 803 | AXP_DESC(AXP806, DCDCE, "dcdce", "vine", 1100, 3400, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 804 | AXP806_DCDCE_V_CTRL, AXP806_DCDCE_V_CTRL_MASK, |
| 805 | AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_DCDCE_MASK), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 806 | AXP_DESC(AXP806, ALDO1, "aldo1", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 807 | AXP806_ALDO1_V_CTRL, AXP806_ALDO1_V_CTRL_MASK, |
| 808 | AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_ALDO1_MASK), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 809 | AXP_DESC(AXP806, ALDO2, "aldo2", "aldoin", 700, 3400, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 810 | AXP806_ALDO2_V_CTRL, AXP806_ALDO2_V_CTRL_MASK, |
| 811 | AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_ALDO2_MASK), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 812 | AXP_DESC(AXP806, ALDO3, "aldo3", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 813 | AXP806_ALDO3_V_CTRL, AXP806_ALDO3_V_CTRL_MASK, |
| 814 | AXP806_PWR_OUT_CTRL1, AXP806_PWR_OUT_ALDO3_MASK), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 815 | AXP_DESC(AXP806, BLDO1, "bldo1", "bldoin", 700, 1900, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 816 | AXP806_BLDO1_V_CTRL, AXP806_BLDO1_V_CTRL_MASK, |
| 817 | AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_BLDO1_MASK), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 818 | AXP_DESC(AXP806, BLDO2, "bldo2", "bldoin", 700, 1900, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 819 | AXP806_BLDO2_V_CTRL, AXP806_BLDO2_V_CTRL, |
| 820 | AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_BLDO2_MASK), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 821 | AXP_DESC(AXP806, BLDO3, "bldo3", "bldoin", 700, 1900, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 822 | AXP806_BLDO3_V_CTRL, AXP806_BLDO3_V_CTRL_MASK, |
| 823 | AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_BLDO3_MASK), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 824 | AXP_DESC(AXP806, BLDO4, "bldo4", "bldoin", 700, 1900, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 825 | AXP806_BLDO4_V_CTRL, AXP806_BLDO4_V_CTRL_MASK, |
| 826 | AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_BLDO4_MASK), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 827 | AXP_DESC(AXP806, CLDO1, "cldo1", "cldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 828 | AXP806_CLDO1_V_CTRL, AXP806_CLDO1_V_CTRL_MASK, |
| 829 | AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_CLDO1_MASK), |
| 830 | AXP_DESC_RANGES(AXP806, CLDO2, "cldo2", "cldoin", |
| 831 | axp803_dldo2_ranges, AXP803_DLDO2_NUM_VOLTAGES, |
| 832 | AXP806_CLDO2_V_CTRL, AXP806_CLDO2_V_CTRL_MASK, |
| 833 | AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_CLDO2_MASK), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 834 | AXP_DESC(AXP806, CLDO3, "cldo3", "cldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 835 | AXP806_CLDO3_V_CTRL, AXP806_CLDO3_V_CTRL_MASK, |
| 836 | AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_CLDO3_MASK), |
| 837 | AXP_DESC_SW(AXP806, SW, "sw", "swin", |
| 838 | AXP806_PWR_OUT_CTRL2, AXP806_PWR_OUT_SW_MASK), |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 839 | }; |
| 840 | |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 841 | static const struct regulator_linear_range axp809_dcdc4_ranges[] = { |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 842 | REGULATOR_LINEAR_RANGE(600000, |
| 843 | AXP809_DCDC4_600mV_START, |
| 844 | AXP809_DCDC4_600mV_END, |
| 845 | 20000), |
| 846 | REGULATOR_LINEAR_RANGE(1800000, |
| 847 | AXP809_DCDC4_1800mV_START, |
| 848 | AXP809_DCDC4_1800mV_END, |
| 849 | 100000), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 850 | }; |
| 851 | |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 852 | static const struct regulator_desc axp809_regulators[] = { |
| 853 | AXP_DESC(AXP809, DCDC1, "dcdc1", "vin1", 1600, 3400, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 854 | AXP22X_DCDC1_V_OUT, AXP22X_DCDC1_V_OUT_MASK, |
| 855 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC1_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 856 | AXP_DESC(AXP809, DCDC2, "dcdc2", "vin2", 600, 1540, 20, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 857 | AXP22X_DCDC2_V_OUT, AXP22X_DCDC2_V_OUT_MASK, |
| 858 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC2_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 859 | AXP_DESC(AXP809, DCDC3, "dcdc3", "vin3", 600, 1860, 20, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 860 | AXP22X_DCDC3_V_OUT, AXP22X_DCDC3_V_OUT_MASK, |
| 861 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC3_MASK), |
| 862 | AXP_DESC_RANGES(AXP809, DCDC4, "dcdc4", "vin4", |
| 863 | axp809_dcdc4_ranges, AXP809_DCDC4_NUM_VOLTAGES, |
| 864 | AXP22X_DCDC4_V_OUT, AXP22X_DCDC4_V_OUT_MASK, |
| 865 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC4_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 866 | AXP_DESC(AXP809, DCDC5, "dcdc5", "vin5", 1000, 2550, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 867 | AXP22X_DCDC5_V_OUT, AXP22X_DCDC5_V_OUT_MASK, |
| 868 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DCDC5_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 869 | /* secondary switchable output of DCDC1 */ |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 870 | AXP_DESC_SW(AXP809, DC1SW, "dc1sw", NULL, |
| 871 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DC1SW_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 872 | /* LDO regulator internally chained to DCDC5 */ |
| 873 | AXP_DESC(AXP809, DC5LDO, "dc5ldo", NULL, 700, 1400, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 874 | AXP22X_DC5LDO_V_OUT, AXP22X_DC5LDO_V_OUT_MASK, |
| 875 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_DC5LDO_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 876 | AXP_DESC(AXP809, ALDO1, "aldo1", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 877 | AXP22X_ALDO1_V_OUT, AXP22X_ALDO1_V_OUT_MASK, |
| 878 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_ALDO1_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 879 | AXP_DESC(AXP809, ALDO2, "aldo2", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 880 | AXP22X_ALDO2_V_OUT, AXP22X_ALDO2_V_OUT_MASK, |
| 881 | AXP22X_PWR_OUT_CTRL1, AXP22X_PWR_OUT_ALDO2_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 882 | AXP_DESC(AXP809, ALDO3, "aldo3", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 883 | AXP22X_ALDO3_V_OUT, AXP22X_ALDO3_V_OUT_MASK, |
| 884 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ALDO3_MASK), |
| 885 | AXP_DESC_RANGES(AXP809, DLDO1, "dldo1", "dldoin", |
| 886 | axp803_dldo2_ranges, AXP803_DLDO2_NUM_VOLTAGES, |
| 887 | AXP22X_DLDO1_V_OUT, AXP22X_DLDO1_V_OUT_MASK, |
| 888 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO1_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 889 | AXP_DESC(AXP809, DLDO2, "dldo2", "dldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 890 | AXP22X_DLDO2_V_OUT, AXP22X_DLDO2_V_OUT_MASK, |
| 891 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO2_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 892 | AXP_DESC(AXP809, ELDO1, "eldo1", "eldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 893 | AXP22X_ELDO1_V_OUT, AXP22X_ELDO1_V_OUT_MASK, |
| 894 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 895 | AXP_DESC(AXP809, ELDO2, "eldo2", "eldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 896 | AXP22X_ELDO2_V_OUT, AXP22X_ELDO2_V_OUT_MASK, |
| 897 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO2_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 898 | AXP_DESC(AXP809, ELDO3, "eldo3", "eldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 899 | AXP22X_ELDO3_V_OUT, AXP22X_ELDO3_V_OUT_MASK, |
| 900 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO3_MASK), |
Chen-Yu Tsai | 618c808 | 2016-11-11 11:12:43 +0800 | [diff] [blame] | 901 | /* |
| 902 | * Note the datasheet only guarantees reliable operation up to |
| 903 | * 3.3V, this needs to be enforced via dts provided constraints |
| 904 | */ |
| 905 | AXP_DESC_IO(AXP809, LDO_IO0, "ldo_io0", "ips", 700, 3800, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 906 | AXP22X_LDO_IO0_V_OUT, AXP22X_LDO_IO0_V_OUT_MASK, |
| 907 | AXP20X_GPIO0_CTRL, AXP20X_GPIO0_FUNC_MASK, |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 908 | AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), |
Chen-Yu Tsai | 618c808 | 2016-11-11 11:12:43 +0800 | [diff] [blame] | 909 | /* |
| 910 | * Note the datasheet only guarantees reliable operation up to |
| 911 | * 3.3V, this needs to be enforced via dts provided constraints |
| 912 | */ |
| 913 | AXP_DESC_IO(AXP809, LDO_IO1, "ldo_io1", "ips", 700, 3800, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 914 | AXP22X_LDO_IO1_V_OUT, AXP22X_LDO_IO1_V_OUT_MASK, |
| 915 | AXP20X_GPIO1_CTRL, AXP20X_GPIO1_FUNC_MASK, |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 916 | AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), |
| 917 | AXP_DESC_FIXED(AXP809, RTC_LDO, "rtc_ldo", "ips", 1800), |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 918 | AXP_DESC_SW(AXP809, SW, "sw", "swin", |
| 919 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_SW_MASK), |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 920 | }; |
| 921 | |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 922 | static const struct regulator_desc axp813_regulators[] = { |
| 923 | AXP_DESC(AXP813, DCDC1, "dcdc1", "vin1", 1600, 3400, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 924 | AXP803_DCDC1_V_OUT, AXP803_DCDC1_V_OUT_MASK, |
| 925 | AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC1_MASK), |
| 926 | AXP_DESC_RANGES(AXP813, DCDC2, "dcdc2", "vin2", |
| 927 | axp803_dcdc234_ranges, AXP803_DCDC234_NUM_VOLTAGES, |
| 928 | AXP803_DCDC2_V_OUT, AXP803_DCDC2_V_OUT_MASK, |
| 929 | AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC2_MASK), |
| 930 | AXP_DESC_RANGES(AXP813, DCDC3, "dcdc3", "vin3", |
| 931 | axp803_dcdc234_ranges, AXP803_DCDC234_NUM_VOLTAGES, |
| 932 | AXP803_DCDC3_V_OUT, AXP803_DCDC3_V_OUT_MASK, |
| 933 | AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC3_MASK), |
| 934 | AXP_DESC_RANGES(AXP813, DCDC4, "dcdc4", "vin4", |
| 935 | axp803_dcdc234_ranges, AXP803_DCDC234_NUM_VOLTAGES, |
| 936 | AXP803_DCDC4_V_OUT, AXP803_DCDC4_V_OUT_MASK, |
| 937 | AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC4_MASK), |
| 938 | AXP_DESC_RANGES(AXP813, DCDC5, "dcdc5", "vin5", |
| 939 | axp803_dcdc5_ranges, AXP803_DCDC5_NUM_VOLTAGES, |
| 940 | AXP803_DCDC5_V_OUT, AXP803_DCDC5_V_OUT_MASK, |
| 941 | AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC5_MASK), |
| 942 | AXP_DESC_RANGES(AXP813, DCDC6, "dcdc6", "vin6", |
| 943 | axp803_dcdc6_ranges, AXP803_DCDC6_NUM_VOLTAGES, |
| 944 | AXP803_DCDC6_V_OUT, AXP803_DCDC6_V_OUT_MASK, |
| 945 | AXP22X_PWR_OUT_CTRL1, AXP803_PWR_OUT_DCDC6_MASK), |
| 946 | AXP_DESC_RANGES(AXP813, DCDC7, "dcdc7", "vin7", |
| 947 | axp803_dcdc6_ranges, AXP803_DCDC6_NUM_VOLTAGES, |
| 948 | AXP813_DCDC7_V_OUT, AXP813_DCDC7_V_OUT_MASK, |
| 949 | AXP22X_PWR_OUT_CTRL1, AXP813_PWR_OUT_DCDC7_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 950 | AXP_DESC(AXP813, ALDO1, "aldo1", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 951 | AXP22X_ALDO1_V_OUT, AXP22X_ALDO1_V_OUT_MASK, |
| 952 | AXP22X_PWR_OUT_CTRL3, AXP806_PWR_OUT_ALDO1_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 953 | AXP_DESC(AXP813, ALDO2, "aldo2", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 954 | AXP22X_ALDO2_V_OUT, AXP22X_ALDO2_V_OUT, |
| 955 | AXP22X_PWR_OUT_CTRL3, AXP806_PWR_OUT_ALDO2_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 956 | AXP_DESC(AXP813, ALDO3, "aldo3", "aldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 957 | AXP22X_ALDO3_V_OUT, AXP22X_ALDO3_V_OUT_MASK, |
| 958 | AXP22X_PWR_OUT_CTRL3, AXP806_PWR_OUT_ALDO3_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 959 | AXP_DESC(AXP813, DLDO1, "dldo1", "dldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 960 | AXP22X_DLDO1_V_OUT, AXP22X_DLDO1_V_OUT_MASK, |
| 961 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO1_MASK), |
| 962 | AXP_DESC_RANGES(AXP813, DLDO2, "dldo2", "dldoin", |
| 963 | axp803_dldo2_ranges, AXP803_DLDO2_NUM_VOLTAGES, |
| 964 | AXP22X_DLDO2_V_OUT, AXP22X_DLDO2_V_OUT, |
| 965 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO2_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 966 | AXP_DESC(AXP813, DLDO3, "dldo3", "dldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 967 | AXP22X_DLDO3_V_OUT, AXP22X_DLDO3_V_OUT_MASK, |
| 968 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO3_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 969 | AXP_DESC(AXP813, DLDO4, "dldo4", "dldoin", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 970 | AXP22X_DLDO4_V_OUT, AXP22X_DLDO4_V_OUT_MASK, |
| 971 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO4_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 972 | AXP_DESC(AXP813, ELDO1, "eldo1", "eldoin", 700, 1900, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 973 | AXP22X_ELDO1_V_OUT, AXP22X_ELDO1_V_OUT_MASK, |
| 974 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO1_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 975 | AXP_DESC(AXP813, ELDO2, "eldo2", "eldoin", 700, 1900, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 976 | AXP22X_ELDO2_V_OUT, AXP22X_ELDO2_V_OUT_MASK, |
| 977 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO2_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 978 | AXP_DESC(AXP813, ELDO3, "eldo3", "eldoin", 700, 1900, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 979 | AXP22X_ELDO3_V_OUT, AXP22X_ELDO3_V_OUT, |
| 980 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_ELDO3_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 981 | /* to do / check ... */ |
| 982 | AXP_DESC(AXP813, FLDO1, "fldo1", "fldoin", 700, 1450, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 983 | AXP803_FLDO1_V_OUT, AXP803_FLDO1_V_OUT_MASK, |
| 984 | AXP22X_PWR_OUT_CTRL3, AXP803_PWR_OUT_FLDO1_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 985 | AXP_DESC(AXP813, FLDO2, "fldo2", "fldoin", 700, 1450, 50, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 986 | AXP803_FLDO2_V_OUT, AXP803_FLDO2_V_OUT_MASK, |
| 987 | AXP22X_PWR_OUT_CTRL3, AXP803_PWR_OUT_FLDO2_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 988 | /* |
| 989 | * TODO: FLDO3 = {DCDC5, FLDOIN} / 2 |
| 990 | * |
| 991 | * This means FLDO3 effectively switches supplies at runtime, |
| 992 | * something the regulator subsystem does not support. |
| 993 | */ |
| 994 | AXP_DESC_FIXED(AXP813, RTC_LDO, "rtc-ldo", "ips", 1800), |
| 995 | AXP_DESC_IO(AXP813, LDO_IO0, "ldo-io0", "ips", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 996 | AXP22X_LDO_IO0_V_OUT, AXP22X_LDO_IO0_V_OUT_MASK, |
| 997 | AXP20X_GPIO0_CTRL, AXP20X_GPIO0_FUNC_MASK, |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 998 | AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), |
| 999 | AXP_DESC_IO(AXP813, LDO_IO1, "ldo-io1", "ips", 700, 3300, 100, |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 1000 | AXP22X_LDO_IO1_V_OUT, AXP22X_LDO_IO1_V_OUT_MASK, |
| 1001 | AXP20X_GPIO1_CTRL, AXP20X_GPIO1_FUNC_MASK, |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 1002 | AXP22X_IO_ENABLED, AXP22X_IO_DISABLED), |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 1003 | AXP_DESC_SW(AXP813, SW, "sw", "swin", |
| 1004 | AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DC1SW_MASK), |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 1005 | }; |
| 1006 | |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1007 | static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) |
| 1008 | { |
| 1009 | struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 1010 | unsigned int reg = AXP20X_DCDC_FREQ; |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1011 | u32 min, max, def, step; |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1012 | |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1013 | switch (axp20x->variant) { |
| 1014 | case AXP202_ID: |
| 1015 | case AXP209_ID: |
| 1016 | min = 750; |
| 1017 | max = 1875; |
| 1018 | def = 1500; |
| 1019 | step = 75; |
| 1020 | break; |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1021 | case AXP803_ID: |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 1022 | case AXP813_ID: |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 1023 | /* |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 1024 | * AXP803/AXP813 DCDC work frequency setting has the same |
| 1025 | * range and step as AXP22X, but at a different register. |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 1026 | * (See include/linux/mfd/axp20x.h) |
| 1027 | */ |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1028 | reg = AXP803_DCDC_FREQ_CTRL; |
Gustavo A. R. Silva | 4b03227a | 2018-10-04 14:52:34 +0200 | [diff] [blame] | 1029 | /* Fall through to the check below.*/ |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1030 | case AXP806_ID: |
| 1031 | /* |
| 1032 | * AXP806 also have DCDC work frequency setting register at a |
| 1033 | * different position. |
| 1034 | */ |
| 1035 | if (axp20x->variant == AXP806_ID) |
| 1036 | reg = AXP806_DCDC_FREQ_CTRL; |
Gustavo A. R. Silva | 4b03227a | 2018-10-04 14:52:34 +0200 | [diff] [blame] | 1037 | /* Fall through */ |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 1038 | case AXP221_ID: |
Chen-Yu Tsai | 04e0981 | 2016-02-12 10:02:45 +0800 | [diff] [blame] | 1039 | case AXP223_ID: |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 1040 | case AXP809_ID: |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 1041 | min = 1800; |
| 1042 | max = 4050; |
| 1043 | def = 3000; |
| 1044 | step = 150; |
| 1045 | break; |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1046 | default: |
| 1047 | dev_err(&pdev->dev, |
| 1048 | "Setting DCDC frequency for unsupported AXP variant\n"); |
| 1049 | return -EINVAL; |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1050 | } |
| 1051 | |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1052 | if (dcdcfreq == 0) |
| 1053 | dcdcfreq = def; |
| 1054 | |
| 1055 | if (dcdcfreq < min) { |
| 1056 | dcdcfreq = min; |
| 1057 | dev_warn(&pdev->dev, "DCDC frequency too low. Set to %ukHz\n", |
| 1058 | min); |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1059 | } |
| 1060 | |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1061 | if (dcdcfreq > max) { |
| 1062 | dcdcfreq = max; |
| 1063 | dev_warn(&pdev->dev, "DCDC frequency too high. Set to %ukHz\n", |
| 1064 | max); |
| 1065 | } |
| 1066 | |
| 1067 | dcdcfreq = (dcdcfreq - min) / step; |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1068 | |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 1069 | return regmap_update_bits(axp20x->regmap, reg, |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1070 | AXP20X_FREQ_DCDC_MASK, dcdcfreq); |
| 1071 | } |
| 1072 | |
| 1073 | static int axp20x_regulator_parse_dt(struct platform_device *pdev) |
| 1074 | { |
| 1075 | struct device_node *np, *regulators; |
| 1076 | int ret; |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1077 | u32 dcdcfreq = 0; |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1078 | |
| 1079 | np = of_node_get(pdev->dev.parent->of_node); |
| 1080 | if (!np) |
| 1081 | return 0; |
| 1082 | |
Boris BREZILLON | a6016c5 | 2014-05-19 10:25:30 +0200 | [diff] [blame] | 1083 | regulators = of_get_child_by_name(np, "regulators"); |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1084 | if (!regulators) { |
| 1085 | dev_warn(&pdev->dev, "regulators node not found\n"); |
| 1086 | } else { |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1087 | of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq); |
| 1088 | ret = axp20x_set_dcdc_freq(pdev, dcdcfreq); |
| 1089 | if (ret < 0) { |
| 1090 | dev_err(&pdev->dev, "Error setting dcdc frequency: %d\n", ret); |
| 1091 | return ret; |
| 1092 | } |
| 1093 | |
| 1094 | of_node_put(regulators); |
| 1095 | } |
| 1096 | |
| 1097 | return 0; |
| 1098 | } |
| 1099 | |
| 1100 | static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode) |
| 1101 | { |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1102 | struct axp20x_dev *axp20x = rdev_get_drvdata(rdev); |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 1103 | unsigned int reg = AXP20X_DCDC_MODE; |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1104 | unsigned int mask; |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1105 | |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1106 | switch (axp20x->variant) { |
| 1107 | case AXP202_ID: |
| 1108 | case AXP209_ID: |
| 1109 | if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3)) |
| 1110 | return -EINVAL; |
| 1111 | |
| 1112 | mask = AXP20X_WORKMODE_DCDC2_MASK; |
| 1113 | if (id == AXP20X_DCDC3) |
| 1114 | mask = AXP20X_WORKMODE_DCDC3_MASK; |
| 1115 | |
| 1116 | workmode <<= ffs(mask) - 1; |
| 1117 | break; |
| 1118 | |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 1119 | case AXP806_ID: |
| 1120 | reg = AXP806_DCDC_MODE_CTRL2; |
| 1121 | /* |
| 1122 | * AXP806 DCDC regulator IDs have the same range as AXP22X. |
| 1123 | * Fall through to the check below. |
| 1124 | * (See include/linux/mfd/axp20x.h) |
| 1125 | */ |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 1126 | case AXP221_ID: |
Chen-Yu Tsai | 04e0981 | 2016-02-12 10:02:45 +0800 | [diff] [blame] | 1127 | case AXP223_ID: |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 1128 | case AXP809_ID: |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 1129 | if (id < AXP22X_DCDC1 || id > AXP22X_DCDC5) |
| 1130 | return -EINVAL; |
| 1131 | |
| 1132 | mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP22X_DCDC1); |
| 1133 | workmode <<= id - AXP22X_DCDC1; |
| 1134 | break; |
| 1135 | |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1136 | case AXP803_ID: |
| 1137 | if (id < AXP803_DCDC1 || id > AXP803_DCDC6) |
| 1138 | return -EINVAL; |
| 1139 | |
| 1140 | mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP803_DCDC1); |
| 1141 | workmode <<= id - AXP803_DCDC1; |
| 1142 | break; |
| 1143 | |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 1144 | case AXP813_ID: |
| 1145 | if (id < AXP813_DCDC1 || id > AXP813_DCDC7) |
| 1146 | return -EINVAL; |
| 1147 | |
| 1148 | mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP813_DCDC1); |
| 1149 | workmode <<= id - AXP813_DCDC1; |
| 1150 | break; |
| 1151 | |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1152 | default: |
| 1153 | /* should not happen */ |
| 1154 | WARN_ON(1); |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1155 | return -EINVAL; |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1156 | } |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1157 | |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 1158 | return regmap_update_bits(rdev->regmap, reg, mask, workmode); |
| 1159 | } |
| 1160 | |
| 1161 | /* |
| 1162 | * This function checks whether a regulator is part of a poly-phase |
| 1163 | * output setup based on the registers settings. Returns true if it is. |
| 1164 | */ |
| 1165 | static bool axp20x_is_polyphase_slave(struct axp20x_dev *axp20x, int id) |
| 1166 | { |
| 1167 | u32 reg = 0; |
| 1168 | |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1169 | /* |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 1170 | * Currently in our supported AXP variants, only AXP803, AXP806, |
| 1171 | * and AXP813 have polyphase regulators. |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1172 | */ |
| 1173 | switch (axp20x->variant) { |
| 1174 | case AXP803_ID: |
Axel Lin | ad92cea | 2017-10-15 17:03:12 +0800 | [diff] [blame] | 1175 | case AXP813_ID: |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1176 | regmap_read(axp20x->regmap, AXP803_POLYPHASE_CTRL, ®); |
| 1177 | |
| 1178 | switch (id) { |
| 1179 | case AXP803_DCDC3: |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 1180 | return !!(reg & AXP803_DCDC23_POLYPHASE_DUAL); |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1181 | case AXP803_DCDC6: |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 1182 | return !!(reg & AXP803_DCDC56_POLYPHASE_DUAL); |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1183 | } |
| 1184 | break; |
| 1185 | |
| 1186 | case AXP806_ID: |
| 1187 | regmap_read(axp20x->regmap, AXP806_DCDC_MODE_CTRL2, ®); |
| 1188 | |
| 1189 | switch (id) { |
| 1190 | case AXP806_DCDCB: |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 1191 | return (((reg & AXP806_DCDCABC_POLYPHASE_MASK) == |
| 1192 | AXP806_DCDCAB_POLYPHASE_DUAL) || |
| 1193 | ((reg & AXP806_DCDCABC_POLYPHASE_MASK) == |
| 1194 | AXP806_DCDCABC_POLYPHASE_TRI)); |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1195 | case AXP806_DCDCC: |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 1196 | return ((reg & AXP806_DCDCABC_POLYPHASE_MASK) == |
| 1197 | AXP806_DCDCABC_POLYPHASE_TRI); |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1198 | case AXP806_DCDCE: |
Olliver Schinagl | db4a555 | 2018-11-26 17:27:42 +0200 | [diff] [blame] | 1199 | return !!(reg & AXP806_DCDCDE_POLYPHASE_DUAL); |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1200 | } |
| 1201 | break; |
| 1202 | |
| 1203 | default: |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 1204 | return false; |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 1205 | } |
| 1206 | |
| 1207 | return false; |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1208 | } |
| 1209 | |
| 1210 | static int axp20x_regulator_probe(struct platform_device *pdev) |
| 1211 | { |
| 1212 | struct regulator_dev *rdev; |
| 1213 | struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1214 | const struct regulator_desc *regulators; |
Chen-Yu Tsai | 765e802 | 2015-01-10 00:23:44 +0800 | [diff] [blame] | 1215 | struct regulator_config config = { |
| 1216 | .dev = pdev->dev.parent, |
| 1217 | .regmap = axp20x->regmap, |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1218 | .driver_data = axp20x, |
Chen-Yu Tsai | 765e802 | 2015-01-10 00:23:44 +0800 | [diff] [blame] | 1219 | }; |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1220 | int ret, i, nregulators; |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1221 | u32 workmode; |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 1222 | const char *dcdc1_name = axp22x_regulators[AXP22X_DCDC1].name; |
| 1223 | const char *dcdc5_name = axp22x_regulators[AXP22X_DCDC5].name; |
Hans de Goede | 636e2a3 | 2016-06-03 18:59:44 +0200 | [diff] [blame] | 1224 | bool drivevbus = false; |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1225 | |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1226 | switch (axp20x->variant) { |
| 1227 | case AXP202_ID: |
| 1228 | case AXP209_ID: |
| 1229 | regulators = axp20x_regulators; |
| 1230 | nregulators = AXP20X_REG_ID_MAX; |
| 1231 | break; |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 1232 | case AXP221_ID: |
Chen-Yu Tsai | 04e0981 | 2016-02-12 10:02:45 +0800 | [diff] [blame] | 1233 | case AXP223_ID: |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 1234 | regulators = axp22x_regulators; |
| 1235 | nregulators = AXP22X_REG_ID_MAX; |
Hans de Goede | 636e2a3 | 2016-06-03 18:59:44 +0200 | [diff] [blame] | 1236 | drivevbus = of_property_read_bool(pdev->dev.parent->of_node, |
| 1237 | "x-powers,drive-vbus-en"); |
Boris BREZILLON | 1b82b4e | 2015-04-10 12:09:04 +0800 | [diff] [blame] | 1238 | break; |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1239 | case AXP803_ID: |
| 1240 | regulators = axp803_regulators; |
| 1241 | nregulators = AXP803_REG_ID_MAX; |
Jagan Teki | 1f5d646 | 2018-04-23 12:02:37 +0530 | [diff] [blame] | 1242 | drivevbus = of_property_read_bool(pdev->dev.parent->of_node, |
| 1243 | "x-powers,drive-vbus-en"); |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1244 | break; |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 1245 | case AXP806_ID: |
| 1246 | regulators = axp806_regulators; |
| 1247 | nregulators = AXP806_REG_ID_MAX; |
| 1248 | break; |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 1249 | case AXP809_ID: |
| 1250 | regulators = axp809_regulators; |
| 1251 | nregulators = AXP809_REG_ID_MAX; |
| 1252 | break; |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 1253 | case AXP813_ID: |
| 1254 | regulators = axp813_regulators; |
| 1255 | nregulators = AXP813_REG_ID_MAX; |
| 1256 | drivevbus = of_property_read_bool(pdev->dev.parent->of_node, |
| 1257 | "x-powers,drive-vbus-en"); |
| 1258 | break; |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1259 | default: |
| 1260 | dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n", |
| 1261 | axp20x->variant); |
| 1262 | return -EINVAL; |
| 1263 | } |
| 1264 | |
Chen-Yu Tsai | 765e802 | 2015-01-10 00:23:44 +0800 | [diff] [blame] | 1265 | /* This only sets the dcdc freq. Ignore any errors */ |
| 1266 | axp20x_regulator_parse_dt(pdev); |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1267 | |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1268 | for (i = 0; i < nregulators; i++) { |
Chen-Yu Tsai | 7118f19 | 2015-09-30 14:39:46 +0800 | [diff] [blame] | 1269 | const struct regulator_desc *desc = ®ulators[i]; |
| 1270 | struct regulator_desc *new_desc; |
| 1271 | |
| 1272 | /* |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 1273 | * If this regulator is a slave in a poly-phase setup, |
| 1274 | * skip it, as its controls are bound to the master |
| 1275 | * regulator and won't work. |
| 1276 | */ |
| 1277 | if (axp20x_is_polyphase_slave(axp20x, i)) |
| 1278 | continue; |
| 1279 | |
Chen-Yu Tsai | d81851c | 2017-09-29 11:25:09 +0800 | [diff] [blame] | 1280 | /* Support for AXP813's FLDO3 is not implemented */ |
| 1281 | if (axp20x->variant == AXP813_ID && i == AXP813_FLDO3) |
| 1282 | continue; |
| 1283 | |
Chen-Yu Tsai | 2ca342d | 2016-08-27 15:55:39 +0800 | [diff] [blame] | 1284 | /* |
Chen-Yu Tsai | 7118f19 | 2015-09-30 14:39:46 +0800 | [diff] [blame] | 1285 | * Regulators DC1SW and DC5LDO are connected internally, |
| 1286 | * so we have to handle their supply names separately. |
| 1287 | * |
| 1288 | * We always register the regulators in proper sequence, |
| 1289 | * so the supply names are correctly read. See the last |
| 1290 | * part of this loop to see where we save the DT defined |
| 1291 | * name. |
| 1292 | */ |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 1293 | if ((regulators == axp22x_regulators && i == AXP22X_DC1SW) || |
Icenowy Zheng | 1dbe0cc | 2017-05-18 15:16:49 +0800 | [diff] [blame] | 1294 | (regulators == axp803_regulators && i == AXP803_DC1SW) || |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 1295 | (regulators == axp809_regulators && i == AXP809_DC1SW)) { |
| 1296 | new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc), |
| 1297 | GFP_KERNEL); |
Gustavo A. R. Silva | da26296 | 2017-07-06 16:49:18 -0500 | [diff] [blame] | 1298 | if (!new_desc) |
| 1299 | return -ENOMEM; |
| 1300 | |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 1301 | *new_desc = regulators[i]; |
| 1302 | new_desc->supply_name = dcdc1_name; |
| 1303 | desc = new_desc; |
| 1304 | } |
| 1305 | |
| 1306 | if ((regulators == axp22x_regulators && i == AXP22X_DC5LDO) || |
| 1307 | (regulators == axp809_regulators && i == AXP809_DC5LDO)) { |
| 1308 | new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc), |
| 1309 | GFP_KERNEL); |
Gustavo A. R. Silva | da26296 | 2017-07-06 16:49:18 -0500 | [diff] [blame] | 1310 | if (!new_desc) |
| 1311 | return -ENOMEM; |
| 1312 | |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 1313 | *new_desc = regulators[i]; |
| 1314 | new_desc->supply_name = dcdc5_name; |
| 1315 | desc = new_desc; |
Chen-Yu Tsai | 7118f19 | 2015-09-30 14:39:46 +0800 | [diff] [blame] | 1316 | } |
| 1317 | |
| 1318 | rdev = devm_regulator_register(&pdev->dev, desc, &config); |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1319 | if (IS_ERR(rdev)) { |
| 1320 | dev_err(&pdev->dev, "Failed to register %s\n", |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1321 | regulators[i].name); |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1322 | |
| 1323 | return PTR_ERR(rdev); |
| 1324 | } |
| 1325 | |
Chen-Yu Tsai | 765e802 | 2015-01-10 00:23:44 +0800 | [diff] [blame] | 1326 | ret = of_property_read_u32(rdev->dev.of_node, |
| 1327 | "x-powers,dcdc-workmode", |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1328 | &workmode); |
| 1329 | if (!ret) { |
| 1330 | if (axp20x_set_dcdc_workmode(rdev, i, workmode)) |
| 1331 | dev_err(&pdev->dev, "Failed to set workmode on %s\n", |
Boris BREZILLON | 866bd95 | 2015-04-10 12:09:03 +0800 | [diff] [blame] | 1332 | rdev->desc->name); |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1333 | } |
Chen-Yu Tsai | 7118f19 | 2015-09-30 14:39:46 +0800 | [diff] [blame] | 1334 | |
| 1335 | /* |
| 1336 | * Save AXP22X DCDC1 / DCDC5 regulator names for later. |
| 1337 | */ |
Chen-Yu Tsai | a51f9f4 | 2016-06-01 00:23:19 +0800 | [diff] [blame] | 1338 | if ((regulators == axp22x_regulators && i == AXP22X_DCDC1) || |
| 1339 | (regulators == axp809_regulators && i == AXP809_DCDC1)) |
| 1340 | of_property_read_string(rdev->dev.of_node, |
| 1341 | "regulator-name", |
| 1342 | &dcdc1_name); |
| 1343 | |
| 1344 | if ((regulators == axp22x_regulators && i == AXP22X_DCDC5) || |
| 1345 | (regulators == axp809_regulators && i == AXP809_DCDC5)) |
| 1346 | of_property_read_string(rdev->dev.of_node, |
| 1347 | "regulator-name", |
| 1348 | &dcdc5_name); |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1349 | } |
| 1350 | |
Hans de Goede | 636e2a3 | 2016-06-03 18:59:44 +0200 | [diff] [blame] | 1351 | if (drivevbus) { |
| 1352 | /* Change N_VBUSEN sense pin to DRIVEVBUS output pin */ |
| 1353 | regmap_update_bits(axp20x->regmap, AXP20X_OVER_TMP, |
| 1354 | AXP22X_MISC_N_VBUSEN_FUNC, 0); |
| 1355 | rdev = devm_regulator_register(&pdev->dev, |
| 1356 | &axp22x_drivevbus_regulator, |
| 1357 | &config); |
| 1358 | if (IS_ERR(rdev)) { |
| 1359 | dev_err(&pdev->dev, "Failed to register drivevbus\n"); |
| 1360 | return PTR_ERR(rdev); |
| 1361 | } |
| 1362 | } |
| 1363 | |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1364 | return 0; |
| 1365 | } |
| 1366 | |
| 1367 | static struct platform_driver axp20x_regulator_driver = { |
| 1368 | .probe = axp20x_regulator_probe, |
| 1369 | .driver = { |
| 1370 | .name = "axp20x-regulator", |
Carlo Caione | dfe7a1b | 2014-04-11 11:38:10 +0200 | [diff] [blame] | 1371 | }, |
| 1372 | }; |
| 1373 | |
| 1374 | module_platform_driver(axp20x_regulator_driver); |
| 1375 | |
| 1376 | MODULE_LICENSE("GPL v2"); |
| 1377 | MODULE_AUTHOR("Carlo Caione <carlo@caione.org>"); |
| 1378 | MODULE_DESCRIPTION("Regulator Driver for AXP20X PMIC"); |
Ian Campbell | d4ea7d8 | 2015-08-01 18:13:25 +0100 | [diff] [blame] | 1379 | MODULE_ALIAS("platform:axp20x-regulator"); |