linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] soc: ti: add k3 platforms chipid module driver
@ 2020-04-23 18:05 Grygorii Strashko
  2020-04-23 18:05 ` [PATCH 1/5] dt-bindings: soc: ti: add binding for k3 platforms chipid module Grygorii Strashko
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Grygorii Strashko @ 2020-04-23 18:05 UTC (permalink / raw)
  To: Dave Gerlach, Santosh Shilimkar, Tero Kristo, Nishanth Menon,
	Rob Herring, Catalin Marinas, Will Deacon, Lokesh Vutla
  Cc: Sekhar Nori, linux-arm-kernel, linux-kernel, devicetree,
	Grygorii Strashko

Hi All,

This series introduces TI K3 Multicore SoC platforms chipid module driver
which provides identification support of the TI K3 SoCs (family, revision)
and register this information with the SoC bus. It is available under
/sys/devices/soc0/ for user space, and can be checked, where needed,
in Kernel using soc_device_match().
It is also required for introducing support for new revisions of
K3 AM65x/J721E SoCs.

Example J721E:
  # cat /sys/devices/soc0/{machine,family,revision}
  Texas Instruments K3 J721E SoC
  J721E
  SR1.0

Example AM65x:
  # cat /sys/devices/soc0/{machine,family,revision}
  Texas Instruments AM654 Base Board
  AM65X
  SR1.0

Grygorii Strashko (5):
  dt-bindings: soc: ti: add binding for k3 platforms chipid module
  soc: ti: add k3 platforms chipid module driver
  arm64: arch_k3: enable chipid driver
  arm64: dts: ti: k3-am65-wakeup: add k3 platforms chipid module node
  arm64: dts: ti: k3-j721e-mcu-wakeup: add k3 platforms chipid module
    node

 .../bindings/soc/ti/k3-socinfo.yaml           |  40 ++++++
 arch/arm64/Kconfig.platforms                  |   1 +
 arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi    |   5 +
 .../boot/dts/ti/k3-j721e-mcu-wakeup.dtsi      |   5 +
 drivers/soc/ti/Kconfig                        |  10 ++
 drivers/soc/ti/Makefile                       |   1 +
 drivers/soc/ti/k3-socinfo.c                   | 135 ++++++++++++++++++
 7 files changed, 197 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/ti/k3-socinfo.yaml
 create mode 100644 drivers/soc/ti/k3-socinfo.c

-- 
2.17.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/5] dt-bindings: soc: ti: add binding for k3 platforms chipid module
  2020-04-23 18:05 [PATCH 0/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
@ 2020-04-23 18:05 ` Grygorii Strashko
  2020-05-04  9:38   ` Grygorii Strashko
  2020-04-23 18:05 ` [PATCH 2/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Grygorii Strashko @ 2020-04-23 18:05 UTC (permalink / raw)
  To: Dave Gerlach, Santosh Shilimkar, Tero Kristo, Nishanth Menon,
	Rob Herring, Catalin Marinas, Will Deacon, Lokesh Vutla
  Cc: Sekhar Nori, linux-arm-kernel, linux-kernel, devicetree,
	Grygorii Strashko

Add DT binding for Texas Instruments K3 Multicore SoC platforms chipid
module which is represented by CTRLMMR_xxx_JTAGID register and contains
information about SoC id and revision.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 .../bindings/soc/ti/k3-socinfo.yaml           | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/ti/k3-socinfo.yaml

diff --git a/Documentation/devicetree/bindings/soc/ti/k3-socinfo.yaml b/Documentation/devicetree/bindings/soc/ti/k3-socinfo.yaml
new file mode 100644
index 000000000000..a1a8423b2e2e
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/ti/k3-socinfo.yaml
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/ti/k3-socinfo.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments K3 Multicore SoC platforms chipid module
+
+maintainers:
+  - Tero Kristo <t-kristo@ti.com>
+  - Nishanth Menon <nm@ti.com>
+
+description: |
+  Texas Instruments (ARM64) K3 Multicore SoC platforms chipid module is
+  represented by CTRLMMR_xxx_JTAGID register which contains information about
+  SoC id and revision.
+
+properties:
+  $nodename:
+    pattern: "^chipid@[0-9a-f]+$"
+
+  compatible:
+    items:
+      - const: ti,am654-chipid
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    chipid@43000014 {
+        compatible = "ti,am654-chipid";
+        reg = <0x43000014 0x4>;
+    };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/5] soc: ti: add k3 platforms chipid module driver
  2020-04-23 18:05 [PATCH 0/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
  2020-04-23 18:05 ` [PATCH 1/5] dt-bindings: soc: ti: add binding for k3 platforms chipid module Grygorii Strashko
@ 2020-04-23 18:05 ` Grygorii Strashko
  2020-04-24  4:36   ` Lokesh Vutla
  2020-04-23 18:05 ` [PATCH 3/5] arm64: arch_k3: enable chipid driver Grygorii Strashko
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Grygorii Strashko @ 2020-04-23 18:05 UTC (permalink / raw)
  To: Dave Gerlach, Santosh Shilimkar, Tero Kristo, Nishanth Menon,
	Rob Herring, Catalin Marinas, Will Deacon, Lokesh Vutla
  Cc: Sekhar Nori, linux-arm-kernel, linux-kernel, devicetree,
	Grygorii Strashko

The Texas Instruments K3 Multicore SoC platforms have chipid module which
is represented by CTRLMMR_xxx_JTAGID register and contains information
about SoC id and revision.
 Bits:
  31-28 VARIANT Device variant
  27-12 PARTNO  Part number
  11-1  MFG     Indicates TI as manufacturer (0x17)
  1             Always 1

This patch adds corresponding driver to identify the TI K3 SoC family and
revision, and registers this information with the SoC bus. It is available
under /sys/devices/soc0/ for user space, and can be checked, where needed,
in Kernel using soc_device_match().

Identification is done by:
- checking MFG to be TI ID
 - retrieving Device variant (revision)
 - retrieving Part number and convert it to the family
 - retrieving machine from DT "/model"

Example J721E:
  # cat /sys/devices/soc0/{machine,family,revision}
  Texas Instruments K3 J721E SoC
  J721E
  SR1.0

Example AM65x:
  # cat /sys/devices/soc0/{machine,family,revision}
  Texas Instruments AM654 Base Board
  AM65X
  SR1.0

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/soc/ti/Kconfig      |  10 +++
 drivers/soc/ti/Makefile     |   1 +
 drivers/soc/ti/k3-socinfo.c | 135 ++++++++++++++++++++++++++++++++++++
 3 files changed, 146 insertions(+)
 create mode 100644 drivers/soc/ti/k3-socinfo.c

diff --git a/drivers/soc/ti/Kconfig b/drivers/soc/ti/Kconfig
index 4486e055794c..e192fb788836 100644
--- a/drivers/soc/ti/Kconfig
+++ b/drivers/soc/ti/Kconfig
@@ -91,6 +91,16 @@ config TI_K3_RINGACC
 	  and a consumer. There is one RINGACC module per NAVSS on TI AM65x SoCs
 	  If unsure, say N.
 
+config TI_K3_SOCINFO
+	bool
+	depends on ARCH_K3 || COMPILE_TEST
+	select SOC_BUS
+	select MFD_SYSCON
+	help
+	  Include support for the SoC bus socinfo for the TI K3 Multicore SoC
+	  platforms to provide information about the SoC family and
+	  variant to user space.
+
 endif # SOC_TI
 
 config TI_SCI_INTA_MSI_DOMAIN
diff --git a/drivers/soc/ti/Makefile b/drivers/soc/ti/Makefile
index bec827937a5f..1110e5c98685 100644
--- a/drivers/soc/ti/Makefile
+++ b/drivers/soc/ti/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_WKUP_M3_IPC)		+= wkup_m3_ipc.o
 obj-$(CONFIG_TI_SCI_PM_DOMAINS)		+= ti_sci_pm_domains.o
 obj-$(CONFIG_TI_SCI_INTA_MSI_DOMAIN)	+= ti_sci_inta_msi.o
 obj-$(CONFIG_TI_K3_RINGACC)		+= k3-ringacc.o
+obj-$(CONFIG_TI_K3_SOCINFO)		+= k3-socinfo.o
diff --git a/drivers/soc/ti/k3-socinfo.c b/drivers/soc/ti/k3-socinfo.c
new file mode 100644
index 000000000000..a0c97b3bd063
--- /dev/null
+++ b/drivers/soc/ti/k3-socinfo.c
@@ -0,0 +1,135 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * TI K3 SoC info driver
+ *
+ * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/mfd/syscon.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/sys_soc.h>
+
+#define CTRLMMR_WKUP_JTAGID_REG		0
+/*
+ * Bits:
+ *  31-28 VARIANT	Device variant
+ *  27-12 PARTNO	Part number
+ *  11-1  MFG		Indicates TI as manufacturer (0x17)
+ *  1			Always 1
+ */
+#define CTRLMMR_WKUP_JTAGID_VARIANT_SHIFT	(28)
+#define CTRLMMR_WKUP_JTAGID_VARIANT_MASK	GENMASK(31, 28)
+
+#define CTRLMMR_WKUP_JTAGID_PARTNO_SHIFT	(12)
+#define CTRLMMR_WKUP_JTAGID_PARTNO_MASK		GENMASK(27, 12)
+
+#define CTRLMMR_WKUP_JTAGID_MFG_SHIFT		(1)
+#define CTRLMMR_WKUP_JTAGID_MFG_MASK		GENMASK(11, 1)
+
+#define CTRLMMR_WKUP_JTAGID_MFG_TI		0x17
+
+static const struct k3_soc_id {
+	unsigned int id;
+	const char *family_name;
+} k3_soc_ids[] = {
+	{ 0xBB5A, "AM65X" },
+	{ 0xBB64, "J721E" },
+};
+
+static int __init partno_to_names(unsigned int partno,
+				  struct soc_device_attribute *soc_dev_attr)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(k3_soc_ids); i++)
+		if (partno == k3_soc_ids[i].id) {
+			soc_dev_attr->family = k3_soc_ids[i].family_name;
+			return 0;
+		}
+
+	return -EINVAL;
+}
+
+static int __init k3_chipinfo_init(void)
+{
+	struct soc_device_attribute *soc_dev_attr;
+	struct soc_device *soc_dev;
+	struct device_node *node;
+	struct regmap *regmap;
+	u32 jtag_id;
+	u32 partno_id;
+	u32 variant;
+	u32 mfg;
+	int ret;
+
+	node = of_find_compatible_node(NULL, NULL, "ti,am654-chipid");
+	if (!node)
+		return -ENODEV;
+
+	regmap = device_node_to_regmap(node);
+	of_node_put(node);
+
+	if (IS_ERR(regmap))
+		return PTR_ERR(regmap);
+
+	ret = regmap_read(regmap, CTRLMMR_WKUP_JTAGID_REG, &jtag_id);
+	if (ret < 0)
+		return ret;
+
+	mfg = (jtag_id & CTRLMMR_WKUP_JTAGID_MFG_MASK) >>
+	       CTRLMMR_WKUP_JTAGID_MFG_SHIFT;
+
+	if (mfg != CTRLMMR_WKUP_JTAGID_MFG_TI) {
+		pr_err("Invalid MFG SoC\n");
+		return -ENODEV;
+	}
+
+	variant = (jtag_id & CTRLMMR_WKUP_JTAGID_VARIANT_MASK) >>
+		  CTRLMMR_WKUP_JTAGID_VARIANT_SHIFT;
+	variant++;
+
+	partno_id = (jtag_id & CTRLMMR_WKUP_JTAGID_PARTNO_MASK) >>
+		 CTRLMMR_WKUP_JTAGID_PARTNO_SHIFT;
+
+	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
+	if (!soc_dev_attr)
+		return -ENOMEM;
+
+	soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%x.0", variant);
+
+	ret = partno_to_names(partno_id, soc_dev_attr);
+	if (ret) {
+		pr_err("Unknown SoC JTAGID[0x%08X]\n", jtag_id);
+		ret = -ENODEV;
+		goto err;
+	}
+
+	node = of_find_node_by_path("/");
+	of_property_read_string(node, "model", &soc_dev_attr->machine);
+	of_node_put(node);
+
+	soc_dev = soc_device_register(soc_dev_attr);
+	if (IS_ERR(soc_dev)) {
+		ret = PTR_ERR(soc_dev);
+		goto err;
+	}
+
+	pr_debug("Family:%s rev:%s JTAGID[0x%08x] Detected\n",
+		 soc_dev_attr->family,
+		 soc_dev_attr->revision, jtag_id);
+
+	return 0;
+
+err:
+	kfree(soc_dev_attr->revision);
+	kfree(soc_dev_attr);
+	return ret;
+}
+
+subsys_initcall(k3_chipinfo_init);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/5] arm64: arch_k3: enable chipid driver
  2020-04-23 18:05 [PATCH 0/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
  2020-04-23 18:05 ` [PATCH 1/5] dt-bindings: soc: ti: add binding for k3 platforms chipid module Grygorii Strashko
  2020-04-23 18:05 ` [PATCH 2/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
@ 2020-04-23 18:05 ` Grygorii Strashko
  2020-04-23 18:05 ` [PATCH 4/5] arm64: dts: ti: k3-am65-wakeup: add k3 platforms chipid module node Grygorii Strashko
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Grygorii Strashko @ 2020-04-23 18:05 UTC (permalink / raw)
  To: Dave Gerlach, Santosh Shilimkar, Tero Kristo, Nishanth Menon,
	Rob Herring, Catalin Marinas, Will Deacon, Lokesh Vutla
  Cc: Sekhar Nori, linux-arm-kernel, linux-kernel, devicetree,
	Grygorii Strashko

Select TI chip id driver for TI's SoCs based on K3 architecture to provide
this information to user space and Kernel as it is required by other
drivers to determine SoC revision to function properly.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 arch/arm64/Kconfig.platforms | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index 55d70cfe0f9e..174dd4fc6cf2 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -98,6 +98,7 @@ config ARCH_K3
 	select TI_SCI_PROTOCOL
 	select TI_SCI_INTR_IRQCHIP
 	select TI_SCI_INTA_IRQCHIP
+	select TI_K3_SOCINFO
 	help
 	  This enables support for Texas Instruments' K3 multicore SoC
 	  architecture.
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/5] arm64: dts: ti: k3-am65-wakeup: add k3 platforms chipid module node
  2020-04-23 18:05 [PATCH 0/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
                   ` (2 preceding siblings ...)
  2020-04-23 18:05 ` [PATCH 3/5] arm64: arch_k3: enable chipid driver Grygorii Strashko
@ 2020-04-23 18:05 ` Grygorii Strashko
  2020-04-23 18:05 ` [PATCH 5/5] arm64: dts: ti: k3-j721e-mcu-wakeup: " Grygorii Strashko
  2020-05-01 20:55 ` [PATCH 0/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
  5 siblings, 0 replies; 10+ messages in thread
From: Grygorii Strashko @ 2020-04-23 18:05 UTC (permalink / raw)
  To: Dave Gerlach, Santosh Shilimkar, Tero Kristo, Nishanth Menon,
	Rob Herring, Catalin Marinas, Will Deacon, Lokesh Vutla
  Cc: Sekhar Nori, linux-arm-kernel, linux-kernel, devicetree,
	Grygorii Strashko

Add DT node for the Texas Instruments K3 Multicore AM65x SoC platforms
chipid module.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi b/arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi
index f4227e2743f2..b79492fa8b5f 100644
--- a/arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi
@@ -34,6 +34,11 @@
 		};
 	};
 
+	chipid@43000014 {
+		compatible = "ti,am654-chipid";
+		reg = <0x43000014 0x4>;
+	};
+
 	wkup_pmx0: pinmux@4301c000 {
 		compatible = "pinctrl-single";
 		reg = <0x4301c000 0x118>;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/5] arm64: dts: ti: k3-j721e-mcu-wakeup: add k3 platforms chipid module node
  2020-04-23 18:05 [PATCH 0/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
                   ` (3 preceding siblings ...)
  2020-04-23 18:05 ` [PATCH 4/5] arm64: dts: ti: k3-am65-wakeup: add k3 platforms chipid module node Grygorii Strashko
@ 2020-04-23 18:05 ` Grygorii Strashko
  2020-05-01 20:55 ` [PATCH 0/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
  5 siblings, 0 replies; 10+ messages in thread
From: Grygorii Strashko @ 2020-04-23 18:05 UTC (permalink / raw)
  To: Dave Gerlach, Santosh Shilimkar, Tero Kristo, Nishanth Menon,
	Rob Herring, Catalin Marinas, Will Deacon, Lokesh Vutla
  Cc: Sekhar Nori, linux-arm-kernel, linux-kernel, devicetree,
	Grygorii Strashko

Add DT node for the Texas Instruments K3 Multicore J721E SoC platforms
chipid module.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi b/arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi
index 3d6064125b40..b69688f0f925 100644
--- a/arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi
@@ -48,6 +48,11 @@
 		};
 	};
 
+	chipid@43000014 {
+		compatible = "ti,am654-chipid";
+		reg = <0x0 0x43000014 0x0 0x4>;
+	};
+
 	wkup_pmx0: pinmux@4301c000 {
 		compatible = "pinctrl-single";
 		/* Proxy 0 addressing */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/5] soc: ti: add k3 platforms chipid module driver
  2020-04-23 18:05 ` [PATCH 2/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
@ 2020-04-24  4:36   ` Lokesh Vutla
  0 siblings, 0 replies; 10+ messages in thread
From: Lokesh Vutla @ 2020-04-24  4:36 UTC (permalink / raw)
  To: Grygorii Strashko, Dave Gerlach, Santosh Shilimkar, Tero Kristo,
	Nishanth Menon, Rob Herring, Catalin Marinas, Will Deacon
  Cc: Sekhar Nori, linux-arm-kernel, linux-kernel, devicetree



On 23/04/20 11:35 PM, Grygorii Strashko wrote:
> The Texas Instruments K3 Multicore SoC platforms have chipid module which
> is represented by CTRLMMR_xxx_JTAGID register and contains information
> about SoC id and revision.
>  Bits:
>   31-28 VARIANT Device variant
>   27-12 PARTNO  Part number
>   11-1  MFG     Indicates TI as manufacturer (0x17)
>   1             Always 1
> 
> This patch adds corresponding driver to identify the TI K3 SoC family and
> revision, and registers this information with the SoC bus. It is available
> under /sys/devices/soc0/ for user space, and can be checked, where needed,
> in Kernel using soc_device_match().
> 
> Identification is done by:
> - checking MFG to be TI ID
>  - retrieving Device variant (revision)
>  - retrieving Part number and convert it to the family
>  - retrieving machine from DT "/model"
> 
> Example J721E:
>   # cat /sys/devices/soc0/{machine,family,revision}
>   Texas Instruments K3 J721E SoC
>   J721E
>   SR1.0
> 
> Example AM65x:
>   # cat /sys/devices/soc0/{machine,family,revision}
>   Texas Instruments AM654 Base Board
>   AM65X
>   SR1.0
> 
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

Very minor comments, other than that:

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>


> ---
>  drivers/soc/ti/Kconfig      |  10 +++
>  drivers/soc/ti/Makefile     |   1 +
>  drivers/soc/ti/k3-socinfo.c | 135 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 146 insertions(+)
>  create mode 100644 drivers/soc/ti/k3-socinfo.c
> 
> diff --git a/drivers/soc/ti/Kconfig b/drivers/soc/ti/Kconfig
> index 4486e055794c..e192fb788836 100644
> --- a/drivers/soc/ti/Kconfig
> +++ b/drivers/soc/ti/Kconfig
> @@ -91,6 +91,16 @@ config TI_K3_RINGACC
>  	  and a consumer. There is one RINGACC module per NAVSS on TI AM65x SoCs
>  	  If unsure, say N.
>  
> +config TI_K3_SOCINFO
> +	bool
> +	depends on ARCH_K3 || COMPILE_TEST
> +	select SOC_BUS
> +	select MFD_SYSCON
> +	help
> +	  Include support for the SoC bus socinfo for the TI K3 Multicore SoC
> +	  platforms to provide information about the SoC family and
> +	  variant to user space.
> +
>  endif # SOC_TI
>  
>  config TI_SCI_INTA_MSI_DOMAIN
> diff --git a/drivers/soc/ti/Makefile b/drivers/soc/ti/Makefile
> index bec827937a5f..1110e5c98685 100644
> --- a/drivers/soc/ti/Makefile
> +++ b/drivers/soc/ti/Makefile
> @@ -11,3 +11,4 @@ obj-$(CONFIG_WKUP_M3_IPC)		+= wkup_m3_ipc.o
>  obj-$(CONFIG_TI_SCI_PM_DOMAINS)		+= ti_sci_pm_domains.o
>  obj-$(CONFIG_TI_SCI_INTA_MSI_DOMAIN)	+= ti_sci_inta_msi.o
>  obj-$(CONFIG_TI_K3_RINGACC)		+= k3-ringacc.o
> +obj-$(CONFIG_TI_K3_SOCINFO)		+= k3-socinfo.o
> diff --git a/drivers/soc/ti/k3-socinfo.c b/drivers/soc/ti/k3-socinfo.c
> new file mode 100644
> index 000000000000..a0c97b3bd063
> --- /dev/null
> +++ b/drivers/soc/ti/k3-socinfo.c
> @@ -0,0 +1,135 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * TI K3 SoC info driver
> + *
> + * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com
> + */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/mfd/syscon.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/regmap.h>
> +#include <linux/slab.h>
> +#include <linux/string.h>
> +#include <linux/sys_soc.h>
> +
> +#define CTRLMMR_WKUP_JTAGID_REG		0
> +/*
> + * Bits:
> + *  31-28 VARIANT	Device variant
> + *  27-12 PARTNO	Part number
> + *  11-1  MFG		Indicates TI as manufacturer (0x17)
> + *  1			Always 1
> + */
> +#define CTRLMMR_WKUP_JTAGID_VARIANT_SHIFT	(28)
> +#define CTRLMMR_WKUP_JTAGID_VARIANT_MASK	GENMASK(31, 28)
> +
> +#define CTRLMMR_WKUP_JTAGID_PARTNO_SHIFT	(12)
> +#define CTRLMMR_WKUP_JTAGID_PARTNO_MASK		GENMASK(27, 12)
> +
> +#define CTRLMMR_WKUP_JTAGID_MFG_SHIFT		(1)
> +#define CTRLMMR_WKUP_JTAGID_MFG_MASK		GENMASK(11, 1)
> +
> +#define CTRLMMR_WKUP_JTAGID_MFG_TI		0x17
> +
> +static const struct k3_soc_id {
> +	unsigned int id;
> +	const char *family_name;
> +} k3_soc_ids[] = {
> +	{ 0xBB5A, "AM65X" },
> +	{ 0xBB64, "J721E" },
> +};
> +
> +static int __init partno_to_names(unsigned int partno,
> +				  struct soc_device_attribute *soc_dev_attr)
> +{
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(k3_soc_ids); i++)
> +		if (partno == k3_soc_ids[i].id) {
> +			soc_dev_attr->family = k3_soc_ids[i].family_name;
> +			return 0;
> +		}
> +
> +	return -EINVAL;
> +}
> +
> +static int __init k3_chipinfo_init(void)
> +{
> +	struct soc_device_attribute *soc_dev_attr;
> +	struct soc_device *soc_dev;
> +	struct device_node *node;
> +	struct regmap *regmap;
> +	u32 jtag_id;
> +	u32 partno_id;
> +	u32 variant;

I think you missed the reverse order here.

> +	u32 mfg;
> +	int ret;
> +
> +	node = of_find_compatible_node(NULL, NULL, "ti,am654-chipid");
> +	if (!node)
> +		return -ENODEV;
> +
> +	regmap = device_node_to_regmap(node);
> +	of_node_put(node);
> +
> +	if (IS_ERR(regmap))
> +		return PTR_ERR(regmap);
> +
> +	ret = regmap_read(regmap, CTRLMMR_WKUP_JTAGID_REG, &jtag_id);
> +	if (ret < 0)
> +		return ret;
> +
> +	mfg = (jtag_id & CTRLMMR_WKUP_JTAGID_MFG_MASK) >>
> +	       CTRLMMR_WKUP_JTAGID_MFG_SHIFT;
> +
> +	if (mfg != CTRLMMR_WKUP_JTAGID_MFG_TI) {
> +		pr_err("Invalid MFG SoC\n");
> +		return -ENODEV;
> +	}
> +
> +	variant = (jtag_id & CTRLMMR_WKUP_JTAGID_VARIANT_MASK) >>
> +		  CTRLMMR_WKUP_JTAGID_VARIANT_SHIFT;
> +	variant++;
> +
> +	partno_id = (jtag_id & CTRLMMR_WKUP_JTAGID_PARTNO_MASK) >>
> +		 CTRLMMR_WKUP_JTAGID_PARTNO_SHIFT;
> +
> +	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
> +	if (!soc_dev_attr)
> +		return -ENOMEM;
> +
> +	soc_dev_attr->revision = kasprintf(GFP_KERNEL, "SR%x.0", variant);
> +
> +	ret = partno_to_names(partno_id, soc_dev_attr);
> +	if (ret) {
> +		pr_err("Unknown SoC JTAGID[0x%08X]\n", jtag_id);
> +		ret = -ENODEV;
> +		goto err;
> +	}
> +
> +	node = of_find_node_by_path("/");
> +	of_property_read_string(node, "model", &soc_dev_attr->machine);
> +	of_node_put(node);
> +
> +	soc_dev = soc_device_register(soc_dev_attr);
> +	if (IS_ERR(soc_dev)) {
> +		ret = PTR_ERR(soc_dev);
> +		goto err;
> +	}
> +
> +	pr_debug("Family:%s rev:%s JTAGID[0x%08x] Detected\n",
> +		 soc_dev_attr->family,
> +		 soc_dev_attr->revision, jtag_id);

May be pr_info. It is good to print SoC name and revision in the log.

Thanks and regards,
Lokesh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] soc: ti: add k3 platforms chipid module driver
  2020-04-23 18:05 [PATCH 0/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
                   ` (4 preceding siblings ...)
  2020-04-23 18:05 ` [PATCH 5/5] arm64: dts: ti: k3-j721e-mcu-wakeup: " Grygorii Strashko
@ 2020-05-01 20:55 ` Grygorii Strashko
  2020-05-01 21:25   ` santosh.shilimkar
  5 siblings, 1 reply; 10+ messages in thread
From: Grygorii Strashko @ 2020-05-01 20:55 UTC (permalink / raw)
  To: Dave Gerlach, Santosh Shilimkar, Tero Kristo, Nishanth Menon,
	Rob Herring, Catalin Marinas, Will Deacon, Lokesh Vutla
  Cc: Sekhar Nori, linux-arm-kernel, linux-kernel, devicetree

Hi Santosh, Tero

On 23/04/2020 21:05, Grygorii Strashko wrote:
> Hi All,
> 
> This series introduces TI K3 Multicore SoC platforms chipid module driver
> which provides identification support of the TI K3 SoCs (family, revision)
> and register this information with the SoC bus. It is available under
> /sys/devices/soc0/ for user space, and can be checked, where needed,
> in Kernel using soc_device_match().
> It is also required for introducing support for new revisions of
> K3 AM65x/J721E SoCs.
> 
> Example J721E:
>    # cat /sys/devices/soc0/{machine,family,revision}
>    Texas Instruments K3 J721E SoC
>    J721E
>    SR1.0
> 
> Example AM65x:
>    # cat /sys/devices/soc0/{machine,family,revision}
>    Texas Instruments AM654 Base Board
>    AM65X
>    SR1.0
> 
> Grygorii Strashko (5):
>    dt-bindings: soc: ti: add binding for k3 platforms chipid module
>    soc: ti: add k3 platforms chipid module driver
>    arm64: arch_k3: enable chipid driver
>    arm64: dts: ti: k3-am65-wakeup: add k3 platforms chipid module node
>    arm64: dts: ti: k3-j721e-mcu-wakeup: add k3 platforms chipid module
>      node
> 
>   .../bindings/soc/ti/k3-socinfo.yaml           |  40 ++++++
>   arch/arm64/Kconfig.platforms                  |   1 +
>   arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi    |   5 +
>   .../boot/dts/ti/k3-j721e-mcu-wakeup.dtsi      |   5 +
>   drivers/soc/ti/Kconfig                        |  10 ++
>   drivers/soc/ti/Makefile                       |   1 +
>   drivers/soc/ti/k3-socinfo.c                   | 135 ++++++++++++++++++
>   7 files changed, 197 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/soc/ti/k3-socinfo.yaml
>   create mode 100644 drivers/soc/ti/k3-socinfo.c
> 

Any more comments? I'm going resend it.

-- 
Best regards,
grygorii

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] soc: ti: add k3 platforms chipid module driver
  2020-05-01 20:55 ` [PATCH 0/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
@ 2020-05-01 21:25   ` santosh.shilimkar
  0 siblings, 0 replies; 10+ messages in thread
From: santosh.shilimkar @ 2020-05-01 21:25 UTC (permalink / raw)
  To: Grygorii Strashko, Dave Gerlach, Santosh Shilimkar, Tero Kristo,
	Nishanth Menon, Rob Herring, Catalin Marinas, Will Deacon,
	Lokesh Vutla
  Cc: Sekhar Nori, linux-arm-kernel, linux-kernel, devicetree

On 5/1/20 1:55 PM, Grygorii Strashko wrote:
> Hi Santosh, Tero
> 
> On 23/04/2020 21:05, Grygorii Strashko wrote:
>> Hi All,
>>
>> This series introduces TI K3 Multicore SoC platforms chipid module driver
>> which provides identification support of the TI K3 SoCs (family, 
>> revision)
>> and register this information with the SoC bus. It is available under
>> /sys/devices/soc0/ for user space, and can be checked, where needed,
>> in Kernel using soc_device_match().
>> It is also required for introducing support for new revisions of
>> K3 AM65x/J721E SoCs.
>>
>> Example J721E:
>>    # cat /sys/devices/soc0/{machine,family,revision}
>>    Texas Instruments K3 J721E SoC
>>    J721E
>>    SR1.0
>>
>> Example AM65x:
>>    # cat /sys/devices/soc0/{machine,family,revision}
>>    Texas Instruments AM654 Base Board
>>    AM65X
>>    SR1.0
>>
>> Grygorii Strashko (5):
>>    dt-bindings: soc: ti: add binding for k3 platforms chipid module
>>    soc: ti: add k3 platforms chipid module driver
>>    arm64: arch_k3: enable chipid driver
>>    arm64: dts: ti: k3-am65-wakeup: add k3 platforms chipid module node
>>    arm64: dts: ti: k3-j721e-mcu-wakeup: add k3 platforms chipid module
>>      node
>>
>>   .../bindings/soc/ti/k3-socinfo.yaml           |  40 ++++++
>>   arch/arm64/Kconfig.platforms                  |   1 +
>>   arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi    |   5 +
>>   .../boot/dts/ti/k3-j721e-mcu-wakeup.dtsi      |   5 +
>>   drivers/soc/ti/Kconfig                        |  10 ++
>>   drivers/soc/ti/Makefile                       |   1 +
>>   drivers/soc/ti/k3-socinfo.c                   | 135 ++++++++++++++++++
>>   7 files changed, 197 insertions(+)
>>   create mode 100644 
>> Documentation/devicetree/bindings/soc/ti/k3-socinfo.yaml
>>   create mode 100644 drivers/soc/ti/k3-socinfo.c
>>
> 
> Any more comments? I'm going resend it.
> 
If you have acks from DT maintainers, then I suggest you to split this 
series and post platform and drivers patches separately.

Regards,
Santosh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/5] dt-bindings: soc: ti: add binding for k3 platforms chipid module
  2020-04-23 18:05 ` [PATCH 1/5] dt-bindings: soc: ti: add binding for k3 platforms chipid module Grygorii Strashko
@ 2020-05-04  9:38   ` Grygorii Strashko
  0 siblings, 0 replies; 10+ messages in thread
From: Grygorii Strashko @ 2020-05-04  9:38 UTC (permalink / raw)
  To: Dave Gerlach, Santosh Shilimkar, Tero Kristo, Nishanth Menon,
	Rob Herring, Catalin Marinas, Will Deacon, Lokesh Vutla
  Cc: Sekhar Nori, linux-arm-kernel, linux-kernel, devicetree

Hi Rob,

On 23/04/2020 21:05, Grygorii Strashko wrote:
> Add DT binding for Texas Instruments K3 Multicore SoC platforms chipid
> module which is represented by CTRLMMR_xxx_JTAGID register and contains
> information about SoC id and revision.
> 
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
> ---
>   .../bindings/soc/ti/k3-socinfo.yaml           | 40 +++++++++++++++++++
>   1 file changed, 40 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/soc/ti/k3-socinfo.yaml
> 
> diff --git a/Documentation/devicetree/bindings/soc/ti/k3-socinfo.yaml b/Documentation/devicetree/bindings/soc/ti/k3-socinfo.yaml
> new file mode 100644
> index 000000000000..a1a8423b2e2e
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/soc/ti/k3-socinfo.yaml
> @@ -0,0 +1,40 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/soc/ti/k3-socinfo.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Texas Instruments K3 Multicore SoC platforms chipid module
> +
> +maintainers:
> +  - Tero Kristo <t-kristo@ti.com>
> +  - Nishanth Menon <nm@ti.com>
> +
> +description: |
> +  Texas Instruments (ARM64) K3 Multicore SoC platforms chipid module is
> +  represented by CTRLMMR_xxx_JTAGID register which contains information about
> +  SoC id and revision.
> +
> +properties:
> +  $nodename:
> +    pattern: "^chipid@[0-9a-f]+$"
> +
> +  compatible:
> +    items:
> +      - const: ti,am654-chipid
> +
> +  reg:
> +    maxItems: 1
> +
> +required:
> +  - compatible
> +  - reg
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    chipid@43000014 {
> +        compatible = "ti,am654-chipid";
> +        reg = <0x43000014 0x4>;
> +    };
> 

Do you have any comments here?

-- 
Best regards,
grygorii

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-05-04  9:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23 18:05 [PATCH 0/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
2020-04-23 18:05 ` [PATCH 1/5] dt-bindings: soc: ti: add binding for k3 platforms chipid module Grygorii Strashko
2020-05-04  9:38   ` Grygorii Strashko
2020-04-23 18:05 ` [PATCH 2/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
2020-04-24  4:36   ` Lokesh Vutla
2020-04-23 18:05 ` [PATCH 3/5] arm64: arch_k3: enable chipid driver Grygorii Strashko
2020-04-23 18:05 ` [PATCH 4/5] arm64: dts: ti: k3-am65-wakeup: add k3 platforms chipid module node Grygorii Strashko
2020-04-23 18:05 ` [PATCH 5/5] arm64: dts: ti: k3-j721e-mcu-wakeup: " Grygorii Strashko
2020-05-01 20:55 ` [PATCH 0/5] soc: ti: add k3 platforms chipid module driver Grygorii Strashko
2020-05-01 21:25   ` santosh.shilimkar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).