Skip to content

Commit a24015f

Browse files
Anson-HuangShawn Guo
authored andcommitted
firmware: imx: Move i.MX SCU soc driver into imx firmware folder
The i.MX SCU soc driver depends on SCU firmware driver, so it has to use platform driver model for proper defer probe operation, since it has no device binding in DT file, a simple platform device is created together inside the platform driver. To make it more clean, we can just move the entire SCU soc driver into imx firmware folder and initialized by i.MX SCU firmware driver. Signed-off-by: Anson Huang <[email protected]> Signed-off-by: Shawn Guo <[email protected]>
1 parent cfda066 commit a24015f

File tree

7 files changed

+15
-55
lines changed

7 files changed

+15
-55
lines changed

arch/arm64/configs/defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,6 @@ CONFIG_OWL_PM_DOMAINS=y
850850
CONFIG_RASPBERRYPI_POWER=y
851851
CONFIG_FSL_DPAA=y
852852
CONFIG_FSL_MC_DPIO=y
853-
CONFIG_IMX_SCU_SOC=y
854853
CONFIG_QCOM_AOSS_QMP=y
855854
CONFIG_QCOM_GENI_SE=y
856855
CONFIG_QCOM_RMTFS_MEM=m

drivers/firmware/imx/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_IMX_DSP) += imx-dsp.o
3-
obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o
3+
obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o
44
obj-$(CONFIG_IMX_SCU_PD) += scu-pd.o

drivers/soc/imx/soc-imx-scu.c renamed to drivers/firmware/imx/imx-scu-soc.c

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
#include <linux/platform_device.h>
1111
#include <linux/of.h>
1212

13-
#define IMX_SCU_SOC_DRIVER_NAME "imx-scu-soc"
14-
15-
static struct imx_sc_ipc *soc_ipc_handle;
13+
static struct imx_sc_ipc *imx_sc_soc_ipc_handle;
1614

1715
struct imx_sc_msg_misc_get_soc_id {
1816
struct imx_sc_rpc_msg hdr;
@@ -44,7 +42,7 @@ static int imx_scu_soc_uid(u64 *soc_uid)
4442
hdr->func = IMX_SC_MISC_FUNC_UNIQUE_ID;
4543
hdr->size = 1;
4644

47-
ret = imx_scu_call_rpc(soc_ipc_handle, &msg, true);
45+
ret = imx_scu_call_rpc(imx_sc_soc_ipc_handle, &msg, true);
4846
if (ret) {
4947
pr_err("%s: get soc uid failed, ret %d\n", __func__, ret);
5048
return ret;
@@ -71,7 +69,7 @@ static int imx_scu_soc_id(void)
7169
msg.data.req.control = IMX_SC_C_ID;
7270
msg.data.req.resource = IMX_SC_R_SYSTEM;
7371

74-
ret = imx_scu_call_rpc(soc_ipc_handle, &msg, true);
72+
ret = imx_scu_call_rpc(imx_sc_soc_ipc_handle, &msg, true);
7573
if (ret) {
7674
pr_err("%s: get soc info failed, ret %d\n", __func__, ret);
7775
return ret;
@@ -80,19 +78,19 @@ static int imx_scu_soc_id(void)
8078
return msg.data.resp.id;
8179
}
8280

83-
static int imx_scu_soc_probe(struct platform_device *pdev)
81+
int imx_scu_soc_init(struct device *dev)
8482
{
8583
struct soc_device_attribute *soc_dev_attr;
8684
struct soc_device *soc_dev;
8785
int id, ret;
8886
u64 uid = 0;
8987
u32 val;
9088

91-
ret = imx_scu_get_handle(&soc_ipc_handle);
89+
ret = imx_scu_get_handle(&imx_sc_soc_ipc_handle);
9290
if (ret)
9391
return ret;
9492

95-
soc_dev_attr = devm_kzalloc(&pdev->dev, sizeof(*soc_dev_attr),
93+
soc_dev_attr = devm_kzalloc(dev, sizeof(*soc_dev_attr),
9694
GFP_KERNEL);
9795
if (!soc_dev_attr)
9896
return -ENOMEM;
@@ -115,19 +113,19 @@ static int imx_scu_soc_probe(struct platform_device *pdev)
115113

116114
/* format soc_id value passed from SCU firmware */
117115
val = id & 0x1f;
118-
soc_dev_attr->soc_id = devm_kasprintf(&pdev->dev, GFP_KERNEL, "0x%x", val);
116+
soc_dev_attr->soc_id = devm_kasprintf(dev, GFP_KERNEL, "0x%x", val);
119117
if (!soc_dev_attr->soc_id)
120118
return -ENOMEM;
121119

122120
/* format revision value passed from SCU firmware */
123121
val = (id >> 5) & 0xf;
124122
val = (((val >> 2) + 1) << 4) | (val & 0x3);
125-
soc_dev_attr->revision = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%d.%d",
123+
soc_dev_attr->revision = devm_kasprintf(dev, GFP_KERNEL, "%d.%d",
126124
(val >> 4) & 0xf, val & 0xf);
127125
if (!soc_dev_attr->revision)
128126
return -ENOMEM;
129127

130-
soc_dev_attr->serial_number = devm_kasprintf(&pdev->dev, GFP_KERNEL,
128+
soc_dev_attr->serial_number = devm_kasprintf(dev, GFP_KERNEL,
131129
"%016llX", uid);
132130
if (!soc_dev_attr->serial_number)
133131
return -ENOMEM;
@@ -138,35 +136,3 @@ static int imx_scu_soc_probe(struct platform_device *pdev)
138136

139137
return 0;
140138
}
141-
142-
static struct platform_driver imx_scu_soc_driver = {
143-
.driver = {
144-
.name = IMX_SCU_SOC_DRIVER_NAME,
145-
},
146-
.probe = imx_scu_soc_probe,
147-
};
148-
149-
static int __init imx_scu_soc_init(void)
150-
{
151-
struct platform_device *pdev;
152-
struct device_node *np;
153-
int ret;
154-
155-
np = of_find_compatible_node(NULL, NULL, "fsl,imx-scu");
156-
if (!np)
157-
return -ENODEV;
158-
159-
of_node_put(np);
160-
161-
ret = platform_driver_register(&imx_scu_soc_driver);
162-
if (ret)
163-
return ret;
164-
165-
pdev = platform_device_register_simple(IMX_SCU_SOC_DRIVER_NAME,
166-
-1, NULL, 0);
167-
if (IS_ERR(pdev))
168-
platform_driver_unregister(&imx_scu_soc_driver);
169-
170-
return PTR_ERR_OR_ZERO(pdev);
171-
}
172-
device_initcall(imx_scu_soc_init);

drivers/firmware/imx/imx-scu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ static int imx_scu_probe(struct platform_device *pdev)
328328

329329
imx_sc_ipc_handle = sc_ipc;
330330

331+
ret = imx_scu_soc_init(dev);
332+
if (ret)
333+
dev_warn(dev, "failed to initialize SoC info: %d\n", ret);
334+
331335
ret = imx_scu_enable_general_irq_channel(dev);
332336
if (ret)
333337
dev_warn(dev,

drivers/soc/imx/Kconfig

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ config IMX_GPCV2_PM_DOMAINS
88
select PM_GENERIC_DOMAINS
99
default y if SOC_IMX7D
1010

11-
config IMX_SCU_SOC
12-
bool "i.MX System Controller Unit SoC info support"
13-
depends on IMX_SCU
14-
select SOC_BUS
15-
help
16-
If you say yes here you get support for the NXP i.MX System
17-
Controller Unit SoC info module, it will provide the SoC info
18-
like SoC family, ID and revision etc.
19-
2011
config SOC_IMX8M
2112
bool "i.MX8M SoC family support"
2213
depends on ARCH_MXC || COMPILE_TEST

drivers/soc/imx/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ endif
55
obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o
66
obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o
77
obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o
8-
obj-$(CONFIG_IMX_SCU_SOC) += soc-imx-scu.o

include/linux/firmware/imx/sci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ int imx_scu_enable_general_irq_channel(struct device *dev);
2020
int imx_scu_irq_register_notifier(struct notifier_block *nb);
2121
int imx_scu_irq_unregister_notifier(struct notifier_block *nb);
2222
int imx_scu_irq_group_enable(u8 group, u32 mask, u8 enable);
23+
int imx_scu_soc_init(struct device *dev);
2324
#endif /* _SC_SCI_H */

0 commit comments

Comments
 (0)