soc: imx: support i.MX93 soc device

Message ID 20230508120514.1534445-1-peng.fan@oss.nxp.com
State New
Headers
Series soc: imx: support i.MX93 soc device |

Commit Message

Peng Fan (OSS) May 8, 2023, 12:05 p.m. UTC
  From: Peng Fan <peng.fan@nxp.com>

Similar to i.MX8M, add i.MX93 soc device support

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

V1:
 Depends on the binding doc, then this driver could use the compatible
 https://lore.kernel.org/all/20230508114639.1525521-1-peng.fan@oss.nxp.com/

 drivers/soc/imx/Makefile    |  2 +-
 drivers/soc/imx/soc-imx8m.c | 70 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 70 insertions(+), 2 deletions(-)
  

Comments

kernel test robot May 8, 2023, 2:06 p.m. UTC | #1
Hi Peng,

kernel test robot noticed the following build errors:

[auto build test ERROR on shawnguo/for-next]
[also build test ERROR on linus/master v6.4-rc1 next-20230508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Peng-Fan-OSS/soc-imx-support-i-MX93-soc-device/20230508-200452
base:   https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git for-next
patch link:    https://lore.kernel.org/r/20230508120514.1534445-1-peng.fan%40oss.nxp.com
patch subject: [PATCH] soc: imx: support i.MX93 soc device
config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20230508/202305082103.ihPSWO6i-lkp@intel.com/config)
compiler: ia64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/d4fb96ce70f039deaf626914f91ca5ce8b74790a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Peng-Fan-OSS/soc-imx-support-i-MX93-soc-device/20230508-200452
        git checkout d4fb96ce70f039deaf626914f91ca5ce8b74790a
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/soc/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202305082103.ihPSWO6i-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/soc/imx/soc-imx8m.c:199:23: error: 'SZ_8' undeclared here (not in a function)
     199 |         .uid_length = SZ_8,
         |                       ^~~~
>> drivers/soc/imx/soc-imx8m.c:223:23: error: 'SZ_16' undeclared here (not in a function)
     223 |         .uid_length = SZ_16,
         |                       ^~~~~


vim +/SZ_8 +199 drivers/soc/imx/soc-imx8m.c

   195	
   196	static const struct imx8_soc_data imx8mq_soc_data = {
   197		.name = "i.MX8MQ",
   198		.soc_revision = imx8mq_soc_revision,
 > 199		.uid_length = SZ_8,
   200	};
   201	
   202	static const struct imx8_soc_data imx8mm_soc_data = {
   203		.name = "i.MX8MM",
   204		.soc_revision = imx8mm_soc_revision,
   205		.uid_length = SZ_8,
   206	};
   207	
   208	static const struct imx8_soc_data imx8mn_soc_data = {
   209		.name = "i.MX8MN",
   210		.soc_revision = imx8mm_soc_revision,
   211		.uid_length = SZ_8,
   212	};
   213	
   214	static const struct imx8_soc_data imx8mp_soc_data = {
   215		.name = "i.MX8MP",
   216		.soc_revision = imx8mm_soc_revision,
   217		.uid_length = SZ_8,
   218	};
   219	
   220	static const struct imx8_soc_data imx93_soc_data = {
   221		.name = "i.MX93",
   222		.soc_revision = imx93_soc_revision,
 > 223		.uid_length = SZ_16,
   224	};
   225
  

Patch

diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile
index a28c44a1f16a..83aff181ae51 100644
--- a/drivers/soc/imx/Makefile
+++ b/drivers/soc/imx/Makefile
@@ -7,5 +7,5 @@  obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o
 obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o
 obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8m-blk-ctrl.o
 obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8mp-blk-ctrl.o
-obj-$(CONFIG_SOC_IMX9) += imx93-src.o imx93-pd.o
+obj-$(CONFIG_SOC_IMX9) += soc-imx8m.o imx93-src.o imx93-pd.o
 obj-$(CONFIG_IMX9_BLK_CTRL) += imx93-blk-ctrl.o
diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
index 1dcd243df567..7359c870e7f8 100644
--- a/drivers/soc/imx/soc-imx8m.c
+++ b/drivers/soc/imx/soc-imx8m.c
@@ -25,15 +25,20 @@ 
 
 #define IMX8MP_OCOTP_UID_OFFSET		0x10
 
+#define IMX93_OCOTP_UID_OFFSET		0x80c0
+
 /* Same as ANADIG_DIGPROG_IMX7D */
 #define ANADIG_DIGPROG_IMX8MM	0x800
+#define ANADIG_DIGPROG_IMX93	0x800
 
 struct imx8_soc_data {
 	char *name;
 	u32 (*soc_revision)(void);
+	int uid_length;
 };
 
 static u64 soc_uid;
+static u64 soc_uid_h;
 
 #ifdef CONFIG_HAVE_ARM_SMCCC
 static u32 imx8mq_soc_revision_from_atf(void)
@@ -141,24 +146,81 @@  static u32 __init imx8mm_soc_revision(void)
 	return rev;
 }
 
+static void __init imx93_soc_uid(void)
+{
+	void __iomem *ocotp_base;
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx93-ocotp");
+	if (!np)
+		return;
+
+	ocotp_base = of_iomap(np, 0);
+	WARN_ON(!ocotp_base);
+
+	soc_uid = readl_relaxed(ocotp_base + IMX93_OCOTP_UID_OFFSET + 0x8);
+	soc_uid <<= 32;
+	soc_uid |= readl_relaxed(ocotp_base + IMX93_OCOTP_UID_OFFSET + 0xC);
+
+	soc_uid_h = readl_relaxed(ocotp_base + IMX93_OCOTP_UID_OFFSET + 0x0);
+	soc_uid_h <<= 32;
+	soc_uid_h |= readl_relaxed(ocotp_base + IMX93_OCOTP_UID_OFFSET + 0x4);
+
+	iounmap(ocotp_base);
+	of_node_put(np);
+}
+
+static u32 __init imx93_soc_revision(void)
+{
+	struct device_node *np;
+	void __iomem *anatop_base;
+	u32 rev;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx93-anatop");
+	if (!np)
+		return 0;
+
+	anatop_base = of_iomap(np, 0);
+	WARN_ON(!anatop_base);
+
+	rev = readl_relaxed(anatop_base + ANADIG_DIGPROG_IMX93);
+
+	iounmap(anatop_base);
+	of_node_put(np);
+
+	imx93_soc_uid();
+
+	return rev;
+}
+
 static const struct imx8_soc_data imx8mq_soc_data = {
 	.name = "i.MX8MQ",
 	.soc_revision = imx8mq_soc_revision,
+	.uid_length = SZ_8,
 };
 
 static const struct imx8_soc_data imx8mm_soc_data = {
 	.name = "i.MX8MM",
 	.soc_revision = imx8mm_soc_revision,
+	.uid_length = SZ_8,
 };
 
 static const struct imx8_soc_data imx8mn_soc_data = {
 	.name = "i.MX8MN",
 	.soc_revision = imx8mm_soc_revision,
+	.uid_length = SZ_8,
 };
 
 static const struct imx8_soc_data imx8mp_soc_data = {
 	.name = "i.MX8MP",
 	.soc_revision = imx8mm_soc_revision,
+	.uid_length = SZ_8,
+};
+
+static const struct imx8_soc_data imx93_soc_data = {
+	.name = "i.MX93",
+	.soc_revision = imx93_soc_revision,
+	.uid_length = SZ_16,
 };
 
 static __maybe_unused const struct of_device_id imx8_soc_match[] = {
@@ -166,6 +228,7 @@  static __maybe_unused const struct of_device_id imx8_soc_match[] = {
 	{ .compatible = "fsl,imx8mm", .data = &imx8mm_soc_data, },
 	{ .compatible = "fsl,imx8mn", .data = &imx8mn_soc_data, },
 	{ .compatible = "fsl,imx8mp", .data = &imx8mp_soc_data, },
+	{ .compatible = "fsl,imx93", .data = &imx93_soc_data, },
 	{ }
 };
 
@@ -212,7 +275,12 @@  static int __init imx8_soc_init(void)
 		goto free_soc;
 	}
 
-	soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
+	if (soc_uid_h) {
+		soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX%016llX",
+							soc_uid_h, soc_uid);
+	} else {
+		soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid);
+	}
 	if (!soc_dev_attr->serial_number) {
 		ret = -ENOMEM;
 		goto free_rev;