soc: imx: Add SCU SoC info driver support
PATCH v4 1/2 soc: imx: Add SCU SoC info driver support
Add i.MX SCU SoC info driver to support i.MX8QXP SoC, introduce driver dependency into Kconfig as CONFIG_IMX_SCU must be selected to support i.MX SCU SoC driver, also need to use platform driver model to make sure IMX_SCU driver is probed before i.MX SCU SoC driver.
With this patch, SoC info can be read from sysfs:
i.mx8qxp-mek# cat /sys/devices/soc0/family
Freescale i.MX
i.mx8qxp-mek# cat /sys/devices/soc0/soc_id0x2
i.mx8qxp-mek# cat /sys/devices/soc0/machine
Freescale i.MX8QXP MEK
i.mx8qxp-mek# cat /sys/devices/soc0/revision
1.1
---
Changes since V3:
- remove of_device_id table to make it generic for all i.MX8 SoC with SCU inside, and check "fsl,imx-scu" node to devide whether to register soc platform driver;
- for soc_id, just return the value reading from SCU firmware instead of creating string, for detail name of soc_id, the machine name already contains it;
- fix some error handling of kasprintf.
--- drivers/soc/imx/Kconfig | 9 +++ drivers/soc/imx/Makefile | 1 + drivers/soc/imx/soc-imx-scu.c | 155 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 drivers/soc/imx/soc-imx-scu.c
drivers/soc/imx/Kconfig +9 -0
@@ -7,4 +7,13 @@ config IMX_GPCV2_PM_DOMAINS select PM_GENERIC_DOMAINS default y if SOC_IMX7D +config IMX_SCU_SOC + bool "i.MX System Controller Unit SoC info support" + depends on IMX_SCU + select SOC_BUS + help + If you say yes here you get support for the NXP i.MX System + Controller Unit SoC info module, it will provide the SoC info + like SoC family, ID and revision etc. + endmenu
drivers/soc/imx/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o obj-$(CONFIG_ARCH_MXC) += soc-imx8.o +obj-$(CONFIG_IMX_SCU_SOC) += soc-imx-scu.o
drivers/soc/imx/soc-imx-scu.c new file +155 -0
155 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 2/2 arm64: defconfig: Add i.MX SCU SoC info driver
This patch selects CONFIG_IMX_SCU_SOC by default to support i.MX system controller unit SoC info driver.
---
No changes.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -691,6 +691,7 @@ CONFIG_RPMSG_QCOM_GLINK_RPM=y CONFIG_RPMSG_QCOM_GLINK_SMEM=m CONFIG_RPMSG_QCOM_SMD=y CONFIG_RASPBERRYPI_POWER=y +CONFIG_IMX_SCU_SOC=y CONFIG_QCOM_COMMAND_DB=y CONFIG_QCOM_GENI_SE=y CONFIG_QCOM_GLINK_SSR=m
Signature · 7 lines
2.7.4 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
drivers/soc/imx/soc-imx-scu.c line 131
Quoted 3 lines · Anson Huang
drivers/soc/imx/soc-imx-scu.c new file +3
-0+ root =of_find_node_by_path ("/" ); + + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx-scu" );
It's possibly not very important for root or FW communication nodes but you should probably of_node_put those back.
Quoted 8 lines · Leonard Crestez
drivers/soc/imx/soc-imx-scu.c line 131
Quoted 3 lines · Anson Huang
drivers/soc/imx/soc-imx-scu.c new file +3
-0+ root =of_find_node_by_path ("/" ); + + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx-scu" );It's possibly not very important for root or FW communication nodes but you should probably
of_node_putthose back.
Isn't it better/simpler to use of_root?
extern struct device_node *of_root;
Regards.
Hi, Marc/Leonard
Quoted 21 lines
-----Original Message-----
From: Marc Gonzalez [mailto:[email protected]]
Sent: Tuesday, May 21, 2019 8:34 PM
To: Leonard Crestez <[email protected]>; Anson Huang <[email protected]>
Cc: Mark Rutland <[email protected]>; Rob Herring <[email protected]>; Linux ARM <[email protected]>; DT <[email protected]>
Subject: Re: [PATCH V4 1/2] soc: imx: Add SCU SoC info driver supportQuoted 8 lines · Leonard Crestez
drivers/soc/imx/soc-imx-scu.c line 131
Quoted 3 lines · Anson Huang
drivers/soc/imx/soc-imx-scu.c new file +3
-0+ root =of_find_node_by_path ("/" ); + + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx-scu" );It's possibly not very important for root or FW communication nodes but you should probably
of_node_putthose back.
Quoted 3 lines
Isn't it better/simpler to use
of_root?extern struct
device_node*of_root;
You are right, I will add below changes into V5, one change is to use extern of_root directly, the other is to add of_put_node() after "fsl,imx-scu" is found.
@@ -56,7 +56,6 @@ static int imx_scu_soc_probe(struct platform_device *pdev)
{
struct soc_device_attribute *soc_dev_attr;
struct soc_device *soc_dev;
- struct device_node *root;
u32 id, val;
int ret;@@ -72,8 +71,7 @@ static int imx_scu_soc_probe(struct platform_device *pdev)
soc_dev_attr->family = "Freescale i.MX";
- root = of_find_node_by_path("/");
- ret = of_property_read_string(root,
+ ret = of_property_read_string(of_root,
"model",
&soc_dev_attr->machine);
if (ret)
@@ -132,6 +130,8 @@ static int __init imx_scu_soc_init(void)
if (!np)
return -ENODEV;+ of_node_put(np);
+
ret = platform_driver_register(&imx_scu_soc_driver);
if (ret)
return ret;thanks,
Anson
Quoted 2 lines
Regards.