Mediatek SCPSYS power domain support
Subsystems (3)
PATCH v2 1/1 Mediatek SCPSYS power domain support
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 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
- Enable all power domains when PM is disabled to allow consumers to work
PATCH 1/4 dt-bindings: soc: Add documentation for the MediaTek SCPSYS unit
This adds documentation for the MediaTek SCPSYS unit found in MT8173 SoCs.
--- .../devicetree/bindings/soc/mediatek/scpsys.txt | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
Documentation/devicetree/bindings/soc/mediatek/scpsys.txt new file +32 -0
@@ -0,0 +1,32 @@ +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 + +Example: + + scpsys: scpsys at 10006000 { + #power-domain-cells = <1>; + compatible = "mediatek,mt8173-scpsys"; + reg = <0 0x10006000 0 0x1000>; + }; + +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
PATCH 2/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 | 6 + drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/mtk-scpsys.c | 345 +++++++++++++++++++++++++++++++ include/dt-bindings/power/mt8173-power.h | 15 ++ 4 files changed, 367 insertions(+) create mode 100644 drivers/soc/mediatek/mtk-scpsys.c create mode 100644 include/dt-bindings/power/mt8173-power.h
drivers/soc/mediatek/Kconfig +6 -0
@@ -9,3 +9,9 @@ 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 + tristate "MediaTek SCPSYS Support" + help + Say yes here to add support for the MediaTek SCPSYS power domain + driver.
drivers/soc/mediatek/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o +obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
drivers/soc/mediatek/mtk-scpsys.c new file +345 -0
345 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_VDE 0 +#define MT8173_POWER_DOMAIN_MFG 1 +#define MT8173_POWER_DOMAIN_VEN 2 +#define MT8173_POWER_DOMAIN_ISP 3 +#define MT8173_POWER_DOMAIN_DIS 4 +#define MT8173_POWER_DOMAIN_VEN2 5 +#define MT8173_POWER_DOMAIN_AUDIO 6 +#define MT8173_POWER_DOMAIN_MFG_2D 7 +#define MT8173_POWER_DOMAIN_MFG_ASYNC 8 +#define MT8173_POWER_DOMAIN_USB 9 + +#endif /* _DT_BINDINGS_POWER_MT8183_POWER_H */
Signature · 1 line
2.1.4
Re: [PATCH 2/4] soc: Mediatek: Add SCPSYS power domain driver
Quoted 28 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.
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]>--- drivers/soc/mediatek/Kconfig | 6 + drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/mtk-scpsys.c | 345 +++++++++++++++++++++++++++++++ include/dt-bindings/power/mt8173-power.h | 15 ++ 4 files changed, 367 insertions(+) create mode 100644 drivers/soc/mediatek/mtk-scpsys.c create mode 100644 include/dt-bindings/power/mt8173-power.hdrivers/soc/mediatek/Kconfig +0
-0
drivers/soc/mediatek/Kconfig config MTK_PMIC_WRAP · line 14
Quoted 6 lines
drivers/soc/mediatek/Kconfig +3
-0@@ -9,3 +9,9 @@ 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 + tristate "MediaTek SCPSYS Support"
depends on ARCH_MEDIATEK ?
Quoted 3 lines
drivers/soc/mediatek/Kconfig +3
-0+ help + Say yes here to add support for the MediaTek SCPSYS power domain + driver.
[...]
Quoted 26 lines
drivers/soc/mediatek/Kconfig +26
-0+static int scpsys_probe(struct platform_device *pdev) +{ + struct genpd_onecell_data *pd_data; + struct resource *res; + int i; + struct scp *scp; + + scp = devm_kzalloc(&pdev->dev, sizeof(*scp), GFP_KERNEL); + if (!scp) + return -ENOMEM; + + scp->dev = &pdev->dev; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + scp->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(scp->base)) + return PTR_ERR(scp->base); + + pd_data = &scp->pd_data; + + pd_data->domains = scp->pmd; + pd_data->num_domains = NUM_DOMAINS; + + for (i = 0; i < NUM_DOMAINS; i++) { + struct scp_domain *scpd = &scp->domains[i]; + struct generic_pm_domain *pmd = &scpd->pmd;
drivers/soc/mediatek/Kconfig
Quoted 10 lines
drivers/soc/mediatek/Kconfig +10
-0+ + scp->pmd[i] = pmd; + scpd->data = &scp_domain_data[i]; + scpd->scp = scp; + + pmd->name = scp_domain_data[i].name; + pmd->power_off = scpsys_power_off; + pmd->power_on = scpsys_power_on; + pmd->power_off_latency_ns = 20000; + pmd->power_on_latency_ns = 20000;
I think I mentioned this before... are these numbers really identical for all domains? I suggest you make these each a field in the domain data so they can be different for each domain, and eventually come from DT data.
drivers/soc/mediatek/Kconfig
Quoted 13 lines
drivers/soc/mediatek/Kconfig +13
-0+ pd_data->domains[i] = pmd; + pm_genpd_init(pmd, NULL, 1); + + /* + * If PM is disabled turn on all domains by default so that + * consumers can work. + */ + if (!IS_ENABLED(CONFIG_PM)) + pmd->power_on(pmd); + } + + return of_genpd_add_provider_onecell(pdev->dev.of_node, pd_data); +}
Kevin
Re: [PATCH 2/4] soc: Mediatek: Add SCPSYS power domain driver
Quoted 25 lines · Kevin Hilman
Quoted 23 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.
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]>--- drivers/soc/mediatek/Kconfig | 6 + drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/mtk-scpsys.c | 345 +++++++++++++++++++++++++++++++ include/dt-bindings/power/mt8173-power.h | 15 ++ 4 files changed, 367 insertions(+) create mode 100644 drivers/soc/mediatek/mtk-scpsys.c create mode 100644 include/dt-bindings/power/mt8173-power.h
Quoted 13 lines
drivers/soc/mediatek/Kconfig config MTK_PMIC_WRAP · line 14
Quoted 11 lines
drivers/soc/mediatek/Kconfig +3
-0@@ -9,3 +9,9 @@ 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 + tristate "MediaTek SCPSYS Support"depends on
ARCH_MEDIATEK?
You are reviewing v2 of this series. This is already fixed in v3 sent out last wednesday.
Quoted 10 lines
Quoted 10 lines
drivers/soc/mediatek/Kconfig +10
-0+ for (i = 0; i < NUM_DOMAINS; i++) { + struct scp_domain *scpd = &scp->domains[i]; + struct generic_pm_domain *pmd = &scpd->pmd; + + scp->pmd[i] = pmd; + scpd->data = &scp_domain_data[i]; + scpd->scp = scp; + + pmd->name = scp_domain_data[i].name; + pmd->power_off = scpsys_power_off;
Quoted 8 lines
drivers/soc/mediatek/Kconfig
Quoted 3 lines
drivers/soc/mediatek/Kconfig +3
-0+ pmd->power_on = scpsys_power_on; + pmd->power_off_latency_ns = 20000; + pmd->power_on_latency_ns = 20000;I think I mentioned this before... are these numbers really identical for all domains? I suggest you make these each a field in the domain data so they can be different for each domain, and eventually come from DT data.
For the record, here are the numbers I just measured:
mtk-scpsys 10006000.scpsys: vdec on: 31000 off: 10769 mtk-scpsys 10006000.scpsys: venc on: 6000 off: 5923 mtk-scpsys 10006000.scpsys: isp on: 5923 off: 5923 mtk-scpsys 10006000.scpsys: mm on: 7616 off: 7692 mtk-scpsys 10006000.scpsys: venc_lt on: 5924 off: 6000 mtk-scpsys 10006000.scpsys: audio on: 5462 off: 5615 mtk-scpsys 10006000.scpsys: usb on: 5461 off: 5462 mtk-scpsys 10006000.scpsys: mfg_async on: 29923 off: 11077 mtk-scpsys 10006000.scpsys: mfg_2d on: 5923 off: 5616 mtk-scpsys 10006000.scpsys: mfg on: 11231 off: 16153
Anyway, the pm domain core measures these times itself, so there should not be a need to fill in anything here. I was irritated by the warning message I got each time when the times were exceeded. This message seemed to imply that something was wrong and I had to fill in sane values in the latency fields. Since we now have [1] I'll just drop the initialisation of these fields.
Sascha
[1]
commit 6d7d5c3266aa946b2049d9fed02186c1a378621b
Author: Russell King <[email protected]> Date: Fri Mar 20 17:20:28 2015 +0000
PM / domains: quieten down generic pm domains
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH 2/4] soc: Mediatek: Add SCPSYS power domain driver
Quoted 40 lines · Sascha Hauer
Quoted 25 lines · Kevin Hilman
Quoted 23 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.
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]>--- drivers/soc/mediatek/Kconfig | 6 + drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/mtk-scpsys.c | 345 +++++++++++++++++++++++++++++++ include/dt-bindings/power/mt8173-power.h | 15 ++ 4 files changed, 367 insertions(+) create mode 100644 drivers/soc/mediatek/mtk-scpsys.c create mode 100644 include/dt-bindings/power/mt8173-power.hQuoted 13 lines
drivers/soc/mediatek/Kconfig config MTK_PMIC_WRAP · line 14
Quoted 11 lines
drivers/soc/mediatek/Kconfig +3
-0@@ -9,3 +9,9 @@ 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 + tristate "MediaTek SCPSYS Support"depends on
ARCH_MEDIATEK?
Quoted 2 lines
You are reviewing v2 of this series. This is already fixed in v3 sent out last wednesday.
Yeah, sorry about that. I noticed that after sending.
Quoted 32 lines
Quoted 10 lines
Quoted 10 lines
drivers/soc/mediatek/Kconfig +10
-0+ for (i = 0; i < NUM_DOMAINS; i++) { + struct scp_domain *scpd = &scp->domains[i]; + struct generic_pm_domain *pmd = &scpd->pmd; + + scp->pmd[i] = pmd; + scpd->data = &scp_domain_data[i]; + scpd->scp = scp; + + pmd->name = scp_domain_data[i].name; + pmd->power_off = scpsys_power_off;Quoted 8 lines
drivers/soc/mediatek/Kconfig
Quoted 3 lines
drivers/soc/mediatek/Kconfig +3
-0+ pmd->power_on = scpsys_power_on; + pmd->power_off_latency_ns = 20000; + pmd->power_on_latency_ns = 20000;I think I mentioned this before... are these numbers really identical for all domains? I suggest you make these each a field in the domain data so they can be different for each domain, and eventually come from DT data.
For the record, here are the numbers I just measured:
mtk-scpsys 10006000.scpsys: vdec on: 31000 off: 10769 mtk-scpsys 10006000.scpsys: venc on: 6000 off: 5923 mtk-scpsys 10006000.scpsys: isp on: 5923 off: 5923 mtk-scpsys 10006000.scpsys: mm on: 7616 off: 7692 mtk-scpsys 10006000.scpsys: venc_lt on: 5924 off: 6000 mtk-scpsys 10006000.scpsys: audio on: 5462 off: 5615 mtk-scpsys 10006000.scpsys: usb on: 5461 off: 5462 mtk-scpsys 10006000.scpsys: mfg_async on: 29923 off: 11077 mtk-scpsys 10006000.scpsys: mfg_2d on: 5923 off: 5616 mtk-scpsys 10006000.scpsys: mfg on: 11231 off: 16153
Quoted 6 lines
Anyway, the pm domain core measures these times itself, so there should not be a need to fill in anything here. I was irritated by the warning message I got each time when the times were exceeded. This message seemed to imply that something was wrong and I had to fill in sane values in the latency fields. Since we now have [1] I'll just drop the initialisation of these fields.
OK.
However, I suspect you will still want these numbers on a per-domain basis eventually when you consider having genpd governors that want to make decisions. But that can always be added later also.
Kevin
PATCH 3/4 ARM64: MediaTek: Add generic pm domain support
In reply to Sascha HauerEnable support for generic power domains in the config.
--- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/Kconfig +1 -0
@@ -185,6 +185,7 @@ config ARCH_MEDIATEK bool "Mediatek MT65xx & MT81xx ARMv8 SoC" select ARM_GIC select PINCTRL + select PM_GENERIC_DOMAINS if PM help Support for Mediatek MT65xx & MT81xx ARMv8 SoCs
Signature · 1 line
2.1.4
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 | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +12 -0
@@ -125,6 +125,18 @@ <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 = <&topckgen CLK_TOP_VDEC_SEL>, + <&topckgen CLK_TOP_MFG_SEL>, + <&topckgen CLK_TOP_VENC_SEL>, + <&topckgen CLK_TOP_MM_SEL>, + <&topckgen CLK_TOP_VENC_LT_SEL>; + clock-names = "vdec", "mfg", "venc", "disp", "ven2"; + }; + 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 15 lines · Sascha Hauer
This adds the SCPSYS device node to the MT8173 dtsi file.
Signed-off-by Sascha Hauer <[email protected]>--- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)arch/arm64/boot/dts/mediatek/mt8173.dtsi +0
-0@@ -125,6 +125,18 @@ <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>; };
arch/arm64/boot/dts/mediatek/mt8173.dtsi line 137
Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8173.dtsi +10
-0+ scpsys: scpsys at 10006000 { + compatible = "mediatek,mt8173-scpsys"; + #power-domain-cells = <1>; + reg = <0 0x10006000 0 0x1000>; + clocks = <&topckgen CLK_TOP_VDEC_SEL>, + <&topckgen CLK_TOP_MFG_SEL>, + <&topckgen CLK_TOP_VENC_SEL>, + <&topckgen CLK_TOP_MM_SEL>, + <&topckgen CLK_TOP_VENC_LT_SEL>; + clock-names = "vdec", "mfg", "venc", "disp", "ven2";
(1) I think people like to align multi-line dts field values, so there should be one more ' ' before each <&topckgen ...>.
(2) it is a bit awkward that these names do not match their clock names. This seems more straightforward:
clock-names = "vdec", "mfg", "venc", "mm", "venc_lt";
(3) the scpsys binding patch does not list the clock fields.
(4) I don't think a patch with these CLK_TOP_* has been sent to the list for review yet.
Thanks,
-Dan
Quoted 13 lines
arch/arm64/boot/dts/mediatek/mt8173.dtsi +2
-1+ }; + sysirq: intpol-controller at 10200620 { compatible = "mediatek,mt8173-sysirq", "mediatek,mt6577-sysirq"; --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/
Matthias Brugger_0
maintainerQuoted 18 lines · Sascha Hauer
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
Quoted 7 lines
changes 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 v2
I can't find this changes. It looks like you send the wrong patches. Please resend.
Cheers,
Matthias
Quoted 27 lines · On Mon, May 11, 2015 at 06:05:20PM +0200, Matthias Brugger_0 wrote:
Quoted 18 lines · Sascha Hauer
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
Quoted 7 lines
changes 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 v2
Quoted 2 lines
I can't find this changes. It looks like you send the wrong patches. Please resend.
Damn, I just proved that changelogs are useful ;)
I have just resent this series.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |