diff options
| author | Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com> | 2026-01-07 11:33:47 +0100 |
|---|---|---|
| committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2026-01-14 15:54:26 +0100 |
| commit | 579c7255922a3e0ba432eb608deb7d0fed896052 (patch) | |
| tree | ce57c6f9166100edf4a7e3705f355796b92450bb /drivers | |
| parent | 540a55a5bafd0ddbeb87672fe569c15954b47038 (diff) | |
i3c: renesas: Switch to clk_bulk API and store clocks in private data
Replace individual devm_clk_get_enabled() calls with the clk_bulk API
and store the clock handles in the driver's private data structure.
All clocks required by the controller are now acquired and enabled using
devm_clk_bulk_get_all_enabled(), removing the need for per-SoC clock
handling and the renesas_i3c_config data.
The TCLK is accessed via a fixed index in the bulk clock array.
Simplify the code and prepare the driver for upcoming suspend/resume
support.
No functional change intended.
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/1286f8600b542da55facf9920fed7c06b2b0e4d5.1767781092.git.tommaso.merciai.xr@bp.renesas.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/i3c/master/renesas-i3c.c | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-i3c.c index 426a418f29b6..bb1d11693ec9 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -198,6 +198,8 @@ #define RENESAS_I3C_MAX_DEVS 8 #define I2C_INIT_MSG -1 +#define RENESAS_I3C_TCLK_IDX 1 + enum i3c_internal_state { I3C_INTERNAL_STATE_DISABLED, I3C_INTERNAL_STATE_CONTROLLER_IDLE, @@ -259,7 +261,8 @@ struct renesas_i3c { u8 addrs[RENESAS_I3C_MAX_DEVS]; struct renesas_i3c_xferqueue xferqueue; void __iomem *regs; - struct clk *tclk; + struct clk_bulk_data *clks; + u8 num_clks; }; struct renesas_i3c_i2c_dev_data { @@ -272,10 +275,6 @@ struct renesas_i3c_irq_desc { const char *desc; }; -struct renesas_i3c_config { - unsigned int has_pclkrw:1; -}; - static inline void renesas_i3c_reg_update(void __iomem *reg, u32 mask, u32 val) { u32 data = readl(reg); @@ -489,7 +488,7 @@ static int renesas_i3c_bus_init(struct i3c_master_controller *m) int od_high_ticks, od_low_ticks, i2c_total_ticks; int ret; - rate = clk_get_rate(i3c->tclk); + rate = clk_get_rate(i3c->clks[RENESAS_I3C_TCLK_IDX].clk); if (!rate) return -EINVAL; @@ -1302,13 +1301,8 @@ static int renesas_i3c_probe(struct platform_device *pdev) { struct renesas_i3c *i3c; struct reset_control *reset; - struct clk *clk; - const struct renesas_i3c_config *config = of_device_get_match_data(&pdev->dev); int ret, i; - if (!config) - return -ENODATA; - i3c = devm_kzalloc(&pdev->dev, sizeof(*i3c), GFP_KERNEL); if (!i3c) return -ENOMEM; @@ -1317,19 +1311,12 @@ static int renesas_i3c_probe(struct platform_device *pdev) if (IS_ERR(i3c->regs)) return PTR_ERR(i3c->regs); - clk = devm_clk_get_enabled(&pdev->dev, "pclk"); - if (IS_ERR(clk)) - return PTR_ERR(clk); - - if (config->has_pclkrw) { - clk = devm_clk_get_enabled(&pdev->dev, "pclkrw"); - if (IS_ERR(clk)) - return PTR_ERR(clk); - } - - i3c->tclk = devm_clk_get_enabled(&pdev->dev, "tclk"); - if (IS_ERR(i3c->tclk)) - return PTR_ERR(i3c->tclk); + ret = devm_clk_bulk_get_all_enabled(&pdev->dev, &i3c->clks); + if (ret <= RENESAS_I3C_TCLK_IDX) + return dev_err_probe(&pdev->dev, ret < 0 ? ret : -EINVAL, + "Failed to get clocks (need > %d, got %d)\n", + RENESAS_I3C_TCLK_IDX, ret); + i3c->num_clks = ret; reset = devm_reset_control_get_optional_exclusive_deasserted(&pdev->dev, "tresetn"); if (IS_ERR(reset)) @@ -1374,16 +1361,9 @@ static void renesas_i3c_remove(struct platform_device *pdev) i3c_master_unregister(&i3c->base); } -static const struct renesas_i3c_config empty_i3c_config = { -}; - -static const struct renesas_i3c_config r9a09g047_i3c_config = { - .has_pclkrw = 1, -}; - static const struct of_device_id renesas_i3c_of_ids[] = { - { .compatible = "renesas,r9a08g045-i3c", .data = &empty_i3c_config }, - { .compatible = "renesas,r9a09g047-i3c", .data = &r9a09g047_i3c_config }, + { .compatible = "renesas,r9a08g045-i3c" }, + { .compatible = "renesas,r9a09g047-i3c" }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, renesas_i3c_of_ids); |
