Skip to content

Commit 49625c6

Browse files
Haylen Chudlan17
authored andcommitted
clk: spacemit: k1: Add TWSI8 bus and function clocks
The control register for TWSI8 clocks, APBC_TWSI8_CLK_RST, contains mux selection bits, reset assertion bit and enable bits for function and bus clocks. It has a quirk that reading always results in zero. As a workaround, let's hardcode the mux value as zero to select pll1_d78_31p5 as parent and treat twsi8_clk as a gate, whose enable mask is combined from the real bus and function clocks to avoid the write-only register being shared between two clk_hws, in which case updates of one clk_hw zero the other's bits. With a 1:1 factor serving as placeholder for the bus clock, the I2C-8 controller could be brought up, which is essential for boards attaching power-management chips to it. Signed-off-by: Haylen Chu <heylenay@4d2.org> Reviewed-by: Alex Elder <elder@riscstar.com> Reviewed-by: Yixun Lan <dlan@gentoo.org> Link: https://lore.kernel.org/r/20250416135406.16284-5-heylenay@4d2.org Signed-off-by: Yixun Lan <dlan@gentoo.org>
1 parent 1b72c59 commit 49625c6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/clk/spacemit/ccu-k1.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ CCU_MUX_GATE_DEFINE(twsi4_clk, twsi_parents, APBC_TWSI4_CLK_RST, 4, 3, BIT(1), 0
328328
CCU_MUX_GATE_DEFINE(twsi5_clk, twsi_parents, APBC_TWSI5_CLK_RST, 4, 3, BIT(1), 0);
329329
CCU_MUX_GATE_DEFINE(twsi6_clk, twsi_parents, APBC_TWSI6_CLK_RST, 4, 3, BIT(1), 0);
330330
CCU_MUX_GATE_DEFINE(twsi7_clk, twsi_parents, APBC_TWSI7_CLK_RST, 4, 3, BIT(1), 0);
331+
/*
332+
* APBC_TWSI8_CLK_RST has a quirk that reading always results in zero.
333+
* Combine functional and bus bits together as a gate to avoid sharing the
334+
* write-only register between different clock hardwares.
335+
*/
336+
CCU_GATE_DEFINE(twsi8_clk, CCU_PARENT_HW(pll1_d78_31p5), APBC_TWSI8_CLK_RST, BIT(1) | BIT(0), 0);
331337

332338
static const struct clk_parent_data timer_parents[] = {
333339
CCU_PARENT_HW(pll1_d192_12p8),
@@ -412,6 +418,8 @@ CCU_GATE_DEFINE(twsi4_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI4_CLK_RST, BIT(0
412418
CCU_GATE_DEFINE(twsi5_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI5_CLK_RST, BIT(0), 0);
413419
CCU_GATE_DEFINE(twsi6_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI6_CLK_RST, BIT(0), 0);
414420
CCU_GATE_DEFINE(twsi7_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TWSI7_CLK_RST, BIT(0), 0);
421+
/* Placeholder to workaround quirk of the register */
422+
CCU_FACTOR_DEFINE(twsi8_bus_clk, CCU_PARENT_HW(apb_clk), 1, 1);
415423

416424
CCU_GATE_DEFINE(timers1_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TIMERS1_CLK_RST, BIT(0), 0);
417425
CCU_GATE_DEFINE(timers2_bus_clk, CCU_PARENT_HW(apb_clk), APBC_TIMERS2_CLK_RST, BIT(0), 0);
@@ -896,6 +904,7 @@ static struct clk_hw *k1_ccu_apbc_hws[] = {
896904
[CLK_TWSI5] = &twsi5_clk.common.hw,
897905
[CLK_TWSI6] = &twsi6_clk.common.hw,
898906
[CLK_TWSI7] = &twsi7_clk.common.hw,
907+
[CLK_TWSI8] = &twsi8_clk.common.hw,
899908
[CLK_TIMERS1] = &timers1_clk.common.hw,
900909
[CLK_TIMERS2] = &timers2_clk.common.hw,
901910
[CLK_AIB] = &aib_clk.common.hw,
@@ -947,6 +956,7 @@ static struct clk_hw *k1_ccu_apbc_hws[] = {
947956
[CLK_TWSI5_BUS] = &twsi5_bus_clk.common.hw,
948957
[CLK_TWSI6_BUS] = &twsi6_bus_clk.common.hw,
949958
[CLK_TWSI7_BUS] = &twsi7_bus_clk.common.hw,
959+
[CLK_TWSI8_BUS] = &twsi8_bus_clk.common.hw,
950960
[CLK_TIMERS1_BUS] = &timers1_bus_clk.common.hw,
951961
[CLK_TIMERS2_BUS] = &timers2_bus_clk.common.hw,
952962
[CLK_AIB_BUS] = &aib_bus_clk.common.hw,

0 commit comments

Comments
 (0)