Lines Matching +full:- +full:- +full:retry +full:- +full:all +full:- +full:errors

1 // SPDX-License-Identifier: GPL-2.0
6 // Logic has been partially adapted from qcom-labibb driver.
37 spin_lock(&rdev->err_lock); in rdev_flag_err()
38 rdev->cached_err |= err; in rdev_flag_err()
39 spin_unlock(&rdev->err_lock); in rdev_flag_err()
44 spin_lock(&rdev->err_lock); in rdev_clear_err()
45 rdev->cached_err &= ~err; in rdev_clear_err()
46 spin_unlock(&rdev->err_lock); in rdev_clear_err()
60 d = &h->desc; in regulator_notifier_isr_work()
61 rid = &h->rdata; in regulator_notifier_isr_work()
62 num_rdevs = rid->num_states; in regulator_notifier_isr_work()
65 if (d->fatal_cnt && h->retry_cnt > d->fatal_cnt) { in regulator_notifier_isr_work()
66 if (!d->die) in regulator_notifier_isr_work()
67 return hw_protection_shutdown("Regulator HW failure? - no IC recovery", in regulator_notifier_isr_work()
69 ret = d->die(rid); in regulator_notifier_isr_work()
79 * If h->die() was implemented we assume recovery has been in regulator_notifier_isr_work()
81 * just enable IRQ and bail-out. in regulator_notifier_isr_work()
85 if (d->renable) { in regulator_notifier_isr_work()
86 ret = d->renable(rid); in regulator_notifier_isr_work()
90 h->retry_cnt++; in regulator_notifier_isr_work()
91 if (!d->reread_ms) in regulator_notifier_isr_work()
94 tmo = d->reread_ms; in regulator_notifier_isr_work()
107 stat = &rid->states[i]; in regulator_notifier_isr_work()
108 rdev = stat->rdev; in regulator_notifier_isr_work()
109 rdev_clear_err(rdev, (~stat->errors) & in regulator_notifier_isr_work()
110 stat->possible_errs); in regulator_notifier_isr_work()
112 h->retry_cnt++; in regulator_notifier_isr_work()
114 * The IC indicated problem is still ON - no point in in regulator_notifier_isr_work()
115 * re-enabling the IRQ. Retry later. in regulator_notifier_isr_work()
117 tmo = d->irq_off_ms; in regulator_notifier_isr_work()
124 * If problems are gone - good. If not - then the IRQ will fire again in regulator_notifier_isr_work()
126 * flags here and re-enable IRQs. in regulator_notifier_isr_work()
132 stat = &rid->states[i]; in regulator_notifier_isr_work()
133 rdev = stat->rdev; in regulator_notifier_isr_work()
134 rdev_clear_err(rdev, stat->possible_errs); in regulator_notifier_isr_work()
138 * Things have been seemingly successful => zero retry-counter. in regulator_notifier_isr_work()
140 h->retry_cnt = 0; in regulator_notifier_isr_work()
143 enable_irq(h->irq); in regulator_notifier_isr_work()
148 if (!d->high_prio) in regulator_notifier_isr_work()
149 mod_delayed_work(system_wq, &h->isr_work, in regulator_notifier_isr_work()
152 mod_delayed_work(system_highpri_wq, &h->isr_work, in regulator_notifier_isr_work()
165 d = &h->desc; in regulator_notifier_isr()
166 rid = &h->rdata; in regulator_notifier_isr()
167 num_rdevs = rid->num_states; in regulator_notifier_isr()
169 if (d->fatal_cnt) in regulator_notifier_isr()
170 h->retry_cnt++; in regulator_notifier_isr()
179 ret = d->map_event(irq, rid, &rdev_map); in regulator_notifier_isr()
183 * IRQ but just increase fail count and retry when IRQ fires again. in regulator_notifier_isr()
187 * If no die handler is given we will just power-off as a last resort. in regulator_notifier_isr()
189 * We could try disabling all associated rdevs - but we might shoot in regulator_notifier_isr()
191 * if IC has no die-handler populated we just assume the regulator in regulator_notifier_isr()
197 h->retry_cnt = 0; in regulator_notifier_isr()
207 * if all relevant regulators are disabled in regulator_notifier_isr()
209 if (d->skip_off) { in regulator_notifier_isr()
214 rdev = rid->states[i].rdev; in regulator_notifier_isr()
215 ops = rdev->desc->ops; in regulator_notifier_isr()
221 if (ops->is_enabled(rdev)) in regulator_notifier_isr()
229 if (d->irq_off_ms) in regulator_notifier_isr()
240 stat = &rid->states[i]; in regulator_notifier_isr()
241 rdev = stat->rdev; in regulator_notifier_isr()
244 stat->notifs); in regulator_notifier_isr()
246 regulator_notifier_call_chain(rdev, stat->notifs, NULL); in regulator_notifier_isr()
247 rdev_flag_err(rdev, stat->errors); in regulator_notifier_isr()
250 if (d->irq_off_ms) { in regulator_notifier_isr()
251 if (!d->high_prio) in regulator_notifier_isr()
252 schedule_delayed_work(&h->isr_work, in regulator_notifier_isr()
253 msecs_to_jiffies(d->irq_off_ms)); in regulator_notifier_isr()
256 &h->isr_work, in regulator_notifier_isr()
257 msecs_to_jiffies(d->irq_off_ms)); in regulator_notifier_isr()
263 if (d->fatal_cnt && h->retry_cnt > d->fatal_cnt) { in regulator_notifier_isr()
265 if (!d->die) { in regulator_notifier_isr()
266 hw_protection_shutdown("Regulator failure. Retry count exceeded", in regulator_notifier_isr()
269 ret = d->die(rid); in regulator_notifier_isr()
286 h->rdata.states = devm_kzalloc(dev, sizeof(*h->rdata.states) * in init_rdev_state()
288 if (!h->rdata.states) in init_rdev_state()
289 return -ENOMEM; in init_rdev_state()
291 h->rdata.num_states = rdev_amount; in init_rdev_state()
292 h->rdata.data = h->desc.data; in init_rdev_state()
295 h->rdata.states[i].possible_errs = common_err; in init_rdev_state()
297 h->rdata.states[i].possible_errs |= *rdev_err++; in init_rdev_state()
298 h->rdata.states[i].rdev = *rdev++; in init_rdev_state()
308 for (i = 0; i < h->rdata.num_states; i++) in init_rdev_errors()
309 if (h->rdata.states[i].possible_errs) in init_rdev_errors()
310 h->rdata.states[i].rdev->use_cached_err = true; in init_rdev_errors()
314 * regulator_irq_helper - register IRQ based regulator event/error notifier
318 * @irq: IRQ used to inform events/errors to be notified.
321 * @common_errs: Errors which can be flagged by this IRQ for all rdevs.
322 * When IRQ is re-enabled these errors will be cleared
323 * from all associated regulators. Use this instead of the
326 * @per_rdev_errs: Optional error flag array describing errors specific
327 * for only some of the regulators. These errors will be
328 * or'ed with common errors. If this is given the array
346 if (!rdev_amount || !d || !d->map_event || !d->name) in regulator_irq_helper()
347 return ERR_PTR(-EINVAL); in regulator_irq_helper()
351 return ERR_PTR(-ENOMEM); in regulator_irq_helper()
353 h->irq = irq; in regulator_irq_helper()
354 h->desc = *d; in regulator_irq_helper()
363 if (h->desc.irq_off_ms) in regulator_irq_helper()
364 INIT_DELAYED_WORK(&h->isr_work, regulator_notifier_isr_work); in regulator_irq_helper()
366 ret = request_threaded_irq(h->irq, NULL, regulator_notifier_isr, in regulator_irq_helper()
367 IRQF_ONESHOT | irq_flags, h->desc.name, h); in regulator_irq_helper()
379 * regulator_irq_helper_cancel - drop IRQ based regulator event/error notifier
392 free_irq(h->irq, h); in regulator_irq_helper_cancel()
393 if (h->desc.irq_off_ms) in regulator_irq_helper_cancel()
394 cancel_delayed_work_sync(&h->isr_work); in regulator_irq_helper_cancel()
402 * regulator_irq_map_event_simple - regulator IRQ notification for trivial IRQs
412 * "common_errs"-field) can be given at IRQ helper registration for
418 int err = rid->states[0].possible_errs; in regulator_irq_map_event_simple()
427 if (WARN_ON(rid->num_states != 1 || hweight32(err) != 1)) in regulator_irq_map_event_simple()
430 rid->states[0].errors = err; in regulator_irq_map_event_simple()
431 rid->states[0].notifs = regulator_err2notif(err); in regulator_irq_map_event_simple()