Skip to content
Permalink
Browse files
regulator: IRQ based event/error notification helpers
Provide helper function for IC's implementing regulator notifications
when an IRQ fires. The helper also works for IRQs which can not be acked.
Helper can be set to disable the IRQ at handler and then re-enabling it
on delayed work later. The helper also adds regulator_get_error_flags()
errors in cache for the duration of IRQ disabling.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
  • Loading branch information
M-Vaittinen authored and intel-lab-lkp committed Feb 11, 2021
1 parent 7b7ccc4 commit 1844ad67f3ebe118184da7e83b30df9f4eb0caf0
Show file tree
Hide file tree
Showing 4 changed files with 547 additions and 4 deletions.
@@ -4,7 +4,7 @@
#


obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o devres.o
obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o devres.o irq_helpers.o
obj-$(CONFIG_OF) += of_regulator.o
obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
@@ -4388,20 +4388,37 @@ unsigned int regulator_get_mode(struct regulator *regulator)
}
EXPORT_SYMBOL_GPL(regulator_get_mode);

static int rdev_get_cached_err_flags(struct regulator_dev *rdev)
{
int ret = 0;

if (rdev->use_cached_err) {
spin_lock(&rdev->err_lock);
ret = rdev->cached_err;
spin_unlock(&rdev->err_lock);
}
return ret;
}

static int _regulator_get_error_flags(struct regulator_dev *rdev,
unsigned int *flags)
{
int ret;
int ret, tmpret;

regulator_lock(rdev);

ret = rdev_get_cached_err_flags(rdev);

/* sanity check */
if (!rdev->desc->ops->get_error_flags) {
if (rdev->desc->ops->get_error_flags) {
tmpret = rdev->desc->ops->get_error_flags(rdev, flags);
if (tmpret > 0)
ret |= tmpret;
} else if (!rdev->use_cached_err) {
ret = -EINVAL;
goto out;
}

ret = rdev->desc->ops->get_error_flags(rdev, flags);
out:
regulator_unlock(rdev);
return ret;
@@ -5236,6 +5253,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
goto rinse;
}
device_initialize(&rdev->dev);
spin_lock_init(&rdev->err_lock);

/*
* Duplicate the config so the driver could override it after

0 comments on commit 1844ad6

Please sign in to comment.