Add driver for dvfsrc, support for active state of scpsys
Subsystems (3)
v3 cover Add driver for dvfsrc, support for active state of scpsys
The patchsets add support for MediaTek hardware module named DVFSRC (dynamic voltage and frequency scaling resource collector). The DVFSRC is a HW module which is used to collect all the requests from both software and hardware and turn into the decision of minimum operating voltage and minimum DRAM frequency to fulfill those requests.
So, This series is to implement the dvfsrc driver to collect all the requests of operating voltage or DRAM bandwidth from other device drivers likes GPU/Camera through 2 frameworks basically:
1. interconnect framework: to aggregate the bandwidth requirements from different clients
[1] https://patchwork.kernel.org/cover/10766329/
Below is the emi bandwidth map of mt8183. There has a hw module "DRAM scheduler" which used to control the throughput. The DVFSRC will collect forecast data of dram bandwidth from SW consumers(camera/gpu...), and according the forecast to change the DRAM frequency
ICC provider ICC Nodes
---- ----
--------- |CPU | |--->|VPU |
----- | |-----> ---- | ----
|DRAM |--|DRAM | ---- | ----
| |--|scheduler|----->|GPU | |--->|DISP|
| |--|(EMI) | ---- | ----
| |--| | ----- | ----
----- | |----->|MMSYS|--|--->|VDEC|
--------- ----- | ----
/|\ | ----
|change DRAM freq |--->|VENC|
---------- | ----
| DVFSR | |
| | | ----
---------- |--->|IMG |
| ----
| ----
|--->|CAM |
----2. Active state management of power domains[1]: to handle the operating voltage opp requirement from different power domains
[2] https://lwn.net/Articles/744047/
Changes in RFC V3:
* Remove RFC from the subject prefix of the series
* Combine dt-binding patch and move interconnect dt-binding document into dvfsrc. (Rob)
* Remove unused header, add unit descirption to the bandwidth, rename compatible name on interconnect driver. (Georgi)
* Fixed some coding style: check flow, naming, used readx_poll_timeout on dvfsrc driver. (Ryan)
* Rename interconnect driver mt8183.c to mtk-emi.c
* Rename interconnect header mtk,mt8183.h to mtk,emi.h
* mtk-scpsys.c: Add opp table check first to avoid OF runtime parse failed
Changes in RFC V2:
* Remove the DT property dram_type. (Rob)
* Used generic dts property 'opp-level' to get the performace state. (Stephen)
* Remove unecessary dependency config on Kconfig. (Stephen)
* Remove unused header file, fixed some coding style issue, typo, error handling on dvfsrc driver. (Nicolas/Stephen)
* Remove irq handler on dvfsrc driver. (Stephen)
* Remove init table on dvfsrc driver, combine hw init on trustzone.
* Add interconnect support of mt8183 to aggregate the emi bandwidth. (Georgi)
RFC V2: https://lore.kernel.org/patchwork/patch/1068113/
RFC V1: https://lore.kernel.org/patchwork/cover/1028535/
Henry Chen (10):
dt-bindings: soc: Add dvfsrc driver bindings
dt-bindings: soc: Add opp table on scpsys bindings
soc: mediatek: add support for the performance state
arm64: dts: mt8183: add performance state support of scpsys
soc: mediatek: add header for mediatek SIP interface
soc: mediatek: add MT8183 dvfsrc support
arm64: dts: mt8183: add dvfsrc related nodes
dt-bindings: interconnect: add MT8183 interconnect dt-bindings
interconnect: mediatek: Add mt8183 interconnect provider driver
arm64: dts: mt8183: Add interconnect provider DT nodes
.../devicetree/bindings/soc/mediatek/dvfsrc.txt | 32 ++ .../devicetree/bindings/soc/mediatek/scpsys.txt | 42 +++ arch/arm64/boot/dts/mediatek/mt8183.dtsi | 33 ++ drivers/interconnect/Kconfig | 1 + drivers/interconnect/Makefile | 1 + drivers/interconnect/mediatek/Kconfig | 13 + drivers/interconnect/mediatek/Makefile | 3 + drivers/interconnect/mediatek/mtk-emi.c | 246 ++++++++++++++ drivers/soc/mediatek/Kconfig | 15 + drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/mtk-dvfsrc.c | 374 +++++++++++++++++++++ drivers/soc/mediatek/mtk-scpsys.c | 58 ++++ drivers/soc/mediatek/mtk-scpsys.h | 22 ++ include/dt-bindings/interconnect/mtk,mt8183-emi.h | 18 + include/dt-bindings/soc/mtk,dvfsrc.h | 14 + include/soc/mediatek/mtk_dvfsrc.h | 22 ++ include/soc/mediatek/mtk_sip.h | 17 + 17 files changed, 912 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt create mode 100644 drivers/interconnect/mediatek/Kconfig create mode 100644 drivers/interconnect/mediatek/Makefile create mode 100644 drivers/interconnect/mediatek/mtk-emi.c create mode 100644 drivers/soc/mediatek/mtk-dvfsrc.c create mode 100644 drivers/soc/mediatek/mtk-scpsys.h create mode 100644 include/dt-bindings/interconnect/mtk,mt8183-emi.h create mode 100644 include/dt-bindings/soc/mtk,dvfsrc.h create mode 100644 include/soc/mediatek/mtk_dvfsrc.h create mode 100644 include/soc/mediatek/mtk_sip.h
Signature · 1 line
1.9.1
PATCH v3 1/10 dt-bindings: soc: Add dvfsrc driver bindings
Document the binding for enabling dvfsrc on MediaTek SoC.
--- .../devicetree/bindings/soc/mediatek/dvfsrc.txt | 23 ++++++++++++++++++++++ include/dt-bindings/soc/mtk,dvfsrc.h | 14 +++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt create mode 100644 include/dt-bindings/soc/mtk,dvfsrc.h
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt new file +23 -0
@@ -0,0 +1,23 @@ +MediaTek DVFSRC + +The Dynamic Voltage and Frequency Scaling Resource Collector (DVFSRC) is a +HW module which is used to collect all the requests from both software and +hardware and turn into the decision of minimum operating voltage and minimum +DRAM frequency to fulfill those requests. + +Required Properties: +- compatible: Should be one of the following + - "mediatek,mt8183-dvfsrc": For MT8183 SoC +- reg: Address range of the DVFSRC unit +- clock-names: Must include the following entries: + "dvfsrc": DVFSRC module clock +- clocks: Must contain an entry for each entry in clock-names. + +Example: + + dvfsrc@10012000 { + compatible = "mediatek,mt8183-dvfsrc"; + reg = <0 0x10012000 0 0x1000>; + clocks = <&infracfg CLK_INFRA_DVFSRC>; + clock-names = "dvfsrc"; + };
include/dt-bindings/soc/mtk,dvfsrc.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (c) 2018 MediaTek Inc. +*/ + +#ifndef _DT_BINDINGS_POWER_MTK_DVFSRC_H +#define _DT_BINDINGS_POWER_MTK_DVFSRC_H + +#define MT8183_DVFSRC_LEVEL_1 1 +#define MT8183_DVFSRC_LEVEL_2 2 +#define MT8183_DVFSRC_LEVEL_3 3 +#define MT8183_DVFSRC_LEVEL_4 4 + +#endif /* _DT_BINDINGS_POWER_MTK_DVFSRC_H */
Signature · 1 line
1.9.1
Rob Herring
maintainerRe: [PATCH V3 01/10] dt-bindings: soc: Add dvfsrc driver bindings
Quoted 10 lines · Henry Chen
Document the binding for enabling dvfsrc on MediaTek SoC.
Signed-off-by Henry Chen <[email protected]>--- .../devicetree/bindings/soc/mediatek/dvfsrc.txt | 23 ++++++++++++++++++++++ include/dt-bindings/soc/mtk,dvfsrc.h | 14 +++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt create mode 100644 include/dt-bindings/soc/mtk,dvfsrc.h
Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.
If a tag was not added on purpose, please state why and what changed.
Re: [PATCH V3 01/10] dt-bindings: soc: Add dvfsrc driver bindings
Quoted 12 lines · Rob Herring
Quoted 10 lines · Henry Chen
Document the binding for enabling dvfsrc on MediaTek SoC.
Signed-off-by Henry Chen <[email protected]>--- .../devicetree/bindings/soc/mediatek/dvfsrc.txt | 23 ++++++++++++++++++++++ include/dt-bindings/soc/mtk,dvfsrc.h | 14 +++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt create mode 100644 include/dt-bindings/soc/mtk,dvfsrc.h
Quoted 5 lines
Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.
If a tag was not added on purpose, please state why and what changed.
Hi Rob,
I'm sorry for the mistake. I stand corrected, and will add tags on next version.
Henry
PATCH v3 2/10 dt-bindings: soc: Add opp table on scpsys bindings
In reply to Henry ChenAdd opp table on scpsys dt-bindings for Mediatek SoC.
--- .../devicetree/bindings/soc/mediatek/scpsys.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+)
Documentation/devicetree/bindings/soc/mediatek/scpsys.txt +42 -0
@@ -64,6 +64,10 @@ Optional properties: - mfg_2d-supply: Power supply for the mfg_2d power domain - mfg-supply: Power supply for the mfg power domain +- operating-points-v2: Phandle to the OPP table for the Power domain. + Refer to Documentation/devicetree/bindings/power/power_domain.txt + and Documentation/devicetree/bindings/opp/opp.txt for more details + Example: scpsys: scpsys@10006000 {
@@ -76,6 +80,27 @@ Example: <&topckgen CLK_TOP_VENC_SEL>, <&topckgen CLK_TOP_VENC_LT_SEL>; clock-names = "mfg", "mm", "venc", "venc_lt"; + operating-points-v2 = <&dvfsrc_opp_table>; + + dvfsrc_opp_table: opp-table { + compatible = "operating-points-v2-level"; + + dvfsrc_vol_min: opp1 { + opp,level = <MT8183_DVFSRC_LEVEL_1>; + }; + + dvfsrc_freq_medium: opp2 { + opp,level = <MT8183_DVFSRC_LEVEL_2>; + }; + + dvfsrc_freq_max: opp3 { + opp,level = <MT8183_DVFSRC_LEVEL_3>; + }; + + dvfsrc_vol_max: opp4 { + opp,level = <MT8183_DVFSRC_LEVEL_4>; + }; + }; }; Example consumer:
@@ -83,4 +108,21 @@ Example consumer: afe: mt8173-afe-pcm@11220000 { compatible = "mediatek,mt8173-afe-pcm"; power-domains = <&scpsys MT8173_POWER_DOMAIN_AUDIO>; + operating-points-v2 = <&aud_opp_table>; + }; + + aud_opp_table: aud-opp-table { + compatible = "operating-points-v2"; + opp1 { + opp-hz = /bits/ 64 <793000000>; + required-opps = <&dvfsrc_vol_min>; + }; + opp2 { + opp-hz = /bits/ 64 <910000000>; + required-opps = <&dvfsrc_vol_max>; + }; + opp3 { + opp-hz = /bits/ 64 <1014000000>; + required-opps = <&dvfsrc_vol_max>; + }; };
Signature · 1 line
1.9.1
Rob Herring
maintainerRe: [PATCH V3 02/10] dt-bindings: soc: Add opp table on scpsys bindings
Quoted 7 lines · Henry Chen
Add opp table on scpsys dt-bindings for Mediatek SoC.
Signed-off-by Henry Chen <[email protected]>--- .../devicetree/bindings/soc/mediatek/scpsys.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+)
Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.
If a tag was not added on purpose, please state why and what changed.
PATCH v3 3/10 soc: mediatek: add support for the performance state
In reply to Henry ChenSupport power domain performance state, add header file for scp event.
--- drivers/soc/mediatek/mtk-scpsys.c | 58 +++++++++++++++++++++++++++++++++++++++ drivers/soc/mediatek/mtk-scpsys.h | 22 +++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 drivers/soc/mediatek/mtk-scpsys.h
drivers/soc/mediatek/mtk-scpsys.c +58 -0
@@ -10,7 +10,9 @@#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/pm_domain.h> +#include <linux/pm_opp.h> #include <linux/regulator/consumer.h> +#include <linux/slab.h> #include <linux/soc/mediatek/infracfg.h> #include <linux/soc/mediatek/scpsys-ext.h>
@@ -21,6 +23,7 @@#include <dt-bindings/power/mt7623a-power.h> #include <dt-bindings/power/mt8173-power.h> #include <dt-bindings/power/mt8183-power.h> +#include "mtk-scpsys.h" #define MTK_POLL_DELAY_US 10#define MTK_POLL_TIMEOUT USEC_PER_SEC
@@ -187,6 +190,18 @@ struct scp_soc_data {bool bus_prot_reg_update; }; +static BLOCKING_NOTIFIER_HEAD (scpsys_notifier_list); + +int register_scpsys_notifier (struct notifier_block *nb) +{ +return blocking_notifier_chain_register (&scpsys_notifier_list, nb); +} + +int unregister_scpsys_notifier (struct notifier_block *nb) +{ +return blocking_notifier_chain_unregister (&scpsys_notifier_list, nb); +} +static int scpsys_domain_is_on (struct scp_domain *scpd) {struct scp *scp = scpd->scp;
@@ -505,6 +520,41 @@ static void init_clks(struct platform_device *pdev, struct clk **clk) clk[i] =devm_clk_get (&pdev->dev, clk_names[i]); } +static int mtk_pd_set_performance (struct generic_pm_domain *genpd, +unsigned int state) +{ +int i; +struct scp_domain *scpd = + container_of(genpd, struct scp_domain, genpd); +struct scp_event_data scpe; +struct scp *scp = scpd->scp; +struct genpd_onecell_data *pd_data = &scp->pd_data; + +for (i =0 ; i < pd_data->num_domains; i++) { +if (genpd == pd_data->domains[i]) { +dev_dbg (scp->dev,"%d. %s = %d\n" , + i, genpd->name, state); +break ; + } + } + +if (i == pd_data->num_domains) +return 0 ; + + scpe.event_type =MTK_SCPSYS_PSTATE ; + scpe.genpd = genpd; + scpe.domain_id = i; +blocking_notifier_call_chain (&scpsys_notifier_list, state, &scpe); + +return 0 ; +} + +static unsigned int mtk_pd_get_performance (struct generic_pm_domain *genpd, +struct dev_pm_opp *opp) +{ +return dev_pm_opp_get_level (opp); +} + static struct scp *init_scp(struct platform_device *pdev, const struct scp_domain_data *scp_domain_data, int num, const struct scp_ctrl_reg *scp_ctrl_reg,
@@ -630,6 +680,14 @@ static struct scp *init_scp(struct platform_device *pdev, genpd->power_on = scpsys_power_on;if (MTK_SCPD_CAPS (scpd,MTK_SCPD_ACTIVE_WAKEUP )) genpd->flags |=GENPD_FLAG_ACTIVE_WAKEUP ; + +/* Add opp table check first to avoid OF runtime parse failed */ +if (of_count_phandle_with_args (pdev->dev.of_node, +"operating-points-v2" ,NULL ) >0 ) { + genpd->set_performance_state = mtk_pd_set_performance; + genpd->opp_to_performance_state = + mtk_pd_get_performance; + } }return scp;
drivers/soc/mediatek/mtk-scpsys.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (c) 2018 MediaTek Inc. +*/ + +#ifndef __MTK_SCPSYS_H__ +#define __MTK_SCPSYS_H__ + +struct scp_event_data { +int event_type; +int domain_id; +struct generic_pm_domain *genpd; +}; + +enum scp_event_type { +MTK_SCPSYS_PSTATE , +}; + +int register_scpsys_notifier (struct notifier_block *nb); +int unregister_scpsys_notifier (struct notifier_block *nb); + +#endif /* __MTK_SCPSYS_H__ */
Signature · 1 line
1.9.1
PATCH v3 4/10 arm64: dts: mt8183: add performance state support of scpsys
In reply to Henry ChenAdd support for performance state of scpsys on mt8183 platform.
--- arch/arm64/boot/dts/mediatek/mt8183.dtsi | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
arch/arm64/boot/dts/mediatek/mt8183.dtsi +21 -0
@@ -10,6 +10,7 @@ #include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/power/mt8183-power.h> #include "mt8183-pinfunc.h" +#include <dt-bindings/soc/mtk,dvfsrc.h> / { compatible = "mediatek,mt8183";
@@ -293,6 +294,26 @@ "vpu-3", "vpu-4", "vpu-5"; infracfg = <&infracfg>; smi_comm = <&smi_common>; + operating-points-v2 = <&dvfsrc_opp_table>; + dvfsrc_opp_table: opp-table { + compatible = "operating-points-v2-level"; + + dvfsrc_vol_min: opp1 { + opp,level = <MT8183_DVFSRC_LEVEL_1>; + }; + + dvfsrc_freq_medium: opp2 { + opp,level = <MT8183_DVFSRC_LEVEL_2>; + }; + + dvfsrc_freq_max: opp3 { + opp,level = <MT8183_DVFSRC_LEVEL_3>; + }; + + dvfsrc_vol_max: opp4 { + opp,level = <MT8183_DVFSRC_LEVEL_4>; + }; + }; }; apmixedsys: syscon@1000c000 {
Signature · 1 line
1.9.1
PATCH v3 5/10 soc: mediatek: add header for mediatek SIP interface
In reply to Henry ChenAdd a header to collect SIPs and add one SIP call to initialize power management hardware for the SIP interface defined to access the SPM handling vcore voltage and ddr rate changes on mt8183 (and most likely later socs).
--- include/soc/mediatek/mtk_sip.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 include/soc/mediatek/mtk_sip.h
include/soc/mediatek/mtk_sip.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (c) 2018 MediaTek Inc. +*/ +#ifndef __SOC_MTK_SIP_H +#define __SOC_MTK_SIP_H + +#ifdef CONFIG_ARM64 +#define MTK_SIP_SMC_AARCH_BIT 0x40000000 +#else +#define MTK_SIP_SMC_AARCH_BIT 0x00000000 +#endif + +#define MTK_SIP_SPM (0x82000506 | MTK_SIP_SMC_AARCH_BIT) +#define MTK_SIP_SPM_DVFSRC_INIT 0x00 + +#endif
Signature · 1 line
1.9.1
PATCH v3 6/10 soc: mediatek: add MT8183 dvfsrc support
In reply to Henry ChenAdd dvfsrc driver for MT8183
--- drivers/soc/mediatek/Kconfig | 15 ++ drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/mtk-dvfsrc.c | 374 ++++++++++++++++++++++++++++++++++++++ include/soc/mediatek/mtk_dvfsrc.h | 22 +++ 4 files changed, 412 insertions(+) create mode 100644 drivers/soc/mediatek/mtk-dvfsrc.c create mode 100644 include/soc/mediatek/mtk_dvfsrc.h
drivers/soc/mediatek/Kconfig +15 -0
@@ -25,6 +25,21 @@ config MTK_INFRACFG INFRACFG controller contains various infrastructure registers not directly associated to any device. +config MTK_DVFSRC + bool "MediaTek DVFSRC Support" + depends on ARCH_MEDIATEK + default ARCH_MEDIATEK + select MTK_INFRACFG + select PM_GENERIC_DOMAINS if PM + depends on MTK_SCPSYS + help + Say yes here to add support for the MediaTek DVFSRC (dynamic voltage + and frequency scaling resource collector) found + on different MediaTek SoCs. The DVFSRC is a proprietary + hardware which is used to collect all the requests from + system and turn into the decision of minimum Vcore voltage + and minimum DRAM frequency to fulfill those requests. + config MTK_PMIC_WRAP tristate "MediaTek PMIC Wrapper Support" depends on RESET_CONTROLLER
drivers/soc/mediatek/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_MTK_CMDQ) += mtk-cmdq-helper.o +obj-$(CONFIG_MTK_DVFSRC) += mtk-dvfsrc.o obj-$(CONFIG_MTK_INFRACFG) += mtk-infracfg.o mtk-scpsys-ext.o obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
drivers/soc/mediatek/mtk-dvfsrc.c new file +374 -0
374 lines not on this page · raw message
include/soc/mediatek/mtk_dvfsrc.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (c) 2018 MediaTek Inc. +*/ +#ifndef __SOC_MTK_DVFSRC_H +#define __SOC_MTK_DVFSRC_H + +#define MTK_DVFSRC_CMD_BW_REQUEST 0 +#define MTK_DVFSRC_CMD_OPP_REQUEST 1 + +#if IS_ENABLED (CONFIG_MTK_DVFSRC ) +void mtk_dvfsrc_send_request (const struct device *dev,u32 cmd,u64 data); + +#else + +static inline void mtk_dvfsrc_send_request (const struct device *dev,u32 cmd, +u64 data) +{return -ENODEV ; } + +#endif /* CONFIG_MTK_DVFSRC */ + +#endif
Signature · 1 line
1.9.1
PATCH v3 7/10 arm64: dts: mt8183: add dvfsrc related nodes
In reply to Henry ChenEnable dvfsrc on mt8183 platform.
--- arch/arm64/boot/dts/mediatek/mt8183.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/mediatek/mt8183.dtsi +7 -0
@@ -143,6 +143,13 @@ clock-output-names = "clk26m"; }; + dvfsrc@10012000 { + compatible = "mediatek,mt8183-dvfsrc"; + reg = <0 0x10012000 0 0x1000>; + clocks = <&infracfg CLK_INFRA_DVFSRC>; + clock-names = "dvfsrc"; + }; + timer { compatible = "arm,armv8-timer"; interrupt-parent = <&gic>;
Signature · 1 line
1.9.1
PATCH v3 8/10 dt-bindings: interconnect: add MT8183 interconnect dt-bindings
In reply to Henry ChenAdd interconnect provider dt-bindings for MT8183.
--- .../devicetree/bindings/soc/mediatek/dvfsrc.txt | 9 +++++++++ include/dt-bindings/interconnect/mtk,mt8183-emi.h | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 include/dt-bindings/interconnect/mtk,mt8183-emi.h
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt +9 -0
@@ -12,6 +12,11 @@ Required Properties: - clock-names: Must include the following entries: "dvfsrc": DVFSRC module clock - clocks: Must contain an entry for each entry in clock-names. +- #interconnect-cells : should contain 1 +- interconnect : interconnect providers support dram bandwidth requirements. + The provider is able to communicate with the DVFSRC and send the dram + bandwidth to it. shall contain only one of the following: + "mediatek,mt8183-emi" Example:
@@ -20,4 +25,8 @@ Example: reg = <0 0x10012000 0 0x1000>; clocks = <&infracfg CLK_INFRA_DVFSRC>; clock-names = "dvfsrc"; + ddr_emi: interconnect { + compatible = "mediatek,mt8183-emi"; + #interconnect-cells = <1>; + }; };
include/dt-bindings/interconnect/mtk,mt8183-emi.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __DT_BINDINGS_INTERCONNECT_MTK_MT8183_EMI_H +#define __DT_BINDINGS_INTERCONNECT_MTK_MT8183_EMI_H + +#define MT8183_SLAVE_DDR_EMI 0 +#define MT8183_MASTER_MCUSYS 1 +#define MT8183_MASTER_GPU 2 +#define MT8183_MASTER_MMSYS 3 +#define MT8183_MASTER_MM_VPU 4 +#define MT8183_MASTER_MM_DISP 5 +#define MT8183_MASTER_MM_VDEC 6 +#define MT8183_MASTER_MM_VENC 7 +#define MT8183_MASTER_MM_CAM 8 +#define MT8183_MASTER_MM_IMG 9 +#define MT8183_MASTER_MM_MDP 10 + +#endif
Signature · 1 line
1.9.1
Rob Herring
maintainerRe: [PATCH V3 08/10] dt-bindings: interconnect: add MT8183 interconnect dt-bindings
Quoted 26 lines · Henry Chen
Add interconnect provider dt-bindings for MT8183.
Signed-off-by Henry Chen <[email protected]>--- .../devicetree/bindings/soc/mediatek/dvfsrc.txt | 9 +++++++++ include/dt-bindings/interconnect/mtk,mt8183-emi.h | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 include/dt-bindings/interconnect/mtk,mt8183-emi.hDocumentation/devicetree/bindings/soc/mediatek/dvfsrc.txt +5
-0@@ -12,6 +12,11 @@ Required Properties: - clock-names: Must include the following entries: "dvfsrc": DVFSRC module clock - clocks: Must contain an entry for each entry in clock-names. +- #interconnect-cells : should contain 1 +- interconnect : interconnect providers support dram bandwidth requirements. + The provider is able to communicate with the DVFSRC and send the dram + bandwidth to it. shall contain only one of the following: + "mediatek,mt8183-emi" Example:
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt Example: · line 28
Quoted 4 lines
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt +1
-0@@ -20,4 +25,8 @@ Example: reg = <0 0x10012000 0 0x1000>; clocks = <&infracfg CLK_INFRA_DVFSRC>; clock-names = "dvfsrc"; + ddr_emi: interconnect {
The EMI is a sub-module in the DVFSRC? This is the DDR controller or something else?
Quoted 4 lines
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt +3
-0+ compatible = "mediatek,mt8183-emi"; + #interconnect-cells = <1>; + }; };
Re: [PATCH V3 08/10] dt-bindings: interconnect: add MT8183 interconnect dt-bindings
On Mon, 2019-09-02 at 14:38 +0100, Rob Herring wrote:
Hi Rob,
Quoted 26 lines · Henry Chen
Quoted 25 lines
Add interconnect provider dt-bindings for MT8183.
Signed-off-by Henry Chen <[email protected]>--- .../devicetree/bindings/soc/mediatek/dvfsrc.txt | 9 +++++++++ include/dt-bindings/interconnect/mtk,mt8183-emi.h | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 include/dt-bindings/interconnect/mtk,mt8183-emi.hDocumentation/devicetree/bindings/soc/mediatek/dvfsrc.txt +5
-0@@ -12,6 +12,11 @@ Required Properties: - clock-names: Must include the following entries: "dvfsrc": DVFSRC module clock - clocks: Must contain an entry for each entry in clock-names. +- #interconnect-cells : should contain 1 +- interconnect : interconnect providers support dram bandwidth requirements. + The provider is able to communicate with the DVFSRC and send the dram + bandwidth to it. shall contain only one of the following: + "mediatek,mt8183-emi" Example:
Quoted 8 lines
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt Example: · line 28
Quoted 5 lines
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt +1
-0@@ -20,4 +25,8 @@ Example: reg = <0 0x10012000 0 0x1000>; clocks = <&infracfg CLK_INFRA_DVFSRC>; clock-names = "dvfsrc"; + ddr_emi: interconnect {The EMI is a sub-module in the DVFSRC? This is the DDR controller or something else?
Yes, EMI is a sub-module in the DVFSRC, the EMI through interconnect framework to collect DRAM bandwidth from other device drivers and will send the bandwidth result to DVFSRC driver.
Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt +3
-0+ compatible = "mediatek,mt8183-emi"; + #interconnect-cells = <1>; + }; };
PATCH v3 9/10 interconnect: mediatek: Add mt8183 interconnect provider driver
In reply to Henry ChenIntroduce Mediatek MT8183 specific provider driver using the interconnect framework.
--- drivers/interconnect/Kconfig | 1 + drivers/interconnect/Makefile | 1 + drivers/interconnect/mediatek/Kconfig | 13 ++ drivers/interconnect/mediatek/Makefile | 3 + drivers/interconnect/mediatek/mtk-emi.c | 246 ++++++++++++++++++++++++++++++++ 5 files changed, 264 insertions(+) create mode 100644 drivers/interconnect/mediatek/Kconfig create mode 100644 drivers/interconnect/mediatek/Makefile create mode 100644 drivers/interconnect/mediatek/mtk-emi.c
drivers/interconnect/Kconfig +1 -0
@@ -12,5 +12,6 @@ menuconfig INTERCONNECT if INTERCONNECT source "drivers/interconnect/qcom/Kconfig" +source "drivers/interconnect/mediatek/Kconfig" endif
drivers/interconnect/Makefile +1 -0
@@ -4,3 +4,4 @@ icc-core-objs := core.o obj-$(CONFIG_INTERCONNECT) += icc-core.o obj-$(CONFIG_INTERCONNECT_QCOM) += qcom/ +obj-$(CONFIG_INTERCONNECT_MTK) += mediatek/
drivers/interconnect/mediatek/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +config INTERCONNECT_MTK + bool "Mediatek Network-on-Chip interconnect drivers" + depends on ARCH_MEDIATEK + help + Support for Mediatek's Network-on-Chip interconnect hardware. + +config INTERCONNECT_MTK_EMI + tristate "Mediatek EMI interconnect driver" + depends on INTERCONNECT_MTK + depends on (MTK_DVFSRC && OF) + help + This is a driver for the Mediatek Network-on-Chip on DVFSRC-based + platforms.
drivers/interconnect/mediatek/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_INTERCONNECT_MTK_EMI) += mtk-emi.o
drivers/interconnect/mediatek/mtk-emi.c new file +246 -0
246 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH V3 09/10] interconnect: mediatek: Add mt8183 interconnect provider driver
Hi Henry,
Please CC also the linux-pm@ list.
Quoted 15 lines · Henry Chen
Introduce Mediatek MT8183 specific provider driver using the interconnect framework.
Signed-off-by Henry Chen <[email protected]>--- drivers/interconnect/Kconfig | 1 + drivers/interconnect/Makefile | 1 + drivers/interconnect/mediatek/Kconfig | 13 ++ drivers/interconnect/mediatek/Makefile | 3 + drivers/interconnect/mediatek/mtk-emi.c | 246 ++++++++++++++++++++++++++++++++ 5 files changed, 264 insertions(+) create mode 100644 drivers/interconnect/mediatek/Kconfig create mode 100644 drivers/interconnect/mediatek/Makefile create mode 100644 drivers/interconnect/mediatek/mtk-emi.c
[..]
Review
Quoted 2 lines
(quoted diff) +2
-0+ +#define MT8183_MAX_LINKS 6
Looks like 1 is enough. Sorry for missing this in my earlier review.
Quoted 49 lines
drivers/interconnect/mediatek/mtk-emi.c new file +49
-0+ +/** +* struct mtk_icc_node - Mediatek specific interconnect nodes +* @name: the node name used in debugfs +* @ep: true if the node is an end point. +* @id: a unique node identifier +* @links: an array of nodes where we can go next while traversing +* @num_links: the total number of @links +* @buswidth: width of the interconnect between a node and the bus +* @sum_avg: current sum aggregate value of all avg bw kBps requests +* @max_peak: current max aggregate value of all peak bw kBps requests +*/ +struct mtk_icc_node { +unsigned char *name; +bool ep; +u16 id; +u16 links[MT8183_MAX_LINKS ]; +u16 num_links; +u16 buswidth; +u64 sum_avg; +u64 max_peak; +}; + +struct mtk_icc_desc { +struct mtk_icc_node **nodes; +size_t num_nodes; +}; + +#define DEFINE_MNODE (_name, _id, _buswidth, _ep, ...) \ + static struct mtk_icc_node _name = { \ + .name = #_name, \ + .id = _id, \ + .buswidth = _buswidth, \ + .ep = _ep, \ + .num_links = ARRAY_SIZE(((int[]){ __VA_ARGS__ })), \ +} + +DEFINE_MNODE (ddr_emi,SLAVE_DDR_EMI ,1024 ,1 ,0 ); +DEFINE_MNODE (mcusys,MASTER_MCUSYS ,256 ,0 ,SLAVE_DDR_EMI ); +DEFINE_MNODE (gpu,MASTER_GPUSYS ,256 ,0 ,SLAVE_DDR_EMI ); +DEFINE_MNODE (mmsys,MASTER_MMSYS ,256 ,0 ,SLAVE_DDR_EMI ); +DEFINE_MNODE (mm_vpu,MASTER_MM_VPU ,128 ,0 ,MASTER_MMSYS ); +DEFINE_MNODE (mm_disp,MASTER_MM_DISP ,128 ,0 ,MASTER_MMSYS ); +DEFINE_MNODE (mm_vdec,MASTER_MM_VDEC ,128 ,0 ,MASTER_MMSYS ); +DEFINE_MNODE (mm_venc,MASTER_MM_VENC ,128 ,0 ,MASTER_MMSYS ); +DEFINE_MNODE (mm_cam,MASTER_MM_CAM ,128 ,0 ,MASTER_MMSYS ); +DEFINE_MNODE (mm_img,MASTER_MM_IMG ,128 ,0 ,MASTER_MMSYS ); +DEFINE_MNODE (mm_mdp,MASTER_MM_MDP ,128 ,0 ,MASTER_MMSYS ); +
[..]
drivers/interconnect/mediatek/mtk-emi.c line 101
Quoted 3 lines
drivers/interconnect/mediatek/mtk-emi.c new file +3
-0+static int emi_icc_aggregate (struct icc_node *node,u32 avg_bw, +u32 peak_bw,u32 *agg_avg,u32 *agg_peak) +{
The prototype of this function has changed meanwhile, so you might want to update.
[..]
Quoted 60 lines
drivers/interconnect/mediatek/mtk-emi.c new file +60
-0+static int emi_icc_probe (struct platform_device *pdev) +{ +int ret; +const struct mtk_icc_desc *desc; +struct icc_node *node; +struct icc_onecell_data *data; +struct icc_provider *provider; +struct mtk_icc_node **mnodes; +size_t num_nodes, i, j; + + desc =of_device_get_match_data (&pdev->dev); +if (!desc) +return -EINVAL ; + + mnodes = desc->nodes; + num_nodes = desc->num_nodes; + + provider =devm_kzalloc (&pdev->dev,sizeof (*provider),GFP_KERNEL ); +if (!provider) +return -ENOMEM ; + + data =devm_kcalloc (&pdev->dev, num_nodes,sizeof (*node),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + provider->dev = &pdev->dev; + provider->set = emi_icc_set; + provider->aggregate = emi_icc_aggregate; + provider->xlate = of_icc_xlate_onecell; +INIT_LIST_HEAD (&provider->nodes); + provider->data = data; + + ret =icc_provider_add (provider); +if (ret) { +dev_err (&pdev->dev,"error adding interconnect provider\n" ); +return ret; + } + +for (i =0 ; i < num_nodes; i++) { + node =icc_node_create (mnodes[i]->id); +if (IS_ERR (node)) { + ret =PTR_ERR (node); + goto err; + } + + node->name = mnodes[i]->name; + node->data = mnodes[i]; +icc_node_add (node, provider); + +dev_dbg (&pdev->dev,"registered node %s, num link: %d\n" , + mnodes[i]->name, mnodes[i]->num_links); + +/* populate links */ +for (j =0 ; j < mnodes[i]->num_links; j++) +icc_link_create (node, mnodes[i]->links[j]); + + data->nodes[i] = node; + } + data->num_nodes = num_nodes; +
drivers/interconnect/mediatek/mtk-emi.c line 201
Quoted 10 lines
drivers/interconnect/mediatek/mtk-emi.c new file +10
-0+platform_set_drvdata (pdev, provider); + +return 0 ; +err: +list_for_each_entry (node, &provider->nodes, node_list) { +icc_node_del (node); +icc_node_destroy (node->id); + } + +icc_provider_del (provider);
You can just call emi_icc_remove() instead of the above.
Thanks,
Georgi
Quoted 15 lines
drivers/interconnect/mediatek/mtk-emi.c new file +15
-0+return ret; +} + +static int emi_icc_remove (struct platform_device *pdev) +{ +struct icc_provider *provider =platform_get_drvdata (pdev); +struct icc_node *n; + +list_for_each_entry (n, &provider->nodes, node_list) { +icc_node_del (n); +icc_node_destroy (n->id); + } + +return icc_provider_del (provider); +}
PATCH v3 10/10 arm64: dts: mt8183: Add interconnect provider DT nodes
In reply to Henry ChenAdd DDR EMI provider dictating dram interconnect bus performance found on MT8183-based platforms
--- arch/arm64/boot/dts/mediatek/mt8183.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/mediatek/mt8183.dtsi +5 -0
@@ -11,6 +11,7 @@ #include <dt-bindings/power/mt8183-power.h> #include "mt8183-pinfunc.h" #include <dt-bindings/soc/mtk,dvfsrc.h> +#include <dt-bindings/interconnect/mtk,mt8183-emi.h> / { compatible = "mediatek,mt8183";
@@ -148,6 +149,10 @@ reg = <0 0x10012000 0 0x1000>; clocks = <&infracfg CLK_INFRA_DVFSRC>; clock-names = "dvfsrc"; + ddr_emi: interconnect { + compatible = "mediatek,mt8183-emi"; + #interconnect-cells = <1>; + }; }; timer {
Signature · 1 line
1.9.1