Skip to contentSkip to conversation

Add reset controller driver for ums512

PATCH In review Zhifeng Tang 2 participants 5 messages Jan 23, 2024 – Apr 11, 2024

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

v4 cover Add reset controller driver for ums512

From: "zhifeng.tang" <[email protected]>

In most of Sprd SOCs,The clock controller register block also contains reset bits for some of these peripherals,so reset controller and clock provider are combined together as a block, and put it under the driver/clk/.

Changes in v4:
- Add description why reset controller put it under the driver/clk/

Changes in v3:
- Fix the driver patch is overwritten by cover letter

Changes in v2:
- The binding file is combined into one patch

zhifeng.tang (3):
dt-bindings: reset: Add reset controller bindings for Unisoc's ums512
clk: sprd: Add reset controller driver for ums512
arm64: dts: sprd: Add reset controller driver for UMS512

 .../bindings/clock/sprd,ums512-clk.yaml       |   3 +
 arch/arm64/boot/dts/sprd/ums512.dtsi          |   9 +
 drivers/clk/sprd/Makefile                     |   1 +
 drivers/clk/sprd/common.c                     |   1 +
 drivers/clk/sprd/common.h                     |   2 +
 drivers/clk/sprd/reset.c                      |  78 ++++++
 drivers/clk/sprd/reset.h                      |  30 +++
 drivers/clk/sprd/ums512-clk.c                 | 240 ++++++++++++++++++
 include/dt-bindings/reset/sprd,ums512-reset.h | 203 +++++++++++++++
 9 files changed, 567 insertions(+)
 create mode 100644 drivers/clk/sprd/reset.c
 create mode 100644 drivers/clk/sprd/reset.h
 create mode 100644 include/dt-bindings/reset/sprd,ums512-reset.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH v4 1/3 dt-bindings: reset: Add reset controller bindings for Unisoc's ums512

From: "zhifeng.tang" <[email protected]>

In most of Sprd SOCs,The clock controller register block also contains reset bits for some of these peripherals,so reset controller and clock provider are combined together as a block, and put it under the driver/clk/.

---
 .../bindings/clock/sprd,ums512-clk.yaml       |   3 +
 include/dt-bindings/reset/sprd,ums512-reset.h | 203 ++++++++++++++++++
 2 files changed, 206 insertions(+)
 create mode 100644 include/dt-bindings/reset/sprd,ums512-reset.h
Documentation/devicetree/bindings/clock/sprd,ums512-clk.yaml +3 -0
index 43d2b6c31357..6b0892d637fe 100644
@@ -34,6 +34,9 @@ properties:
   "#clock-cells":
     const: 1
 
+  "#reset-cells":
+    const: 1
+
   clocks:
     minItems: 1
     maxItems: 4
include/dt-bindings/reset/sprd,ums512-reset.h new file +203 -0

203 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v4 2/3 clk: sprd: Add reset controller driver for ums512

In reply to Zhifeng Tang

From: "zhifeng.tang" <[email protected]>

In most of Sprd SOCs,The clock controller register block also contains reset bits for some of these peripherals,so reset controller and clock provider are combined together as a block, and put it under the driver/clk/.

---
 drivers/clk/sprd/Makefile     |   1 +
 drivers/clk/sprd/common.c     |   1 +
 drivers/clk/sprd/common.h     |   2 +
 drivers/clk/sprd/reset.c      |  78 +++++++++++
 drivers/clk/sprd/reset.h      |  30 +++++
 drivers/clk/sprd/ums512-clk.c | 240 ++++++++++++++++++++++++++++++++++
 6 files changed, 352 insertions(+)
 create mode 100644 drivers/clk/sprd/reset.c
 create mode 100644 drivers/clk/sprd/reset.h
drivers/clk/sprd/Makefile +1 -0
index f25b2c3904fb..72f6ecf8291e 100644
@@ -7,6 +7,7 @@ clk-sprd-y	+= mux.o
 clk-sprd-y	+= div.o
 clk-sprd-y	+= composite.o
 clk-sprd-y	+= pll.o
+clk-sprd-y	+= reset.o
 
 ## SoC support
 obj-$(CONFIG_SPRD_SC9860_CLK)	+= sc9860-clk.o
drivers/clk/sprd/common.c +1 -0
index 762f0961f17f..4ddec6348447 100644
@@ -75,6 +75,7 @@ int sprd_clk_regmap_init(struct platform_device *pdev,
 	}
 
 	sprd_clk_set_regmap(desc, regmap);
+	platform_set_drvdata(pdev, regmap);
 
 	return 0;
 }
drivers/clk/sprd/common.h +2 -0
index 1d077b39cef6..1ac39af68497 100644
@@ -24,6 +24,8 @@ struct sprd_clk_desc {
 	struct sprd_clk_common		**clk_clks;
 	unsigned long			num_clk_clks;
 	struct clk_hw_onecell_data      *hw_clks;
+	struct sprd_reset_map		*resets;
+	unsigned long			num_resets;
 };
 
 static inline struct sprd_clk_common *
drivers/clk/sprd/reset.c new file +78 -0

78 lines not on this page · raw message

drivers/clk/sprd/reset.h new file +30 -0
new file mode 100644
index 000000000000..155330b42775
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+//
+// Spreadtrum reset clock driver
+//
+// Copyright (C) 2022 Spreadtrum, Inc.
+// Author: Zhifeng Tang <[email protected]>
+
+#ifndef _SPRD_RESET_H_
+#define _SPRD_RESET_H_
+
+#include <linux/reset-controller.h>
+#include <linux/spinlock.h>
+
+struct sprd_reset_map {
+	u32	reg;
+	u32	mask;
+	bool	sc;
+	u32	sc_offset;
+};
+
+struct sprd_reset {
+	struct reset_controller_dev	rcdev;
+	const struct sprd_reset_map	*reset_map;
+	struct regmap			*regmap;
+	spinlock_t			lock;
+};
+
+extern const struct reset_control_ops sprd_reset_ops;
+
+#endif /* _SPRD_RESET_H_ */
drivers/clk/sprd/ums512-clk.c +240 -0

344 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

PATCH v4 3/3 arm64: dts: sprd: Add reset controller driver for UMS512

In reply to Zhifeng Tang

From: "zhifeng.tang" <[email protected]>

In most of Sprd SOCs,The clock controller register block also contains reset bits for some of these peripherals,so reset controller and clock provider are combined together as a block, and put it under the driver/clk/.

---
 arch/arm64/boot/dts/sprd/ums512.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/sprd/ums512.dtsi +9 -0
index 024be594c47d..08d0adf6624c 100644
@@ -7,6 +7,7 @@
 
 #include <dt-bindings/clock/sprd,ums512-clk.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/reset/sprd,ums512-reset.h>
 
 / {
 	interrupt-parent = <&gic>;
@@ -182,6 +183,7 @@
 				clocks = <&ext_26m>;
 				clock-names = "ext-26m";
 				#clock-cells = <1>;
+				#reset-cells = <1>;
 			};
 		};
 
@@ -316,6 +318,7 @@
 				clocks = <&ext_26m>;
 				clock-names = "ext-26m";
 				#clock-cells = <1>;
+				#reset-cells = <1>;
 			};
 		};
 
@@ -333,6 +336,7 @@
 				clocks = <&ext_26m>;
 				clock-names = "ext-26m";
 				#clock-cells = <1>;
+				#reset-cells = <1>;
 			};
 		};
 
@@ -348,6 +352,7 @@
 				compatible = "sprd,ums512-audcpapb-gate";
 				reg = <0x0 0x300>;
 				#clock-cells = <1>;
+				#reset-cells = <1>;
 			};
 		};
 
@@ -363,6 +368,7 @@
 				compatible = "sprd,ums512-audcpahb-gate";
 				reg = <0x0 0x300>;
 				#clock-cells = <1>;
+				#reset-cells = <1>;
 			};
 		};
 
@@ -380,6 +386,7 @@
 				clock-names = "ext-26m";
 				reg = <0x0 0x100>;
 				#clock-cells = <1>;
+				#reset-cells = <1>;
 			};
 		};
 
@@ -401,6 +408,7 @@
 				compatible = "sprd,ums512-mm-gate-clk";
 				reg = <0x0 0x3000>;
 				#clock-cells = <1>;
+				#reset-cells = <1>;
 			};
 		};
 
@@ -416,6 +424,7 @@
 				compatible = "sprd,ums512-apapb-gate";
 				reg = <0x0 0x3000>;
 				#clock-cells = <1>;
+				#reset-cells = <1>;
 			};
 		};
 
Signature · 1 line
2.17.1
maintainer
#4 lore raw
In reply to Zhifeng Tang

Quoting Zhifeng Tang (2024-01-22 18:56:10)

Quoted 9 lines

From: "zhifeng.tang" <[email protected]>

In most of Sprd SOCs,The clock controller register block also contains reset bits for some of these peripherals,so reset controller and clock provider are combined together as a block, and put it under the driver/clk/.

Changes in v4:
- Add description why reset controller put it under the driver/clk/

Please use an auxiliary device and put the code almost entirely under drivers/reset/. You can still have the data tables in the clk driver if you want, but I don't see why an auxiliary device can't be used.