Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firmware: imx: Add i.MX95 SCMI CPU driver

The i.MX95 System manager exports SCMI CPU protocol for linux to manage
cpu cores. The driver is to use the cpu Protocol interface to
start, stop a cpu cores (eg, M7).

Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Message-Id: <20250408-imx-lmm-cpu-v4-6-4c5f4a456e49@nxp.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

authored by

Peng Fan and committed by
Sudeep Holla
1055faa5 7242bbf4

+103
+1
drivers/firmware/arm_scmi/vendors/imx/Kconfig
··· 15 15 config IMX_SCMI_CPU_EXT 16 16 tristate "i.MX SCMI CPU EXTENSION" 17 17 depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) 18 + depends on IMX_SCMI_CPU_DRV 18 19 default y if ARCH_MXC 19 20 help 20 21 This enables i.MX System CPU Protocol to manage cpu
+11
drivers/firmware/imx/Kconfig
··· 23 23 This driver manages the IPC interface between host CPU and the 24 24 SCU firmware running on M4. 25 25 26 + config IMX_SCMI_CPU_DRV 27 + tristate "IMX SCMI CPU Protocol driver" 28 + depends on ARCH_MXC || COMPILE_TEST 29 + default y if ARCH_MXC 30 + help 31 + The System Controller Management Interface firmware (SCMI FW) is 32 + a low-level system function which runs on a dedicated Cortex-M 33 + core that could provide cpu management features. 34 + 35 + This driver can also be built as a module. 36 + 26 37 config IMX_SCMI_LMM_DRV 27 38 tristate "IMX SCMI LMM Protocol driver" 28 39 depends on ARCH_MXC || COMPILE_TEST
+1
drivers/firmware/imx/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 obj-$(CONFIG_IMX_DSP) += imx-dsp.o 3 3 obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o 4 + obj-${CONFIG_IMX_SCMI_CPU_DRV} += sm-cpu.o 4 5 obj-${CONFIG_IMX_SCMI_MISC_DRV} += sm-misc.o 5 6 obj-${CONFIG_IMX_SCMI_LMM_DRV} += sm-lmm.o
+85
drivers/firmware/imx/sm-cpu.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright 2025 NXP 4 + */ 5 + 6 + #include <linux/firmware/imx/sm.h> 7 + #include <linux/module.h> 8 + #include <linux/of.h> 9 + #include <linux/platform_device.h> 10 + #include <linux/scmi_protocol.h> 11 + #include <linux/scmi_imx_protocol.h> 12 + 13 + static const struct scmi_imx_cpu_proto_ops *imx_cpu_ops; 14 + static struct scmi_protocol_handle *ph; 15 + 16 + int scmi_imx_cpu_reset_vector_set(u32 cpuid, u64 vector, bool start, bool boot, 17 + bool resume) 18 + { 19 + if (!ph) 20 + return -EPROBE_DEFER; 21 + 22 + return imx_cpu_ops->cpu_reset_vector_set(ph, cpuid, vector, start, 23 + boot, resume); 24 + } 25 + EXPORT_SYMBOL(scmi_imx_cpu_reset_vector_set); 26 + 27 + int scmi_imx_cpu_start(u32 cpuid, bool start) 28 + { 29 + if (!ph) 30 + return -EPROBE_DEFER; 31 + 32 + if (start) 33 + return imx_cpu_ops->cpu_start(ph, cpuid, true); 34 + 35 + return imx_cpu_ops->cpu_start(ph, cpuid, false); 36 + }; 37 + EXPORT_SYMBOL(scmi_imx_cpu_start); 38 + 39 + int scmi_imx_cpu_started(u32 cpuid, bool *started) 40 + { 41 + if (!ph) 42 + return -EPROBE_DEFER; 43 + 44 + if (!started) 45 + return -EINVAL; 46 + 47 + return imx_cpu_ops->cpu_started(ph, cpuid, started); 48 + }; 49 + EXPORT_SYMBOL(scmi_imx_cpu_started); 50 + 51 + static int scmi_imx_cpu_probe(struct scmi_device *sdev) 52 + { 53 + const struct scmi_handle *handle = sdev->handle; 54 + 55 + if (!handle) 56 + return -ENODEV; 57 + 58 + if (imx_cpu_ops) { 59 + dev_err(&sdev->dev, "sm cpu already initialized\n"); 60 + return -EEXIST; 61 + } 62 + 63 + imx_cpu_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_CPU, &ph); 64 + if (IS_ERR(imx_cpu_ops)) 65 + return PTR_ERR(imx_cpu_ops); 66 + 67 + return 0; 68 + } 69 + 70 + static const struct scmi_device_id scmi_id_table[] = { 71 + { SCMI_PROTOCOL_IMX_CPU, "imx-cpu" }, 72 + { }, 73 + }; 74 + MODULE_DEVICE_TABLE(scmi, scmi_id_table); 75 + 76 + static struct scmi_driver scmi_imx_cpu_driver = { 77 + .name = "scmi-imx-cpu", 78 + .probe = scmi_imx_cpu_probe, 79 + .id_table = scmi_id_table, 80 + }; 81 + module_scmi_driver(scmi_imx_cpu_driver); 82 + 83 + MODULE_AUTHOR("Peng Fan <peng.fan@nxp.com>"); 84 + MODULE_DESCRIPTION("IMX SM CPU driver"); 85 + MODULE_LICENSE("GPL");
+5
include/linux/firmware/imx/sm.h
··· 21 21 int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val); 22 22 int scmi_imx_misc_ctrl_set(u32 id, u32 val); 23 23 24 + int scmi_imx_cpu_start(u32 cpuid, bool start); 25 + int scmi_imx_cpu_started(u32 cpuid, bool *started); 26 + int scmi_imx_cpu_reset_vector_set(u32 cpuid, u64 vector, bool start, bool boot, 27 + bool resume); 28 + 24 29 enum scmi_imx_lmm_op { 25 30 SCMI_IMX_LMM_BOOT, 26 31 SCMI_IMX_LMM_POWER_ON,