Message ID | 1424175072-14643-2-git-send-email-geert+renesas@glider.be (mailing list archive) |
---|---|
State | RFC |
Delegated to: | Geert Uytterhoeven |
Headers | show |
On Tue, Feb 17, 2015 at 01:11:12PM +0100, Geert Uytterhoeven wrote: > - Does there exist any regulator notifier event that corresponds to > DA9210_E_VMAX? What does that mean, I might be able to tell you? I guess it might be an over voltage event... > + error = regmap_read(chip->regmap, DA9210_REG_EVENT_B, &val); > + if (error < 0) > + goto error_i2c; ... > + if (val) { > + /* Clear all events */ > + error = regmap_write(chip->regmap, DA9210_REG_EVENT_B, val); > + if (error < 0) > + goto error_i2c; > + > + ret = IRQ_HANDLED; > + } It's generally better to only acknowledge unmasked sources for defensiveness and improved diagnostics. Not super critical though.
Hi Mark, On Tue, Feb 17, 2015 at 3:01 PM, Mark Brown <broonie@kernel.org> wrote: > On Tue, Feb 17, 2015 at 01:11:12PM +0100, Geert Uytterhoeven wrote: > >> - Does there exist any regulator notifier event that corresponds to >> DA9210_E_VMAX? > > What does that mean, I might be able to tell you? I guess it might be > an over voltage event... Possibly. There's no regulator notifier event for that yet, though. Shall I add one? Anyway, let's wait for confirmation from Dialog... Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Feb 17, 2015 at 03:18:40PM +0100, Geert Uytterhoeven wrote: > Hi Mark, > > On Tue, Feb 17, 2015 at 3:01 PM, Mark Brown <broonie@kernel.org> wrote: > > On Tue, Feb 17, 2015 at 01:11:12PM +0100, Geert Uytterhoeven wrote: > >> - Does there exist any regulator notifier event that corresponds to > >> DA9210_E_VMAX? > > What does that mean, I might be able to tell you? I guess it might be > > an over voltage event... > Possibly. There's no regulator notifier event for that yet, though. > Shall I add one? I'm wondering if it may be better to change the first notification to just a general "out of regulation" one, though the consequences of over voltage are usually different to under voltage if that is what's going on here. > Anyway, let's wait for confirmation from Dialog... I guess - is there really no indication in the datasheet?
Hi Mark, On Thu, Feb 19, 2015 at 11:33 AM, Mark Brown <broonie@kernel.org> wrote: > On Tue, Feb 17, 2015 at 03:18:40PM +0100, Geert Uytterhoeven wrote: >> On Tue, Feb 17, 2015 at 3:01 PM, Mark Brown <broonie@kernel.org> wrote: >> > On Tue, Feb 17, 2015 at 01:11:12PM +0100, Geert Uytterhoeven wrote: > >> >> - Does there exist any regulator notifier event that corresponds to >> >> DA9210_E_VMAX? > >> > What does that mean, I might be able to tell you? I guess it might be >> > an over voltage event... > >> Possibly. There's no regulator notifier event for that yet, though. >> Shall I add one? > > I'm wondering if it may be better to change the first notification to > just a general "out of regulation" one, though the consequences of over > voltage are usually different to under voltage if that is what's going > on here. > >> Anyway, let's wait for confirmation from Dialog... > > I guess - is there really no indication in the datasheet? -ENOENT (I hope that's actually -EPROBE_DEFER, as I applied for datasheet access last week ;-) Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/Documentation/devicetree/bindings/regulator/da9210.txt b/Documentation/devicetree/bindings/regulator/da9210.txt index 3297c53cb9152395..7aa9b1fa6b21ca18 100644 --- a/Documentation/devicetree/bindings/regulator/da9210.txt +++ b/Documentation/devicetree/bindings/regulator/da9210.txt @@ -5,6 +5,10 @@ Required properties: - compatible: must be "dlg,da9210" - reg: the i2c slave address of the regulator. It should be 0x68. +Optional properties: + +- interrupts: a reference to the DA9210 interrupt, if available. + Any standard regulator properties can be used to configure the single da9210 DCDC. diff --git a/drivers/regulator/da9210-regulator.c b/drivers/regulator/da9210-regulator.c index f0489cb9018b4e78..2c60a2d6f3a7a080 100644 --- a/drivers/regulator/da9210-regulator.c +++ b/drivers/regulator/da9210-regulator.c @@ -22,6 +22,8 @@ #include <linux/i2c.h> #include <linux/module.h> #include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/irq.h> #include <linux/slab.h> #include <linux/regulator/driver.h> #include <linux/regulator/machine.h> @@ -120,6 +122,43 @@ static int da9210_get_current_limit(struct regulator_dev *rdev) return da9210_buck_limits[sel]; } +static irqreturn_t da9210_irq_handler(int irq, void *data) +{ + struct da9210 *chip = data; + unsigned int val; + int error, ret = IRQ_NONE; + + error = regmap_read(chip->regmap, DA9210_REG_EVENT_B, &val); + if (error < 0) + goto error_i2c; + + if (val & DA9210_E_OVCURR) + regulator_notifier_call_chain(chip->rdev, + REGULATOR_EVENT_OVER_CURRENT, + NULL); + if (val & DA9210_E_NPWRGOOD) + regulator_notifier_call_chain(chip->rdev, + REGULATOR_EVENT_UNDER_VOLTAGE, + NULL); + if (val & (DA9210_E_TEMP_WARN | DA9210_E_TEMP_CRIT)) + regulator_notifier_call_chain(chip->rdev, + REGULATOR_EVENT_OVER_TEMP, NULL); + if (val) { + /* Clear all events */ + error = regmap_write(chip->regmap, DA9210_REG_EVENT_B, val); + if (error < 0) + goto error_i2c; + + ret = IRQ_HANDLED; + } + + return ret; + +error_i2c: + dev_err(regmap_get_device(chip->regmap), "I2C error : %d\n", error); + return ret; +} + /* * I2C driver interface functions */ @@ -168,6 +207,30 @@ static int da9210_i2c_probe(struct i2c_client *i2c, } chip->rdev = rdev; + if (i2c->irq) { + error = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, + da9210_irq_handler, + IRQF_TRIGGER_LOW | + IRQF_ONESHOT | IRQF_SHARED, + "da9210", chip); + if (error) { + dev_err(&i2c->dev, "Failed to request IRQ%u: %d\n", + i2c->irq, error); + return error; + } + + error = regmap_update_bits(chip->regmap, DA9210_REG_MASK_B, + DA9210_M_OVCURR | DA9210_M_NPWRGOOD | + DA9210_M_TEMP_WARN | + DA9210_M_TEMP_CRIT, 0); + if (error < 0) { + dev_err(&i2c->dev, "Failed to update mask reg: %d\n", + error); + return error; + } + } else { + dev_warn(&i2c->dev, "No IRQ configured\n"); + } i2c_set_clientdata(i2c, chip);
Add optional interrupt support to the da9210 regulator driver, to handle over-current, under-voltage, and over-temperature events. Only the interrupt sources for which we handle events are unmasked, to avoid interrupts we cannot handle. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Cc: devicetree@vger.kernel.org --- - I do not have access to the da9210 datasheet, but looked at the da9211 driver, hence the RFC status, - Does there exist any regulator notifier event that corresponds to DA9210_E_VMAX? --- .../devicetree/bindings/regulator/da9210.txt | 4 ++ drivers/regulator/da9210-regulator.c | 63 ++++++++++++++++++++++ 2 files changed, 67 insertions(+)