17 #include <linux/kernel.h>
18 #include <linux/slab.h>
21 #include <linux/module.h>
24 #define MC13783_REG_SWITCHERS0 24
26 #define MC13783_REG_SWITCHERS0_SW1AEN 0
27 #define MC13783_REG_SWITCHERS0_SW1AVSEL 0
28 #define MC13783_REG_SWITCHERS0_SW1AVSEL_M (63 << 0)
30 #define MC13783_REG_SWITCHERS1 25
32 #define MC13783_REG_SWITCHERS1_SW1BEN 0
33 #define MC13783_REG_SWITCHERS1_SW1BVSEL 0
34 #define MC13783_REG_SWITCHERS1_SW1BVSEL_M (63 << 0)
36 #define MC13783_REG_SWITCHERS2 26
38 #define MC13783_REG_SWITCHERS2_SW2AEN 0
39 #define MC13783_REG_SWITCHERS2_SW2AVSEL 0
40 #define MC13783_REG_SWITCHERS2_SW2AVSEL_M (63 << 0)
42 #define MC13783_REG_SWITCHERS3 27
44 #define MC13783_REG_SWITCHERS3_SW2BEN 0
45 #define MC13783_REG_SWITCHERS3_SW2BVSEL 0
46 #define MC13783_REG_SWITCHERS3_SW2BVSEL_M (63 << 0)
48 #define MC13783_REG_SWITCHERS5 29
49 #define MC13783_REG_SWITCHERS5_SW3EN (1 << 20)
50 #define MC13783_REG_SWITCHERS5_SW3VSEL 18
51 #define MC13783_REG_SWITCHERS5_SW3VSEL_M (3 << 18)
53 #define MC13783_REG_REGULATORSETTING0 30
54 #define MC13783_REG_REGULATORSETTING0_VIOLOVSEL 2
55 #define MC13783_REG_REGULATORSETTING0_VDIGVSEL 4
56 #define MC13783_REG_REGULATORSETTING0_VGENVSEL 6
57 #define MC13783_REG_REGULATORSETTING0_VRFDIGVSEL 9
58 #define MC13783_REG_REGULATORSETTING0_VRFREFVSEL 11
59 #define MC13783_REG_REGULATORSETTING0_VRFCPVSEL 13
60 #define MC13783_REG_REGULATORSETTING0_VSIMVSEL 14
61 #define MC13783_REG_REGULATORSETTING0_VESIMVSEL 15
62 #define MC13783_REG_REGULATORSETTING0_VCAMVSEL 16
64 #define MC13783_REG_REGULATORSETTING0_VIOLOVSEL_M (3 << 2)
65 #define MC13783_REG_REGULATORSETTING0_VDIGVSEL_M (3 << 4)
66 #define MC13783_REG_REGULATORSETTING0_VGENVSEL_M (7 << 6)
67 #define MC13783_REG_REGULATORSETTING0_VRFDIGVSEL_M (3 << 9)
68 #define MC13783_REG_REGULATORSETTING0_VRFREFVSEL_M (3 << 11)
69 #define MC13783_REG_REGULATORSETTING0_VRFCPVSEL_M (1 << 13)
70 #define MC13783_REG_REGULATORSETTING0_VSIMVSEL_M (1 << 14)
71 #define MC13783_REG_REGULATORSETTING0_VESIMVSEL_M (1 << 15)
72 #define MC13783_REG_REGULATORSETTING0_VCAMVSEL_M (7 << 16)
74 #define MC13783_REG_REGULATORSETTING1 31
75 #define MC13783_REG_REGULATORSETTING1_VVIBVSEL 0
76 #define MC13783_REG_REGULATORSETTING1_VRF1VSEL 2
77 #define MC13783_REG_REGULATORSETTING1_VRF2VSEL 4
78 #define MC13783_REG_REGULATORSETTING1_VMMC1VSEL 6
79 #define MC13783_REG_REGULATORSETTING1_VMMC2VSEL 9
81 #define MC13783_REG_REGULATORSETTING1_VVIBVSEL_M (3 << 0)
82 #define MC13783_REG_REGULATORSETTING1_VRF1VSEL_M (3 << 2)
83 #define MC13783_REG_REGULATORSETTING1_VRF2VSEL_M (3 << 4)
84 #define MC13783_REG_REGULATORSETTING1_VMMC1VSEL_M (7 << 6)
85 #define MC13783_REG_REGULATORSETTING1_VMMC2VSEL_M (7 << 9)
87 #define MC13783_REG_REGULATORMODE0 32
88 #define MC13783_REG_REGULATORMODE0_VAUDIOEN (1 << 0)
89 #define MC13783_REG_REGULATORMODE0_VIOHIEN (1 << 3)
90 #define MC13783_REG_REGULATORMODE0_VIOLOEN (1 << 6)
91 #define MC13783_REG_REGULATORMODE0_VDIGEN (1 << 9)
92 #define MC13783_REG_REGULATORMODE0_VGENEN (1 << 12)
93 #define MC13783_REG_REGULATORMODE0_VRFDIGEN (1 << 15)
94 #define MC13783_REG_REGULATORMODE0_VRFREFEN (1 << 18)
95 #define MC13783_REG_REGULATORMODE0_VRFCPEN (1 << 21)
97 #define MC13783_REG_REGULATORMODE1 33
98 #define MC13783_REG_REGULATORMODE1_VSIMEN (1 << 0)
99 #define MC13783_REG_REGULATORMODE1_VESIMEN (1 << 3)
100 #define MC13783_REG_REGULATORMODE1_VCAMEN (1 << 6)
101 #define MC13783_REG_REGULATORMODE1_VRFBGEN (1 << 9)
102 #define MC13783_REG_REGULATORMODE1_VVIBEN (1 << 11)
103 #define MC13783_REG_REGULATORMODE1_VRF1EN (1 << 12)
104 #define MC13783_REG_REGULATORMODE1_VRF2EN (1 << 15)
105 #define MC13783_REG_REGULATORMODE1_VMMC1EN (1 << 18)
106 #define MC13783_REG_REGULATORMODE1_VMMC2EN (1 << 21)
108 #define MC13783_REG_POWERMISC 34
109 #define MC13783_REG_POWERMISC_GPO1EN (1 << 6)
110 #define MC13783_REG_POWERMISC_GPO2EN (1 << 8)
111 #define MC13783_REG_POWERMISC_GPO3EN (1 << 10)
112 #define MC13783_REG_POWERMISC_GPO4EN (1 << 12)
113 #define MC13783_REG_POWERMISC_PWGT1SPIEN (1 << 15)
114 #define MC13783_REG_POWERMISC_PWGT2SPIEN (1 << 16)
116 #define MC13783_REG_POWERMISC_PWGTSPI_M (3 << 15)
120 static const int mc13783_sw1x_val[] = {
121 900000, 925000, 950000, 975000,
122 1000000, 1025000, 1050000, 1075000,
123 1100000, 1125000, 1150000, 1175000,
124 1200000, 1225000, 1250000, 1275000,
125 1300000, 1325000, 1350000, 1375000,
126 1400000, 1425000, 1450000, 1475000,
127 1500000, 1525000, 1550000, 1575000,
128 1600000, 1625000, 1650000, 1675000,
129 1700000, 1700000, 1700000, 1700000,
130 1800000, 1800000, 1800000, 1800000,
131 1850000, 1850000, 1850000, 1850000,
132 2000000, 2000000, 2000000, 2000000,
133 2100000, 2100000, 2100000, 2100000,
134 2200000, 2200000, 2200000, 2200000,
135 2200000, 2200000, 2200000, 2200000,
136 2200000, 2200000, 2200000, 2200000,
139 static const int mc13783_sw2x_val[] = {
140 900000, 925000, 950000, 975000,
141 1000000, 1025000, 1050000, 1075000,
142 1100000, 1125000, 1150000, 1175000,
143 1200000, 1225000, 1250000, 1275000,
144 1300000, 1325000, 1350000, 1375000,
145 1400000, 1425000, 1450000, 1475000,
146 1500000, 1525000, 1550000, 1575000,
147 1600000, 1625000, 1650000, 1675000,
148 1700000, 1700000, 1700000, 1700000,
149 1800000, 1800000, 1800000, 1800000,
150 1900000, 1900000, 1900000, 1900000,
151 2000000, 2000000, 2000000, 2000000,
152 2100000, 2100000, 2100000, 2100000,
153 2200000, 2200000, 2200000, 2200000,
154 2200000, 2200000, 2200000, 2200000,
155 2200000, 2200000, 2200000, 2200000,
158 static const unsigned int mc13783_sw3_val[] = {
159 5000000, 5000000, 5000000, 5500000,
162 static const unsigned int mc13783_vaudio_val[] = {
166 static const unsigned int mc13783_viohi_val[] = {
170 static const unsigned int mc13783_violo_val[] = {
171 1200000, 1300000, 1500000, 1800000,
174 static const unsigned int mc13783_vdig_val[] = {
175 1200000, 1300000, 1500000, 1800000,
178 static const unsigned int mc13783_vgen_val[] = {
179 1200000, 1300000, 1500000, 1800000,
180 1100000, 2000000, 2775000, 2400000,
183 static const unsigned int mc13783_vrfdig_val[] = {
184 1200000, 1500000, 1800000, 1875000,
187 static const unsigned int mc13783_vrfref_val[] = {
188 2475000, 2600000, 2700000, 2775000,
191 static const unsigned int mc13783_vrfcp_val[] = {
195 static const unsigned int mc13783_vsim_val[] = {
196 1800000, 2900000, 3000000,
199 static const unsigned int mc13783_vesim_val[] = {
203 static const unsigned int mc13783_vcam_val[] = {
204 1500000, 1800000, 2500000, 2550000,
205 2600000, 2750000, 2800000, 3000000,
208 static const unsigned int mc13783_vrfbg_val[] = {
212 static const unsigned int mc13783_vvib_val[] = {
213 1300000, 1800000, 2000000, 3000000,
216 static const unsigned int mc13783_vmmc_val[] = {
217 1600000, 1800000, 2000000, 2600000,
218 2700000, 2800000, 2900000, 3000000,
221 static const unsigned int mc13783_vrf_val[] = {
222 1500000, 1875000, 2700000, 2775000,
225 static const unsigned int mc13783_gpo_val[] = {
229 static const unsigned int mc13783_pwgtdrv_val[] = {
235 #define MC13783_DEFINE(prefix, name, reg, vsel_reg, voltages) \
236 MC13xxx_DEFINE(MC13783_REG_, name, reg, vsel_reg, voltages, \
237 mc13xxx_regulator_ops)
239 #define MC13783_FIXED_DEFINE(prefix, name, reg, voltages) \
240 MC13xxx_FIXED_DEFINE(MC13783_REG_, name, reg, voltages, \
241 mc13xxx_fixed_regulator_ops)
243 #define MC13783_GPO_DEFINE(prefix, name, reg, voltages) \
244 MC13xxx_GPO_DEFINE(MC13783_REG_, name, reg, voltages, \
245 mc13783_gpo_regulator_ops)
247 #define MC13783_DEFINE_SW(_name, _reg, _vsel_reg, _voltages) \
248 MC13783_DEFINE(REG, _name, _reg, _vsel_reg, _voltages)
249 #define MC13783_DEFINE_REGU(_name, _reg, _vsel_reg, _voltages) \
250 MC13783_DEFINE(REG, _name, _reg, _vsel_reg, _voltages)
318 valread = (valread & ~mask) | val;
343 return mc13783_powermisc_rmw(priv, mc13xxx_regulators[
id].
enable_bit,
347 static int mc13783_gpo_regulator_disable(
struct regulator_dev *rdev)
361 return mc13783_powermisc_rmw(priv, mc13xxx_regulators[
id].
enable_bit,
365 static int mc13783_gpo_regulator_is_enabled(
struct regulator_dev *rdev)
384 return (val & mc13xxx_regulators[
id].
enable_bit) != 0;
388 .enable = mc13783_gpo_regulator_enable,
389 .disable = mc13783_gpo_regulator_disable,
390 .is_enabled = mc13783_gpo_regulator_is_enabled,
400 dev_get_platdata(&pdev->
dev);
423 desc = &mc13783_regulators[init_data->
id].
desc;
431 dev_err(&pdev->
dev,
"failed to register regulator %s\n",
432 mc13783_regulators[i].
desc.name);
438 platform_set_drvdata(pdev, priv);
452 dev_get_platdata(&pdev->
dev);
455 platform_set_drvdata(pdev,
NULL);
465 .name =
"mc13783-regulator",
469 .probe = mc13783_regulator_probe,
472 static int __init mc13783_regulator_init(
void)
478 static void __exit mc13783_regulator_exit(
void)