Skip to contentSkip to conversation

Add k1 reset driver for bananapi-bpif3 platform.

PATCH In review Huan Zhou 2 participants 9 messages Mar 11, 2025 – Mar 25, 2025

Subsystems (4)
lore
Share & tools
lore

Huan Zhou

author
#0 lore raw

v2 cover Add k1 reset driver for bananapi-bpif3 platform.

Add device tree bindings and basic reset controller driver for the BananaPi F3 board.This initial implementation supports the core reset functionality.

Changed in v2:
- fixed checkpatch error/warning.
- Links to v1: https://lore.kernel.org/u-boot/[email protected]/

---
Huan Zhou (4):
riscv: dt-binding: k1: Add reset driver binding definition.
riscv: reset: k1: Add reset driver
riscv: dts: k1: add reset controller node in device tree Add reset config options for k1

 arch/riscv/cpu/k1/Kconfig                     |   1 +
 arch/riscv/dts/k1.dtsi                        |  15 +
 configs/bananapi-f3_defconfig                 |   1 +
 drivers/reset/Kconfig                         |   7 +
 drivers/reset/Makefile                        |   1 +
 drivers/reset/reset-spacemit-k1.c             | 548 ++++++++++++++++++++++++++
 include/dt-bindings/reset/spacemit-k1-reset.h | 118 ++++++
 7 files changed, 691 insertions(+)

---
base-commit: cf6354ab23bfc3337b1087d243e6be4af48abe84
change-id: 20250308-reset-k1-773cd93f5337

Best regards,

Signature · 1 line
Huan Zhou <[email protected]>
author
#1 lore raw

PATCH v2 1/4 riscv: dt-binding: k1: Add reset driver binding definition.

Add dt-binding for reset driver.

---
 include/dt-bindings/reset/spacemit-k1-reset.h | 118 ++++++++++++++++++++++++++
 1 file changed, 118 insertions(+)
include/dt-bindings/reset/spacemit-k1-reset.h new file +118 -0
new file mode 100644
index 0000000000000000000000000000000000000000..74db58b27ef875aa2cfe99bd28ed959116b46536
@@ -0,0 +1,118 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2022 Spacemit Inc.
+ * Copyright (C) 2025 Huan Zhou <[email protected]>
+ */
+
+#ifndef __DT_BINDINGS_RESET_SAPCEMIT_K1_H__
+#define __DT_BINDINGS_RESET_SAPCEMIT_K1_H__
+/* APBC */
+#define	RESET_UART1   1
+#define	RESET_UART2   2
+#define	RESET_GPIO    3
+#define	RESET_PWM0    4
+#define	RESET_PWM1    5
+#define	RESET_PWM2    6
+#define	RESET_PWM3    7
+#define	RESET_PWM4    8
+#define	RESET_PWM5    9
+#define	RESET_PWM6    10
+#define	RESET_PWM7    11
+#define	RESET_PWM8    12
+#define	RESET_PWM9    13
+#define	RESET_PWM10   14
+#define	RESET_PWM11   15
+#define	RESET_PWM12   16
+#define	RESET_PWM13   17
+#define	RESET_PWM14   18
+#define	RESET_PWM15   19
+#define	RESET_PWM16   20
+#define	RESET_PWM17   21
+#define	RESET_PWM18   22
+#define	RESET_PWM19   23
+#define	RESET_SSP3    24
+#define	RESET_UART3   25
+#define	RESET_RTC     26
+#define	RESET_TWSI0   27
+#define	RESET_TIMERS1 28
+#define	RESET_AIB     29
+#define	RESET_TIMERS2 30
+#define	RESET_ONEWIRE 31
+#define	RESET_SSPA0   32
+#define	RESET_SSPA1   33
+#define	RESET_DRO     34
+#define	RESET_IR      35
+#define	RESET_TWSI1   36
+#define	RESET_TSEN    37
+#define	RESET_TWSI2   38
+#define	RESET_TWSI4   39
+#define	RESET_TWSI5   40
+#define	RESET_TWSI6   41
+#define	RESET_TWSI7   42
+#define	RESET_TWSI8   43
+#define	RESET_IPC_AP2AUD  44
+#define	RESET_UART4   45
+#define	RESET_UART5   46
+#define	RESET_UART6   47
+#define	RESET_UART7   48
+#define	RESET_UART8   49
+#define	RESET_UART9   50
+#define	RESET_CAN0    51
+
+/* MPMU */
+#define	RESET_WDT     52
+
+/* APMU */
+#define	RESET_JPG        53
+#define	RESET_CSI        54
+#define	RESET_CCIC2_PHY  55
+#define	RESET_CCIC3_PHY  56
+#define	RESET_ISP        57
+#define	RESET_ISP_AHB    58
+#define	RESET_ISP_CI     59
+#define	RESET_ISP_CPP    60
+#define	RESET_LCD        61
+#define	RESET_DSI_ESC    62
+#define	RESET_V2D        63
+#define	RESET_MIPI       64
+#define	RESET_LCD_SPI    65
+#define	RESET_LCD_SPI_BUS  66
+#define	RESET_LCD_SPI_HBUS 67
+#define	RESET_LCD_MCLK     68
+#define	RESET_CCIC_4X      69
+#define	RESET_CCIC1_PHY    70
+#define	RESET_SDH_AXI      71
+#define	RESET_SDH0         72
+#define	RESET_SDH1         73
+#define	RESET_USB_AXI      74
+#define	RESET_USBP1_AXI    75
+#define	RESET_USB3_0       76
+#define	RESET_QSPI         77
+#define	RESET_QSPI_BUS     78
+#define	RESET_DMA          79
+#define	RESET_AES          80
+#define	RESET_VPU          81
+#define	RESET_GPU          82
+#define	RESET_SDH2         83
+#define	RESET_MC           84
+#define	RESET_EM_AXI       85
+#define	RESET_EM           86
+#define	RESET_AUDIO_SYS    87
+#define	RESET_HDMI         88
+#define	RESET_PCIE0        89
+#define	RESET_PCIE1        90
+#define	RESET_PCIE2        91
+#define	RESET_EMAC0        92
+#define	RESET_EMAC1        93
+
+/* APBC2 */
+#define	RESET_SEC_UART1    94
+#define	RESET_SEC_SSP2     95
+#define	RESET_SEC_TWSI3    96
+#define	RESET_SEC_RTC      97
+#define	RESET_SEC_TIMERS0  98
+#define	RESET_SEC_KPC      99
+#define	RESET_SEC_GPIO     100
+#define	RESET_NUMBER       101
+
+#endif
Signature · 1 line
2.39.5
author
#3 lore raw

PATCH v2 2/4 riscv: reset: k1: Add reset driver

In reply to Huan Zhou

Add spacemit reset driver.

---
 drivers/reset/Kconfig             |   7 +
 drivers/reset/Makefile            |   1 +
 drivers/reset/reset-spacemit-k1.c | 548 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 556 insertions(+)
drivers/reset/Kconfig +7 -0
index fe5c1214f57a8b4d6f21b3a765bff813712ae3ff..9ee14a74211a5f1c23a35473a41044f7f2ebe61a 100644
@@ -235,4 +235,11 @@ config RESET_AT91
 	  This enables the Reset Controller driver support for Microchip/Atmel
 	  SoCs. Mainly used to expose assert/deassert methods to other drivers
 	  that require it.
+
+config RESET_SPACEMIT_K1
+	bool "Support for SPACEMIT's K1 Reset driver"
+	depends on DM_RESET
+	help
+	  Support for SPACEMIT's K1 Reset system. Basic Assert/Deassert
+	  is supported.
 endmenu
drivers/reset/Makefile +1 -0
index d99a78c9828b7f870acff8de75ebdcff59edc137..a69432bad2fb5980012e6fcc094a3ed669d9a378 100644
@@ -33,3 +33,4 @@ obj-$(CONFIG_RESET_ZYNQMP) += reset-zynqmp.o
 obj-$(CONFIG_RESET_DRA7) += reset-dra7.o
 obj-$(CONFIG_RESET_AT91) += reset-at91.o
 obj-$(CONFIG_$(PHASE_)RESET_JH7110) += reset-jh7110.o
+obj-$(CONFIG_RESET_SPACEMIT_K1) += reset-spacemit-k1.o
\ No newline at end of file
drivers/reset/reset-spacemit-k1.c new file +548 -0

548 lines not on this page · raw message

Signature · 1 line
2.39.5
Reviewed-by on v2 2/4
#4 lore raw

Re: [PATCH v2 2/4] riscv: reset: k1: Add reset driver

Quoted 8 lines · Huan Zhou

Add spacemit reset driver.

---
 drivers/reset/Kconfig             |   7 +
 drivers/reset/Makefile            |   1 +
 drivers/reset/reset-spacemit-k1.c | 548 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 556 insertions(+)
author
#5 lore raw

PATCH v2 3/4 riscv: dts: k1: add reset controller node in device tree

In reply to Huan Zhou

Add reset-controller in k1 device tree.

---
 arch/riscv/dts/k1.dtsi | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/riscv/dts/k1.dtsi +15 -0
index 514be453dbaf6713cdf4ad5a5d653488297ebb83..b3e3f81d4dfa6e64dd4a00625280e43b014a6915 100644
@@ -455,5 +455,20 @@
 			reg-io-width = <4>;
 			status = "reserved"; /* for TEE usage */
 		};
+
+		reset: reset-controller@d4050000 {
+			compatible = "spacemit,k1-reset";
+			reg = <0x0 0xd4050000 0x0 0x209c>,
+				<0x0 0xd4282800 0x0 0x400>,
+				<0x0 0xd4015000 0x0 0x1000>,
+				<0x0 0xd4090000 0x0 0x1000>,
+				<0x0 0xd4282c00 0x0 0x400>,
+				<0x0 0xd8440000 0x0 0x98>,
+				<0x0 0xc0000000 0x0 0x4280>,
+				<0x0 0xf0610000 0x0 0x20>;
+			reg-names = "mpmu", "apmu", "apbc", "apbs", "ciu", "dciu", "ddrc", "apbc2";
+			#reset-cells = <1>;
+			status = "disabled";
+		};
 	};
 };
\ No newline at end of file
Signature · 1 line
2.39.5
author
#7 lore raw

PATCH v2 4/4 Add reset config options for k1

In reply to Huan Zhou

Add RESET_SPACEMIT_K1 option in config

---
 arch/riscv/cpu/k1/Kconfig     | 1 +
 configs/bananapi-f3_defconfig | 1 +
 2 files changed, 2 insertions(+)
arch/riscv/cpu/k1/Kconfig +1 -0
index d9cd8dce96426bb4cbe9ff38385a4c66116fe341..14201df80f2c0bf304225ef6d8dc8e72ff508815 100644
@@ -13,6 +13,7 @@ config SPACEMIT_K1
 	imply RISCV_ACLINT if RISCV_MMODE
 	imply SPL_RISCV_ACLINT if SPL_RISCV_MMODE
 	imply CMD_CPU
+	imply DM_RESET
 	imply SPL_CPU
 	imply SPL_OPENSBI
 	imply SPL_LOAD_FIT
configs/bananapi-f3_defconfig +1 -0
index 0f12db3db848badda1fc7192aeb0190ac22a269d..7483f128baea9d8971efc9ed166aa042ec32d908 100644
@@ -18,3 +18,4 @@ CONFIG_HUSH_PARSER=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_NS16550=y
 CONFIG_SYS_NS16550_MEM32=y
+CONFIG_RESET_SPACEMIT_K1=y
Signature · 1 line
2.39.5