Skip to content

Commit 16963d3

Browse files
Shreehari-AlifSemicfriedt
authored andcommitted
drivers: i3c: dw: Add clock subsystem and pinctrl support
Add support for clock subsystem configuration and pinctrl in the DesignWare I3C driver to enable proper clock control and pin management on platforms that require them. Changes include: - Add clock_subsys field to dw_i3c_config structure. - Update clock_control_get_rate() and clock_control_on() calls to use the configured clock subsystem instead of NULL. - Use COND_CODE_1 with DT_INST_PHA_HAS_CELL to conditionally extract clock subsystem ID from devicetree, providing backward compatibility for platforms without clkid cell. - Include pinctrl-device.yaml in devicetree binding to enable pinctrl support for platforms that need pin configuration. - Gracefully fallback to NULL behavior when clkid is not specified. This follows the same pattern used by other I3C drivers (mcux, renesas_ra) and enables proper clock management for SoCs that require clock subsystem identifiers while maintaining compatibility with existing devicetree configurations. Signed-off-by: Shreehari HK <[email protected]>
1 parent bd9ade1 commit 16963d3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

drivers/i3c/i3c_dw.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ struct dw_i3c_xfer {
360360
struct dw_i3c_config {
361361
struct i3c_driver_config common;
362362
const struct device *clock;
363+
364+
/* Clock control subsys related struct */
365+
clock_control_subsys_t clock_subsys;
363366
uint32_t regs;
364367

365368
/* Initial clk configuration */
@@ -1420,7 +1423,7 @@ static int init_scl_timing(const struct device *dev)
14201423
uint32_t hcnt, lcnt;
14211424
#endif /* CONFIG_I3C_CONTROLLER */
14221425

1423-
if (clock_control_get_rate(config->clock, NULL, &core_rate) != 0) {
1426+
if (clock_control_get_rate(config->clock, config->clock_subsys, &core_rate) != 0) {
14241427
LOG_ERR("%s: get clock rate failed", dev->name);
14251428
return -EINVAL;
14261429
}
@@ -2291,7 +2294,7 @@ static int dw_i3c_init(const struct device *dev)
22912294
return -ENODEV;
22922295
}
22932296

2294-
ret = clock_control_on(config->clock, NULL);
2297+
ret = clock_control_on(config->clock, config->clock_subsys);
22952298
if (ret < 0) {
22962299
return ret;
22972300
}
@@ -2498,6 +2501,9 @@ static DEVICE_API(i3c, dw_i3c_api) = {
24982501
static const struct dw_i3c_config dw_i3c_cfg_##n = { \
24992502
.regs = DT_INST_REG_ADDR(n), \
25002503
.clock = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
2504+
.clock_subsys = COND_CODE_1(DT_INST_PHA_HAS_CELL(n, clocks, clkid), \
2505+
((clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, clkid)), \
2506+
((clock_control_subsys_t)0)), \
25012507
.od_thigh_max_ns = DT_INST_PROP(n, od_thigh_max_ns), \
25022508
.od_tlow_min_ns = DT_INST_PROP(n, od_tlow_min_ns), \
25032509
.irq_config_func = &i3c_dw_irq_config_##n, \

dts/bindings/i3c/snps,designware-i3c.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: >
77
88
compatible: "snps,designware-i3c"
99

10-
include: i3c-controller.yaml
10+
include: [i3c-controller.yaml, pinctrl-device.yaml]
1111

1212
properties:
1313
clocks:

0 commit comments

Comments
 (0)