Message ID | 20250408-imx-lmm-cpu-v4-5-4c5f4a456e49@nxp.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | firmware: scmi/imx: Add i.MX95 LMM/CPU Protocol | expand |
On Tue, Apr 08, 2025 at 04:44:29PM +0800, Peng Fan (OSS) wrote: > From: Peng Fan <peng.fan@nxp.com> > > The i.MX95 System manager exports SCMI LMM protocol for linux to manage > Logical Machines. The driver is to use the LMM Protocol interface to > boot, shutdown a LM. > > Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> > Signed-off-by: Peng Fan <peng.fan@nxp.com> > --- > drivers/firmware/arm_scmi/vendors/imx/Kconfig | 3 +- > drivers/firmware/imx/Kconfig | 11 ++++ > drivers/firmware/imx/Makefile | 1 + > drivers/firmware/imx/sm-lmm.c | 91 +++++++++++++++++++++++++++ > include/linux/firmware/imx/sm.h | 14 +++++ > 5 files changed, 119 insertions(+), 1 deletion(-) > > diff --git a/drivers/firmware/arm_scmi/vendors/imx/Kconfig b/drivers/firmware/arm_scmi/vendors/imx/Kconfig > index b5f13d0e40155e485f4d1696e9550645d888ef44..4c24e17425f830810f8ba376ece9db93c8cded6d 100644 > --- a/drivers/firmware/arm_scmi/vendors/imx/Kconfig > +++ b/drivers/firmware/arm_scmi/vendors/imx/Kconfig > @@ -26,7 +26,8 @@ config IMX_SCMI_CPU_EXT > config IMX_SCMI_LMM_EXT > tristate "i.MX SCMI LMM EXTENSION" > depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) > - default y if ARCH_MXC > + depends on IMX_SCMI_LMM_DRV > + default y if ARCH_MXC && ARM64 I can't understand the ARM64 dependency on this and next patch.
Hi Sudeep, > Subject: Re: [PATCH v4 5/7] firmware: imx: Add i.MX95 SCMI LMM > driver > > On Tue, Apr 08, 2025 at 04:44:29PM +0800, Peng Fan (OSS) wrote: > > From: Peng Fan <peng.fan@nxp.com> > > > > The i.MX95 System manager exports SCMI LMM protocol for linux to > > manage Logical Machines. The driver is to use the LMM Protocol > > interface to boot, shutdown a LM. > > > > Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> > > Signed-off-by: Peng Fan <peng.fan@nxp.com> > > --- > > drivers/firmware/arm_scmi/vendors/imx/Kconfig | 3 +- > > drivers/firmware/imx/Kconfig | 11 ++++ > > drivers/firmware/imx/Makefile | 1 + > > drivers/firmware/imx/sm-lmm.c | 91 > +++++++++++++++++++++++++++ > > include/linux/firmware/imx/sm.h | 14 +++++ > > 5 files changed, 119 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > b/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > index > > > b5f13d0e40155e485f4d1696e9550645d888ef44..4c24e17425f83081 > 0f8ba376ece9 > > db93c8cded6d 100644 > > --- a/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > +++ b/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > @@ -26,7 +26,8 @@ config IMX_SCMI_CPU_EXT config > IMX_SCMI_LMM_EXT > > tristate "i.MX SCMI LMM EXTENSION" > > depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) > > - default y if ARCH_MXC > > + depends on IMX_SCMI_LMM_DRV > > + default y if ARCH_MXC && ARM64 > > I can't understand the ARM64 dependency on this and next patch. ARCH_MXC both supports ARM32 and ARM64. To i.MX ARM32 platform, there is no plan to enable SCMI, so only set y for ARCH_MXC ARM64 platforms. Thanks, Peng. > > -- > Regards, > Sudeep
On Mon, Apr 14, 2025 at 09:57:43AM +0000, Peng Fan wrote: > Hi Sudeep, > > > Subject: Re: [PATCH v4 5/7] firmware: imx: Add i.MX95 SCMI LMM > > driver > > > > On Tue, Apr 08, 2025 at 04:44:29PM +0800, Peng Fan (OSS) wrote: > > > From: Peng Fan <peng.fan@nxp.com> > > > > > > The i.MX95 System manager exports SCMI LMM protocol for linux to > > > manage Logical Machines. The driver is to use the LMM Protocol > > > interface to boot, shutdown a LM. > > > > > > Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> > > > Signed-off-by: Peng Fan <peng.fan@nxp.com> > > > --- > > > drivers/firmware/arm_scmi/vendors/imx/Kconfig | 3 +- > > > drivers/firmware/imx/Kconfig | 11 ++++ > > > drivers/firmware/imx/Makefile | 1 + > > > drivers/firmware/imx/sm-lmm.c | 91 > > +++++++++++++++++++++++++++ > > > include/linux/firmware/imx/sm.h | 14 +++++ > > > 5 files changed, 119 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > > b/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > > index > > > > > b5f13d0e40155e485f4d1696e9550645d888ef44..4c24e17425f83081 > > 0f8ba376ece9 > > > db93c8cded6d 100644 > > > --- a/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > > +++ b/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > > @@ -26,7 +26,8 @@ config IMX_SCMI_CPU_EXT config > > IMX_SCMI_LMM_EXT > > > tristate "i.MX SCMI LMM EXTENSION" > > > depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) > > > - default y if ARCH_MXC > > > + depends on IMX_SCMI_LMM_DRV > > > + default y if ARCH_MXC && ARM64 > > > > I can't understand the ARM64 dependency on this and next patch. > > ARCH_MXC both supports ARM32 and ARM64. > > To i.MX ARM32 platform, there is no plan to enable SCMI, so only > set y for ARCH_MXC ARM64 platforms. > OK but why is it different for IMX_SCMI_MISC_DRV. I really don't see any dependency. If it is not supported today fine, but do you need any issue to use it or compile it for arm32 ?
Hi Sudeep, > Subject: Re: [PATCH v4 5/7] firmware: imx: Add i.MX95 SCMI LMM > driver > > On Mon, Apr 14, 2025 at 09:57:43AM +0000, Peng Fan wrote: > > Hi Sudeep, > > > > > Subject: Re: [PATCH v4 5/7] firmware: imx: Add i.MX95 SCMI LMM > > > driver > > > > > > On Tue, Apr 08, 2025 at 04:44:29PM +0800, Peng Fan (OSS) wrote: > > > > From: Peng Fan <peng.fan@nxp.com> > > > > > > > > The i.MX95 System manager exports SCMI LMM protocol for linux > to > > > > manage Logical Machines. The driver is to use the LMM Protocol > > > > interface to boot, shutdown a LM. > > > > > > > > Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> > > > > Signed-off-by: Peng Fan <peng.fan@nxp.com> > > > > --- > > > > drivers/firmware/arm_scmi/vendors/imx/Kconfig | 3 +- > > > > drivers/firmware/imx/Kconfig | 11 ++++ > > > > drivers/firmware/imx/Makefile | 1 + > > > > drivers/firmware/imx/sm-lmm.c | 91 > > > +++++++++++++++++++++++++++ > > > > include/linux/firmware/imx/sm.h | 14 +++++ > > > > 5 files changed, 119 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > > > b/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > > > index > > > > > > > > b5f13d0e40155e485f4d1696e9550645d888ef44..4c24e17425f83081 > > > 0f8ba376ece9 > > > > db93c8cded6d 100644 > > > > --- a/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > > > +++ b/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > > > @@ -26,7 +26,8 @@ config IMX_SCMI_CPU_EXT config > > > IMX_SCMI_LMM_EXT > > > > tristate "i.MX SCMI LMM EXTENSION" > > > > depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) > > > > - default y if ARCH_MXC > > > > + depends on IMX_SCMI_LMM_DRV > > > > + default y if ARCH_MXC && ARM64 > > > > > > I can't understand the ARM64 dependency on this and next patch. > > > > ARCH_MXC both supports ARM32 and ARM64. > > > > To i.MX ARM32 platform, there is no plan to enable SCMI, so only set > y > > for ARCH_MXC ARM64 platforms. > > > > OK but why is it different for IMX_SCMI_MISC_DRV. I really don't see > any dependency. If it is not supported today fine, but do you need any > issue to use it or compile it for arm32 ? Seems my over-thinking. There is no ARM64 dependency. No issue. I just think there is no need to default build in this driver for i.MX ARM32 platform, because no i.MX ARM32 platform supports SCMI. But after a rethink, ARM64 dependency could be dropped, because there was already a dependency ARM_SCMI_PROTOCOL(i.MX ARM32 not select this option), so we could follow same as IMX_SCMI_MISC_DRV. Please let me know if I need post new version for this and Dan's comments. Anyway, no rush. Thanks, Peng. > > -- > Regards, > Sudeep
> Subject: RE: [PATCH v4 5/7] firmware: imx: Add i.MX95 SCMI LMM > driver > > Hi Sudeep, > > > Subject: Re: [PATCH v4 5/7] firmware: imx: Add i.MX95 SCMI LMM > driver > > > > On Mon, Apr 14, 2025 at 09:57:43AM +0000, Peng Fan wrote: > > > Hi Sudeep, > > > > > > > Subject: Re: [PATCH v4 5/7] firmware: imx: Add i.MX95 SCMI > LMM > > > > driver > > > > > > > > On Tue, Apr 08, 2025 at 04:44:29PM +0800, Peng Fan (OSS) > wrote: > > > > > From: Peng Fan <peng.fan@nxp.com> > > > > > > > > > > The i.MX95 System manager exports SCMI LMM protocol for > linux > > to > > > > > manage Logical Machines. The driver is to use the LMM > Protocol > > > > > interface to boot, shutdown a LM. > > > > > > > > > > Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> > > > > > Signed-off-by: Peng Fan <peng.fan@nxp.com> > > > > > --- > > > > > drivers/firmware/arm_scmi/vendors/imx/Kconfig | 3 +- > > > > > drivers/firmware/imx/Kconfig | 11 ++++ > > > > > drivers/firmware/imx/Makefile | 1 + > > > > > drivers/firmware/imx/sm-lmm.c | 91 > > > > +++++++++++++++++++++++++++ > > > > > include/linux/firmware/imx/sm.h | 14 +++++ > > > > > 5 files changed, 119 insertions(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > > > > b/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > > > > index > > > > > > > > > > > > b5f13d0e40155e485f4d1696e9550645d888ef44..4c24e17425f83081 > > > > 0f8ba376ece9 > > > > > db93c8cded6d 100644 > > > > > --- a/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > > > > +++ b/drivers/firmware/arm_scmi/vendors/imx/Kconfig > > > > > @@ -26,7 +26,8 @@ config IMX_SCMI_CPU_EXT config > > > > IMX_SCMI_LMM_EXT > > > > > tristate "i.MX SCMI LMM EXTENSION" > > > > > depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) > > > > > - default y if ARCH_MXC > > > > > + depends on IMX_SCMI_LMM_DRV > > > > > + default y if ARCH_MXC && ARM64 > > > > > > > > I can't understand the ARM64 dependency on this and next patch. > > > > > > ARCH_MXC both supports ARM32 and ARM64. > > > > > > To i.MX ARM32 platform, there is no plan to enable SCMI, so only > set > > y > > > for ARCH_MXC ARM64 platforms. > > > > > > > OK but why is it different for IMX_SCMI_MISC_DRV. I really don't see > > any dependency. If it is not supported today fine, but do you need > any > > issue to use it or compile it for arm32 ? > > Seems my over-thinking. > There is no ARM64 dependency. No issue. > I just think there is no need to default build in this driver for i.MX > ARM32 platform, because no i.MX ARM32 platform supports SCMI. > > But after a rethink, ARM64 dependency could be dropped, because > there was already a dependency ARM_SCMI_PROTOCOL(i.MX ARM32 > not select this option), so we could follow same as > IMX_SCMI_MISC_DRV. Oops, I just checked wrong Kconfig under drivers/firmware/arm_scmi/ vendors/imx Build this for ARM32 i.MX is ok, I just think no need. So add a ARM64 dependency. For IMX_SCMI_MISC_DRV, I could not recall clearly, seems I forgot to add. But anyway, w/o ARM64 should be both fine. I tested ARM32 build with imx_v6_v7_defconfig, no issue. Thanks, Peng. > > Please let me know if I need post new version for this and Dan's > comments. Anyway, no rush. > > Thanks, > Peng. > > > > > -- > > Regards, > > Sudeep
On Mon, Apr 14, 2025 at 11:00:20AM +0000, Peng Fan wrote: > > Oops, I just checked wrong Kconfig under drivers/firmware/arm_scmi/ > vendors/imx > > Build this for ARM32 i.MX is ok, I just think no need. So add > a ARM64 dependency. > OK, I will drop the ARM64 dependency when applying. I also don't understand the dependency on i.MX firmware LMM and CPU drivers in the scmi vendor protocol as the dependency should be other way around. But I see Arnd had fixed it so I will keep it as you have posted to keep them all aligned.
On Mon, Apr 14, 2025 at 12:17:34PM +0100, Sudeep Holla wrote: >On Mon, Apr 14, 2025 at 11:00:20AM +0000, Peng Fan wrote: >> >> Oops, I just checked wrong Kconfig under drivers/firmware/arm_scmi/ >> vendors/imx >> >> Build this for ARM32 i.MX is ok, I just think no need. So add >> a ARM64 dependency. >> > >OK, I will drop the ARM64 dependency when applying. I also don't understand Thanks for helping on this. >the dependency on i.MX firmware LMM and CPU drivers in the scmi vendor >protocol as the dependency should be other way around. But I see Arnd had >fixed it so I will keep it as you have posted to keep them all aligned. Not dig into much on this. I just followed what Arnd did when I prepared the patchset to avoid potential build issue as reported before. Thanks, Peng > >-- >Regards, >Sudeep
On Tue, Apr 15, 2025 at 05:10:16PM +0800, Peng Fan wrote: > On Mon, Apr 14, 2025 at 12:17:34PM +0100, Sudeep Holla wrote: > >On Mon, Apr 14, 2025 at 11:00:20AM +0000, Peng Fan wrote: > >> > >> Oops, I just checked wrong Kconfig under drivers/firmware/arm_scmi/ > >> vendors/imx > >> > >> Build this for ARM32 i.MX is ok, I just think no need. So add > >> a ARM64 dependency. > >> > > > >OK, I will drop the ARM64 dependency when applying. I also don't understand > > Thanks for helping on this. > > >the dependency on i.MX firmware LMM and CPU drivers in the scmi vendor > >protocol as the dependency should be other way around. But I see Arnd had > >fixed it so I will keep it as you have posted to keep them all aligned. > Not dig into much on this. > I just followed what Arnd did when I prepared the patchset to avoid > potential build issue as reported before. > Yes, I am keeping it based on those changes. I need to spend sometime to understand why it was done so and see if anything can be improved. It is not straightforward to understand that dependency, for me looks like it is in reverse direction. Anyway I have pushed it tentatively, will let you know once it is finalised.
diff --git a/drivers/firmware/arm_scmi/vendors/imx/Kconfig b/drivers/firmware/arm_scmi/vendors/imx/Kconfig index b5f13d0e40155e485f4d1696e9550645d888ef44..4c24e17425f830810f8ba376ece9db93c8cded6d 100644 --- a/drivers/firmware/arm_scmi/vendors/imx/Kconfig +++ b/drivers/firmware/arm_scmi/vendors/imx/Kconfig @@ -26,7 +26,8 @@ config IMX_SCMI_CPU_EXT config IMX_SCMI_LMM_EXT tristate "i.MX SCMI LMM EXTENSION" depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) - default y if ARCH_MXC + depends on IMX_SCMI_LMM_DRV + default y if ARCH_MXC && ARM64 help This enables i.MX System Logical Machine Protocol to manage Logical Machines boot, shutdown and etc. diff --git a/drivers/firmware/imx/Kconfig b/drivers/firmware/imx/Kconfig index c964f4924359fcd375560ee8263021b0fe65db1b..70c092424328067ea6b946cee59f072661e27e47 100644 --- a/drivers/firmware/imx/Kconfig +++ b/drivers/firmware/imx/Kconfig @@ -23,6 +23,17 @@ config IMX_SCU This driver manages the IPC interface between host CPU and the SCU firmware running on M4. +config IMX_SCMI_LMM_DRV + tristate "IMX SCMI LMM Protocol driver" + depends on ARCH_MXC && ARM64 || COMPILE_TEST + default y if ARCH_MXC && ARM64 + help + The System Controller Management Interface firmware (SCMI FW) is + a low-level system function which runs on a dedicated Cortex-M + core that could provide Logical Machine management features. + + This driver can also be built as a module. + config IMX_SCMI_MISC_DRV tristate "IMX SCMI MISC Protocol driver" depends on ARCH_MXC || COMPILE_TEST diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 8d046c341be878bb6dd1e6277992ff66ae90e292..7762855d2a771169d4f1867d27e0d51be7c9ad03 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_IMX_DSP) += imx-dsp.o obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o obj-${CONFIG_IMX_SCMI_MISC_DRV} += sm-misc.o +obj-${CONFIG_IMX_SCMI_LMM_DRV} += sm-lmm.o diff --git a/drivers/firmware/imx/sm-lmm.c b/drivers/firmware/imx/sm-lmm.c new file mode 100644 index 0000000000000000000000000000000000000000..6807bf563c03d21a68022ecf3469c38bee4fc2f5 --- /dev/null +++ b/drivers/firmware/imx/sm-lmm.c @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2025 NXP + */ + +#include <linux/firmware/imx/sm.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/scmi_protocol.h> +#include <linux/scmi_imx_protocol.h> + +static const struct scmi_imx_lmm_proto_ops *imx_lmm_ops; +static struct scmi_protocol_handle *ph; + +int scmi_imx_lmm_info(u32 lmid, struct scmi_imx_lmm_info *info) +{ + if (!ph) + return -EPROBE_DEFER; + + if (!info) + return -EINVAL; + + return imx_lmm_ops->lmm_info(ph, lmid, info); +}; +EXPORT_SYMBOL(scmi_imx_lmm_info); + +int scmi_imx_lmm_reset_vector_set(u32 lmid, u32 cpuid, u32 flags, u64 vector) +{ + if (!ph) + return -EPROBE_DEFER; + + return imx_lmm_ops->lmm_reset_vector_set(ph, lmid, cpuid, flags, vector); +} +EXPORT_SYMBOL(scmi_imx_lmm_reset_vector_set); + +int scmi_imx_lmm_operation(u32 lmid, enum scmi_imx_lmm_op op, u32 flags) +{ + if (!ph) + return -EPROBE_DEFER; + + switch (op) { + case SCMI_IMX_LMM_BOOT: + return imx_lmm_ops->lmm_power_boot(ph, lmid, true); + case SCMI_IMX_LMM_POWER_ON: + return imx_lmm_ops->lmm_power_boot(ph, lmid, false); + case SCMI_IMX_LMM_SHUTDOWN: + return imx_lmm_ops->lmm_shutdown(ph, lmid, flags); + default: + break; + } + + return -EINVAL; +} +EXPORT_SYMBOL(scmi_imx_lmm_operation); + +static int scmi_imx_lmm_probe(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + + if (!handle) + return -ENODEV; + + if (imx_lmm_ops) { + dev_err(&sdev->dev, "lmm already initialized\n"); + return -EEXIST; + } + + imx_lmm_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_LMM, &ph); + if (IS_ERR(imx_lmm_ops)) + return PTR_ERR(imx_lmm_ops); + + return 0; +} + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_LMM, "imx-lmm" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_lmm_driver = { + .name = "scmi-imx-lmm", + .probe = scmi_imx_lmm_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_lmm_driver); + +MODULE_AUTHOR("Peng Fan <peng.fan@nxp.com>"); +MODULE_DESCRIPTION("IMX SM LMM driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/firmware/imx/sm.h b/include/linux/firmware/imx/sm.h index 9b85a3f028d1b0a5287b453eb3ad8412a363fe6c..bc27b04afb2f68b048955f51c07a106f4c7e5852 100644 --- a/include/linux/firmware/imx/sm.h +++ b/include/linux/firmware/imx/sm.h @@ -8,6 +8,7 @@ #include <linux/bitfield.h> #include <linux/errno.h> +#include <linux/scmi_imx_protocol.h> #include <linux/types.h> #define SCMI_IMX_CTRL_PDM_CLK_SEL 0 /* AON PDM clock sel */ @@ -20,4 +21,17 @@ int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val); int scmi_imx_misc_ctrl_set(u32 id, u32 val); +enum scmi_imx_lmm_op { + SCMI_IMX_LMM_BOOT, + SCMI_IMX_LMM_POWER_ON, + SCMI_IMX_LMM_SHUTDOWN, +}; + +/* For shutdown pperation */ +#define SCMI_IMX_LMM_OP_FORCEFUL 0 +#define SCMI_IMX_LMM_OP_GRACEFUL BIT(0) + +int scmi_imx_lmm_operation(u32 lmid, enum scmi_imx_lmm_op op, u32 flags); +int scmi_imx_lmm_info(u32 lmid, struct scmi_imx_lmm_info *info); +int scmi_imx_lmm_reset_vector_set(u32 lmid, u32 cpuid, u32 flags, u64 vector); #endif