blob: 8003c363cdfdd5015b72ff8a148643b4a4989309 [file] [log] [blame]
Wen Sud7a58de2021-05-26 14:52:05 +08001// SPDX-License-Identifier: GPL-2.0
2//
3// Copyright (c) 2021 MediaTek Inc.
4
5#include <linux/platform_device.h>
6#include <linux/mfd/mt6359/registers.h>
Hsin-Hsiung Wang4cfc9652021-05-26 14:52:06 +08007#include <linux/mfd/mt6359p/registers.h>
Wen Sud7a58de2021-05-26 14:52:05 +08008#include <linux/mfd/mt6397/core.h>
9#include <linux/module.h>
10#include <linux/of_device.h>
11#include <linux/regmap.h>
12#include <linux/regulator/driver.h>
13#include <linux/regulator/machine.h>
14#include <linux/regulator/mt6359-regulator.h>
15#include <linux/regulator/of_regulator.h>
16
17#define MT6359_BUCK_MODE_AUTO 0
18#define MT6359_BUCK_MODE_FORCE_PWM 1
19#define MT6359_BUCK_MODE_NORMAL 0
20#define MT6359_BUCK_MODE_LP 2
21
22/*
23 * MT6359 regulators' information
24 *
25 * @desc: standard fields of regulator description.
26 * @status_reg: for query status of regulators.
27 * @qi: Mask for query enable signal status of regulators.
28 * @modeset_reg: for operating AUTO/PWM mode register.
29 * @modeset_mask: MASK for operating modeset register.
30 * @modeset_shift: SHIFT for operating modeset register.
31 */
32struct mt6359_regulator_info {
33 struct regulator_desc desc;
34 u32 status_reg;
35 u32 qi;
36 u32 modeset_reg;
37 u32 modeset_mask;
38 u32 modeset_shift;
39 u32 lp_mode_reg;
40 u32 lp_mode_mask;
41 u32 lp_mode_shift;
42};
43
44#define MT6359_BUCK(match, _name, min, max, step, min_sel, \
45 volt_ranges, _enable_reg, _status_reg, \
46 _vsel_reg, _vsel_mask, \
47 _lp_mode_reg, _lp_mode_shift, \
48 _modeset_reg, _modeset_shift) \
49[MT6359_ID_##_name] = { \
50 .desc = { \
51 .name = #_name, \
52 .of_match = of_match_ptr(match), \
53 .regulators_node = of_match_ptr("regulators"), \
54 .ops = &mt6359_volt_range_ops, \
55 .type = REGULATOR_VOLTAGE, \
56 .id = MT6359_ID_##_name, \
57 .owner = THIS_MODULE, \
58 .uV_step = (step), \
59 .linear_min_sel = (min_sel), \
60 .n_voltages = ((max) - (min)) / (step) + 1, \
61 .min_uV = (min), \
62 .linear_ranges = volt_ranges, \
63 .n_linear_ranges = ARRAY_SIZE(volt_ranges), \
64 .vsel_reg = _vsel_reg, \
65 .vsel_mask = _vsel_mask, \
66 .enable_reg = _enable_reg, \
67 .enable_mask = BIT(0), \
68 .of_map_mode = mt6359_map_mode, \
69 }, \
70 .status_reg = _status_reg, \
71 .qi = BIT(0), \
72 .lp_mode_reg = _lp_mode_reg, \
73 .lp_mode_mask = BIT(_lp_mode_shift), \
74 .lp_mode_shift = _lp_mode_shift, \
75 .modeset_reg = _modeset_reg, \
76 .modeset_mask = BIT(_modeset_shift), \
77 .modeset_shift = _modeset_shift \
78}
79
80#define MT6359_LDO_LINEAR(match, _name, min, max, step, min_sel,\
81 volt_ranges, _enable_reg, _status_reg, \
82 _vsel_reg, _vsel_mask) \
83[MT6359_ID_##_name] = { \
84 .desc = { \
85 .name = #_name, \
86 .of_match = of_match_ptr(match), \
87 .regulators_node = of_match_ptr("regulators"), \
88 .ops = &mt6359_volt_range_ops, \
89 .type = REGULATOR_VOLTAGE, \
90 .id = MT6359_ID_##_name, \
91 .owner = THIS_MODULE, \
92 .uV_step = (step), \
93 .linear_min_sel = (min_sel), \
94 .n_voltages = ((max) - (min)) / (step) + 1, \
95 .min_uV = (min), \
96 .linear_ranges = volt_ranges, \
97 .n_linear_ranges = ARRAY_SIZE(volt_ranges), \
98 .vsel_reg = _vsel_reg, \
99 .vsel_mask = _vsel_mask, \
100 .enable_reg = _enable_reg, \
101 .enable_mask = BIT(0), \
102 }, \
103 .status_reg = _status_reg, \
104 .qi = BIT(0), \
105}
106
107#define MT6359_LDO(match, _name, _volt_table, \
108 _enable_reg, _enable_mask, _status_reg, \
109 _vsel_reg, _vsel_mask, _en_delay) \
110[MT6359_ID_##_name] = { \
111 .desc = { \
112 .name = #_name, \
113 .of_match = of_match_ptr(match), \
114 .regulators_node = of_match_ptr("regulators"), \
115 .ops = &mt6359_volt_table_ops, \
116 .type = REGULATOR_VOLTAGE, \
117 .id = MT6359_ID_##_name, \
118 .owner = THIS_MODULE, \
119 .n_voltages = ARRAY_SIZE(_volt_table), \
120 .volt_table = _volt_table, \
121 .vsel_reg = _vsel_reg, \
122 .vsel_mask = _vsel_mask, \
123 .enable_reg = _enable_reg, \
124 .enable_mask = BIT(_enable_mask), \
125 .enable_time = _en_delay, \
126 }, \
127 .status_reg = _status_reg, \
128 .qi = BIT(0), \
129}
130
131#define MT6359_REG_FIXED(match, _name, _enable_reg, \
132 _status_reg, _fixed_volt) \
133[MT6359_ID_##_name] = { \
134 .desc = { \
135 .name = #_name, \
136 .of_match = of_match_ptr(match), \
137 .regulators_node = of_match_ptr("regulators"), \
138 .ops = &mt6359_volt_fixed_ops, \
139 .type = REGULATOR_VOLTAGE, \
140 .id = MT6359_ID_##_name, \
141 .owner = THIS_MODULE, \
142 .n_voltages = 1, \
143 .enable_reg = _enable_reg, \
144 .enable_mask = BIT(0), \
145 .fixed_uV = (_fixed_volt), \
146 }, \
147 .status_reg = _status_reg, \
148 .qi = BIT(0), \
149}
150
Hsin-Hsiung Wang4cfc9652021-05-26 14:52:06 +0800151#define MT6359P_LDO1(match, _name, _ops, _volt_table, \
152 _enable_reg, _enable_mask, _status_reg, \
153 _vsel_reg, _vsel_mask) \
154[MT6359_ID_##_name] = { \
155 .desc = { \
156 .name = #_name, \
157 .of_match = of_match_ptr(match), \
158 .regulators_node = of_match_ptr("regulators"), \
159 .ops = &_ops, \
160 .type = REGULATOR_VOLTAGE, \
161 .id = MT6359_ID_##_name, \
162 .owner = THIS_MODULE, \
163 .n_voltages = ARRAY_SIZE(_volt_table), \
164 .volt_table = _volt_table, \
165 .vsel_reg = _vsel_reg, \
166 .vsel_mask = _vsel_mask, \
167 .enable_reg = _enable_reg, \
168 .enable_mask = BIT(_enable_mask), \
169 }, \
170 .status_reg = _status_reg, \
171 .qi = BIT(0), \
172}
173
Wen Sud7a58de2021-05-26 14:52:05 +0800174static const struct linear_range mt_volt_range1[] = {
175 REGULATOR_LINEAR_RANGE(800000, 0, 0x70, 12500),
176};
177
178static const struct linear_range mt_volt_range2[] = {
179 REGULATOR_LINEAR_RANGE(400000, 0, 0x7f, 6250),
180};
181
182static const struct linear_range mt_volt_range3[] = {
183 REGULATOR_LINEAR_RANGE(400000, 0, 0x70, 6250),
184};
185
186static const struct linear_range mt_volt_range4[] = {
187 REGULATOR_LINEAR_RANGE(800000, 0, 0x40, 12500),
188};
189
190static const struct linear_range mt_volt_range5[] = {
191 REGULATOR_LINEAR_RANGE(500000, 0, 0x3F, 50000),
192};
193
194static const struct linear_range mt_volt_range6[] = {
195 REGULATOR_LINEAR_RANGE(500000, 0, 0x7f, 6250),
196};
197
198static const struct linear_range mt_volt_range7[] = {
199 REGULATOR_LINEAR_RANGE(500000, 0, 0x7f, 6250),
200};
201
Hsin-Hsiung Wang4cfc9652021-05-26 14:52:06 +0800202static const struct linear_range mt_volt_range8[] = {
203 REGULATOR_LINEAR_RANGE(506250, 0, 0x7f, 6250),
204};
205
Axel Lin5a5e3112021-06-06 14:50:51 +0800206static const unsigned int vsim1_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800207 0, 0, 0, 1700000, 1800000, 0, 0, 0, 2700000, 0, 0, 3000000, 3100000,
208};
209
Axel Lin5a5e3112021-06-06 14:50:51 +0800210static const unsigned int vibr_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800211 1200000, 1300000, 1500000, 0, 1800000, 2000000, 0, 0, 2700000, 2800000,
212 0, 3000000, 0, 3300000,
213};
214
Axel Lin5a5e3112021-06-06 14:50:51 +0800215static const unsigned int vrf12_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800216 0, 0, 1100000, 1200000, 1300000,
217};
218
Axel Lin5a5e3112021-06-06 14:50:51 +0800219static const unsigned int volt18_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800220 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1700000, 1800000, 1900000,
221};
222
Axel Lin5a5e3112021-06-06 14:50:51 +0800223static const unsigned int vcn13_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800224 900000, 1000000, 0, 1200000, 1300000,
225};
226
Axel Lin5a5e3112021-06-06 14:50:51 +0800227static const unsigned int vcn33_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800228 0, 0, 0, 0, 0, 0, 0, 0, 0, 2800000, 0, 0, 0, 3300000, 3400000, 3500000,
229};
230
Axel Lin5a5e3112021-06-06 14:50:51 +0800231static const unsigned int vefuse_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800232 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1700000, 1800000, 1900000, 2000000,
233};
234
Axel Lin5a5e3112021-06-06 14:50:51 +0800235static const unsigned int vxo22_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800236 1800000, 0, 0, 0, 2200000,
237};
238
Axel Lin5a5e3112021-06-06 14:50:51 +0800239static const unsigned int vrfck_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800240 0, 0, 1500000, 0, 0, 0, 0, 1600000, 0, 0, 0, 0, 1700000,
241};
242
Axel Lin5a5e3112021-06-06 14:50:51 +0800243static const unsigned int vrfck_voltages_1[] = {
Hsin-Hsiung Wang4cfc9652021-05-26 14:52:06 +0800244 1240000, 1600000,
245};
246
Axel Lin5a5e3112021-06-06 14:50:51 +0800247static const unsigned int vio28_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800248 0, 0, 0, 0, 0, 0, 0, 0, 0, 2800000, 2900000, 3000000, 3100000, 3300000,
249};
250
Axel Lin5a5e3112021-06-06 14:50:51 +0800251static const unsigned int vemc_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800252 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2900000, 3000000, 0, 3300000,
253};
254
Axel Lin5a5e3112021-06-06 14:50:51 +0800255static const unsigned int vemc_voltages_1[] = {
Hsin-Hsiung Wang4cfc9652021-05-26 14:52:06 +0800256 0, 0, 0, 0, 0, 0, 0, 0, 2500000, 2800000, 2900000, 3000000, 3100000,
257 3300000,
258};
259
Axel Lin5a5e3112021-06-06 14:50:51 +0800260static const unsigned int va12_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800261 0, 0, 0, 0, 0, 0, 1200000, 1300000,
262};
263
Axel Lin5a5e3112021-06-06 14:50:51 +0800264static const unsigned int va09_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800265 0, 0, 800000, 900000, 0, 0, 1200000,
266};
267
Axel Lin5a5e3112021-06-06 14:50:51 +0800268static const unsigned int vrf18_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800269 0, 0, 0, 0, 0, 1700000, 1800000, 1810000,
270};
271
Axel Lin5a5e3112021-06-06 14:50:51 +0800272static const unsigned int vbbck_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800273 0, 0, 0, 0, 1100000, 0, 0, 0, 1150000, 0, 0, 0, 1200000,
274};
275
Axel Lin5a5e3112021-06-06 14:50:51 +0800276static const unsigned int vsim2_voltages[] = {
Wen Sud7a58de2021-05-26 14:52:05 +0800277 0, 0, 0, 1700000, 1800000, 0, 0, 0, 2700000, 0, 0, 3000000, 3100000,
278};
279
280static inline unsigned int mt6359_map_mode(unsigned int mode)
281{
282 switch (mode) {
283 case MT6359_BUCK_MODE_NORMAL:
284 return REGULATOR_MODE_NORMAL;
285 case MT6359_BUCK_MODE_FORCE_PWM:
286 return REGULATOR_MODE_FAST;
287 case MT6359_BUCK_MODE_LP:
288 return REGULATOR_MODE_IDLE;
289 default:
290 return REGULATOR_MODE_INVALID;
291 }
292}
293
294static int mt6359_get_status(struct regulator_dev *rdev)
295{
296 int ret;
297 u32 regval;
298 struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
299
300 ret = regmap_read(rdev->regmap, info->status_reg, &regval);
301 if (ret != 0) {
302 dev_err(&rdev->dev, "Failed to get enable reg: %d\n", ret);
303 return ret;
304 }
305
306 if (regval & info->qi)
307 return REGULATOR_STATUS_ON;
308 else
309 return REGULATOR_STATUS_OFF;
310}
311
312static unsigned int mt6359_regulator_get_mode(struct regulator_dev *rdev)
313{
314 struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
315 int ret, regval;
316
317 ret = regmap_read(rdev->regmap, info->modeset_reg, &regval);
318 if (ret != 0) {
319 dev_err(&rdev->dev,
320 "Failed to get mt6359 buck mode: %d\n", ret);
321 return ret;
322 }
323
324 if ((regval & info->modeset_mask) >> info->modeset_shift ==
325 MT6359_BUCK_MODE_FORCE_PWM)
326 return REGULATOR_MODE_FAST;
327
328 ret = regmap_read(rdev->regmap, info->lp_mode_reg, &regval);
329 if (ret != 0) {
330 dev_err(&rdev->dev,
331 "Failed to get mt6359 buck lp mode: %d\n", ret);
332 return ret;
333 }
334
335 if (regval & info->lp_mode_mask)
336 return REGULATOR_MODE_IDLE;
337 else
338 return REGULATOR_MODE_NORMAL;
339}
340
341static int mt6359_regulator_set_mode(struct regulator_dev *rdev,
342 unsigned int mode)
343{
344 struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
345 int ret = 0, val;
346 int curr_mode;
347
348 curr_mode = mt6359_regulator_get_mode(rdev);
349 switch (mode) {
350 case REGULATOR_MODE_FAST:
351 val = MT6359_BUCK_MODE_FORCE_PWM;
352 val <<= info->modeset_shift;
353 ret = regmap_update_bits(rdev->regmap,
354 info->modeset_reg,
355 info->modeset_mask,
356 val);
357 break;
358 case REGULATOR_MODE_NORMAL:
359 if (curr_mode == REGULATOR_MODE_FAST) {
360 val = MT6359_BUCK_MODE_AUTO;
361 val <<= info->modeset_shift;
362 ret = regmap_update_bits(rdev->regmap,
363 info->modeset_reg,
364 info->modeset_mask,
365 val);
366 } else if (curr_mode == REGULATOR_MODE_IDLE) {
367 val = MT6359_BUCK_MODE_NORMAL;
368 val <<= info->lp_mode_shift;
369 ret = regmap_update_bits(rdev->regmap,
370 info->lp_mode_reg,
371 info->lp_mode_mask,
372 val);
373 udelay(100);
374 }
375 break;
376 case REGULATOR_MODE_IDLE:
377 val = MT6359_BUCK_MODE_LP >> 1;
378 val <<= info->lp_mode_shift;
379 ret = regmap_update_bits(rdev->regmap,
380 info->lp_mode_reg,
381 info->lp_mode_mask,
382 val);
383 break;
384 default:
385 return -EINVAL;
386 }
387
388 if (ret != 0) {
389 dev_err(&rdev->dev,
390 "Failed to set mt6359 buck mode: %d\n", ret);
391 }
392
393 return ret;
394}
395
Hsin-Hsiung Wang4cfc9652021-05-26 14:52:06 +0800396static int mt6359p_vemc_set_voltage_sel(struct regulator_dev *rdev,
397 u32 sel)
398{
399 struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
400 int ret;
401 u32 val = 0;
402
403 sel <<= ffs(info->desc.vsel_mask) - 1;
404 ret = regmap_write(rdev->regmap, MT6359P_TMA_KEY_ADDR, TMA_KEY);
405 if (ret)
406 return ret;
407
408 ret = regmap_read(rdev->regmap, MT6359P_VM_MODE_ADDR, &val);
409 if (ret)
410 return ret;
411
412 switch (val) {
413 case 0:
414 /* If HW trapping is 0, use VEMC_VOSEL_0 */
415 ret = regmap_update_bits(rdev->regmap,
416 info->desc.vsel_reg,
417 info->desc.vsel_mask, sel);
418 break;
419 case 1:
420 /* If HW trapping is 1, use VEMC_VOSEL_1 */
421 ret = regmap_update_bits(rdev->regmap,
422 info->desc.vsel_reg + 0x2,
423 info->desc.vsel_mask, sel);
424 break;
425 default:
426 return -EINVAL;
427 }
428
429 if (ret)
430 return ret;
431
432 ret = regmap_write(rdev->regmap, MT6359P_TMA_KEY_ADDR, 0);
433 return ret;
434}
435
436static int mt6359p_vemc_get_voltage_sel(struct regulator_dev *rdev)
437{
438 struct mt6359_regulator_info *info = rdev_get_drvdata(rdev);
439 int ret;
440 u32 val = 0;
441
442 ret = regmap_read(rdev->regmap, MT6359P_VM_MODE_ADDR, &val);
443 if (ret)
444 return ret;
445 switch (val) {
446 case 0:
447 /* If HW trapping is 0, use VEMC_VOSEL_0 */
448 ret = regmap_read(rdev->regmap,
449 info->desc.vsel_reg, &val);
450 break;
451 case 1:
452 /* If HW trapping is 1, use VEMC_VOSEL_1 */
453 ret = regmap_read(rdev->regmap,
454 info->desc.vsel_reg + 0x2, &val);
455 break;
456 default:
457 return -EINVAL;
458 }
459 if (ret)
460 return ret;
461
462 val &= info->desc.vsel_mask;
463 val >>= ffs(info->desc.vsel_mask) - 1;
464
465 return val;
466}
467
Wen Sud7a58de2021-05-26 14:52:05 +0800468static const struct regulator_ops mt6359_volt_range_ops = {
469 .list_voltage = regulator_list_voltage_linear_range,
470 .map_voltage = regulator_map_voltage_linear_range,
471 .set_voltage_sel = regulator_set_voltage_sel_regmap,
472 .get_voltage_sel = regulator_get_voltage_sel_regmap,
473 .set_voltage_time_sel = regulator_set_voltage_time_sel,
474 .enable = regulator_enable_regmap,
475 .disable = regulator_disable_regmap,
476 .is_enabled = regulator_is_enabled_regmap,
477 .get_status = mt6359_get_status,
478 .set_mode = mt6359_regulator_set_mode,
479 .get_mode = mt6359_regulator_get_mode,
480};
481
482static const struct regulator_ops mt6359_volt_table_ops = {
483 .list_voltage = regulator_list_voltage_table,
484 .map_voltage = regulator_map_voltage_iterate,
485 .set_voltage_sel = regulator_set_voltage_sel_regmap,
486 .get_voltage_sel = regulator_get_voltage_sel_regmap,
487 .set_voltage_time_sel = regulator_set_voltage_time_sel,
488 .enable = regulator_enable_regmap,
489 .disable = regulator_disable_regmap,
490 .is_enabled = regulator_is_enabled_regmap,
491 .get_status = mt6359_get_status,
492};
493
494static const struct regulator_ops mt6359_volt_fixed_ops = {
495 .enable = regulator_enable_regmap,
496 .disable = regulator_disable_regmap,
497 .is_enabled = regulator_is_enabled_regmap,
498 .get_status = mt6359_get_status,
499};
500
Hsin-Hsiung Wang4cfc9652021-05-26 14:52:06 +0800501static const struct regulator_ops mt6359p_vemc_ops = {
502 .list_voltage = regulator_list_voltage_table,
503 .map_voltage = regulator_map_voltage_iterate,
504 .set_voltage_sel = mt6359p_vemc_set_voltage_sel,
505 .get_voltage_sel = mt6359p_vemc_get_voltage_sel,
506 .set_voltage_time_sel = regulator_set_voltage_time_sel,
507 .enable = regulator_enable_regmap,
508 .disable = regulator_disable_regmap,
509 .is_enabled = regulator_is_enabled_regmap,
510 .get_status = mt6359_get_status,
511};
512
Wen Sud7a58de2021-05-26 14:52:05 +0800513/* The array is indexed by id(MT6359_ID_XXX) */
514static struct mt6359_regulator_info mt6359_regulators[] = {
515 MT6359_BUCK("buck_vs1", VS1, 800000, 2200000, 12500, 0,
516 mt_volt_range1, MT6359_RG_BUCK_VS1_EN_ADDR,
517 MT6359_DA_VS1_EN_ADDR, MT6359_RG_BUCK_VS1_VOSEL_ADDR,
518 MT6359_RG_BUCK_VS1_VOSEL_MASK <<
519 MT6359_RG_BUCK_VS1_VOSEL_SHIFT,
520 MT6359_RG_BUCK_VS1_LP_ADDR, MT6359_RG_BUCK_VS1_LP_SHIFT,
521 MT6359_RG_VS1_FPWM_ADDR, MT6359_RG_VS1_FPWM_SHIFT),
522 MT6359_BUCK("buck_vgpu11", VGPU11, 400000, 1193750, 6250, 0,
523 mt_volt_range2, MT6359_RG_BUCK_VGPU11_EN_ADDR,
524 MT6359_DA_VGPU11_EN_ADDR, MT6359_RG_BUCK_VGPU11_VOSEL_ADDR,
525 MT6359_RG_BUCK_VGPU11_VOSEL_MASK <<
526 MT6359_RG_BUCK_VGPU11_VOSEL_SHIFT,
527 MT6359_RG_BUCK_VGPU11_LP_ADDR,
528 MT6359_RG_BUCK_VGPU11_LP_SHIFT,
529 MT6359_RG_VGPU11_FCCM_ADDR, MT6359_RG_VGPU11_FCCM_SHIFT),
530 MT6359_BUCK("buck_vmodem", VMODEM, 400000, 1100000, 6250, 0,
531 mt_volt_range3, MT6359_RG_BUCK_VMODEM_EN_ADDR,
532 MT6359_DA_VMODEM_EN_ADDR, MT6359_RG_BUCK_VMODEM_VOSEL_ADDR,
533 MT6359_RG_BUCK_VMODEM_VOSEL_MASK <<
534 MT6359_RG_BUCK_VMODEM_VOSEL_SHIFT,
535 MT6359_RG_BUCK_VMODEM_LP_ADDR,
536 MT6359_RG_BUCK_VMODEM_LP_SHIFT,
537 MT6359_RG_VMODEM_FCCM_ADDR, MT6359_RG_VMODEM_FCCM_SHIFT),
538 MT6359_BUCK("buck_vpu", VPU, 400000, 1193750, 6250, 0,
539 mt_volt_range2, MT6359_RG_BUCK_VPU_EN_ADDR,
540 MT6359_DA_VPU_EN_ADDR, MT6359_RG_BUCK_VPU_VOSEL_ADDR,
541 MT6359_RG_BUCK_VPU_VOSEL_MASK <<
542 MT6359_RG_BUCK_VPU_VOSEL_SHIFT,
543 MT6359_RG_BUCK_VPU_LP_ADDR, MT6359_RG_BUCK_VPU_LP_SHIFT,
544 MT6359_RG_VPU_FCCM_ADDR, MT6359_RG_VPU_FCCM_SHIFT),
545 MT6359_BUCK("buck_vcore", VCORE, 400000, 1193750, 6250, 0,
546 mt_volt_range2, MT6359_RG_BUCK_VCORE_EN_ADDR,
547 MT6359_DA_VCORE_EN_ADDR, MT6359_RG_BUCK_VCORE_VOSEL_ADDR,
548 MT6359_RG_BUCK_VCORE_VOSEL_MASK <<
549 MT6359_RG_BUCK_VCORE_VOSEL_SHIFT,
550 MT6359_RG_BUCK_VCORE_LP_ADDR, MT6359_RG_BUCK_VCORE_LP_SHIFT,
551 MT6359_RG_VCORE_FCCM_ADDR, MT6359_RG_VCORE_FCCM_SHIFT),
552 MT6359_BUCK("buck_vs2", VS2, 800000, 1600000, 12500, 0,
553 mt_volt_range4, MT6359_RG_BUCK_VS2_EN_ADDR,
554 MT6359_DA_VS2_EN_ADDR, MT6359_RG_BUCK_VS2_VOSEL_ADDR,
555 MT6359_RG_BUCK_VS2_VOSEL_MASK <<
556 MT6359_RG_BUCK_VS2_VOSEL_SHIFT,
557 MT6359_RG_BUCK_VS2_LP_ADDR, MT6359_RG_BUCK_VS2_LP_SHIFT,
558 MT6359_RG_VS2_FPWM_ADDR, MT6359_RG_VS2_FPWM_SHIFT),
559 MT6359_BUCK("buck_vpa", VPA, 500000, 3650000, 50000, 0,
560 mt_volt_range5, MT6359_RG_BUCK_VPA_EN_ADDR,
561 MT6359_DA_VPA_EN_ADDR, MT6359_RG_BUCK_VPA_VOSEL_ADDR,
562 MT6359_RG_BUCK_VPA_VOSEL_MASK <<
563 MT6359_RG_BUCK_VPA_VOSEL_SHIFT,
564 MT6359_RG_BUCK_VPA_LP_ADDR, MT6359_RG_BUCK_VPA_LP_SHIFT,
565 MT6359_RG_VPA_MODESET_ADDR, MT6359_RG_VPA_MODESET_SHIFT),
566 MT6359_BUCK("buck_vproc2", VPROC2, 400000, 1193750, 6250, 0,
567 mt_volt_range2, MT6359_RG_BUCK_VPROC2_EN_ADDR,
568 MT6359_DA_VPROC2_EN_ADDR, MT6359_RG_BUCK_VPROC2_VOSEL_ADDR,
569 MT6359_RG_BUCK_VPROC2_VOSEL_MASK <<
570 MT6359_RG_BUCK_VPROC2_VOSEL_SHIFT,
571 MT6359_RG_BUCK_VPROC2_LP_ADDR,
572 MT6359_RG_BUCK_VPROC2_LP_SHIFT,
573 MT6359_RG_VPROC2_FCCM_ADDR, MT6359_RG_VPROC2_FCCM_SHIFT),
574 MT6359_BUCK("buck_vproc1", VPROC1, 400000, 1193750, 6250, 0,
575 mt_volt_range2, MT6359_RG_BUCK_VPROC1_EN_ADDR,
576 MT6359_DA_VPROC1_EN_ADDR, MT6359_RG_BUCK_VPROC1_VOSEL_ADDR,
577 MT6359_RG_BUCK_VPROC1_VOSEL_MASK <<
578 MT6359_RG_BUCK_VPROC1_VOSEL_SHIFT,
579 MT6359_RG_BUCK_VPROC1_LP_ADDR,
580 MT6359_RG_BUCK_VPROC1_LP_SHIFT,
581 MT6359_RG_VPROC1_FCCM_ADDR, MT6359_RG_VPROC1_FCCM_SHIFT),
582 MT6359_BUCK("buck_vcore_sshub", VCORE_SSHUB, 400000, 1193750, 6250, 0,
583 mt_volt_range2, MT6359_RG_BUCK_VCORE_SSHUB_EN_ADDR,
584 MT6359_DA_VCORE_EN_ADDR,
585 MT6359_RG_BUCK_VCORE_SSHUB_VOSEL_ADDR,
586 MT6359_RG_BUCK_VCORE_SSHUB_VOSEL_MASK <<
587 MT6359_RG_BUCK_VCORE_SSHUB_VOSEL_SHIFT,
588 MT6359_RG_BUCK_VCORE_LP_ADDR, MT6359_RG_BUCK_VCORE_LP_SHIFT,
589 MT6359_RG_VCORE_FCCM_ADDR, MT6359_RG_VCORE_FCCM_SHIFT),
590 MT6359_REG_FIXED("ldo_vaud18", VAUD18, MT6359_RG_LDO_VAUD18_EN_ADDR,
591 MT6359_DA_VAUD18_B_EN_ADDR, 1800000),
592 MT6359_LDO("ldo_vsim1", VSIM1, vsim1_voltages,
593 MT6359_RG_LDO_VSIM1_EN_ADDR, MT6359_RG_LDO_VSIM1_EN_SHIFT,
594 MT6359_DA_VSIM1_B_EN_ADDR, MT6359_RG_VSIM1_VOSEL_ADDR,
595 MT6359_RG_VSIM1_VOSEL_MASK << MT6359_RG_VSIM1_VOSEL_SHIFT,
596 480),
597 MT6359_LDO("ldo_vibr", VIBR, vibr_voltages,
598 MT6359_RG_LDO_VIBR_EN_ADDR, MT6359_RG_LDO_VIBR_EN_SHIFT,
599 MT6359_DA_VIBR_B_EN_ADDR, MT6359_RG_VIBR_VOSEL_ADDR,
600 MT6359_RG_VIBR_VOSEL_MASK << MT6359_RG_VIBR_VOSEL_SHIFT,
601 240),
602 MT6359_LDO("ldo_vrf12", VRF12, vrf12_voltages,
603 MT6359_RG_LDO_VRF12_EN_ADDR, MT6359_RG_LDO_VRF12_EN_SHIFT,
604 MT6359_DA_VRF12_B_EN_ADDR, MT6359_RG_VRF12_VOSEL_ADDR,
605 MT6359_RG_VRF12_VOSEL_MASK << MT6359_RG_VRF12_VOSEL_SHIFT,
606 120),
607 MT6359_REG_FIXED("ldo_vusb", VUSB, MT6359_RG_LDO_VUSB_EN_0_ADDR,
608 MT6359_DA_VUSB_B_EN_ADDR, 3000000),
609 MT6359_LDO_LINEAR("ldo_vsram_proc2", VSRAM_PROC2, 500000, 1293750, 6250,
610 0, mt_volt_range6, MT6359_RG_LDO_VSRAM_PROC2_EN_ADDR,
611 MT6359_DA_VSRAM_PROC2_B_EN_ADDR,
612 MT6359_RG_LDO_VSRAM_PROC2_VOSEL_ADDR,
613 MT6359_RG_LDO_VSRAM_PROC2_VOSEL_MASK <<
614 MT6359_RG_LDO_VSRAM_PROC2_VOSEL_SHIFT),
615 MT6359_LDO("ldo_vio18", VIO18, volt18_voltages,
616 MT6359_RG_LDO_VIO18_EN_ADDR, MT6359_RG_LDO_VIO18_EN_SHIFT,
617 MT6359_DA_VIO18_B_EN_ADDR, MT6359_RG_VIO18_VOSEL_ADDR,
618 MT6359_RG_VIO18_VOSEL_MASK << MT6359_RG_VIO18_VOSEL_SHIFT,
619 960),
620 MT6359_LDO("ldo_vcamio", VCAMIO, volt18_voltages,
621 MT6359_RG_LDO_VCAMIO_EN_ADDR, MT6359_RG_LDO_VCAMIO_EN_SHIFT,
622 MT6359_DA_VCAMIO_B_EN_ADDR, MT6359_RG_VCAMIO_VOSEL_ADDR,
623 MT6359_RG_VCAMIO_VOSEL_MASK << MT6359_RG_VCAMIO_VOSEL_SHIFT,
624 1290),
625 MT6359_REG_FIXED("ldo_vcn18", VCN18, MT6359_RG_LDO_VCN18_EN_ADDR,
626 MT6359_DA_VCN18_B_EN_ADDR, 1800000),
627 MT6359_REG_FIXED("ldo_vfe28", VFE28, MT6359_RG_LDO_VFE28_EN_ADDR,
628 MT6359_DA_VFE28_B_EN_ADDR, 2800000),
629 MT6359_LDO("ldo_vcn13", VCN13, vcn13_voltages,
630 MT6359_RG_LDO_VCN13_EN_ADDR, MT6359_RG_LDO_VCN13_EN_SHIFT,
631 MT6359_DA_VCN13_B_EN_ADDR, MT6359_RG_VCN13_VOSEL_ADDR,
632 MT6359_RG_VCN13_VOSEL_MASK << MT6359_RG_VCN13_VOSEL_SHIFT,
633 240),
634 MT6359_LDO("ldo_vcn33_1_bt", VCN33_1_BT, vcn33_voltages,
635 MT6359_RG_LDO_VCN33_1_EN_0_ADDR,
636 MT6359_RG_LDO_VCN33_1_EN_0_SHIFT,
637 MT6359_DA_VCN33_1_B_EN_ADDR, MT6359_RG_VCN33_1_VOSEL_ADDR,
638 MT6359_RG_VCN33_1_VOSEL_MASK <<
639 MT6359_RG_VCN33_1_VOSEL_SHIFT, 240),
640 MT6359_LDO("ldo_vcn33_1_wifi", VCN33_1_WIFI, vcn33_voltages,
641 MT6359_RG_LDO_VCN33_1_EN_1_ADDR,
642 MT6359_RG_LDO_VCN33_1_EN_1_SHIFT,
643 MT6359_DA_VCN33_1_B_EN_ADDR, MT6359_RG_VCN33_1_VOSEL_ADDR,
644 MT6359_RG_VCN33_1_VOSEL_MASK <<
645 MT6359_RG_VCN33_1_VOSEL_SHIFT, 240),
646 MT6359_REG_FIXED("ldo_vaux18", VAUX18, MT6359_RG_LDO_VAUX18_EN_ADDR,
647 MT6359_DA_VAUX18_B_EN_ADDR, 1800000),
648 MT6359_LDO_LINEAR("ldo_vsram_others", VSRAM_OTHERS, 500000, 1293750,
649 6250, 0, mt_volt_range6,
650 MT6359_RG_LDO_VSRAM_OTHERS_EN_ADDR,
651 MT6359_DA_VSRAM_OTHERS_B_EN_ADDR,
652 MT6359_RG_LDO_VSRAM_OTHERS_VOSEL_ADDR,
653 MT6359_RG_LDO_VSRAM_OTHERS_VOSEL_MASK <<
654 MT6359_RG_LDO_VSRAM_OTHERS_VOSEL_SHIFT),
655 MT6359_LDO("ldo_vefuse", VEFUSE, vefuse_voltages,
656 MT6359_RG_LDO_VEFUSE_EN_ADDR, MT6359_RG_LDO_VEFUSE_EN_SHIFT,
657 MT6359_DA_VEFUSE_B_EN_ADDR, MT6359_RG_VEFUSE_VOSEL_ADDR,
658 MT6359_RG_VEFUSE_VOSEL_MASK << MT6359_RG_VEFUSE_VOSEL_SHIFT,
659 240),
660 MT6359_LDO("ldo_vxo22", VXO22, vxo22_voltages,
661 MT6359_RG_LDO_VXO22_EN_ADDR, MT6359_RG_LDO_VXO22_EN_SHIFT,
662 MT6359_DA_VXO22_B_EN_ADDR, MT6359_RG_VXO22_VOSEL_ADDR,
663 MT6359_RG_VXO22_VOSEL_MASK << MT6359_RG_VXO22_VOSEL_SHIFT,
664 120),
665 MT6359_LDO("ldo_vrfck", VRFCK, vrfck_voltages,
666 MT6359_RG_LDO_VRFCK_EN_ADDR, MT6359_RG_LDO_VRFCK_EN_SHIFT,
667 MT6359_DA_VRFCK_B_EN_ADDR, MT6359_RG_VRFCK_VOSEL_ADDR,
668 MT6359_RG_VRFCK_VOSEL_MASK << MT6359_RG_VRFCK_VOSEL_SHIFT,
669 480),
670 MT6359_REG_FIXED("ldo_vbif28", VBIF28, MT6359_RG_LDO_VBIF28_EN_ADDR,
671 MT6359_DA_VBIF28_B_EN_ADDR, 2800000),
672 MT6359_LDO("ldo_vio28", VIO28, vio28_voltages,
673 MT6359_RG_LDO_VIO28_EN_ADDR, MT6359_RG_LDO_VIO28_EN_SHIFT,
674 MT6359_DA_VIO28_B_EN_ADDR, MT6359_RG_VIO28_VOSEL_ADDR,
675 MT6359_RG_VIO28_VOSEL_MASK << MT6359_RG_VIO28_VOSEL_SHIFT,
676 240),
677 MT6359_LDO("ldo_vemc", VEMC, vemc_voltages,
678 MT6359_RG_LDO_VEMC_EN_ADDR, MT6359_RG_LDO_VEMC_EN_SHIFT,
679 MT6359_DA_VEMC_B_EN_ADDR, MT6359_RG_VEMC_VOSEL_ADDR,
680 MT6359_RG_VEMC_VOSEL_MASK << MT6359_RG_VEMC_VOSEL_SHIFT,
681 240),
682 MT6359_LDO("ldo_vcn33_2_bt", VCN33_2_BT, vcn33_voltages,
683 MT6359_RG_LDO_VCN33_2_EN_0_ADDR,
684 MT6359_RG_LDO_VCN33_2_EN_0_SHIFT,
685 MT6359_DA_VCN33_2_B_EN_ADDR, MT6359_RG_VCN33_2_VOSEL_ADDR,
686 MT6359_RG_VCN33_2_VOSEL_MASK <<
687 MT6359_RG_VCN33_2_VOSEL_SHIFT, 240),
688 MT6359_LDO("ldo_vcn33_2_wifi", VCN33_2_WIFI, vcn33_voltages,
689 MT6359_RG_LDO_VCN33_2_EN_1_ADDR,
690 MT6359_RG_LDO_VCN33_2_EN_1_SHIFT,
691 MT6359_DA_VCN33_2_B_EN_ADDR, MT6359_RG_VCN33_2_VOSEL_ADDR,
692 MT6359_RG_VCN33_2_VOSEL_MASK <<
693 MT6359_RG_VCN33_2_VOSEL_SHIFT, 240),
694 MT6359_LDO("ldo_va12", VA12, va12_voltages,
695 MT6359_RG_LDO_VA12_EN_ADDR, MT6359_RG_LDO_VA12_EN_SHIFT,
696 MT6359_DA_VA12_B_EN_ADDR, MT6359_RG_VA12_VOSEL_ADDR,
697 MT6359_RG_VA12_VOSEL_MASK << MT6359_RG_VA12_VOSEL_SHIFT,
698 240),
699 MT6359_LDO("ldo_va09", VA09, va09_voltages,
700 MT6359_RG_LDO_VA09_EN_ADDR, MT6359_RG_LDO_VA09_EN_SHIFT,
701 MT6359_DA_VA09_B_EN_ADDR, MT6359_RG_VA09_VOSEL_ADDR,
702 MT6359_RG_VA09_VOSEL_MASK << MT6359_RG_VA09_VOSEL_SHIFT,
703 240),
704 MT6359_LDO("ldo_vrf18", VRF18, vrf18_voltages,
705 MT6359_RG_LDO_VRF18_EN_ADDR, MT6359_RG_LDO_VRF18_EN_SHIFT,
706 MT6359_DA_VRF18_B_EN_ADDR, MT6359_RG_VRF18_VOSEL_ADDR,
707 MT6359_RG_VRF18_VOSEL_MASK << MT6359_RG_VRF18_VOSEL_SHIFT,
708 120),
709 MT6359_LDO_LINEAR("ldo_vsram_md", VSRAM_MD, 500000, 1100000, 6250,
710 0, mt_volt_range7, MT6359_RG_LDO_VSRAM_MD_EN_ADDR,
711 MT6359_DA_VSRAM_MD_B_EN_ADDR,
712 MT6359_RG_LDO_VSRAM_MD_VOSEL_ADDR,
713 MT6359_RG_LDO_VSRAM_MD_VOSEL_MASK <<
714 MT6359_RG_LDO_VSRAM_MD_VOSEL_SHIFT),
715 MT6359_LDO("ldo_vufs", VUFS, volt18_voltages,
716 MT6359_RG_LDO_VUFS_EN_ADDR, MT6359_RG_LDO_VUFS_EN_SHIFT,
717 MT6359_DA_VUFS_B_EN_ADDR, MT6359_RG_VUFS_VOSEL_ADDR,
718 MT6359_RG_VUFS_VOSEL_MASK << MT6359_RG_VUFS_VOSEL_SHIFT,
719 1920),
720 MT6359_LDO("ldo_vm18", VM18, volt18_voltages,
721 MT6359_RG_LDO_VM18_EN_ADDR, MT6359_RG_LDO_VM18_EN_SHIFT,
722 MT6359_DA_VM18_B_EN_ADDR, MT6359_RG_VM18_VOSEL_ADDR,
723 MT6359_RG_VM18_VOSEL_MASK << MT6359_RG_VM18_VOSEL_SHIFT,
724 1920),
725 MT6359_LDO("ldo_vbbck", VBBCK, vbbck_voltages,
726 MT6359_RG_LDO_VBBCK_EN_ADDR, MT6359_RG_LDO_VBBCK_EN_SHIFT,
727 MT6359_DA_VBBCK_B_EN_ADDR, MT6359_RG_VBBCK_VOSEL_ADDR,
728 MT6359_RG_VBBCK_VOSEL_MASK << MT6359_RG_VBBCK_VOSEL_SHIFT,
729 240),
730 MT6359_LDO_LINEAR("ldo_vsram_proc1", VSRAM_PROC1, 500000, 1293750, 6250,
731 0, mt_volt_range6, MT6359_RG_LDO_VSRAM_PROC1_EN_ADDR,
732 MT6359_DA_VSRAM_PROC1_B_EN_ADDR,
733 MT6359_RG_LDO_VSRAM_PROC1_VOSEL_ADDR,
734 MT6359_RG_LDO_VSRAM_PROC1_VOSEL_MASK <<
735 MT6359_RG_LDO_VSRAM_PROC1_VOSEL_SHIFT),
736 MT6359_LDO("ldo_vsim2", VSIM2, vsim2_voltages,
737 MT6359_RG_LDO_VSIM2_EN_ADDR, MT6359_RG_LDO_VSIM2_EN_SHIFT,
738 MT6359_DA_VSIM2_B_EN_ADDR, MT6359_RG_VSIM2_VOSEL_ADDR,
739 MT6359_RG_VSIM2_VOSEL_MASK << MT6359_RG_VSIM2_VOSEL_SHIFT,
740 480),
741 MT6359_LDO_LINEAR("ldo_vsram_others_sshub", VSRAM_OTHERS_SSHUB,
742 500000, 1293750, 6250, 0, mt_volt_range6,
743 MT6359_RG_LDO_VSRAM_OTHERS_SSHUB_EN_ADDR,
744 MT6359_DA_VSRAM_OTHERS_B_EN_ADDR,
745 MT6359_RG_LDO_VSRAM_OTHERS_SSHUB_VOSEL_ADDR,
746 MT6359_RG_LDO_VSRAM_OTHERS_SSHUB_VOSEL_MASK <<
747 MT6359_RG_LDO_VSRAM_OTHERS_SSHUB_VOSEL_SHIFT),
748};
749
Hsin-Hsiung Wang4cfc9652021-05-26 14:52:06 +0800750static struct mt6359_regulator_info mt6359p_regulators[] = {
751 MT6359_BUCK("buck_vs1", VS1, 800000, 2200000, 12500, 0,
752 mt_volt_range1, MT6359_RG_BUCK_VS1_EN_ADDR,
753 MT6359_DA_VS1_EN_ADDR, MT6359_RG_BUCK_VS1_VOSEL_ADDR,
754 MT6359_RG_BUCK_VS1_VOSEL_MASK <<
755 MT6359_RG_BUCK_VS1_VOSEL_SHIFT,
756 MT6359_RG_BUCK_VS1_LP_ADDR, MT6359_RG_BUCK_VS1_LP_SHIFT,
757 MT6359_RG_VS1_FPWM_ADDR, MT6359_RG_VS1_FPWM_SHIFT),
758 MT6359_BUCK("buck_vgpu11", VGPU11, 400000, 1193750, 6250, 0,
759 mt_volt_range2, MT6359_RG_BUCK_VGPU11_EN_ADDR,
760 MT6359_DA_VGPU11_EN_ADDR, MT6359P_RG_BUCK_VGPU11_VOSEL_ADDR,
761 MT6359_RG_BUCK_VGPU11_VOSEL_MASK <<
762 MT6359_RG_BUCK_VGPU11_VOSEL_SHIFT,
763 MT6359_RG_BUCK_VGPU11_LP_ADDR,
764 MT6359_RG_BUCK_VGPU11_LP_SHIFT,
765 MT6359_RG_VGPU11_FCCM_ADDR, MT6359_RG_VGPU11_FCCM_SHIFT),
766 MT6359_BUCK("buck_vmodem", VMODEM, 400000, 1100000, 6250, 0,
767 mt_volt_range3, MT6359_RG_BUCK_VMODEM_EN_ADDR,
768 MT6359_DA_VMODEM_EN_ADDR, MT6359_RG_BUCK_VMODEM_VOSEL_ADDR,
769 MT6359_RG_BUCK_VMODEM_VOSEL_MASK <<
770 MT6359_RG_BUCK_VMODEM_VOSEL_SHIFT,
771 MT6359_RG_BUCK_VMODEM_LP_ADDR,
772 MT6359_RG_BUCK_VMODEM_LP_SHIFT,
773 MT6359_RG_VMODEM_FCCM_ADDR, MT6359_RG_VMODEM_FCCM_SHIFT),
774 MT6359_BUCK("buck_vpu", VPU, 400000, 1193750, 6250, 0,
775 mt_volt_range2, MT6359_RG_BUCK_VPU_EN_ADDR,
776 MT6359_DA_VPU_EN_ADDR, MT6359_RG_BUCK_VPU_VOSEL_ADDR,
777 MT6359_RG_BUCK_VPU_VOSEL_MASK <<
778 MT6359_RG_BUCK_VPU_VOSEL_SHIFT,
779 MT6359_RG_BUCK_VPU_LP_ADDR, MT6359_RG_BUCK_VPU_LP_SHIFT,
780 MT6359_RG_VPU_FCCM_ADDR, MT6359_RG_VPU_FCCM_SHIFT),
781 MT6359_BUCK("buck_vcore", VCORE, 506250, 1300000, 6250, 0,
782 mt_volt_range8, MT6359_RG_BUCK_VCORE_EN_ADDR,
783 MT6359_DA_VCORE_EN_ADDR, MT6359P_RG_BUCK_VCORE_VOSEL_ADDR,
784 MT6359_RG_BUCK_VCORE_VOSEL_MASK <<
785 MT6359_RG_BUCK_VCORE_VOSEL_SHIFT,
786 MT6359_RG_BUCK_VCORE_LP_ADDR, MT6359_RG_BUCK_VCORE_LP_SHIFT,
787 MT6359_RG_VCORE_FCCM_ADDR, MT6359_RG_VCORE_FCCM_SHIFT),
788 MT6359_BUCK("buck_vs2", VS2, 800000, 1600000, 12500, 0,
789 mt_volt_range4, MT6359_RG_BUCK_VS2_EN_ADDR,
790 MT6359_DA_VS2_EN_ADDR, MT6359_RG_BUCK_VS2_VOSEL_ADDR,
791 MT6359_RG_BUCK_VS2_VOSEL_MASK <<
792 MT6359_RG_BUCK_VS2_VOSEL_SHIFT,
793 MT6359_RG_BUCK_VS2_LP_ADDR, MT6359_RG_BUCK_VS2_LP_SHIFT,
794 MT6359_RG_VS2_FPWM_ADDR, MT6359_RG_VS2_FPWM_SHIFT),
795 MT6359_BUCK("buck_vpa", VPA, 500000, 3650000, 50000, 0,
796 mt_volt_range5, MT6359_RG_BUCK_VPA_EN_ADDR,
797 MT6359_DA_VPA_EN_ADDR, MT6359_RG_BUCK_VPA_VOSEL_ADDR,
798 MT6359_RG_BUCK_VPA_VOSEL_MASK <<
799 MT6359_RG_BUCK_VPA_VOSEL_SHIFT,
800 MT6359_RG_BUCK_VPA_LP_ADDR, MT6359_RG_BUCK_VPA_LP_SHIFT,
801 MT6359_RG_VPA_MODESET_ADDR, MT6359_RG_VPA_MODESET_SHIFT),
802 MT6359_BUCK("buck_vproc2", VPROC2, 400000, 1193750, 6250, 0,
803 mt_volt_range2, MT6359_RG_BUCK_VPROC2_EN_ADDR,
804 MT6359_DA_VPROC2_EN_ADDR, MT6359_RG_BUCK_VPROC2_VOSEL_ADDR,
805 MT6359_RG_BUCK_VPROC2_VOSEL_MASK <<
806 MT6359_RG_BUCK_VPROC2_VOSEL_SHIFT,
807 MT6359_RG_BUCK_VPROC2_LP_ADDR,
808 MT6359_RG_BUCK_VPROC2_LP_SHIFT,
809 MT6359_RG_VPROC2_FCCM_ADDR, MT6359_RG_VPROC2_FCCM_SHIFT),
810 MT6359_BUCK("buck_vproc1", VPROC1, 400000, 1193750, 6250, 0,
811 mt_volt_range2, MT6359_RG_BUCK_VPROC1_EN_ADDR,
812 MT6359_DA_VPROC1_EN_ADDR, MT6359_RG_BUCK_VPROC1_VOSEL_ADDR,
813 MT6359_RG_BUCK_VPROC1_VOSEL_MASK <<
814 MT6359_RG_BUCK_VPROC1_VOSEL_SHIFT,
815 MT6359_RG_BUCK_VPROC1_LP_ADDR,
816 MT6359_RG_BUCK_VPROC1_LP_SHIFT,
817 MT6359_RG_VPROC1_FCCM_ADDR, MT6359_RG_VPROC1_FCCM_SHIFT),
818 MT6359_BUCK("buck_vgpu11_sshub", VGPU11_SSHUB, 400000, 1193750, 6250, 0,
819 mt_volt_range2, MT6359P_RG_BUCK_VGPU11_SSHUB_EN_ADDR,
820 MT6359_DA_VGPU11_EN_ADDR,
821 MT6359P_RG_BUCK_VGPU11_SSHUB_VOSEL_ADDR,
822 MT6359P_RG_BUCK_VGPU11_SSHUB_VOSEL_MASK <<
823 MT6359P_RG_BUCK_VGPU11_SSHUB_VOSEL_SHIFT,
824 MT6359_RG_BUCK_VGPU11_LP_ADDR,
825 MT6359_RG_BUCK_VGPU11_LP_SHIFT,
826 MT6359_RG_VGPU11_FCCM_ADDR, MT6359_RG_VGPU11_FCCM_SHIFT),
827 MT6359_REG_FIXED("ldo_vaud18", VAUD18, MT6359P_RG_LDO_VAUD18_EN_ADDR,
828 MT6359P_DA_VAUD18_B_EN_ADDR, 1800000),
829 MT6359_LDO("ldo_vsim1", VSIM1, vsim1_voltages,
830 MT6359P_RG_LDO_VSIM1_EN_ADDR, MT6359P_RG_LDO_VSIM1_EN_SHIFT,
831 MT6359P_DA_VSIM1_B_EN_ADDR, MT6359P_RG_VSIM1_VOSEL_ADDR,
832 MT6359_RG_VSIM1_VOSEL_MASK << MT6359_RG_VSIM1_VOSEL_SHIFT,
833 480),
834 MT6359_LDO("ldo_vibr", VIBR, vibr_voltages,
835 MT6359P_RG_LDO_VIBR_EN_ADDR, MT6359P_RG_LDO_VIBR_EN_SHIFT,
836 MT6359P_DA_VIBR_B_EN_ADDR, MT6359P_RG_VIBR_VOSEL_ADDR,
837 MT6359_RG_VIBR_VOSEL_MASK << MT6359_RG_VIBR_VOSEL_SHIFT,
838 240),
839 MT6359_LDO("ldo_vrf12", VRF12, vrf12_voltages,
840 MT6359P_RG_LDO_VRF12_EN_ADDR, MT6359P_RG_LDO_VRF12_EN_SHIFT,
841 MT6359P_DA_VRF12_B_EN_ADDR, MT6359P_RG_VRF12_VOSEL_ADDR,
842 MT6359_RG_VRF12_VOSEL_MASK << MT6359_RG_VRF12_VOSEL_SHIFT,
843 480),
844 MT6359_REG_FIXED("ldo_vusb", VUSB, MT6359P_RG_LDO_VUSB_EN_0_ADDR,
845 MT6359P_DA_VUSB_B_EN_ADDR, 3000000),
846 MT6359_LDO_LINEAR("ldo_vsram_proc2", VSRAM_PROC2, 500000, 1293750, 6250,
847 0, mt_volt_range6, MT6359P_RG_LDO_VSRAM_PROC2_EN_ADDR,
848 MT6359P_DA_VSRAM_PROC2_B_EN_ADDR,
849 MT6359P_RG_LDO_VSRAM_PROC2_VOSEL_ADDR,
850 MT6359_RG_LDO_VSRAM_PROC2_VOSEL_MASK <<
851 MT6359_RG_LDO_VSRAM_PROC2_VOSEL_SHIFT),
852 MT6359_LDO("ldo_vio18", VIO18, volt18_voltages,
853 MT6359P_RG_LDO_VIO18_EN_ADDR, MT6359P_RG_LDO_VIO18_EN_SHIFT,
854 MT6359P_DA_VIO18_B_EN_ADDR, MT6359P_RG_VIO18_VOSEL_ADDR,
855 MT6359_RG_VIO18_VOSEL_MASK << MT6359_RG_VIO18_VOSEL_SHIFT,
856 960),
857 MT6359_LDO("ldo_vcamio", VCAMIO, volt18_voltages,
858 MT6359P_RG_LDO_VCAMIO_EN_ADDR,
859 MT6359P_RG_LDO_VCAMIO_EN_SHIFT,
860 MT6359P_DA_VCAMIO_B_EN_ADDR, MT6359P_RG_VCAMIO_VOSEL_ADDR,
861 MT6359_RG_VCAMIO_VOSEL_MASK << MT6359_RG_VCAMIO_VOSEL_SHIFT,
862 1290),
863 MT6359_REG_FIXED("ldo_vcn18", VCN18, MT6359P_RG_LDO_VCN18_EN_ADDR,
864 MT6359P_DA_VCN18_B_EN_ADDR, 1800000),
865 MT6359_REG_FIXED("ldo_vfe28", VFE28, MT6359P_RG_LDO_VFE28_EN_ADDR,
866 MT6359P_DA_VFE28_B_EN_ADDR, 2800000),
867 MT6359_LDO("ldo_vcn13", VCN13, vcn13_voltages,
868 MT6359P_RG_LDO_VCN13_EN_ADDR, MT6359P_RG_LDO_VCN13_EN_SHIFT,
869 MT6359P_DA_VCN13_B_EN_ADDR, MT6359P_RG_VCN13_VOSEL_ADDR,
870 MT6359_RG_VCN13_VOSEL_MASK << MT6359_RG_VCN13_VOSEL_SHIFT,
871 240),
872 MT6359_LDO("ldo_vcn33_1_bt", VCN33_1_BT, vcn33_voltages,
873 MT6359P_RG_LDO_VCN33_1_EN_0_ADDR,
874 MT6359_RG_LDO_VCN33_1_EN_0_SHIFT,
875 MT6359P_DA_VCN33_1_B_EN_ADDR, MT6359P_RG_VCN33_1_VOSEL_ADDR,
876 MT6359_RG_VCN33_1_VOSEL_MASK <<
877 MT6359_RG_VCN33_1_VOSEL_SHIFT, 240),
878 MT6359_LDO("ldo_vcn33_1_wifi", VCN33_1_WIFI, vcn33_voltages,
879 MT6359P_RG_LDO_VCN33_1_EN_1_ADDR,
880 MT6359P_RG_LDO_VCN33_1_EN_1_SHIFT,
881 MT6359P_DA_VCN33_1_B_EN_ADDR, MT6359P_RG_VCN33_1_VOSEL_ADDR,
882 MT6359_RG_VCN33_1_VOSEL_MASK <<
883 MT6359_RG_VCN33_1_VOSEL_SHIFT, 240),
884 MT6359_REG_FIXED("ldo_vaux18", VAUX18, MT6359P_RG_LDO_VAUX18_EN_ADDR,
885 MT6359P_DA_VAUX18_B_EN_ADDR, 1800000),
886 MT6359_LDO_LINEAR("ldo_vsram_others", VSRAM_OTHERS, 500000, 1293750,
887 6250, 0, mt_volt_range6,
888 MT6359P_RG_LDO_VSRAM_OTHERS_EN_ADDR,
889 MT6359P_DA_VSRAM_OTHERS_B_EN_ADDR,
890 MT6359P_RG_LDO_VSRAM_OTHERS_VOSEL_ADDR,
891 MT6359_RG_LDO_VSRAM_OTHERS_VOSEL_MASK <<
892 MT6359_RG_LDO_VSRAM_OTHERS_VOSEL_SHIFT),
893 MT6359_LDO("ldo_vefuse", VEFUSE, vefuse_voltages,
894 MT6359P_RG_LDO_VEFUSE_EN_ADDR,
895 MT6359P_RG_LDO_VEFUSE_EN_SHIFT,
896 MT6359P_DA_VEFUSE_B_EN_ADDR, MT6359P_RG_VEFUSE_VOSEL_ADDR,
897 MT6359_RG_VEFUSE_VOSEL_MASK << MT6359_RG_VEFUSE_VOSEL_SHIFT,
898 240),
899 MT6359_LDO("ldo_vxo22", VXO22, vxo22_voltages,
900 MT6359P_RG_LDO_VXO22_EN_ADDR, MT6359P_RG_LDO_VXO22_EN_SHIFT,
901 MT6359P_DA_VXO22_B_EN_ADDR, MT6359P_RG_VXO22_VOSEL_ADDR,
902 MT6359_RG_VXO22_VOSEL_MASK << MT6359_RG_VXO22_VOSEL_SHIFT,
903 480),
904 MT6359_LDO("ldo_vrfck_1", VRFCK, vrfck_voltages_1,
905 MT6359P_RG_LDO_VRFCK_EN_ADDR, MT6359P_RG_LDO_VRFCK_EN_SHIFT,
906 MT6359P_DA_VRFCK_B_EN_ADDR, MT6359P_RG_VRFCK_VOSEL_ADDR,
907 MT6359_RG_VRFCK_VOSEL_MASK << MT6359_RG_VRFCK_VOSEL_SHIFT,
908 480),
909 MT6359_REG_FIXED("ldo_vbif28", VBIF28, MT6359P_RG_LDO_VBIF28_EN_ADDR,
910 MT6359P_DA_VBIF28_B_EN_ADDR, 2800000),
911 MT6359_LDO("ldo_vio28", VIO28, vio28_voltages,
912 MT6359P_RG_LDO_VIO28_EN_ADDR, MT6359P_RG_LDO_VIO28_EN_SHIFT,
913 MT6359P_DA_VIO28_B_EN_ADDR, MT6359P_RG_VIO28_VOSEL_ADDR,
914 MT6359_RG_VIO28_VOSEL_MASK << MT6359_RG_VIO28_VOSEL_SHIFT,
915 1920),
916 MT6359P_LDO1("ldo_vemc_1", VEMC, mt6359p_vemc_ops, vemc_voltages_1,
917 MT6359P_RG_LDO_VEMC_EN_ADDR, MT6359P_RG_LDO_VEMC_EN_SHIFT,
918 MT6359P_DA_VEMC_B_EN_ADDR,
919 MT6359P_RG_LDO_VEMC_VOSEL_0_ADDR,
920 MT6359P_RG_LDO_VEMC_VOSEL_0_MASK <<
921 MT6359P_RG_LDO_VEMC_VOSEL_0_SHIFT),
922 MT6359_LDO("ldo_vcn33_2_bt", VCN33_2_BT, vcn33_voltages,
923 MT6359P_RG_LDO_VCN33_2_EN_0_ADDR,
924 MT6359P_RG_LDO_VCN33_2_EN_0_SHIFT,
925 MT6359P_DA_VCN33_2_B_EN_ADDR, MT6359P_RG_VCN33_2_VOSEL_ADDR,
926 MT6359_RG_VCN33_2_VOSEL_MASK <<
927 MT6359_RG_VCN33_2_VOSEL_SHIFT, 240),
928 MT6359_LDO("ldo_vcn33_2_wifi", VCN33_2_WIFI, vcn33_voltages,
929 MT6359P_RG_LDO_VCN33_2_EN_1_ADDR,
930 MT6359_RG_LDO_VCN33_2_EN_1_SHIFT,
931 MT6359P_DA_VCN33_2_B_EN_ADDR, MT6359P_RG_VCN33_2_VOSEL_ADDR,
932 MT6359_RG_VCN33_2_VOSEL_MASK <<
933 MT6359_RG_VCN33_2_VOSEL_SHIFT, 240),
934 MT6359_LDO("ldo_va12", VA12, va12_voltages,
935 MT6359P_RG_LDO_VA12_EN_ADDR, MT6359P_RG_LDO_VA12_EN_SHIFT,
936 MT6359P_DA_VA12_B_EN_ADDR, MT6359P_RG_VA12_VOSEL_ADDR,
937 MT6359_RG_VA12_VOSEL_MASK << MT6359_RG_VA12_VOSEL_SHIFT,
938 960),
939 MT6359_LDO("ldo_va09", VA09, va09_voltages,
940 MT6359P_RG_LDO_VA09_EN_ADDR, MT6359P_RG_LDO_VA09_EN_SHIFT,
941 MT6359P_DA_VA09_B_EN_ADDR, MT6359P_RG_VA09_VOSEL_ADDR,
942 MT6359_RG_VA09_VOSEL_MASK << MT6359_RG_VA09_VOSEL_SHIFT,
943 960),
944 MT6359_LDO("ldo_vrf18", VRF18, vrf18_voltages,
945 MT6359P_RG_LDO_VRF18_EN_ADDR, MT6359P_RG_LDO_VRF18_EN_SHIFT,
946 MT6359P_DA_VRF18_B_EN_ADDR, MT6359P_RG_VRF18_VOSEL_ADDR,
947 MT6359_RG_VRF18_VOSEL_MASK << MT6359_RG_VRF18_VOSEL_SHIFT,
948 240),
949 MT6359_LDO_LINEAR("ldo_vsram_md", VSRAM_MD, 500000, 1293750, 6250,
950 0, mt_volt_range7, MT6359P_RG_LDO_VSRAM_MD_EN_ADDR,
951 MT6359P_DA_VSRAM_MD_B_EN_ADDR,
952 MT6359P_RG_LDO_VSRAM_MD_VOSEL_ADDR,
953 MT6359_RG_LDO_VSRAM_MD_VOSEL_MASK <<
954 MT6359_RG_LDO_VSRAM_MD_VOSEL_SHIFT),
955 MT6359_LDO("ldo_vufs", VUFS, volt18_voltages,
956 MT6359P_RG_LDO_VUFS_EN_ADDR, MT6359P_RG_LDO_VUFS_EN_SHIFT,
957 MT6359P_DA_VUFS_B_EN_ADDR, MT6359P_RG_VUFS_VOSEL_ADDR,
958 MT6359_RG_VUFS_VOSEL_MASK << MT6359_RG_VUFS_VOSEL_SHIFT,
959 1920),
960 MT6359_LDO("ldo_vm18", VM18, volt18_voltages,
961 MT6359P_RG_LDO_VM18_EN_ADDR, MT6359P_RG_LDO_VM18_EN_SHIFT,
962 MT6359P_DA_VM18_B_EN_ADDR, MT6359P_RG_VM18_VOSEL_ADDR,
963 MT6359_RG_VM18_VOSEL_MASK << MT6359_RG_VM18_VOSEL_SHIFT,
964 1920),
965 MT6359_LDO("ldo_vbbck", VBBCK, vbbck_voltages,
966 MT6359P_RG_LDO_VBBCK_EN_ADDR, MT6359P_RG_LDO_VBBCK_EN_SHIFT,
967 MT6359P_DA_VBBCK_B_EN_ADDR, MT6359P_RG_VBBCK_VOSEL_ADDR,
968 MT6359P_RG_VBBCK_VOSEL_MASK << MT6359P_RG_VBBCK_VOSEL_SHIFT,
969 480),
970 MT6359_LDO_LINEAR("ldo_vsram_proc1", VSRAM_PROC1, 500000, 1293750, 6250,
971 0, mt_volt_range6, MT6359P_RG_LDO_VSRAM_PROC1_EN_ADDR,
972 MT6359P_DA_VSRAM_PROC1_B_EN_ADDR,
973 MT6359P_RG_LDO_VSRAM_PROC1_VOSEL_ADDR,
974 MT6359_RG_LDO_VSRAM_PROC1_VOSEL_MASK <<
975 MT6359_RG_LDO_VSRAM_PROC1_VOSEL_SHIFT),
976 MT6359_LDO("ldo_vsim2", VSIM2, vsim2_voltages,
977 MT6359P_RG_LDO_VSIM2_EN_ADDR, MT6359P_RG_LDO_VSIM2_EN_SHIFT,
978 MT6359P_DA_VSIM2_B_EN_ADDR, MT6359P_RG_VSIM2_VOSEL_ADDR,
979 MT6359_RG_VSIM2_VOSEL_MASK << MT6359_RG_VSIM2_VOSEL_SHIFT,
980 480),
981 MT6359_LDO_LINEAR("ldo_vsram_others_sshub", VSRAM_OTHERS_SSHUB,
982 500000, 1293750, 6250, 0, mt_volt_range6,
983 MT6359P_RG_LDO_VSRAM_OTHERS_SSHUB_EN_ADDR,
984 MT6359P_DA_VSRAM_OTHERS_B_EN_ADDR,
985 MT6359P_RG_LDO_VSRAM_OTHERS_SSHUB_VOSEL_ADDR,
986 MT6359_RG_LDO_VSRAM_OTHERS_SSHUB_VOSEL_MASK <<
987 MT6359_RG_LDO_VSRAM_OTHERS_SSHUB_VOSEL_SHIFT),
988};
989
Wen Sud7a58de2021-05-26 14:52:05 +0800990static int mt6359_regulator_probe(struct platform_device *pdev)
991{
992 struct mt6397_chip *mt6397 = dev_get_drvdata(pdev->dev.parent);
993 struct regulator_config config = {};
994 struct regulator_dev *rdev;
Hsin-Hsiung Wang4cfc9652021-05-26 14:52:06 +0800995 struct mt6359_regulator_info *mt6359_info;
996 int i, hw_ver;
997
998 regmap_read(mt6397->regmap, MT6359P_HWCID, &hw_ver);
999 if (hw_ver >= MT6359P_CHIP_VER)
1000 mt6359_info = mt6359p_regulators;
1001 else
1002 mt6359_info = mt6359_regulators;
Wen Sud7a58de2021-05-26 14:52:05 +08001003
1004 config.dev = mt6397->dev;
1005 config.regmap = mt6397->regmap;
Hsin-Hsiung Wang4cfc9652021-05-26 14:52:06 +08001006 for (i = 0; i < MT6359_MAX_REGULATOR; i++, mt6359_info++) {
1007 config.driver_data = mt6359_info;
1008 rdev = devm_regulator_register(&pdev->dev, &mt6359_info->desc, &config);
Wen Sud7a58de2021-05-26 14:52:05 +08001009 if (IS_ERR(rdev)) {
Hsin-Hsiung Wang4cfc9652021-05-26 14:52:06 +08001010 dev_err(&pdev->dev, "failed to register %s\n", mt6359_info->desc.name);
Wen Sud7a58de2021-05-26 14:52:05 +08001011 return PTR_ERR(rdev);
1012 }
1013 }
1014
1015 return 0;
1016}
1017
1018static const struct platform_device_id mt6359_platform_ids[] = {
1019 {"mt6359-regulator", 0},
1020 { /* sentinel */ },
1021};
1022MODULE_DEVICE_TABLE(platform, mt6359_platform_ids);
1023
1024static struct platform_driver mt6359_regulator_driver = {
1025 .driver = {
1026 .name = "mt6359-regulator",
1027 },
1028 .probe = mt6359_regulator_probe,
1029 .id_table = mt6359_platform_ids,
1030};
1031
1032module_platform_driver(mt6359_regulator_driver);
1033
1034MODULE_AUTHOR("Wen Su <wen.su@mediatek.com>");
1035MODULE_DESCRIPTION("Regulator Driver for MediaTek MT6359 PMIC");
1036MODULE_LICENSE("GPL");