Skip to contentSkip to conversation

mtk-socinfo driver implementation

PATCH Superseded William-tw Lin 3 participants 9 messages Jul 18, 2023 – Jul 19, 2023

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover mtk-socinfo driver implementation

This purpose for these patches is to enable soc-related information retrival. Such information includes manufacturer information, SoC name, SoC segment name, and SoC marketing name.

Based on tag: next-20230718, linux-next/master

William-tw Lin (3):
soc: mediatek: mtk-socinfo: Add driver for getting chip information
dt-bindings: soc: mediatek: Add mtk-socinfo driver
arm64: dts: Add node for chip info driver

 .../bindings/soc/mediatek/mtk-socinfo.yaml    |  58 +++++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi      |  15 ++
 arch/arm64/boot/dts/mediatek/mt8183.dtsi      |  15 ++
 arch/arm64/boot/dts/mediatek/mt8186.dtsi      |  10 +
 arch/arm64/boot/dts/mediatek/mt8192.dtsi      |  14 ++
 arch/arm64/boot/dts/mediatek/mt8195.dtsi      |   9 +
 drivers/soc/mediatek/Kconfig                  |  18 ++
 drivers/soc/mediatek/Makefile                 |   1 +
 drivers/soc/mediatek/mtk-socinfo.c            | 203 +++++++++++++++++
 drivers/soc/mediatek/mtk-socinfo.h            | 213 ++++++++++++++++++
 10 files changed, 556 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml
 create mode 100644 drivers/soc/mediatek/mtk-socinfo.c
 create mode 100644 drivers/soc/mediatek/mtk-socinfo.h
Signature · 1 line
2.18.0
#1 lore raw

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

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       |  18 +++
 drivers/soc/mediatek/Makefile      |   1 +
 drivers/soc/mediatek/mtk-socinfo.c | 203 +++++++++++++++++++++++++++
 drivers/soc/mediatek/mtk-socinfo.h | 213 +++++++++++++++++++++++++++++
 4 files changed, 435 insertions(+)
 create mode 100644 drivers/soc/mediatek/mtk-socinfo.c
 create mode 100644 drivers/soc/mediatek/mtk-socinfo.h
drivers/soc/mediatek/Kconfig +18 -0
index a88cf04fc803..50bd9ec75ca5 100644
@@ -91,4 +91,22 @@ 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 SOCINFO"
+	depends on MTK_EFUSE && NVMEM
+	help
+	  Say y here to enable mtk socinfo information.
+	  This enables a sysfs node which shows attributes of MTK soc info.
+	  Information of soc info includes the manufacturer, the marketing
+	  name, and the soc used.
+
+config MTK_SOCINFO_DEBUG
+	tristate "MediaTek SOCINFO debug"
+	depends on MTK_SOCINFO
+	help
+	  Say y here to enables a debug node which shows MTK SOC information.
+	  This enables a debug node that gives details on MTK soc info attributes.
+	  Information included in this debug node includes the manufacturer, the marketing
+	  name, the soc used, as well as the segment of the soc.
+
 endmenu
drivers/soc/mediatek/Makefile +1 -0
index 8c0ddacbcde8..c900e5f13a35 100644
@@ -9,3 +9,4 @@ 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
+obj-$(CONFIG_MTK_SOCINFO) += mtk-socinfo.o
drivers/soc/mediatek/mtk-socinfo.c new file +203 -0

203 lines not on this page · raw message

drivers/soc/mediatek/mtk-socinfo.h new file +213 -0

213 lines not on this page · raw message

Signature · 1 line
2.18.0
#4 lore raw

PATCH 2/3 dt-bindings: soc: mediatek: Add mtk-socinfo driver

In reply to William-tw Lin

dt-binding documentation for mtk-socinfo driver. mtk-socinfo driver provides SoC-related information. Such information includes manufacturer information, SoC name, SoC segment name, and SoC marketing name.

---
 .../bindings/soc/mediatek/mtk-socinfo.yaml    | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml
Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml new file +58 -0
new file mode 100644
index 000000000000..4420430a9bca
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/mediatek/mtk-socinfo.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek SOC information
+
+maintainers:
+  - William Lin <[email protected]>
+  - Matthias Brugger <[email protected]>
+  - Kevin Hilman <[email protected]>
+
+description:
+  The MTK socinfo driver can retrieve several
+  SoC related information based on settings in eFuse.
+  Such information include manufacturer information, SoC name,
+  SoC segment name, and SoC marketing name.
+
+
+properties:
+  compatible:
+    enum:
+      - mediatek,mt8173-socinfo
+      - mediatek,mt8183-socinfo
+      - mediatek,mt8186-socinfo
+      - mediatek,mt8188-socinfo
+      - mediatek,mt8192-socinfo
+      - mediatek,mt8195-socinfo
+
+
+  nvmem-cells:
+    description:
+      Phandle to the eFuse data for SoC differentiation.
+    items:
+      - description: eFuse data that mtk-socinfo driver uses for SoC differentiation
+
+  nvmem-cell-names:
+    minItems: 1
+    items:
+      - const: socinfo-data1
+      - const: socinfo-data2
+
+required:
+  - compatible
+  - nvmem-cells
+  - nvmem-cell-names
+
+additionalProperties: false
+
+examples:
+  - |
+        mtk_socinfo: socinfo {
+            compatible = "mediatek,mt8186-socinfo";
+            nvmem-cells = <&socinfo_data1>;
+            nvmem-cell-names = "socinfo-data1";
+        };
+
Signature · 1 line
2.18.0
#6 lore raw

PATCH 3/3 arm64: dts: Add node for chip info driver

In reply to William-tw Lin

Add dts node for socinfo retrieval. This includes the following projects:
MT8173
MT8183
MT8186
MT8192
MT8195

---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 15 +++++++++++++++
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 15 +++++++++++++++
 arch/arm64/boot/dts/mediatek/mt8186.dtsi | 10 ++++++++++
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 14 ++++++++++++++
 arch/arm64/boot/dts/mediatek/mt8195.dtsi |  9 +++++++++
 5 files changed, 63 insertions(+)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +15 -0
index c47d7d900f28..115f907751c1 100644
@@ -590,11 +590,26 @@
 			reg = <0 0x10206000 0 0x1000>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+
+			socinfo_data1: socinfo-data1 {
+				reg = <0x040 0x4>;
+			};
+
+			socinfo_data2: socinfo-data2 {
+				reg = <0x044 0x4>;
+			};
+
 			thermal_calibration: calib@528 {
 				reg = <0x528 0xc>;
 			};
 		};
 
+		mtk_socinfo: mtk-socinfo {
+			compatible = "mediatek,mt8173-socinfo";
+			nvmem-cells = <&socinfo_data1 &socinfo_data2>;
+			nvmem-cell-names = "socinfo-data1", "socinfo-data2";
+		};
+
 		apmixedsys: clock-controller@10209000 {
 			compatible = "mediatek,mt8173-apmixedsys";
 			reg = <0 0x10209000 0 0x1000>;
arch/arm64/boot/dts/mediatek/mt8183.dtsi +15 -0
index 5169779d01df..1035c6d7eb91 100644
@@ -1706,6 +1706,15 @@
 			reg = <0 0x11f10000 0 0x1000>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+
+			socinfo_data1: socinfo-data1 {
+				reg = <0x04C 0x4>;
+			};
+
+			socinfo_data2: socinfo-data2 {
+				reg = <0x060 0x4>;
+			};
+
 			thermal_calibration: calib@180 {
 				reg = <0x180 0xc>;
 			};
@@ -1719,6 +1728,12 @@
 			};
 		};
 
+		mtk_socinfo: mtk-socinfo {
+			compatible = "mediatek,mt8183-socinfo";
+			nvmem-cells = <&socinfo_data1 &socinfo_data2>;
+			nvmem-cell-names = "socinfo-data1", "socinfo-data2";
+		};
+
 		u3phy: t-phy@11f40000 {
 			compatible = "mediatek,mt8183-tphy",
 				     "mediatek,generic-tphy-v2";
arch/arm64/boot/dts/mediatek/mt8186.dtsi +10 -0
index f04ae70c470a..e048e4d994e9 100644
@@ -1660,6 +1660,16 @@
 				reg = <0x59c 0x4>;
 				bits = <0 3>;
 			};
+
+			socinfo_data1: socinfo-data1 {
+				reg = <0x7a0 0x4>;
+			};
+		};
+
+		mtk_socinfo: socinfo {
+			compatible = "mediatek,mt8186-socinfo";
+			nvmem-cells = <&socinfo_data1>;
+			nvmem-cell-names = "socinfo-data1";
 		};
 
 		mipi_tx0: dsi-phy@11cc0000 {
arch/arm64/boot/dts/mediatek/mt8192.dtsi +14 -0
index 5e94cb4aeb44..80066faf2b2c 100644
@@ -1122,6 +1122,14 @@
 			#address-cells = <1>;
 			#size-cells = <1>;
 
+			socinfo_data1: socinfo-data1 {
+				reg = <0x044 0x4>;
+			};
+
+			socinfo_data2: socinfo-data2 {
+				reg = <0x050 0x4>;
+			};
+
 			lvts_e_data1: data1@1c0 {
 				reg = <0x1c0 0x58>;
 			};
@@ -1131,6 +1139,12 @@
 			};
 		};
 
+		mtk_socinfo: mtk-socinfo {
+			compatible = "mediatek,mt8192-socinfo";
+			nvmem-cells = <&socinfo_data1 &socinfo_data2>;
+			nvmem-cell-names = "socinfo-data1", "socinfo-data2";
+		};
+
 		i2c3: i2c@11cb0000 {
 			compatible = "mediatek,mt8192-i2c";
 			reg = <0 0x11cb0000 0 0x1000>,
arch/arm64/boot/dts/mediatek/mt8195.dtsi +9 -0
index 48b72b3645e1..ec8f2c8888cb 100644
@@ -1683,6 +1683,15 @@
 			lvts_efuse_data2: lvts2-calib@1d0 {
 				reg = <0x1d0 0x38>;
 			};
+			socinfo_data1: socinfo-data1 {
+				reg = <0x7a0 0x4>;
+			};
+		};
+
+		mtk_socinfo: socinfo {
+			compatible = "mediatek,mt8195-socinfo";
+			nvmem-cells = <&socinfo_data1>;
+			nvmem-cell-names = "socinfo-data1";
 		};
 
 		u3phy2: t-phy@11c40000 {
Signature · 1 line
2.18.0
#5 lore raw

Re: [PATCH 2/3] dt-bindings: soc: mediatek: Add mtk-socinfo driver

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

dt-binding documentation for mtk-socinfo driver. mtk-socinfo driver provides SoC-related information. Such information includes manufacturer information, SoC name, SoC segment name, and SoC marketing name.

---
 .../bindings/soc/mediatek/mtk-socinfo.yaml    | 58 +++++++++++++++++++

Put it in appropriate place - hwinfo.

Quoted 2 lines
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml

Wrong filename: missing vendor prefix, not matching compatibles.

Quoted 12 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml new file +5 -0
new file mode 100644
index 000000000000..4420430a9bca
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/mediatek/mtk-socinfo.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#

Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml line 15

Quoted 10 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml new file +10 -0
+
+title: MediaTek SOC information
+
+maintainers:
+  - William Lin <[email protected]>
+  - Matthias Brugger <[email protected]>
+  - Kevin Hilman <[email protected]>
+
+description:
+  The MTK socinfo driver can retrieve several

Driver? As in Linux driver? Drop. Describe hardware instead.

Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml line 20

Quoted 5 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml new file +5 -0
+  SoC related information based on settings in eFuse.
+  Such information include manufacturer information, SoC name,
+  SoC segment name, and SoC marketing name.
+
+

Just one blank line.

Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml line 31

Quoted 11 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml new file +11 -0
+properties:
+  compatible:
+    enum:
+      - mediatek,mt8173-socinfo
+      - mediatek,mt8183-socinfo
+      - mediatek,mt8186-socinfo
+      - mediatek,mt8188-socinfo
+      - mediatek,mt8192-socinfo
+      - mediatek,mt8195-socinfo
+
+

Ditto...

Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml line 42

Quoted 11 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml new file +11 -0
+  nvmem-cells:
+    description:
+      Phandle to the eFuse data for SoC differentiation.
+    items:
+      - description: eFuse data that mtk-socinfo driver uses for SoC differentiation
+
+  nvmem-cell-names:
+    minItems: 1
+    items:
+      - const: socinfo-data1
+      - const: socinfo-data2

This does not match your cells.

Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml line 53

Quoted 11 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml new file +11 -0
+
+required:
+  - compatible
+  - nvmem-cells
+  - nvmem-cell-names
+
+additionalProperties: false
+
+examples:
+  - |
+        mtk_socinfo: socinfo {

Broken indentation.

Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml line 56

Quoted 3 lines
Documentation/devicetree/bindings/soc/mediatek/mtk-socinfo.yaml new file +3 -0
+            compatible = "mediatek,mt8186-socinfo";
+            nvmem-cells = <&socinfo_data1>;
+            nvmem-cell-names = "socinfo-data1";

No other resources? So this is just DT description of driver? Does not look like suitable for DT in the first place.

Best regards,
Krzysztof

#2 lore raw

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

In reply to William-tw Lin
Quoted 6 lines · 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/mtk-socinfo.c line 32

Quoted 13 lines
drivers/soc/mediatek/mtk-socinfo.c new file +13 -0
+#if IS_ENABLED(CONFIG_MTK_SOCINFO_DEBUG)
+static int mtk_socinfo_socinfo_debug_show(struct seq_file *m, void *p)
+{
+	struct mtk_socinfo *mtk_socinfop = (struct mtk_socinfo *)m->private;
+
+	seq_printf(m, "SOC Manufacturer:   %s\n", soc_manufacturer);
+	seq_printf(m, "SOC Name:           %s\n", mtk_socinfop->name_data->soc_name);
+	seq_printf(m, "SOC segment Name:   %s\n", mtk_socinfop->name_data->soc_segment_name);
+	seq_printf(m, "Marketing Name:     %s\n", mtk_socinfop->name_data->marketing_name);
+
+	return 0;
+}
+DEBUG_FOPS_RO(socinfo);

No, there is socinfo for this.

...

drivers/soc/mediatek/mtk-socinfo.c line 153

Quoted 12 lines
drivers/soc/mediatek/mtk-socinfo.c new file +12 -0
+
+static int mtk_socinfo_probe(struct platform_device *pdev)
+{
+	struct mtk_socinfo *mtk_socinfop;
+	int ret = 0;
+
+	mtk_socinfop = devm_kzalloc(&pdev->dev, sizeof(*mtk_socinfop), GFP_KERNEL);
+	if (!mtk_socinfop)
+		return -ENOMEM;
+
+	mtk_socinfop->dev = &pdev->dev;
+	mtk_socinfop->soc_data = (struct socinfo_data *)of_device_get_match_data(mtk_socinfop->dev);

Why do you need the cast?

drivers/soc/mediatek/mtk-socinfo.c line 156

Quoted 3 lines
drivers/soc/mediatek/mtk-socinfo.c new file +3 -0
+	if (!mtk_socinfop->soc_data) {
+		dev_err(mtk_socinfop->dev, "No mtk-socinfo platform data found\n");
+		return -EPERM;

EPERM? Is this correct errno? How is it even possible?

drivers/soc/mediatek/mtk-socinfo.c line 162

Quoted 6 lines
drivers/soc/mediatek/mtk-socinfo.c new file +6 -0
+	}
+
+	ret = mtk_socinfo_get_socinfo_data(mtk_socinfop);
+	if (ret < 0) {
+		dev_err(mtk_socinfop->dev, "Failed to get socinfo data (ret = %d)\n", ret);
+		return -EINVAL;

return dev_err_probe

drivers/soc/mediatek/mtk-socinfo.c line 171

Quoted 9 lines
drivers/soc/mediatek/mtk-socinfo.c new file +9 -0
+	}
+
+	ret = mtk_socinfo_create_socinfo_node(mtk_socinfop);
+	if (ret != 0) {
+		dev_err(mtk_socinfop->dev, "Failed to create socinfo node (ret = %d)\n", ret);
+		return ret;
+	}
+
+#if IS_ENABLED(CONFIG_MTK_SOCINFO_DEBUG)

Drop #if. If you need to make it conditional, then use standard C code.

drivers/soc/mediatek/mtk-socinfo.c line 175

Quoted 4 lines
drivers/soc/mediatek/mtk-socinfo.c new file +4 -0
+	ret = mtk_socinfo_create_debug_cmds(mtk_socinfop);
+	if (ret != 0) {
+		dev_err(mtk_socinfop->dev, "Failed to create socinfo debug node (ret = %d)\n", ret);
+		return ret;

No, we do not print failures and definitely do not fail probing on debugfs! Come one...

drivers/soc/mediatek/mtk-socinfo.c line 185

Quoted 10 lines
drivers/soc/mediatek/mtk-socinfo.c new file +10 -0
+	}
+#endif
+	return 0;
+}
+
+static int mtk_socinfo_remove(struct platform_device *pdev)
+{
+	if (soc_dev)
+		soc_device_unregister(soc_dev);
+#if IS_ENABLED(CONFIG_MTK_SOCINFO_DEBUG)

Same

Quoted 24 lines
drivers/soc/mediatek/mtk-socinfo.c new file +18 -0
+	debugfs_remove(file_entry);
+#endif
+	return 0;
+}
+
+static struct platform_driver mtk_socinfo = {
+	.probe          = mtk_socinfo_probe,
+	.remove         = mtk_socinfo_remove,
+	.driver         = {
+		.name   = "mtk_socinfo",
+		.owner  = THIS_MODULE,
+		.of_match_table = mtk_socinfo_id_table,
+	},
+};
+module_platform_driver(mtk_socinfo);
+MODULE_AUTHOR("William-TW LIN <[email protected]>");
+MODULE_DESCRIPTION("Mediatek socinfo driver");
+MODULE_LICENSE("GPL");
drivers/soc/mediatek/mtk-socinfo.h new file +0 -0
new file mode 100644
index 000000000000..8fd490311c8b

drivers/soc/mediatek/mtk-socinfo.h line 9

Quoted 9 lines
drivers/soc/mediatek/mtk-socinfo.h new file +9 -0
@@ -0,0 +1,213 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (c) 2023 MediaTek Inc.
+ */
+
+#ifndef __MTK_SOCINFO_H__
+#define __MTK_SOCINFO_H__
+
+#define MODULE_NAME	"[mtk-socinfo]"

No, drop.

Quoted 9 lines
drivers/soc/mediatek/mtk-socinfo.h new file +9 -0
+
+#define DEBUG_FOPS_RO(name)						\
+	static int mtk_socinfo_##name##_debug_open(struct inode *inode,		\
+					   struct file *filp)		\
+	{								\
+		return single_open(filp, mtk_socinfo_##name##_debug_show,	\
+				   inode->i_private);			\
+	}								\
+	static const struct file_operations mtk_socinfo_##name##_debug_fops = {	\

drivers/soc/mediatek/mtk-socinfo.h line 28

Quoted 10 lines
drivers/soc/mediatek/mtk-socinfo.h new file +10 -0
+		.owner = THIS_MODULE,					\
+		.open = mtk_socinfo_##name##_debug_open,			\
+		.read = seq_read,					\
+		.llseek = seq_lseek,					\
+		.release = single_release,				\
+	}
+
+#define MTK_SOCINFO_DENTRY_DATA(name)	{__stringify(name), &mtk_socinfo_##name##_debug_fops}
+
+const char *soc_manufacturer = "MediaTek";

global variable in the header? No, drop.

drivers/soc/mediatek/mtk-socinfo.h line 31

Quoted 3 lines
drivers/soc/mediatek/mtk-socinfo.h new file +3 -0
+
+struct soc_device *soc_dev;
+struct dentry *mtk_socinfo_dir, *file_entry;

Why do you need them in the header?

Quoted 29 lines
drivers/soc/mediatek/mtk-socinfo.h new file +29 -0
+
+struct mtk_socinfo {
+	struct device *dev;
+	struct name_data *name_data;
+	struct socinfo_data *soc_data;
+};
+
+struct efuse_data {
+	char *nvmem_cell_name;
+	u32 efuse_data;
+};
+
+struct name_data {
+	char *soc_name;
+	char *soc_segment_name;
+	char *marketing_name;
+};
+
+struct socinfo_data {
+	char *soc_name;
+	struct efuse_data *efuse_data;
+	struct name_data *name_data;
+	unsigned int efuse_segment_count;
+	unsigned int efuse_data_count;
+};
+
+enum socinfo_data_index {
+	INDEX_MT8186 = 0,
+	INDEX_MT8188,

drivers/soc/mediatek/mtk-socinfo.h line 70

Quoted 10 lines
drivers/soc/mediatek/mtk-socinfo.h new file +10 -0
+	INDEX_MT8195,
+	INDEX_MT8192,
+	INDEX_MT8183,
+	INDEX_MT8173,
+	SOCINFO_DATA_LAST_INDEX
+};
+
+/* begin 8186 info */
+#define mtk_mt8186_EFUSE_DATA_COUNT 1
+static struct efuse_data mtk_mt8186_efuse_data_info[][mtk_mt8186_EFUSE_DATA_COUNT] = {

Nope. Don't put variable in the header. This code is not yet ready to upstream.

Work with your colleagues to submit something passing basic coding style. Please send something reasonable, after doing internal reviews.

Best regards,
Krzysztof

#7 lore raw

Re: [PATCH 3/3] arm64: dts: Add node for chip info driver

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

Add dts node for socinfo retrieval. This includes the following projects:
MT8173
MT8183
MT8186
MT8192
MT8195

---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 15 +++++++++++++++
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 15 +++++++++++++++
 arch/arm64/boot/dts/mediatek/mt8186.dtsi | 10 ++++++++++
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 14 ++++++++++++++
 arch/arm64/boot/dts/mediatek/mt8195.dtsi |  9 +++++++++
 5 files changed, 63 insertions(+)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +5 -0
index c47d7d900f28..115f907751c1 100644
@@ -590,11 +590,26 @@
 			reg = <0 0x10206000 0 0x1000>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+
+			socinfo_data1: socinfo-data1 {
+				reg = <0x040 0x4>;
+			};
+

arch/arm64/boot/dts/mediatek/mt8173.dtsi line 607

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8173.dtsi +5 -0
+			socinfo_data2: socinfo-data2 {
+				reg = <0x044 0x4>;
+			};
+
 			thermal_calibration: calib@528 {
 				reg = <0x528 0xc>;
 			};
 		};
 
+		mtk_socinfo: mtk-socinfo {

Why do you put non-MMIO nodes in MMIO bus?

It does not look like you tested the DTS against bindings. Please run make dtbs_check (see Documentation/devicetree/bindings/writing-schema.rst or
https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
for instructions).

Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

Best regards,
Krzysztof

#8 lore raw

Re: [PATCH 3/3] arm64: dts: Add node for chip info driver

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

Add dts node for socinfo retrieval. This includes the following projects:
MT8173
MT8183
MT8186
MT8192
MT8195

Please
wrap
your
lines. :)

Please use subject prefixes matching the subsystem. You can get them for example with git log --oneline -- DIRECTORY_OR_FILE on the directory your patch is touching.

Anyway, your commit suggests even more that you add driver. Drivers do not have place in DTS nor in bindings. Your code in patch 2 is very poor quality, so considering this "driver approach" I think you just send some random downstream driver. Don't.

Entire concept is NAK.

Best regards,
Krzysztof

#3 lore raw

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

In reply to William-tw Lin

Il 18/07/23 13:21, William-tw Lin ha scritto:

Quoted 14 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

---
  drivers/soc/mediatek/Kconfig       |  18 +++
  drivers/soc/mediatek/Makefile      |   1 +
  drivers/soc/mediatek/mtk-socinfo.c | 203 +++++++++++++++++++++++++++
  drivers/soc/mediatek/mtk-socinfo.h | 213 +++++++++++++++++++++++++++++
  4 files changed, 435 insertions(+)

create mode 100644 drivers/soc/mediatek/mtk-socinfo.c create mode 100644 drivers/soc/mediatek/mtk-socinfo.h

..snip..

drivers/soc/mediatek/mtk-socinfo.h line 73

Quoted 7 lines
drivers/soc/mediatek/mtk-socinfo.h new file +7 -0
+
+/* begin 8186 info */
+#define mtk_mt8186_EFUSE_DATA_COUNT 1
+static struct efuse_data mtk_mt8186_efuse_data_info[][mtk_mt8186_EFUSE_DATA_COUNT] = {
+	{{.nvmem_cell_name = "socinfo-data1", .efuse_data = 0x81861001}},
+	{{.nvmem_cell_name = "socinfo-data1", .efuse_data = 0x81862001}},
+};

I'm *sure* that there's a way to avoid specifying the soc-specific compatible, as the efuse_data is used only for validation, while what you do here is to simply read the SoC ID from eFuse array.

In theory, this driver could simply have

compatible = "mediatek,socinfo";

as compatible string, without any SoC-specific string in the devicetree, at all, so that the SoC ID would get recognized completely dynamically - and adding the name and other strings would be a consequence.

drivers/soc/mediatek/mtk-socinfo.h line 84

Quoted 11 lines
drivers/soc/mediatek/mtk-socinfo.h new file +11 -0
+
+static struct name_data mtk_mt8186_name_data_info[] = {
+	{.soc_name = "MT8186",
+	 .soc_segment_name = "MT8186GV/AZA",
+	 .marketing_name = "Kompanio 520"},
+	{.soc_name = "MT8186T",
+	 .soc_segment_name = "MT8186TV/AZA",
+	 .marketing_name = "Kompanio 528"},
+};
+/* end 8186 info */
+

Regards,
Angelo