Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp561605imm; Wed, 13 Jun 2018 05:05:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKC5mdddTxLgQhu5voYRwRkaTqZ7he6RMVSUu+81SGqS7TcAZj8m+Lu9u0Fx3dXo7hYcDkv X-Received: by 2002:a17:902:2f43:: with SMTP id s61-v6mr4883671plb.274.1528891516197; Wed, 13 Jun 2018 05:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528891516; cv=none; d=google.com; s=arc-20160816; b=B3w9zFnqfsZjPS3f1PB5W06V7aKX/DwCmdrGROJ46giDUzGiWCJyRi8mZ8p4YxIo0l QrQd/epgj7yv0bMwCJ62Bq2bLCWfndbcOlGUhiZENQWGCHY27BFtHTh8QJCvW5aFHHai MaqMaxbtRd2FcUWDG7ffaOHPsd4C/+ko5ot9/vIIQ8n/m9X7231ECrwZy11AE88cMJxm UaJ39F1mAD6+Kz5ZLIqZvOP0z4ptiQ5gAdCOsRiAYd71hjhXIeyiVdWXLBQia3OANZID VpETrJsgASxCD882cqVpouQsoqlyyeEJ97zAcZGChuql25VgvUMIL1dKEr2ly4BsboHs AnAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=6lB44kGMzj2TjlN8uacHfwScdDQdllF8jiTsdMqWzP4=; b=HEn+1X/LfMvkbaciVJZXe+OkZBUPhADKj63rNeTfgZ0Vso7WNFyjFt2vurY/RhNT0U zCafppZss3IRQoV7qWd42GEc7jMB4UKkgEexX+Z+RMDA9G+9WJMUDrugEXQJs1EODd0P dRQd2W+Geq86yR6/2n2AYVDwGloTUby9HUrcV/pj/v847/Ey5ECERALs5nmuGtRKY27c wJT1+XQecDa/dc6OJskYzk3J6D53F+JRJW78Fs7OLTflxQygN1z0ObZ7hqZtQDVIf+tn DDwbzCiB0lK2q+pYyvcSzc10KMqpDfj1YrFprgGG5J5a1IxNJ3YW+HJ8MpetltxkboKA 81Sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9-v6si2697021ple.104.2018.06.13.05.05.01; Wed, 13 Jun 2018 05:05:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935538AbeFMMDQ (ORCPT + 99 others); Wed, 13 Jun 2018 08:03:16 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:34637 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935106AbeFMMDN (ORCPT ); Wed, 13 Jun 2018 08:03:13 -0400 Received: from soja.hi.pengutronix.de ([2001:67c:670:100:3ad5:47ff:feaf:13da]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1fT4UR-00053x-DK; Wed, 13 Jun 2018 14:03:03 +0200 Subject: Re: [PATCH v7 5/6] regulator: pfuze100-regulator: provide pm_power_off_prepare handler To: Shawn Guo , Mark Brown , "Rafael J. Wysocki" Cc: kernel@pengutronix.de, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton , Liam Girdwood , Leonard Crestez , Rob Herring , Mark Rutland , Michael Turquette , Stephen Boyd , Fabio Estevam , Russell King References: <20180517055014.6607-1-o.rempel@pengutronix.de> <20180517055014.6607-6-o.rempel@pengutronix.de> From: Oleksij Rempel Message-ID: <503b7af3-6a6a-1ed9-e2b6-609da537c855@pengutronix.de> Date: Wed, 13 Jun 2018 14:03:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180517055014.6607-6-o.rempel@pengutronix.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PAdCPQPW3BM1XfBSmjcmXXJJqHNDNxnVP" X-SA-Exim-Connect-IP: 2001:67c:670:100:3ad5:47ff:feaf:13da X-SA-Exim-Mail-From: o.rempel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PAdCPQPW3BM1XfBSmjcmXXJJqHNDNxnVP Content-Type: multipart/mixed; boundary="ebaSKat60fCA9TqMPHx77ey6XsIur2bCf"; protected-headers="v1" From: Oleksij Rempel To: Shawn Guo , Mark Brown , "Rafael J. Wysocki" Cc: kernel@pengutronix.de, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton , Liam Girdwood , Leonard Crestez , Rob Herring , Mark Rutland , Michael Turquette , Stephen Boyd , Fabio Estevam , Russell King Message-ID: <503b7af3-6a6a-1ed9-e2b6-609da537c855@pengutronix.de> Subject: Re: [PATCH v7 5/6] regulator: pfuze100-regulator: provide pm_power_off_prepare handler References: <20180517055014.6607-1-o.rempel@pengutronix.de> <20180517055014.6607-6-o.rempel@pengutronix.de> In-Reply-To: <20180517055014.6607-6-o.rempel@pengutronix.de> --ebaSKat60fCA9TqMPHx77ey6XsIur2bCf Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Hi Mark, Rob ACKed DT bindings, Rafael ACKed export of pm_power_off_prepare. I need your OK for regulator patch. On 17.05.2018 07:50, Oleksij Rempel wrote: > On some boards the SoC can use one pin "PMIC_STBY_REQ" to notify th PMI= C > about state changes. In this case internal state of PMIC must be > preconfigured for upcomming state change. > It works fine with the current regulator framework, except with the > power-off case. >=20 > This patch is providing an optional pm_power_off_prepare handler > which will configure standby state of the PMIC to disable all power lin= es. >=20 > In my power consumption test on RIoTBoard, I got the following results:= > power off without this patch: 320 mA > power off with this patch: 2 mA > suspend to ram: 40 mA >=20 > Signed-off-by: Oleksij Rempel > --- > drivers/regulator/pfuze100-regulator.c | 92 ++++++++++++++++++++++++++= > 1 file changed, 92 insertions(+) >=20 > diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator= /pfuze100-regulator.c > index 63922a2167e5..f6c276ed91d8 100644 > --- a/drivers/regulator/pfuze100-regulator.c > +++ b/drivers/regulator/pfuze100-regulator.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > #include > =20 > #define PFUZE_NUMREGS 128 > @@ -42,11 +43,17 @@ > =20 > #define PFUZE100_COINVOL 0x1a > #define PFUZE100_SW1ABVOL 0x20 > +#define PFUZE100_SW1ABMODE 0x23 > #define PFUZE100_SW1CVOL 0x2e > +#define PFUZE100_SW1CMODE 0x31 > #define PFUZE100_SW2VOL 0x35 > +#define PFUZE100_SW2MODE 0x38 > #define PFUZE100_SW3AVOL 0x3c > +#define PFUZE100_SW3AMODE 0x3f > #define PFUZE100_SW3BVOL 0x43 > +#define PFUZE100_SW3BMODE 0x46 > #define PFUZE100_SW4VOL 0x4a > +#define PFUZE100_SW4MODE 0x4d > #define PFUZE100_SWBSTCON1 0x66 > #define PFUZE100_VREFDDRCON 0x6a > #define PFUZE100_VSNVSVOL 0x6b > @@ -57,6 +64,13 @@ > #define PFUZE100_VGEN5VOL 0x70 > #define PFUZE100_VGEN6VOL 0x71 > =20 > +#define PFUZE100_SWxMODE_MASK 0xf > +#define PFUZE100_SWxMODE_APS_APS 0x8 > +#define PFUZE100_SWxMODE_APS_OFF 0x4 > + > +#define PFUZE100_VGENxLPWR BIT(6) > +#define PFUZE100_VGENxSTBY BIT(5) > + > enum chips { PFUZE100, PFUZE200, PFUZE3000 =3D 3 }; > =20 > struct pfuze_regulator { > @@ -489,6 +503,69 @@ static inline struct device_node *match_of_node(in= t index) > } > #endif > =20 > +static struct pfuze_chip *syspm_pfuze_chip; > + > +static void pfuze_power_off_prepare(void) > +{ > + dev_info(syspm_pfuze_chip->dev, "Configure standy mode for power off"= ); > + > + /* Switch from default mode: APS/APS to APS/Off */ > + regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW1ABMODE, > + PFUZE100_SWxMODE_MASK, PFUZE100_SWxMODE_APS_OFF); > + regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW1CMODE, > + PFUZE100_SWxMODE_MASK, PFUZE100_SWxMODE_APS_OFF); > + regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW2MODE, > + PFUZE100_SWxMODE_MASK, PFUZE100_SWxMODE_APS_OFF); > + regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW3AMODE, > + PFUZE100_SWxMODE_MASK, PFUZE100_SWxMODE_APS_OFF); > + regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW3BMODE, > + PFUZE100_SWxMODE_MASK, PFUZE100_SWxMODE_APS_OFF); > + regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW4MODE, > + PFUZE100_SWxMODE_MASK, PFUZE100_SWxMODE_APS_OFF); > + > + regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_VGEN1VOL, > + PFUZE100_VGENxLPWR | PFUZE100_VGENxSTBY, > + PFUZE100_VGENxSTBY); > + regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_VGEN2VOL, > + PFUZE100_VGENxLPWR | PFUZE100_VGENxSTBY, > + PFUZE100_VGENxSTBY); > + regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_VGEN3VOL, > + PFUZE100_VGENxLPWR | PFUZE100_VGENxSTBY, > + PFUZE100_VGENxSTBY); > + regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_VGEN4VOL, > + PFUZE100_VGENxLPWR | PFUZE100_VGENxSTBY, > + PFUZE100_VGENxSTBY); > + regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_VGEN5VOL, > + PFUZE100_VGENxLPWR | PFUZE100_VGENxSTBY, > + PFUZE100_VGENxSTBY); > + regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_VGEN6VOL, > + PFUZE100_VGENxLPWR | PFUZE100_VGENxSTBY, > + PFUZE100_VGENxSTBY); > +} > + > +static int pfuze_power_off_prepare_init(struct pfuze_chip *pfuze_chip)= > +{ > + if (pfuze_chip->chip_id !=3D PFUZE100) { > + dev_warn(pfuze_chip->dev, "Requested pm_power_off_prepare handler fo= r not supported chip\n"); > + return -ENODEV; > + } > + > + if (pm_power_off_prepare) { > + dev_warn(pfuze_chip->dev, "pm_power_off_prepare is already registere= d.\n"); > + return -EBUSY; > + } > + > + if (syspm_pfuze_chip) { > + dev_warn(pfuze_chip->dev, "syspm_pfuze_chip is already set.\n"); > + return -EBUSY; > + } > + > + syspm_pfuze_chip =3D pfuze_chip; > + pm_power_off_prepare =3D pfuze_power_off_prepare; > + > + return 0; > +} > + > static int pfuze_identify(struct pfuze_chip *pfuze_chip) > { > unsigned int value; > @@ -659,6 +736,20 @@ static int pfuze100_regulator_probe(struct i2c_cli= ent *client, > } > } > =20 > + if (of_property_read_bool(client->dev.of_node, > + "fsl,pmic-stby-poweroff")) > + return pfuze_power_off_prepare_init(pfuze_chip); > + > + return 0; > +} > + > +static int pfuze100_regulator_remove(struct i2c_client *client) > +{ > + if (syspm_pfuze_chip) { > + syspm_pfuze_chip =3D NULL; > + pm_power_off_prepare =3D NULL; > + } > + > return 0; > } > =20 > @@ -669,6 +760,7 @@ static struct i2c_driver pfuze_driver =3D { > .of_match_table =3D pfuze_dt_ids, > }, > .probe =3D pfuze100_regulator_probe, > + .remove =3D pfuze100_regulator_remove, > }; > module_i2c_driver(pfuze_driver); > =20 >=20 --ebaSKat60fCA9TqMPHx77ey6XsIur2bCf-- --PAdCPQPW3BM1XfBSmjcmXXJJqHNDNxnVP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEpENFL0P3hvQ7p0DDdQOiSHVI77QFAlshB/UACgkQdQOiSHVI 77TuZAgAtvxSvuq8V8Sv8A3kPzH5oxmZVqSxDGgjskOHCS4rZ6AAcw7zCxBC8xcH wrtXLKhetE1PmBn3qP78U3gS/VMdVdXuGV7qItRrprlmgO45cJ4EJ2fYVIMijHb2 K4q3GPZZJhgwRd3s/Fs3JVZneWYWnPtqEbQeAxro+iJ1oPSr1foHmqQAJpkaWhN0 CnSyDGHD9JER8p+KFg8BsUb3c5ypw/C0WPD0gjQLlPhID2fkgylpFuuFpWzngl4B v34Uh9Z51aKoXxLpOcVaSnp7UFX5ME7HVQjFsAkqi2Xq08oq3nFg1zc+e+9Jz8t3 v79GIIzFPLIsasLHTd0vWCT0veApLQ== =yIkj -----END PGP SIGNATURE----- --PAdCPQPW3BM1XfBSmjcmXXJJqHNDNxnVP--