2023-02-25 10:17:02

by Yassine Oudjana

[permalink] [raw]
Subject: [PATCH 0/3] MediaTek MT6735 SCPSYS support

From: Yassine Oudjana <[email protected]>

These patches are part of a larger effort to support the MT6735 SoC family in
mainline Linux. More patches (unsent or sent and pending review or revision)
can be found here[1].

This series adds support for most SCPSYS power domains on MT6735. See patches
for details.

[1] https://gitlab.com/mt6735-mainline/linux/-/commits/mt6735-staging

Yassine Oudjana (3):
dt-bindings: power: Add bindings for MediaTek MT6735
dt-bindings: soc: mediatek: scpsys: Document MT6735 SCPSYS compatible
string
soc: mediatek: scpsys: Add support for MT6735

.../bindings/soc/mediatek/scpsys.txt | 2 +
drivers/soc/mediatek/mtk-scpsys.c | 84 +++++++++++++++++++
.../power/mediatek,mt6735-scpsys.h | 14 ++++
3 files changed, 100 insertions(+)
create mode 100644 include/dt-bindings/power/mediatek,mt6735-scpsys.h

--
2.39.2



2023-02-25 10:17:19

by Yassine Oudjana

[permalink] [raw]
Subject: [PATCH 1/3] dt-bindings: power: Add bindings for MediaTek MT6735

From: Yassine Oudjana <[email protected]>

Add DT bindings for MediaTek MT6735 SCPSYS.

Signed-off-by: Yassine Oudjana <[email protected]>
---
include/dt-bindings/power/mediatek,mt6735-scpsys.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 include/dt-bindings/power/mediatek,mt6735-scpsys.h

diff --git a/include/dt-bindings/power/mediatek,mt6735-scpsys.h b/include/dt-bindings/power/mediatek,mt6735-scpsys.h
new file mode 100644
index 000000000000..5124cdee9dc7
--- /dev/null
+++ b/include/dt-bindings/power/mediatek,mt6735-scpsys.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _DT_BINDINGS_POWER_MEDIATEK_MT6735_SCPSYS_H
+#define _DT_BINDINGS_POWER_MEDIATEK_MT6735_SCPSYS_H
+
+#define MT6735_POWER_DOMAIN_MD1 0
+#define MT6735_POWER_DOMAIN_CONN 1
+#define MT6735_POWER_DOMAIN_DIS 2
+#define MT6735_POWER_DOMAIN_MFG 3
+#define MT6735_POWER_DOMAIN_ISP 4
+#define MT6735_POWER_DOMAIN_VDE 5
+#define MT6735_POWER_DOMAIN_VEN 6
+
+#endif
--
2.39.2


2023-02-25 10:17:23

by Yassine Oudjana

[permalink] [raw]
Subject: [PATCH 2/3] dt-bindings: soc: mediatek: scpsys: Document MT6735 SCPSYS compatible string

From: Yassine Oudjana <[email protected]>

Add a compatible string for MT6735 SCPSYS.

Signed-off-by: Yassine Oudjana <[email protected]>
---
Documentation/devicetree/bindings/soc/mediatek/scpsys.txt | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt b/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
index 2bc367793aec..54ba2e06403a 100644
--- a/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
+++ b/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
@@ -10,6 +10,7 @@ domain control.
The driver implements the Generic PM domain bindings described in
power/power-domain.yaml. It provides the power domains defined in
- include/dt-bindings/power/mt8173-power.h
+- include/dt-bindings/power/mediatek,mt6735-scpsys.h
- include/dt-bindings/power/mt6797-power.h
- include/dt-bindings/power/mt6765-power.h
- include/dt-bindings/power/mt2701-power.h
@@ -20,6 +21,7 @@ Required properties:
- compatible: Should be one of:
- "mediatek,mt2701-scpsys"
- "mediatek,mt2712-scpsys"
+ - "mediatek,mt6735-scpsys"
- "mediatek,mt6765-scpsys"
- "mediatek,mt6797-scpsys"
- "mediatek,mt7622-scpsys"
--
2.39.2


2023-02-25 10:17:26

by Yassine Oudjana

[permalink] [raw]
Subject: [PATCH 3/3] soc: mediatek: scpsys: Add support for MT6735

From: Yassine Oudjana <[email protected]>

Add support for SCPSYS power domains of MT6735. All non-CPU power domains
are added except for MD2 (C2K modem), which is left out due to issues
with powering it on.

Signed-off-by: Yassine Oudjana <[email protected]>
---
drivers/soc/mediatek/mtk-scpsys.c | 84 +++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)

diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c
index 7a668888111c..b771bfb93cc9 100644
--- a/drivers/soc/mediatek/mtk-scpsys.c
+++ b/drivers/soc/mediatek/mtk-scpsys.c
@@ -13,6 +13,7 @@
#include <linux/regulator/consumer.h>
#include <linux/soc/mediatek/infracfg.h>

+#include <dt-bindings/power/mediatek,mt6735-scpsys.h>
#include <dt-bindings/power/mt2701-power.h>
#include <dt-bindings/power/mt2712-power.h>
#include <dt-bindings/power/mt6797-power.h>
@@ -32,6 +33,7 @@
#define SPM_VEN_PWR_CON 0x0230
#define SPM_ISP_PWR_CON 0x0238
#define SPM_DIS_PWR_CON 0x023c
+#define SPM_MD1_PWR_CON 0x0284 /* MT6735 */
#define SPM_CONN_PWR_CON 0x0280
#define SPM_VEN2_PWR_CON 0x0298
#define SPM_AUDIO_PWR_CON 0x029c /* MT8173, MT2712 */
@@ -57,11 +59,13 @@
#define PWR_ON_2ND_BIT BIT(3)
#define PWR_CLK_DIS_BIT BIT(4)

+#define PWR_STATUS_MD1 BIT(0)
#define PWR_STATUS_CONN BIT(1)
#define PWR_STATUS_DISP BIT(3)
#define PWR_STATUS_MFG BIT(4)
#define PWR_STATUS_ISP BIT(5)
#define PWR_STATUS_VDEC BIT(7)
+#define PWR_STATUS_VEN BIT(8) /* MT6735 */
#define PWR_STATUS_BDP BIT(14)
#define PWR_STATUS_ETH BIT(15)
#define PWR_STATUS_HIF BIT(16)
@@ -750,6 +754,73 @@ static const struct scp_subdomain scp_subdomain_mt2712[] = {
{MT2712_POWER_DOMAIN_MFG_SC2, MT2712_POWER_DOMAIN_MFG_SC3},
};

+/*
+ * MT6735 power domain support
+ */
+
+static const struct scp_domain_data scp_domain_data_mt6735[] = {
+ [MT6735_POWER_DOMAIN_MD1] = {
+ .name = "md1",
+ .sta_mask = PWR_STATUS_MD1,
+ .ctl_offs = SPM_MD1_PWR_CON,
+ .sram_pdn_bits = GENMASK(8, 8),
+ .sram_pdn_ack_bits = 0,
+ .clk_id = {CLK_NONE},
+ .bus_prot_mask = (BIT(24) | BIT(25) | BIT(26) | BIT(27) | BIT(28)),
+ },
+ [MT6735_POWER_DOMAIN_CONN] = {
+ .name = "conn",
+ .sta_mask = PWR_STATUS_CONN,
+ .ctl_offs = SPM_CONN_PWR_CON,
+ .sram_pdn_bits = GENMASK(8, 8),
+ .sram_pdn_ack_bits = 0,
+ .clk_id = {CLK_NONE},
+ .bus_prot_mask = (BIT(2) | BIT(8)),
+ },
+ [MT6735_POWER_DOMAIN_DIS] = {
+ .name = "dis",
+ .sta_mask = PWR_STATUS_DISP,
+ .ctl_offs = SPM_DIS_PWR_CON,
+ .sram_pdn_bits = GENMASK(11, 8),
+ .sram_pdn_ack_bits = GENMASK(12, 12),
+ .clk_id = {CLK_NONE},
+ .bus_prot_mask = (BIT(1)),
+ },
+ [MT6735_POWER_DOMAIN_MFG] = {
+ .name = "mfg",
+ .sta_mask = PWR_STATUS_MFG,
+ .ctl_offs = SPM_MFG_PWR_CON,
+ .sram_pdn_bits = GENMASK(11, 8),
+ .sram_pdn_ack_bits = GENMASK(12, 12),
+ .clk_id = {CLK_NONE},
+ .bus_prot_mask = BIT(14),
+ },
+ [MT6735_POWER_DOMAIN_ISP] = {
+ .name = "isp",
+ .sta_mask = PWR_STATUS_ISP,
+ .ctl_offs = SPM_ISP_PWR_CON,
+ .sram_pdn_bits = GENMASK(11, 8),
+ .sram_pdn_ack_bits = GENMASK(13, 12),
+ .clk_id = {CLK_NONE},
+ },
+ [MT6735_POWER_DOMAIN_VDE] = {
+ .name = "vde",
+ .sta_mask = PWR_STATUS_VDEC,
+ .ctl_offs = SPM_VDE_PWR_CON,
+ .sram_pdn_bits = GENMASK(11, 8),
+ .sram_pdn_ack_bits = GENMASK(12, 12),
+ .clk_id = {CLK_NONE},
+ },
+ [MT6735_POWER_DOMAIN_VEN] = {
+ .name = "ven",
+ .sta_mask = PWR_STATUS_VEN,
+ .ctl_offs = SPM_VEN_PWR_CON,
+ .sram_pdn_bits = GENMASK(11, 8),
+ .sram_pdn_ack_bits = GENMASK(15, 12),
+ .clk_id = {CLK_NONE},
+ },
+};
+
/*
* MT6797 power domain support
*/
@@ -1033,6 +1104,16 @@ static const struct scp_soc_data mt2712_data = {
.bus_prot_reg_update = false,
};

+static const struct scp_soc_data mt6735_data = {
+ .domains = scp_domain_data_mt6735,
+ .num_domains = ARRAY_SIZE(scp_domain_data_mt6735),
+ .regs = {
+ .pwr_sta_offs = SPM_PWR_STATUS,
+ .pwr_sta2nd_offs = SPM_PWR_STATUS_2ND
+ },
+ .bus_prot_reg_update = true,
+};
+
static const struct scp_soc_data mt6797_data = {
.domains = scp_domain_data_mt6797,
.num_domains = ARRAY_SIZE(scp_domain_data_mt6797),
@@ -1088,6 +1169,9 @@ static const struct of_device_id of_scpsys_match_tbl[] = {
}, {
.compatible = "mediatek,mt2712-scpsys",
.data = &mt2712_data,
+ }, {
+ .compatible = "mediatek,mt6735-scpsys",
+ .data = &mt6735_data,
}, {
.compatible = "mediatek,mt6797-scpsys",
.data = &mt6797_data,
--
2.39.2


2023-02-27 08:15:03

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 1/3] dt-bindings: power: Add bindings for MediaTek MT6735

On 25/02/2023 11:16, Yassine Oudjana wrote:
> From: Yassine Oudjana <[email protected]>
>
> Add DT bindings for MediaTek MT6735 SCPSYS.
>
> Signed-off-by: Yassine Oudjana <[email protected]>
> ---
> include/dt-bindings/power/mediatek,mt6735-scpsys.h | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
> create mode 100644 include/dt-bindings/power/mediatek,mt6735-scpsys.h
>
> diff --git a/include/dt-bindings/power/mediatek,mt6735-scpsys.h b/include/dt-bindings/power/mediatek,mt6735-scpsys.h
> new file mode 100644
> index 000000000000..5124cdee9dc7
> --- /dev/null
> +++ b/include/dt-bindings/power/mediatek,mt6735-scpsys.h
> @@ -0,0 +1,14 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */

Dual license, please. Same as bindings (checkpatch should warn).


Best regards,
Krzysztof


2023-02-27 08:15:45

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 2/3] dt-bindings: soc: mediatek: scpsys: Document MT6735 SCPSYS compatible string

On 25/02/2023 11:16, Yassine Oudjana wrote:
> From: Yassine Oudjana <[email protected]>
>
> Add a compatible string for MT6735 SCPSYS.
>
> Signed-off-by: Yassine Oudjana <[email protected]>
> ---
> Documentation/devicetree/bindings/soc/mediatek/scpsys.txt | 2 ++

Previous commit should be part of this one. It is logically the same and
you cannot merge them via different trees/branches.


Best regards,
Krzysztof


Subject: Re: [PATCH 3/3] soc: mediatek: scpsys: Add support for MT6735

Il 25/02/23 11:16, Yassine Oudjana ha scritto:
> From: Yassine Oudjana <[email protected]>
>
> Add support for SCPSYS power domains of MT6735. All non-CPU power domains
> are added except for MD2 (C2K modem), which is left out due to issues
> with powering it on.
>

This is a legacy driver and I'm convinced that we should do something to
actually *drop it forever*.

Please add support for power domains in mtk-pm-domains.c instead: if you need
a nice example about differences between the two, look at MT8173's implementation,
as that is present in both scpsys and mtk-pm-domains.

Summarizing, your MT6735 support will be about:
- Adding soc/mediatek/mt6735-pm-domains.h
- Adding support in mtk-pm-domains:

static const struct of_device_id scpsys_of_match[] = {
........
{
.compatible = "mediatek,mt6735-power-controller",
.data = &mt6735_scpsys_data,
},
.........
};

Cheers,
Angelo

> Signed-off-by: Yassine Oudjana <[email protected]>
> ---


Subject: Re: [PATCH 2/3] dt-bindings: soc: mediatek: scpsys: Document MT6735 SCPSYS compatible string

Il 25/02/23 11:16, Yassine Oudjana ha scritto:
> From: Yassine Oudjana <[email protected]>
>
> Add a compatible string for MT6735 SCPSYS.
>
> Signed-off-by: Yassine Oudjana <[email protected]>
> ---
> Documentation/devicetree/bindings/soc/mediatek/scpsys.txt | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt b/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
> index 2bc367793aec..54ba2e06403a 100644
> --- a/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
> +++ b/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
> @@ -10,6 +10,7 @@ domain control.
> The driver implements the Generic PM domain bindings described in
> power/power-domain.yaml. It provides the power domains defined in
> - include/dt-bindings/power/mt8173-power.h
> +- include/dt-bindings/power/mediatek,mt6735-scpsys.h
> - include/dt-bindings/power/mt6797-power.h
> - include/dt-bindings/power/mt6765-power.h
> - include/dt-bindings/power/mt2701-power.h
> @@ -20,6 +21,7 @@ Required properties:
> - compatible: Should be one of:
> - "mediatek,mt2701-scpsys"
> - "mediatek,mt2712-scpsys"
> + - "mediatek,mt6735-scpsys"

NACK. Please implement in mtk-pm-domains instead.

> - "mediatek,mt6765-scpsys"
> - "mediatek,mt6797-scpsys"
> - "mediatek,mt7622-scpsys"