Lines Matching +full:dvs +full:- +full:gpio
1 // SPDX-License-Identifier: GPL-2.0-only
3 * TI LP8788 MFD - buck regulator driver
16 #include <linux/gpio.h>
91 void *dvs; member
102 struct lp8788_buck1_dvs *dvs = (struct lp8788_buck1_dvs *)buck->dvs; in lp8788_buck1_set_dvs() local
105 if (!dvs) in lp8788_buck1_set_dvs()
108 pinstate = dvs->vsel == DVS_SEL_V0 ? DVS_LOW : DVS_HIGH; in lp8788_buck1_set_dvs()
109 if (gpio_is_valid(dvs->gpio)) in lp8788_buck1_set_dvs()
110 gpio_set_value(dvs->gpio, pinstate); in lp8788_buck1_set_dvs()
115 struct lp8788_buck2_dvs *dvs = (struct lp8788_buck2_dvs *)buck->dvs; in lp8788_buck2_set_dvs() local
118 if (!dvs) in lp8788_buck2_set_dvs()
121 switch (dvs->vsel) { in lp8788_buck2_set_dvs()
142 if (gpio_is_valid(dvs->gpio[0])) in lp8788_buck2_set_dvs()
143 gpio_set_value(dvs->gpio[0], pin1); in lp8788_buck2_set_dvs()
145 if (gpio_is_valid(dvs->gpio[1])) in lp8788_buck2_set_dvs()
146 gpio_set_value(dvs->gpio[1], pin2); in lp8788_buck2_set_dvs()
179 lp8788_read_byte(buck->lp, LP8788_BUCK_DVS_SEL, &val); in lp8788_get_buck_dvs_ctrl_mode()
213 b1_dvs = (struct lp8788_buck1_dvs *)buck->dvs; in lp8788_select_buck_vout_addr()
217 idx = gpio_get_value(b1_dvs->gpio) ? 1 : 0; in lp8788_select_buck_vout_addr()
219 lp8788_read_byte(buck->lp, LP8788_BUCK_DVS_SEL, &val); in lp8788_select_buck_vout_addr()
226 b2_dvs = (struct lp8788_buck2_dvs *)buck->dvs; in lp8788_select_buck_vout_addr()
230 pin1 = gpio_get_value(b2_dvs->gpio[0]); in lp8788_select_buck_vout_addr()
231 pin2 = gpio_get_value(b2_dvs->gpio[1]); in lp8788_select_buck_vout_addr()
242 lp8788_read_byte(buck->lp, LP8788_BUCK_DVS_SEL, &val); in lp8788_select_buck_vout_addr()
263 if (buck->dvs) in lp8788_buck12_set_voltage_sel()
268 return -EINVAL; in lp8788_buck12_set_voltage_sel()
270 return lp8788_update_bits(buck->lp, addr, LP8788_VOUT_M, selector); in lp8788_buck12_set_voltage_sel()
282 return -EINVAL; in lp8788_buck12_get_voltage_sel()
284 ret = lp8788_read_byte(buck->lp, addr, &val); in lp8788_buck12_get_voltage_sel()
297 if (lp8788_read_byte(buck->lp, addr, &val)) in lp8788_buck_enable_time()
298 return -EINVAL; in lp8788_buck_enable_time()
320 return -EINVAL; in lp8788_buck_set_mode()
323 return lp8788_update_bits(buck->lp, LP8788_BUCK_PWM, mask, val); in lp8788_buck_set_mode()
333 ret = lp8788_read_byte(buck->lp, LP8788_BUCK_PWM, &val); in lp8788_buck_get_mode()
426 struct lp8788_platform_data *pdata = buck->lp->pdata; in lp8788_dvs_gpio_request()
429 int i, gpio, ret; in lp8788_dvs_gpio_request() local
433 gpio = pdata->buck1_dvs->gpio; in lp8788_dvs_gpio_request()
434 ret = devm_gpio_request_one(&pdev->dev, gpio, DVS_LOW, in lp8788_dvs_gpio_request()
439 buck->dvs = pdata->buck1_dvs; in lp8788_dvs_gpio_request()
443 gpio = pdata->buck2_dvs->gpio[i]; in lp8788_dvs_gpio_request()
444 ret = devm_gpio_request_one(&pdev->dev, gpio, in lp8788_dvs_gpio_request()
449 buck->dvs = pdata->buck2_dvs; in lp8788_dvs_gpio_request()
461 struct lp8788_platform_data *pdata = buck->lp->pdata; in lp8788_init_dvs()
466 /* no dvs for buck3, 4 */ in lp8788_init_dvs()
470 /* no dvs platform data, then dvs will be selected by I2C registers */ in lp8788_init_dvs()
474 if ((id == BUCK1 && !pdata->buck1_dvs) || in lp8788_init_dvs()
475 (id == BUCK2 && !pdata->buck2_dvs)) in lp8788_init_dvs()
481 return lp8788_update_bits(buck->lp, LP8788_BUCK_DVS_SEL, mask[id], in lp8788_init_dvs()
485 return lp8788_update_bits(buck->lp, LP8788_BUCK_DVS_SEL, mask[id], in lp8788_init_dvs()
491 struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent); in lp8788_buck_probe()
492 int id = pdev->id; in lp8788_buck_probe()
499 return -EINVAL; in lp8788_buck_probe()
501 buck = devm_kzalloc(&pdev->dev, sizeof(struct lp8788_buck), GFP_KERNEL); in lp8788_buck_probe()
503 return -ENOMEM; in lp8788_buck_probe()
505 buck->lp = lp; in lp8788_buck_probe()
511 cfg.dev = pdev->dev.parent; in lp8788_buck_probe()
512 cfg.init_data = lp->pdata ? lp->pdata->buck_data[id] : NULL; in lp8788_buck_probe()
514 cfg.regmap = lp->regmap; in lp8788_buck_probe()
516 rdev = devm_regulator_register(&pdev->dev, &lp8788_buck_desc[id], &cfg); in lp8788_buck_probe()
519 dev_err(&pdev->dev, "BUCK%d regulator register err = %d\n", in lp8788_buck_probe()
524 buck->regulator = rdev; in lp8788_buck_probe()
552 MODULE_ALIAS("platform:lp8788-buck");