[RFC PATCH 8/8] firmware: arm_scmi: probe and initialise all the supported protocols
From: Sudeep Holla
Date: Wed Jun 07 2017 - 12:11:20 EST
Now that we have basic support for all the protocols in the
specification, let's probe them individually and initialise them.
Signed-off-by: Sudeep Holla <sudeep.holla@xxxxxxx>
---
drivers/firmware/arm_scmi/common.h | 5 +++++
drivers/firmware/arm_scmi/driver.c | 30 +++++++++++++++++++++++++++++-
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
index 32873a315c76..e2ff799e7dd4 100644
--- a/drivers/firmware/arm_scmi/common.h
+++ b/drivers/firmware/arm_scmi/common.h
@@ -119,4 +119,9 @@ int scmi_version_get(struct scmi_handle *h, u8 protocol, u32 *version);
bool scmi_is_protocol_implemented(struct scmi_handle *h, u8 prot_id);
void scmi_setup_protocol_implemented(struct scmi_handle *handle, u8 *prot_imp);
+typedef int (*scmi_init_fn_t)(struct scmi_handle *);
int scmi_base_protocol_init(struct scmi_handle *h);
+int scmi_perf_protocol_init(struct scmi_handle *h);
+int scmi_sensors_protocol_init(struct scmi_handle *h);
+int scmi_power_protocol_init(struct scmi_handle *h);
+int scmi_clock_protocol_init(struct scmi_handle *h);
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 7b653c932edc..3300d0cce9e0 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -684,6 +684,23 @@ static int scmi_xfer_info_init(struct scmi_info *sinfo)
return 0;
}
+static const struct of_device_id scmi_protocol_match[] = {
+ {
+ .compatible = "arm,scmi-perf-domains",
+ .data = scmi_perf_protocol_init,
+ }, {
+ .compatible = "arm,scmi-clocks",
+ .data = scmi_clock_protocol_init,
+ }, {
+ .compatible = "arm,scmi-power-domains",
+ .data = scmi_power_protocol_init,
+ }, {
+ .compatible = "arm,scmi-sensors",
+ .data = scmi_sensors_protocol_init,
+ },
+ {}
+};
+
static int scmi_probe(struct platform_device *pdev)
{
int ret = -EINVAL;
@@ -694,7 +711,7 @@ static int scmi_probe(struct platform_device *pdev)
const struct scmi_desc *desc;
struct scmi_info *info = NULL;
struct device *dev = &pdev->dev;
- struct device_node *shmem, *np = dev->of_node;
+ struct device_node *child, *shmem, *np = dev->of_node;
desc = of_match_device(scmi_of_match, dev)->data;
@@ -755,6 +772,17 @@ static int scmi_probe(struct platform_device *pdev)
goto out;
}
+ for_each_available_child_of_node(np, child) {
+ scmi_init_fn_t fn;
+ const struct of_device_id *match;
+
+ match = of_match_node(scmi_protocol_match, child);
+ if (!match)
+ continue;
+ fn = match->data;
+ fn(handle);
+ }
+
mutex_lock(&scmi_list_mutex);
list_add_tail(&info->node, &scmi_list);
mutex_unlock(&scmi_list_mutex);
--
2.7.4