mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: AngeloGioacchino Del Regno  <angelogioacchino.delregno@collabora.com>
To: Markus Schneider-Pargmann <msp@baylibre.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Weiyi Lu <weiyi.lu@mediatek.com>
Cc: Fabien Parent <parent.f@gmail.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	Alexandre Bailon <abailon@baylibre.com>,
	Fabien Parent <fparent@baylibre.com>
Subject: Re: [PATCH v2 3/4] soc: mediatek: add support of MTK_SCPD_STRICT_BUSP cap
Date: Mon, 25 Jul 2022 11:07:23 +0200	[thread overview]
Message-ID: <59d9e674-2021-b02e-4ec8-aee8a118a96d@collabora.com> (raw)
In-Reply-To: <20220725081853.1636444-4-msp@baylibre.com>

Il 25/07/22 10:18, Markus Schneider-Pargmann ha scritto:
> From: Alexandre Bailon <abailon@baylibre.com>
> 
> This adds support for MTK_SCPD_STRICT_BUSP capability. It is a strict
> bus protection policy that requires the bus protection to be disabled
> before accessing the bus.
> This is required by the mt8365, for the MM power domain.
> 
> Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
> ---
> 
> Notes:
>      Changes in v2:
>      - Fixup error handling path.
> 
>   drivers/soc/mediatek/mtk-pm-domains.c | 29 +++++++++++++++++++++++----
>   drivers/soc/mediatek/mtk-pm-domains.h |  1 +
>   2 files changed, 26 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/soc/mediatek/mtk-pm-domains.c b/drivers/soc/mediatek/mtk-pm-domains.c
> index d0eae2227813..94ca8981f45e 100644
> --- a/drivers/soc/mediatek/mtk-pm-domains.c
> +++ b/drivers/soc/mediatek/mtk-pm-domains.c
> @@ -240,6 +240,7 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
>   	struct scpsys *scpsys = pd->scpsys;
>   	bool tmp;
>   	int ret;
> +	bool strict_busprotect;
>   
>   	ret = scpsys_regulator_enable(pd->supply);
>   	if (ret)
> @@ -263,9 +264,18 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
>   	regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_ISO_BIT);
>   	regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_RST_B_BIT);
>   
> -	ret = clk_bulk_prepare_enable(pd->num_subsys_clks, pd->subsys_clks);
> -	if (ret)
> -		goto err_pwr_ack;
> +	/*
> +	 * In few Mediatek platforms(e.g. MT6779), the bus protect policy is
> +	 * stricter, which leads to bus protect release must be prior to bus
> +	 * access.
> +	 */
> +	strict_busprotect = MTK_SCPD_CAPS(pd, MTK_SCPD_STRICT_BUSP);
> +	if (!strict_busprotect) {

Please directly check for MTK_SCPD_CAPS, you don't really need that bool variable,
not even for performance... and it fits just fine in one line, even.

	if (!MTK_SCPD_CAPS(pd, MTK_SCPD_STRICT_BUS_PROTECTION)) {

> +		ret = clk_bulk_prepare_enable(pd->num_subsys_clks,
> +					      pd->subsys_clks);
> +		if (ret)
> +			goto err_pwr_ack;
> +	}
>   
>   	ret = scpsys_sram_enable(pd);
>   	if (ret < 0)
> @@ -275,12 +285,23 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
>   	if (ret < 0)
>   		goto err_disable_sram;
>   
> +	if (strict_busprotect) {

	if (MTK_SCPD_CAPS(pd, MTK_SCPD_STRICT_BUS_PROTECTION)) {

> +		ret = clk_bulk_prepare_enable(pd->num_subsys_clks,
> +					      pd->subsys_clks);
> +		if (ret)
> +			goto err_enable_bus_protect;
> +	}
> +
>   	return 0;
>   
> +err_enable_bus_protect:

For human readability purposes (and paranoidly preventing future mistakes), I'd
add a check for the strict bus protection cap here too.

> +	scpsys_bus_protect_enable(pd);
>   err_disable_sram:
>   	scpsys_sram_disable(pd);
>   err_disable_subsys_clks:
> -	clk_bulk_disable_unprepare(pd->num_subsys_clks, pd->subsys_clks);
> +	if (!strict_busprotect)
> +		clk_bulk_disable_unprepare(pd->num_subsys_clks,
> +					   pd->subsys_clks);
>   err_pwr_ack:
>   	clk_bulk_disable_unprepare(pd->num_clks, pd->clks);
>   err_reg:
> diff --git a/drivers/soc/mediatek/mtk-pm-domains.h b/drivers/soc/mediatek/mtk-pm-domains.h
> index e788d6bdde9d..a50cfb926d22 100644
> --- a/drivers/soc/mediatek/mtk-pm-domains.h
> +++ b/drivers/soc/mediatek/mtk-pm-domains.h
> @@ -8,6 +8,7 @@
>   #define MTK_SCPD_SRAM_ISO		BIT(2)
>   #define MTK_SCPD_KEEP_DEFAULT_OFF	BIT(3)
>   #define MTK_SCPD_DOMAIN_SUPPLY		BIT(4)
> +#define MTK_SCPD_STRICT_BUSP		BIT(5)

MTK_SCPD_STRICT_BUS_PROTECTION is a bit more human readable.

>   #define MTK_SCPD_CAPS(_scpd, _x)	((_scpd)->data->caps & (_x))
>   
>   #define SPM_VDE_PWR_CON			0x0210

Regards,
Angelo

  reply	other threads:[~2022-07-25  9:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25  8:18 [PATCH v2 0/4] soc: mediatek: MT8365 power support Markus Schneider-Pargmann
2022-07-25  8:18 ` [PATCH v2 1/4] dt-bindings: power: Add MT8365 power domains Markus Schneider-Pargmann
2022-07-25  8:54   ` AngeloGioacchino Del Regno
2022-08-11 10:14     ` Markus Schneider-Pargmann
2022-08-11 10:45       ` Krzysztof Kozlowski
2022-07-25  8:18 ` [PATCH v2 2/4] soc: mediatek: Add support of WAY_EN operations Markus Schneider-Pargmann
2022-07-25  9:55   ` AngeloGioacchino Del Regno
2022-08-19 12:42     ` Markus Schneider-Pargmann
2022-07-25  8:18 ` [PATCH v2 3/4] soc: mediatek: add support of MTK_SCPD_STRICT_BUSP cap Markus Schneider-Pargmann
2022-07-25  9:07   ` AngeloGioacchino Del Regno [this message]
2022-07-25  8:18 ` [PATCH v2 4/4] soc: mediatek: pm-domains: Add support for MT8365 Markus Schneider-Pargmann

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=59d9e674-2021-b02e-4ec8-aee8a118a96d@collabora.com \
    --to=angelogioacchino.delregno@collabora.com \
    --cc=abailon@baylibre.com \
    --cc=devicetree@vger.kernel.org \
    --cc=fparent@baylibre.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=msp@baylibre.com \
    --cc=parent.f@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=weiyi.lu@mediatek.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®