* [PATCH v2 1/2] firmware: arm_scmi: channel unavailable if no of_node
2024-06-26 8:32 [PATCH v2 0/2] firmware: arm_scmi: create scmi devices for protocols that not have of_node Peng Fan (OSS)
@ 2024-06-26 8:32 ` Peng Fan (OSS)
2024-06-26 8:32 ` [PATCH v2 2/2] firmware: arm_scmi: create scmi_devices that not have of_node Peng Fan (OSS)
1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan (OSS) @ 2024-06-26 8:32 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi
Cc: arm-scmi, linux-arm-kernel, linux-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
If there is no of_node for the protocol, there is no per protocol
channel, so return false. Then it will reuse the base protocol
channel per `scmi_chan_setup`.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/firmware/arm_scmi/mailbox.c | 2 ++
drivers/firmware/arm_scmi/optee.c | 3 +++
drivers/firmware/arm_scmi/smc.c | 7 ++++++-
drivers/firmware/arm_scmi/virtio.c | 3 +++
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/mailbox.c b/drivers/firmware/arm_scmi/mailbox.c
index 0219a12e3209..4f3abc933315 100644
--- a/drivers/firmware/arm_scmi/mailbox.c
+++ b/drivers/firmware/arm_scmi/mailbox.c
@@ -71,6 +71,8 @@ static bool mailbox_chan_available(struct device_node *of_node, int idx)
{
int num_mb;
+ if (!of_node)
+ return false;
/*
* Just check if bidirrectional channels are involved, and check the
* index accordingly; proper full validation will be made later
diff --git a/drivers/firmware/arm_scmi/optee.c b/drivers/firmware/arm_scmi/optee.c
index 4e7944b91e38..c0a198baa706 100644
--- a/drivers/firmware/arm_scmi/optee.c
+++ b/drivers/firmware/arm_scmi/optee.c
@@ -334,6 +334,9 @@ static bool scmi_optee_chan_available(struct device_node *of_node, int idx)
{
u32 channel_id;
+ if (!of_node)
+ return false;
+
return !of_property_read_u32_index(of_node, "linaro,optee-channel-id",
idx, &channel_id);
}
diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
index 39936e1dd30e..913e45c205fb 100644
--- a/drivers/firmware/arm_scmi/smc.c
+++ b/drivers/firmware/arm_scmi/smc.c
@@ -81,7 +81,12 @@ static irqreturn_t smc_msg_done_isr(int irq, void *data)
static bool smc_chan_available(struct device_node *of_node, int idx)
{
- struct device_node *np = of_parse_phandle(of_node, "shmem", 0);
+ struct device_node *np;
+
+ if (!of_node)
+ return false;
+
+ np = of_parse_phandle(of_node, "shmem", 0);
if (!np)
return false;
diff --git a/drivers/firmware/arm_scmi/virtio.c b/drivers/firmware/arm_scmi/virtio.c
index 4892058445ce..4d8d6ad3ab5b 100644
--- a/drivers/firmware/arm_scmi/virtio.c
+++ b/drivers/firmware/arm_scmi/virtio.c
@@ -389,6 +389,9 @@ static bool virtio_chan_available(struct device_node *of_node, int idx)
{
struct scmi_vio_channel *channels, *vioch = NULL;
+ if (!of_node)
+ return false;
+
if (WARN_ON_ONCE(!scmi_vdev))
return false;
--
2.37.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH v2 2/2] firmware: arm_scmi: create scmi_devices that not have of_node
2024-06-26 8:32 [PATCH v2 0/2] firmware: arm_scmi: create scmi devices for protocols that not have of_node Peng Fan (OSS)
2024-06-26 8:32 ` [PATCH v2 1/2] firmware: arm_scmi: channel unavailable if no of_node Peng Fan (OSS)
@ 2024-06-26 8:32 ` Peng Fan (OSS)
1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan (OSS) @ 2024-06-26 8:32 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi
Cc: arm-scmi, linux-arm-kernel, linux-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
The scmi protocol device tree node is expected to have consumers or
per node properties expect `reg`. For System power management protocol,
if no per node channel information, no need to add it in device tree,
and it will also trigger dtbs_check error "scmi: 'protocol@12' does not
match any of the regexes: 'pinctrl-[0-9]+'".
To enable system power protocol, need to explictily create the scmi
device and bind with protocol driver.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/firmware/arm_scmi/driver.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 6b6957f4743f..44a6e64eb78e 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2952,7 +2952,7 @@ static int scmi_debugfs_raw_mode_setup(struct scmi_info *info)
static int scmi_probe(struct platform_device *pdev)
{
- int ret;
+ int i, ret;
char *err_str = "probe failure\n";
struct scmi_handle *handle;
const struct scmi_desc *desc;
@@ -2960,6 +2960,7 @@ static int scmi_probe(struct platform_device *pdev)
bool coex = IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT_COEX);
struct device *dev = &pdev->dev;
struct device_node *child, *np = dev->of_node;
+ uint32_t protocols[] = { SCMI_PROTOCOL_SYSTEM, SCMI_PROTOCOL_POWERCAP };
desc = of_device_get_match_data(dev);
if (!desc)
@@ -3114,6 +3115,36 @@ static int scmi_probe(struct platform_device *pdev)
scmi_create_protocol_devices(child, info, prot_id, NULL);
}
+ /* Create devices that not have a device node */
+ for (i = 0; i < ARRAY_SIZE(protocols); i++) {
+ void *p;
+ u32 prot_id = protocols[i];
+
+ p = idr_find(&info->active_protocols, prot_id);
+ if (p)
+ continue;
+
+ if (!scmi_is_protocol_implemented(handle, prot_id)) {
+ dev_info(dev, "SCMI protocol 0x%x not implemented\n",
+ protocols[i]);
+ continue;
+ }
+
+ ret = scmi_txrx_setup(info, NULL, prot_id);
+ if (ret) {
+ dev_err(dev, "SCMI protocol 0x%x txrx setup fail(%d)\n",
+ prot_id, ret);
+ continue;
+ }
+
+ ret = idr_alloc(&info->active_protocols, NULL,
+ prot_id, prot_id + 1, GFP_KERNEL);
+ if (ret != prot_id)
+ continue;
+
+ scmi_create_protocol_devices(NULL, info, prot_id, NULL);
+ }
+
return 0;
notification_exit:
--
2.37.1
^ permalink raw reply related [flat|nested] 3+ messages in thread