On Sun, Jan 5, 2020 at 6:24 PM Chen-Yu Tsai <[email protected]> wrote:
>
> On Sun, Jan 5, 2020 at 9:24 AM Samuel Holland <[email protected]> wrote:
> >
> > The AC power supply input can be used as a wakeup source. Hook up the
> > ACIN_PLUGIN IRQ to trigger wakeup based on userspace configuration.
> >
> > To do this, we must remember the list of IRQs for the life of the
> > device. To know how much space to allocate for the flexible array
> > member, we switch from using a NULL sentinel to using an array length.
> >
> > Because we now depend on the specific order of the IRQs (we assume
> > ACIN_PLUGIN is first and always present), failing to acquire an IRQ
> > during probe must be a fatal error.
> >
> > To avoid spuriously waking up the system when the AC power supply is
> > not configured as a wakeup source, we must explicitly disable all non-
> > wake IRQs during system suspend. This is because the SoC's NMI input is
> > shared among all IRQs on the AXP PMIC. Due to the use of regmap-irq, the
> > individual IRQs within the PMIC are nested threaded interrupts, and are
> > therefore not automatically disabled during system suspend.
> >
> > The upshot is that if any other device within the MFD (such as the power
> > key) is an enabled wakeup source, all enabled IRQs within the PMIC will
> > cause wakeup. We still need to call enable_irq_wake() when we *do* want
> > wakeup, in case those other wakeup sources on the PMIC are all disabled.
> >
> > Signed-off-by: Samuel Holland <[email protected]>
> > ---
> >  drivers/power/supply/axp20x_ac_power.c | 91 +++++++++++++++++++++-----
> >  1 file changed, 74 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/power/supply/axp20x_ac_power.c 
> > b/drivers/power/supply/axp20x_ac_power.c
> > index bc2663cd47fa..177b5c1eee8f 100644
> > --- a/drivers/power/supply/axp20x_ac_power.c
> > +++ b/drivers/power/supply/axp20x_ac_power.c

[...]

> > @@ -284,12 +335,14 @@ static int axp20x_ac_power_probe(struct 
> > platform_device *pdev)
> >                 return -EINVAL;
> >         }
> >
> > -       power = devm_kzalloc(&pdev->dev, sizeof(*power), GFP_KERNEL);
> > +       axp_data = of_device_get_match_data(&pdev->dev);
> > +
> > +       power = devm_kzalloc(&pdev->dev,
> > +                            struct_size(power, irqs, 
> > axp_data->num_irq_names),
> > +                            GFP_KERNEL);
> >         if (!power)
> >                 return -ENOMEM;
> >
> > -       axp_data = of_device_get_match_data(&pdev->dev);
> > -
>
> This change doesn't seem related, nor is it needed.

Nevermind, I see it.

> >         if (axp_data->acin_adc) {
> >                 power->acin_v = devm_iio_channel_get(&pdev->dev, "acin_v");
> >                 if (IS_ERR(power->acin_v)) {

Reviewed-by: Chen-Yu Tsai <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/CAGb2v648d2UFo81shetRfHENwW_f1O8stD_a6x6vu43TEpQ%2B2A%40mail.gmail.com.

Reply via email to