soc: mediatek: SVS: introduce MTK SVS
Subsystems (2)
v11 cover soc: mediatek: SVS: introduce MTK SVS
1. SVS driver uses OPP adjust event in [1] to update OPP table voltage part.
2. SVS driver gets thermal/GPU device by node [2][3] and CPU device by get_cpu_device(). After retrieving subsys device, SVS driver does device_link_add() to make sure probe/suspend callback priority.
3. SVS dts refers to reset controller [4] to help reset SVS HW.
#mt8183 SVS related patches
[1] https://patchwork.kernel.org/patch/11193513/
[2] https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
[3] https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
#mt8192 SVS related patches
[1] https://patchwork.kernel.org/patch/11193513/
[2] https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
[3] https://lore.kernel.org/patchwork/patch/1360551/
[4] https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
changes since v10:
- Fix typos and remove duplicate GENASK()
- Use DIV_ROUND_UP instead of creating own math
- Remove fake_efuse related codes and some type casting
- Optimize svs_get_vops_v2() coding
- Check "supplier links.status DL_DEV_DRIVER_BOUND" to make sure supplier is ready after doing device_link_add()
Roger Lu (7):
[v11,1/7]: dt-bindings: soc: mediatek: add mtk svs dt-bindings [v11,2/7]: arm64: dts: mt8183: add svs device information [v11,3/7]: soc: mediatek: SVS: introduce MTK SVS engine [v11,4/7]: soc: mediatek: SVS: add debug commands [v11,5/7]: dt-bindings: soc: mediatek: add mt8192 svs dt-bindings [v11,6/7]: arm64: dts: mt8192: add svs device information [v11,7/7]: soc: mediatek: SVS: add mt8192 SVS GPU driver
.../bindings/soc/mediatek/mtk-svs.yaml | 89 + arch/arm64/boot/dts/mediatek/mt8183.dtsi | 18 + arch/arm64/boot/dts/mediatek/mt8192.dtsi | 34 + drivers/soc/mediatek/Kconfig | 10 + drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/mtk-svs.c | 2492 +++++++++++++++++ 6 files changed, 2644 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml create mode 100644 drivers/soc/mediatek/mtk-svs.c
PATCH v11 1/7 dt-bindings: soc: mediatek: add mtk svs dt-bindings
Document the binding for enabling mtk svs on MediaTek SoC.
--- .../bindings/soc/mediatek/mtk-svs.yaml | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml new file +80 -0
@@ -0,0 +1,80 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/mediatek/mtk-svs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Introduce MTK SVS engine + +maintainers: + - Matthias Brugger <[email protected]> + - Kevin Hilman <[email protected]> + - Nishanth Menon <[email protected]> + +description: |+ + The Smart Voltage Scaling(SVS) engine is a piece of hardware + which has several controllers(banks) for calculating suitable + voltage to different power domains(CPU/GPU/CCI) according to + chip process corner, temperatures and other factors. Then DVFS + driver could apply SVS bank voltage to PMIC/Buck. + +properties: + compatible: + enum: + - mediatek,mt8183-svs + + reg: + description: Address range of the MTK SVS controller. + maxItems: 1 + + interrupts: + description: IRQ for the MTK SVS controller. + maxItems: 1 + + clocks: + description: Main clock for MTK SVS controller to work. + + clock-names: + const: main + + nvmem-cells: + maxItems: 2 + description: + Phandle to the calibration data provided by a nvmem device. + + nvmem-cell-names: + items: + - const: svs-calibration-data + - const: t-calibration-data + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - nvmem-cells + - nvmem-cell-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/mt8183-clk.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + svs@1100b000 { + compatible = "mediatek,mt8183-svs"; + reg = <0 0x1100b000 0 0x1000>; + interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW>; + clocks = <&infracfg CLK_INFRA_THERM>; + clock-names = "main"; + nvmem-cells = <&svs_calibration>, <&thermal_calibration>; + nvmem-cell-names = "svs-calibration-data", "t-calibration-data"; + }; + };
Signature · 5 lines
2.18.0 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Rob Herring
maintainerRe: [PATCH v11 1/7] dt-bindings: soc: mediatek: add mtk svs dt-bindings
Quoted 14 lines · Roger Lu
Document the binding for enabling mtk svs on MediaTek SoC.
Signed-off-by Roger Lu <[email protected]>--- .../bindings/soc/mediatek/mtk-svs.yaml | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yamlDocumentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml new file +0
-0
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml line 7
Quoted 7 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml new file +7
-0@@ -0,0 +1,80 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/mediatek/mtk-svs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Introduce MTK SVS engine
Introduce? That's what this commit does, not what this binding is.
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml line 12
Quoted 5 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml new file +5
-0+ +maintainers: + - Matthias Brugger <[email protected]> + - Kevin Hilman <[email protected]> + - Nishanth Menon <[email protected]>
This should be someone that knows the h/w. Not who applies patches. Perhaps you.
Quoted 9 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml new file +9
-0+ +description: |+ + The Smart Voltage Scaling(SVS) engine is a piece of hardware + which has several controllers(banks) for calculating suitable + voltage to different power domains(CPU/GPU/CCI) according to + chip process corner, temperatures and other factors. Then DVFS + driver could apply SVS bank voltage to PMIC/Buck. + +properties:
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml line 31
Quoted 10 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml new file +10
-0+ compatible: + enum: + - mediatek,mt8183-svs + + reg: + description: Address range of the MTK SVS controller. + maxItems: 1 + + interrupts: + description: IRQ for the MTK SVS controller.
Drop. That's kind of obvious with only 1 interrupt.
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml line 35
Quoted 4 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml new file +4
-0+ maxItems: 1 + + clocks: + description: Main clock for MTK SVS controller to work.
How many clocks (maxItems)?
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml line 43
Quoted 8 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml new file +8
-0+ + clock-names: + const: main + + nvmem-cells: + maxItems: 2 + description: + Phandle to the calibration data provided by a nvmem device.
Need to define what each entry is.
items:
- description: ...
- description: ...
Quoted 40 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml new file +37
-0+ + nvmem-cell-names: + items: + - const: svs-calibration-data + - const: t-calibration-data + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - nvmem-cells + - nvmem-cell-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/mt8183-clk.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + svs@1100b000 { + compatible = "mediatek,mt8183-svs"; + reg = <0 0x1100b000 0 0x1000>; + interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW>; + clocks = <&infracfg CLK_INFRA_THERM>; + clock-names = "main"; + nvmem-cells = <&svs_calibration>, <&thermal_calibration>; + nvmem-cell-names = "svs-calibration-data", "t-calibration-data"; + }; + };Signature · 1 line
2.18.0
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v11 1/7] dt-bindings: soc: mediatek: add mtk svs dt-bindings
Quoted 8 lines · Rob Herring
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml line 12
Quoted 5 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml new file +5
-0+ +maintainers: + - Matthias Brugger <[email protected]> + - Kevin Hilman <[email protected]> + - Nishanth Menon <[email protected]>This should be someone that knows the h/w. Not who applies patches. Perhaps you.
Yes please, I would have no idea what to do with SVS patches. Thanks Rob for catching it.
Signature · 8 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v11 2/7 arm64: dts: mt8183: add svs device information
In reply to Roger Luadd compitable/reg/irq/clock/efuse setting in svs node
--- arch/arm64/boot/dts/mediatek/mt8183.dtsi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/arm64/boot/dts/mediatek/mt8183.dtsi +18 -0
@@ -657,6 +657,18 @@ status = "disabled"; }; + svs: svs@1100b000 { + compatible = "mediatek,mt8183-svs"; + reg = <0 0x1100b000 0 0x1000>; + interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW>; + clocks = <&infracfg CLK_INFRA_THERM>; + clock-names = "main"; + nvmem-cells = <&svs_calibration>, + <&thermal_calibration>; + nvmem-cell-names = "svs-calibration-data", + "t-calibration-data"; + }; + pwm0: pwm@1100e000 { compatible = "mediatek,mt8183-disp-pwm"; reg = <0 0x1100e000 0 0x1000>;
@@ -926,9 +938,15 @@ reg = <0 0x11f10000 0 0x1000>; #address-cells = <1>; #size-cells = <1>; + thermal_calibration: calib@180 { + reg = <0x180 0xc>; + }; mipi_tx_calibration: calib@190 { reg = <0x190 0xc>; }; + svs_calibration: calib@580 { + reg = <0x580 0x64>; + }; }; u3phy: usb-phy@11f40000 {
Signature · 5 lines
2.18.0 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v11 3/7 soc: mediatek: SVS: introduce MTK SVS engine
In reply to Roger LuThe Smart Voltage Scaling(SVS) engine is a piece of hardware which calculates suitable SVS bank voltages to OPP voltage table. Then, DVFS driver could apply those SVS bank voltages to PMIC/Buck when receiving OPP_EVENT_ADJUST_VOLTAGE.
--- drivers/soc/mediatek/Kconfig | 10 + drivers/soc/mediatek/Makefile | 1 + drivers/soc/mediatek/mtk-svs.c | 1702 ++++++++++++++++++++++++++++++++ 3 files changed, 1713 insertions(+) create mode 100644 drivers/soc/mediatek/mtk-svs.c
drivers/soc/mediatek/Kconfig +10 -0
@@ -73,4 +73,14 @@ config MTK_MMSYS Say yes here to add support for the MediaTek Multimedia Subsystem (MMSYS). +config MTK_SVS + tristate "MediaTek Smart Voltage Scaling(SVS)" + depends on MTK_EFUSE && NVMEM + help + The Smart Voltage Scaling(SVS) engine is a piece of hardware + which has several controllers(banks) for calculating suitable + voltage to different power domains(CPU/GPU/CCI) according to + chip process corner, temperatures and other factors. Then DVFS + driver could apply SVS bank voltage to PMIC/Buck. + endmenu
drivers/soc/mediatek/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o obj-$(CONFIG_MTK_SCPSYS_PM_DOMAINS) += mtk-pm-domains.o obj-$(CONFIG_MTK_MMSYS) += mtk-mmsys.o +obj-$(CONFIG_MTK_SVS) += mtk-svs.o
drivers/soc/mediatek/mtk-svs.c new file +1702 -0
1,702 lines not on this page · raw message
Signature · 5 lines
2.18.0 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v11 4/7 soc: mediatek: SVS: add debug commands
In reply to Roger LuThe purpose of SVS is to help find the suitable voltages for DVFS. Therefore, if SVS bank voltages are concerned to be wrong, we can adjust SVS bank voltages by this patch.
--- drivers/soc/mediatek/mtk-svs.c | 325 +++++++++++++++++++++++++++++++++ 1 file changed, 325 insertions(+)
drivers/soc/mediatek/mtk-svs.c +325 -0
@@ -6,6 +6,7 @@#include <linux/bits.h> #include <linux/clk.h> #include <linux/completion.h> +#include <linux/debugfs.h> #include <linux/device.h> #include <linux/init.h> #include <linux/interrupt.h>
@@ -24,6 +25,7 @@#include <linux/pm_runtime.h> #include <linux/regulator/consumer.h> #include <linux/reset.h> +#include <linux/seq_file.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/thermal.h>
@@ -60,6 +62,39 @@#define SVSB_INTSTS_COMPLETE 0x1#define SVSB_INTSTS_CLEAN 0x00ffffff +#define debug_fops_ro (name) \ + static int svs_##name##_debug_open(struct inode *inode, \ + struct file *filp) \ + { \ + return single_open(filp, svs_##name##_debug_show, \ + inode->i_private); \ + } \ + static const struct file_operations svs_##name##_debug_fops = { \ + .owner = THIS_MODULE, \ + .open = svs_##name##_debug_open, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ + } + +#define debug_fops_rw (name) \ + static int svs_##name##_debug_open(struct inode *inode, \ + struct file *filp) \ + { \ + return single_open(filp, svs_##name##_debug_show, \ + inode->i_private); \ + } \ + static const struct file_operations svs_##name##_debug_fops = { \ + .owner = THIS_MODULE, \ + .open = svs_##name##_debug_open, \ + .read = seq_read, \ + .write = svs_##name##_debug_write, \ + .llseek = seq_lseek, \ + .release = single_release, \ + } + +#define svs_dentry (name) {__stringify(name), &svs_##name##_debug_fops} +static DEFINE_SPINLOCK (mtk_svs_lock);/*
@@ -138,6 +173,7 @@ enum svs_reg_index {SPARE2 ,SPARE3 ,THSLPEVEB , + SVS_REG_NUM, }; static const u32 svs_regs_v2[] = {
@@ -241,6 +277,7 @@ struct thermal_parameter {* @opp_volts: signed-off voltages from default opp table * @freqs_pct: percent of "opp_freqs / freq_base" for bank init * @volts: bank voltages +* @reg_data: bank register data of each phase * @freq_base: reference frequency for bank init * @vboot: voltage request for bank init01 stage only * @volt_step: bank voltage step
@@ -259,6 +296,7 @@ struct thermal_parameter {* @opp_count: bank opp count * @int_st: bank interrupt identification * @sw_id: bank software identification +* @hw_id: bank hardware identification * @ctl0: bank thermal sensor selection * @cpu_id: cpu core id for SVS CPU only *
@@ -284,6 +322,7 @@ struct svs_bank {u32 opp_volts[16 ];u32 freqs_pct[16 ];u32 volts[16 ]; +u32 reg_data[3 ][SVS_REG_NUM ];u32 freq_base;u32 vboot;u32 volt_step;
@@ -321,6 +360,7 @@ struct svs_bank {u32 opp_count;u32 int_st;u32 sw_id; +u32 hw_id;u32 ctl0;u32 cpu_id; };
@@ -636,11 +676,15 @@ static void svs_set_bank_phase(struct svs_platform *svsp,static inline void svs_init01_isr_handler (struct svs_platform *svsp) {struct svs_bank *svsb = svsp->pbank; +enum svs_reg_index rg_i;dev_info (svsb->dev,"%s: VDN74~30:0x%08x~0x%08x, DC:0x%08x\n" , __func__,svs_readl (svsp,VDESIGN74 ),svs_readl (svsp,VDESIGN30 ),svs_readl (svsp,DCVALUES )); +for (rg_i =DESCHAR ; rg_i <SVS_REG_NUM ; rg_i++) + svsb->reg_data[SVSB_PHASE_INIT01 ][rg_i] =svs_readl (svsp, rg_i); + svsb->phase =SVSB_PHASE_INIT01 ; svsb->dc_voffset_in = ~(svs_readl (svsp,DCVALUES ) &GENMASK (15 ,0 )) +1 ; if (svsb->init01_volt_flag == SVSB_INIT01_VOLT_IGNORE ||
@@ -660,11 +704,15 @@ static inline void svs_init01_isr_handler(struct svs_platform *svsp)static inline void svs_init02_isr_handler (struct svs_platform *svsp) {struct svs_bank *svsb = svsp->pbank; +enum svs_reg_index rg_i;dev_info (svsb->dev,"%s: VOP74~30:0x%08x~0x%08x, DC:0x%08x\n" , __func__,svs_readl (svsp,VOP74 ),svs_readl (svsp,VOP30 ),svs_readl (svsp,DCVALUES )); +for (rg_i =DESCHAR ; rg_i <SVS_REG_NUM ; rg_i++) + svsb->reg_data[SVSB_PHASE_INIT02 ][rg_i] =svs_readl (svsp, rg_i); + svsb->phase =SVSB_PHASE_INIT02 ; svsp->get_vops (svsp);
@@ -675,6 +723,10 @@ static inline void svs_init02_isr_handler(struct svs_platform *svsp)static inline void svs_mon_mode_isr_handler (struct svs_platform *svsp) {struct svs_bank *svsb = svsp->pbank; +enum svs_reg_index rg_i; + +for (rg_i =DESCHAR ; rg_i <SVS_REG_NUM ; rg_i++) + svsb->reg_data[SVSB_PHASE_MON ][rg_i] =svs_readl (svsp, rg_i); svsb->phase =SVSB_PHASE_MON ; svsb->temp =svs_readl (svsp,TEMP ) &GENMASK (7 ,0 );
@@ -686,6 +738,7 @@ static inline void svs_mon_mode_isr_handler(struct svs_platform *svsp)static inline void svs_error_isr_handler (struct svs_platform *svsp) {struct svs_bank *svsb = svsp->pbank; +enum svs_reg_index rg_i;dev_err (svsb->dev,"%s: CORESEL = 0x%08x\n" , __func__,svs_readl (svsp,CORESEL ));
@@ -695,6 +748,9 @@ static inline void svs_error_isr_handler(struct svs_platform *svsp) svs_readl(svsp, SMSTATE0), svs_readl(svsp, SMSTATE1));dev_err (svsb->dev,"TEMP = 0x%08x\n" ,svs_readl (svsp,TEMP )); +for (rg_i =DESCHAR ; rg_i <SVS_REG_NUM ; rg_i++) + svsb->reg_data[SVSB_PHASE_MON ][rg_i] =svs_readl (svsp, rg_i); + svsb->mode_support =SVSB_MODE_ALL_DISABLE ; svsb->phase =SVSB_PHASE_ERROR ;
@@ -1401,9 +1457,269 @@ static int svs_resume(struct device *dev)return 0 ; } +/* +* svs_dump_debug_show - dump svs/thermal efuse and svs banks' registers +*/ +static int svs_dump_debug_show (struct seq_file *m,void *p) +{ +struct svs_platform *svsp = (struct svs_platform *)m->private; +struct svs_bank *svsb; +unsigned long svs_reg_addr; +u32 idx, i, j; + +for (i =0 ; i < svsp->efuse_num; i++) +if (svsp->efuse && svsp->efuse[i]) +seq_printf (m,"M_HW_RES%d = 0x%08x\n" , + i, svsp->efuse[i]); + +for (i =0 ; i < svsp->tefuse_num; i++) +if (svsp->tefuse) +seq_printf (m,"THERMAL_EFUSE%d = 0x%08x\n" , + i, svsp->tefuse[i]); + +for (idx =0 ; idx < svsp->bank_num; idx++) { + svsb = &svsp->banks[idx]; + +for (i =SVSB_PHASE_INIT01 ; i <=SVSB_PHASE_MON ; i++) { +seq_printf (m,"Bank_number = %u\n" , svsb->hw_id); + +if (i <SVSB_PHASE_MON ) +seq_printf (m,"mode = init%d\n" , i +1 ); +else +seq_puts (m,"mode = mon\n" ); + +for (j =DESCHAR ; j <SVS_REG_NUM ; j++) { + svs_reg_addr = (unsigned long )(svsp->base + + svsp->regs[j]); +seq_printf (m,"0x%08lx = 0x%08x\n" , + svs_reg_addr, svsb->reg_data[i][j]); + } + } + } + +return 0 ; +} + +debug_fops_ro (dump); + +/* +* svs_enable_debug_show - show svs bank current enable phase +*/ +static int svs_enable_debug_show (struct seq_file *m,void *v) +{ +struct svs_bank *svsb = (struct svs_bank *)m->private; + +if (svsb->phase ==SVSB_PHASE_INIT01 ) +seq_puts (m,"init1\n" ); +else if (svsb->phase ==SVSB_PHASE_INIT02 ) +seq_puts (m,"init2\n" ); +else if (svsb->phase ==SVSB_PHASE_MON ) +seq_puts (m,"mon mode\n" ); +else if (svsb->phase ==SVSB_PHASE_ERROR ) +seq_puts (m,"disabled\n" ); +else +seq_puts (m,"unknown\n" ); + +return 0 ; +} + +/* +* svs_enable_debug_write - we only support svs bank disable control +*/ +static ssize_t svs_enable_debug_write (struct file *filp, +const char __user *buffer, +size_t count,loff_t *pos) +{ +struct svs_bank *svsb =file_inode (filp)->i_private; +struct svs_platform *svsp =dev_get_drvdata (svsb->dev); +unsigned long flags; +int enabled, ret; +char *buf =NULL ; + +if (count >=PAGE_SIZE ) +return -EINVAL ; + + buf = (char *)memdup_user_nul (buffer, count); +if (IS_ERR (buf)) +return PTR_ERR (buf); + + ret =kstrtoint (buf,10 , &enabled); +if (ret) +return ret; + +if (!enabled) { +spin_lock_irqsave (&mtk_svs_lock, flags); + svsp->pbank = svsb; + svsb->mode_support =SVSB_MODE_ALL_DISABLE ; +svs_switch_bank (svsp); +svs_writel (svsp,SVSB_EN_OFF ,SVSEN ); +svs_writel (svsp,SVSB_INTSTS_CLEAN ,INTSTS ); +spin_unlock_irqrestore (&mtk_svs_lock, flags); + + svsb->phase =SVSB_PHASE_ERROR ; +svs_adjust_pm_opp_volts (svsb, true); + } + +kfree (buf); + +return count; +} + +debug_fops_rw (enable); + +/* +* svs_status_debug_show - show svs bank's tzone_temp/voltages/freqs_pct +* and its corresponding opp-table's opp_freqs/opp_volts +*/ +static int svs_status_debug_show (struct seq_file *m,void *v) +{ +struct svs_bank *svsb = (struct svs_bank *)m->private; +struct dev_pm_opp *opp; +int tzone_temp, ret; +u32 i; + + ret =svs_get_bank_zone_temperature (svsb->tzone_name, &tzone_temp); +if (ret) +seq_printf (m,"%s: no \"%s\" zone?\n" , svsb->name, + svsb->tzone_name); +else +seq_printf (m,"%s: temperature = %d\n" , svsb->name, tzone_temp); + +for (i =0 ; i < svsb->opp_count; i++) { + opp =dev_pm_opp_find_freq_exact (svsb->opp_dev, + svsb->opp_freqs[i], true); +if (IS_ERR (opp)) { +seq_printf (m,"%s: cannot find freq = %u (%ld)\n" , + svsb->name, svsb->opp_freqs[i], +PTR_ERR (opp)); +return PTR_ERR (opp); + } + +seq_printf (m,"opp_freqs[%02u]: %u, opp_volts[%02u]: %lu, " , + i, svsb->opp_freqs[i], i, +dev_pm_opp_get_voltage (opp)); +seq_printf (m,"svsb_volts[%02u]: 0x%x, freqs_pct[%02u]: %u\n" , + i, svsb->volts[i], i, svsb->freqs_pct[i]); +dev_pm_opp_put (opp); + } + +return 0 ; +} + +debug_fops_ro (status); + +/* +* svs_volt_offset_debug_show - show svs bank's voltage offset +*/ +static int svs_volt_offset_debug_show (struct seq_file *m,void *v) +{ +struct svs_bank *svsb = (struct svs_bank *)m->private; + +seq_printf (m,"%d\n" , svsb->volt_offset); + +return 0 ; +} + +/* +* svs_volt_offset_debug_write - write svs bank's voltage offset +*/ +static ssize_t svs_volt_offset_debug_write (struct file *filp, +const char __user *buffer, +size_t count,loff_t *pos) +{ +struct svs_bank *svsb =file_inode (filp)->i_private; +char *buf =NULL ; +s32 volt_offset; + +if (count >=PAGE_SIZE ) +return -EINVAL ; + + buf = (char *)memdup_user_nul (buffer, count); +if (IS_ERR (buf)) +return PTR_ERR (buf); + +if (!kstrtoint (buf,10 , &volt_offset)) { + svsb->volt_offset = volt_offset; +svs_adjust_pm_opp_volts (svsb, true); + } + +kfree (buf); + +return count; +} + +debug_fops_rw (volt_offset); + +static int svs_create_svs_debug_cmds (struct svs_platform *svsp) +{ +struct svs_bank *svsb; +struct dentry *svs_dir, *svsb_dir, *file_entry; +const char *d ="/sys/kernel/debug/svs" ; +u32 i, idx; + +struct svs_dentry { +const char *name; +const struct file_operations *fops; + }; + +struct svs_dentry svs_entries[] = { +svs_dentry (dump), + }; + +struct svs_dentry svsb_entries[] = { +svs_dentry (enable), +svs_dentry (status), +svs_dentry (volt_offset), + }; + + svs_dir =debugfs_create_dir ("svs" ,NULL ); +if (IS_ERR (svs_dir)) { +dev_err (svsp->dev,"cannot create %s: %ld\n" , + d,PTR_ERR (svs_dir)); +return 0 ; + } + +for (i =0 ; i <ARRAY_SIZE (svs_entries); i++) { + file_entry =debugfs_create_file (svs_entries[i].name,0664 , + svs_dir, svsp, + svs_entries[i].fops); +if (IS_ERR (file_entry)) { +dev_err (svsp->dev,"cannot create %s/%s: %ld\n" , + d, svs_entries[i].name,PTR_ERR (file_entry)); +return PTR_ERR (file_entry); + } + } + +for (idx =0 ; idx < svsp->bank_num; idx++) { + svsb = &svsp->banks[idx]; + + svsb_dir =debugfs_create_dir (svsb->name, svs_dir); +if (IS_ERR (svsb_dir)) { +dev_err (svsp->dev,"cannot create %s/%s: %ld\n" , + d, svsb->name,PTR_ERR (svsb_dir)); +return PTR_ERR (svsb_dir); + } + +for (i =0 ; i <ARRAY_SIZE (svsb_entries); i++) { + file_entry =debugfs_create_file (svsb_entries[i].name, +0664 , svsb_dir, svsb, + svsb_entries[i].fops); +if (IS_ERR (file_entry)) { +dev_err (svsp->dev,"no %s/%s/%s?: %ld\n" , + d, svsb->name, svsb_entries[i].name, +PTR_ERR (file_entry)); +return PTR_ERR (file_entry); + } + } + } + +return 0 ; +} +static struct svs_bank svs_mt8183_banks[4 ] = { { .sw_id =SVSB_CPU_LITTLE , + .hw_id =0 , .cpu_id =0 , .tzone_name ="tzts4" , .buck_name ="proc" ,
@@ -1439,6 +1755,7 @@ static struct svs_bank svs_mt8183_banks[4] = { }, { .sw_id = SVSB_CPU_BIG, + .hw_id = 1, .cpu_id = 4, .tzone_name = "tzts5", .buck_name = "proc",
@@ -1474,6 +1791,7 @@ static struct svs_bank svs_mt8183_banks[4] = { }, { .sw_id = SVSB_CCI, + .hw_id = 2, .tzone_name = "tzts4", .buck_name = "proc", .pd_req = false,
@@ -1508,6 +1826,7 @@ static struct svs_bank svs_mt8183_banks[4] = { }, { .sw_id = SVSB_GPU, + .hw_id = 3, .tzone_name = "tzts2", .buck_name = "mali", .pd_req = true,
@@ -1673,6 +1992,12 @@ static int svs_probe(struct platform_device *pdev) goto svs_probe_iounmap; } + ret =svs_create_svs_debug_cmds (svsp); +if (ret) { +dev_err (svsp->dev,"svs create debug cmds fail: %d\n" , ret); + goto svs_probe_iounmap; + } +return 0 ; svs_probe_iounmap:
Signature · 5 lines
2.18.0 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v11 5/7 dt-bindings: soc: mediatek: add mt8192 svs dt-bindings
In reply to Roger Lu--- .../devicetree/bindings/soc/mediatek/mtk-svs.yaml | 9 +++++++++ 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml +9 -0
@@ -22,6 +22,7 @@ properties: compatible: enum: - mediatek,mt8183-svs + - mediatek,mt8192-svs reg: description: Address range of the MTK SVS controller.
@@ -47,6 +48,14 @@ properties: - const: svs-calibration-data - const: t-calibration-data + resets: + description: + svs reset control. + + reset-names: + items: + - const: svs_rst + required: - compatible - reg
Signature · 5 lines
2.18.0 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Rob Herring
maintainerRe: [PATCH v11 5/7] dt-bindings: soc: mediatek: add mt8192 svs dt-bindings
Quoted 18 lines · Roger Lu
Signed-off-by Roger Lu <[email protected]>--- .../devicetree/bindings/soc/mediatek/mtk-svs.yaml | 9 +++++++++ 1 file changed, 9 insertions(+)Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml +1
-0@@ -22,6 +22,7 @@ properties: compatible: enum: - mediatek,mt8183-svs + - mediatek,mt8192-svs reg: description: Address range of the MTK SVS controller.
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml properties: · line 53
Quoted 6 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml +3
-0@@ -47,6 +48,14 @@ properties: - const: svs-calibration-data - const: t-calibration-data + resets: + description: + svs reset control.
How many?
And you can drop the description given there's only 1.
Quoted 11 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-svs.yaml +5
-0+ + reset-names: + items: + - const: svs_rst + required: - compatible - regSignature · 1 line
2.18.0
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v11 6/7 arm64: dts: mt8192: add svs device information
In reply to Roger Luadd compitable/reg/irq/clock/efuse/reset setting in svs node
--- arch/arm64/boot/dts/mediatek/mt8192.dtsi | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
arch/arm64/boot/dts/mediatek/mt8192.dtsi +34 -0
@@ -224,6 +224,14 @@ compatible = "mediatek,mt8192-infracfg", "syscon"; reg = <0 0x10001000 0 0x1000>; #clock-cells = <1>; + + infracfg_rst: reset-controller { + compatible = "mediatek,infra-reset", "ti,syscon-reset"; + #reset-cells = <1>; + ti,reset-bits = < + 0x150 5 0x154 5 0 0 (ASSERT_SET | DEASSERT_SET | STATUS_NONE) /* 0: svs */ + >; + }; }; pericfg: syscon@10003000 {
@@ -318,6 +326,20 @@ status = "disabled"; }; + svs: svs@1100b000 { + compatible = "mediatek,mt8192-svs"; + reg = <0 0x1100b000 0 0x1000>; + interrupts = <GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&infracfg CLK_INFRA_THERM>; + clock-names = "main"; + nvmem-cells = <&svs_calibration>, + <&lvts_e_data1>; + nvmem-cell-names = "svs-calibration-data", + "t-calibration-data"; + resets = <&infracfg_rst 0>; + reset-names = "svs_rst"; + }; + spi1: spi@11010000 { compatible = "mediatek,mt8192-spi", "mediatek,mt6765-spi";
@@ -422,6 +444,18 @@ #clock-cells = <1>; }; + efuse: efuse@11c10000 { + compatible = "mediatek,efuse"; + reg = <0 0x11c10000 0 0x1000>; + + lvts_e_data1: data1 { + reg = <0x1C0 0x58>; + }; + svs_calibration: calib@580 { + reg = <0x580 0x68>; + }; + }; + i2c3: i2c3@11cb0000 { compatible = "mediatek,mt8192-i2c"; reg = <0 0x11cb0000 0 0x1000>,
Signature · 5 lines
2.18.0 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v11 7/7 soc: mediatek: SVS: add mt8192 SVS GPU driver
In reply to Roger Lu--- drivers/soc/mediatek/mtk-svs.c | 477 ++++++++++++++++++++++++++++++++- 1 file changed, 471 insertions(+), 6 deletions(-)
drivers/soc/mediatek/mtk-svs.c +471 -6
@@ -36,6 +36,10 @@#define SVSB_CCI BIT(2)#define SVSB_GPU BIT(3) +/* svs bank 2-line type */ +#define SVSB_LOW BIT(4) +#define SVSB_HIGH BIT(5) +/* svs bank mode support */ #define SVSB_MODE_ALL_DISABLE 0#define SVSB_MODE_INIT01 BIT(1)
@@ -279,6 +283,7 @@ struct thermal_parameter {* @volts: bank voltages * @reg_data: bank register data of each phase * @freq_base: reference frequency for bank init +* @turn_freq_base: refenrece frequency for turn point * @vboot: voltage request for bank init01 stage only * @volt_step: bank voltage step * @volt_base: bank voltage base
@@ -299,6 +304,8 @@ struct thermal_parameter {* @hw_id: bank hardware identification * @ctl0: bank thermal sensor selection * @cpu_id: cpu core id for SVS CPU only +* @turn_pt: turn point informs which opp_volt calculated by high/low bank. +* @type: bank type to represent it is 2-line (high/low) bank or 1-line bank. * * Other structure members which are not listed above are svs platform * efuse data for bank init
@@ -324,6 +331,7 @@ struct svs_bank {u32 volts[16 ];u32 reg_data[3 ][SVS_REG_NUM ];u32 freq_base; +u32 turn_freq_base;u32 vboot;u32 volt_step;u32 volt_base;
@@ -363,6 +371,8 @@ struct svs_bank {u32 hw_id;u32 ctl0;u32 cpu_id; +u32 turn_pt; +u32 type; };/*
@@ -440,6 +450,37 @@ static u32 svs_bank_volt_to_opp_volt(u32 svsb_volt, u32 svsb_volt_step,return (svsb_volt * svsb_volt_step) + svsb_volt_base; } +static u32 svs_opp_volt_to_bank_volt (u32 opp_u_volt,u32 svsb_volt_step, +u32 svsb_volt_base) +{ +return (opp_u_volt - svsb_volt_base) / svsb_volt_step; +} + +static int svs_sync_bank_volts_from_opp (struct svs_bank *svsb) +{ +struct dev_pm_opp *opp; +u32 i, opp_u_volt; + +for (i =0 ; i < svsb->opp_count; i++) { + opp =dev_pm_opp_find_freq_exact (svsb->opp_dev, + svsb->opp_freqs[i], + true); +if (IS_ERR (opp)) { +dev_err (svsb->dev,"cannot find freq = %u (%ld)\n" , + svsb->opp_freqs[i],PTR_ERR (opp)); +return PTR_ERR (opp); + } + + opp_u_volt =dev_pm_opp_get_voltage (opp); + svsb->volts[i] =svs_opp_volt_to_bank_volt (opp_u_volt, + svsb->volt_step, + svsb->volt_base); +dev_pm_opp_put (opp); + } + +return 0 ; +} +static int svs_get_bank_zone_temperature (const char *tzone_name,int *tzone_temp) {
@@ -455,7 +496,7 @@ static int svs_get_bank_zone_temperature(const char *tzone_name,static int svs_adjust_pm_opp_volts (struct svs_bank *svsb,bool force_update) {int tzone_temp, ret = -EPERM ; -u32 i, svsb_volt, opp_volt, temp_offset =0 ; +u32 i, svsb_volt, opp_volt, temp_offset =0 , opp_start, opp_stop;mutex_lock (&svsb->lock);
@@ -469,6 +510,21 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svsb, bool force_update) goto unlock_mutex; } +/* +* 2-line bank updates its corresponding opp volts. +* 1-line bank updates all opp volts. +*/ +if (svsb->type ==SVSB_HIGH ) { + opp_start =0 ; + opp_stop = svsb->turn_pt; + }else if (svsb->type ==SVSB_LOW ) { + opp_start = svsb->turn_pt; + opp_stop = svsb->opp_count; + }else { + opp_start =0 ; + opp_stop = svsb->opp_count; + } +/* Get thermal effect */ if (svsb->phase ==SVSB_PHASE_MON ) { if (svsb->temp > svsb->temp_upper_bound &&
@@ -490,10 +546,16 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svsb, bool force_update) temp_offset += svsb->tzone_high_temp_offset; else if (tzone_temp <= svsb->tzone_low_temp) temp_offset += svsb->tzone_low_temp_offset; + +/* 2-line bank takes thermal factor to update all opp volts */ +if (svsb->type ==SVSB_HIGH || svsb->type ==SVSB_LOW ) { + opp_start =0 ; + opp_stop = svsb->opp_count; + } }/* vmin <= svsb_volt (opp_volt) <= signed-off (default) voltage */ -for (i =0 ; i < svsb->opp_count; i++) { +for (i = opp_start; i < opp_stop; i++) {if (svsb->phase ==SVSB_PHASE_MON ) { svsb_volt =max (svsb->volts[i] + svsb->volt_offset + temp_offset, svsb->vmin);
@@ -544,6 +606,181 @@ static u32 interpolate(u32 f0, u32 f1, u32 v0, u32 v1, u32 fx)return DIV_ROUND_UP (vy,100 ); } +static void svs_get_vops_v3 (struct svs_platform *svsp) +{ +struct svs_bank *svsb = svsp->pbank; +u32 i, vop_i, *vop, vop74, vop30, mask7_0 =GENMASK (7 ,0 ); +u32 b_sft, bits8 =8 , shift_byte =0 , reg_4bytes =4 ; +u32 middle_index = (svsb->opp_count /2 ); +u32 opp_start =0 , opp_stop =0 , turn_pt = svsb->turn_pt; + +/* get vops v3 doesn't use mon mode voltages */ +if (svsb->phase ==SVSB_PHASE_MON ) +return ; + + vop74 =svs_readl (svsp,VOP74 ); + vop30 =svs_readl (svsp,VOP30 ); + +if (turn_pt < middle_index) { +if (svsb->type ==SVSB_HIGH ) { +/* We attain volts[0 ~ (turn_pt - 1)] */ +for (i =0 ; i < turn_pt; i++) { + b_sft = bits8 * (shift_byte % reg_4bytes); + vop = (shift_byte < reg_4bytes) ? &vop30 : + &vop74; + svsb->volts[i] = (*vop >> b_sft) & mask7_0; + shift_byte++; + } + }else if (svsb->type ==SVSB_LOW ) { +/* +* We attain volts[turn_pt] + +* volts[vop_i ~ (opp_count - 1)] +*/ + vop_i = svsb->opp_count -7 ; + svsb->volts[turn_pt] = vop30 & mask7_0; + shift_byte++; +for (i = vop_i; i < svsb->opp_count; i++) { + b_sft = bits8 * (shift_byte % reg_4bytes); + vop = (shift_byte < reg_4bytes) ? &vop30 : + &vop74; + svsb->volts[i] = (*vop >> b_sft) & mask7_0; + shift_byte++; + } + +/* +* We attain volts[turn_pt + 1 ~ (vop_i - 1)] +* by interpolate +*/ +for (i = turn_pt +1 ; i < vop_i; i++) + svsb->volts[i] = +interpolate (svsb->freqs_pct[turn_pt], + svsb->freqs_pct[vop_i], + svsb->volts[turn_pt], + svsb->volts[vop_i], + svsb->freqs_pct[i]); + } + }else { +if (svsb->type ==SVSB_HIGH ) { +/* We attain volts[0] + volts[vop_i ~ (turn_pt - 1)] */ + vop_i = turn_pt -7 ; + svsb->volts[0 ] = vop30 & mask7_0; + shift_byte++; +for (i = vop_i; i < turn_pt; i++) { + b_sft = bits8 * (shift_byte % reg_4bytes); + vop = (shift_byte < reg_4bytes) ? &vop30 : + &vop74; + svsb->volts[i] = (*vop >> b_sft) & mask7_0; + shift_byte++; + } + +/* We attain volts[1 ~ (vop_i - 1)] by interpolate */ +for (i =1 ; i < vop_i; i++) + svsb->volts[i] = +interpolate (svsb->freqs_pct[0 ], + svsb->freqs_pct[vop_i], + svsb->volts[0 ], + svsb->volts[vop_i], + svsb->freqs_pct[i]); + }else if (svsb->type ==SVSB_LOW ) { +/* We attain volts[turn_pt ~ (opp_count - 1)] */ +for (i = turn_pt; i < svsb->opp_count; i++) { + b_sft = bits8 * (shift_byte % reg_4bytes); + vop = (shift_byte < reg_4bytes) ? &vop30 : + &vop74; + svsb->volts[i] = (*vop >> b_sft) & mask7_0; + shift_byte++; + } + } + } + +if (svsb->type ==SVSB_HIGH ) { + opp_start =0 ; + opp_stop = svsb->turn_pt; + }else if (svsb->type ==SVSB_LOW ) { + opp_start = svsb->turn_pt; + opp_stop = svsb->opp_count; + } + +for (i = opp_start; i < opp_stop; i++) + svsb->volts[i] -= svsb->dvt_fixed; +} + +static void svs_set_freqs_pct_v3 (struct svs_platform *svsp) +{ +struct svs_bank *svsb = svsp->pbank; +u32 i, freq_i, *freq_pct, freq_pct74 =0 , freq_pct30 =0 ; +u32 b_sft, bits8 =8 , shift_byte =0 , reg_4bytes =4 ; +u32 middle_index = (svsb->opp_count /2 ), mask7_0 =GENMASK (7 ,0 ); +u32 turn_pt = middle_index; + +for (i =0 ; i < svsb->opp_count; i++) { +if (svsb->opp_freqs[i] <= svsb->turn_freq_base) { + svsb->turn_pt = i; +break ; + } + } + + turn_pt = svsb->turn_pt; + +/* Target is to fill out freq_pct74 / freq_pct30 */ +if (turn_pt < middle_index) { +if (svsb->type ==SVSB_HIGH ) { +/* We select freqs_pct[0 ~ (turn_pt - 1)] */ +for (i =0 ; i < turn_pt; i++) { + b_sft = bits8 * (shift_byte % reg_4bytes); + freq_pct = (shift_byte < reg_4bytes) ? + &freq_pct30 : &freq_pct74; + *freq_pct |= (svsb->freqs_pct[i] << b_sft); + shift_byte++; + } + }else if (svsb->type ==SVSB_LOW ) { +/* +* We select freqs_pct[turn_pt] + +* freqs_pct[(opp_count - 7) ~ (opp_count -1)] +*/ + freq_pct30 = svsb->freqs_pct[turn_pt] & mask7_0; + shift_byte++; + freq_i = svsb->opp_count -7 ; +for (i = freq_i; i < svsb->opp_count; i++) { + b_sft = bits8 * (shift_byte % reg_4bytes); + freq_pct = (shift_byte < reg_4bytes) ? + &freq_pct30 : &freq_pct74; + *freq_pct |= (svsb->freqs_pct[i] << b_sft); + shift_byte++; + } + } + }else { +if (svsb->type ==SVSB_HIGH ) { +/* +* We select freqs_pct[0] + +* freqs_pct[(turn_pt - 7) ~ (turn_pt - 1)] +*/ + freq_pct30 = svsb->freqs_pct[0 ] & mask7_0; + shift_byte++; + freq_i = turn_pt -7 ; +for (i = freq_i; i < turn_pt; i++) { + b_sft = bits8 * (shift_byte % reg_4bytes); + freq_pct = (shift_byte < reg_4bytes) ? + &freq_pct30 : &freq_pct74; + *freq_pct |= (svsb->freqs_pct[i] << b_sft); + shift_byte++; + } + }else if (svsb->type ==SVSB_LOW ) { +/* We select freqs_pct[turn_pt ~ (opp_count - 1)] */ +for (i = turn_pt; i < svsb->opp_count; i++) { + b_sft = bits8 * (shift_byte % reg_4bytes); + freq_pct = (shift_byte < reg_4bytes) ? + &freq_pct30 : &freq_pct74; + *freq_pct |= (svsb->freqs_pct[i] << b_sft); + shift_byte++; + } + } + } + +svs_writel (svsp, freq_pct74,FREQPCT74 ); +svs_writel (svsp, freq_pct30,FREQPCT30 ); +} +static void svs_get_vops_v2 (struct svs_platform *svsp) {struct svs_bank *svsb = svsp->pbank;
@@ -855,6 +1092,25 @@ static int svs_init02(struct svs_platform *svsp) } } +/* +* 2-line high/low bank update its corresponding opp voltages only. +* Therefore, we sync voltages from opp for high/low bank voltages +* consistency. +*/ +for (idx =0 ; idx < svsp->bank_num; idx++) { + svsb = &svsp->banks[idx]; + +if (!(svsb->mode_support &SVSB_MODE_INIT02 )) +continue ; + +if (svsb->type ==SVSB_HIGH || svsb->type ==SVSB_LOW ) { +if (svs_sync_bank_volts_from_opp (svsb)) { +dev_err (svsb->dev,"sync volt fail\n" ); +return -EPERM ; + } + } + } +return 0 ; }
@@ -1098,7 +1354,12 @@ static int svs_resource_setup(struct svs_platform *svsp) svsb->name ="SVSB_CCI" ;break ;case SVSB_GPU : - svsb->name ="SVSB_GPU" ; +if (svsb->type ==SVSB_HIGH ) + svsb->name ="SVSB_GPU_HIGH" ; +else if (svsb->type ==SVSB_LOW ) + svsb->name ="SVSB_GPU_LOW" ; +else + svsb->name ="SVSB_GPU" ;break ;default :WARN_ON (1 );
@@ -1160,6 +1421,88 @@ static int svs_resource_setup(struct svs_platform *svsp)return 0 ; } +static bool svs_mt8192_efuse_parsing (struct svs_platform *svsp) +{ +struct svs_bank *svsb; +struct nvmem_cell *cell; +u32 idx, i, ft_pgm, vmin, golden_temp; + +for (i =0 ; i < svsp->efuse_num; i++) +if (svsp->efuse[i]) +dev_info (svsp->dev,"M_HW_RES%d: 0x%08x\n" , + i, svsp->efuse[i]); + +/* Svs efuse parsing */ + ft_pgm = svsp->efuse[0 ] &GENMASK (7 ,0 ); + vmin = (svsp->efuse[19 ] >>4 ) &GENMASK (1 ,0 ); + +for (idx =0 ; idx < svsp->bank_num; idx++) { + svsb = &svsp->banks[idx]; + +if (svsb->sw_id !=SVSB_GPU ) +return false; + +if (vmin ==0x1 ) + svsb->vmin =0x1e ; + +if (ft_pgm ==0 ) + svsb->init01_volt_flag =SVSB_INIT01_VOLT_IGNORE ; + +if (svsb->type ==SVSB_LOW ) { + svsb->mtdes = svsp->efuse[10 ] &GENMASK (7 ,0 ); + svsb->bdes = (svsp->efuse[10 ] >>16 ) &GENMASK (7 ,0 ); + svsb->mdes = (svsp->efuse[10 ] >>24 ) &GENMASK (7 ,0 ); + svsb->dcbdet = (svsp->efuse[17 ]) &GENMASK (7 ,0 ); + svsb->dcmdet = (svsp->efuse[17 ] >>8 ) &GENMASK (7 ,0 ); + svsb->vmax += svsb->dvt_fixed; + }else if (svsb->type ==SVSB_HIGH ) { + svsb->mtdes = svsp->efuse[9 ] &GENMASK (7 ,0 ); + svsb->bdes = (svsp->efuse[9 ] >>16 ) &GENMASK (7 ,0 ); + svsb->mdes = (svsp->efuse[9 ] >>24 ) &GENMASK (7 ,0 ); + svsb->dcbdet = (svsp->efuse[17 ] >>16 ) &GENMASK (7 ,0 ); + svsb->dcmdet = (svsp->efuse[17 ] >>24 ) &GENMASK (7 ,0 ); + svsb->vmax += svsb->dvt_fixed; + } + } + +/* Thermal efuse parsing */ + cell =nvmem_cell_get (svsp->dev,"t-calibration-data" ); +if (IS_ERR_OR_NULL (cell)) { +dev_err (svsp->dev,"no thermal cell, no mon mode\n" ); +for (idx =0 ; idx < svsp->bank_num; idx++) { + svsb = &svsp->banks[idx]; + svsb->mode_support &= ~SVSB_MODE_MON ; + } + +return true; + } + + svsp->tefuse =nvmem_cell_read (cell, &svsp->tefuse_num); + svsp->tefuse_num /=sizeof (u32); +nvmem_cell_put (cell); + +for (i =0 ; i < svsp->tefuse_num; i++) +if (svsp->tefuse[i] !=0 ) +break ; + +if (i == svsp->tefuse_num) + golden_temp =50 ;/* All thermal efuse data are 0 */ +else + golden_temp = (svsp->tefuse[0 ] >>24 ) &GENMASK (7 ,0 ); + +for (idx =0 ; idx < svsp->bank_num; idx++) { + svsb = &svsp->banks[idx]; + +if (svsb->sw_id !=SVSB_GPU ) +return false; + + svsb->mts =500 ; + svsb->bts = (((500 * golden_temp +250460 ) /1000 ) -25 ) *4 ; + } + +return true; +} +static bool svs_mt8183_efuse_parsing (struct svs_platform *svsp) {struct thermal_parameter tp;
@@ -1580,10 +1923,11 @@ static int svs_status_debug_show(struct seq_file *m, void *v) ret =svs_get_bank_zone_temperature (svsb->tzone_name, &tzone_temp);if (ret) -seq_printf (m,"%s: no \"%s\" zone?\n" , svsb->name, - svsb->tzone_name); +seq_printf (m,"%s: no \"%s\" zone? turn_pt = %u\n" , + svsb->name, svsb->tzone_name, svsb->turn_pt);else -seq_printf (m,"%s: temperature = %d\n" , svsb->name, tzone_temp); +seq_printf (m,"%s: temperature = %d, turn_pt = %u\n" , + svsb->name, tzone_temp, svsb->turn_pt);for (i =0 ; i < svsb->opp_count; i++) { opp = dev_pm_opp_find_freq_exact(svsb->opp_dev,
@@ -1716,6 +2060,82 @@ static int svs_create_svs_debug_cmds(struct svs_platform *svsp)return 0 ; } +static struct svs_bank svs_mt8192_banks[2 ] = { + { + .sw_id =SVSB_GPU , + .hw_id =0 , + .tzone_name ="gpu1" , + .buck_name ="mali" , + .mode_support =SVSB_MODE_INIT02 , + .opp_count =16 , + .freq_base =688000000 , + .turn_freq_base =688000000 , + .vboot =0x38 , + .volt_step =6250 , + .volt_base =400000 , + .volt_offset =0 , + .vmax =0x60 , + .vmin =0x1a , + .dthi =0x1 , + .dtlo =0xfe , + .det_window =0xa28 , + .det_max =0xffff , + .age_config =0x555555 , + .agem =0 , + .dc_config =0x1 , + .dvt_fixed =0x1 , + .vco =0x18 , + .chk_shift =0x87 , + .temp_upper_bound =0x64 , + .temp_lower_bound =0xb2 , + .tzone_high_temp =85000 , + .tzone_high_temp_offset =0 , + .tzone_low_temp =25000 , + .tzone_low_temp_offset =7 , + .core_sel =0x0fff0100 , + .int_st =BIT (0 ), + .ctl0 =0x00540003 , + .type =SVSB_LOW , + }, + { + .sw_id =SVSB_GPU , + .hw_id =1 , + .tzone_name ="gpu1" , + .buck_name ="mali" , + .pd_req = false, + .mode_support =SVSB_MODE_INIT02 |SVSB_MODE_MON , + .opp_count =16 , + .freq_base =902000000 , + .turn_freq_base =688000000 , + .vboot =0x38 , + .volt_step =6250 , + .volt_base =400000 , + .volt_offset =0 , + .vmax =0x60 , + .vmin =0x1a , + .dthi =0x1 , + .dtlo =0xfe , + .det_window =0xa28 , + .det_max =0xffff , + .age_config =0x555555 , + .agem =0 , + .dc_config =0x1 , + .dvt_fixed =0x6 , + .vco =0x18 , + .chk_shift =0x87 , + .temp_upper_bound =0x64 , + .temp_lower_bound =0xb2 , + .tzone_high_temp =85000 , + .tzone_high_temp_offset =0 , + .tzone_low_temp =25000 , + .tzone_low_temp_offset =7 , + .core_sel =0x0fff0101 , + .int_st =BIT (1 ), + .ctl0 =0x00540003 , + .type =SVSB_HIGH , + }, +}; +static struct svs_bank svs_mt8183_banks[4 ] = { { .sw_id =SVSB_CPU_LITTLE ,
@@ -1862,6 +2282,48 @@ static struct svs_bank svs_mt8183_banks[4] = { }, }; +static int svs_get_svs_mt8192_platform_data (struct svs_platform *svsp) +{ +struct device *dev; +struct svs_bank *svsb; +u32 idx; + + svsp->name ="mt8192-svs" , + svsp->banks = svs_mt8192_banks, + svsp->efuse_parsing = svs_mt8192_efuse_parsing, + svsp->set_freqs_pct = svs_set_freqs_pct_v3, + svsp->get_vops = svs_get_vops_v3, + svsp->regs = svs_regs_v2, + svsp->irqflags =IRQF_TRIGGER_HIGH |IRQF_ONESHOT , + svsp->bank_num =2 , + svsp->efuse_check =9 , + + svsp->rst =devm_reset_control_get_optional (svsp->dev,"svs_rst" ); +if (IS_ERR (svsp->rst)) { +dev_err_probe (svsp->dev,PTR_ERR (svsp->rst), +"cannot get svs reset control\n" ); +return PTR_ERR (svsp->rst); + } + + dev =svs_add_device_link (svsp,"lvts" ); +if (IS_ERR (dev)) +return PTR_ERR (dev); + +for (idx =0 ; idx < svsp->bank_num; idx++) { + svsb = &svsp->banks[idx]; + +if (svsb->type ==SVSB_HIGH ) + svsb->opp_dev =svs_add_device_link (svsp,"mali" ); +else if (svsb->type ==SVSB_LOW ) + svsb->opp_dev =svs_get_subsys_device (svsp,"mali" ); + +if (IS_ERR (svsb->opp_dev)) +return PTR_ERR (svsb->opp_dev); + } + +return 0 ; +} +static int svs_get_svs_mt8183_platform_data (struct svs_platform *svsp) {struct device *dev;
@@ -1917,6 +2379,9 @@ static const struct of_device_id mtk_svs_of_match[] = { { .compatible = "mediatek,mt8183-svs", .data = &svs_get_svs_mt8183_platform_data, + }, { + .compatible = "mediatek,mt8192-svs", + .data = &svs_get_svs_mt8192_platform_data, }, { /* Sentinel */ },
Signature · 5 lines
2.18.0 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek