Lines Matching +full:output +full:- +full:micro +full:- +full:ohms
1 // SPDX-License-Identifier: GPL-2.0
55 struct regmap *regmap = ddata->regmap; in max5970_read()
67 * ddata->irng holds the voltage corresponding to the maximum value the in max5970_read()
68 * 10-bit ADC can measure. in max5970_read()
69 * To obtain the output, multiply the ADC value by the IRNG range (in in max5970_read()
70 * millivolts) and then divide it by the maximum value of the 10-bit ADC. in max5970_read()
72 *val = (*val * ddata->irng) >> 10; in max5970_read()
74 *val = (*val * 1000) / ddata->shunt_micro_ohms; in max5970_read()
77 return -EOPNOTSUPP; in max5970_read()
88 * ddata->mon_rng holds the voltage corresponding to the maximum value the in max5970_read()
89 * 10-bit ADC can measure. in max5970_read()
90 * To obtain the output, multiply the ADC value by the MON range (in in max5970_read()
91 * microvolts) and then divide it by the maximum value of the 10-bit ADC. in max5970_read()
93 *val = mul_u64_u32_shr(*val, ddata->mon_rng, 10); in max5970_read()
98 return -EOPNOTSUPP; in max5970_read()
101 return -EOPNOTSUPP; in max5970_read()
117 if (channel >= ddata->num_switches) in max5970_is_visible()
133 if (ddata->shunt_micro_ohms) in max5970_is_visible()
167 ret = regmap_read(rdev->regmap, MAX5970_REG_STATUS1, ®); in max597x_uvp_ovp_check_mode()
174 return -EOPNOTSUPP; in max597x_uvp_ovp_check_mode()
179 return -EOPNOTSUPP; in max597x_uvp_ovp_check_mode()
210 /* reg = ADC_MASK * (lim_uV / 1000000) / (data->mon_rng / 1000000) */ in max597x_set_vp()
211 reg = ADC_MASK * lim_uV / data->mon_rng; in max597x_set_vp()
215 ret = regmap_write(rdev->regmap, off_h, MAX5970_VAL2REG_H(reg)); in max597x_set_vp()
219 ret = regmap_write(rdev->regmap, off_l, MAX5970_VAL2REG_L(reg)); in max597x_set_vp()
236 return -EINVAL; in max597x_set_uvp()
255 return -EINVAL; in max597x_set_ovp()
277 if (lim_uA != 0 && lim_uA != data->lim_uA) in max597x_set_ocp()
278 data->lim_uA = lim_uA; in max597x_set_ocp()
281 return -EINVAL; in max597x_set_ocp()
287 div_u64(mul_u32_u32(data->shunt_micro_ohms, data->lim_uA), in max597x_set_ocp()
299 if (vthfst > data->irng) { in max597x_set_ocp()
300 dev_err(&rdev->dev, "Current limit out of range\n"); in max597x_set_ocp()
301 return -EINVAL; in max597x_set_ocp()
304 val = div_u64(mul_u32_u32(0xFF, vthfst), data->irng); in max597x_set_ocp()
314 return regmap_write(rdev->regmap, reg, val); in max597x_set_ocp()
321 ret = regmap_read(rdev->regmap, MAX5970_REG_STATUS3, &val); in max597x_get_status()
352 struct max5970_regulator *data = cfg->driver_data; in max597x_dt_parse()
356 of_property_read_u32(np, "shunt-resistor-micro-ohms", in max597x_dt_parse()
357 &data->shunt_micro_ohms); in max597x_dt_parse()
359 dev_err(cfg->dev, in max597x_dt_parse()
360 "property 'shunt-resistor-micro-ohms' not found, err %d\n", in max597x_dt_parse()
404 struct max5970_regulator *d = (struct max5970_regulator *)rid->data; in max597x_irq_handler()
407 ret = max597x_regmap_read_clear(d->regmap, MAX5970_REG_FAULT0, &val); in max597x_irq_handler()
412 for (i = 0; i < d->num_switches; i++) { in max597x_irq_handler()
413 stat = &rid->states[i]; in max597x_irq_handler()
414 stat->notifs = 0; in max597x_irq_handler()
415 stat->errors = 0; in max597x_irq_handler()
418 for (i = 0; i < d->num_switches; i++) { in max597x_irq_handler()
419 stat = &rid->states[i]; in max597x_irq_handler()
423 stat->notifs |= REGULATOR_EVENT_UNDER_VOLTAGE; in max597x_irq_handler()
424 stat->errors |= REGULATOR_ERROR_UNDER_VOLTAGE; in max597x_irq_handler()
427 stat->notifs |= REGULATOR_EVENT_UNDER_VOLTAGE_WARN; in max597x_irq_handler()
428 stat->errors |= REGULATOR_ERROR_UNDER_VOLTAGE_WARN; in max597x_irq_handler()
432 ret = max597x_regmap_read_clear(d->regmap, MAX5970_REG_FAULT1, &val); in max597x_irq_handler()
436 for (i = 0; i < d->num_switches; i++) { in max597x_irq_handler()
437 stat = &rid->states[i]; in max597x_irq_handler()
441 stat->notifs |= REGULATOR_EVENT_REGULATION_OUT; in max597x_irq_handler()
442 stat->errors |= REGULATOR_ERROR_REGULATION_OUT; in max597x_irq_handler()
445 stat->notifs |= REGULATOR_EVENT_OVER_VOLTAGE_WARN; in max597x_irq_handler()
446 stat->errors |= REGULATOR_ERROR_OVER_VOLTAGE_WARN; in max597x_irq_handler()
450 ret = max597x_regmap_read_clear(d->regmap, MAX5970_REG_FAULT2, &val); in max597x_irq_handler()
454 for (i = 0; i < d->num_switches; i++) { in max597x_irq_handler()
455 stat = &rid->states[i]; in max597x_irq_handler()
459 stat->notifs |= REGULATOR_EVENT_OVER_CURRENT_WARN; in max597x_irq_handler()
460 stat->errors |= REGULATOR_ERROR_OVER_CURRENT_WARN; in max597x_irq_handler()
464 ret = regmap_read(d->regmap, MAX5970_REG_STATUS0, &val); in max597x_irq_handler()
468 for (i = 0; i < d->num_switches; i++) { in max597x_irq_handler()
469 stat = &rid->states[i]; in max597x_irq_handler()
474 stat->notifs |= in max597x_irq_handler()
477 stat->errors |= in max597x_irq_handler()
480 /* Clear the sub-IRQ status */ in max597x_irq_handler()
481 regulator_disable_regmap(stat->rdev); in max597x_irq_handler()
508 return -EINVAL; in max597x_adc_range()
527 .name = "max597x-irq", in max597x_setup_irq()
539 /* Register notifiers - can fail if IRQ is not given */ in max597x_setup_irq()
544 if (PTR_ERR(irq_helper) == -EPROBE_DEFER) in max597x_setup_irq()
545 return -EPROBE_DEFER; in max597x_setup_irq()
555 struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL); in max597x_regulator_probe()
557 struct i2c_client *i2c = to_i2c_client(pdev->dev.parent); in max597x_regulator_probe()
566 return -EPROBE_DEFER; in max597x_regulator_probe()
568 rdevs = devm_kcalloc(&i2c->dev, MAX5970_NUM_SWITCHES, sizeof(struct regulator_dev *), in max597x_regulator_probe()
571 return -ENOMEM; in max597x_regulator_probe()
573 if (of_device_is_compatible(i2c->dev.of_node, "maxim,max5978")) in max597x_regulator_probe()
575 else if (of_device_is_compatible(i2c->dev.of_node, "maxim,max5970")) in max597x_regulator_probe()
578 return -ENODEV; in max597x_regulator_probe()
582 devm_kzalloc(&i2c->dev, sizeof(struct max5970_regulator), in max597x_regulator_probe()
585 return -ENOMEM; in max597x_regulator_probe()
587 data->num_switches = num_switches; in max597x_regulator_probe()
588 data->regmap = regmap; in max597x_regulator_probe()
590 ret = max597x_adc_range(regmap, i, &data->irng, &data->mon_rng); in max597x_regulator_probe()
594 config.dev = &i2c->dev; in max597x_regulator_probe()
596 config.regmap = data->regmap; in max597x_regulator_probe()
597 rdev = devm_regulator_register(&i2c->dev, in max597x_regulator_probe()
600 dev_err(&i2c->dev, "failed to register regulator %s\n", in max597x_regulator_probe()
608 hwmon_dev = devm_hwmon_device_register_with_info(&i2c->dev, "max5970", rdevs, in max597x_regulator_probe()
611 return dev_err_probe(&i2c->dev, PTR_ERR(hwmon_dev), in max597x_regulator_probe()
616 if (i2c->irq) { in max597x_regulator_probe()
618 max597x_setup_irq(&i2c->dev, i2c->irq, rdevs, num_switches, in max597x_regulator_probe()
621 dev_err(&i2c->dev, "IRQ setup failed"); in max597x_regulator_probe()
631 .name = "max5970-regulator",
641 MODULE_DESCRIPTION("MAX5970_hot-swap controller driver");