Lines Matching +full:vin2 +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0+
3 #include <dt-bindings/regulator/richtek,rt5190a-regulator.h>
40 #define RT5190A_BUCK23_STEPNUM ((1400000 - 600000) / 10000 + 1)
93 return -EINVAL; in rt5190a_fixed_buck_set_mode()
108 dev_err(&rdev->dev, "Failed to get mode [%d]\n", ret); in rt5190a_fixed_buck_get_mode()
161 ret = regmap_raw_read(priv->regmap, RT5190A_REG_OVINT, &raws, in rt5190a_irq_handler()
164 dev_err(priv->dev, "Failed to read events\n"); in rt5190a_irq_handler()
170 ret = regmap_raw_write(priv->regmap, RT5190A_REG_OVINT, &raws, in rt5190a_irq_handler()
173 dev_err(priv->dev, "Failed to write-clear events\n"); in rt5190a_irq_handler()
178 fields >>= ffs(event_tbl[i].bitmask) - 1; in rt5190a_irq_handler()
184 regulator_notifier_call_chain(priv->rdev[j], in rt5190a_irq_handler()
193 regulator_notifier_call_chain(priv->rdev[j], in rt5190a_irq_handler()
201 dev_warn(priv->dev, "CHIP overheat\n"); in rt5190a_irq_handler()
221 struct regulator_desc *desc = priv->rdesc + rid; in rt5190a_of_parse_cb()
222 struct regulator_init_data *init_data = match->init_data; in rt5190a_of_parse_cb()
223 struct device_node *np = match->of_node; in rt5190a_of_parse_cb()
234 init_data->constraints.apply_uV = 0; in rt5190a_of_parse_cb()
236 if (init_data->constraints.min_uV == in rt5190a_of_parse_cb()
237 init_data->constraints.max_uV) in rt5190a_of_parse_cb()
238 desc->fixed_uV = init_data->constraints.min_uV; in rt5190a_of_parse_cb()
240 dev_err(priv->dev, in rt5190a_of_parse_cb()
242 return -EINVAL; in rt5190a_of_parse_cb()
249 latchup_enable = of_property_read_bool(np, "richtek,latchup-enable"); in rt5190a_of_parse_cb()
254 return regmap_update_bits(priv->regmap, RT5190A_REG_PROTMODE, mask, val); in rt5190a_of_parse_cb()
262 static const char * const supply[] = { NULL, "vin2", "vin3", "vin4", in rt5190a_fillin_regulator_desc() local
265 desc->name = regu_name[rid]; in rt5190a_fillin_regulator_desc()
266 desc->supply_name = supply[rid]; in rt5190a_fillin_regulator_desc()
267 desc->owner = THIS_MODULE; in rt5190a_fillin_regulator_desc()
268 desc->type = REGULATOR_VOLTAGE; in rt5190a_fillin_regulator_desc()
269 desc->id = rid; in rt5190a_fillin_regulator_desc()
270 desc->enable_reg = RT5190A_REG_ENABLE; in rt5190a_fillin_regulator_desc()
271 desc->enable_mask = RT5190A_RID_BITMASK(rid); in rt5190a_fillin_regulator_desc()
272 desc->active_discharge_reg = RT5190A_REG_DISCHARGE; in rt5190a_fillin_regulator_desc()
273 desc->active_discharge_mask = RT5190A_RID_BITMASK(rid); in rt5190a_fillin_regulator_desc()
274 desc->active_discharge_on = RT5190A_RID_BITMASK(rid); in rt5190a_fillin_regulator_desc()
278 desc->active_discharge_mask = RT5190A_BUCK1_DISCHG_MASK; in rt5190a_fillin_regulator_desc()
279 desc->active_discharge_on = RT5190A_BUCK1_DISCHG_ONVAL; in rt5190a_fillin_regulator_desc()
280 desc->n_voltages = 1; in rt5190a_fillin_regulator_desc()
281 desc->ops = &rt5190a_fixed_buck_ops; in rt5190a_fillin_regulator_desc()
282 desc->of_map_mode = rt5190a_of_map_mode; in rt5190a_fillin_regulator_desc()
285 desc->vsel_reg = RT5190A_REG_BUCK2VSEL; in rt5190a_fillin_regulator_desc()
286 desc->vsel_mask = RT5190A_VSEL_MASK; in rt5190a_fillin_regulator_desc()
287 desc->min_uV = RT5190A_BUCK23_MINUV; in rt5190a_fillin_regulator_desc()
288 desc->uV_step = RT5190A_BUCK23_STEPUV; in rt5190a_fillin_regulator_desc()
289 desc->n_voltages = RT5190A_BUCK23_STEPNUM; in rt5190a_fillin_regulator_desc()
290 desc->ops = &rt5190a_ranged_buck_ops; in rt5190a_fillin_regulator_desc()
293 desc->vsel_reg = RT5190A_REG_BUCK3VSEL; in rt5190a_fillin_regulator_desc()
294 desc->vsel_mask = RT5190A_VSEL_MASK; in rt5190a_fillin_regulator_desc()
295 desc->min_uV = RT5190A_BUCK23_MINUV; in rt5190a_fillin_regulator_desc()
296 desc->uV_step = RT5190A_BUCK23_STEPUV; in rt5190a_fillin_regulator_desc()
297 desc->n_voltages = RT5190A_BUCK23_STEPNUM; in rt5190a_fillin_regulator_desc()
298 desc->ops = &rt5190a_ranged_buck_ops; in rt5190a_fillin_regulator_desc()
301 desc->n_voltages = 1; in rt5190a_fillin_regulator_desc()
302 desc->ops = &rt5190a_fixed_buck_ops; in rt5190a_fillin_regulator_desc()
303 desc->of_map_mode = rt5190a_of_map_mode; in rt5190a_fillin_regulator_desc()
306 desc->n_voltages = 1; in rt5190a_fillin_regulator_desc()
307 desc->ops = &rt5190a_fixed_ldo_ops; in rt5190a_fillin_regulator_desc()
328 reg_desc = priv->rdesc + i; in rt5190a_parse_regulator_dt_data()
333 match->desc = reg_desc; in rt5190a_parse_regulator_dt_data()
336 regulator_np = of_get_child_by_name(priv->dev->of_node, "regulators"); in rt5190a_parse_regulator_dt_data()
338 dev_err(priv->dev, "Could not find 'regulators' node\n"); in rt5190a_parse_regulator_dt_data()
339 return -ENODEV; in rt5190a_parse_regulator_dt_data()
342 ret = of_regulator_match(priv->dev, regulator_np, in rt5190a_parse_regulator_dt_data()
349 dev_err(priv->dev, in rt5190a_parse_regulator_dt_data()
359 dev_err(priv->dev, "Failed in [%d] of_parse_cb\n", i); in rt5190a_parse_regulator_dt_data()
386 ret = regmap_register_patch(priv->regmap, rt5190a_init_patch, in rt5190a_device_initialize()
389 dev_err(priv->dev, "Failed to do register patch\n"); in rt5190a_device_initialize()
393 mute_enable = device_property_read_bool(priv->dev, in rt5190a_device_initialize()
394 "richtek,mute-enable"); in rt5190a_device_initialize()
397 ret = regmap_write(priv->regmap, RT5190A_REG_MUTECNTL, 0x00); in rt5190a_device_initialize()
399 dev_err(priv->dev, "Failed to enable mute function\n"); in rt5190a_device_initialize()
412 ret = regmap_raw_read(priv->regmap, RT5190A_REG_MANUFACTURE, &devid, in rt5190a_device_check()
418 dev_err(priv->dev, "Incorrect device id 0x%04x\n", devid); in rt5190a_device_check()
419 return -ENODEV; in rt5190a_device_check()
437 priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL); in rt5190a_probe()
439 return -ENOMEM; in rt5190a_probe()
441 priv->dev = &i2c->dev; in rt5190a_probe()
443 priv->regmap = devm_regmap_init_i2c(i2c, &rt5190a_regmap_config); in rt5190a_probe()
444 if (IS_ERR(priv->regmap)) { in rt5190a_probe()
445 dev_err(&i2c->dev, "Failed to allocate regmap\n"); in rt5190a_probe()
446 return PTR_ERR(priv->regmap); in rt5190a_probe()
451 dev_err(&i2c->dev, "Failed to check device %d\n", ret); in rt5190a_probe()
457 dev_err(&i2c->dev, "Failed to initialize the device\n"); in rt5190a_probe()
463 dev_err(&i2c->dev, "Failed to parse regulator dt\n"); in rt5190a_probe()
467 cfg.dev = &i2c->dev; in rt5190a_probe()
468 cfg.regmap = priv->regmap; in rt5190a_probe()
471 struct regulator_desc *desc = priv->rdesc + i; in rt5190a_probe()
474 cfg.init_data = match->init_data; in rt5190a_probe()
475 cfg.of_node = match->of_node; in rt5190a_probe()
477 priv->rdev[i] = devm_regulator_register(&i2c->dev, desc, &cfg); in rt5190a_probe()
478 if (IS_ERR(priv->rdev[i])) { in rt5190a_probe()
479 dev_err(&i2c->dev, "Failed to register regulator %s\n", in rt5190a_probe()
480 desc->name); in rt5190a_probe()
481 return PTR_ERR(priv->rdev[i]); in rt5190a_probe()
485 if (i2c->irq) { in rt5190a_probe()
486 ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, in rt5190a_probe()
489 dev_name(&i2c->dev), priv); in rt5190a_probe()
491 dev_err(&i2c->dev, "Failed to register interrupt\n"); in rt5190a_probe()