Re: [PATCH v2 3/4] soc: mediatek: add support of MTK_SCPD_STRICT_BUSP cap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Il 25/07/22 10:18, Markus Schneider-Pargmann ha scritto:
From: Alexandre Bailon <abailon@xxxxxxxxxxxx>

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@xxxxxxxxxxxx>
Signed-off-by: Fabien Parent <fparent@xxxxxxxxxxxx>
Signed-off-by: Markus Schneider-Pargmann <msp@xxxxxxxxxxxx>
---

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



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux