Lines Matching +full:shunt +full:- +full:resistor +full:- +full:micro +full:- +full:ohms

1 // SPDX-License-Identifier: GPL-2.0
40 ret = regmap_read(rdev->regmap, MAX5970_REG_STATUS1, &reg); in max597x_uvp_ovp_check_mode()
47 return -EOPNOTSUPP; in max597x_uvp_ovp_check_mode()
52 return -EOPNOTSUPP; in max597x_uvp_ovp_check_mode()
83 /* reg = ADC_MASK * (lim_uV / 1000000) / (data->mon_rng / 1000000) */ in max597x_set_vp()
84 reg = ADC_MASK * lim_uV / data->mon_rng; in max597x_set_vp()
88 ret = regmap_write(rdev->regmap, off_h, MAX5970_VAL2REG_H(reg)); in max597x_set_vp()
92 ret = regmap_write(rdev->regmap, off_l, MAX5970_VAL2REG_L(reg)); in max597x_set_vp()
109 return -EINVAL; in max597x_set_uvp()
128 return -EINVAL; in max597x_set_ovp()
150 if (lim_uA != 0 && lim_uA != data->lim_uA) in max597x_set_ocp()
151 data->lim_uA = lim_uA; in max597x_set_ocp()
154 return -EINVAL; in max597x_set_ocp()
160 div_u64(mul_u32_u32(data->shunt_micro_ohms, data->lim_uA), in max597x_set_ocp()
172 if (vthfst > data->irng) { in max597x_set_ocp()
173 dev_err(&rdev->dev, "Current limit out of range\n"); in max597x_set_ocp()
174 return -EINVAL; in max597x_set_ocp()
177 val = div_u64(mul_u32_u32(0xFF, vthfst), data->irng); in max597x_set_ocp()
187 return regmap_write(rdev->regmap, reg, val); in max597x_set_ocp()
194 ret = regmap_read(rdev->regmap, MAX5970_REG_STATUS3, &val); in max597x_get_status()
225 struct max597x_regulator *data = cfg->driver_data; in max597x_dt_parse()
229 of_property_read_u32(np, "shunt-resistor-micro-ohms", in max597x_dt_parse()
230 &data->shunt_micro_ohms); in max597x_dt_parse()
232 dev_err(cfg->dev, in max597x_dt_parse()
233 "property 'shunt-resistor-micro-ohms' not found, err %d\n", in max597x_dt_parse()
277 struct max597x_regulator *d = (struct max597x_regulator *)rid->data; in max597x_irq_handler()
280 ret = max597x_regmap_read_clear(d->regmap, MAX5970_REG_FAULT0, &val); in max597x_irq_handler()
285 for (i = 0; i < d->num_switches; i++) { in max597x_irq_handler()
286 stat = &rid->states[i]; in max597x_irq_handler()
287 stat->notifs = 0; in max597x_irq_handler()
288 stat->errors = 0; in max597x_irq_handler()
291 for (i = 0; i < d->num_switches; i++) { in max597x_irq_handler()
292 stat = &rid->states[i]; in max597x_irq_handler()
296 stat->notifs |= REGULATOR_EVENT_UNDER_VOLTAGE; in max597x_irq_handler()
297 stat->errors |= REGULATOR_ERROR_UNDER_VOLTAGE; in max597x_irq_handler()
300 stat->notifs |= REGULATOR_EVENT_UNDER_VOLTAGE_WARN; in max597x_irq_handler()
301 stat->errors |= REGULATOR_ERROR_UNDER_VOLTAGE_WARN; in max597x_irq_handler()
305 ret = max597x_regmap_read_clear(d->regmap, MAX5970_REG_FAULT1, &val); in max597x_irq_handler()
309 for (i = 0; i < d->num_switches; i++) { in max597x_irq_handler()
310 stat = &rid->states[i]; in max597x_irq_handler()
314 stat->notifs |= REGULATOR_EVENT_REGULATION_OUT; in max597x_irq_handler()
315 stat->errors |= REGULATOR_ERROR_REGULATION_OUT; in max597x_irq_handler()
318 stat->notifs |= REGULATOR_EVENT_OVER_VOLTAGE_WARN; in max597x_irq_handler()
319 stat->errors |= REGULATOR_ERROR_OVER_VOLTAGE_WARN; in max597x_irq_handler()
323 ret = max597x_regmap_read_clear(d->regmap, MAX5970_REG_FAULT2, &val); in max597x_irq_handler()
327 for (i = 0; i < d->num_switches; i++) { in max597x_irq_handler()
328 stat = &rid->states[i]; in max597x_irq_handler()
332 stat->notifs |= REGULATOR_EVENT_OVER_CURRENT_WARN; in max597x_irq_handler()
333 stat->errors |= REGULATOR_ERROR_OVER_CURRENT_WARN; in max597x_irq_handler()
337 ret = regmap_read(d->regmap, MAX5970_REG_STATUS0, &val); in max597x_irq_handler()
341 for (i = 0; i < d->num_switches; i++) { in max597x_irq_handler()
342 stat = &rid->states[i]; in max597x_irq_handler()
347 stat->notifs |= in max597x_irq_handler()
350 stat->errors |= in max597x_irq_handler()
353 /* Clear the sub-IRQ status */ in max597x_irq_handler()
354 regulator_disable_regmap(stat->rdev); in max597x_irq_handler()
387 return -EINVAL; in max597x_adc_range()
406 .name = "max597x-irq", in max597x_setup_irq()
418 /* Register notifiers - can fail if IRQ is not given */ in max597x_setup_irq()
423 if (PTR_ERR(irq_helper) == -EPROBE_DEFER) in max597x_setup_irq()
424 return -EPROBE_DEFER; in max597x_setup_irq()
436 struct max597x_data *max597x = dev_get_drvdata(pdev->dev.parent); in max597x_regulator_probe()
442 int num_switches = max597x->num_switches; in max597x_regulator_probe()
447 devm_kzalloc(max597x->dev, sizeof(struct max597x_regulator), in max597x_regulator_probe()
450 return -ENOMEM; in max597x_regulator_probe()
452 data->num_switches = num_switches; in max597x_regulator_probe()
453 data->regmap = max597x->regmap; in max597x_regulator_probe()
455 ret = max597x_adc_range(data->regmap, i, &max597x->irng[i], &max597x->mon_rng[i]); in max597x_regulator_probe()
459 data->irng = max597x->irng[i]; in max597x_regulator_probe()
460 data->mon_rng = max597x->mon_rng[i]; in max597x_regulator_probe()
462 config.dev = max597x->dev; in max597x_regulator_probe()
464 config.regmap = data->regmap; in max597x_regulator_probe()
465 rdev = devm_regulator_register(max597x->dev, in max597x_regulator_probe()
468 dev_err(max597x->dev, "failed to register regulator %s\n", in max597x_regulator_probe()
473 max597x->shunt_micro_ohms[i] = data->shunt_micro_ohms; in max597x_regulator_probe()
476 if (max597x->irq) { in max597x_regulator_probe()
478 max597x_setup_irq(max597x->dev, max597x->irq, rdevs, num_switches, in max597x_regulator_probe()
481 dev_err(max597x->dev, "IRQ setup failed"); in max597x_regulator_probe()
491 .name = "max597x-regulator",
500 MODULE_DESCRIPTION("MAX5970_hot-swap controller driver");