Add Support for MediaTek MT8192 APU Power Domain
Subsystems (3)
v4 cover Add Support for MediaTek MT8192 APU Power Domain
The MediaTek AI Processing Unit (APU) is a proprietary hardware in the SoC to support AI operations.
The series is to create apusys in the SoC folder for developing the related drivers. Add the apu clocks, basic apu nodes and the power domain to provide the power controller of APU subsystem.
This series is based on MT8192 power domain[1], PWRAP[2] and PMIC MT6359[3] patches.
[1] https://patchwork.kernel.org/patch/12456165
[2] https://patchwork.kernel.org/patch/12134935
[3] https://patchwork.kernel.org/patch/12140237
Change notes:v3->v4:
1) Rebase to 5.16-rc1
2) Update mtk-apu-pm driver to be a module or a buildin driver.
3) Fix coding defects and typo in mtk-apu-pm.c and update copyright in dt-bindins.
4) Split the mt8192 EVB device tree "mt8192-evb.dts" to a new patch file in the series.
v2->v3:
1) Rebase to 5.15-rc1
2) remove the apu-mbox registers from syscon.
3) update mtk-apu-pm to fix clock flow and move power status bit into platform data to support different hardware settings.
v1->v2:
1) update expression "s/_/-/" in dt-bindings documents.
2) drop apu power domain header file for mt8192.
v1: https://patchwork.kernel.org/project/linux-mediatek/list/?series=461999
Flora Fu (8):
dt-bindings: clock: Add MT8192 APU clock bindings
clk: mediatek: mt8192: Add APU clocks support
dt-bindings: arm: mediatek: Add new document bindings for APU
dt-bindings: soc: mediatek: apusys: Add new document for APU power
domain
soc: mediatek: apu: Add apusys and add apu power domain driver
arm64: dts: mt8192: Add APU node
arm64: dts: mt8192: Add APU power domain node
arm64: dts: mt8192: Set up apu power domain regulators
.../arm/mediatek/mediatek,apusys.yaml | 50 ++ .../soc/mediatek/mediatek,apu-pm.yaml | 144 ++++ arch/arm64/boot/dts/mediatek/mt8192-evb.dts | 7 + arch/arm64/boot/dts/mediatek/mt8192.dtsi | 39 + drivers/clk/mediatek/clk-mt8192.c | 91 +++ drivers/soc/mediatek/Kconfig | 12 + drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/apusys/Kconfig | 14 + drivers/soc/mediatek/apusys/Makefile | 2 + drivers/soc/mediatek/apusys/mtk-apu-pm.c | 727 ++++++++++++++++++ include/dt-bindings/clock/mt8192-clk.h | 14 +- 11 files changed, 1099 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,apusys.yaml create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,apu-pm.yaml create mode 100644 drivers/soc/mediatek/apusys/Kconfig create mode 100644 drivers/soc/mediatek/apusys/Makefile create mode 100644 drivers/soc/mediatek/apusys/mtk-apu-pm.c
Signature · 1 line
2.18.0
PATCH v4 1/8 dt-bindings: clock: Add MT8192 APU clock bindings
Add clock bindings for APU on MT8192.
--- include/dt-bindings/clock/mt8192-clk.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
include/dt-bindings/clock/mt8192-clk.h +12 -2
@@ -164,7 +164,15 @@#define CLK_TOP_APLL12_DIV9 152#define CLK_TOP_SSUSB_TOP_REF 153#define CLK_TOP_SSUSB_PHY_REF 154 -#define CLK_TOP_NR_CLK 155 +#define CLK_TOP_DSP_SEL 155 +#define CLK_TOP_DSP1_SEL 156 +#define CLK_TOP_DSP1_NPUPLL_SEL 157 +#define CLK_TOP_DSP2_SEL 158 +#define CLK_TOP_DSP2_NPUPLL_SEL 159 +#define CLK_TOP_DSP5_SEL 160 +#define CLK_TOP_DSP5_APUPLL_SEL 161 +#define CLK_TOP_IPU_IF_SEL 162 +#define CLK_TOP_NR_CLK 163/* INFRACFG */
@@ -309,7 +317,9 @@#define CLK_APMIXED_APLL1 8#define CLK_APMIXED_APLL2 9#define CLK_APMIXED_MIPID26M 10 -#define CLK_APMIXED_NR_CLK 11 +#define CLK_APMIXED_APUPLL 11 +#define CLK_APMIXED_NPUPLL 12 +#define CLK_APMIXED_NR_CLK 13/* SCP_ADSP */
Signature · 1 line
2.18.0
PATCH v4 2/8 clk: mediatek: mt8192: Add APU clocks support
In reply to Flora FuAdd APU clocks support on MT8192.
--- drivers/clk/mediatek/clk-mt8192.c | 91 +++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+)
drivers/clk/mediatek/clk-mt8192.c +91 -0
@@ -244,6 +244,65 @@ static const char * const ccu_parents[] = {"univpll_d6_d2" }; +static const char *const dsp_parents[] = { +"clk26m" , +"univpll_d6_d2" , +"univpll_d4_d2" , +"univpll_d5" , +"univpll_d4" , +"mmpll_d4" , +"mainpll_d3" , +"univpll_d3" +}; + +static const char *const dsp1_parents[] = { +"clk26m" , +"npupll_ck" , +"mainpll_d4_d2" , +"univpll_d5" , +"univpll_d4" , +"mainpll_d3" , +"univpll_d3" , +"apupll_ck" +}; + +static const char *const dsp1_npupll_parents[] = { +"dsp1_sel" , +"npupll_ck" +}; + +static const char *const dsp2_parents[] = { +"clk26m" , +"npupll_ck" , +"mainpll_d4_d2" , +"univpll_d5" , +"univpll_d4" , +"mainpll_d3" , +"univpll_d3" , +"apupll_ck" +}; + +static const char *const dsp2_npupll_parents[] = { +"dsp2_sel" , +"npupll_ck" +}; + +static const char *const dsp5_parents[] = { +"clk26m" , +"apupll_ck" , +"univpll_d4_d2" , +"mainpll_d4" , +"univpll_d4" , +"mmpll_d4" , +"mainpll_d3" , +"univpll_d3" +}; + +static const char *const dsp5_apupll_parents[] = { +"dsp5_sel" , +"apupll_ck" +}; +static const char *const dsp7_parents[] = {"clk26m" ,"mainpll_d4_d2" ,
@@ -255,6 +314,17 @@ static const char * const dsp7_parents[] = {"mmpll_d4" }; +static const char *const ipu_if_parents[] = { +"clk26m" , +"univpll_d6_d2" , +"mainpll_d4_d2" , +"univpll_d4_d2" , +"univpll_d5" , +"mainpll_d4" , +"tvdpll_ck" , +"univpll_d4" +}; +static const char *const mfg_ref_parents[] = {"clk26m" ,"clk26m" ,
@@ -734,9 +804,26 @@ static const struct mtk_mux top_mtk_muxes[] = { cam_parents, 0x030, 0x034, 0x038, 16, 4, 23, 0x004, 10),MUX_GATE_CLR_SET_UPD (CLK_TOP_CCU_SEL ,"ccu_sel" , ccu_parents,0x030 ,0x034 ,0x038 ,24 ,4 ,31 ,0x004 ,11 ), +/* CLK_CFG_3 */ +MUX_GATE_CLR_SET_UPD (CLK_TOP_DSP_SEL ,"dsp_sel" , + dsp_parents,0x040 ,0x044 ,0x048 ,0 ,3 ,7 ,0x004 ,12 ), +MUX_GATE_CLR_SET_UPD (CLK_TOP_DSP1_SEL ,"dsp1_sel" , + dsp1_parents,0x040 ,0x044 ,0x048 ,8 ,3 ,15 ,0x004 ,13 ), +MUX_CLR_SET_UPD (CLK_TOP_DSP1_NPUPLL_SEL ,"dsp1_npupll_sel" , + dsp1_npupll_parents,0x040 ,0x044 ,0x048 ,11 ,1 ,-1 ,-1 ), +MUX_GATE_CLR_SET_UPD (CLK_TOP_DSP2_SEL ,"dsp2_sel" , + dsp2_parents,0x040 ,0x044 ,0x048 ,16 ,3 ,23 ,0x004 ,14 ), +MUX_CLR_SET_UPD (CLK_TOP_DSP2_NPUPLL_SEL ,"dsp2_npupll_sel" , + dsp2_npupll_parents,0x040 ,0x044 ,0x048 ,19 ,1 ,-1 ,-1 ), +MUX_GATE_CLR_SET_UPD (CLK_TOP_DSP5_SEL ,"dsp5_sel" , + dsp5_parents,0x040 ,0x044 ,0x048 ,24 ,3 ,31 ,0x004 ,15 ), +MUX_CLR_SET_UPD (CLK_TOP_DSP5_APUPLL_SEL ,"dsp5_apupll_sel" , + dsp5_apupll_parents,0x040 ,0x044 ,0x048 ,27 ,1 ,-1 ,-1 ),/* CLK_CFG_4 */ MUX_GATE_CLR_SET_UPD (CLK_TOP_DSP7_SEL ,"dsp7_sel" , dsp7_parents,0x050 ,0x054 ,0x058 ,0 ,3 ,7 ,0x004 ,16 ), +MUX_GATE_CLR_SET_UPD (CLK_TOP_IPU_IF_SEL ,"ipu_if_sel" , + ipu_if_parents,0x050 ,0x054 ,0x058 ,8 ,3 ,15 ,0x004 ,17 ),MUX_GATE_CLR_SET_UPD (CLK_TOP_MFG_REF_SEL ,"mfg_ref_sel" , mfg_ref_parents,0x050 ,0x054 ,0x058 ,16 ,2 ,23 ,0x004 ,18 ), MUX_CLR_SET_UPD(CLK_TOP_MFG_PLL_SEL, "mfg_pll_sel",
@@ -1175,6 +1262,10 @@ static const struct mtk_pll_data plls[] = { 0, 0, 32, 0x031c, 24, 0x0040, 0x000c, 0, 0x0320, 0),PLL_B (CLK_APMIXED_APLL2 ,"apll2" ,0x032c ,0x033c ,0x00000000 ,0 ,0 ,32 ,0x0330 ,24 ,0 ,0 ,0 ,0x0334 ,0 ), +PLL_B (CLK_APMIXED_APUPLL ,"apupll" ,0x03a0 ,0x03ac ,0xff000001 , +HAVE_RST_BAR ,BIT (23 ),22 ,0x03a4 ,24 ,0 ,0 ,0 ,0x03a4 ,0 ), +PLL_B (CLK_APMIXED_NPUPLL ,"npupll" ,0x03b4 ,0x03c0 ,0x00000001 , + 0, 0, 22, 0x03b8, 24, 0, 0, 0, 0x03b8, 0), };static struct clk_onecell_data *top_clk_data;
Signature · 1 line
2.18.0
PATCH v4 3/8 dt-bindings: arm: mediatek: Add new document bindings for APU
In reply to Flora FuDocument the apusys bindings.
--- .../arm/mediatek/mediatek,apusys.yaml | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,apusys.yaml
Documentation/devicetree/bindings/arm/mediatek/mediatek,apusys.yaml new file +50 -0
@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (C) 2021 MediaTek Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,apusys.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek APUSYS Controller + +maintainers: + - Flora Fu <[email protected]> + +description: + The MediaTek apusys controller provides functional configurations and clocks + to the system. + +properties: + compatible: + items: + - enum: + - mediatek,mt8192-apu-conn + - mediatek,mt8192-apu-vcore + - const: syscon + + reg: + maxItems: 1 + + '#clock-cells': + const: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + apu_conn: apu_conn@19020000 { + compatible = "mediatek,mt8192-apu-conn", "syscon"; + reg = <0x19020000 0x1000>; + #clock-cells = <1>; + }; + + - | + apu_vcore: apu_vcore@19029000 { + compatible = "mediatek,mt8192-apu-vcore", "syscon"; + reg = <0x19029000 0x1000>; + #clock-cells = <1>; + };
Signature · 1 line
2.18.0
PATCH v4 4/8 dt-bindings: soc: mediatek: apusys: Add new document for APU power domain
In reply to Flora FuDocument the bindings for APU power domain on MediaTek SoC.
--- .../soc/mediatek/mediatek,apu-pm.yaml | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,apu-pm.yaml
Documentation/devicetree/bindings/soc/mediatek/mediatek,apu-pm.yaml new file +144 -0
@@ -0,0 +1,144 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2021 (C) MediaTek Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/mediatek/mediatek,apu-pm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek APU Power Domains + +maintainers: + - Flora Fu <[email protected]> + +description: | + MediaTek AI Process Unit (APU) include support for power domains which can be + powered up/down by software. + APU subsys belonging to a power domain should contain a 'power-domains' + property that is a phandle for apuspm node representing the domain. + +properties: + compatible: + items: + - enum: + - mediatek,mt8192-apu-pm + - const: syscon + + reg: + description: Address range of the APU power domain controller. + maxItems: 1 + + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + '#power-domain-cells': + const: 1 + + vsram-supply: + description: apu sram regulator supply. + + mediatek,scpsys: + $ref: /schemas/types.yaml#/definitions/phandle + description: | + phandle to the device containing the scpsys register range. + + mediatek,apu-conn: + $ref: /schemas/types.yaml#/definitions/phandle + description: | + phandle to the device containing the scpsys apu conn register range. + + mediatek,apu-conn1: + $ref: /schemas/types.yaml#/definitions/phandle + description: | + phandle to the device containing the scpsys apu conn1 register range. + + mediatek,apu-vcore: + $ref: /schemas/types.yaml#/definitions/phandle + description: | + phandle to the device containing the scpsys apu vcore register range. + +patternProperties: + "^power-domain@[0-9a-f]+$": + type: object + description: | + Represents the power domains within the power controller node as + documented in Documentation/devicetree/bindings/power/power-domain.yaml. + + properties: + reg: + description: Power domain index. + maxItems: 1 + + '#power-domain-cells': + description: | + Must be 0 for nodes representing a single PM domain and 1 for nodes + providing multiple PM. + + clocks: + description: | + List of phandles of clocks list. Specify by order according to + power-up sequence. + + clock-names: + description: | + List of names of clocks. Specify by order according to power-up + sequence. + + assigned-clocks: + maxItems: 2 + + assigned-clock-parents: + maxItems: 2 + + domain-supply: + description: domain regulator supply. + + required: + - reg + - '#power-domain-cells' + + additionalProperties: false + +required: + - compatible + - reg + - '#power-domain-cells' + - vsram-supply + - mediatek,scpsys + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/mt8192-clk.h> + apuspm: power-domain@190f0000 { + compatible = "mediatek,mt8192-apu-pm", "syscon"; + reg = <0x190f0000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + #power-domain-cells = <1>; + vsram-supply = <&mt6359_vsram_md_ldo_reg>; + mediatek,scpsys = <&scpsys>; + mediatek,apu-conn = <&apu_conn>; + mediatek,apu-vcore = <&apu_vcore>; + + apu_top: power-domain@0 { + reg = <0>; + #power-domain-cells = <0>; + clocks = <&topckgen CLK_TOP_DSP_SEL>, + <&topckgen CLK_TOP_IPU_IF_SEL>, + <&clk26m>, + <&topckgen CLK_TOP_UNIVPLL_D6_D2>; + clock-names = "clk_top_conn", + "clk_top_ipu_if", + "clk_off", + "clk_on_default"; + assigned-clocks = <&topckgen CLK_TOP_DSP_SEL>, + <&topckgen CLK_TOP_IPU_IF_SEL>; + assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D6_D2>, + <&topckgen CLK_TOP_UNIVPLL_D6_D2>; + domain-supply = <&mt6359_vproc1_buck_reg>; + }; + };
Signature · 1 line
2.18.0
PATCH v4 5/8 soc: mediatek: apu: Add apusys and add apu power domain driver
In reply to Flora FuAdd the apusys in soc.
Add driver for apu power domains.
APU power domain shall be enabled before accessing the internal sub modules.
--- drivers/soc/mediatek/Kconfig | 12 + drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/apusys/Kconfig | 14 + drivers/soc/mediatek/apusys/Makefile | 2 + drivers/soc/mediatek/apusys/mtk-apu-pm.c | 727 +++++++++++++++++++++++ 5 files changed, 756 insertions(+) create mode 100644 drivers/soc/mediatek/apusys/Kconfig create mode 100644 drivers/soc/mediatek/apusys/Makefile create mode 100644 drivers/soc/mediatek/apusys/mtk-apu-pm.c
drivers/soc/mediatek/Kconfig +12 -0
@@ -5,6 +5,18 @@ menu "MediaTek SoC drivers" depends on ARCH_MEDIATEK || COMPILE_TEST +config MTK_APUSYS + bool "MediaTek APUSYS Support" + select REGMAP + help + Say yes here to add support for the MediaTek AI Processing Unit + Subsystem (APUSYS). + The APUSYS is a proprietary hardware in SoC to support AI + operations. The drivers can be enabled individually within this menu. + If unsure, say N. + +source "drivers/soc/mediatek/apusys/Kconfig" + config MTK_CMDQ tristate "MediaTek CMDQ Support" depends on ARCH_MEDIATEK || COMPILE_TEST
drivers/soc/mediatek/Makefile +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_MTK_APUSYS) += apusys/ obj-$(CONFIG_MTK_CMDQ) += mtk-cmdq-helper.o obj-$(CONFIG_MTK_DEVAPC) += mtk-devapc.o obj-$(CONFIG_MTK_INFRACFG) += mtk-infracfg.o
drivers/soc/mediatek/apusys/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +if MTK_APUSYS + +config MTK_APU_PM + tristate "MediaTek APU power management support" + select REGMAP + select PM_GENERIC_DOMAINS if PM + help + Say yes here to add support for power management control + to MediaTek AI Processing Unit Subsystem (APUSYS). + APU power domain shall be enabled before accessing the + internal sub modules. + +endif # MTK_APUSYS
drivers/soc/mediatek/apusys/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_MTK_APU_PM) += mtk-apu-pm.o
drivers/soc/mediatek/apusys/mtk-apu-pm.c new file +727 -0
727 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v4 6/8 arm64: dts: mt8192: Add APU node
In reply to Flora FuAdd APU node to MT8192.
--- arch/arm64/boot/dts/mediatek/mt8192.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/mediatek/mt8192.dtsi +12 -0
@@ -906,6 +906,18 @@ #clock-cells = <1>; }; + apu_conn: apu_conn@19020000 { + compatible = "mediatek,mt8192-apu-conn", "syscon"; + reg = <0 0x19020000 0 0x1000>; + #clock-cells = <1>; + }; + + apu_vcore: apu_vcore@19029000 { + compatible = "mediatek,mt8192-apu-vcore", "syscon"; + reg = <0 0x19029000 0 0x1000>; + #clock-cells = <1>; + }; + camsys: clock-controller@1a000000 { compatible = "mediatek,mt8192-camsys"; reg = <0 0x1a000000 0 0x1000>;
Signature · 1 line
2.18.0
PATCH v4 7/8 arm64: dts: mt8192: Add APU power domain node
In reply to Flora FuAdd APU power domain node to MT8192.
---
Note:
This patch depends on mt8192/mt6359 dts patches which haven't yet been accepted. This series is based on MT8192 power domain[1], PWRAP[2] and PMIC MT6359[3] patches.
[1] https://patchwork.kernel.org/patch/12456165
[2] https://patchwork.kernel.org/patch/12134935
[3] https://patchwork.kernel.org/patch/12140237
--- arch/arm64/boot/dts/mediatek/mt8192.dtsi | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
arch/arm64/boot/dts/mediatek/mt8192.dtsi +27 -0
@@ -918,6 +918,33 @@ #clock-cells = <1>; }; + apuspm: power-domain@190f0000 { + compatible = "mediatek,mt8192-apu-pm", "syscon"; + reg = <0 0x190f0000 0 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + #power-domain-cells = <1>; + mediatek,scpsys = <&scpsys>; + mediatek,apu-conn = <&apu_conn>; + mediatek,apu-vcore = <&apu_vcore>; + apu_top: power-domain@0 { + reg = <0>; + #power-domain-cells = <0>; + clocks = <&topckgen CLK_TOP_DSP_SEL>, + <&topckgen CLK_TOP_IPU_IF_SEL>, + <&clk26m>, + <&topckgen CLK_TOP_UNIVPLL_D6_D2>; + clock-names = "clk_top_conn", + "clk_top_ipu_if", + "clk_off", + "clk_on_default"; + assigned-clocks = <&topckgen CLK_TOP_DSP_SEL>, + <&topckgen CLK_TOP_IPU_IF_SEL>; + assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D6_D2>, + <&topckgen CLK_TOP_UNIVPLL_D6_D2>; + }; + }; + camsys: clock-controller@1a000000 { compatible = "mediatek,mt8192-camsys"; reg = <0 0x1a000000 0 0x1000>;
Signature · 1 line
2.18.0
PATCH v4 8/8 arm64: dts: mt8192: Set up apu power domain regulators
In reply to Flora FuSet up apu power domain related regulators.
---
Note:
This patch depends on mt6359[3] dts patches which haven't yet been accepted.
[1] https://patchwork.kernel.org/patch/12140237
--- arch/arm64/boot/dts/mediatek/mt8192-evb.dts | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/mediatek/mt8192-evb.dts +7 -0
@@ -28,3 +28,10 @@ &uart0 { status = "okay"; }; + +&apuspm { + vsram-supply = <&mt6359_vsram_md_ldo_reg>; + apu_top: power-domain@0 { + domain-supply = <&mt6359_vproc1_buck_reg>; + }; +};
Signature · 1 line
2.18.0