soc: imx: Add SCU SoC info driver support
PATCH v2 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_id
i.MX8QXP
i.mx8qxp-mek# cat /sys/devices/soc0/machine
Freescale i.MX8QXP MEK
i.mx8qxp-mek# cat /sys/devices/soc0/revision
1.1
---
Changes since V1:
- return correct value in probe function instead of hardcode;
- add comment to explain why return 0 when get soc info from SCU firmware failed.
--- drivers/soc/imx/Kconfig | 9 +++ drivers/soc/imx/Makefile | 1 + drivers/soc/imx/soc-imx-scu.c | 183 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 193 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 +183 -0
183 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 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 · 1 line
2.7.4
drivers/soc/imx/soc-imx-scu.c line 116
Quoted 13 lines · Anson Huang
Add i.MX SCU SoC info driver to support i.MX8QXP SoC, introduce driver dependency into
KconfigasCONFIG_IMX_SCUmust be selected to support i.MX SCU SoC driver, also need to use platform driver model to make sureIMX_SCUdriver is probed before i.MX SCU SoC driver.With this patch, SoC info can be read from sysfs:
drivers/soc/imx/soc-imx-scu.c new file +5
-0+ id =of_match_node (imx_scu_soc_match, root); +if (!id) { +of_node_put (root); +return -ENODEV ; + }
Perhaps this check should be moved from imx_scu_soc_probe to imx_scu_soc_init? As far as I can tell this "probe" function will be attempted on all SOCs (even non-imx). Better to check if we're on a SCU-based soc early and avoid temporary allocations.
drivers/soc/imx/soc-imx-scu.c line 179
Quoted 2 lines
drivers/soc/imx/soc-imx-scu.c new file +2
-0+module_init (imx_scu_soc_init); +module_exit (imx_scu_soc_exit);
Please don't make this a module
--
Regards,
Leonard
Hi, Leonard
Quoted 24 lines
-----Original Message-----
From: Leonard Crestez
Sent: Wednesday, May 15, 2019 6:05 PM
To: Anson Huang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Abel Vesa <[email protected]>; [email protected]; linux-arm- [email protected]; [email protected]; dl-linux-imx <[email protected]>; Aisheng Dong <[email protected]>
Subject: Re: [PATCH V2 1/2] soc: imx: Add SCU SoC info driver supportQuoted 6 lines · Anson Huang
Add i.MX SCU SoC info driver to support i.MX8QXP SoC, introduce driver dependency into
KconfigasCONFIG_IMX_SCUmust be selected to support i.MX SCU SoC driver, also need to use platform driver model to make sureIMX_SCUdriver is probed before i.MX SCU SoC driver.With this patch, SoC info can be read from sysfs:
Quoted 10 lines
drivers/soc/imx/soc-imx-scu.c line 116
Quoted 5 lines
drivers/soc/imx/soc-imx-scu.c new file +5
-0+ id =of_match_node (imx_scu_soc_match, root); +if (!id) { +of_node_put (root); +return -ENODEV ; + }Perhaps this check should be moved from
imx_scu_soc_probetoimx_scu_soc_init? As far as I can tell this "probe" function will be attempted on all SOCs (even non-imx). Better to check if we're on a SCU-based soc early and avoid temporary allocations.
Make sense, I will move this check block into imx_scu_soc_init() function and ONLY register platform driver when check passed.
Quoted 5 lines
drivers/soc/imx/soc-imx-scu.c line 179
Quoted 3 lines
drivers/soc/imx/soc-imx-scu.c new file +2
-0+module_init (imx_scu_soc_init); +module_exit (imx_scu_soc_exit);Please don't make this a module
OK, will fix it in V3.
Thanks,
Anson.
Quoted 4 lines
--
Regards,
Leonard
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Anson,
Since you are going to send a new version for this please consider my comment inline.
<snip>
drivers/soc/imx/soc-imx-scu.c line 42
Quoted 5 lines
drivers/soc/imx/soc-imx-scu.c new file +5
-0+static u32 imx8qxp_soc_revision (void ) +{ +struct imx_sc_msg_misc_get_soc_id msg; +struct imx_sc_rpc_msg *hdr = &msg.hdr; +u32 rev =0 ;
No need to initialize this here.
Quoted 5 lines
drivers/soc/imx/soc-imx-scu.c new file +5
-0+int ret; + + hdr->ver =IMX_SC_RPC_VERSION ; + hdr->svc =IMX_SC_RPC_SVC_MISC ; + hdr->func =IMX_SC_MISC_FUNC_GET_CONTROL ;
drivers/soc/imx/soc-imx-scu.c line 57
Quoted 10 lines
drivers/soc/imx/soc-imx-scu.c new file +10
-0+ hdr->size =3 ; + + msg.data.send.control =IMX_SC_C_ID ; + msg.data.send.resource =IMX_SC_R_SYSTEM ; + + ret =imx_scu_call_rpc (soc_ipc_handle, &msg, true); +if (ret) { +dev_err (&imx_scu_soc_pdev->dev, +"get soc info failed, ret %d\n" , ret); +/* return 0 means getting revision failed */
Just return 0 here. No need for rev.
Quoted 3 lines
drivers/soc/imx/soc-imx-scu.c new file +3
-0+return rev; + } +
Quoted 41 lines
-----Original Message-----
From: Daniel Baluta [mailto:[email protected]]
Sent: Wednesday, May 15, 2019 7:47 PM
To: Anson Huang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Leonard Crestez <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Abel Vesa <[email protected]>; [email protected]; [email protected]; [email protected]; dl-linux- imx <[email protected]>
Subject: Re: [PATCH V2 1/2] soc: imx: Add SCU SoC info driver supportHi Anson,
Since you are going to send a new version for this please consider my comment inline.
<snip>
drivers/soc/imx/soc-imx-scu.c line 42
Quoted 4 lines
drivers/soc/imx/soc-imx-scu.c new file +4
-0+static u32 imx8qxp_soc_revision (void ) { +struct imx_sc_msg_misc_get_soc_id msg; +struct imx_sc_rpc_msg *hdr = &msg.hdr; +u32 rev =0 ;No need to initialize this here.
Quoted 9 lines
drivers/soc/imx/soc-imx-scu.c new file +9
-0+int ret; + + hdr->ver =IMX_SC_RPC_VERSION ; + hdr->svc =IMX_SC_RPC_SVC_MISC ; + hdr->func =IMX_SC_MISC_FUNC_GET_CONTROL ; + hdr->size =3 ; + + msg.data.send.control =IMX_SC_C_ID ; + msg.data.send.resource =IMX_SC_R_SYSTEM ;
Quoted 8 lines
drivers/soc/imx/soc-imx-scu.c line 57
Quoted 6 lines
drivers/soc/imx/soc-imx-scu.c new file +6
-0+ + ret =imx_scu_call_rpc (soc_ipc_handle, &msg, true); +if (ret) { +dev_err (&imx_scu_soc_pdev->dev, +"get soc info failed, ret %d\n" , ret); +/* return 0 means getting revision failed */ Just return 0 here. No need for rev.
OK, thanks.
Anson.
Quoted 3 lines
Quoted 3 lines
drivers/soc/imx/soc-imx-scu.c new file +3
-0+return rev; + } +