Lines Matching +full:buck +full:-

1 // SPDX-License-Identifier: GPL-2.0-only
3 * TI LP8788 MFD - buck regulator driver
94 /* BUCK 1 ~ 4 voltage ranges */
100 static void lp8788_buck1_set_dvs(struct lp8788_buck *buck) in lp8788_buck1_set_dvs() argument
102 struct lp8788_buck1_dvs *dvs = (struct lp8788_buck1_dvs *)buck->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()
113 static void lp8788_buck2_set_dvs(struct lp8788_buck *buck) in lp8788_buck2_set_dvs() argument
115 struct lp8788_buck2_dvs *dvs = (struct lp8788_buck2_dvs *)buck->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()
149 static void lp8788_set_dvs(struct lp8788_buck *buck, enum lp8788_buck_id id) in lp8788_set_dvs() argument
153 lp8788_buck1_set_dvs(buck); in lp8788_set_dvs()
156 lp8788_buck2_set_dvs(buck); in lp8788_set_dvs()
164 lp8788_get_buck_dvs_ctrl_mode(struct lp8788_buck *buck, enum lp8788_buck_id id) in lp8788_get_buck_dvs_ctrl_mode() argument
179 lp8788_read_byte(buck->lp, LP8788_BUCK_DVS_SEL, &val); in lp8788_get_buck_dvs_ctrl_mode()
201 static u8 lp8788_select_buck_vout_addr(struct lp8788_buck *buck, in lp8788_select_buck_vout_addr() argument
204 enum lp8788_dvs_mode mode = lp8788_get_buck_dvs_ctrl_mode(buck, id); in lp8788_select_buck_vout_addr()
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()
259 struct lp8788_buck *buck = rdev_get_drvdata(rdev); in lp8788_buck12_set_voltage_sel() local
263 if (buck->dvs) in lp8788_buck12_set_voltage_sel()
264 lp8788_set_dvs(buck, id); in lp8788_buck12_set_voltage_sel()
266 addr = lp8788_select_buck_vout_addr(buck, id); 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()
275 struct lp8788_buck *buck = rdev_get_drvdata(rdev); in lp8788_buck12_get_voltage_sel() local
280 addr = lp8788_select_buck_vout_addr(buck, id); in lp8788_buck12_get_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()
293 struct lp8788_buck *buck = rdev_get_drvdata(rdev); in lp8788_buck_enable_time() local
297 if (lp8788_read_byte(buck->lp, addr, &val)) in lp8788_buck_enable_time()
298 return -EINVAL; in lp8788_buck_enable_time()
307 struct lp8788_buck *buck = rdev_get_drvdata(rdev); in lp8788_buck_set_mode() local
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()
328 struct lp8788_buck *buck = rdev_get_drvdata(rdev); in lp8788_buck_get_mode() local
333 ret = lp8788_read_byte(buck->lp, LP8788_BUCK_PWM, &val); in lp8788_buck_get_mode()
423 struct lp8788_buck *buck, in lp8788_dvs_gpio_request() argument
426 struct lp8788_platform_data *pdata = buck->lp->pdata; in lp8788_dvs_gpio_request()
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()
459 struct lp8788_buck *buck, enum lp8788_buck_id id) in lp8788_init_dvs() argument
461 struct lp8788_platform_data *pdata = buck->lp->pdata; 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()
478 if (lp8788_dvs_gpio_request(pdev, buck, id)) 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()
493 struct lp8788_buck *buck; in lp8788_buck_probe() local
499 return -EINVAL; in lp8788_buck_probe()
501 buck = devm_kzalloc(&pdev->dev, sizeof(struct lp8788_buck), GFP_KERNEL); in lp8788_buck_probe()
502 if (!buck) in lp8788_buck_probe()
503 return -ENOMEM; in lp8788_buck_probe()
505 buck->lp = lp; in lp8788_buck_probe()
507 ret = lp8788_init_dvs(pdev, buck, id); 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()
513 cfg.driver_data = buck; 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()
525 platform_set_drvdata(pdev, buck); in lp8788_buck_probe()
549 MODULE_DESCRIPTION("TI LP8788 BUCK Driver");
552 MODULE_ALIAS("platform:lp8788-buck");