Skip to content

Commit ca5a67e

Browse files
Yuhang.chenopsiff
authored andcommitted
drivers: soc: cix: Fix scmi clock device not found issues.
Due to changes in the common interface(upstream commit: d9f866b) CIX drivers needs to be re-adapted. Signed-off-by: Yuhang.chen <Yuhang.Chen@cixtech.com>
1 parent 81ac630 commit ca5a67e

2 files changed

Lines changed: 48 additions & 33 deletions

File tree

drivers/soc/cix/scmi/base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ static int scmi_base_protocol_init(const struct scmi_protocol_handle *ph)
406406
dev_info(dev, "SCMI Protocol v%d.%d '%s:%s' Firmware version 0x%x\n",
407407
rev->major_ver, rev->minor_ver, rev->vendor_id,
408408
rev->sub_vendor_id, rev->impl_ver);
409-
dev_dbg(dev, "Found %d protocol(s) %d agent(s)\n", rev->num_protocols,
409+
dev_info(dev, "CIX Found %d protocol(s) %d agent(s)\n", rev->num_protocols,
410410
rev->num_agents);
411411

412412
for (id = 0; id < rev->num_agents; id++) {

drivers/soc/cix/scmi/driver.c

Lines changed: 47 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/processor.h>
3434
#include <linux/refcount.h>
3535
#include <linux/slab.h>
36+
#include <linux/acpi.h>
3637

3738
#include "raw_mode.h"
3839

@@ -1630,7 +1631,7 @@ void cix_scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id)
16301631
mutex_unlock(&info->protocols_mtx);
16311632
}
16321633

1633-
static bool
1634+
static bool __maybe_unused
16341635
scmi_is_protocol_implemented(const struct scmi_handle *handle, u8 prot_id)
16351636
{
16361637
int i;
@@ -2327,6 +2328,47 @@ static int scmi_debugfs_raw_mode_setup(struct scmi_info *info)
23272328
return ret;
23282329
}
23292330

2331+
int scan_scmi_child_dev(struct device *dev, void *data)
2332+
{
2333+
struct scmi_info *info = data;
2334+
struct fwnode_handle *child;
2335+
u32 prot_id, ret;
2336+
2337+
/*make sure child dev is acpi_device*/
2338+
if (!dev->bus || strcmp(dev->bus->name, "acpi"))
2339+
return 0;
2340+
2341+
child = &(to_acpi_device(dev)->fwnode);
2342+
if (fwnode_property_read_u32(child, "reg", &prot_id))
2343+
return 0;
2344+
2345+
if (!FIELD_FIT(MSG_PROTOCOL_ID_MASK, prot_id)) {
2346+
dev_err(dev, "Out of range protocol %d\n", prot_id);
2347+
return 0;
2348+
}
2349+
2350+
if (!scmi_is_protocol_implemented(&info->handle, prot_id)) {
2351+
dev_err(dev, "SCMI protocol %d not implemented\n", prot_id);
2352+
return 0;
2353+
}
2354+
2355+
/*
2356+
* Save this valid DT protocol descriptor amongst
2357+
* @active_protocols for this SCMI instance/
2358+
*/
2359+
ret = idr_alloc(&info->active_protocols, child, prot_id, prot_id + 1, GFP_KERNEL);
2360+
if (ret != prot_id) {
2361+
dev_err(dev, "SCMI protocol %d already activated. Skip\n", prot_id);
2362+
return 0;
2363+
}
2364+
2365+
fwnode_handle_get(child);
2366+
scmi_txrx_setup(info, child, prot_id); //for create scmi_chan_info
2367+
scmi_create_protocol_devices(child, info, prot_id, NULL);
2368+
2369+
return 0;
2370+
}
2371+
23302372
static int scmi_probe(struct platform_device *pdev)
23312373
{
23322374
int ret;
@@ -2335,7 +2377,8 @@ static int scmi_probe(struct platform_device *pdev)
23352377
struct scmi_info *info;
23362378
bool coex = IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT_COEX);
23372379
struct device *dev = &pdev->dev;
2338-
struct fwnode_handle *child, *np = dev->fwnode;
2380+
struct fwnode_handle *np = dev->fwnode;
2381+
struct acpi_device *adev = to_acpi_device_node(np);
23392382

23402383
desc = device_get_match_data(dev);
23412384
if (!desc)
@@ -2447,36 +2490,8 @@ static int scmi_probe(struct platform_device *pdev)
24472490
list_add_tail(&info->node, &scmi_list);
24482491
mutex_unlock(&scmi_list_mutex);
24492492

2450-
fwnode_for_each_child_node(np, child) {
2451-
u32 prot_id;
2452-
2453-
if (fwnode_property_read_u32(child, "reg", &prot_id))
2454-
continue;
2455-
2456-
if (!FIELD_FIT(MSG_PROTOCOL_ID_MASK, prot_id))
2457-
dev_err(dev, "Out of range protocol %d\n", prot_id);
2458-
2459-
if (!scmi_is_protocol_implemented(handle, prot_id)) {
2460-
dev_err(dev, "SCMI protocol %d not implemented\n",
2461-
prot_id);
2462-
continue;
2463-
}
2464-
2465-
/*
2466-
* Save this valid DT protocol descriptor amongst
2467-
* @active_protocols for this SCMI instance/
2468-
*/
2469-
ret = idr_alloc(&info->active_protocols, child,
2470-
prot_id, prot_id + 1, GFP_KERNEL);
2471-
if (ret != prot_id) {
2472-
dev_err(dev, "SCMI protocol %d already activated. Skip\n",
2473-
prot_id);
2474-
continue;
2475-
}
2476-
2477-
fwnode_handle_get(child);
2478-
scmi_create_protocol_devices(child, info, prot_id, NULL);
2479-
}
2493+
if (adev)
2494+
device_for_each_child(&adev->dev, info, scan_scmi_child_dev);
24802495

24812496
return 0;
24822497

0 commit comments

Comments
 (0)