Add driver for dvfsrc, support for active state of scpsys
Subsystems (4)
v4 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 3 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/dram opp requirement from different power domains
[2] https://lwn.net/Articles/744047/
3. Regualtor framework: to handle the operating voltage requirement from user or cosumer which not belong any power domain
Changes in V4:
* Add acked TAG on dt-bindings patches. (Rob)
* Declaration of emi_icc_aggregate since the prototype of aggregate function has changed meanwhile. (Georgi)
* Used emi_icc_remove instead of icc_provider_del on probe. (Georgi)
* Add dvfsrc regulator driver into series.
* Bug fixed of mt8183_get_current_level.
* Add mutex protection for pstate operation on dvfsrc_set_performance.
Changes in 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)
V3: https://patchwork.kernel.org/cover/11118867/
RFC V2: https://lore.kernel.org/patchwork/patch/1068113/
RFC V1: https://lore.kernel.org/patchwork/cover/1028535/
PATCH v4 1/13 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
PATCH v4 2/13 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
@@ -70,6 +70,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 {
@@ -82,6 +86,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:
@@ -89,4 +114,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
PATCH v4 3/13 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,8 +10,10 @@#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/pm_domain.h> +#include <linux/pm_opp.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> +#include <linux/slab.h> #include "scpsys.h" #include <dt-bindings/power/mt2701-power.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
@@ -150,6 +153,18 @@ struct scp_soc_data {const struct scp_ctrl_reg regs; }; +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;
@@ -550,6 +565,41 @@ static int init_basic_clks(struct platform_device *pdev, struct clk **clk,return 0 ; } +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)
@@ -650,6 +700,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 v4 4/13 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
@@ -11,6 +11,7 @@ #include <dt-bindings/power/mt8183-power.h> #include <dt-bindings/reset-controller/mt8183-resets.h> #include "mt8183-pinfunc.h" +#include <dt-bindings/soc/mtk,dvfsrc.h> / { compatible = "mediatek,mt8183";
@@ -310,6 +311,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 · 5 lines
1.9.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 5/13 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 v4 6/13 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 | 434 ++++++++++++++++++++++++++++++++++++++ include/soc/mediatek/mtk_dvfsrc.h | 30 +++ 4 files changed, 480 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
@@ -16,6 +16,21 @@ config MTK_CMDQ time limitation, such as updating display configuration during the vblank. +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,4 +1,5 @@ # 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_PMIC_WRAP) += mtk-pmic-wrap.o obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
drivers/soc/mediatek/mtk-dvfsrc.c new file +434 -0
434 lines not on this page · raw message
include/soc/mediatek/mtk_dvfsrc.h new file +30 -0
@@ -0,0 +1,30 @@ +/* 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 +#define MTK_DVFSRC_CMD_VCORE_REQUEST 2 + +#define MTK_DVFSRC_CMD_VCORE_QUERY 0 + +#if IS_ENABLED (CONFIG_MTK_DVFSRC ) +void mtk_dvfsrc_send_request (const struct device *dev,u32 cmd,u64 data); +int mtk_dvfsrc_query_info (const struct device *dev,u32 cmd,int *data); + +#else + +static inline void mtk_dvfsrc_send_request (const struct device *dev,u32 cmd, +u64 data) +{return -ENODEV ; } + +static inline int mtk_dvfsrc_query_info (const struct device *dev,u32 cmd, +int *data); +{return -ENODEV ; } + +#endif /* CONFIG_MTK_DVFSRC */ + +#endif
Signature · 1 line
1.9.1
Re: [PATCH V4 06/13] soc: mediatek: add MT8183 dvfsrc support
Hi Henry,
Quoted 59 lines · Henry Chen
Add dvfsrc driver for MT8183
Signed-off-by Henry Chen <[email protected]>--- drivers/soc/mediatek/Kconfig | 15 ++ drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/mtk-dvfsrc.c | 434 ++++++++++++++++++++++++++++++++++++++ include/soc/mediatek/mtk_dvfsrc.h | 30 +++ 4 files changed, 480 insertions(+) create mode 100644 drivers/soc/mediatek/mtk-dvfsrc.c create mode 100644 include/soc/mediatek/mtk_dvfsrc.hdrivers/soc/mediatek/Kconfig +15
-0@@ -16,6 +16,21 @@ config MTK_CMDQ time limitation, such as updating display configuration during the vblank. +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_CONTROLLERdrivers/soc/mediatek/Makefile +1
-0@@ -1,4 +1,5 @@ # 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_PMIC_WRAP) += mtk-pmic-wrap.o obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.odrivers/soc/mediatek/mtk-dvfsrc.c new file +5
-0@@ -0,0 +1,434 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018 MediaTek Inc. +*/ +#include <linux/arm-smccc.h>
drivers/soc/mediatek/mtk-dvfsrc.c line 15
Quoted 10 lines
drivers/soc/mediatek/mtk-dvfsrc.c new file +10
-0+#include <linux/clk.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/module.h> +#include <linux/notifier.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> +#include <soc/mediatek/mtk_dvfsrc.h> +#include <soc/mediatek/mtk_sip.h> +#include <dt-bindings/power/mt8183-power.h>
Looks like this depends on a header which is not part of this patch-set. It would be nice to list any dependencies in the cover letter.
Thanks,
Georgi
Re: [PATCH V4 06/13] soc: mediatek: add MT8183 dvfsrc support
Hi Georgi,
Quoted 76 lines · Georgi Djakov
Hi Henry,
Quoted 59 lines · Henry Chen
Add dvfsrc driver for MT8183
Signed-off-by Henry Chen <[email protected]>--- drivers/soc/mediatek/Kconfig | 15 ++ drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/mtk-dvfsrc.c | 434 ++++++++++++++++++++++++++++++++++++++ include/soc/mediatek/mtk_dvfsrc.h | 30 +++ 4 files changed, 480 insertions(+) create mode 100644 drivers/soc/mediatek/mtk-dvfsrc.c create mode 100644 include/soc/mediatek/mtk_dvfsrc.hdrivers/soc/mediatek/Kconfig +15
-0@@ -16,6 +16,21 @@ config MTK_CMDQ time limitation, such as updating display configuration during the vblank. +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_CONTROLLERdrivers/soc/mediatek/Makefile +1
-0@@ -1,4 +1,5 @@ # 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_PMIC_WRAP) += mtk-pmic-wrap.o obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.odrivers/soc/mediatek/mtk-dvfsrc.c new file +5
-0@@ -0,0 +1,434 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018 MediaTek Inc. +*/ +#include <linux/arm-smccc.h> drivers/soc/mediatek/mtk-dvfsrc.c line 15
Quoted 10 lines
drivers/soc/mediatek/mtk-dvfsrc.c new file +10
-0+#include <linux/clk.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/module.h> +#include <linux/notifier.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> +#include <soc/mediatek/mtk_dvfsrc.h> +#include <soc/mediatek/mtk_sip.h> +#include <dt-bindings/power/mt8183-power.h> Looks like this depends on a header which is not part of this patch-set. It would be nice to list any dependencies in the cover letter.
Quoted 2 lines
Thanks,
Georgi
I disregarded to list here. Thanks for your friendly reminder.
PATCH v4 7/13 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
@@ -159,6 +159,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 v4 8/13 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 V4 08/13] 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 30
Quoted 6 lines
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt +3
-0@@ -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>;
Nodes with a compatible and no defined way to access the hardware always look suspicious. Can't you make the parent node an interconnect provider.
Rob
PATCH v4 9/13 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 | 242 ++++++++++++++++++++++++++++++++ 5 files changed, 260 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
@@ -5,3 +5,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 +242 -0
242 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH V4 09/13] interconnect: mediatek: Add mt8183 interconnect provider driver
Hi Henry,
Thanks for the patch!
Quoted 70 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 | 242 ++++++++++++++++++++++++++++++++ 5 files changed, 260 insertions(+) create mode 100644 drivers/interconnect/mediatek/Kconfig create mode 100644 drivers/interconnect/mediatek/Makefile create mode 100644 drivers/interconnect/mediatek/mtk-emi.cdrivers/interconnect/Kconfig +1
-0@@ -12,5 +12,6 @@ menuconfig INTERCONNECT if INTERCONNECT source "drivers/interconnect/qcom/Kconfig" +source "drivers/interconnect/mediatek/Kconfig" endifdrivers/interconnect/Makefile +1
-0@@ -5,3 +5,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.odrivers/interconnect/mediatek/mtk-emi.c new file +0
-0
drivers/interconnect/mediatek/mtk-emi.c line 3
Quoted 3 lines
drivers/interconnect/mediatek/mtk-emi.c new file +3
-0@@ -0,0 +1,242 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2019, The Linux Foundation. All rights reserved.
Nit: Maybe 2020?
drivers/interconnect/mediatek/mtk-emi.c line 7
Quoted 4 lines
drivers/interconnect/mediatek/mtk-emi.c new file +4
-0+* +*/ + +#include <dt-bindings/interconnect/mtk,mt8183-emi.h>
Please move this below the all other linux/ headers
drivers/interconnect/mediatek/mtk-emi.c line 12
Quoted 5 lines
drivers/interconnect/mediatek/mtk-emi.c new file +5
-0+#include <linux/device.h> +#include <linux/interconnect-provider.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/of_platform.h>
Is this needed?
Quoted 72 lines
drivers/interconnect/mediatek/mtk-emi.c new file +72
-0+#include <linux/platform_device.h> +#include <soc/mediatek/mtk_dvfsrc.h> + +enum mtk_icc_name { +SLAVE_DDR_EMI , +MASTER_MCUSYS , +MASTER_GPUSYS , +MASTER_MMSYS , +MASTER_MM_VPU , +MASTER_MM_DISP , +MASTER_MM_VDEC , +MASTER_MM_VENC , +MASTER_MM_CAM , +MASTER_MM_IMG , +MASTER_MM_MDP , +}; + +#define MT8183_MAX_LINKS 1 + +/** +* 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 ); + +static struct mtk_icc_node *mt8183_icc_nodes[] = { + [MT8183_SLAVE_DDR_EMI ] = &ddr_emi, + [MT8183_MASTER_MCUSYS ] = &mcusys, + [MT8183_MASTER_GPU ] = &gpu, + [MT8183_MASTER_MMSYS ] = &mmsys,
drivers/interconnect/mediatek/mtk-emi.c line 94
Quoted 10 lines
drivers/interconnect/mediatek/mtk-emi.c new file +10
-0+ [MT8183_MASTER_MM_VPU] = &mm_vpu, + [MT8183_MASTER_MM_DISP] = &mm_disp, + [MT8183_MASTER_MM_VDEC] = &mm_vdec, + [MT8183_MASTER_MM_VENC] = &mm_venc, + [MT8183_MASTER_MM_CAM] = &mm_cam, + [MT8183_MASTER_MM_IMG] = &mm_img, + [MT8183_MASTER_MM_MDP] = &mm_mdp, +}; + +static struct mtk_icc_desc mt8183_icc = {
const?
Quoted 50 lines
drivers/interconnect/mediatek/mtk-emi.c new file +50
-0+ .nodes = mt8183_icc_nodes, + .num_nodes = ARRAY_SIZE(mt8183_icc_nodes), +}; + +static int emi_icc_aggregate (struct icc_node *node,u32 tag,u32 avg_bw, +u32 peak_bw,u32 *agg_avg,u32 *agg_peak) +{ +struct mtk_icc_node *in; + + in = node->data; + + *agg_avg += avg_bw; + *agg_peak += peak_bw; + + in->sum_avg = *agg_avg; + in->max_peak = *agg_peak; + +return 0 ; +} + +static int emi_icc_set (struct icc_node *src,struct icc_node *dst) +{ +int ret =0 ; +struct mtk_icc_node *node; + + node = dst->data; +if (node->ep) { +pr_debug ("sum_avg (%llu), max_peak (%llu)\n" , + node->sum_avg, node->max_peak); +mtk_dvfsrc_send_request (src->provider->dev->parent, +MTK_DVFSRC_CMD_BW_REQUEST , + node->max_peak); + } + +return ret; +} + +static int emi_icc_remove (struct platform_device *pdev); +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)
drivers/interconnect/mediatek/mtk-emi.c line 154
Quoted 10 lines
drivers/interconnect/mediatek/mtk-emi.c new file +10
-0+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 );
This should be:devm_kzalloc(&pdev->dev, struct_size(data, nodes, num_nodes), GFP_KERNEL);
Quoted 19 lines
drivers/interconnect/mediatek/mtk-emi.c new file +19
-0+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)) {
drivers/interconnect/mediatek/mtk-emi.c line 183
Quoted 10 lines
drivers/interconnect/mediatek/mtk-emi.c new file +10
-0+ 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);
Please remove this.
drivers/interconnect/mediatek/mtk-emi.c line 185
Quoted 2 lines
drivers/interconnect/mediatek/mtk-emi.c new file +2
-0+ +/* populate links */
Please remove the comment too.
drivers/interconnect/mediatek/mtk-emi.c line 197
Quoted 12 lines
drivers/interconnect/mediatek/mtk-emi.c new file +12
-0+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; + +platform_set_drvdata (pdev, provider); + +return 0 ; +err: +emi_icc_remove (pdev);
This will not work because platform_set_drvdata() is called only when the probe function completes successfully. So platform_get_drvdata() in emi_icc_remove() will return NULL.
drivers/interconnect/mediatek/mtk-emi.c line 209
Quoted 12 lines
drivers/interconnect/mediatek/mtk-emi.c new file +12
-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); + }
You can use icc_nodes_remove() instead of the above.
Thanks,
Georgi
Re: [PATCH V4 09/13] interconnect: mediatek: Add mt8183 interconnect provider driver
Hi Georgi,
Quoted 72 lines · Georgi Djakov
Hi Henry,
Thanks for the patch!
Quoted 67 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 | 242 ++++++++++++++++++++++++++++++++ 5 files changed, 260 insertions(+) create mode 100644 drivers/interconnect/mediatek/Kconfig create mode 100644 drivers/interconnect/mediatek/Makefile create mode 100644 drivers/interconnect/mediatek/mtk-emi.cdrivers/interconnect/Kconfig +1
-0@@ -12,5 +12,6 @@ menuconfig INTERCONNECT if INTERCONNECT source "drivers/interconnect/qcom/Kconfig" +source "drivers/interconnect/mediatek/Kconfig" endifdrivers/interconnect/Makefile +1
-0@@ -5,3 +5,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.odrivers/interconnect/mediatek/mtk-emi.c new file +0
-0
Quoted 8 lines
drivers/interconnect/mediatek/mtk-emi.c line 3
Quoted 6 lines
drivers/interconnect/mediatek/mtk-emi.c new file +3
-0@@ -0,0 +1,242 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2019, The Linux Foundation. All rights reserved. Nit: Maybe 2020?
Yes, will change to 2020
Quoted 7 lines
drivers/interconnect/mediatek/mtk-emi.c line 7
Quoted 5 lines
drivers/interconnect/mediatek/mtk-emi.c new file +4
-0+* +*/ + +#include <dt-bindings/interconnect/mtk,mt8183-emi.h> Please move this below the all other linux/ headers
OK
Quoted 8 lines
drivers/interconnect/mediatek/mtk-emi.c line 12
Quoted 6 lines
drivers/interconnect/mediatek/mtk-emi.c new file +5
-0+#include <linux/device.h> +#include <linux/interconnect-provider.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/of_platform.h> Is this needed?
You're right, it not necessary and I will remove this.
Quoted 77 lines
Quoted 77 lines
drivers/interconnect/mediatek/mtk-emi.c new file +76
-0+#include <linux/platform_device.h> +#include <soc/mediatek/mtk_dvfsrc.h> + +enum mtk_icc_name { +SLAVE_DDR_EMI , +MASTER_MCUSYS , +MASTER_GPUSYS , +MASTER_MMSYS , +MASTER_MM_VPU , +MASTER_MM_DISP , +MASTER_MM_VDEC , +MASTER_MM_VENC , +MASTER_MM_CAM , +MASTER_MM_IMG , +MASTER_MM_MDP , +}; + +#define MT8183_MAX_LINKS 1 + +/** +* 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 ); + +static struct mtk_icc_node *mt8183_icc_nodes[] = { + [MT8183_SLAVE_DDR_EMI ] = &ddr_emi, + [MT8183_MASTER_MCUSYS ] = &mcusys, + [MT8183_MASTER_GPU ] = &gpu, + [MT8183_MASTER_MMSYS ] = &mmsys, + [MT8183_MASTER_MM_VPU ] = &mm_vpu, + [MT8183_MASTER_MM_DISP ] = &mm_disp, + [MT8183_MASTER_MM_VDEC ] = &mm_vdec, + [MT8183_MASTER_MM_VENC ] = &mm_venc,
Quoted 8 lines
drivers/interconnect/mediatek/mtk-emi.c line 94
Quoted 6 lines
drivers/interconnect/mediatek/mtk-emi.c new file +6
-0+ [MT8183_MASTER_MM_CAM] = &mm_cam, + [MT8183_MASTER_MM_IMG] = &mm_img, + [MT8183_MASTER_MM_MDP] = &mm_mdp, +}; + +static struct mtk_icc_desc mt8183_icc = {const?
ok
Quoted 56 lines
Quoted 56 lines
drivers/interconnect/mediatek/mtk-emi.c new file +55
-0+ .nodes = mt8183_icc_nodes, + .num_nodes = ARRAY_SIZE(mt8183_icc_nodes), +}; + +static int emi_icc_aggregate (struct icc_node *node,u32 tag,u32 avg_bw, +u32 peak_bw,u32 *agg_avg,u32 *agg_peak) +{ +struct mtk_icc_node *in; + + in = node->data; + + *agg_avg += avg_bw; + *agg_peak += peak_bw; + + in->sum_avg = *agg_avg; + in->max_peak = *agg_peak; + +return 0 ; +} + +static int emi_icc_set (struct icc_node *src,struct icc_node *dst) +{ +int ret =0 ; +struct mtk_icc_node *node; + + node = dst->data; +if (node->ep) { +pr_debug ("sum_avg (%llu), max_peak (%llu)\n" , + node->sum_avg, node->max_peak); +mtk_dvfsrc_send_request (src->provider->dev->parent, +MTK_DVFSRC_CMD_BW_REQUEST , + node->max_peak); + } + +return ret; +} + +static int emi_icc_remove (struct platform_device *pdev); +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; +
Quoted 8 lines
drivers/interconnect/mediatek/mtk-emi.c line 154
Quoted 5 lines
drivers/interconnect/mediatek/mtk-emi.c new file +5
-0+ provider =devm_kzalloc (&pdev->dev,sizeof (*provider),GFP_KERNEL ); +if (!provider) +return -ENOMEM ; + + data =devm_kcalloc (&pdev->dev, num_nodes,sizeof (*node),GFP_KERNEL );This should be:
devm_kzalloc(&pdev->dev, struct_size(data, nodes, num_nodes), GFP_KERNEL);
thanks, will fix this.
Quoted 24 lines
Quoted 24 lines
drivers/interconnect/mediatek/mtk-emi.c new file +23
-0+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; + } +
Quoted 8 lines
drivers/interconnect/mediatek/mtk-emi.c line 183
Quoted 6 lines
drivers/interconnect/mediatek/mtk-emi.c new file +6
-0+ 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);Please remove this.
ok
Quoted 5 lines
drivers/interconnect/mediatek/mtk-emi.c line 185
Quoted 3 lines
drivers/interconnect/mediatek/mtk-emi.c new file +2
-0+ +/* populate links */ Please remove the comment too.
ok
Quoted 18 lines
drivers/interconnect/mediatek/mtk-emi.c line 197
Quoted 13 lines
drivers/interconnect/mediatek/mtk-emi.c new file +12
-0+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; + +platform_set_drvdata (pdev, provider); + +return 0 ; +err: +emi_icc_remove (pdev);This will not work because
platform_set_drvdata()is called only when the probe function completes successfully. Soplatform_get_drvdata()inemi_icc_remove()will return NULL.
Quoted 14 lines
drivers/interconnect/mediatek/mtk-emi.c line 209
Quoted 12 lines
drivers/interconnect/mediatek/mtk-emi.c new file +12
-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); + }You can use
icc_nodes_remove()instead of the above.
Got it, thanks for advise.
Quoted 3 lines
Thanks,
Georgi
Thanks for the review.
Henry
PATCH v4 10/13 arm64: dts: mt8183: add dvfsrc related 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
@@ -12,6 +12,7 @@ #include <dt-bindings/reset-controller/mt8183-resets.h> #include "mt8183-pinfunc.h" #include <dt-bindings/soc/mtk,dvfsrc.h> +#include <dt-bindings/interconnect/mtk,mt8183-emi.h> / { compatible = "mediatek,mt8183";
@@ -164,6 +165,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
PATCH v4 11/13 dt-bindings: regulator: add DVFSRC regulator dt-bindings
In reply to Henry ChenFrom: "henryc.chen" <[email protected]>
Add a regulator as sub device into dvfsrc dt-bindings for MT8183.
--- Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt +14 -0
@@ -17,6 +17,11 @@ Required Properties: 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" +- regulator : The DVFSRC regulator is modelled as a subdevice of the DVFSRC. + Because DVFSRC can request power directly via register read/write, likes + vcore which is a core power of mt8183. As such, the DVFSRC regulator + requires that DVFSRC nodes be present. shall contain only one of the + following: "mediatek,mt8183-dvfsrc-regulator" Example:
@@ -29,4 +34,13 @@ Example: compatible = "mediatek,mt8183-emi"; #interconnect-cells = <1>; }; + dvfsrc-regulator { + compatible = "mediatek,mt8183-dvfsrc-regulator"; + dvfsrc_vcore: dvfsrc-vcore { + regulator-name = "dvfsrc-vcore"; + regulator-min-microvolt = <725000>; + regulator-max-microvolt = <800000>; + regulator-always-on; + }; + }; };
Signature · 5 lines
1.9.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Mark Brown
maintainerRe: [PATCH V4 11/13] dt-bindings: regulator: add DVFSRC regulator dt-bindings
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt Required Properties: · line 24
Quoted 5 lines · Henry Chen
+- regulator : The DVFSRC regulator is modelled as a subdevice of the DVFSRC.
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt +4
-0+ Because DVFSRC can request power directly via register read/write, likes + vcore which is a core power of mt8183. As such, the DVFSRC regulator + requires that DVFSRC nodes be present. shall contain only one of the + following: "mediatek,mt8183-dvfsrc-regulator"
Why do we even need a compatible here - it's not adding any new information to the parent mt8183 node, the compatible is mainly for the way Linux divides things up rather than a description of the hardware. We could just say that the regulator node always has a particular name instead.
It's also not quite true that it contains "only" the compatible - it also allows the regulator constraints to be defined.
Re: [PATCH V4 11/13] dt-bindings: regulator: add DVFSRC regulator dt-bindings
Hi Mark,
Quoted 13 lines · Mark Brown
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt Required Properties: · line 24
Quoted 5 lines · Henry Chen
+- regulator : The DVFSRC regulator is modelled as a subdevice of the DVFSRC.
Documentation/devicetree/bindings/soc/mediatek/dvfsrc.txt +4
-0+ Because DVFSRC can request power directly via register read/write, likes + vcore which is a core power of mt8183. As such, the DVFSRC regulator + requires that DVFSRC nodes be present. shall contain only one of the + following: "mediatek,mt8183-dvfsrc-regulator"Why do we even need a compatible here - it's not adding any new information to the parent mt8183 node, the compatible is mainly for the way Linux divides things up rather than a description of the hardware. We could just say that the regulator node always has a particular name instead.
Sorry, not quite sure what you mean, because I think DVFSRC is a regulator provider that can provide vcore voltage control on mt8183, and it can provide more power control in the next generation Mediatek SOC. Here I add a sub-node to describe it. Or should I move this node to regulator folder?
Quoted 3 lines
It's also not quite true that it contains "only" the compatible - it also allows the regulator constraints to be defined.
PATCH v4 12/13 regulator: Regulator driver for the Mediatek DVFSRC
In reply to Henry ChenFrom: "henryc.chen" <[email protected]>
Driver for regulators exposed by the DVFSRC (dynamic voltage and frequency scaling resource collector) found in devices based on mt8183 and newer platforms.
--- drivers/regulator/Kconfig | 10 +++ drivers/regulator/Makefile | 1 + drivers/regulator/mtk-dvfsrc-regulator.c | 119 +++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 drivers/regulator/mtk-dvfsrc-regulator.c
drivers/regulator/Kconfig +10 -0
@@ -680,6 +680,16 @@ config REGULATOR_MT6397 This driver supports the control of different power rails of device through regulator interface. +config REGULATOR_MTK_DVFSRC + tristate "MediaTek DVFSRC regulator driver" + depends on MTK_DVFSRC + help + Say y here to control regulator by DVFSRC (dynamic voltage + and frequency scaling resource collector). + This driver supports to control regulators via the DVFSRC + of Mediatek. It allows for voting on regulator state + between multiple users. + config REGULATOR_PALMAS tristate "TI Palmas PMIC Regulators" depends on MFD_PALMAS
drivers/regulator/Makefile +1 -0
@@ -85,6 +85,7 @@ obj-$(CONFIG_REGULATOR_MT6323) += mt6323-regulator.o obj-$(CONFIG_REGULATOR_MT6358) += mt6358-regulator.o obj-$(CONFIG_REGULATOR_MT6380) += mt6380-regulator.o obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o +obj-$(CONFIG_REGULATOR_MTK_DVFSRC) += mtk-dvfsrc-regulator.o obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o obj-$(CONFIG_REGULATOR_QCOM_RPMH) += qcom-rpmh-regulator.o obj-$(CONFIG_REGULATOR_QCOM_SMD_RPM) += qcom_smd-regulator.o
drivers/regulator/mtk-dvfsrc-regulator.c new file +119 -0
119 lines not on this page · raw message
Signature · 5 lines
1.9.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v4 13/13 arm64: dts: mt8183: add dvfsrc regulator nodes
In reply to Henry ChenFrom: "henryc.chen" <[email protected]>
Add dvfsrc regulator nodes which is for MT8183-based platforms
--- arch/arm64/boot/dts/mediatek/mt8183.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/mediatek/mt8183.dtsi +9 -0
@@ -169,6 +169,15 @@ compatible = "mediatek,mt8183-emi"; #interconnect-cells = <1>; }; + dvfsrc-regulator { + compatible = "mediatek,mt8183-dvfsrc-regulator"; + dvfsrc_vcore: dvfsrc-vcore { + regulator-name = "dvfsrc-vcore"; + regulator-min-microvolt = <725000>; + regulator-max-microvolt = <800000>; + regulator-always-on; + }; + }; }; timer {
Signature · 5 lines
1.9.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Henry,
Quoted 32 lines · Henry Chen
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 3 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|
Quoted 8 lines
---------- | ----
| DVFSR | |
| | | ----
---------- |--->|IMG |
| ----
| ----
|--->|CAM |
----It would be useful to also add the above diagram into the commit text of patch 09/13. By doing so, it will be saved into the history, as cover letters are discarded.
Thanks,
Georgi
Hi Georgi,
Quoted 44 lines · Georgi Djakov
Hi Henry,
Quoted 32 lines · Henry Chen
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 3 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|Quoted 8 lines
---------- | ---- | DVFSR | | | | | ---- ---------- |--->|IMG | | ---- | ---- |--->|CAM | ----
Quoted 3 lines
It would be useful to also add the above diagram into the commit text of patch 09/13. By doing so, it will be saved into the history, as cover letters are discarded.
OK, thanks.
Quoted 8 lines
Thanks,
Georgi_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek