Lines Matching full:max8998
3 // max8998.c - Voltage regulator driver for the Maxim 8998
22 #include <linux/mfd/max8998.h>
23 #include <linux/mfd/max8998-private.h>
86 struct max8998_data *max8998 = rdev_get_drvdata(rdev); in max8998_ldo_is_enabled() local
87 struct i2c_client *i2c = max8998->iodev->i2c; in max8998_ldo_is_enabled()
109 struct max8998_data *max8998 = rdev_get_drvdata(rdev); in max8998_ldo_enable() local
110 struct i2c_client *i2c = max8998->iodev->i2c; in max8998_ldo_enable()
122 struct max8998_data *max8998 = rdev_get_drvdata(rdev); in max8998_ldo_disable() local
123 struct i2c_client *i2c = max8998->iodev->i2c; in max8998_ldo_disable()
137 struct max8998_data *max8998 = rdev_get_drvdata(rdev); in max8998_get_voltage_register() local
174 reg = MAX8998_REG_BUCK1_VOLTAGE1 + max8998->buck1_idx; in max8998_get_voltage_register()
177 reg = MAX8998_REG_BUCK2_VOLTAGE1 + max8998->buck2_idx; in max8998_get_voltage_register()
198 struct max8998_data *max8998 = rdev_get_drvdata(rdev); in max8998_get_voltage_sel() local
199 struct i2c_client *i2c = max8998->iodev->i2c; in max8998_get_voltage_sel()
220 struct max8998_data *max8998 = rdev_get_drvdata(rdev); in max8998_set_voltage_ldo_sel() local
221 struct i2c_client *i2c = max8998->iodev->i2c; in max8998_set_voltage_ldo_sel()
247 struct max8998_data *max8998 = rdev_get_drvdata(rdev); in max8998_set_voltage_buck_sel() local
248 struct max8998_platform_data *pdata = max8998->iodev->pdata; in max8998_set_voltage_buck_sel()
249 struct i2c_client *i2c = max8998->iodev->i2c; in max8998_set_voltage_buck_sel()
260 dev_dbg(max8998->dev, in max8998_set_voltage_buck_sel()
263 selector, max8998->buck1_vol[0], max8998->buck1_vol[1], in max8998_set_voltage_buck_sel()
264 max8998->buck1_vol[2], max8998->buck1_vol[3]); in max8998_set_voltage_buck_sel()
266 if (max8998->buck1_gpio1 && max8998->buck1_gpio2) { in max8998_set_voltage_buck_sel()
270 for (j = 0; j < ARRAY_SIZE(max8998->buck1_vol); j++) { in max8998_set_voltage_buck_sel()
271 if (max8998->buck1_vol[j] == selector) { in max8998_set_voltage_buck_sel()
272 max8998->buck1_idx = j; in max8998_set_voltage_buck_sel()
273 buck1_gpio_set(max8998->buck1_gpio1, in max8998_set_voltage_buck_sel()
274 max8998->buck1_gpio2, j); in max8998_set_voltage_buck_sel()
283 max8998->buck1_idx = (buck1_last_val % 2) + 2; in max8998_set_voltage_buck_sel()
284 dev_dbg(max8998->dev, "max8998->buck1_idx:%d\n", in max8998_set_voltage_buck_sel()
285 max8998->buck1_idx); in max8998_set_voltage_buck_sel()
286 max8998->buck1_vol[max8998->buck1_idx] = selector; in max8998_set_voltage_buck_sel()
291 buck1_gpio_set(max8998->buck1_gpio1, in max8998_set_voltage_buck_sel()
292 max8998->buck1_gpio2, max8998->buck1_idx); in max8998_set_voltage_buck_sel()
295 dev_dbg(max8998->dev, "%s: SET1:%d, SET2:%d\n", in max8998_set_voltage_buck_sel()
296 i2c->name, gpiod_get_value(max8998->buck1_gpio1), in max8998_set_voltage_buck_sel()
297 gpiod_get_value(max8998->buck1_gpio2)); in max8998_set_voltage_buck_sel()
305 dev_dbg(max8998->dev, in max8998_set_voltage_buck_sel()
307 selector, max8998->buck2_vol[0], max8998->buck2_vol[1]); in max8998_set_voltage_buck_sel()
308 if (max8998->buck2_gpio) { in max8998_set_voltage_buck_sel()
311 for (j = 0; j < ARRAY_SIZE(max8998->buck2_vol); j++) { in max8998_set_voltage_buck_sel()
312 if (max8998->buck2_vol[j] == selector) { in max8998_set_voltage_buck_sel()
313 max8998->buck2_idx = j; in max8998_set_voltage_buck_sel()
314 buck2_gpio_set(max8998->buck2_gpio, j); in max8998_set_voltage_buck_sel()
325 max8998->buck2_vol[max8998->buck2_idx] = selector; in max8998_set_voltage_buck_sel()
326 buck2_gpio_set(max8998->buck2_gpio, max8998->buck2_idx); in max8998_set_voltage_buck_sel()
328 dev_dbg(max8998->dev, "%s: SET3:%d\n", i2c->name, in max8998_set_voltage_buck_sel()
329 gpiod_get_value(max8998->buck2_gpio)); in max8998_set_voltage_buck_sel()
349 struct max8998_data *max8998 = rdev_get_drvdata(rdev); in max8998_set_voltage_buck_time_sel() local
350 struct i2c_client *i2c = max8998->iodev->i2c; in max8998_set_voltage_buck_time_sel()
364 /* MAX8998 has ENRAMP bit implemented, so test it*/ in max8998_set_voltage_buck_time_sel()
365 if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP)) in max8998_set_voltage_buck_time_sel()
378 struct max8998_data *max8998 = rdev_get_drvdata(rdev); in max8998_set_current_limit() local
379 struct i2c_client *i2c = max8998->iodev->i2c; in max8998_set_current_limit()
421 struct max8998_data *max8998 = rdev_get_drvdata(rdev); in max8998_get_current_limit() local
422 struct i2c_client *i2c = max8998->iodev->i2c; in max8998_get_current_limit()
588 pdata->buck_voltage_lock = of_property_read_bool(pmic_np, "max8998,pmic-buck-voltage-lock"); in max8998_pmic_dt_parse_pdata()
591 "max8998,pmic-buck1-default-dvs-idx", in max8998_pmic_dt_parse_pdata()
599 "max8998,pmic-buck2-default-dvs-idx", in max8998_pmic_dt_parse_pdata()
607 "max8998,pmic-buck1-dvs-voltage", in max8998_pmic_dt_parse_pdata()
616 "max8998,pmic-buck2-dvs-voltage", in max8998_pmic_dt_parse_pdata()
633 struct max8998_data *max8998; in max8998_pmic_probe() local
650 max8998 = devm_kzalloc(&pdev->dev, sizeof(struct max8998_data), in max8998_pmic_probe()
652 if (!max8998) in max8998_pmic_probe()
655 max8998->dev = &pdev->dev; in max8998_pmic_probe()
656 max8998->iodev = iodev; in max8998_pmic_probe()
657 max8998->num_regulators = pdata->num_regulators; in max8998_pmic_probe()
658 platform_set_drvdata(pdev, max8998); in max8998_pmic_probe()
659 i2c = max8998->iodev->i2c; in max8998_pmic_probe()
661 max8998->buck1_idx = pdata->buck1_default_idx; in max8998_pmic_probe()
662 max8998->buck2_idx = pdata->buck2_default_idx; in max8998_pmic_probe()
664 /* Check if MAX8998 voltage selection GPIOs are defined */ in max8998_pmic_probe()
665 flags = (max8998->buck1_idx & BIT(0)) ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; in max8998_pmic_probe()
666 max8998->buck1_gpio1 = devm_gpiod_get_index_optional(iodev->dev, in max8998_pmic_probe()
667 "max8998,pmic-buck1-dvs", in max8998_pmic_probe()
670 if (IS_ERR(max8998->buck1_gpio1)) in max8998_pmic_probe()
671 return dev_err_probe(&pdev->dev, PTR_ERR(max8998->buck1_gpio1), in max8998_pmic_probe()
673 gpiod_set_consumer_name(max8998->buck1_gpio1, "MAX8998 BUCK1_SET1"); in max8998_pmic_probe()
675 flags = (max8998->buck1_idx & BIT(1)) ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; in max8998_pmic_probe()
676 max8998->buck1_gpio2 = devm_gpiod_get_index_optional(iodev->dev, in max8998_pmic_probe()
677 "max8998,pmic-buck1-dvs", in max8998_pmic_probe()
680 if (IS_ERR(max8998->buck1_gpio2)) in max8998_pmic_probe()
681 return dev_err_probe(&pdev->dev, PTR_ERR(max8998->buck1_gpio2), in max8998_pmic_probe()
683 gpiod_set_consumer_name(max8998->buck1_gpio1, "MAX8998 BUCK1_SET2"); in max8998_pmic_probe()
685 flags = (max8998->buck2_idx & BIT(0)) ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; in max8998_pmic_probe()
686 max8998->buck2_gpio = devm_gpiod_get_index_optional(iodev->dev, in max8998_pmic_probe()
687 "max8998,pmic-buck2-dvs", in max8998_pmic_probe()
690 if (IS_ERR(max8998->buck2_gpio)) in max8998_pmic_probe()
691 return dev_err_probe(&pdev->dev, PTR_ERR(max8998->buck2_gpio), in max8998_pmic_probe()
693 gpiod_set_consumer_name(max8998->buck1_gpio1, "MAX8998 BUCK2_SET3"); in max8998_pmic_probe()
695 if (max8998->buck1_gpio1 && max8998->buck1_gpio2) { in max8998_pmic_probe()
706 max8998->buck1_vol[v] = i; in max8998_pmic_probe()
714 if (max8998->buck2_gpio) { in max8998_pmic_probe()
725 max8998->buck2_vol[v] = i; in max8998_pmic_probe()
736 config.dev = max8998->dev; in max8998_pmic_probe()
739 config.driver_data = max8998; in max8998_pmic_probe()
745 dev_err(max8998->dev, "regulator %s init failed (%d)\n", in max8998_pmic_probe()
755 { "max8998-pmic", TYPE_MAX8998 },
763 .name = "max8998-pmic",