Commit Graph

7 Commits

Author SHA1 Message Date
Yixun Lan
c79550f69f RISC-V SpacemiT Reset for 6.17
- Add reset driver support for K1 SoC
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQKTBAABCgB9FiEEtbq4ycMbcRVnAiPcMarqR1lNu+0FAmhr07BfFIAAAAAALgAo
 aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEI1
 QkFCOEM5QzMxQjcxMTU2NzAyMjNEQzMxQUFFQTQ3NTk0REJCRUQACgkQMarqR1lN
 u+0AHA/8CVWBAUYpwdz8oU3OizK/wFHHokqFlZ8iZ/LFM9TmfHN/07H47twfVEIo
 ouBHoWqNbQ25TZ7YvxoyJMNdkc6+h1qZvzYsSFlQtXfxJqcTafYu4v58uWXlizDP
 aiABWVbpqTSdW4AuIoALnhsqsb0GcY7iZuiZMykrLYq4N9FPxGYrZKbZ2lxfB4Bd
 AWMpFOZwPt7FTX3dDIfCoqvXlOvvQqzXhXKe6YPhhAgtN1/M7ofKVCEmhU84v2Ig
 Z1zulAb0eUTPjddRRiUX+oTKhvx4F8YsJ6WFugwnfDtBe29StI3Sd33041SbJH+e
 EyGTv1zJUXpTh1nmwaUB2BpObcVWpe8on0B2iVT06Smw6uPdFcbSCQbCSyCzEmvC
 ZlsemyNe7oYw5Ba+Dt91sn7epVoclHselUz1uI2AwJlaNeqNclg2INqgTcYhqKya
 W/jznHeZwX+oIYo2swMnIotjvmpg/iTKpxhJT2BVtSEdZcPBvzS9RofqRal98Pzd
 lsqJJnJ5pFgZxm6gXk9+y+zK5fIIbLSctJT6mkIWMLriXXl+YNiZHeIKe/8a9bbe
 EtoJV4umbl3TgYWSqDfnzkTGME6kFVwFTaPE03fQ33bbkYyG0F+xYl+T4hac307q
 FplHKXosxAVyZ4kex5cAjdl3dN+wK08dd4nNW0gYVKjQ5+vKdTM=
 =B45P
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQKTBAABCgB9FiEEtbq4ycMbcRVnAiPcMarqR1lNu+0FAmhr1M1fFIAAAAAALgAo
 aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEI1
 QkFCOEM5QzMxQjcxMTU2NzAyMjNEQzMxQUFFQTQ3NTk0REJCRUQACgkQMarqR1lN
 u+0g7Q//dVoNUV4E2j9aVnQKLAHVsPH+/JcsgCLWe+4/eDgOY+Owy1kJuanOY58l
 onOZuK661291pXjd7KH821O8Uvh9iP0uP9rfRuiCJ7iQ6piTM9lvo81j1e9SPfIA
 P8Us7pUM37c9qdovR/CqhRRPyS8GZpJntDzgM8LbJ1YFrc32SzI6mFUo2O2xwoZU
 CAHbjim4ELW78T3gX+TvS4RME2pTh5aqoJ1siTEUpD8DYnyT/2onURsPKPZLmYqb
 cHzGodOn+SD96xGXzgLJV24gpr5ZzgreL8RMW6klpc40Hsgc4b+I0mYC8EHR9bRZ
 ZFqwPWWvmHwA7fwaYBZMaCNpjYBe5hvl7K+pHn/rW26mKDXquLpNfae1Z+1SduYi
 fOXWaWaI1O3htFGheM2YrYxEtVRETk242vskYnNSWsYQAyMwcVA14pLXCzryzWC0
 GRDnDgM+LHAq5sNG2f86D331m5fDUAssPM7VupTy0GTVqWIJz0q9v9EY8rMbAaSA
 sxVFCGUmaLgjqdm60mdXVJLaLbCskcwrTB1hAvZtnKyFL5cSZ8W0CAwEZUC5Mxc1
 jGenD+YZ2xHYxXWdas38mNWyaVePKsOp3iqfUtOCqd6/gXvLVstvjivfio4/oXtA
 I+bt0jFSmaSmQaf780/qAELOSjBF6N/JrR3H/AxOdGfu3QXI/Jc=
 =om5E
 -----END PGP SIGNATURE-----

Merge tag 'spacemit-reset-for-6.17-1' of https://github.com/spacemit-com/linux

RISC-V SpacemiT Reset for 6.17

- Add reset driver support for K1 SoC

* tag 'spacemit-reset-for-6.17-1':
  reset: spacemit: add support for SpacemiT CCU resets
  clk: spacemit: define three reset-only CCUs
  clk: spacemit: set up reset auxiliary devices
  soc: spacemit: create a header for clock/reset registers
  dt-bindings: soc: spacemit: define spacemit,k1-ccu resets

Signed-off-by: Yixun Lan <dlan@gentoo.org>
2025-07-07 22:07:15 +08:00
Alex Elder
7554729de2
clk: spacemit: mark K1 pll1_d8 as critical
The pll1_d8 clock is enabled by the boot loader, and is ultimately a
parent for numerous clocks, including those used by APB and AXI buses.
Guodong Xu discovered that this clock got disabled while responding to
getting -EPROBE_DEFER when requesting a reset controller.

The needed clock (CLK_DMA, along with its parents) had already been
enabled.  To respond to the probe deferral return, the CLK_DMA clock
was disabled, and this led to parent clocks also reducing their enable
count.  When the enable count for pll1_d8 was decremented it became 0,
which caused it to be disabled.  This led to a system hang.

Marking that clock critical resolves this by preventing it from being
disabled.

Define a new macro CCU_FACTOR_GATE_DEFINE() to allow clock flags to
be supplied for a CCU_FACTOR_GATE clock.

Fixes: 1b72c59db0 ("clk: spacemit: Add clock support for SpacemiT K1 SoC")
Signed-off-by: Alex Elder <elder@riscstar.com>
Tested-by: Guodong Xu <guodong@riscstar.com>
Reviewed-by: Haylen Chu <heylenay@4d2.org>
Link: https://lore.kernel.org/r/20250612224856.1105924-1-elder@riscstar.com
Signed-off-by: Yixun Lan <dlan@gentoo.org>
2025-07-04 09:06:33 +08:00
Alex Elder
024b84f661
clk: spacemit: define three reset-only CCUs
Three CCUs on the SpacemiT K1 SoC implement only resets, not clocks.
Define the CCU data for these resets so their auxiliary devices get
created.

Signed-off-by: Alex Elder <elder@riscstar.com>
Reviewed-by: Yixun Lan <dlan@gentoo.org>
Link: https://lore.kernel.org/r/20250702113709.291748-5-elder@riscstar.com
Signed-off-by: Yixun Lan <dlan@gentoo.org>
2025-07-03 23:24:03 +08:00
Alex Elder
988543522e
clk: spacemit: set up reset auxiliary devices
Add a new reset_name field to the spacemit_ccu_data structure.  If it is
non-null, the CCU implements a reset controller, and the name will be
used in the name for the auxiliary device that implements it.

Define a new type to hold an auxiliary device as well as the regmap
pointer that will be needed by CCU reset controllers.  Set up code to
initialize and add an auxiliary device for any CCU that implements reset
functionality.

Make it optional for a CCU to implement a clock controller.  This
doesn't apply to any of the existing CCUs but will for some new ones
that will be added soon.

Signed-off-by: Alex Elder <elder@riscstar.com>
Reviewed-by: Haylen Chu <heylenay@4d2.org>
Reviewed-by: Yixun Lan <dlan@gentoo.org>
Link: https://lore.kernel.org/r/20250702113709.291748-4-elder@riscstar.com
Signed-off-by: Yixun Lan <dlan@gentoo.org>
2025-07-03 23:24:00 +08:00
Alex Elder
bf6239ddaa
soc: spacemit: create a header for clock/reset registers
Move the definitions of register offsets and fields used by the SpacemiT
K1 SoC CCUs into a separate header file, so that they can be shared by
the reset driver that will be found under drivers/reset.

Signed-off-by: Alex Elder <elder@riscstar.com>
Reviewed-by: Haylen Chu <heylenay@4d2.org>
Reviewed-by: Yixun Lan <dlan@gentoo.org>
Link: https://lore.kernel.org/r/20250702113709.291748-3-elder@riscstar.com
Signed-off-by: Yixun Lan <dlan@gentoo.org>
2025-07-03 23:23:57 +08:00
Haylen Chu
49625c6e4d
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>
2025-04-17 03:22:56 +08:00
Haylen Chu
1b72c59db0
clk: spacemit: Add clock support for SpacemiT K1 SoC
The clock tree of K1 SoC contains three main types of clock hardware
(PLL/DDN/MIX) and has control registers split into several multifunction
devices: APBS (PLLs), MPMU, APBC and APMU.

All register operations are done through regmap to ensure atomicity
between concurrent operations of clock driver and reset,
power-domain driver that will be introduced in the future.

Signed-off-by: Haylen Chu <heylenay@4d2.org>
Reviewed-by: Alex Elder <elder@riscstar.com>
Reviewed-by: Inochi Amaoto <inochiama@outlook.com>
Reviewed-by: Yixun Lan <dlan@gentoo.org>
Link: https://lore.kernel.org/r/20250416135406.16284-4-heylenay@4d2.org
Signed-off-by: Yixun Lan <dlan@gentoo.org>
2025-04-17 03:22:53 +08:00