From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lee Jones Subject: Re: [PATCH] mfd: twl4030-power: Fix poweroff with PM configuration enabled Date: Mon, 10 Nov 2014 12:40:19 +0000 Message-ID: <20141110124019.GZ21424@x1> References: <20141102180756.GH31454@atomide.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Received: from mail-ig0-f178.google.com ([209.85.213.178]:47967 "EHLO mail-ig0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752249AbaKJMkZ (ORCPT ); Mon, 10 Nov 2014 07:40:25 -0500 Received: by mail-ig0-f178.google.com with SMTP id a13so8965349igq.17 for ; Mon, 10 Nov 2014 04:40:24 -0800 (PST) Content-Disposition: inline In-Reply-To: <20141102180756.GH31454@atomide.com> Sender: linux-omap-owner@vger.kernel.org List-Id: linux-omap@vger.kernel.org To: Tony Lindgren Cc: Samuel Ortiz , Russell King - ARM Linux , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org On Sun, 02 Nov 2014, Tony Lindgren wrote: > Commit e7cd1d1eb16f ("mfd: twl4030-power: Add generic reset > configuration") enabled configuring the PM features for twl4030. >=20 > This caused poweroff command to fail on devices that have the > BCI charger on twl4030 wired, or have power wired for VBUS. > Instead of powering off, the device reboots. This is because > voltage is detected on charger or VBUS with the default bits > enabled for the power transition registers. >=20 > To fix the issue, let's just clear VBUS and CHG bits as we want > poweroff command to keep the system powered off. >=20 > Fixes: e7cd1d1eb16f ("mfd: twl4030-power: Add generic reset configura= tion") > Cc: stable@vger.kernel.org # v3.16+ > Reported-by: Russell King > Signed-off-by: Tony Lindgren Applied to -fixes. Not sure whether that was an Ack from Russell or not? > --- a/drivers/mfd/twl4030-power.c > +++ b/drivers/mfd/twl4030-power.c > @@ -44,6 +44,15 @@ static u8 twl4030_start_script_address =3D 0x2b; > #define PWR_DEVSLP BIT(1) > #define PWR_DEVOFF BIT(0) > =20 > +/* Register bits for CFG_P1_TRANSITION (also for P2 and P3) */ > +#define STARTON_SWBUG BIT(7) /* Start on watchdog */ > +#define STARTON_VBUS BIT(5) /* Start on VBUS */ > +#define STARTON_VBAT BIT(4) /* Start on battery insert */ > +#define STARTON_RTC BIT(3) /* Start on RTC */ > +#define STARTON_USB BIT(2) /* Start on USB host */ > +#define STARTON_CHG BIT(1) /* Start on charger */ > +#define STARTON_PWON BIT(0) /* Start on PWRON button */ > + > #define SEQ_OFFSYNC (1 << 0) > =20 > #define PHY_TO_OFF_PM_MASTER(p) (p - 0x36) > @@ -606,6 +615,44 @@ twl4030_power_configure_resources(const struct t= wl4030_power_data *pdata) > return 0; > } > =20 > +static int twl4030_starton_mask_and_set(u8 bitmask, u8 bitvalues) > +{ > + u8 regs[3] =3D { TWL4030_PM_MASTER_CFG_P1_TRANSITION, > + TWL4030_PM_MASTER_CFG_P2_TRANSITION, > + TWL4030_PM_MASTER_CFG_P3_TRANSITION, }; > + u8 val; > + int i, err; > + > + err =3D twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KE= Y_CFG1, > + TWL4030_PM_MASTER_PROTECT_KEY); > + if (err) > + goto relock; > + err =3D twl_i2c_write_u8(TWL_MODULE_PM_MASTER, > + TWL4030_PM_MASTER_KEY_CFG2, > + TWL4030_PM_MASTER_PROTECT_KEY); > + if (err) > + goto relock; > + > + for (i =3D 0; i < sizeof(regs); i++) { > + err =3D twl_i2c_read_u8(TWL_MODULE_PM_MASTER, > + &val, regs[i]); > + if (err) > + break; > + val =3D (~bitmask & val) | (bitmask & bitvalues); > + err =3D twl_i2c_write_u8(TWL_MODULE_PM_MASTER, > + val, regs[i]); > + if (err) > + break; > + } > + > + if (err) > + pr_err("TWL4030 Register access failed: %i\n", err); > + > +relock: > + return twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0, > + TWL4030_PM_MASTER_PROTECT_KEY); > +} > + > /* > * In master mode, start the power off sequence. > * After a successful execution, TWL shuts down the power to the SoC > @@ -615,6 +662,11 @@ void twl4030_power_off(void) > { > int err; > =20 > + /* Disable start on charger or VBUS as it can break poweroff */ > + err =3D twl4030_starton_mask_and_set(STARTON_VBUS | STARTON_CHG, 0)= ; > + if (err) > + pr_err("TWL4030 Unable to configure start-up\n"); > + > err =3D twl_i2c_write_u8(TWL_MODULE_PM_MASTER, PWR_DEVOFF, > TWL4030_PM_MASTER_P1_SW_EVENTS); > if (err) --=20 Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org =E2=94=82 Open source software for ARM SoCs =46ollow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe linux-omap" i= n the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html