From febfffd338e0be62d28c280ae779fd7bb88fe17c Mon Sep 17 00:00:00 2001 From: Junhui Liu Date: Sat, 15 Aug 2026 11:40:23 +0800 Subject: i2c: k1: enable both functional and bus clocks The K1 I2C controller requires both its functional clock and APB bus clock to operate. The device tree provides them as "func" and "bus", but the driver currently acquires and enables only the first clock. Acquire both clocks by name and enable them during probe. Use explicit named lookups instead of the bulk clock API to align with the K1 Linux driver and keep the roles of the two clocks clear if functional clock rate configuration is needed later. Fixes: 271546fb8e54 ("i2c: k1: add I2C driver support") Reviewed-by: Heiko Schocher Reviewed-by: Yao Zi Signed-off-by: Junhui Liu --- drivers/i2c/k1_i2c.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/k1_i2c.c b/drivers/i2c/k1_i2c.c index 2c7a1e0d377..e2e4f9e5344 100644 --- a/drivers/i2c/k1_i2c.c +++ b/drivers/i2c/k1_i2c.c @@ -51,7 +51,6 @@ struct k1_i2c { struct k1_i2c_priv { int id; void __iomem *base; - struct clk clk; }; /* @@ -465,6 +464,7 @@ static int k1_i2c_probe(struct udevice *bus) { struct k1_i2c_priv *priv = dev_get_priv(bus); struct reset_ctl reset; + struct clk clk; u32 speed; int ret; @@ -487,15 +487,21 @@ static int k1_i2c_probe(struct udevice *bus) return ret; } - ret = clk_get_by_index(bus, 0, &priv->clk); + ret = clk_get_by_name(bus, "func", &clk); if (ret) return ret; - ret = clk_enable(&priv->clk); - if (ret && ret != -ENOSYS && ret != -EOPNOTSUPP) { - debug("%s: failed to enable clock\n", __func__); + ret = clk_enable(&clk); + if (ret) + return ret; + + ret = clk_get_by_name(bus, "bus", &clk); + if (ret) + return ret; + + ret = clk_enable(&clk); + if (ret) return ret; - } priv->base = (void *)devfdt_get_addr_ptr(bus); -- cgit v1.3.1