blob: 5d9c605cf534d9dea23b99885b1a5babffc65869 [file] [log] [blame]
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +01001/*
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +02002 * max14577.c - Regulator driver for the Maxim 14577/77836
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +01003 *
Krzysztof Kozlowski4d047d62014-01-28 13:18:25 +01004 * Copyright (C) 2013,2014 Samsung Electronics
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +01005 * Krzysztof Kozlowski <k.kozlowski@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#include <linux/module.h>
19#include <linux/platform_device.h>
20#include <linux/regulator/driver.h>
21#include <linux/mfd/max14577.h>
22#include <linux/mfd/max14577-private.h>
23#include <linux/regulator/of_regulator.h>
24
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +020025/*
26 * Valid limits of current for max14577 and max77836 chargers.
27 * They must correspond to MBCICHWRCL and MBCICHWRCH fields in CHGCTRL4
28 * register for given chipset.
29 */
30struct maxim_charger_current {
31 /* Minimal current, set in CHGCTRL4/MBCICHWRCL, uA */
32 unsigned int min;
33 /*
34 * Minimal current when high setting is active,
35 * set in CHGCTRL4/MBCICHWRCH, uA
36 */
37 unsigned int high_start;
38 /* Value of one step in high setting, uA */
39 unsigned int high_step;
40 /* Maximum current of high setting, uA */
41 unsigned int max;
42};
43
44/* Table of valid charger currents for different Maxim chipsets */
45static const struct maxim_charger_current maxim_charger_currents[] = {
46 [MAXIM_DEVICE_TYPE_UNKNOWN] = { 0, 0, 0, 0 },
47 [MAXIM_DEVICE_TYPE_MAX14577] = {
48 .min = MAX14577_REGULATOR_CURRENT_LIMIT_MIN,
49 .high_start = MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START,
50 .high_step = MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP,
51 .max = MAX14577_REGULATOR_CURRENT_LIMIT_MAX,
52 },
53 [MAXIM_DEVICE_TYPE_MAX77836] = {
54 .min = MAX77836_REGULATOR_CURRENT_LIMIT_MIN,
55 .high_start = MAX77836_REGULATOR_CURRENT_LIMIT_HIGH_START,
56 .high_step = MAX77836_REGULATOR_CURRENT_LIMIT_HIGH_STEP,
57 .max = MAX77836_REGULATOR_CURRENT_LIMIT_MAX,
58 },
59};
60
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +010061static int max14577_reg_is_enabled(struct regulator_dev *rdev)
62{
63 int rid = rdev_get_id(rdev);
64 struct regmap *rmap = rdev->regmap;
65 u8 reg_data;
66
67 switch (rid) {
68 case MAX14577_CHARGER:
69 max14577_read_reg(rmap, MAX14577_CHG_REG_CHG_CTRL2, &reg_data);
70 if ((reg_data & CHGCTRL2_MBCHOSTEN_MASK) == 0)
71 return 0;
72 max14577_read_reg(rmap, MAX14577_CHG_REG_STATUS3, &reg_data);
73 if ((reg_data & STATUS3_CGMBC_MASK) == 0)
74 return 0;
75 /* MBCHOSTEN and CGMBC are on */
76 return 1;
77 default:
78 return -EINVAL;
79 }
80}
81
82static int max14577_reg_get_current_limit(struct regulator_dev *rdev)
83{
84 u8 reg_data;
85 struct regmap *rmap = rdev->regmap;
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +020086 struct max14577 *max14577 = rdev_get_drvdata(rdev);
87 const struct maxim_charger_current *limits =
88 &maxim_charger_currents[max14577->dev_type];
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +010089
90 if (rdev_get_id(rdev) != MAX14577_CHARGER)
91 return -EINVAL;
92
93 max14577_read_reg(rmap, MAX14577_CHG_REG_CHG_CTRL4, &reg_data);
94
95 if ((reg_data & CHGCTRL4_MBCICHWRCL_MASK) == 0)
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +020096 return limits->min;
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +010097
98 reg_data = ((reg_data & CHGCTRL4_MBCICHWRCH_MASK) >>
99 CHGCTRL4_MBCICHWRCH_SHIFT);
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200100 return limits->high_start + reg_data * limits->high_step;
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100101}
102
103static int max14577_reg_set_current_limit(struct regulator_dev *rdev,
104 int min_uA, int max_uA)
105{
106 int i, current_bits = 0xf;
107 u8 reg_data;
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200108 struct max14577 *max14577 = rdev_get_drvdata(rdev);
109 const struct maxim_charger_current *limits =
110 &maxim_charger_currents[max14577->dev_type];
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100111
112 if (rdev_get_id(rdev) != MAX14577_CHARGER)
113 return -EINVAL;
114
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200115 if (min_uA > limits->max || max_uA < limits->min)
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100116 return -EINVAL;
117
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200118 if (max_uA < limits->high_start) {
119 /*
120 * Less than high_start,
121 * so set the minimal current (turn only Low Bit off)
122 */
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100123 u8 reg_data = 0x0 << CHGCTRL4_MBCICHWRCL_SHIFT;
124 return max14577_update_reg(rdev->regmap,
125 MAX14577_CHG_REG_CHG_CTRL4,
126 CHGCTRL4_MBCICHWRCL_MASK, reg_data);
127 }
128
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200129 /*
130 * max_uA is in range: <high_start, inifinite>, so search for
131 * valid current starting from maximum current.
132 */
133 for (i = limits->max; i >= limits->high_start; i -= limits->high_step) {
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100134 if (i <= max_uA)
135 break;
136 current_bits--;
137 }
138 BUG_ON(current_bits < 0); /* Cannot happen */
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200139
140 /* Turn Low Bit on (use range high_start-max)... */
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100141 reg_data = 0x1 << CHGCTRL4_MBCICHWRCL_SHIFT;
142 /* and set proper High Bits */
143 reg_data |= current_bits << CHGCTRL4_MBCICHWRCH_SHIFT;
144
145 return max14577_update_reg(rdev->regmap, MAX14577_CHG_REG_CHG_CTRL4,
146 CHGCTRL4_MBCICHWRCL_MASK | CHGCTRL4_MBCICHWRCH_MASK,
147 reg_data);
148}
149
150static struct regulator_ops max14577_safeout_ops = {
151 .is_enabled = regulator_is_enabled_regmap,
152 .enable = regulator_enable_regmap,
153 .disable = regulator_disable_regmap,
154 .list_voltage = regulator_list_voltage_linear,
155};
156
157static struct regulator_ops max14577_charger_ops = {
158 .is_enabled = max14577_reg_is_enabled,
159 .enable = regulator_enable_regmap,
160 .disable = regulator_disable_regmap,
161 .get_current_limit = max14577_reg_get_current_limit,
162 .set_current_limit = max14577_reg_set_current_limit,
163};
164
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200165static const struct regulator_desc max14577_supported_regulators[] = {
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100166 [MAX14577_SAFEOUT] = {
167 .name = "SAFEOUT",
168 .id = MAX14577_SAFEOUT,
169 .ops = &max14577_safeout_ops,
170 .type = REGULATOR_VOLTAGE,
171 .owner = THIS_MODULE,
172 .n_voltages = 1,
173 .min_uV = MAX14577_REGULATOR_SAFEOUT_VOLTAGE,
174 .enable_reg = MAX14577_REG_CONTROL2,
175 .enable_mask = CTRL2_SFOUTORD_MASK,
176 },
177 [MAX14577_CHARGER] = {
178 .name = "CHARGER",
179 .id = MAX14577_CHARGER,
180 .ops = &max14577_charger_ops,
181 .type = REGULATOR_CURRENT,
182 .owner = THIS_MODULE,
183 .enable_reg = MAX14577_CHG_REG_CHG_CTRL2,
184 .enable_mask = CHGCTRL2_MBCHOSTEN_MASK,
185 },
186};
187
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200188static struct regulator_ops max77836_ldo_ops = {
189 .is_enabled = regulator_is_enabled_regmap,
190 .enable = regulator_enable_regmap,
191 .disable = regulator_disable_regmap,
192 .list_voltage = regulator_list_voltage_linear,
193 .map_voltage = regulator_map_voltage_linear,
194 .get_voltage_sel = regulator_get_voltage_sel_regmap,
195 .set_voltage_sel = regulator_set_voltage_sel_regmap,
196 /* TODO: add .set_suspend_mode */
197};
198
199static const struct regulator_desc max77836_supported_regulators[] = {
200 [MAX14577_SAFEOUT] = {
201 .name = "SAFEOUT",
202 .id = MAX14577_SAFEOUT,
203 .ops = &max14577_safeout_ops,
204 .type = REGULATOR_VOLTAGE,
205 .owner = THIS_MODULE,
206 .n_voltages = 1,
207 .min_uV = MAX14577_REGULATOR_SAFEOUT_VOLTAGE,
208 .enable_reg = MAX14577_REG_CONTROL2,
209 .enable_mask = CTRL2_SFOUTORD_MASK,
210 },
211 [MAX14577_CHARGER] = {
212 .name = "CHARGER",
213 .id = MAX14577_CHARGER,
214 .ops = &max14577_charger_ops,
215 .type = REGULATOR_CURRENT,
216 .owner = THIS_MODULE,
217 .enable_reg = MAX14577_CHG_REG_CHG_CTRL2,
218 .enable_mask = CHGCTRL2_MBCHOSTEN_MASK,
219 },
220 [MAX77836_LDO1] = {
221 .name = "LDO1",
222 .id = MAX77836_LDO1,
223 .ops = &max77836_ldo_ops,
224 .type = REGULATOR_VOLTAGE,
225 .owner = THIS_MODULE,
226 .n_voltages = MAX77836_REGULATOR_LDO_VOLTAGE_STEPS_NUM,
227 .min_uV = MAX77836_REGULATOR_LDO_VOLTAGE_MIN,
228 .uV_step = MAX77836_REGULATOR_LDO_VOLTAGE_STEP,
229 .enable_reg = MAX77836_LDO_REG_CNFG1_LDO1,
230 .enable_mask = MAX77836_CNFG1_LDO_PWRMD_MASK,
231 .vsel_reg = MAX77836_LDO_REG_CNFG1_LDO1,
232 .vsel_mask = MAX77836_CNFG1_LDO_TV_MASK,
233 },
234 [MAX77836_LDO2] = {
235 .name = "LDO2",
236 .id = MAX77836_LDO2,
237 .ops = &max77836_ldo_ops,
238 .type = REGULATOR_VOLTAGE,
239 .owner = THIS_MODULE,
240 .n_voltages = MAX77836_REGULATOR_LDO_VOLTAGE_STEPS_NUM,
241 .min_uV = MAX77836_REGULATOR_LDO_VOLTAGE_MIN,
242 .uV_step = MAX77836_REGULATOR_LDO_VOLTAGE_STEP,
243 .enable_reg = MAX77836_LDO_REG_CNFG1_LDO2,
244 .enable_mask = MAX77836_CNFG1_LDO_PWRMD_MASK,
245 .vsel_reg = MAX77836_LDO_REG_CNFG1_LDO2,
246 .vsel_mask = MAX77836_CNFG1_LDO_TV_MASK,
247 },
248};
249
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100250#ifdef CONFIG_OF
251static struct of_regulator_match max14577_regulator_matches[] = {
252 { .name = "SAFEOUT", },
253 { .name = "CHARGER", },
254};
255
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200256static struct of_regulator_match max77836_regulator_matches[] = {
257 { .name = "SAFEOUT", },
258 { .name = "CHARGER", },
259 { .name = "LDO1", },
260 { .name = "LDO2", },
261};
262
263static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev,
264 enum maxim_device_type dev_type)
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100265{
266 int ret;
267 struct device_node *np;
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200268 struct of_regulator_match *regulator_matches;
269 unsigned int regulator_matches_size;
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100270
271 np = of_get_child_by_name(pdev->dev.parent->of_node, "regulators");
272 if (!np) {
273 dev_err(&pdev->dev, "Failed to get child OF node for regulators\n");
274 return -EINVAL;
275 }
276
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200277 switch (dev_type) {
278 case MAXIM_DEVICE_TYPE_MAX77836:
279 regulator_matches = max77836_regulator_matches;
280 regulator_matches_size = ARRAY_SIZE(max77836_regulator_matches);
281 break;
282 case MAXIM_DEVICE_TYPE_MAX14577:
283 default:
284 regulator_matches = max14577_regulator_matches;
285 regulator_matches_size = ARRAY_SIZE(max14577_regulator_matches);
286 }
287
288 ret = of_regulator_match(&pdev->dev, np, regulator_matches,
289 regulator_matches_size);
Krzysztof Kozlowski08221fc2014-02-21 13:12:38 +0100290 if (ret < 0)
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100291 dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret);
Krzysztof Kozlowski08221fc2014-02-21 13:12:38 +0100292 else
293 ret = 0;
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100294
Krzysztof Kozlowski667a6b72014-02-05 17:56:27 +0100295 of_node_put(np);
296
297 return ret;
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100298}
299
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200300static inline struct regulator_init_data *match_init_data(int index,
301 enum maxim_device_type dev_type)
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100302{
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200303 switch (dev_type) {
304 case MAXIM_DEVICE_TYPE_MAX77836:
305 return max77836_regulator_matches[index].init_data;
306
307 case MAXIM_DEVICE_TYPE_MAX14577:
308 default:
309 return max14577_regulator_matches[index].init_data;
310 }
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100311}
312
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200313static inline struct device_node *match_of_node(int index,
314 enum maxim_device_type dev_type)
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100315{
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200316 switch (dev_type) {
317 case MAXIM_DEVICE_TYPE_MAX77836:
318 return max77836_regulator_matches[index].of_node;
319
320 case MAXIM_DEVICE_TYPE_MAX14577:
321 default:
322 return max14577_regulator_matches[index].of_node;
323 }
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100324}
325#else /* CONFIG_OF */
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200326static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev,
327 enum maxim_device_type dev_type)
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100328{
329 return 0;
330}
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200331static inline struct regulator_init_data *match_init_data(int index,
332 enum maxim_device_type dev_type)
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100333{
334 return NULL;
335}
336
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200337static inline struct device_node *match_of_node(int index,
338 enum maxim_device_type dev_type)
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100339{
340 return NULL;
341}
342#endif /* CONFIG_OF */
343
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200344/**
345 * Registers for regulators of max77836 use different I2C slave addresses so
346 * different regmaps must be used for them.
347 *
348 * Returns proper regmap for accessing regulator passed by id.
349 */
350static struct regmap *max14577_get_regmap(struct max14577 *max14577,
351 int reg_id)
352{
353 switch (max14577->dev_type) {
354 case MAXIM_DEVICE_TYPE_MAX77836:
355 switch (reg_id) {
356 case MAX77836_SAFEOUT ... MAX77836_CHARGER:
357 return max14577->regmap;
358 default:
359 /* MAX77836_LDO1 ... MAX77836_LDO2 */
360 return max14577->regmap_pmic;
361 }
362
363 case MAXIM_DEVICE_TYPE_MAX14577:
364 default:
365 return max14577->regmap;
366 }
367}
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100368
369static int max14577_regulator_probe(struct platform_device *pdev)
370{
371 struct max14577 *max14577 = dev_get_drvdata(pdev->dev.parent);
372 struct max14577_platform_data *pdata = dev_get_platdata(max14577->dev);
373 int i, ret;
374 struct regulator_config config = {};
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200375 const struct regulator_desc *supported_regulators;
376 unsigned int supported_regulators_size;
377 enum maxim_device_type dev_type = max14577->dev_type;
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100378
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200379 ret = max14577_regulator_dt_parse_pdata(pdev, dev_type);
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100380 if (ret)
381 return ret;
382
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200383 switch (dev_type) {
384 case MAXIM_DEVICE_TYPE_MAX77836:
385 supported_regulators = max77836_supported_regulators;
386 supported_regulators_size = ARRAY_SIZE(max77836_supported_regulators);
387 break;
388 case MAXIM_DEVICE_TYPE_MAX14577:
389 default:
390 supported_regulators = max14577_supported_regulators;
391 supported_regulators_size = ARRAY_SIZE(max14577_supported_regulators);
392 }
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100393
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200394 config.dev = &pdev->dev;
395 config.driver_data = max14577;
396
397 for (i = 0; i < supported_regulators_size; i++) {
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100398 struct regulator_dev *regulator;
399 /*
400 * Index of supported_regulators[] is also the id and must
401 * match index of pdata->regulators[].
402 */
403 if (pdata && pdata->regulators) {
404 config.init_data = pdata->regulators[i].initdata;
405 config.of_node = pdata->regulators[i].of_node;
406 } else {
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200407 config.init_data = match_init_data(i, dev_type);
408 config.of_node = match_of_node(i, dev_type);
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100409 }
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200410 config.regmap = max14577_get_regmap(max14577,
411 supported_regulators[i].id);
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100412
413 regulator = devm_regulator_register(&pdev->dev,
414 &supported_regulators[i], &config);
415 if (IS_ERR(regulator)) {
416 ret = PTR_ERR(regulator);
417 dev_err(&pdev->dev,
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200418 "Regulator init failed for %d/%s with error: %d\n",
419 i, supported_regulators[i].name, ret);
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100420 return ret;
421 }
422 }
423
424 return ret;
425}
426
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200427static const struct platform_device_id max14577_regulator_id[] = {
428 { "max14577-regulator", MAXIM_DEVICE_TYPE_MAX14577, },
429 { "max77836-regulator", MAXIM_DEVICE_TYPE_MAX77836, },
430 { }
431};
432MODULE_DEVICE_TABLE(platform, max14577_regulator_id);
433
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100434static struct platform_driver max14577_regulator_driver = {
435 .driver = {
436 .owner = THIS_MODULE,
437 .name = "max14577-regulator",
438 },
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200439 .probe = max14577_regulator_probe,
440 .id_table = max14577_regulator_id,
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100441};
442
443static int __init max14577_regulator_init(void)
444{
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200445 /* Check for valid values for charger */
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100446 BUILD_BUG_ON(MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START +
447 MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP * 0xf !=
448 MAX14577_REGULATOR_CURRENT_LIMIT_MAX);
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200449 BUILD_BUG_ON(MAX77836_REGULATOR_CURRENT_LIMIT_HIGH_START +
450 MAX77836_REGULATOR_CURRENT_LIMIT_HIGH_STEP * 0xf !=
451 MAX77836_REGULATOR_CURRENT_LIMIT_MAX);
452 /* Valid charger current values must be provided for each chipset */
453 BUILD_BUG_ON(ARRAY_SIZE(maxim_charger_currents) != MAXIM_DEVICE_TYPE_NUM);
454
455 BUILD_BUG_ON(ARRAY_SIZE(max14577_supported_regulators) != MAX14577_REGULATOR_NUM);
456 BUILD_BUG_ON(ARRAY_SIZE(max77836_supported_regulators) != MAX77836_REGULATOR_NUM);
457
458 BUILD_BUG_ON(MAX77836_REGULATOR_LDO_VOLTAGE_MIN +
459 (MAX77836_REGULATOR_LDO_VOLTAGE_STEP *
460 (MAX77836_REGULATOR_LDO_VOLTAGE_STEPS_NUM - 1)) !=
461 MAX77836_REGULATOR_LDO_VOLTAGE_MAX);
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100462
463 return platform_driver_register(&max14577_regulator_driver);
464}
465subsys_initcall(max14577_regulator_init);
466
467static void __exit max14577_regulator_exit(void)
468{
469 platform_driver_unregister(&max14577_regulator_driver);
470}
471module_exit(max14577_regulator_exit);
472
473MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski@samsung.com>");
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +0200474MODULE_DESCRIPTION("Maxim 14577/77836 regulator driver");
Krzysztof Kozlowskib0902bb2013-12-06 12:32:13 +0100475MODULE_LICENSE("GPL");
Axel Lin9f45a3d2013-12-23 14:50:53 +0800476MODULE_ALIAS("platform:max14577-regulator");