Skip to contentSkip to conversation

mtk-socinfo driver implementation

PATCH Applied William-tw Lin 3 participants 10 messages Dec 22, 2023 – Jan 29, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 cover mtk-socinfo driver implementation

v4 changes:
dts:
1. remove phandle from socinfo-data for all platforms

mtk-socinfo.c:
1. use module_platform_driver instead of builtin_platform_driver

drivers/soc/mediatek/Kconfig:
1. add dependency for MTK_SOCINFO

mtk-efuse.c:
1. add remove function

commit message:
1. update commit message by following reviewer's comment

William-tw Lin (3):
arm64: dts: mediatek: Add socinfo efuses to MT8173/83/96/92/95 SoCs
soc: mediatek: mtk-socinfo: Add driver for getting chip information
nvmem: mtk-efuse: Register MediaTek socinfo driver from efuse

 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   9 ++
 arch/arm64/boot/dts/mediatek/mt8183.dtsi |   9 ++
 arch/arm64/boot/dts/mediatek/mt8186.dtsi |   4 +
 arch/arm64/boot/dts/mediatek/mt8192.dtsi |   8 +
 arch/arm64/boot/dts/mediatek/mt8195.dtsi |   3 +
 drivers/nvmem/mtk-efuse.c                |  21 ++-
 drivers/soc/mediatek/Kconfig             |   9 ++
 drivers/soc/mediatek/Makefile            |   1 +
 drivers/soc/mediatek/mtk-socinfo.c       | 186 +++++++++++++++++++++++
 9 files changed, 249 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/mediatek/mtk-socinfo.c
Signature · 1 line
2.18.0
#1 lore raw

PATCH v4 1/3 arm64: dts: mediatek: Add socinfo efuses to MT8173/83/96/92/95 SoCs

Add efuse nodes for socinfo retrieval for MT8173, MT8183, MT8186, MT8192 and MT8195.

---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 9 +++++++++
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 9 +++++++++
 arch/arm64/boot/dts/mediatek/mt8186.dtsi | 4 ++++
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 8 ++++++++
 arch/arm64/boot/dts/mediatek/mt8195.dtsi | 3 +++
 5 files changed, 33 insertions(+)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +9 -0
index c47d7d900f28..0f4aab80d5e4 100644
@@ -590,6 +590,15 @@
 			reg = <0 0x10206000 0 0x1000>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+
+			socinfo-data1@40 {
+				reg = <0x040 0x4>;
+			};
+
+			socinfo-data2@44 {
+				reg = <0x044 0x4>;
+			};
+
 			thermal_calibration: calib@528 {
 				reg = <0x528 0xc>;
 			};
arch/arm64/boot/dts/mediatek/mt8183.dtsi +9 -0
index 976dc968b3ca..1fe351b710ed 100644
@@ -1585,6 +1585,15 @@
 			reg = <0 0x11f10000 0 0x1000>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+
+			socinfo-data1@4c {
+				reg = <0x04c 0x4>;
+			};
+
+			socinfo-data2@60 {
+				reg = <0x060 0x4>;
+			};
+
 			thermal_calibration: calib@180 {
 				reg = <0x180 0xc>;
 			};
arch/arm64/boot/dts/mediatek/mt8186.dtsi +4 -0
index df0c04f2ba1d..7dd0ae965ee0 100644
@@ -1672,6 +1672,10 @@
 				reg = <0x59c 0x4>;
 				bits = <0 3>;
 			};
+
+			socinfo-data1@7a0 {
+				reg = <0x7a0 0x4>;
+			};
 		};
 
 		mipi_tx0: dsi-phy@11cc0000 {
arch/arm64/boot/dts/mediatek/mt8192.dtsi +8 -0
index 69f4cded5dbb..85f2c49be6fc 100644
@@ -1120,6 +1120,14 @@
 			#address-cells = <1>;
 			#size-cells = <1>;
 
+			socinfo-data1@44 {
+				reg = <0x044 0x4>;
+			};
+
+			socinfo-data2@50 {
+				reg = <0x050 0x4>;
+			};
+
 			lvts_e_data1: data1@1c0 {
 				reg = <0x1c0 0x58>;
 			};
arch/arm64/boot/dts/mediatek/mt8195.dtsi +3 -0
index e0ac2e9f5b72..520f7b649cb2 100644
@@ -1686,6 +1686,9 @@
 			lvts_efuse_data2: lvts2-calib@1d0 {
 				reg = <0x1d0 0x38>;
 			};
+			socinfo-data1@7a0 {
+				reg = <0x7a0 0x4>;
+			};
 		};
 
 		u3phy2: t-phy@11c40000 {
Signature · 1 line
2.18.0
#4 lore raw

PATCH v4 2/3 soc: mediatek: mtk-socinfo: Add driver for getting chip information

In reply to William-tw Lin

Add driver for socinfo retrieval. This patch includes the following:
1. mtk-socinfo driver for chip info retrieval
2. Related changes to Makefile and Kconfig

---
 drivers/soc/mediatek/Kconfig       |   9 ++
 drivers/soc/mediatek/Makefile      |   1 +
 drivers/soc/mediatek/mtk-socinfo.c | 186 +++++++++++++++++++++++++++++
 3 files changed, 196 insertions(+)
 create mode 100644 drivers/soc/mediatek/mtk-socinfo.c
drivers/soc/mediatek/Kconfig +9 -0
index 0810b5b0c688..50c664b65f4d 100644
@@ -68,4 +68,13 @@ config MTK_SVS
 	  chip process corner, temperatures and other factors. Then DVFS
 	  driver could apply SVS bank voltage to PMIC/Buck.
 
+config MTK_SOCINFO
+	tristate "MediaTek SoC Information"
+	default y
+	depends on NVMEM_MTK_EFUSE
+	help
+	  The MediaTek SoC Information (mtk-socinfo) driver provides
+	  information about the SoC to the userspace including the
+	  manufacturer name, marketing name and soc name.
+
 endmenu
drivers/soc/mediatek/Makefile +1 -0
index 9d3ce7878c5c..6830512848fd 100644
@@ -7,3 +7,4 @@ obj-$(CONFIG_MTK_REGULATOR_COUPLER) += mtk-regulator-coupler.o
 obj-$(CONFIG_MTK_MMSYS) += mtk-mmsys.o
 obj-$(CONFIG_MTK_MMSYS) += mtk-mutex.o
 obj-$(CONFIG_MTK_SVS) += mtk-svs.o
+obj-$(CONFIG_MTK_SOCINFO) += mtk-socinfo.o
drivers/soc/mediatek/mtk-socinfo.c new file +186 -0

186 lines not on this page · raw message

Signature · 1 line
2.18.0
maintainer Reviewed-by on v4 2/3
#5 lore raw

Re: [PATCH v4 2/3] soc: mediatek: mtk-socinfo: Add driver for getting chip information

Il 22/12/23 09:07, William-tw Lin ha scritto:

Quoted 5 lines

Add driver for socinfo retrieval. This patch includes the following:
1. mtk-socinfo driver for chip info retrieval
2. Related changes to Makefile and Kconfig

maintainer Applied
#6 lore raw

Re: [PATCH v4 2/3] soc: mediatek: mtk-socinfo: Add driver for getting chip information

In reply to William-tw Lin

Il 22/12/23 09:07, William-tw Lin ha scritto:

Quoted 5 lines

Add driver for socinfo retrieval. This patch includes the following:
1. mtk-socinfo driver for chip info retrieval
2. Related changes to Makefile and Kconfig

Applied to v6.4-next/soc

Thanks!
Angelo

#7 lore raw

PATCH v4 3/3 nvmem: mtk-efuse: Register MediaTek socinfo driver from efuse

In reply to William-tw Lin

The socinfo driver reads chip information from eFuses and does not need any devicetree node. Register it from mtk-efuse.

While at it, also add the name for this driver's nvmem_config.

---
 drivers/nvmem/mtk-efuse.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/nvmem/mtk-efuse.c +20 -1
index 84f05b40a411..f5bebcecf9bd 100644
@@ -68,6 +68,7 @@ static int mtk_efuse_probe(struct platform_device *pdev)
 	struct nvmem_config econfig = {};
 	struct mtk_efuse_priv *priv;
 	const struct mtk_efuse_pdata *pdata;
+	struct platform_device *socinfo;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -85,11 +86,20 @@ static int mtk_efuse_probe(struct platform_device *pdev)
 	econfig.size = resource_size(res);
 	econfig.priv = priv;
 	econfig.dev = dev;
+	econfig.name = "mtk-efuse";
 	if (pdata->uses_post_processing)
 		econfig.fixup_dt_cell_info = &mtk_efuse_fixup_dt_cell_info;
 	nvmem = devm_nvmem_register(dev, &econfig);
+	if (IS_ERR(nvmem))
+		return PTR_ERR(nvmem);
 
-	return PTR_ERR_OR_ZERO(nvmem);
+	socinfo = platform_device_register_data(&pdev->dev, "mtk-socinfo",
+						PLATFORM_DEVID_AUTO, NULL, 0);
+	if (IS_ERR(socinfo))
+		dev_info(dev, "MediaTek SoC Information will be unavailable\n");
+
+	platform_set_drvdata(pdev, socinfo);
+	return 0;
 }
 
 static const struct mtk_efuse_pdata mtk_mt8186_efuse_pdata = {
@@ -108,8 +118,17 @@ static const struct of_device_id mtk_efuse_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, mtk_efuse_of_match);
 
+static void mtk_efuse_remove(struct platform_device *pdev)
+{
+	struct platform_device *socinfo = platform_get_drvdata(pdev);
+
+	if (!IS_ERR_OR_NULL(socinfo))
+		platform_device_unregister(socinfo);
+}
+
 static struct platform_driver mtk_efuse_driver = {
 	.probe = mtk_efuse_probe,
+	.remove_new = mtk_efuse_remove,
 	.driver = {
 		.name = "mediatek,efuse",
 		.of_match_table = mtk_efuse_of_match,
Signature · 1 line
2.18.0
maintainer Reviewed-by on v4 3/3
#8 lore raw

Re: [PATCH v4 3/3] nvmem: mtk-efuse: Register MediaTek socinfo driver from efuse

Il 22/12/23 09:07, William-tw Lin ha scritto:

Quoted 6 lines

The socinfo driver reads chip information from eFuses and does not need any devicetree node. Register it from mtk-efuse.

While at it, also add the name for this driver's nvmem_config.

#9 lore raw

Re: (subset) [PATCH v4 0/3] mtk-socinfo driver implementation

In reply to William-tw Lin
Quoted 8 lines · William-tw Lin

v4 changes:
dts:
1. remove phandle from socinfo-data for all platforms

mtk-socinfo.c:
1. use module_platform_driver instead of builtin_platform_driver

[...]

Applied, thanks!

[3/3] nvmem: mtk-efuse: Register MediaTek socinfo driver from efuse

      commit: 4e6102d60d88975bc65a0dde05a8ba096c450249

Best regards,

Signature · 1 line
Srinivas Kandagatla <[email protected]>