Lines Matching +full:sub +full:- +full:sampled

1 // SPDX-License-Identifier: GPL-2.0
39 /* Status1 register contains the soft strap values sampled at POR */ in max597x_uvp_ovp_check_mode()
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 max5970_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 max5970_regulator *d = (struct max5970_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()
381 return -EINVAL; in max597x_adc_range()
400 .name = "max597x-irq", in max597x_setup_irq()
412 /* Register notifiers - can fail if IRQ is not given */ in max597x_setup_irq()
417 if (PTR_ERR(irq_helper) == -EPROBE_DEFER) in max597x_setup_irq()
418 return -EPROBE_DEFER; in max597x_setup_irq()
429 struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL); in max597x_regulator_probe()
431 struct i2c_client *i2c = to_i2c_client(pdev->dev.parent); in max597x_regulator_probe()
439 return -EPROBE_DEFER; in max597x_regulator_probe()
441 max597x = devm_kzalloc(&i2c->dev, sizeof(struct max5970_data), GFP_KERNEL); in max597x_regulator_probe()
443 return -ENOMEM; in max597x_regulator_probe()
447 if (of_device_is_compatible(i2c->dev.of_node, "maxim,max5978")) in max597x_regulator_probe()
448 max597x->num_switches = MAX5978_NUM_SWITCHES; in max597x_regulator_probe()
449 else if (of_device_is_compatible(i2c->dev.of_node, "maxim,max5970")) in max597x_regulator_probe()
450 max597x->num_switches = MAX5970_NUM_SWITCHES; in max597x_regulator_probe()
452 return -ENODEV; in max597x_regulator_probe()
455 num_switches = max597x->num_switches; in max597x_regulator_probe()
459 devm_kzalloc(&i2c->dev, sizeof(struct max5970_regulator), in max597x_regulator_probe()
462 return -ENOMEM; in max597x_regulator_probe()
464 data->num_switches = num_switches; in max597x_regulator_probe()
465 data->regmap = regmap; in max597x_regulator_probe()
467 ret = max597x_adc_range(regmap, i, &max597x->irng[i], &max597x->mon_rng[i]); in max597x_regulator_probe()
471 data->irng = max597x->irng[i]; in max597x_regulator_probe()
472 data->mon_rng = max597x->mon_rng[i]; in max597x_regulator_probe()
474 config.dev = &i2c->dev; in max597x_regulator_probe()
476 config.regmap = data->regmap; in max597x_regulator_probe()
477 rdev = devm_regulator_register(&i2c->dev, in max597x_regulator_probe()
480 dev_err(&i2c->dev, "failed to register regulator %s\n", in max597x_regulator_probe()
485 max597x->shunt_micro_ohms[i] = data->shunt_micro_ohms; in max597x_regulator_probe()
488 if (i2c->irq) { in max597x_regulator_probe()
490 max597x_setup_irq(&i2c->dev, i2c->irq, rdevs, num_switches, in max597x_regulator_probe()
493 dev_err(&i2c->dev, "IRQ setup failed"); in max597x_regulator_probe()
503 .name = "max5970-regulator",
513 MODULE_DESCRIPTION("MAX5970_hot-swap controller driver");