Skip to contentSkip to conversation

reset: rockchip: implement rk3588 lookup table

PATCH RESEND New Eugen Hristev 1 participant 1 message May 15, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 reset: rockchip: implement rk3588 lookup table

The current DT bindings for the rk3588 clock use a different ID than the one that is supposed to be written to the hardware registers. Thus, we cannot use directly the id provided in the phandle, but rather use a lookup table to correctly setup the hardware.

This approach has been implemented already in Linux, by commit :
f1c506d152ff ("clk: rockchip: add clock controller for the RK3588")

Hence, implement a similar approach using the lookup table, and adapt the existing reset driver to work with SoCs using lookup table. The file rst-rk3588.c has been copied as much as possible from Linux.

Adapt the clk rk3588 driver as well to bind the reset driver with the lookup table.

---

Hi Kever,
I rebased this

Thanks,
Eugen

 arch/arm/include/asm/arch-rockchip/clock.h |  21 +
 drivers/clk/rockchip/clk_rk3588.c          |   2 +-
 drivers/reset/Makefile                     |   2 +-
 drivers/reset/reset-rockchip.c             |  46 +-
 drivers/reset/rst-rk3588.c                 | 854 +++++++++++++++++++++
 5 files changed, 912 insertions(+), 13 deletions(-)
 create mode 100644 drivers/reset/rst-rk3588.c
arch/arm/include/asm/arch-rockchip/clock.h +21 -0
index f002ebcb7ac1..f01c5aeb71cb 100644
@@ -194,5 +194,26 @@ int rockchip_get_clk(struct udevice **devp);
  * Return: 0 success, or error value
  */
 int rockchip_reset_bind(struct udevice *pdev, u32 reg_offset, u32 reg_number);
+/*
+ * rockchip_reset_bind_lut() - Bind soft reset device as child of clock device
+ *			       using a dedicated SoC lookup table
+ * @pdev: clock udevice
+ * @lookup_table: register lookup_table dedicated to SoC
+ * @reg_offset: the first offset in cru for softreset registers
+ * @reg_number: the reg numbers of softreset registers
+ * Return: 0 success, or error value
+ */
+int rockchip_reset_bind_lut(struct udevice *pdev, const int *lookup_table,
+			    u32 reg_offset, u32 reg_number);
+/*
+ * rk3588_reset_bind_lut() - Bind soft reset device as child of clock device
+ *			     using dedicated RK3588 lookup table
+ *
+ * @pdev: clock udevice
+ * @reg_offset: the first offset in cru for softreset registers
+ * @reg_number: the reg numbers of softreset registers
+ * Return: 0 success, or error value
+ */
+int rk3588_reset_bind_lut(struct udevice *pdev, u32 reg_offset, u32 reg_number);
 
 #endif
drivers/clk/rockchip/clk_rk3588.c +1 -1
index 5c27626df78d..119b1337bdf2 100644
@@ -1996,7 +1996,7 @@ static int rk3588_clk_bind(struct udevice *dev)
 
 #if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
 	ret = offsetof(struct rk3588_cru, softrst_con[0]);
-	ret = rockchip_reset_bind(dev, ret, 49158);
+	ret = rk3588_reset_bind_lut(dev, ret, 49158);
 	if (ret)
 		debug("Warning: software reset driver bind failed\n");
 #endif
drivers/reset/Makefile +1 -1
index 680126818090..e2239a250a3a 100644
@@ -16,7 +16,7 @@ obj-$(CONFIG_RESET_BCM6345) += reset-bcm6345.o
 obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o
 obj-$(CONFIG_RESET_AST2500) += reset-ast2500.o
 obj-$(CONFIG_RESET_AST2600) += reset-ast2600.o
-obj-$(CONFIG_RESET_ROCKCHIP) += reset-rockchip.o
+obj-$(CONFIG_RESET_ROCKCHIP) += reset-rockchip.o rst-rk3588.o
 obj-$(CONFIG_RESET_MESON) += reset-meson.o
 obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o
 obj-$(CONFIG_RESET_MEDIATEK) += reset-mediatek.o
drivers/reset/reset-rockchip.c +35 -11

94 lines not on this page · raw message

drivers/reset/rst-rk3588.c new file +854 -0

854 lines not on this page · raw message

Signature · 1 line
2.34.1