From: Cristian Marussi <cristian.marussi@arm.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: Jonathan Corbet <corbet@lwn.net>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Sudeep Holla <sudeep.holla@arm.com>,
Cristian Marussi <cristian.marussi@arm.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Peng Fan <peng.fan@nxp.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
devicetree@vger.kernel.org, arm-scmi@vger.kernel.org,
linux-rtc@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH v5 5/7] firmware: imx: add i.MX95 MISC driver
Date: Thu, 11 Jul 2024 14:33:39 +0100 [thread overview]
Message-ID: <Zo_fM8c485SSnTDF@pluto> (raw)
In-Reply-To: <20240621-imx95-bbm-misc-v2-v5-5-b85a6bf778cb@nxp.com>
On Fri, Jun 21, 2024 at 03:04:40PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> The i.MX95 System manager exports SCMI MISC protocol for linux to do
> various settings, such as set board gpio expander as wakeup source.
>
> The driver is to add the support.
>
Hi,
a small style nitpick down below.
Other than that,
LGTM.
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/firmware/imx/Kconfig | 11 ++++
> drivers/firmware/imx/Makefile | 1 +
> drivers/firmware/imx/sm-misc.c | 119 ++++++++++++++++++++++++++++++++++++++++
> include/linux/firmware/imx/sm.h | 33 +++++++++++
> 4 files changed, 164 insertions(+)
>
> diff --git a/drivers/firmware/imx/Kconfig b/drivers/firmware/imx/Kconfig
> index 183613f82a11..477d3f32d99a 100644
> --- a/drivers/firmware/imx/Kconfig
> +++ b/drivers/firmware/imx/Kconfig
> @@ -22,3 +22,14 @@ config IMX_SCU
>
> This driver manages the IPC interface between host CPU and the
> SCU firmware running on M4.
> +
> +config IMX_SCMI_MISC_DRV
> + tristate "IMX SCMI MISC Protocol driver"
> + depends on IMX_SCMI_MISC_EXT || COMPILE_TEST
> + default y if ARCH_MXC
> + 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 misc functions such as board control.
> +
> + This driver can also be built as a module.
> diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile
> index 8f9f04a513a8..8d046c341be8 100644
> --- a/drivers/firmware/imx/Makefile
> +++ b/drivers/firmware/imx/Makefile
> @@ -1,3 +1,4 @@
> # SPDX-License-Identifier: GPL-2.0
> 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
> diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c
> new file mode 100644
> index 000000000000..342e1254a356
> --- /dev/null
> +++ b/drivers/firmware/imx/sm-misc.c
> @@ -0,0 +1,119 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2024 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_misc_proto_ops *imx_misc_ctrl_ops;
> +static struct scmi_protocol_handle *ph;
> +struct notifier_block scmi_imx_misc_ctrl_nb;
> +
> +int scmi_imx_misc_ctrl_set(u32 id, u32 val)
> +{
> + if (!ph)
> + return -EPROBE_DEFER;
> +
> + return imx_misc_ctrl_ops->misc_ctrl_set(ph, id, 1, &val);
> +};
> +EXPORT_SYMBOL(scmi_imx_misc_ctrl_set);
> +
> +int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val)
> +{
> + if (!ph)
> + return -EPROBE_DEFER;
> +
> + return imx_misc_ctrl_ops->misc_ctrl_get(ph, id, num, val);
> +}
> +EXPORT_SYMBOL(scmi_imx_misc_ctrl_get);
> +
> +static int scmi_imx_misc_ctrl_notifier(struct notifier_block *nb,
> + unsigned long event, void *data)
> +{
> + /*
> + * notifier_chain_register requires a valid notifier_block and
> + * valid notifier_call. SCMI_EVENT_IMX_MISC_CONTROL is needed
> + * to let SCMI firmware enable control events, but the hook here
> + * is just a dummy function to avoid kernel panic as of now.
> + */
> + return 0;
> +}
> +
> +static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
> +{
> + const struct scmi_handle *handle = sdev->handle;
> + struct device_node *np = sdev->dev.of_node;
> + u32 src_id, flags;
> + int ret, i, num;
> +
> + if (!handle)
> + return -ENODEV;
> +
> + if (imx_misc_ctrl_ops) {
> + dev_err(&sdev->dev, "misc ctrl already initialized\n");
> + return -EEXIST;
> + }
> +
> + imx_misc_ctrl_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_MISC, &ph);
> + if (IS_ERR(imx_misc_ctrl_ops))
> + return PTR_ERR(imx_misc_ctrl_ops);
> +
> + num = of_property_count_u32_elems(np, "nxp,ctrl-ids");
> + if (num % 2) {
> + dev_err(&sdev->dev, "Invalid wakeup-sources\n");
> + return -EINVAL;
> + }
> +
> + scmi_imx_misc_ctrl_nb.notifier_call = &scmi_imx_misc_ctrl_notifier;
> + for (i = 0; i < num; i += 2) {
> + ret = of_property_read_u32_index(np, "nxp,ctrl-ids", i, &src_id);
> + if (ret) {
> + dev_err(&sdev->dev, "Failed to read ctrl-id: %i\n", i);
> + continue;
> + }
> +
> + ret = of_property_read_u32_index(np, "nxp,ctrl-ids", i + 1, &flags);
> + if (ret) {
> + dev_err(&sdev->dev, "Failed to read ctrl-id value: %d\n", i + 1);
> + continue;
> + }
> +
> + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_MISC,
> + SCMI_EVENT_IMX_MISC_CONTROL,
> + &src_id,
> + &scmi_imx_misc_ctrl_nb);
> + if (ret)
missing {
dev_err(&sdev->dev, "Failed to register scmi misc event: %d\n", src_id);
}
Thanks,
Cristian
next prev parent reply other threads:[~2024-07-11 13:33 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 7:04 [PATCH v5 0/7] firmware: support i.MX95 SCMI BBM/MISC Extenstion Peng Fan (OSS)
2024-06-21 7:04 ` [PATCH v5 1/7] Documentation: firmware-guide: add NXP i.MX95 SCMI documentation Peng Fan (OSS)
2024-07-11 13:16 ` Cristian Marussi
2024-07-15 11:47 ` Peng Fan
2024-07-15 12:59 ` Sudeep Holla
2024-07-16 9:56 ` Peng Fan
2024-06-21 7:04 ` [PATCH v5 2/7] dt-bindings: firmware: add i.MX95 SCMI Extension protocol Peng Fan (OSS)
2024-07-11 13:04 ` Cristian Marussi
2024-06-21 7:04 ` [PATCH v5 3/7] firmware: arm_scmi: add initial support for i.MX BBM protocol Peng Fan (OSS)
2024-06-21 7:04 ` [PATCH v5 4/7] firmware: arm_scmi: add initial support for i.MX MISC protocol Peng Fan (OSS)
2024-07-11 13:24 ` Cristian Marussi
2024-06-21 7:04 ` [PATCH v5 5/7] firmware: imx: add i.MX95 MISC driver Peng Fan (OSS)
2024-07-11 13:33 ` Cristian Marussi [this message]
2024-06-21 7:04 ` [PATCH v5 6/7] rtc: support i.MX95 BBM RTC Peng Fan (OSS)
2024-07-11 13:39 ` Cristian Marussi
2024-07-11 20:33 ` Alexandre Belloni
2024-07-14 8:22 ` Peng Fan
2024-07-14 20:01 ` Alexandre Belloni
2024-06-21 7:04 ` [PATCH v5 7/7] input: keyboard: support i.MX95 BBM module Peng Fan (OSS)
2024-07-11 14:01 ` Cristian Marussi
2024-07-11 14:05 ` [PATCH v5 0/7] firmware: support i.MX95 SCMI BBM/MISC Extenstion Cristian Marussi
2024-07-11 19:54 ` Alexandre Belloni
2024-07-14 8:26 ` Peng Fan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zo_fM8c485SSnTDF@pluto \
--to=cristian.marussi@arm.com \
--cc=alexandre.belloni@bootlin.com \
--cc=arm-scmi@vger.kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=sudeep.holla@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).