Mediatek SCPSYS power domain support
Subsystems (2)
PATCH v6 1/1 Mediatek SCPSYS power domain support
Just a small update to this series with a memory corruption bug fixed.
This series adds support for the MediaTek SCPSYS unit.
The SCPSYS unit handles several power management related tasks such as thermal measurement, DVFS, interrupt filter and low level sleep control.
The initial support only contains the generic power domain handling. This is needed to turn on power to the different power domains.
The driver is quite straight forward now. Due to the lack of a better place I have put it to drivers/soc/mediatek. As the SCPSYS unit has several other tasks that also do not fit into some specific subsystem this probably is a good place for this driver.
Please review, any input welcome.
Sascha
changes since v5:
- Fix array out of bounds access
- Fix typo
Changes since v4:
- move Kconfig dependency "select PM_GENERIC_DOMAINS if PM" from arch/arm64 next to the driver which needs this dependency
- drop unnecessary clk[] array from struct scp and make the array local to the function which needs it.
- Disable clock when enabling the domain fails
- Drop error message when devm_clk_get fails. The core already issues a similar warning
- Add clocks/clock-names description to the binding doc
Changes since v3:
- Drop unnecessary MODULE_* macros for builtin code
- introduce scpsys_domain_is_on() function instead of open coding this twice
- Drop unnecessary initialisation of power_o[ff|n]_latencies. The kernel updates them with the measured values anyway.
changes since v2:
- Add missing include/linux/soc/mediatek/infracfg.h file
- rename VDE -> VDEC, VEN -> VENC, DIS -> DISP and VEN2 -> VENC_LT to make the abbreviatons more clear
- make of_device_id const
- remove double loop
- fix hunk in wrong patch
- Fix order of domains. Some domains depend on other domains. Reorder the domains so that all domains can be turned on in order when CONFIG_PM is disabled. Also fixes earlier mixups in the domain array
- Do not allow compilation as modules. pm_domains cannot be removed, so compilation as module is not that useful
- reorder Kconfig items alphabetically
- reorder #includes alphabetically
- select MTK_INFRACFG instead of depending on it
- Use only two clocks as dependencies for the domains. The previously used 5 clocks are not necessary as confirmed by the hardware designers
- use 'genpd' as variable name for struct generic_pm_domain like done in other pm code
changes since v1:
- make MFG_ASYNC a subdomain of MFG_2D and MFG_2D a subdomain of MFG
- Add (now hopefully properly) infracfg register handling again
- Add clock handling
- Fix on/off mixup in error message
- Make readonly data const
- Fix MODULE_LICENSE to GPL v2
changes since RFC:
- add a commit log to driver patch
- drop manipulating infracfg registers for now, can be added (properly) later
- Add warning messages when errors occur
- add NULL pointer check for kmalloc
PATCH 1/4 soc: mediatek: Add infracfg misc driver support
This adds support for some miscellaneous bits of the infracfg controller. The mtk_infracfg_set/clear_bus_protection functions are necessary for the scpsys power domain driver to handle the bus protection bits which are contained in the infacfg register space.
--- drivers/soc/mediatek/Kconfig | 9 ++++ drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/mtk-infracfg.c | 91 +++++++++++++++++++++++++++++++++++ include/linux/soc/mediatek/infracfg.h | 26 ++++++++++ 4 files changed, 127 insertions(+) create mode 100644 drivers/soc/mediatek/mtk-infracfg.c create mode 100644 include/linux/soc/mediatek/infracfg.h
drivers/soc/mediatek/Kconfig +9 -0
@@ -1,6 +1,15 @@ # # MediaTek SoC drivers # +config MTK_INFRACFG + bool "MediaTek INFRACFG Support" + depends on ARCH_MEDIATEK + select REGMAP + help + Say yes here to add support for the MediaTek INFRACFG controller. The + INFRACFG controller contains various infrastructure registers not + directly associated to any device. + config MTK_PMIC_WRAP tristate "MediaTek PMIC Wrapper Support" depends on ARCH_MEDIATEK
drivers/soc/mediatek/Makefile +1 -0
@@ -1 +1,2 @@ +obj-$(CONFIG_MTK_INFRACFG) += mtk-infracfg.o obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o
drivers/soc/mediatek/mtk-infracfg.c new file +91 -0
91 lines not on this page · raw message
include/linux/soc/mediatek/infracfg.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef __SOC_MEDIATEK_INFRACFG_H +#define __SOC_MEDIATEK_INFRACFG_H + +#define MT8173_TOP_AXI_PROT_EN_MCI_M2 BIT(0) +#define MT8173_TOP_AXI_PROT_EN_MM_M0 BIT(1) +#define MT8173_TOP_AXI_PROT_EN_MM_M1 BIT(2) +#define MT8173_TOP_AXI_PROT_EN_MMAPB_S BIT(6) +#define MT8173_TOP_AXI_PROT_EN_L2C_M2 BIT(9) +#define MT8173_TOP_AXI_PROT_EN_L2SS_SMI BIT(11) +#define MT8173_TOP_AXI_PROT_EN_L2SS_ADD BIT(12) +#define MT8173_TOP_AXI_PROT_EN_CCI_M2 BIT(13) +#define MT8173_TOP_AXI_PROT_EN_MFG_S BIT(14) +#define MT8173_TOP_AXI_PROT_EN_PERI_M0 BIT(15) +#define MT8173_TOP_AXI_PROT_EN_PERI_M1 BIT(16) +#define MT8173_TOP_AXI_PROT_EN_DEBUGSYS BIT(17) +#define MT8173_TOP_AXI_PROT_EN_CQ_DMA BIT(18) +#define MT8173_TOP_AXI_PROT_EN_GCPU BIT(19) +#define MT8173_TOP_AXI_PROT_EN_IOMMU BIT(20) +#define MT8173_TOP_AXI_PROT_EN_MFG_M0 BIT(21) +#define MT8173_TOP_AXI_PROT_EN_MFG_M1 BIT(22) +#define MT8173_TOP_AXI_PROT_EN_MFG_SNOOP_OUT BIT(23) + +int mtk_infracfg_set_bus_protection (struct regmap *infracfg,u32 mask); +int mtk_infracfg_clear_bus_protection (struct regmap *infracfg,u32 mask); + +#endif /* __SOC_MEDIATEK_INFRACFG_H */
Signature · 1 line
2.1.4
Re: [PATCH 1/4] soc: mediatek: Add infracfg misc driver support
Quoted 7 lines · Sascha Hauer
This adds support for some miscellaneous bits of the infracfg controller. The mtk_infracfg_set/clear_bus_protection functions are necessary for the scpsys power domain driver to handle the bus protection bits which are contained in the infacfg register space.
Signed-off-by Sascha Hauer <[email protected]>---
Applied to v4.2-next/soc
PATCH 2/4 dt-bindings: soc: Add documentation for the MediaTek SCPSYS unit
In reply to Sascha HauerThis adds documentation for the MediaTek SCPSYS unit found in MT8173 SoCs.
--- .../devicetree/bindings/soc/mediatek/scpsys.txt | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
Documentation/devicetree/bindings/soc/mediatek/scpsys.txt new file +41 -0
@@ -0,0 +1,41 @@ +MediaTek SCPSYS +=============== + +The System Control Processor System (SCPSYS) has several power management +related tasks in the system. The tasks include thermal measurement, dynamic +voltage frequency scaling (DVFS), interrupt filter and lowlevel sleep control. +The System Power Manager (SPM) inside the SCPSYS is for the MTCMOS power +domain control. + +The driver implements the Generic PM domain bindings described in +power/power_domain.txt. It provides the power domains defined in +include/dt-bindings/power/mt8173-power.h. + +Required properties: +- compatible: Must be "mediatek,mt8173-scpsys" +- #power-domain-cells: Must be 1 +- reg: Address range of the SCPSYS unit +- infracfg: must contain a phandle to the infracfg controller +- clock, clock-names: clocks according to the common clock binding. + The clocks needed "mm" and "mfg". These are the + clocks which hardware needs to be enabled before + enabling certain power domains. + +Example: + + scpsys: scpsys at 10006000 { + #power-domain-cells = <1>; + compatible = "mediatek,mt8173-scpsys"; + reg = <0 0x10006000 0 0x1000>; + infracfg = <&infracfg>; + clocks = <&clk26m>, + <&topckgen CLK_TOP_MM_SEL>; + clock-names = "mfg", "mm"; + }; + +Example consumer: + + afe: mt8173-afe-pcm at 11220000 { + compatible = "mediatek,mt8173-afe-pcm"; + power-domains = <&scpsys MT8173_POWER_DOMAIN_AUDIO>; + };
Signature · 1 line
2.1.4
Re: [PATCH 2/4] dt-bindings: soc: Add documentation for the MediaTek SCPSYS unit
Quoted 4 lines · Sascha Hauer
This adds documentation for the MediaTek SCPSYS unit found in MT8173 SoCs.
Signed-off-by Sascha Hauer <[email protected]>---
Applied to v4.2-next/soc
Re: [PATCH 2/4] dt-bindings: soc: Add documentation for the MediaTek SCPSYS unit
In reply to Sascha HauerQuoted 30 lines · Sascha Hauer
This adds documentation for the MediaTek SCPSYS unit found in MT8173 SoCs.
Signed-off-by Sascha Hauer <[email protected]>--- .../devicetree/bindings/soc/mediatek/scpsys.txt | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/mediatek/scpsys.txtDocumentation/devicetree/bindings/soc/mediatek/scpsys.txt new file +16
-0@@ -0,0 +1,41 @@ +MediaTek SCPSYS +=============== + +The System Control Processor System (SCPSYS) has several power management +related tasks in the system. The tasks include thermal measurement, dynamic +voltage frequency scaling (DVFS), interrupt filter and lowlevel sleep control. +The System Power Manager (SPM) inside the SCPSYS is for the MTCMOS power +domain control. + +The driver implements the Generic PM domain bindings described in +power/power_domain.txt. It provides the power domains defined in +include/dt-bindings/power/mt8173-power.h. + +Required properties: +- compatible: Must be "mediatek,mt8173-scpsys" +- #power-domain-cells: Must be 1
Documentation/devicetree/bindings/soc/mediatek/scpsys.txt line 26
Quoted 10 lines
Documentation/devicetree/bindings/soc/mediatek/scpsys.txt new file +10
-0+- reg: Address range of the SCPSYS unit +- infracfg: must contain a phandle to the infracfg controller +- clock, clock-names: clocks according to the common clock binding. + The clocks needed "mm" and "mfg". These are the + clocks which hardware needs to be enabled before + enabling certain power domains. + +Example: + + scpsys: scpsys at 10006000 {
Perhaps it is too late, and/or too pedantic, but, since this node defines a PM domain provider as defined in [0], shouldn't its node have been the more generic:
scpsys: power-controller at 10006000
[0] /Documentation/devicetree/bindings/power/power_domain.txt
Quoted 23 lines
Documentation/devicetree/bindings/soc/mediatek/scpsys.txt new file +15
-1+ #power-domain-cells = <1>; + compatible = "mediatek,mt8173-scpsys"; + reg = <0 0x10006000 0 0x1000>; + infracfg = <&infracfg>; + clocks = <&clk26m>, + <&topckgen CLK_TOP_MM_SEL>; + clock-names = "mfg", "mm"; + }; + +Example consumer: + + afe: mt8173-afe-pcm at 11220000 { + compatible = "mediatek,mt8173-afe-pcm"; + power-domains = <&scpsys MT8173_POWER_DOMAIN_AUDIO>; + }; --2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
PATCH 3/4 soc: Mediatek: Add SCPSYS power domain driver
In reply to Sascha HauerThis adds a power domain driver for the Mediatek SCPSYS unit.
The System Control Processor System (SCPSYS) has several power management related tasks in the system. The tasks include thermal measurement, dynamic voltage frequency scaling (DVFS), interrupt filter and lowlevel sleep control. The System Power Manager (SPM) inside the SCPSYS is for the MTCMOS power domain control.
For now this driver only adds power domain support, the more advanced features are not yet supported. The driver implements the generic PM domain device tree bindings, the first user will most likely be the Mediatek AFE audio driver.
--- drivers/soc/mediatek/Kconfig | 10 + drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/mtk-scpsys.c | 487 +++++++++++++++++++++++++++++++ include/dt-bindings/power/mt8173-power.h | 15 + 4 files changed, 513 insertions(+) create mode 100644 drivers/soc/mediatek/mtk-scpsys.c create mode 100644 include/dt-bindings/power/mt8173-power.h
drivers/soc/mediatek/Kconfig +10 -0
@@ -18,3 +18,13 @@ config MTK_PMIC_WRAP Say yes here to add support for MediaTek PMIC Wrapper found on different MediaTek SoCs. The PMIC wrapper is a proprietary hardware to connect the PMIC. + +config MTK_SCPSYS + bool "MediaTek SCPSYS Support" + depends on ARCH_MEDIATEK || COMPILE_TEST + select REGMAP + select MTK_INFRACFG + select PM_GENERIC_DOMAINS if PM + help + Say yes here to add support for the MediaTek SCPSYS power domain + driver.
drivers/soc/mediatek/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_MTK_INFRACFG) += mtk-infracfg.o obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o +obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
drivers/soc/mediatek/mtk-scpsys.c new file +487 -0
487 lines not on this page · raw message
include/dt-bindings/power/mt8173-power.h new file +15 -0
@@ -0,0 +1,15 @@ +#ifndef _DT_BINDINGS_POWER_MT8183_POWER_H +#define _DT_BINDINGS_POWER_MT8183_POWER_H + +#define MT8173_POWER_DOMAIN_VDEC 0 +#define MT8173_POWER_DOMAIN_VENC 1 +#define MT8173_POWER_DOMAIN_ISP 2 +#define MT8173_POWER_DOMAIN_MM 3 +#define MT8173_POWER_DOMAIN_VENC_LT 4 +#define MT8173_POWER_DOMAIN_AUDIO 5 +#define MT8173_POWER_DOMAIN_USB 6 +#define MT8173_POWER_DOMAIN_MFG_ASYNC 7 +#define MT8173_POWER_DOMAIN_MFG_2D 8 +#define MT8173_POWER_DOMAIN_MFG 9 + +#endif /* _DT_BINDINGS_POWER_MT8183_POWER_H */
Signature · 1 line
2.1.4
Re: [PATCH 3/4] soc: Mediatek: Add SCPSYS power domain driver
Quoted 8 lines · Sascha Hauer
This adds a power domain driver for the Mediatek SCPSYS unit.
The System Control Processor System (SCPSYS) has several power management related tasks in the system. The tasks include thermal measurement, dynamic voltage frequency scaling (DVFS), interrupt filter and lowlevel sleep control. The System Power Manager (SPM) inside the SCPSYS is for the MTCMOS power domain control.
Quoted 7 lines
For now this driver only adds power domain support, the more advanced features are not yet supported. The driver implements the generic PM domain device tree bindings, the first user will most likely be the Mediatek AFE audio driver.
Signed-off-by Sascha Hauer <[email protected]>---
Applied to v4.2-next/soc
PATCH 4/4 ARM64: MediaTek MT8173: Add SCPSYS device node
In reply to Sascha HauerThis adds the SCPSYS device node to the MT8173 dtsi file.
--- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +10 -0
@@ -125,6 +125,16 @@ <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>; }; + scpsys: scpsys at 10006000 { + compatible = "mediatek,mt8173-scpsys"; + #power-domain-cells = <1>; + reg = <0 0x10006000 0 0x1000>; + clocks = <&clk26m>, + <&topckgen CLK_TOP_MM_SEL>; + clock-names = "mfg", "mm"; + infracfg = <&infracfg>; + }; + sysirq: intpol-controller at 10200620 { compatible = "mediatek,mt8173-sysirq", "mediatek,mt6577-sysirq";
Signature · 1 line
2.1.4
Re: [PATCH 4/4] ARM64: MediaTek MT8173: Add SCPSYS device node
Quoted 4 lines · Sascha Hauer
This adds the SCPSYS device node to the MT8173 dtsi file.
Signed-off-by Sascha Hauer <[email protected]>---
Applied to v4.2-next/arm64
Quoted 11 lines · Sascha Hauer
Just a small update to this series with a memory corruption bug fixed.
This series adds support for the MediaTek SCPSYS unit.
The SCPSYS unit handles several power management related tasks such as thermal measurement, DVFS, interrupt filter and low level sleep control.
The initial support only contains the generic power domain handling. This is needed to turn on power to the different power domains.
Quoted 6 lines
The driver is quite straight forward now. Due to the lack of a better place I have put it to
drivers/soc/mediatek. As the SCPSYS unit has several other tasks that also do not fit into some specific subsystem this probably is a good place for this driver.Please review, any input welcome.
For the series:
Quoted 65 lines
Sascha
changes since v5:
- Fix array out of bounds access
- Fix typoChanges since v4:
- moveKconfigdependency "selectPM_GENERIC_DOMAINSif PM" fromarch/arm64next to the driver which needs this dependency
- drop unnecessary clk[] array from struct scp and make the array local to the function which needs it.
- Disable clock when enabling the domain fails
- Drop error message whendevm_clk_getfails. The core already issues a similar warning
- Add clocks/clock-names description to the binding docChanges since v3:
- Drop unnecessary MODULE_* macros for builtin code
- introducescpsys_domain_is_on()function instead of open coding this twice
- Drop unnecessary initialisation of power_o[ff|n]_latencies. The kernel updates them with the measured values anyway.changes since v2:
- Add missinginclude/linux/soc/mediatek/infracfg.hfile
- rename VDE -> VDEC, VEN -> VENC, DIS -> DISP and VEN2 ->VENC_LTto make the abbreviatons more clear
- makeof_device_idconst
- remove double loop
- fix hunk in wrong patch
- Fix order of domains. Some domains depend on other domains. Reorder the domains so that all domains can be turned on in order whenCONFIG_PMis disabled. Also fixes earlier mixups in the domain array
- Do not allow compilation as modules.pm_domainscannot be removed, so compilation as module is not that useful
- reorderKconfigitems alphabetically
- reorder #includes alphabetically
- selectMTK_INFRACFGinstead of depending on it
- Use only two clocks as dependencies for the domains. The previously used 5 clocks are not necessary as confirmed by the hardware designers
- use 'genpd' as variable name for structgeneric_pm_domainlike done in other pm codechanges since v1:
- makeMFG_ASYNCa subdomain ofMFG_2DandMFG_2Da subdomain of MFG
- Add (now hopefully properly) infracfg register handling again
- Add clock handling
- Fix on/off mixup in error message
- Make readonly data const
- FixMODULE_LICENSEto GPL v2changes since RFC:
- add a commit log to driver patch
- drop manipulating infracfg registers for now, can be added (properly) later
- Add warning messages when errors occur
- add NULL pointer check for kmalloc--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/