All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Dmitry Osipenko <digetx@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	Mallikarjun Kasoju <mkasoju@nvidia.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	devicetree@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 6/6] mfd: max77620: Provide system power-off functionality
Date: Thu, 25 Apr 2019 13:22:41 +0200	[thread overview]
Message-ID: <20190425112241.GA10218@ulmo> (raw)
In-Reply-To: <20190424224900.8018-7-digetx@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2801 bytes --]

On Thu, Apr 25, 2019 at 01:49:00AM +0300, Dmitry Osipenko wrote:
> Provide system power-off functionality that allows to turn off machine
> gracefully.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/mfd/max77620.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c
> index 9b0009c29610..e56223bde568 100644
> --- a/drivers/mfd/max77620.c
> +++ b/drivers/mfd/max77620.c
> @@ -37,6 +37,8 @@
>  #include <linux/regmap.h>
>  #include <linux/slab.h>
>  
> +static struct max77620_chip *max77620_scratch;
> +
>  static const struct resource gpio_resources[] = {
>  	DEFINE_RES_IRQ(MAX77620_IRQ_TOP_GPIO),
>  };
> @@ -481,6 +483,15 @@ static int max77620_read_es_version(struct max77620_chip *chip)
>  	return ret;
>  }
>  
> +static void max77620_pm_power_off(void)
> +{
> +	struct max77620_chip *chip = max77620_scratch;
> +
> +	regmap_update_bits(chip->rmap, MAX77620_REG_ONOFFCNFG1,
> +			   MAX77620_ONOFFCNFG1_SFT_RST,
> +			   MAX77620_ONOFFCNFG1_SFT_RST);
> +}

I think this is only partially correct. See here for a driver that I had
proposed a while back:

	https://github.com/thierryreding/linux/commit/d0eaa77b402f62bd236d76e3edeb3ccf296cbe81

Note that that driver is part of a larger series to move away from all
the pm_power_off hackery. There was a fair bit of discussion back when I
proposed the original power off driver for max77620:

	https://lkml.org/lkml/2017/1/12/470

I think I may have a more up-to-date local branch of the system-power
branch from my github repository if you're interested in looking at some
of that code. There wasn't a whole lot of feedback on the patches, but
the feedback I did get was generally positive. However, since it didn't
gain any traction I eventually abandoned that effort. It might be worth
picking it up again, since, as far as I can tell, the situation around
power off and restart hasn't changed in the meantime.

Thierry

> +
>  static int max77620_probe(struct i2c_client *client,
>  			  const struct i2c_device_id *id)
>  {
> @@ -488,6 +499,7 @@ static int max77620_probe(struct i2c_client *client,
>  	struct max77620_chip *chip;
>  	const struct mfd_cell *mfd_cells;
>  	int n_mfd_cells;
> +	bool pm_off;
>  	int ret;
>  
>  	chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
> @@ -554,6 +566,13 @@ static int max77620_probe(struct i2c_client *client,
>  		return ret;
>  	}
>  
> +	pm_off = of_property_read_bool(client->dev.of_node,
> +				       "maxim,system-power-controller");
> +	if (pm_off && !pm_power_off) {
> +		max77620_scratch = chip;
> +		pm_power_off = max77620_pm_power_off;
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 2.21.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-04-25 11:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24 22:48 [PATCH v3 0/6] Add support for Maxim 77663 MFD Dmitry Osipenko
2019-04-24 22:48 ` [PATCH v3 1/6] mfd: max77620: Fix swapped FPS_PERIOD_MAX_US values Dmitry Osipenko
2019-04-24 22:48 ` [PATCH v3 2/6] mfd: max77620: Support Maxim 77663 Dmitry Osipenko
2019-04-24 22:48 ` [PATCH v3 3/6] regulator: " Dmitry Osipenko
2019-04-25 17:41   ` Mark Brown
2019-04-24 22:48 ` [PATCH v3 4/6] dt-bindings: mfd: max77620: Add compatible for " Dmitry Osipenko
2019-04-30 22:53   ` Rob Herring
2019-04-24 22:48 ` [PATCH v3 5/6] dt-bindings: mfd: max77620: Add maxim,system-power-controller property Dmitry Osipenko
2019-04-30 22:55   ` Rob Herring
2019-04-24 22:49 ` [PATCH v3 6/6] mfd: max77620: Provide system power-off functionality Dmitry Osipenko
2019-04-25 11:22   ` Thierry Reding [this message]
2019-04-25 14:58     ` Dmitry Osipenko

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=20190425112241.GA10218@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=digetx@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=ldewangan@nvidia.com \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mkasoju@nvidia.com \
    --cc=robh+dt@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.