linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Liam Breck <liam@networkimprov.net>
To: Tony Lindgren <tony@atomide.com>
Cc: Sebastian Reichel <sre@kernel.org>,
	Liam Breck <kernel@networkimprov.net>,
	"Mark A . Greer" <mgreer@animalcreek.com>,
	linux-pm@vger.kernel.org, linux-omap@vger.kernel.org,
	Matt Ranostay <matt@ranostay.consulting>
Subject: Re: [PATCH 1/2] power: bq24190_charger: Check the interrupt status on resume
Date: Sat, 21 Jan 2017 00:08:02 -0800	[thread overview]
Message-ID: <CAKvHMgRipKyVAF6Y6Wr3t=McPouqfC2B9KuAnM+RFUtE-LRtuw@mail.gmail.com> (raw)
In-Reply-To: <20170120220440.1971-2-tony@atomide.com>

On Fri, Jan 20, 2017 at 2:04 PM, Tony Lindgren <tony@atomide.com> wrote:
> Some SoCs like omap3 can configure GPIO irqs to use Linux generic
> dedicated wakeirq support. If the dedicated wakeirq is configured,
> the SoC will use a always-on interrupt controller to produce wake-up
> events.
>
> If bq24190 is configured for dedicated wakeirq, we need to check the
> interrupt status on PM runtime resume. This is because the Linux
> generic wakeirq will call pm_runtime_resume() on the device on a
> wakeirq. And as the bq24190 interrupt is falling edge sensitive
> and only active for 250 us, there will be no device interrupt seen
> by the runtime SoC IRQ controller.
>
> Note that this can cause spurious interrupts on omap3 devices with
> bq24190 connected to gpio banks 2 - 5 as there's a glitch on those
> pins waking from off mode as listed in "Advisory 1.45". Devices
> with this issue should not configure the optional wakeirq interrupt
> in the dts file.
>
> Cc: Matt Ranostay <matt@ranostay.consulting>
> Cc: Liam Breck <kernel@networkimprov.net>
> Acked-by: Mark Greer <mgreer@animalcreek.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/power/supply/bq24190_charger.c | 62 ++++++++++++++++++++++++++++------
>  1 file changed, 52 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
> --- a/drivers/power/supply/bq24190_charger.c
> +++ b/drivers/power/supply/bq24190_charger.c
> @@ -155,6 +155,8 @@ struct bq24190_dev_info {
>         kernel_ulong_t                  model;
>         unsigned int                    gpio_int;
>         unsigned int                    irq;
> +       bool                            initialized;
> +       bool                            irq_event;
>         struct mutex                    f_reg_lock;
>         u8                              f_reg;
>         u8                              ss_reg;
> @@ -1157,9 +1159,8 @@ static const struct power_supply_desc bq24190_battery_desc = {
>         .property_is_writeable  = bq24190_battery_property_is_writeable,
>  };
>
> -static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
> +static void bq24190_check_status(struct bq24190_dev_info *bdi)
>  {
> -       struct bq24190_dev_info *bdi = data;
>         const u8 battery_mask_ss = BQ24190_REG_SS_CHRG_STAT_MASK;
>         const u8 battery_mask_f = BQ24190_REG_F_BAT_FAULT_MASK
>                                 | BQ24190_REG_F_NTC_FAULT_MASK;
> @@ -1167,12 +1168,10 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
>         u8 ss_reg = 0, f_reg = 0;
>         int i, ret;
>
> -       pm_runtime_get_sync(bdi->dev);
> -
>         ret = bq24190_read(bdi, BQ24190_REG_SS, &ss_reg);
>         if (ret < 0) {
>                 dev_err(bdi->dev, "Can't read SS reg: %d\n", ret);
> -               goto out;
> +               return;
>         }
>
>         i = 0;
> @@ -1180,7 +1179,7 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
>                 ret = bq24190_read(bdi, BQ24190_REG_F, &f_reg);
>                 if (ret < 0) {
>                         dev_err(bdi->dev, "Can't read F reg: %d\n", ret);
> -                       goto out;
> +                       return;
>                 }
>         } while (f_reg && ++i < 2);
>
> @@ -1229,10 +1228,18 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
>         if (alert_battery)
>                 power_supply_changed(bdi->battery);
>
> -out:
> -       pm_runtime_put_sync(bdi->dev);
> -
>         dev_dbg(bdi->dev, "ss_reg: 0x%02x, f_reg: 0x%02x\n", ss_reg, f_reg);
> +}
> +
> +static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
> +{
> +       struct bq24190_dev_info *bdi = data;
> +
> +       bdi->irq_event = true;
> +       pm_runtime_get_sync(bdi->dev);

Do we need to call pm_runtime_irq_safe() prior to the above?

> +       bq24190_check_status(bdi);
> +       pm_runtime_put_sync(bdi->dev);
> +       bdi->irq_event = false;
>
>         return IRQ_HANDLED;
>  }
> ...

  reply	other threads:[~2017-01-21  8:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 22:04 [PATCH 0/2] Two bq24190 PM improvments Tony Lindgren
2017-01-20 22:04 ` [PATCH 1/2] power: bq24190_charger: Check the interrupt status on resume Tony Lindgren
2017-01-21  8:08   ` Liam Breck [this message]
2017-01-22  1:51     ` Sebastian Reichel
2017-01-22  1:54   ` Sebastian Reichel
2017-01-24  0:47     ` Tony Lindgren
2017-01-20 22:04 ` [PATCH 2/2] power: bq24190_charger: Use PM runtime autosuspend Tony Lindgren
2017-01-21  0:47   ` Liam Breck
2017-01-24  1:27     ` Tony Lindgren
2017-01-24  3:34       ` Liam Breck
2017-01-24 18:29         ` Tony Lindgren
2017-01-24 23:05           ` Mark Greer
2017-01-26 16:20             ` Tony Lindgren
2017-01-26 23:56           ` Liam Breck
2017-01-30 23:55             ` Tony Lindgren
2017-01-31  0:01               ` Liam Breck
2017-01-31  0:04                 ` Tony Lindgren
  -- strict thread matches above, loose matches on Subject: below --
2017-01-31  0:02 [PATCHv2 0/2] Two bq24190 PM improvments Tony Lindgren
2017-01-31  0:02 ` [PATCH 1/2] power: bq24190_charger: Check the interrupt status on resume Tony Lindgren
2017-02-03  0:32   ` Liam Breck
2017-02-03 23:09 [PATCHv3 0/2] Two bq24190 PM improvments Tony Lindgren
2017-02-03 23:09 ` [PATCH 1/2] power: bq24190_charger: Check the interrupt status on resume Tony Lindgren
2017-02-08 23:12 [PATCHv4 0/2] Two bq24190 PM improvments Tony Lindgren
2017-02-08 23:13 ` [PATCH 1/2] power: bq24190_charger: Check the interrupt status on resume Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKvHMgRipKyVAF6Y6Wr3t=McPouqfC2B9KuAnM+RFUtE-LRtuw@mail.gmail.com' \
    --to=liam@networkimprov.net \
    --cc=kernel@networkimprov.net \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=matt@ranostay.consulting \
    --cc=mgreer@animalcreek.com \
    --cc=sre@kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).