2 * max8973-regulator.c -- Maxim max8973
4 * Regulator driver for MAXIM 8973 DC-DC step-down switching regulator.
6 * Copyright (c) 2012, NVIDIA Corporation.
8 * Author: Laxman Dewangan <ldewangan@nvidia.com>
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation version 2.
14 * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
15 * whether express or implied; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/init.h>
28 #include <linux/err.h>
30 #include <linux/of_device.h>
31 #include <linux/platform_device.h>
32 #include <linux/regulator/driver.h>
33 #include <linux/regulator/machine.h>
34 #include <linux/regulator/max8973-regulator.h>
35 #include <linux/regulator/of_regulator.h>
36 #include <linux/gpio.h>
37 #include <linux/of_gpio.h>
38 #include <linux/i2c.h>
39 #include <linux/slab.h>
40 #include <linux/regmap.h>
42 /* Register definitions */
43 #define MAX8973_VOUT 0x0
44 #define MAX8973_VOUT_DVS 0x1
45 #define MAX8973_CONTROL1 0x2
46 #define MAX8973_CONTROL2 0x3
47 #define MAX8973_CHIPID1 0x4
48 #define MAX8973_CHIPID2 0x5
50 #define MAX8973_MAX_VOUT_REG 2
53 #define MAX8973_VOUT_ENABLE BIT(7)
54 #define MAX8973_VOUT_MASK 0x7F
56 /* MAX8973_VOUT_DVS */
57 #define MAX8973_DVS_VOUT_MASK 0x7F
59 /* MAX8973_CONTROL1 */
60 #define MAX8973_SNS_ENABLE BIT(7)
61 #define MAX8973_FPWM_EN_M BIT(6)
62 #define MAX8973_NFSR_ENABLE BIT(5)
63 #define MAX8973_AD_ENABLE BIT(4)
64 #define MAX8973_BIAS_ENABLE BIT(3)
65 #define MAX8973_FREQSHIFT_9PER BIT(2)
67 #define MAX8973_RAMP_12mV_PER_US 0x0
68 #define MAX8973_RAMP_25mV_PER_US 0x1
69 #define MAX8973_RAMP_50mV_PER_US 0x2
70 #define MAX8973_RAMP_200mV_PER_US 0x3
71 #define MAX8973_RAMP_MASK 0x3
73 /* MAX8973_CONTROL2 */
74 #define MAX8973_WDTMR_ENABLE BIT(6)
75 #define MAX8973_DISCH_ENBABLE BIT(5)
76 #define MAX8973_FT_ENABLE BIT(4)
78 #define MAX8973_CKKADV_TRIP_MASK 0xC
79 #define MAX8973_CKKADV_TRIP_DISABLE 0xC
80 #define MAX8973_CKKADV_TRIP_75mV_PER_US 0x0
81 #define MAX8973_CKKADV_TRIP_150mV_PER_US 0x4
82 #define MAX8973_CKKADV_TRIP_75mV_PER_US_HIST_DIS 0x8
83 #define MAX8973_CONTROL_CLKADV_TRIP_MASK 0x00030000
85 #define MAX8973_INDUCTOR_MIN_30_PER 0x0
86 #define MAX8973_INDUCTOR_NOMINAL 0x1
87 #define MAX8973_INDUCTOR_PLUS_30_PER 0x2
88 #define MAX8973_INDUCTOR_PLUS_60_PER 0x3
89 #define MAX8973_CONTROL_INDUCTOR_VALUE_MASK 0x00300000
91 #define MAX8973_MIN_VOLATGE 606250
92 #define MAX8973_MAX_VOLATGE 1400000
93 #define MAX8973_VOLATGE_STEP 6250
94 #define MAX8973_BUCK_N_VOLTAGE 0x80
101 /* Maxim 8973 chip information */
102 struct max8973_chip
{
104 struct regulator_desc desc
;
105 struct regmap
*regmap
;
106 bool enable_external_control
;
109 int lru_index
[MAX8973_MAX_VOUT_REG
];
110 int curr_vout_val
[MAX8973_MAX_VOUT_REG
];
113 struct regulator_ops ops
;
118 * find_voltage_set_register: Find new voltage configuration register (VOUT).
119 * The finding of the new VOUT register will be based on the LRU mechanism.
120 * Each VOUT register will have different voltage configured . This
121 * Function will look if any of the VOUT register have requested voltage set
123 * - If it is already there then it will make that register as most
124 * recently used and return as found so that caller need not to set
125 * the VOUT register but need to set the proper gpios to select this
127 * - If requested voltage is not found then it will use the least
128 * recently mechanism to get new VOUT register for new configuration
129 * and will return not_found so that caller need to set new VOUT
130 * register and then gpios (both).
132 static bool find_voltage_set_register(struct max8973_chip
*tps
,
133 int req_vsel
, int *vout_reg
, int *gpio_val
)
137 int new_vout_reg
= tps
->lru_index
[MAX8973_MAX_VOUT_REG
- 1];
138 int found_index
= MAX8973_MAX_VOUT_REG
- 1;
140 for (i
= 0; i
< MAX8973_MAX_VOUT_REG
; ++i
) {
141 if (tps
->curr_vout_val
[tps
->lru_index
[i
]] == req_vsel
) {
142 new_vout_reg
= tps
->lru_index
[i
];
145 goto update_lru_index
;
150 for (i
= found_index
; i
> 0; i
--)
151 tps
->lru_index
[i
] = tps
->lru_index
[i
- 1];
153 tps
->lru_index
[0] = new_vout_reg
;
154 *gpio_val
= new_vout_reg
;
155 *vout_reg
= MAX8973_VOUT
+ new_vout_reg
;
159 static int max8973_dcdc_get_voltage_sel(struct regulator_dev
*rdev
)
161 struct max8973_chip
*max
= rdev_get_drvdata(rdev
);
165 ret
= regmap_read(max
->regmap
, max
->curr_vout_reg
, &data
);
167 dev_err(max
->dev
, "register %d read failed, err = %d\n",
168 max
->curr_vout_reg
, ret
);
171 return data
& MAX8973_VOUT_MASK
;
174 static int max8973_dcdc_set_voltage_sel(struct regulator_dev
*rdev
,
177 struct max8973_chip
*max
= rdev_get_drvdata(rdev
);
180 int vout_reg
= max
->curr_vout_reg
;
181 int gpio_val
= max
->curr_gpio_val
;
184 * If gpios are available to select the VOUT register then least
185 * recently used register for new configuration.
187 if (gpio_is_valid(max
->dvs_gpio
))
188 found
= find_voltage_set_register(max
, vsel
,
189 &vout_reg
, &gpio_val
);
192 ret
= regmap_update_bits(max
->regmap
, vout_reg
,
193 MAX8973_VOUT_MASK
, vsel
);
195 dev_err(max
->dev
, "register %d update failed, err %d\n",
199 max
->curr_vout_reg
= vout_reg
;
200 max
->curr_vout_val
[gpio_val
] = vsel
;
203 /* Select proper VOUT register vio gpios */
204 if (gpio_is_valid(max
->dvs_gpio
)) {
205 gpio_set_value_cansleep(max
->dvs_gpio
, gpio_val
& 0x1);
206 max
->curr_gpio_val
= gpio_val
;
211 static int max8973_dcdc_set_mode(struct regulator_dev
*rdev
, unsigned int mode
)
213 struct max8973_chip
*max
= rdev_get_drvdata(rdev
);
217 /* Enable force PWM mode in FAST mode only. */
219 case REGULATOR_MODE_FAST
:
220 pwm
= MAX8973_FPWM_EN_M
;
223 case REGULATOR_MODE_NORMAL
:
231 ret
= regmap_update_bits(max
->regmap
, MAX8973_CONTROL1
,
232 MAX8973_FPWM_EN_M
, pwm
);
234 dev_err(max
->dev
, "register %d update failed, err %d\n",
235 MAX8973_CONTROL1
, ret
);
239 static unsigned int max8973_dcdc_get_mode(struct regulator_dev
*rdev
)
241 struct max8973_chip
*max
= rdev_get_drvdata(rdev
);
245 ret
= regmap_read(max
->regmap
, MAX8973_CONTROL1
, &data
);
247 dev_err(max
->dev
, "register %d read failed, err %d\n",
248 MAX8973_CONTROL1
, ret
);
251 return (data
& MAX8973_FPWM_EN_M
) ?
252 REGULATOR_MODE_FAST
: REGULATOR_MODE_NORMAL
;
255 static int max8973_set_ramp_delay(struct regulator_dev
*rdev
,
258 struct max8973_chip
*max
= rdev_get_drvdata(rdev
);
259 unsigned int control
;
264 if (ramp_delay
< 25000) {
265 control
= MAX8973_RAMP_12mV_PER_US
;
267 } else if (ramp_delay
< 50000) {
268 control
= MAX8973_RAMP_25mV_PER_US
;
270 } else if (ramp_delay
< 200000) {
271 control
= MAX8973_RAMP_50mV_PER_US
;
274 control
= MAX8973_RAMP_200mV_PER_US
;
278 ret
= regmap_update_bits(max
->regmap
, MAX8973_CONTROL1
,
279 MAX8973_RAMP_MASK
, control
);
281 dev_err(max
->dev
, "register %d update failed, %d",
282 MAX8973_CONTROL1
, ret
);
286 static int max8973_set_current_limit(struct regulator_dev
*rdev
,
287 int min_ua
, int max_ua
)
289 struct max8973_chip
*max
= rdev_get_drvdata(rdev
);
293 if (max_ua
<= 9000000)
294 val
= MAX8973_CKKADV_TRIP_75mV_PER_US
;
295 else if (max_ua
<= 12000000)
296 val
= MAX8973_CKKADV_TRIP_150mV_PER_US
;
298 val
= MAX8973_CKKADV_TRIP_DISABLE
;
300 ret
= regmap_update_bits(max
->regmap
, MAX8973_CONTROL2
,
301 MAX8973_CKKADV_TRIP_MASK
, val
);
303 dev_err(max
->dev
, "register %d update failed: %d\n",
304 MAX8973_CONTROL2
, ret
);
310 static int max8973_get_current_limit(struct regulator_dev
*rdev
)
312 struct max8973_chip
*max
= rdev_get_drvdata(rdev
);
313 unsigned int control2
;
316 ret
= regmap_read(max
->regmap
, MAX8973_CONTROL2
, &control2
);
318 dev_err(max
->dev
, "register %d read failed: %d\n",
319 MAX8973_CONTROL2
, ret
);
322 switch (control2
& MAX8973_CKKADV_TRIP_MASK
) {
323 case MAX8973_CKKADV_TRIP_DISABLE
:
325 case MAX8973_CKKADV_TRIP_150mV_PER_US
:
327 case MAX8973_CKKADV_TRIP_75mV_PER_US
:
335 static const struct regulator_ops max8973_dcdc_ops
= {
336 .get_voltage_sel
= max8973_dcdc_get_voltage_sel
,
337 .set_voltage_sel
= max8973_dcdc_set_voltage_sel
,
338 .list_voltage
= regulator_list_voltage_linear
,
339 .set_mode
= max8973_dcdc_set_mode
,
340 .get_mode
= max8973_dcdc_get_mode
,
341 .set_voltage_time_sel
= regulator_set_voltage_time_sel
,
342 .set_ramp_delay
= max8973_set_ramp_delay
,
345 static int max8973_init_dcdc(struct max8973_chip
*max
,
346 struct max8973_regulator_platform_data
*pdata
)
349 uint8_t control1
= 0;
350 uint8_t control2
= 0;
353 ret
= regmap_read(max
->regmap
, MAX8973_CONTROL1
, &data
);
355 dev_err(max
->dev
, "register %d read failed, err = %d",
356 MAX8973_CONTROL1
, ret
);
359 control1
= data
& MAX8973_RAMP_MASK
;
361 case MAX8973_RAMP_12mV_PER_US
:
362 max
->desc
.ramp_delay
= 12000;
364 case MAX8973_RAMP_25mV_PER_US
:
365 max
->desc
.ramp_delay
= 25000;
367 case MAX8973_RAMP_50mV_PER_US
:
368 max
->desc
.ramp_delay
= 50000;
370 case MAX8973_RAMP_200mV_PER_US
:
371 max
->desc
.ramp_delay
= 200000;
375 if (pdata
->control_flags
& MAX8973_CONTROL_REMOTE_SENSE_ENABLE
)
376 control1
|= MAX8973_SNS_ENABLE
;
378 if (!(pdata
->control_flags
& MAX8973_CONTROL_FALLING_SLEW_RATE_ENABLE
))
379 control1
|= MAX8973_NFSR_ENABLE
;
381 if (pdata
->control_flags
& MAX8973_CONTROL_OUTPUT_ACTIVE_DISCH_ENABLE
)
382 control1
|= MAX8973_AD_ENABLE
;
384 if (pdata
->control_flags
& MAX8973_CONTROL_BIAS_ENABLE
) {
385 control1
|= MAX8973_BIAS_ENABLE
;
386 max
->desc
.enable_time
= 20;
388 max
->desc
.enable_time
= 240;
391 if (pdata
->control_flags
& MAX8973_CONTROL_FREQ_SHIFT_9PER_ENABLE
)
392 control1
|= MAX8973_FREQSHIFT_9PER
;
394 if (!(pdata
->control_flags
& MAX8973_CONTROL_PULL_DOWN_ENABLE
))
395 control2
|= MAX8973_DISCH_ENBABLE
;
397 /* Clock advance trip configuration */
398 switch (pdata
->control_flags
& MAX8973_CONTROL_CLKADV_TRIP_MASK
) {
399 case MAX8973_CONTROL_CLKADV_TRIP_DISABLED
:
400 control2
|= MAX8973_CKKADV_TRIP_DISABLE
;
403 case MAX8973_CONTROL_CLKADV_TRIP_75mV_PER_US
:
404 control2
|= MAX8973_CKKADV_TRIP_75mV_PER_US
;
407 case MAX8973_CONTROL_CLKADV_TRIP_150mV_PER_US
:
408 control2
|= MAX8973_CKKADV_TRIP_150mV_PER_US
;
411 case MAX8973_CONTROL_CLKADV_TRIP_75mV_PER_US_HIST_DIS
:
412 control2
|= MAX8973_CKKADV_TRIP_75mV_PER_US_HIST_DIS
;
416 /* Configure inductor value */
417 switch (pdata
->control_flags
& MAX8973_CONTROL_INDUCTOR_VALUE_MASK
) {
418 case MAX8973_CONTROL_INDUCTOR_VALUE_NOMINAL
:
419 control2
|= MAX8973_INDUCTOR_NOMINAL
;
422 case MAX8973_CONTROL_INDUCTOR_VALUE_MINUS_30_PER
:
423 control2
|= MAX8973_INDUCTOR_MIN_30_PER
;
426 case MAX8973_CONTROL_INDUCTOR_VALUE_PLUS_30_PER
:
427 control2
|= MAX8973_INDUCTOR_PLUS_30_PER
;
430 case MAX8973_CONTROL_INDUCTOR_VALUE_PLUS_60_PER
:
431 control2
|= MAX8973_INDUCTOR_PLUS_60_PER
;
435 ret
= regmap_write(max
->regmap
, MAX8973_CONTROL1
, control1
);
437 dev_err(max
->dev
, "register %d write failed, err = %d",
438 MAX8973_CONTROL1
, ret
);
442 ret
= regmap_write(max
->regmap
, MAX8973_CONTROL2
, control2
);
444 dev_err(max
->dev
, "register %d write failed, err = %d",
445 MAX8973_CONTROL2
, ret
);
449 /* If external control is enabled then disable EN bit */
450 if (max
->enable_external_control
&& (max
->id
== MAX8973
)) {
451 ret
= regmap_update_bits(max
->regmap
, MAX8973_VOUT
,
452 MAX8973_VOUT_ENABLE
, 0);
454 dev_err(max
->dev
, "register %d update failed, err = %d",
460 static const struct regmap_config max8973_regmap_config
= {
463 .max_register
= MAX8973_CHIPID2
,
464 .cache_type
= REGCACHE_RBTREE
,
467 static struct max8973_regulator_platform_data
*max8973_parse_dt(
470 struct max8973_regulator_platform_data
*pdata
;
471 struct device_node
*np
= dev
->of_node
;
475 bool etr_sensitivity_high
;
477 pdata
= devm_kzalloc(dev
, sizeof(*pdata
), GFP_KERNEL
);
481 pdata
->enable_ext_control
= of_property_read_bool(np
,
482 "maxim,externally-enable");
483 pdata
->enable_gpio
= of_get_named_gpio(np
, "maxim,enable-gpio", 0);
484 pdata
->dvs_gpio
= of_get_named_gpio(np
, "maxim,dvs-gpio", 0);
486 ret
= of_property_read_u32(np
, "maxim,dvs-default-state", &pval
);
488 pdata
->dvs_def_state
= pval
;
490 if (of_property_read_bool(np
, "maxim,enable-remote-sense"))
491 pdata
->control_flags
|= MAX8973_CONTROL_REMOTE_SENSE_ENABLE
;
493 if (of_property_read_bool(np
, "maxim,enable-falling-slew-rate"))
494 pdata
->control_flags
|=
495 MAX8973_CONTROL_FALLING_SLEW_RATE_ENABLE
;
497 if (of_property_read_bool(np
, "maxim,enable-active-discharge"))
498 pdata
->control_flags
|=
499 MAX8973_CONTROL_OUTPUT_ACTIVE_DISCH_ENABLE
;
501 if (of_property_read_bool(np
, "maxim,enable-frequency-shift"))
502 pdata
->control_flags
|= MAX8973_CONTROL_FREQ_SHIFT_9PER_ENABLE
;
504 if (of_property_read_bool(np
, "maxim,enable-bias-control"))
505 pdata
->control_flags
|= MAX8973_CONTROL_BIAS_ENABLE
;
507 etr_enable
= of_property_read_bool(np
, "maxim,enable-etr");
508 etr_sensitivity_high
= of_property_read_bool(np
,
509 "maxim,enable-high-etr-sensitivity");
510 if (etr_sensitivity_high
)
514 if (etr_sensitivity_high
)
515 pdata
->control_flags
|=
516 MAX8973_CONTROL_CLKADV_TRIP_75mV_PER_US
;
518 pdata
->control_flags
|=
519 MAX8973_CONTROL_CLKADV_TRIP_150mV_PER_US
;
521 pdata
->control_flags
|= MAX8973_CONTROL_CLKADV_TRIP_DISABLED
;
527 static const struct of_device_id of_max8973_match_tbl
[] = {
528 { .compatible
= "maxim,max8973", .data
= (void *)MAX8973
, },
529 { .compatible
= "maxim,max77621", .data
= (void *)MAX77621
, },
532 MODULE_DEVICE_TABLE(of
, of_max8973_match_tbl
);
534 static int max8973_probe(struct i2c_client
*client
,
535 const struct i2c_device_id
*id
)
537 struct max8973_regulator_platform_data
*pdata
;
538 struct regulator_init_data
*ridata
;
539 struct regulator_config config
= { };
540 struct regulator_dev
*rdev
;
541 struct max8973_chip
*max
;
542 bool pdata_from_dt
= false;
543 unsigned int chip_id
;
546 pdata
= dev_get_platdata(&client
->dev
);
548 if (!pdata
&& client
->dev
.of_node
) {
549 pdata
= max8973_parse_dt(&client
->dev
);
550 pdata_from_dt
= true;
554 dev_err(&client
->dev
, "No Platform data");
558 if ((pdata
->dvs_gpio
== -EPROBE_DEFER
) ||
559 (pdata
->enable_gpio
== -EPROBE_DEFER
))
560 return -EPROBE_DEFER
;
562 max
= devm_kzalloc(&client
->dev
, sizeof(*max
), GFP_KERNEL
);
566 max
->regmap
= devm_regmap_init_i2c(client
, &max8973_regmap_config
);
567 if (IS_ERR(max
->regmap
)) {
568 ret
= PTR_ERR(max
->regmap
);
569 dev_err(&client
->dev
, "regmap init failed, err %d\n", ret
);
573 if (client
->dev
.of_node
) {
574 const struct of_device_id
*match
;
576 match
= of_match_device(of_match_ptr(of_max8973_match_tbl
),
580 max
->id
= (u32
)((uintptr_t)match
->data
);
582 max
->id
= id
->driver_data
;
585 ret
= regmap_read(max
->regmap
, MAX8973_CHIPID1
, &chip_id
);
587 dev_err(&client
->dev
, "register CHIPID1 read failed, %d", ret
);
591 dev_info(&client
->dev
, "CHIP-ID OTP: 0x%02x ID_M: 0x%02x\n",
592 (chip_id
>> 4) & 0xF, (chip_id
>> 1) & 0x7);
594 i2c_set_clientdata(client
, max
);
595 max
->ops
= max8973_dcdc_ops
;
596 max
->dev
= &client
->dev
;
597 max
->desc
.name
= id
->name
;
599 max
->desc
.ops
= &max
->ops
;
600 max
->desc
.type
= REGULATOR_VOLTAGE
;
601 max
->desc
.owner
= THIS_MODULE
;
602 max
->desc
.min_uV
= MAX8973_MIN_VOLATGE
;
603 max
->desc
.uV_step
= MAX8973_VOLATGE_STEP
;
604 max
->desc
.n_voltages
= MAX8973_BUCK_N_VOLTAGE
;
606 max
->dvs_gpio
= (pdata
->dvs_gpio
) ? pdata
->dvs_gpio
: -EINVAL
;
607 max
->enable_gpio
= (pdata
->enable_gpio
) ? pdata
->enable_gpio
: -EINVAL
;
608 max
->enable_external_control
= pdata
->enable_ext_control
;
609 max
->curr_gpio_val
= pdata
->dvs_def_state
;
610 max
->curr_vout_reg
= MAX8973_VOUT
+ pdata
->dvs_def_state
;
612 if (gpio_is_valid(max
->enable_gpio
))
613 max
->enable_external_control
= true;
615 max
->lru_index
[0] = max
->curr_vout_reg
;
617 if (gpio_is_valid(max
->dvs_gpio
)) {
621 gpio_flags
= (pdata
->dvs_def_state
) ?
622 GPIOF_OUT_INIT_HIGH
: GPIOF_OUT_INIT_LOW
;
623 ret
= devm_gpio_request_one(&client
->dev
, max
->dvs_gpio
,
624 gpio_flags
, "max8973-dvs");
626 dev_err(&client
->dev
,
627 "gpio_request for gpio %d failed, err = %d\n",
633 * Initialize the lru index with vout_reg id
634 * The index 0 will be most recently used and
635 * set with the max->curr_vout_reg */
636 for (i
= 0; i
< MAX8973_MAX_VOUT_REG
; ++i
)
637 max
->lru_index
[i
] = i
;
638 max
->lru_index
[0] = max
->curr_vout_reg
;
639 max
->lru_index
[max
->curr_vout_reg
] = 0;
642 * If there is no DVS GPIO, the VOUT register
645 max
->ops
.set_voltage_sel
= regulator_set_voltage_sel_regmap
;
646 max
->ops
.get_voltage_sel
= regulator_get_voltage_sel_regmap
;
647 max
->desc
.vsel_reg
= max
->curr_vout_reg
;
648 max
->desc
.vsel_mask
= MAX8973_VOUT_MASK
;
652 pdata
->reg_init_data
= of_get_regulator_init_data(&client
->dev
,
653 client
->dev
.of_node
, &max
->desc
);
655 ridata
= pdata
->reg_init_data
;
658 if (!pdata
->enable_ext_control
) {
659 max
->desc
.enable_reg
= MAX8973_VOUT
;
660 max
->desc
.enable_mask
= MAX8973_VOUT_ENABLE
;
661 max
->ops
.enable
= regulator_enable_regmap
;
662 max
->ops
.disable
= regulator_disable_regmap
;
663 max
->ops
.is_enabled
= regulator_is_enabled_regmap
;
667 if (gpio_is_valid(max
->enable_gpio
)) {
668 config
.ena_gpio_flags
= GPIOF_OUT_INIT_LOW
;
669 if (ridata
&& (ridata
->constraints
.always_on
||
670 ridata
->constraints
.boot_on
))
671 config
.ena_gpio_flags
= GPIOF_OUT_INIT_HIGH
;
672 config
.ena_gpio
= max
->enable_gpio
;
677 if (gpio_is_valid(max
->enable_gpio
)) {
678 ret
= devm_gpio_request_one(&client
->dev
,
679 max
->enable_gpio
, GPIOF_OUT_INIT_HIGH
,
682 dev_err(&client
->dev
,
683 "gpio_request for gpio %d failed: %d\n",
684 max
->enable_gpio
, ret
);
689 max
->desc
.enable_reg
= MAX8973_VOUT
;
690 max
->desc
.enable_mask
= MAX8973_VOUT_ENABLE
;
691 max
->ops
.enable
= regulator_enable_regmap
;
692 max
->ops
.disable
= regulator_disable_regmap
;
693 max
->ops
.is_enabled
= regulator_is_enabled_regmap
;
694 max
->ops
.set_current_limit
= max8973_set_current_limit
;
695 max
->ops
.get_current_limit
= max8973_get_current_limit
;
701 ret
= max8973_init_dcdc(max
, pdata
);
703 dev_err(max
->dev
, "Max8973 Init failed, err = %d\n", ret
);
707 config
.dev
= &client
->dev
;
708 config
.init_data
= pdata
->reg_init_data
;
709 config
.driver_data
= max
;
710 config
.of_node
= client
->dev
.of_node
;
711 config
.regmap
= max
->regmap
;
713 /* Register the regulators */
714 rdev
= devm_regulator_register(&client
->dev
, &max
->desc
, &config
);
717 dev_err(max
->dev
, "regulator register failed, err %d\n", ret
);
724 static const struct i2c_device_id max8973_id
[] = {
725 {.name
= "max8973", .driver_data
= MAX8973
},
726 {.name
= "max77621", .driver_data
= MAX77621
},
729 MODULE_DEVICE_TABLE(i2c
, max8973_id
);
731 static struct i2c_driver max8973_i2c_driver
= {
734 .of_match_table
= of_max8973_match_tbl
,
736 .probe
= max8973_probe
,
737 .id_table
= max8973_id
,
740 static int __init
max8973_init(void)
742 return i2c_add_driver(&max8973_i2c_driver
);
744 subsys_initcall(max8973_init
);
746 static void __exit
max8973_cleanup(void)
748 i2c_del_driver(&max8973_i2c_driver
);
750 module_exit(max8973_cleanup
);
752 MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
753 MODULE_DESCRIPTION("MAX8973 voltage regulator driver");
754 MODULE_LICENSE("GPL v2");