[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <59334bc1f64926f8106a9b1e885dd88971d34117.camel@pengutronix.de>
Date: Wed, 06 Oct 2021 11:24:34 +0200
From: Philipp Zabel <p.zabel@...gutronix.de>
To: Hector Martin <marcan@...can.st>,
linux-arm-kernel@...ts.infradead.org
Cc: Marc Zyngier <maz@...nel.org>, Rob Herring <robh+dt@...nel.org>,
Arnd Bergmann <arnd@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>,
Alyssa Rosenzweig <alyssa@...enzweig.io>,
Krzysztof Kozlowski <krzk@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Mark Kettenis <mark.kettenis@...all.nl>,
"Rafael J. Wysocki" <rafael@...nel.org>,
devicetree@...r.kernel.org, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-samsung-soc@...r.kernel.org,
linux-serial@...r.kernel.org
Subject: Re: [PATCH 3/7] soc: apple: Add driver for Apple PMGR power state
controls
Hi Hector,
On Wed, 2021-10-06 at 00:59 +0900, Hector Martin wrote:
> Implements genpd and reset providers for downstream devices. Each
> instance of the driver binds to a single register and represents a
> single SoC power domain.
>
> The driver does not currently implement all features (auto-pm,
> clockgate-only state), but we declare the respective registers for
> documentation purposes. These features will be added as they become
> useful for downstream devices.
>
> This also creates the apple/soc tree and Kconfig submenu.
>
> Signed-off-by: Hector Martin <marcan@...can.st>
> ---
> MAINTAINERS | 1 +
> drivers/soc/Kconfig | 1 +
> drivers/soc/Makefile | 1 +
> drivers/soc/apple/Kconfig | 21 ++
> drivers/soc/apple/Makefile | 2 +
> drivers/soc/apple/apple-pmgr-pwrstate.c | 281 ++++++++++++++++++++++++
> 6 files changed, 307 insertions(+)
> create mode 100644 drivers/soc/apple/Kconfig
> create mode 100644 drivers/soc/apple/Makefile
> create mode 100644 drivers/soc/apple/apple-pmgr-pwrstate.c
>
[...]
> diff --git a/drivers/soc/apple/apple-pmgr-pwrstate.c b/drivers/soc/apple/apple-pmgr-pwrstate.c
> new file mode 100644
> index 000000000000..a0338dbb29b8
> --- /dev/null
> +++ b/drivers/soc/apple/apple-pmgr-pwrstate.c
> @@ -0,0 +1,281 @@
[...]
> +static int apple_pmgr_reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
> +{
> + struct apple_pmgr_ps *ps = rcdev_to_apple_pmgr_ps(rcdev);
> +
> + mutex_lock(&ps->genpd.mlock);
> +
> + if (ps->genpd.status == GENPD_STATE_OFF)
> + dev_err(ps->dev, "PS 0x%x: asserting RESET while powered down\n", ps->offset);
> +
> + dev_dbg(ps->dev, "PS 0x%x: assert reset\n", ps->offset);
> + /* Quiesce device before asserting reset */
> + regmap_set_bits(ps->regmap, ps->offset, APPLE_PMGR_DEV_DISABLE);
> + regmap_set_bits(ps->regmap, ps->offset, APPLE_PMGR_RESET);
> +
> + mutex_unlock(&ps->genpd.mlock);
> +
> + return 0;
> +}
> +
> +static int apple_pmgr_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
> +{
> + struct apple_pmgr_ps *ps = rcdev_to_apple_pmgr_ps(rcdev);
> +
> + mutex_lock(&ps->genpd.mlock);
> +
> + dev_dbg(ps->dev, "PS 0x%x: deassert reset\n", ps->offset);
> + regmap_clear_bits(ps->regmap, ps->offset, APPLE_PMGR_RESET);
> + regmap_clear_bits(ps->regmap, ps->offset, APPLE_PMGR_DEV_DISABLE);
> +
> + if (ps->genpd.status == GENPD_STATE_OFF)
> + dev_err(ps->dev, "PS 0x%x: RESET was deasserted while powered down\n", ps->offset);
> +
> + mutex_unlock(&ps->genpd.mlock);
> +
> + return 0;
> +}
> +
> +static int apple_pmgr_reset_reset(struct reset_controller_dev *rcdev, unsigned long id)
> +{
> + int ret;
> +
> + ret = apple_pmgr_reset_assert(rcdev, id);
> + if (ret)
> + return ret;
> +
> + usleep_range(APPLE_PMGR_RESET_TIME, 2 * APPLE_PMGR_RESET_TIME);
Is this delay known to be long enough for all consumers using the
reset_control_reset() functionality? Are there any users at all?
Is it ok for a genpd transition to happen during this sleep?
> + return apple_pmgr_reset_deassert(rcdev, id);
> +}
regards
Philipp
Powered by blists - more mailing lists