Skip to contentSkip to conversation

soc: mediatek: mtk-svs: refactor and cleanup the driver

PATCH In review [email protected] 3 participants 20 messages Sep 28, 2022 – Oct 6, 2022 Arm MediaTek

lore
Share & tools
lore
#0 lore raw

cover soc: mediatek: mtk-svs: refactor and cleanup the driver

From: Matthias Brugger <[email protected]>

Mediatek SVS driver got accepted upstream but has coding style issues which were overseen in the review process. This series is a first step to clean up the driver. It basically cleans up the SoC specific probe. As next step we will need to clean up the 'struct svs_bank'.

This series should be a mere cleanup with no functional change. I'm happy to recieve tested-by tags to make sure it does not break anything.

Matthias Brugger (8):
soc: mediatek: mtk-svs: clean up platform probing
soc: mediatek: mtk-svs: improve readability of platform_probe
soc: mediatek: mtk-svs: move svs_platform_probe into probe
soc: mediatek: mtk-svs: delete superfluous platform data entries
soc: mediatek: mtk-svs: Move SoC specific functions to new files
soc: mtk-svs: mt8183: Move thermal parsing in new function
soc: mtk-svs: mt8183: refactor o_slope calculation
soc: mtk-svs: mt8192: fix bank data

 drivers/soc/mediatek/Makefile         |   3 +-
 drivers/soc/mediatek/mt8183-svs.h     | 113 ++++
 drivers/soc/mediatek/mt8192-svs.h     |  64 ++
 drivers/soc/mediatek/mtk-svs-mt8183.c | 235 +++++++
 drivers/soc/mediatek/mtk-svs-mt8192.c |  98 +++
 drivers/soc/mediatek/mtk-svs.c        | 882 ++------------------------
 drivers/soc/mediatek/mtk-svs.h        | 279 ++++++++
 7 files changed, 853 insertions(+), 821 deletions(-)
 create mode 100644 drivers/soc/mediatek/mt8183-svs.h
 create mode 100644 drivers/soc/mediatek/mt8192-svs.h
 create mode 100644 drivers/soc/mediatek/mtk-svs-mt8183.c
 create mode 100644 drivers/soc/mediatek/mtk-svs-mt8192.c
 create mode 100644 drivers/soc/mediatek/mtk-svs.h
Signature · 1 line
2.37.3
#1 lore raw

PATCH 1/8 soc: mediatek: mtk-svs: clean up platform probing

From: Matthias Brugger <[email protected]>

We only ever call the SoC specific probe function from svs_platform_probe. No need to carry that function in a global datastructure around.

---

 drivers/soc/mediatek/mtk-svs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/soc/mediatek/mtk-svs.c +1 -4
index 0469c9dfeb04..fd0f636e8644 100644
@@ -319,7 +319,6 @@ static const u32 svs_regs_v2[] = {
  * @banks: svs banks that svs platform supports
  * @rst: svs platform reset control
  * @efuse_parsing: svs platform efuse parsing function pointer
- * @probe: svs platform probe function pointer
  * @efuse_max: total number of svs efuse
  * @tefuse_max: total number of thermal efuse
  * @regs: svs platform registers map
@@ -336,7 +335,6 @@ struct svs_platform {
 	struct svs_bank *banks;
 	struct reset_control *rst;
 	bool (*efuse_parsing)(struct svs_platform *svsp);
-	int (*probe)(struct svs_platform *svsp);
 	size_t efuse_max;
 	size_t tefuse_max;
 	const u32 *regs;
@@ -2347,11 +2345,10 @@ static struct svs_platform *svs_platform_probe(struct platform_device *pdev)
 	svsp->name = svsp_data->name;
 	svsp->banks = svsp_data->banks;
 	svsp->efuse_parsing = svsp_data->efuse_parsing;
-	svsp->probe = svsp_data->probe;
 	svsp->regs = svsp_data->regs;
 	svsp->bank_max = svsp_data->bank_max;
 
-	ret = svsp->probe(svsp);
+	ret = svsp_data->probe(svsp);
 	if (ret)
 		return ERR_PTR(ret);
 
Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 1/8
#2 lore raw

Re: [PATCH 1/8] soc: mediatek: mtk-svs: clean up platform probing

Il 28/09/22 17:55, [email protected] ha scritto:

Quoted 7 lines

From: Matthias Brugger <[email protected]>

We only ever call the SoC specific probe function from svs_platform_probe. No need to carry that function in a global datastructure around.

#3 lore raw

PATCH 2/8 soc: mediatek: mtk-svs: improve readability of platform_probe

In reply to [email protected]

From: Matthias Brugger <[email protected]>

If a compatible misses a match data entry, then something is wrong in the development phase, we don't need to check for that at runtime.

---

 drivers/soc/mediatek/mtk-svs.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/soc/mediatek/mtk-svs.c +0 -4
index fd0f636e8644..52bb4f8bbe6d 100644
@@ -2332,10 +2332,6 @@ static struct svs_platform *svs_platform_probe(struct platform_device *pdev)
 	int ret;
 
 	svsp_data = of_device_get_match_data(&pdev->dev);
-	if (!svsp_data) {
-		dev_err(&pdev->dev, "no svs platform data?\n");
-		return ERR_PTR(-EPERM);
-	}
 
 	svsp = devm_kzalloc(&pdev->dev, sizeof(*svsp), GFP_KERNEL);
 	if (!svsp)
Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 2/8
#4 lore raw

Re: [PATCH 2/8] soc: mediatek: mtk-svs: improve readability of platform_probe

Il 28/09/22 17:55, [email protected] ha scritto:

Quoted 16 lines

From: Matthias Brugger <[email protected]>

If a compatible misses a match data entry, then something is wrong in the development phase, we don't need to check for that at runtime.

---

  drivers/soc/mediatek/mtk-svs.c | 4 ----
  1 file changed, 4 deletions(-)
drivers/soc/mediatek/mtk-svs.c +0 -0
index fd0f636e8644..52bb4f8bbe6d 100644

drivers/soc/mediatek/mtk-svs.c static struct svs_platform *svs_platform_probe(struct platform_device *pdev) · line 2334

Quoted 3 lines
drivers/soc/mediatek/mtk-svs.c +0 -0
@@ -2332,10 +2332,6 @@ static struct svs_platform *svs_platform_probe(struct platform_device *pdev)
  	int ret;
 
  	svsp_data = of_device_get_match_data(&pdev->dev);

Changing that to device_get_match_data() (so, dropping of_) would be a plus to this cleanup, perhaps...

In any case:

Quoted 7 lines
drivers/soc/mediatek/mtk-svs.c +0 -4
-	if (!svsp_data) {
-		dev_err(&pdev->dev, "no svs platform data?\n");
-		return ERR_PTR(-EPERM);
-	}
 
  	svsp = devm_kzalloc(&pdev->dev, sizeof(*svsp), GFP_KERNEL);
  	if (!svsp)
#5 lore raw

PATCH 3/8 soc: mediatek: mtk-svs: move svs_platform_probe into probe

In reply to [email protected]

From: Matthias Brugger <[email protected]>

Moving svs_platform_probe into driver probe function will allow us to reduce svs_platform members. This will be done in a follow-up patch.

---

 drivers/soc/mediatek/mtk-svs.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/soc/mediatek/mtk-svs.c +4 -16
index 52bb4f8bbe6d..8342627f8dea 100644
@@ -2325,17 +2325,17 @@ static const struct of_device_id svs_of_match[] = {
 	},
 };
 
-static struct svs_platform *svs_platform_probe(struct platform_device *pdev)
+static int svs_probe(struct platform_device *pdev)
 {
 	struct svs_platform *svsp;
 	const struct svs_platform_data *svsp_data;
-	int ret;
+	int ret, svsp_irq;
 
 	svsp_data = of_device_get_match_data(&pdev->dev);
 
 	svsp = devm_kzalloc(&pdev->dev, sizeof(*svsp), GFP_KERNEL);
 	if (!svsp)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
 	svsp->dev = &pdev->dev;
 	svsp->name = svsp_data->name;
@@ -2346,19 +2346,7 @@ static struct svs_platform *svs_platform_probe(struct platform_device *pdev)
 
 	ret = svsp_data->probe(svsp);
 	if (ret)
-		return ERR_PTR(ret);
-
-	return svsp;
-}
-
-static int svs_probe(struct platform_device *pdev)
-{
-	struct svs_platform *svsp;
-	int svsp_irq, ret;
-
-	svsp = svs_platform_probe(pdev);
-	if (IS_ERR(svsp))
-		return PTR_ERR(svsp);
+		return ret;
 
 	if (!svs_is_efuse_data_correct(svsp)) {
 		dev_notice(svsp->dev, "efuse data isn't correct\n");
Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 3/8
#6 lore raw

Re: [PATCH 3/8] soc: mediatek: mtk-svs: move svs_platform_probe into probe

Il 28/09/22 17:55, [email protected] ha scritto:

Quoted 6 lines

From: Matthias Brugger <[email protected]>

Moving svs_platform_probe into driver probe function will allow us to reduce svs_platform members. This will be done in a follow-up patch.

#7 lore raw

PATCH 4/8 soc: mediatek: mtk-svs: delete superfluous platform data entries

In reply to [email protected]

From: Matthias Brugger <[email protected]>

The platform name and efuse parsing function pointer are only used while probing the device. Use them from the svs_platform_data struct instead.

---

 drivers/soc/mediatek/mtk-svs.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/soc/mediatek/mtk-svs.c +12 -10
index 8342627f8dea..482cc8d7e7cf 100644
@@ -311,14 +311,12 @@ static const u32 svs_regs_v2[] = {
 
 /**
  * struct svs_platform - svs platform control
- * @name: svs platform name
  * @base: svs platform register base
  * @dev: svs platform device
  * @main_clk: main clock for svs bank
  * @pbank: svs bank pointer needing to be protected by spin_lock section
  * @banks: svs banks that svs platform supports
  * @rst: svs platform reset control
- * @efuse_parsing: svs platform efuse parsing function pointer
  * @efuse_max: total number of svs efuse
  * @tefuse_max: total number of thermal efuse
  * @regs: svs platform registers map
@@ -327,14 +325,12 @@ static const u32 svs_regs_v2[] = {
  * @tefuse: thermal efuse data received from NVMEM framework
  */
 struct svs_platform {
-	char *name;
 	void __iomem *base;
 	struct device *dev;
 	struct clk *main_clk;
 	struct svs_bank *pbank;
 	struct svs_bank *banks;
 	struct reset_control *rst;
-	bool (*efuse_parsing)(struct svs_platform *svsp);
 	size_t efuse_max;
 	size_t tefuse_max;
 	const u32 *regs;
@@ -2009,7 +2005,7 @@ static bool svs_is_efuse_data_correct(struct svs_platform *svsp)
 	svsp->efuse_max /= sizeof(u32);
 	nvmem_cell_put(cell);
 
-	return svsp->efuse_parsing(svsp);
+	return true;
 }
 
 static struct device *svs_get_subsys_device(struct svs_platform *svsp,
@@ -2338,9 +2334,7 @@ static int svs_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	svsp->dev = &pdev->dev;
-	svsp->name = svsp_data->name;
 	svsp->banks = svsp_data->banks;
-	svsp->efuse_parsing = svsp_data->efuse_parsing;
 	svsp->regs = svsp_data->regs;
 	svsp->bank_max = svsp_data->bank_max;
 
@@ -2351,6 +2345,12 @@ static int svs_probe(struct platform_device *pdev)
 	if (!svs_is_efuse_data_correct(svsp)) {
 		dev_notice(svsp->dev, "efuse data isn't correct\n");
 		ret = -EPERM;
+		goto svs_probe_free_efuse;
+	}
+
+	if (!svsp_data->efuse_parsing(svsp)) {
+		dev_notice(svsp->dev, "efuse data parsing failed\n");
+		ret = -EPERM;
 		goto svs_probe_free_resource;
 	}
 
@@ -2367,7 +2367,7 @@ static int svs_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr,
-					IRQF_ONESHOT, svsp->name, svsp);
+					IRQF_ONESHOT, svsp_data->name, svsp);
 	if (ret) {
 		dev_err(svsp->dev, "register irq(%d) failed: %d\n",
 			svsp_irq, ret);
@@ -2416,11 +2416,13 @@ static int svs_probe(struct platform_device *pdev)
 	clk_disable_unprepare(svsp->main_clk);
 
 svs_probe_free_resource:
-	if (!IS_ERR_OR_NULL(svsp->efuse))
-		kfree(svsp->efuse);
 	if (!IS_ERR_OR_NULL(svsp->tefuse))
 		kfree(svsp->tefuse);
 
+svs_probe_free_efuse:
+	if (!IS_ERR_OR_NULL(svsp->efuse))
+		kfree(svsp->efuse);
+
 	return ret;
 }
 
Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 4/8
#8 lore raw

Re: [PATCH 4/8] soc: mediatek: mtk-svs: delete superfluous platform data entries

Il 28/09/22 17:55, [email protected] ha scritto:

Quoted 6 lines

From: Matthias Brugger <[email protected]>

The platform name and efuse parsing function pointer are only used while probing the device. Use them from the svs_platform_data struct instead.

#9 lore raw

Re: [PATCH 4/8] soc: mediatek: mtk-svs: delete superfluous platform data entries

In reply to [email protected]

Hi Matthias Sir,

Quoted 46 lines · On Wed, 2022-09-28 at 17:55 +0200, [email protected] wrote:

From: Matthias Brugger <[email protected]>

The platform name and efuse parsing function pointer are only used while probing the device. Use them from the svs_platform_data struct instead.

---

 drivers/soc/mediatek/mtk-svs.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/soc/mediatek/mtk-svs.c +0 -4
index 8342627f8dea..482cc8d7e7cf 100644
@@ -311,14 +311,12 @@ static const u32 svs_regs_v2[] = {
 
 /**
  * struct svs_platform - svs platform control
- * @name: svs platform name
  * @base: svs platform register base
  * @dev: svs platform device
  * @main_clk: main clock for svs bank
  * @pbank: svs bank pointer needing to be protected by spin_lock section
  * @banks: svs banks that svs platform supports
  * @rst: svs platform reset control
- * @efuse_parsing: svs platform efuse parsing function pointer
  * @efuse_max: total number of svs efuse
  * @tefuse_max: total number of thermal efuse
  * @regs: svs platform registers map
@@ -327,14 +325,12 @@ static const u32 svs_regs_v2[] = {
  * @tefuse: thermal efuse data received from NVMEM framework
  */
 struct svs_platform {
-	char *name;
 	void __iomem *base;
 	struct device *dev;
 	struct clk *main_clk;
 	struct svs_bank *pbank;
 	struct svs_bank *banks;
 	struct reset_control *rst;
-	bool (*efuse_parsing)(struct svs_platform *svsp);
 	size_t efuse_max;
 	size_t tefuse_max;
 	const u32 *regs;

drivers/soc/mediatek/mtk-svs.c static bool svs_is_efuse_data_correct(struct · line 2010

Quoted 7 lines
drivers/soc/mediatek/mtk-svs.c +1 -1
@@ -2009,7 +2005,7 @@ static bool svs_is_efuse_data_correct(struct
 svs_platform *svsp)
 	svsp->efuse_max /= sizeof(u32);
 	nvmem_cell_put(cell);
 
-	return svsp->efuse_parsing(svsp);
+	return true;
 }

Based on the current coding design, I think this function can be removed. We can rename/refactor svs_thermal_efuse_get_data() to svs_get_efuse_data() as below. Is this acceptable? Thanks.

int svs_get_efuse_data(struct svs_platform *svsp, const char *nvmem_cell_name)

{
        struct nvmem_cell *cell;

        /* Thermal efuse parsing */
        cell = nvmem_cell_get(svsp->dev, nvmem_cell_name);
        if (IS_ERR_OR_NULL(cell)) {
                dev_err(svsp->dev, "no \"%s\"? %ld\n", nvmem_cell_name,
PTR_ERR(cell));
                return PTR_ERR(cell);
        }

        svsp->tefuse = nvmem_cell_read(cell, &svsp->tefuse_max);
        if (IS_ERR(svsp->tefuse)) {
                dev_err(svsp->dev, "cannot read thermal efuse: %ld\n",
                        PTR_ERR(svsp->tefuse));
                nvmem_cell_put(cell);
                return PTR_ERR(svsp->tefuse);
        }

        svsp->tefuse_max /= sizeof(u32);
        nvmem_cell_put(cell);

        return 0;
}
Quoted 13 lines
drivers/soc/mediatek/mtk-svs.c +0 -2
 static struct device *svs_get_subsys_device(struct svs_platform *svsp,
@@ -2338,9 +2334,7 @@ static int svs_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	svsp->dev = &pdev->dev;
-	svsp->name = svsp_data->name;
 	svsp->banks = svsp_data->banks;
-	svsp->efuse_parsing = svsp_data->efuse_parsing;
 	svsp->regs = svsp_data->regs;
 	svsp->bank_max = svsp_data->bank_max;
 

drivers/soc/mediatek/mtk-svs.c static int svs_probe(struct platform_device *pdev) · line 2350

Quoted 6 lines
drivers/soc/mediatek/mtk-svs.c +3 -0
@@ -2351,6 +2345,12 @@ static int svs_probe(struct platform_device *pdev)
 	if (!svs_is_efuse_data_correct(svsp)) {
 		dev_notice(svsp->dev, "efuse data isn't correct\n");
 		ret = -EPERM;
+		goto svs_probe_free_efuse;
+	}
+

Remove svs_is_efuse_data_correct() and add below get-efuse-data function.

	ret = svs_get_efuse_data(svsp, "svs-calibration-data");
	if (ret)
		goto svs_probe_free_efuse;
Quoted 16 lines
drivers/soc/mediatek/mtk-svs.c +4 -1
+	if (!svsp_data->efuse_parsing(svsp)) {
+		dev_notice(svsp->dev, "efuse data parsing failed\n");
+		ret = -EPERM;
 		goto svs_probe_free_resource;
 	}
 
@@ -2367,7 +2367,7 @@ static int svs_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr,
-					IRQF_ONESHOT, svsp->name, svsp);
+					IRQF_ONESHOT, svsp_data->name, svsp);
 	if (ret) {
 		dev_err(svsp->dev, "register irq(%d) failed: %d\n",
 			svsp_irq, ret);

drivers/soc/mediatek/mtk-svs.c static int svs_probe(struct platform_device *pdev) · line 2418

Quoted 3 lines
drivers/soc/mediatek/mtk-svs.c +0 -0
@@ -2416,11 +2416,13 @@ static int svs_probe(struct platform_device *pdev)
 	clk_disable_unprepare(svsp->main_clk);
 
 svs_probe_free_resource:

For current coding design, I suggest we rename the goto-label to svs_probe_free_tefuse to identify the resource we free.

drivers/soc/mediatek/mtk-svs.c static int svs_probe(struct platform_device *pdev) · line 2428

Quoted 12 lines
drivers/soc/mediatek/mtk-svs.c +4 -2
-	if (!IS_ERR_OR_NULL(svsp->efuse))
-		kfree(svsp->efuse);
 	if (!IS_ERR_OR_NULL(svsp->tefuse))
 		kfree(svsp->tefuse);
 
+svs_probe_free_efuse:
+	if (!IS_ERR_OR_NULL(svsp->efuse))
+		kfree(svsp->efuse);
+
 	return ret;
 }
 

Sincerely,
Roger Lu.

#10 lore raw

PATCH 5/8 soc: mediatek: mtk-svs: Move SoC specific functions to new files

In reply to [email protected]

From: Matthias Brugger <[email protected]>

With every SoC added to the driver, it grows. Move SoC specific callbacks to a new source files.

---

 drivers/soc/mediatek/Makefile         |   3 +-
 drivers/soc/mediatek/mt8183-svs.h     | 113 ++++
 drivers/soc/mediatek/mt8192-svs.h     |  64 ++
 drivers/soc/mediatek/mtk-svs-mt8183.c | 234 ++++++++
 drivers/soc/mediatek/mtk-svs-mt8192.c | 100 ++++
 drivers/soc/mediatek/mtk-svs.c        | 831 ++------------------------
 drivers/soc/mediatek/mtk-svs.h        | 279 +++++++++
 7 files changed, 837 insertions(+), 787 deletions(-)
 create mode 100644 drivers/soc/mediatek/mt8183-svs.h
 create mode 100644 drivers/soc/mediatek/mt8192-svs.h
 create mode 100644 drivers/soc/mediatek/mtk-svs-mt8183.c
 create mode 100644 drivers/soc/mediatek/mtk-svs-mt8192.c
 create mode 100644 drivers/soc/mediatek/mtk-svs.h
drivers/soc/mediatek/Makefile +2 -1
index 0e9e703c931a..851131638644 100644
@@ -7,4 +7,5 @@ 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_MMSYS) += mtk-mutex.o
-obj-$(CONFIG_MTK_SVS) += mtk-svs.o
+mtk_svs-objs := mtk-svs.o mtk-svs-mt8183.o mtk-svs-mt8192.o
+obj-$(CONFIG_MTK_SVS) += mtk_svs.o
drivers/soc/mediatek/mt8183-svs.h new file +113 -0

113 lines not on this page · raw message

drivers/soc/mediatek/mt8192-svs.h new file +64 -0

64 lines not on this page · raw message

drivers/soc/mediatek/mtk-svs-mt8183.c new file +234 -0

234 lines not on this page · raw message

drivers/soc/mediatek/mtk-svs-mt8192.c new file +100 -0

100 lines not on this page · raw message

drivers/soc/mediatek/mtk-svs.c +45 -786

931 lines not on this page · raw message

drivers/soc/mediatek/mtk-svs.h new file +279 -0

279 lines not on this page · raw message

Signature · 1 line
2.37.3
#11 lore raw

Re: [PATCH 5/8] soc: mediatek: mtk-svs: Move SoC specific functions to new files

Il 28/09/22 17:55, [email protected] ha scritto:

Quoted 39 lines

From: Matthias Brugger <[email protected]>

With every SoC added to the driver, it grows. Move SoC specific callbacks to a new source files.

---

  drivers/soc/mediatek/Makefile         |   3 +-
  drivers/soc/mediatek/mt8183-svs.h     | 113 ++++
  drivers/soc/mediatek/mt8192-svs.h     |  64 ++
  drivers/soc/mediatek/mtk-svs-mt8183.c | 234 ++++++++
  drivers/soc/mediatek/mtk-svs-mt8192.c | 100 ++++
  drivers/soc/mediatek/mtk-svs.c        | 831 ++------------------------
  drivers/soc/mediatek/mtk-svs.h        | 279 +++++++++
  7 files changed, 837 insertions(+), 787 deletions(-)

create mode 100644 drivers/soc/mediatek/mt8183-svs.h create mode 100644 drivers/soc/mediatek/mt8192-svs.h create mode 100644 drivers/soc/mediatek/mtk-svs-mt8183.c create mode 100644 drivers/soc/mediatek/mtk-svs-mt8192.c create mode 100644 drivers/soc/mediatek/mtk-svs.h

drivers/soc/mediatek/Makefile +2 -1
index 0e9e703c931a..851131638644 100644
@@ -7,4 +7,5 @@ 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_MMSYS) += mtk-mutex.o
-obj-$(CONFIG_MTK_SVS) += mtk-svs.o
+mtk_svs-objs := mtk-svs.o mtk-svs-mt8183.o mtk-svs-mt8192.o
+obj-$(CONFIG_MTK_SVS) += mtk_svs.o
drivers/soc/mediatek/mt8183-svs.h new file +0 -0
new file mode 100644
index 000000000000..89c0deb9fb11

drivers/soc/mediatek/mt8183-svs.h line 5

Quoted 5 lines
drivers/soc/mediatek/mt8183-svs.h new file +5 -0
@@ -0,0 +1,113 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __DRV_SVS_MT8183_H
+#define __DRV_SVS_MT8183_H
+

Please avoid implicit header inclusion (here and in mt8192-svs.h).

#include "mtk-svs.h"

Cheers,
Angelo

#12 lore raw

Re: [PATCH 5/8] soc: mediatek: mtk-svs: Move SoC specific functions to new files

In reply to [email protected]

Hi Matthias Sir,

Quoted 2 lines

drivers/soc/mediatek/mtk-svs-mt8183.c | 234 ++++++++ drivers/soc/mediatek/mtk-svs-mt8192.c | 100 ++++

We've encountered some build warnings as below. Could we put mtk-svs-mtxx.c implementation into mt81xx-svs.h and remove mtk-svs-mtxx.c?

kernel/mediatek/drivers/soc/mediatek/mtk-svs-mt8183.c:103:6: warning: no previous prototype for ‘svs_mt8183_efuse_parsing’ [-Wmissing-prototypes]
bool svs_mt8183_efuse_parsing(struct svs_platform *svsp)

      ^~~~~~~~~~~~~~~~~~~~~~~~

/mfs/mtkslt1043/mtk11157/upstream/2022_1003_1704/kernel/mediatek/drivers/soc/med iatek/mtk-svs-mt8183.c:198:5: warning: no previous prototype for ‘svs_mt8183_platform_probe’ [-Wmissing-prototypes]
int svs_mt8183_platform_probe(struct svs_platform *svsp)

     ^~~~~~~~~~~~~~~~~~~~~~~~~

kernel/mediatek/drivers/soc/mediatek/mtk-svs-mt8192.c:5:6: warning: no previous prototype for ‘svs_mt8192_efuse_parsing’ [-Wmissing-prototypes]
bool svs_mt8192_efuse_parsing(struct svs_platform *svsp)

      ^~~~~~~~~~~~~~~~~~~~~~~~

/mfs/mtkslt1043/mtk11157/upstream/2022_1003_1704/kernel/mediatek/drivers/soc/med iatek/mtk-svs-mt8192.c:67:5: warning: no previous prototype for ‘svs_mt8192_platform_probe’ [-Wmissing-prototypes]
int svs_mt8192_platform_probe(struct svs_platform *svsp)

...[snip]...

Quoted 32 lines
drivers/soc/mediatek/mtk-svs.c +32 -0
+#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_data(name)	{__stringify(name),
Quoted 2 lines

&svs_##name##_debug_fops}
+

CHECK: Please don't use multiple blank lines
#208: FILE: drivers/soc/mediatek/mtk-svs.c:208:
+
+

...[snip]...

drivers/soc/mediatek/mtk-svs.c static struct device *svs_get_subsys_device(struct · line 1527

Quoted 13 lines
drivers/soc/mediatek/mtk-svs.c +2 -2
-static struct device *svs_get_subsys_device(struct svs_platform *svsp,
+struct device *svs_get_subsys_device(struct svs_platform *svsp,
 					    const char *node_name)
 {
 	struct platform_device *pdev;
@@ -2032,7 +1522,7 @@ static struct device *svs_get_subsys_device(struct
 svs_platform *svsp,
 	return &pdev->dev;
 }
 
-static struct device *svs_add_device_link(struct svs_platform *svsp,
+struct device *svs_add_device_link(struct svs_platform *svsp,
 					  const char *node_name)

CHECK: Alignment should match open parenthesis
#1502: FILE: drivers/soc/mediatek/mtk-svs.c:1502:
+struct device *svs_get_subsys_device(struct svs_platform *svsp,
+ const char *node_name)

CHECK: Alignment should match open parenthesis #1526: FILE: drivers/soc/mediatek/mtk-svs.c:1526:
+struct device *svs_add_device_link(struct svs_platform *svsp,
+ const char *node_name)

... [snip]...

drivers/soc/mediatek/mtk-svs.h line 271

Quoted 4 lines
drivers/soc/mediatek/mtk-svs.h new file +4 -0
+struct device *svs_add_device_link(struct svs_platform *svsp,
+					  const char *node_name);
+struct device *svs_get_subsys_device(struct svs_platform *svsp,
+					    const char *node_name);

CHECK: Alignment should match open parenthesis
#269: FILE: drivers/soc/mediatek/mtk-svs.h:269:
+struct device *svs_add_device_link(struct svs_platform *svsp,
+ const char *node_name);

CHECK: Alignment should match open parenthesis
#271: FILE: drivers/soc/mediatek/mtk-svs.h:271:
+struct device *svs_get_subsys_device(struct svs_platform *svsp,
+ const char *node_name);

drivers/soc/mediatek/mtk-svs.h line 279

Quoted 8 lines
drivers/soc/mediatek/mtk-svs.h new file +8 -0
+int svs_thermal_efuse_get_data(struct svs_platform *svsp);
+
+void svs_get_bank_volts_v2(struct svs_platform *svsp);
+void svs_set_bank_freq_pct_v2(struct svs_platform *svsp);
+
+void svs_get_bank_volts_v3(struct svs_platform *svsp);
+void svs_set_bank_freq_pct_v3(struct svs_platform *svsp);
+#endif

Sincerely,
Roger Lu.

#13 lore raw

PATCH 6/8 soc: mtk-svs: mt8183: Move thermal parsing in new function

In reply to [email protected]

From: Matthias Brugger <[email protected]>

We jumpt to lable remove_mt8183_svsb_mon_mode from different error path in the code. Move the thermal parsing in a new function will allow us to refactor the code in a subsequent patch. No behavioural changes from this commit.

---

 drivers/soc/mediatek/mtk-svs-mt8183.c | 183 +++++++++++++-------------
 1 file changed, 95 insertions(+), 88 deletions(-)
drivers/soc/mediatek/mtk-svs-mt8183.c +95 -88
index a97fcae59dd7..4b538cdefc86 100644
@@ -2,94 +2,14 @@
 
 #include "mtk-svs.h"
 
-bool svs_mt8183_efuse_parsing(struct svs_platform *svsp)
+static int svs_mt8183_efuse_thermal_parsing(struct svs_platform *svsp)
 {
 	struct svs_bank *svsb;
 	int format[6], x_roomt[6], o_vtsmcu[5], o_vtsabb, tb_roomt = 0;
 	int adc_ge_t, adc_oe_t, ge, oe, gain, degc_cali, adc_cali_en_t;
 	int o_slope, o_slope_sign, ts_id;
-	u32 idx, i, ft_pgm, mts, temp0, temp1, temp2;
-	int ret;
-
-	for (i = 0; i < svsp->efuse_max; i++)
-		if (svsp->efuse[i])
-			dev_info(svsp->dev, "M_HW_RES%d: 0x%08x\n",
-				 i, svsp->efuse[i]);
-
-	if (!svsp->efuse[2]) {
-		dev_notice(svsp->dev, "svs_efuse[2] = 0x0?\n");
-		return false;
-	}
-
-	/* Svs efuse parsing */
-	ft_pgm = (svsp->efuse[0] >> 4) & GENMASK(3, 0);
-
-	for (idx = 0; idx < svsp->bank_max; idx++) {
-		svsb = &svsp->banks[idx];
-
-		if (ft_pgm <= 1)
-			svsb->volt_flags |= SVSB_INIT01_VOLT_IGNORE;
+	u32 idx, i, mts, temp0, temp1, temp2;
 
-		switch (svsb->sw_id) {
-		case SVSB_CPU_LITTLE:
-			svsb->bdes = svsp->efuse[16] & GENMASK(7, 0);
-			svsb->mdes = (svsp->efuse[16] >> 8) & GENMASK(7, 0);
-			svsb->dcbdet = (svsp->efuse[16] >> 16) & GENMASK(7, 0);
-			svsb->dcmdet = (svsp->efuse[16] >> 24) & GENMASK(7, 0);
-			svsb->mtdes  = (svsp->efuse[17] >> 16) & GENMASK(7, 0);
-
-			if (ft_pgm <= 3)
-				svsb->volt_od += 10;
-			else
-				svsb->volt_od += 2;
-			break;
-		case SVSB_CPU_BIG:
-			svsb->bdes = svsp->efuse[18] & GENMASK(7, 0);
-			svsb->mdes = (svsp->efuse[18] >> 8) & GENMASK(7, 0);
-			svsb->dcbdet = (svsp->efuse[18] >> 16) & GENMASK(7, 0);
-			svsb->dcmdet = (svsp->efuse[18] >> 24) & GENMASK(7, 0);
-			svsb->mtdes  = svsp->efuse[17] & GENMASK(7, 0);
-
-			if (ft_pgm <= 3)
-				svsb->volt_od += 15;
-			else
-				svsb->volt_od += 12;
-			break;
-		case SVSB_CCI:
-			svsb->bdes = svsp->efuse[4] & GENMASK(7, 0);
-			svsb->mdes = (svsp->efuse[4] >> 8) & GENMASK(7, 0);
-			svsb->dcbdet = (svsp->efuse[4] >> 16) & GENMASK(7, 0);
-			svsb->dcmdet = (svsp->efuse[4] >> 24) & GENMASK(7, 0);
-			svsb->mtdes  = (svsp->efuse[5] >> 16) & GENMASK(7, 0);
-
-			if (ft_pgm <= 3)
-				svsb->volt_od += 10;
-			else
-				svsb->volt_od += 2;
-			break;
-		case SVSB_GPU:
-			svsb->bdes = svsp->efuse[6] & GENMASK(7, 0);
-			svsb->mdes = (svsp->efuse[6] >> 8) & GENMASK(7, 0);
-			svsb->dcbdet = (svsp->efuse[6] >> 16) & GENMASK(7, 0);
-			svsb->dcmdet = (svsp->efuse[6] >> 24) & GENMASK(7, 0);
-			svsb->mtdes  = svsp->efuse[5] & GENMASK(7, 0);
-
-			if (ft_pgm >= 2) {
-				svsb->freq_base = 800000000; /* 800MHz */
-				svsb->dvt_fixed = 2;
-			}
-			break;
-		default:
-			dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id);
-			return false;
-		}
-	}
-
-	ret = svs_thermal_efuse_get_data(svsp);
-	if (ret)
-		return false;
-
-	/* Thermal efuse parsing */
 	adc_ge_t = (svsp->tefuse[1] >> 22) & GENMASK(9, 0);
 	adc_oe_t = (svsp->tefuse[1] >> 12) & GENMASK(9, 0);
 
@@ -121,11 +41,11 @@ bool svs_mt8183_efuse_parsing(struct svs_platform *svsp)
 		    o_vtsabb < -8 || o_vtsabb > 484 ||
 		    degc_cali < 1 || degc_cali > 63) {
 			dev_err(svsp->dev, "bad thermal efuse, no mon mode\n");
-			goto remove_mt8183_svsb_mon_mode;
+			return -1;
 		}
 	} else {
 		dev_err(svsp->dev, "no thermal efuse, no mon mode\n");
-		goto remove_mt8183_svsb_mon_mode;
+		return -1;
 	}
 
 	ge = ((adc_ge_t - 512) * 10000) / 4096;
@@ -168,7 +88,7 @@ bool svs_mt8183_efuse_parsing(struct svs_platform *svsp)
 			break;
 		default:
 			dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id);
-			goto remove_mt8183_svsb_mon_mode;
+			return -1;
 		}
 
 		temp0 = (degc_cali * 10 / 2);
@@ -183,12 +103,99 @@ bool svs_mt8183_efuse_parsing(struct svs_platform *svsp)
 		svsb->bts = (temp0 + temp2 - 250) * 4 / 10;
 	}
 
-	return true;
+	return 0;
+}
+
+bool svs_mt8183_efuse_parsing(struct svs_platform *svsp)
+{
+	struct svs_bank *svsb;
+	u32 idx, i, ft_pgm;
+	int ret;
+
+	for (i = 0; i < svsp->efuse_max; i++)
+		if (svsp->efuse[i])
+			dev_info(svsp->dev, "M_HW_RES%d: 0x%08x\n",
+				 i, svsp->efuse[i]);
+
+	if (!svsp->efuse[2]) {
+		dev_notice(svsp->dev, "svs_efuse[2] = 0x0?\n");
+		return false;
+	}
+
+	/* Svs efuse parsing */
+	ft_pgm = (svsp->efuse[0] >> 4) & GENMASK(3, 0);
 
-remove_mt8183_svsb_mon_mode:
 	for (idx = 0; idx < svsp->bank_max; idx++) {
 		svsb = &svsp->banks[idx];
-		svsb->mode_support &= ~SVSB_MODE_MON;
+
+		if (ft_pgm <= 1)
+			svsb->volt_flags |= SVSB_INIT01_VOLT_IGNORE;
+
+		switch (svsb->sw_id) {
+		case SVSB_CPU_LITTLE:
+			svsb->bdes = svsp->efuse[16] & GENMASK(7, 0);
+			svsb->mdes = (svsp->efuse[16] >> 8) & GENMASK(7, 0);
+			svsb->dcbdet = (svsp->efuse[16] >> 16) & GENMASK(7, 0);
+			svsb->dcmdet = (svsp->efuse[16] >> 24) & GENMASK(7, 0);
+			svsb->mtdes  = (svsp->efuse[17] >> 16) & GENMASK(7, 0);
+
+			if (ft_pgm <= 3)
+				svsb->volt_od += 10;
+			else
+				svsb->volt_od += 2;
+			break;
+		case SVSB_CPU_BIG:
+			svsb->bdes = svsp->efuse[18] & GENMASK(7, 0);
+			svsb->mdes = (svsp->efuse[18] >> 8) & GENMASK(7, 0);
+			svsb->dcbdet = (svsp->efuse[18] >> 16) & GENMASK(7, 0);
+			svsb->dcmdet = (svsp->efuse[18] >> 24) & GENMASK(7, 0);
+			svsb->mtdes  = svsp->efuse[17] & GENMASK(7, 0);
+
+			if (ft_pgm <= 3)
+				svsb->volt_od += 15;
+			else
+				svsb->volt_od += 12;
+			break;
+		case SVSB_CCI:
+			svsb->bdes = svsp->efuse[4] & GENMASK(7, 0);
+			svsb->mdes = (svsp->efuse[4] >> 8) & GENMASK(7, 0);
+			svsb->dcbdet = (svsp->efuse[4] >> 16) & GENMASK(7, 0);
+			svsb->dcmdet = (svsp->efuse[4] >> 24) & GENMASK(7, 0);
+			svsb->mtdes  = (svsp->efuse[5] >> 16) & GENMASK(7, 0);
+
+			if (ft_pgm <= 3)
+				svsb->volt_od += 10;
+			else
+				svsb->volt_od += 2;
+			break;
+		case SVSB_GPU:
+			svsb->bdes = svsp->efuse[6] & GENMASK(7, 0);
+			svsb->mdes = (svsp->efuse[6] >> 8) & GENMASK(7, 0);
+			svsb->dcbdet = (svsp->efuse[6] >> 16) & GENMASK(7, 0);
+			svsb->dcmdet = (svsp->efuse[6] >> 24) & GENMASK(7, 0);
+			svsb->mtdes  = svsp->efuse[5] & GENMASK(7, 0);
+
+			if (ft_pgm >= 2) {
+				svsb->freq_base = 800000000; /* 800MHz */
+				svsb->dvt_fixed = 2;
+			}
+			break;
+		default:
+			dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id);
+			return false;
+		}
+	}
+
+	ret = svs_thermal_efuse_get_data(svsp);
+	if (ret)
+		return false;
+
+	ret = svs_mt8183_efuse_thermal_parsing(svsp);
+	if (ret) {
+		for (idx = 0; idx < svsp->bank_max; idx++) {
+			svsb = &svsp->banks[idx];
+			svsb->mode_support &= ~SVSB_MODE_MON;
+		}
 	}
 
 	return true;
Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 6/8
#14 lore raw

Re: [PATCH 6/8] soc: mtk-svs: mt8183: Move thermal parsing in new function

Il 28/09/22 17:55, [email protected] ha scritto:

Quoted 8 lines

From: Matthias Brugger <[email protected]>

We jumpt to lable remove_mt8183_svsb_mon_mode from different error path in the code. Move the thermal parsing in a new function will allow us to refactor the code in a subsequent patch. No behavioural changes from this commit.

#15 lore raw

PATCH 7/8 soc: mtk-svs: mt8183: refactor o_slope calculation

In reply to [email protected]

From: Matthias Brugger <[email protected]>

The o_slope value is dependent of the o_slope_sign, refactor code to get rid of unnecessary if constructs.

---

 drivers/soc/mediatek/mtk-svs-mt8183.c | 54 ++++++++++++---------------
 1 file changed, 24 insertions(+), 30 deletions(-)
drivers/soc/mediatek/mtk-svs-mt8183.c +24 -30
index 4b538cdefc86..7f7d5cd6be35 100644
@@ -25,26 +25,28 @@ static int svs_mt8183_efuse_thermal_parsing(struct svs_platform *svsp)
 	o_slope_sign = (svsp->tefuse[0] >> 7) & BIT(0);
 
 	ts_id = (svsp->tefuse[1] >> 9) & BIT(0);
-	o_slope = (svsp->tefuse[0] >> 26) & GENMASK(5, 0);
-
-	if (adc_cali_en_t == 1) {
-		if (!ts_id)
-			o_slope = 0;
-
-		if (adc_ge_t < 265 || adc_ge_t > 758 ||
-		    adc_oe_t < 265 || adc_oe_t > 758 ||
-		    o_vtsmcu[0] < -8 || o_vtsmcu[0] > 484 ||
-		    o_vtsmcu[1] < -8 || o_vtsmcu[1] > 484 ||
-		    o_vtsmcu[2] < -8 || o_vtsmcu[2] > 484 ||
-		    o_vtsmcu[3] < -8 || o_vtsmcu[3] > 484 ||
-		    o_vtsmcu[4] < -8 || o_vtsmcu[4] > 484 ||
-		    o_vtsabb < -8 || o_vtsabb > 484 ||
-		    degc_cali < 1 || degc_cali > 63) {
-			dev_err(svsp->dev, "bad thermal efuse, no mon mode\n");
-			return -1;
-		}
-	} else {
-		dev_err(svsp->dev, "no thermal efuse, no mon mode\n");
+
+	if (!ts_id)
+		o_slope = 1534;
+	else {
+		o_slope = (svsp->tefuse[0] >> 26) & GENMASK(5, 0);
+		if (!o_slope_sign)
+			o_slope = 1534 + o_slope * 10;
+		else
+			o_slope = 1534 - o_slope * 10;
+	}
+
+	if (adc_cali_en_t == 0 ||
+	    adc_ge_t < 265 || adc_ge_t > 758 ||
+	    adc_oe_t < 265 || adc_oe_t > 758 ||
+	    o_vtsmcu[0] < -8 || o_vtsmcu[0] > 484 ||
+	    o_vtsmcu[1] < -8 || o_vtsmcu[1] > 484 ||
+	    o_vtsmcu[2] < -8 || o_vtsmcu[2] > 484 ||
+	    o_vtsmcu[3] < -8 || o_vtsmcu[3] > 484 ||
+	    o_vtsmcu[4] < -8 || o_vtsmcu[4] > 484 ||
+	    o_vtsabb < -8 || o_vtsabb > 484 ||
+	    degc_cali < 1 || degc_cali > 63) {
+		dev_err(svsp->dev, "bad thermal efuse, no mon mode\n");
 		return -1;
 	}
 
@@ -63,11 +65,7 @@ static int svs_mt8183_efuse_thermal_parsing(struct svs_platform *svsp)
 		x_roomt[i] = (((format[i] * 10000) / 4096) * 10000) / gain;
 
 	temp0 = (10000 * 100000 / gain) * 15 / 18;
-
-	if (!o_slope_sign)
-		mts = (temp0 * 10) / (1534 + o_slope * 10);
-	else
-		mts = (temp0 * 10) / (1534 - o_slope * 10);
+	mts = (temp0 * 10) / o_slope;
 
 	for (idx = 0; idx < svsp->bank_max; idx++) {
 		svsb = &svsp->banks[idx];
@@ -94,11 +92,7 @@ static int svs_mt8183_efuse_thermal_parsing(struct svs_platform *svsp)
 		temp0 = (degc_cali * 10 / 2);
 		temp1 = ((10000 * 100000 / 4096 / gain) *
 			 oe + tb_roomt * 10) * 15 / 18;
-
-		if (!o_slope_sign)
-			temp2 = temp1 * 100 / (1534 + o_slope * 10);
-		else
-			temp2 = temp1 * 100 / (1534 - o_slope * 10);
+		temp2 = temp1 * 100 / o_slope;
 
 		svsb->bts = (temp0 + temp2 - 250) * 4 / 10;
 	}
Signature · 1 line
2.37.3
#16 lore raw

PATCH 8/8 soc: mtk-svs: mt8192: fix bank data

In reply to [email protected]

From: Matthias Brugger <[email protected]>

Values vmax and dvt_fixed are not changed at runtime, set them as needed in the svs_banks struct.

---

 drivers/soc/mediatek/mt8192-svs.h     | 4 ++--
 drivers/soc/mediatek/mtk-svs-mt8192.c | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/soc/mediatek/mt8192-svs.h +2 -2
index 6571ebcb2c0f..bf8c6030428f 100644
@@ -16,7 +16,7 @@ static struct svs_bank svs_mt8192_banks[] = {
 		.turn_freq_base		= 688000000,
 		.volt_step		= 6250,
 		.volt_base		= 400000,
-		.vmax			= 0x60,
+		.vmax			= 0x61,
 		.vmin			= 0x1a,
 		.age_config		= 0x555555,
 		.dc_config		= 0x1,
@@ -41,7 +41,7 @@ static struct svs_bank svs_mt8192_banks[] = {
 		.turn_freq_base		= 688000000,
 		.volt_step		= 6250,
 		.volt_base		= 400000,
-		.vmax			= 0x60,
+		.vmax			= 0x66,
 		.vmin			= 0x1a,
 		.age_config		= 0x555555,
 		.dc_config		= 0x1,
drivers/soc/mediatek/mtk-svs-mt8192.c +0 -2
index 838a94834741..183acf2829f0 100644
@@ -40,8 +40,6 @@ bool svs_mt8192_efuse_parsing(struct svs_platform *svsp)
 			svsb->dcbdet = (svsp->efuse[17] >> 16) & GENMASK(7, 0);
 			svsb->dcmdet = (svsp->efuse[17] >> 24) & GENMASK(7, 0);
 		}
-
-		svsb->vmax += svsb->dvt_fixed;
 	}
 
 	ret = svs_thermal_efuse_get_data(svsp);
Signature · 1 line
2.37.3
#17 lore raw

Re: [PATCH 8/8] soc: mtk-svs: mt8192: fix bank data

Il 28/09/22 17:55, [email protected] ha scritto:

Quoted 7 lines

From: Matthias Brugger <[email protected]>

Values vmax and dvt_fixed are not changed at runtime, set them as needed in the svs_banks struct.

Honestly, I'm undecided on this one... because the vmax += dvt_fixed is something descriptive of how the SVS works.
Since you're simply removing one addition, in a path that gets executed only once in a kernel boot life, that's not even going to improve performance at all...

Right now, I'm more for dropping this change than keeping it.

Cheers,
Angelo

Quoted 41 lines

---

  drivers/soc/mediatek/mt8192-svs.h     | 4 ++--
  drivers/soc/mediatek/mtk-svs-mt8192.c | 2 --
  2 files changed, 2 insertions(+), 4 deletions(-)
drivers/soc/mediatek/mt8192-svs.h +2 -2
index 6571ebcb2c0f..bf8c6030428f 100644
@@ -16,7 +16,7 @@ static struct svs_bank svs_mt8192_banks[] = {
  		.turn_freq_base		= 688000000,
  		.volt_step		= 6250,
  		.volt_base		= 400000,
-		.vmax			= 0x60,
+		.vmax			= 0x61,
  		.vmin			= 0x1a,
  		.age_config		= 0x555555,
  		.dc_config		= 0x1,
@@ -41,7 +41,7 @@ static struct svs_bank svs_mt8192_banks[] = {
  		.turn_freq_base		= 688000000,
  		.volt_step		= 6250,
  		.volt_base		= 400000,
-		.vmax			= 0x60,
+		.vmax			= 0x66,
  		.vmin			= 0x1a,
  		.age_config		= 0x555555,
  		.dc_config		= 0x1,
drivers/soc/mediatek/mtk-svs-mt8192.c +0 -2
index 838a94834741..183acf2829f0 100644
@@ -40,8 +40,6 @@ bool svs_mt8192_efuse_parsing(struct svs_platform *svsp)
  			svsb->dcbdet = (svsp->efuse[17] >> 16) & GENMASK(7, 0);
  			svsb->dcmdet = (svsp->efuse[17] >> 24) & GENMASK(7, 0);
  		}
-
-		svsb->vmax += svsb->dvt_fixed;
  	}
 
  	ret = svs_thermal_efuse_get_data(svsp);
#18 lore raw

Re: [PATCH 8/8] soc: mtk-svs: mt8192: fix bank data

In reply to [email protected]

Hi Matthias Sir,

This addition is for indicating vmax value is increased by dvt_fixed. Please keep this information to make it be seen. Many thanks.

Sincerely,
Roger Lu.

Quoted 50 lines · On Wed, 2022-09-28 at 17:55 +0200, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Values vmax and dvt_fixed are not changed at runtime, set them as needed in the svs_banks struct.

---

 drivers/soc/mediatek/mt8192-svs.h     | 4 ++--
 drivers/soc/mediatek/mtk-svs-mt8192.c | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/soc/mediatek/mt8192- renamed from drivers/soc/mediatek/mt8192-svs.h +0 -0

svs.h
index 6571ebcb2c0f..bf8c6030428f 100644

drivers/soc/mediatek/mt8192-svs.h +2 -2
@@ -16,7 +16,7 @@ static struct svs_bank svs_mt8192_banks[] = {
 		.turn_freq_base		= 688000000,
 		.volt_step		= 6250,
 		.volt_base		= 400000,
-		.vmax			= 0x60,
+		.vmax			= 0x61,
 		.vmin			= 0x1a,
 		.age_config		= 0x555555,
 		.dc_config		= 0x1,
@@ -41,7 +41,7 @@ static struct svs_bank svs_mt8192_banks[] = {
 		.turn_freq_base		= 688000000,
 		.volt_step		= 6250,
 		.volt_base		= 400000,
-		.vmax			= 0x60,
+		.vmax			= 0x66,
 		.vmin			= 0x1a,
 		.age_config		= 0x555555,
 		.dc_config		= 0x1,
drivers/soc/mediatek/mtk- renamed from drivers/soc/mediatek/mtk-svs-mt8192.c +0 -0

svs-mt8192.c
index 838a94834741..183acf2829f0 100644

drivers/soc/mediatek/mtk-svs-mt8192.c +0 -2
@@ -40,8 +40,6 @@ bool svs_mt8192_efuse_parsing(struct svs_platform *svsp)
 			svsb->dcbdet = (svsp->efuse[17] >> 16) & GENMASK(7, 0);
 			svsb->dcmdet = (svsp->efuse[17] >> 24) & GENMASK(7, 0);
 		}
-
-		svsb->vmax += svsb->dvt_fixed;
 	}
 
 	ret = svs_thermal_efuse_get_data(svsp);
#19 lore raw
In reply to [email protected]

Hi Matthias Sir,

Thanks for sharing these great ideas to improve MTK SVS driver. I've added some feedback to this patchset. However, should I just submit the v2 of these patches for you to review? Thanks very much.

Sincerely,
Roger Lu.

Quoted 35 lines · On Wed, 2022-09-28 at 17:55 +0200, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Mediatek SVS driver got accepted upstream but has coding style issues which were overseen in the review process. This series is a first step to clean up the driver. It basically cleans up the SoC specific probe. As next step we will need to clean up the 'struct svs_bank'.

This series should be a mere cleanup with no functional change. I'm happy to recieve tested-by tags to make sure it does not break anything.

Matthias Brugger (8):
soc: mediatek: mtk-svs: clean up platform probing
soc: mediatek: mtk-svs: improve readability of platform_probe
soc: mediatek: mtk-svs: move svs_platform_probe into probe
soc: mediatek: mtk-svs: delete superfluous platform data entries
soc: mediatek: mtk-svs: Move SoC specific functions to new files
soc: mtk-svs: mt8183: Move thermal parsing in new function
soc: mtk-svs: mt8183: refactor o_slope calculation
soc: mtk-svs: mt8192: fix bank data

 drivers/soc/mediatek/Makefile         |   3 +-
 drivers/soc/mediatek/mt8183-svs.h     | 113 ++++
 drivers/soc/mediatek/mt8192-svs.h     |  64 ++
 drivers/soc/mediatek/mtk-svs-mt8183.c | 235 +++++++
 drivers/soc/mediatek/mtk-svs-mt8192.c |  98 +++
 drivers/soc/mediatek/mtk-svs.c        | 882 ++------------------------
 drivers/soc/mediatek/mtk-svs.h        | 279 ++++++++
 7 files changed, 853 insertions(+), 821 deletions(-)
 create mode 100644 drivers/soc/mediatek/mt8183-svs.h
 create mode 100644 drivers/soc/mediatek/mt8192-svs.h
 create mode 100644 drivers/soc/mediatek/mtk-svs-mt8183.c
 create mode 100644 drivers/soc/mediatek/mtk-svs-mt8192.c
 create mode 100644 drivers/soc/mediatek/mtk-svs.h