Lines Matching full:max

159 	struct max8973_chip *max = rdev_get_drvdata(rdev);  in max8973_dcdc_get_voltage_sel()  local
163 ret = regmap_read(max->regmap, max->curr_vout_reg, &data); in max8973_dcdc_get_voltage_sel()
165 dev_err(max->dev, "register %d read failed, err = %d\n", in max8973_dcdc_get_voltage_sel()
166 max->curr_vout_reg, ret); in max8973_dcdc_get_voltage_sel()
175 struct max8973_chip *max = rdev_get_drvdata(rdev); in max8973_dcdc_set_voltage_sel() local
178 int vout_reg = max->curr_vout_reg; in max8973_dcdc_set_voltage_sel()
179 int gpio_val = max->curr_gpio_val; in max8973_dcdc_set_voltage_sel()
185 if (max->dvs_gpiod) in max8973_dcdc_set_voltage_sel()
186 found = find_voltage_set_register(max, vsel, in max8973_dcdc_set_voltage_sel()
190 ret = regmap_update_bits(max->regmap, vout_reg, in max8973_dcdc_set_voltage_sel()
193 dev_err(max->dev, "register %d update failed, err %d\n", in max8973_dcdc_set_voltage_sel()
197 max->curr_vout_reg = vout_reg; in max8973_dcdc_set_voltage_sel()
198 max->curr_vout_val[gpio_val] = vsel; in max8973_dcdc_set_voltage_sel()
202 if (max->dvs_gpiod) { in max8973_dcdc_set_voltage_sel()
203 gpiod_set_value_cansleep(max->dvs_gpiod, gpio_val & 0x1); in max8973_dcdc_set_voltage_sel()
204 max->curr_gpio_val = gpio_val; in max8973_dcdc_set_voltage_sel()
211 struct max8973_chip *max = rdev_get_drvdata(rdev); in max8973_dcdc_set_mode() local
229 ret = regmap_update_bits(max->regmap, MAX8973_CONTROL1, in max8973_dcdc_set_mode()
232 dev_err(max->dev, "register %d update failed, err %d\n", in max8973_dcdc_set_mode()
239 struct max8973_chip *max = rdev_get_drvdata(rdev); in max8973_dcdc_get_mode() local
243 ret = regmap_read(max->regmap, MAX8973_CONTROL1, &data); in max8973_dcdc_get_mode()
245 dev_err(max->dev, "register %d read failed, err %d\n", in max8973_dcdc_get_mode()
256 struct max8973_chip *max = rdev_get_drvdata(rdev); in max8973_set_current_limit() local
267 ret = regmap_update_bits(max->regmap, MAX8973_CONTROL2, in max8973_set_current_limit()
270 dev_err(max->dev, "register %d update failed: %d\n", in max8973_set_current_limit()
279 struct max8973_chip *max = rdev_get_drvdata(rdev); in max8973_get_current_limit() local
283 ret = regmap_read(max->regmap, MAX8973_CONTROL2, &control2); in max8973_get_current_limit()
285 dev_err(max->dev, "register %d read failed: %d\n", in max8973_get_current_limit()
316 static int max8973_init_dcdc(struct max8973_chip *max, in max8973_init_dcdc() argument
324 ret = regmap_read(max->regmap, MAX8973_CONTROL1, &data); in max8973_init_dcdc()
326 dev_err(max->dev, "register %d read failed, err = %d", in max8973_init_dcdc()
333 max->desc.ramp_delay = 12000; in max8973_init_dcdc()
336 max->desc.ramp_delay = 25000; in max8973_init_dcdc()
339 max->desc.ramp_delay = 50000; in max8973_init_dcdc()
342 max->desc.ramp_delay = 200000; in max8973_init_dcdc()
357 max->desc.enable_time = 20; in max8973_init_dcdc()
359 max->desc.enable_time = 240; in max8973_init_dcdc()
366 (max->id == MAX77621)) in max8973_init_dcdc()
410 ret = regmap_write(max->regmap, MAX8973_CONTROL1, control1); in max8973_init_dcdc()
412 dev_err(max->dev, "register %d write failed, err = %d", in max8973_init_dcdc()
417 ret = regmap_write(max->regmap, MAX8973_CONTROL2, control2); in max8973_init_dcdc()
419 dev_err(max->dev, "register %d write failed, err = %d", in max8973_init_dcdc()
425 if (max->enable_external_control && (max->id == MAX8973)) { in max8973_init_dcdc()
426 ret = regmap_update_bits(max->regmap, MAX8973_VOUT, in max8973_init_dcdc()
429 dev_err(max->dev, "register %d update failed, err = %d", in max8973_init_dcdc()
590 struct max8973_chip *max; in max8973_probe() local
609 max = devm_kzalloc(&client->dev, sizeof(*max), GFP_KERNEL); in max8973_probe()
610 if (!max) in max8973_probe()
613 max->dvs_gpiod = devm_gpiod_get_optional(&client->dev, "maxim,dvs", in max8973_probe()
615 if (IS_ERR(max->dvs_gpiod)) in max8973_probe()
616 return dev_err_probe(&client->dev, PTR_ERR(max->dvs_gpiod), in max8973_probe()
618 gpiod_set_consumer_name(max->dvs_gpiod, "max8973-dvs"); in max8973_probe()
620 max->regmap = devm_regmap_init_i2c(client, &max8973_regmap_config); in max8973_probe()
621 if (IS_ERR(max->regmap)) { in max8973_probe()
622 ret = PTR_ERR(max->regmap); in max8973_probe()
634 max->id = (u32)((uintptr_t)match->data); in max8973_probe()
636 max->id = id->driver_data; in max8973_probe()
639 ret = regmap_read(max->regmap, MAX8973_CHIPID1, &chip_id); in max8973_probe()
648 i2c_set_clientdata(client, max); in max8973_probe()
649 max->ops = max8973_dcdc_ops; in max8973_probe()
650 max->dev = &client->dev; in max8973_probe()
651 max->desc.name = id->name; in max8973_probe()
652 max->desc.id = 0; in max8973_probe()
653 max->desc.ops = &max->ops; in max8973_probe()
654 max->desc.type = REGULATOR_VOLTAGE; in max8973_probe()
655 max->desc.owner = THIS_MODULE; in max8973_probe()
656 max->desc.min_uV = MAX8973_MIN_VOLATGE; in max8973_probe()
657 max->desc.uV_step = MAX8973_VOLATGE_STEP; in max8973_probe()
658 max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; in max8973_probe()
659 max->desc.ramp_reg = MAX8973_CONTROL1; in max8973_probe()
660 max->desc.ramp_mask = MAX8973_RAMP_MASK; in max8973_probe()
661 max->desc.ramp_delay_table = max8973_buck_ramp_table; in max8973_probe()
662 max->desc.n_ramp_values = ARRAY_SIZE(max8973_buck_ramp_table); in max8973_probe()
664 max->enable_external_control = pdata->enable_ext_control; in max8973_probe()
665 max->curr_gpio_val = pdata->dvs_def_state; in max8973_probe()
666 max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; in max8973_probe()
667 max->junction_temp_warning = pdata->junction_temp_warning; in max8973_probe()
669 max->lru_index[0] = max->curr_vout_reg; in max8973_probe()
671 if (max->dvs_gpiod) { in max8973_probe()
677 * set with the max->curr_vout_reg */ in max8973_probe()
679 max->lru_index[i] = i; in max8973_probe()
680 max->lru_index[0] = max->curr_vout_reg; in max8973_probe()
681 max->lru_index[max->curr_vout_reg] = 0; in max8973_probe()
687 max->ops.set_voltage_sel = regulator_set_voltage_sel_regmap; in max8973_probe()
688 max->ops.get_voltage_sel = regulator_get_voltage_sel_regmap; in max8973_probe()
689 max->desc.vsel_reg = max->curr_vout_reg; in max8973_probe()
690 max->desc.vsel_mask = MAX8973_VOUT_MASK; in max8973_probe()
695 client->dev.of_node, &max->desc); in max8973_probe()
698 switch (max->id) { in max8973_probe()
701 max->desc.enable_reg = MAX8973_VOUT; in max8973_probe()
702 max->desc.enable_mask = MAX8973_VOUT_ENABLE; in max8973_probe()
703 max->ops.enable = regulator_enable_regmap; in max8973_probe()
704 max->ops.disable = regulator_disable_regmap; in max8973_probe()
705 max->ops.is_enabled = regulator_is_enabled_regmap; in max8973_probe()
722 max->enable_external_control = true; in max8973_probe()
738 max->enable_external_control = true; in max8973_probe()
740 max->desc.enable_reg = MAX8973_VOUT; in max8973_probe()
741 max->desc.enable_mask = MAX8973_VOUT_ENABLE; in max8973_probe()
742 max->ops.enable = regulator_enable_regmap; in max8973_probe()
743 max->ops.disable = regulator_disable_regmap; in max8973_probe()
744 max->ops.is_enabled = regulator_is_enabled_regmap; in max8973_probe()
745 max->ops.set_current_limit = max8973_set_current_limit; in max8973_probe()
746 max->ops.get_current_limit = max8973_get_current_limit; in max8973_probe()
752 ret = max8973_init_dcdc(max, pdata); in max8973_probe()
754 dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret); in max8973_probe()
760 config.driver_data = max; in max8973_probe()
762 config.regmap = max->regmap; in max8973_probe()
771 rdev = devm_regulator_register(&client->dev, &max->desc, &config); in max8973_probe()
774 dev_err(max->dev, "regulator register failed, err %d\n", ret); in max8973_probe()
778 max8973_thermal_init(max); in max8973_probe()