summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2026-08-25 11:37:49 -0600
committerTom Rini <[email protected]>2026-08-25 11:37:49 -0600
commit12d7a1e89c2bb00febfb41ea7566ce704dda1845 (patch)
tree8a452b9fd108a6e9dbb09568a1796f49d7a874a5
parent640cd54caede8086f0ccfc597ce3eef6d998f9e2 (diff)
parent35c2947b5b217962e8d88e2a0b7f507a037a0676 (diff)
Merge tag 'i2c-updates-for-2026.10-next' of https://git.u-boot-project.org/u-boot/custodians/hs/u-boot-i2c into next
i2c updates for 2026.10-next - i2c/clk: spacemit: k1: fix I2C bus configuration and clock handling from Junhui Reviewed by Yao Zi and myself.
-rw-r--r--drivers/clk/spacemit/clk-k1.c41
-rw-r--r--drivers/i2c/k1_i2c.c27
2 files changed, 51 insertions, 17 deletions
diff --git a/drivers/clk/spacemit/clk-k1.c b/drivers/clk/spacemit/clk-k1.c
index 07adc126ee3..20b8595aa3c 100644
--- a/drivers/clk/spacemit/clk-k1.c
+++ b/drivers/clk/spacemit/clk-k1.c
@@ -154,11 +154,27 @@ CCU_GATE_DEFINE(CLK_PLL1_409P6, pll1_d6_409p6, pll1_d6_409p6, "pll1_d6",
MPMU_ACGR, BIT(0), 0);
CCU_GATE_DEFINE(CLK_PLL1_307P2, pll1_d8_307p2, pll1_d8_307p2, "pll1_d8",
MPMU_ACGR, BIT(13), 0);
+CCU_FACTOR_GATE_DEFINE(CLK_PLL1_102P4, pll1_d24_102p4, pll1_d24_102p4,
+ "pll1_d8", MPMU_ACGR, BIT(12), 3, 1);
+CCU_FACTOR_GATE_DEFINE(CLK_PLL1_51P2, pll1_d48_51p2, pll1_d48_51p2,
+ "pll1_d8", MPMU_ACGR, BIT(7), 6, 1);
+CCU_FACTOR_GATE_DEFINE(CLK_PLL1_25P6, pll1_d96_25p6, pll1_d96_25p6,
+ "pll1_d8", MPMU_ACGR, BIT(4), 12, 1);
CCU_FACTOR_GATE_DEFINE(CLK_PLL1_31P5, pll1_d78_31p5, pll1_d78_31p5,
"pll1_d4", MPMU_ACGR, BIT(6), 39, 2);
CCU_DDN_DEFINE(CLK_SLOW_UART2, slow_uart2_48, slow_uart2_48,
"pll1_d4_614p4", MPMU_SUCCR_1,
CCU_DDN_MASK(16, 13), 16, CCU_DDN_MASK(0, 13), 0, 2, 0);
+
+static const char * const apb_parents[] = {
+ "pll1_d96_25p6",
+ "pll1_d48_51p2",
+ "pll1_d96_25p6",
+ "pll1_d24_102p4",
+};
+
+CCU_MUX_DEFINE(CLK_APB, apb_clk, apb_clk, apb_parents, ARRAY_SIZE(apb_parents),
+ MPMU_APBCSCR, 0, 2, 0);
#else
CCU_GATE_DEFINE(CLK_PLL1_307P2, pll1_d8_307p2, pll1_d8_307p2, "pll1_d8",
MPMU_ACGR, BIT(13), 0);
@@ -298,7 +314,7 @@ static const char * const twsi_parents[] = {
CCU_MUX_GATE_DEFINE(CLK_TWSI2, twsi2_clk, twsi2_clk, twsi_parents,
ARRAY_SIZE(twsi_parents), APBC_TWSI2_CLK_RST,
- 4, 3, BIT(1) | BIT(0), 0);
+ 4, 3, BIT(1), 0);
/*
* APBC_TWSI8_CLK_RST has a quirk that reading always results in zero.
* Combine functional and bus bits together as a gate to avoid sharing the
@@ -306,6 +322,9 @@ CCU_MUX_GATE_DEFINE(CLK_TWSI2, twsi2_clk, twsi2_clk, twsi_parents,
*/
CCU_GATE_DEFINE(CLK_TWSI8, twsi8_clk, twsi8_clk, "pll1_d78_31p5",
APBC_TWSI8_CLK_RST, BIT(1) | BIT(0), 0);
+CCU_GATE_DEFINE(CLK_TWSI2_BUS, twsi2_bus_clk, twsi2_bus_clk, "apb_clk",
+ APBC_TWSI2_CLK_RST, BIT(0), 0);
+CCU_FACTOR_DEFINE(CLK_TWSI8_BUS, twsi8_bus_clk, twsi8_bus_clk, "apb_clk", 1, 1);
#else
static const char * const uart_clk_parents[] = {
@@ -326,7 +345,7 @@ static const char * const twsi_parents[] = {
CCU_MUX_GATE_DEFINE(CLK_TWSI2, twsi2_clk, twsi2_clk, twsi_parents,
ARRAY_SIZE(twsi_parents), APBC_TWSI2_CLK_RST,
- 4, 3, BIT(1) | BIT(0), 0);
+ 4, 3, BIT(1), 0);
/*
* APBC_TWSI8_CLK_RST has a quirk that reading always results in zero.
* Combine functional and bus bits together as a gate to avoid sharing the
@@ -448,22 +467,22 @@ CCU_GATE_DEFINE(CLK_RTC, rtc_clk, rtc_clk, "clock-32k", APBC_RTC_CLK_RST,
CCU_MUX_GATE_DEFINE(CLK_TWSI0, twsi0_clk, twsi0_clk, twsi_parents,
ARRAY_SIZE(twsi_parents), APBC_TWSI0_CLK_RST,
- 4, 3, BIT(1) | BIT(0), 0);
+ 4, 3, BIT(1), 0);
CCU_MUX_GATE_DEFINE(CLK_TWSI1, twsi1_clk, twsi1_clk, twsi_parents,
ARRAY_SIZE(twsi_parents), APBC_TWSI1_CLK_RST,
- 4, 3, BIT(1) | BIT(0), 0);
+ 4, 3, BIT(1), 0);
CCU_MUX_GATE_DEFINE(CLK_TWSI4, twsi4_clk, twsi4_clk, twsi_parents,
ARRAY_SIZE(twsi_parents), APBC_TWSI4_CLK_RST,
- 4, 3, BIT(1) | BIT(0), 0);
+ 4, 3, BIT(1), 0);
CCU_MUX_GATE_DEFINE(CLK_TWSI5, twsi5_clk, twsi5_clk, twsi_parents,
ARRAY_SIZE(twsi_parents), APBC_TWSI5_CLK_RST,
- 4, 3, BIT(1) | BIT(0), 0);
+ 4, 3, BIT(1), 0);
CCU_MUX_GATE_DEFINE(CLK_TWSI6, twsi6_clk, twsi6_clk, twsi_parents,
ARRAY_SIZE(twsi_parents), APBC_TWSI6_CLK_RST,
- 4, 3, BIT(1) | BIT(0), 0);
+ 4, 3, BIT(1), 0);
CCU_MUX_GATE_DEFINE(CLK_TWSI7, twsi7_clk, twsi7_clk, twsi_parents,
ARRAY_SIZE(twsi_parents), APBC_TWSI7_CLK_RST,
- 4, 3, BIT(1) | BIT(0), 0);
+ 4, 3, BIT(1), 0);
static const char * const timer_parents[] = {
"pll1_d192_12p8",
@@ -1232,8 +1251,12 @@ static struct clk *k1_ccu_mpmu_clks[] = {
&pll1_d4_614p4.common.clk,
&pll1_d6_409p6.common.clk,
&pll1_d8_307p2.common.clk,
+ &pll1_d24_102p4.common.clk,
+ &pll1_d48_51p2.common.clk,
+ &pll1_d96_25p6.common.clk,
&pll1_d78_31p5.common.clk,
&slow_uart2_48.common.clk,
+ &apb_clk.common.clk,
};
#else
static struct clk *k1_ccu_mpmu_clks[] = {
@@ -1288,6 +1311,8 @@ static struct clk *k1_ccu_apbc_clks[] = {
&uart0_clk.common.clk,
&twsi2_clk.common.clk,
&twsi8_clk.common.clk,
+ &twsi2_bus_clk.common.clk,
+ &twsi8_bus_clk.common.clk,
};
#else
static struct clk *k1_ccu_apbc_clks[] = {
diff --git a/drivers/i2c/k1_i2c.c b/drivers/i2c/k1_i2c.c
index a08ff15803d..e2e4f9e5344 100644
--- a/drivers/i2c/k1_i2c.c
+++ b/drivers/i2c/k1_i2c.c
@@ -51,8 +51,6 @@ struct k1_i2c {
struct k1_i2c_priv {
int id;
void __iomem *base;
- struct clk clk;
- u32 clk_rate;
};
/*
@@ -466,6 +464,8 @@ 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;
priv->id = dev_seq(bus);
@@ -487,19 +487,28 @@ 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->clk_rate = clk_get_rate(&priv->clk);
priv->base = (void *)devfdt_get_addr_ptr(bus);
- k1_i2c_set_bus_speed(bus, priv->clk_rate);
+
+ speed = dev_read_u32_default(bus, "clock-frequency",
+ I2C_SPEED_STANDARD_RATE);
+ k1_i2c_set_bus_speed(bus, speed);
+
return 0;
}