Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752959AbbFYK6f (ORCPT ); Thu, 25 Jun 2015 06:58:35 -0400 Received: from mail1.bemta5.messagelabs.com ([195.245.231.140]:21385 "EHLO mail1.bemta5.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752063AbbFYK61 convert rfc822-to-8bit (ORCPT ); Thu, 25 Jun 2015 06:58:27 -0400 X-Env-Sender: stwiss.opensource@diasemi.com X-Msg-Ref: server-10.tower-178.messagelabs.com!1435229902!38750026!1 X-Originating-IP: [94.185.165.51] X-StarScan-Received: X-StarScan-Version: 6.13.16; banners=-,-,- X-VirusChecked: Checked From: "Opensource [Steve Twiss]" To: Geert Uytterhoeven , Support Opensource , Liam Girdwood , "Mark Brown" , "Opensource [Steve Twiss]" CC: "linux-sh@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" Subject: RE: [PATCH] regulator: da9210: Add optional interrupt support Thread-Topic: [PATCH] regulator: da9210: Add optional interrupt support Thread-Index: AQHQrndP1SlnhE3JukuIjzwuUTviwZ29DApg Date: Thu, 25 Jun 2015 10:58:21 +0000 Message-ID: <6ED8E3B22081A4459DAC7699F3695FB7014B2323E5@SW-EX-MBX02.diasemi.com> References: <1435148061-11844-1-git-send-email-geert+renesas@glider.be> In-Reply-To: <1435148061-11844-1-git-send-email-geert+renesas@glider.be> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.20.26.77] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5093 Lines: 177 On 24 June 2015 13:14, Geert Uytterhoeven wrote: > To: Support Opensource; Liam Girdwood; Mark Brown; Opensource [Steve Twiss] > Subject: [PATCH] regulator: da9210: Add optional interrupt support > > Add optional interrupt support to the da9210 regulator driver, to handle > over-current, under- and over-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 > Cc: devicetree@vger.kernel.org > --- > I do not have access to the da9210 datasheet, but looked at the da9211 driver. > > v2: > - Only acknowledge unmasked sources, > - Handle DA9210_E_VMAX using REGULATOR_EVENT_REGULATION_OUT. > --- Hi Geert, https://lkml.org/lkml/2015/2/17/358 I got side-tracked with other things and this one got forgotten ... I'll take another look at this. A cursory glance from me -- it seems fair and consistent with the DA9210 data sheet. I'll check with the engineers here. Regards, Steve > .../devicetree/bindings/regulator/da9210.txt | 4 ++ > drivers/regulator/da9210-regulator.c | 75 > ++++++++++++++++++++++ > 2 files changed, 79 insertions(+) > > 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..8e39f7457bc36a07 100644 > --- a/drivers/regulator/da9210-regulator.c > +++ b/drivers/regulator/da9210-regulator.c > @@ -22,6 +22,8 @@ > #include > #include > #include > +#include > +#include > #include > #include > #include > @@ -120,6 +122,55 @@ 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, handled = 0; > + 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); > + handled |= DA9210_E_OVCURR; > + } > + if (val & DA9210_E_NPWRGOOD) { > + regulator_notifier_call_chain(chip->rdev, > + > REGULATOR_EVENT_UNDER_VOLTAGE, > + NULL); > + handled |= DA9210_E_NPWRGOOD; > + } > + if (val & (DA9210_E_TEMP_WARN | DA9210_E_TEMP_CRIT)) { > + regulator_notifier_call_chain(chip->rdev, > + REGULATOR_EVENT_OVER_TEMP, > NULL); > + handled |= val & (DA9210_E_TEMP_WARN | > DA9210_E_TEMP_CRIT); > + } > + if (val & DA9210_E_VMAX) { > + regulator_notifier_call_chain(chip->rdev, > + > REGULATOR_EVENT_REGULATION_OUT, > + NULL); > + handled |= DA9210_E_VMAX; > + } > + if (handled) { > + /* Clear handled events */ > + error = regmap_write(chip->regmap, > DA9210_REG_EVENT_B, handled); > + 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 +219,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 | > DA9210_M_VMAX, 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); > > -- > 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/