Lines Matching refs:max
174 struct max8973_chip *max = rdev_get_drvdata(rdev); in max8973_dcdc_get_voltage_sel() local
178 ret = regmap_read(max->regmap, max->curr_vout_reg, &data); in max8973_dcdc_get_voltage_sel()
180 dev_err(max->dev, "register %d read failed, err = %d\n", in max8973_dcdc_get_voltage_sel()
181 max->curr_vout_reg, ret); in max8973_dcdc_get_voltage_sel()
190 struct max8973_chip *max = rdev_get_drvdata(rdev); in max8973_dcdc_set_voltage_sel() local
193 int vout_reg = max->curr_vout_reg; in max8973_dcdc_set_voltage_sel()
194 int gpio_val = max->curr_gpio_val; in max8973_dcdc_set_voltage_sel()
200 if (gpio_is_valid(max->dvs_gpio)) in max8973_dcdc_set_voltage_sel()
201 found = find_voltage_set_register(max, vsel, in max8973_dcdc_set_voltage_sel()
205 ret = regmap_update_bits(max->regmap, vout_reg, in max8973_dcdc_set_voltage_sel()
208 dev_err(max->dev, "register %d update failed, err %d\n", in max8973_dcdc_set_voltage_sel()
212 max->curr_vout_reg = vout_reg; in max8973_dcdc_set_voltage_sel()
213 max->curr_vout_val[gpio_val] = vsel; in max8973_dcdc_set_voltage_sel()
217 if (gpio_is_valid(max->dvs_gpio)) { in max8973_dcdc_set_voltage_sel()
218 gpio_set_value_cansleep(max->dvs_gpio, gpio_val & 0x1); in max8973_dcdc_set_voltage_sel()
219 max->curr_gpio_val = gpio_val; in max8973_dcdc_set_voltage_sel()
226 struct max8973_chip *max = rdev_get_drvdata(rdev); in max8973_dcdc_set_mode() local
244 ret = regmap_update_bits(max->regmap, MAX8973_CONTROL1, in max8973_dcdc_set_mode()
247 dev_err(max->dev, "register %d update failed, err %d\n", in max8973_dcdc_set_mode()
254 struct max8973_chip *max = rdev_get_drvdata(rdev); in max8973_dcdc_get_mode() local
258 ret = regmap_read(max->regmap, MAX8973_CONTROL1, &data); in max8973_dcdc_get_mode()
260 dev_err(max->dev, "register %d read failed, err %d\n", in max8973_dcdc_get_mode()
271 struct max8973_chip *max = rdev_get_drvdata(rdev); in max8973_set_current_limit() local
282 ret = regmap_update_bits(max->regmap, MAX8973_CONTROL2, in max8973_set_current_limit()
285 dev_err(max->dev, "register %d update failed: %d\n", in max8973_set_current_limit()
294 struct max8973_chip *max = rdev_get_drvdata(rdev); in max8973_get_current_limit() local
298 ret = regmap_read(max->regmap, MAX8973_CONTROL2, &control2); in max8973_get_current_limit()
300 dev_err(max->dev, "register %d read failed: %d\n", in max8973_get_current_limit()
331 static int max8973_init_dcdc(struct max8973_chip *max, in max8973_init_dcdc() argument
339 ret = regmap_read(max->regmap, MAX8973_CONTROL1, &data); in max8973_init_dcdc()
341 dev_err(max->dev, "register %d read failed, err = %d", in max8973_init_dcdc()
348 max->desc.ramp_delay = 12000; in max8973_init_dcdc()
351 max->desc.ramp_delay = 25000; in max8973_init_dcdc()
354 max->desc.ramp_delay = 50000; in max8973_init_dcdc()
357 max->desc.ramp_delay = 200000; in max8973_init_dcdc()
372 max->desc.enable_time = 20; in max8973_init_dcdc()
374 max->desc.enable_time = 240; in max8973_init_dcdc()
381 (max->id == MAX77621)) in max8973_init_dcdc()
425 ret = regmap_write(max->regmap, MAX8973_CONTROL1, control1); in max8973_init_dcdc()
427 dev_err(max->dev, "register %d write failed, err = %d", in max8973_init_dcdc()
432 ret = regmap_write(max->regmap, MAX8973_CONTROL2, control2); in max8973_init_dcdc()
434 dev_err(max->dev, "register %d write failed, err = %d", in max8973_init_dcdc()
440 if (max->enable_external_control && (max->id == MAX8973)) { in max8973_init_dcdc()
441 ret = regmap_update_bits(max->regmap, MAX8973_VOUT, in max8973_init_dcdc()
444 dev_err(max->dev, "register %d update failed, err = %d", in max8973_init_dcdc()
609 struct max8973_chip *max; in max8973_probe() local
631 max = devm_kzalloc(&client->dev, sizeof(*max), GFP_KERNEL); in max8973_probe()
632 if (!max) in max8973_probe()
635 max->regmap = devm_regmap_init_i2c(client, &max8973_regmap_config); in max8973_probe()
636 if (IS_ERR(max->regmap)) { in max8973_probe()
637 ret = PTR_ERR(max->regmap); in max8973_probe()
649 max->id = (u32)((uintptr_t)match->data); in max8973_probe()
651 max->id = id->driver_data; in max8973_probe()
654 ret = regmap_read(max->regmap, MAX8973_CHIPID1, &chip_id); in max8973_probe()
663 i2c_set_clientdata(client, max); in max8973_probe()
664 max->ops = max8973_dcdc_ops; in max8973_probe()
665 max->dev = &client->dev; in max8973_probe()
666 max->desc.name = id->name; in max8973_probe()
667 max->desc.id = 0; in max8973_probe()
668 max->desc.ops = &max->ops; in max8973_probe()
669 max->desc.type = REGULATOR_VOLTAGE; in max8973_probe()
670 max->desc.owner = THIS_MODULE; in max8973_probe()
671 max->desc.min_uV = MAX8973_MIN_VOLATGE; in max8973_probe()
672 max->desc.uV_step = MAX8973_VOLATGE_STEP; in max8973_probe()
673 max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; in max8973_probe()
674 max->desc.ramp_reg = MAX8973_CONTROL1; in max8973_probe()
675 max->desc.ramp_mask = MAX8973_RAMP_MASK; in max8973_probe()
676 max->desc.ramp_delay_table = max8973_buck_ramp_table; in max8973_probe()
677 max->desc.n_ramp_values = ARRAY_SIZE(max8973_buck_ramp_table); in max8973_probe()
679 max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL; in max8973_probe()
680 max->enable_external_control = pdata->enable_ext_control; in max8973_probe()
681 max->curr_gpio_val = pdata->dvs_def_state; in max8973_probe()
682 max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; in max8973_probe()
683 max->junction_temp_warning = pdata->junction_temp_warning; in max8973_probe()
685 max->lru_index[0] = max->curr_vout_reg; in max8973_probe()
687 if (gpio_is_valid(max->dvs_gpio)) { in max8973_probe()
693 ret = devm_gpio_request_one(&client->dev, max->dvs_gpio, in max8973_probe()
698 max->dvs_gpio, ret); in max8973_probe()
707 max->lru_index[i] = i; in max8973_probe()
708 max->lru_index[0] = max->curr_vout_reg; in max8973_probe()
709 max->lru_index[max->curr_vout_reg] = 0; in max8973_probe()
715 max->ops.set_voltage_sel = regulator_set_voltage_sel_regmap; in max8973_probe()
716 max->ops.get_voltage_sel = regulator_get_voltage_sel_regmap; in max8973_probe()
717 max->desc.vsel_reg = max->curr_vout_reg; in max8973_probe()
718 max->desc.vsel_mask = MAX8973_VOUT_MASK; in max8973_probe()
723 client->dev.of_node, &max->desc); in max8973_probe()
726 switch (max->id) { in max8973_probe()
729 max->desc.enable_reg = MAX8973_VOUT; in max8973_probe()
730 max->desc.enable_mask = MAX8973_VOUT_ENABLE; in max8973_probe()
731 max->ops.enable = regulator_enable_regmap; in max8973_probe()
732 max->ops.disable = regulator_disable_regmap; in max8973_probe()
733 max->ops.is_enabled = regulator_is_enabled_regmap; in max8973_probe()
750 max->enable_external_control = true; in max8973_probe()
766 max->enable_external_control = true; in max8973_probe()
768 max->desc.enable_reg = MAX8973_VOUT; in max8973_probe()
769 max->desc.enable_mask = MAX8973_VOUT_ENABLE; in max8973_probe()
770 max->ops.enable = regulator_enable_regmap; in max8973_probe()
771 max->ops.disable = regulator_disable_regmap; in max8973_probe()
772 max->ops.is_enabled = regulator_is_enabled_regmap; in max8973_probe()
773 max->ops.set_current_limit = max8973_set_current_limit; in max8973_probe()
774 max->ops.get_current_limit = max8973_get_current_limit; in max8973_probe()
780 ret = max8973_init_dcdc(max, pdata); in max8973_probe()
782 dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret); in max8973_probe()
788 config.driver_data = max; in max8973_probe()
790 config.regmap = max->regmap; in max8973_probe()
799 rdev = devm_regulator_register(&client->dev, &max->desc, &config); in max8973_probe()
802 dev_err(max->dev, "regulator register failed, err %d\n", ret); in max8973_probe()
806 max8973_thermal_init(max); in max8973_probe()