Skip to contentSkip to conversation

Add StarFive JHB100 syscon modules

PATCH In review Changhuang Liang 2 participants 7 messages Oct 10 – Nov 17

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

v6 cover Add StarFive JHB100 syscon modules

StarFive JHB100 has many syscon modules, as listed below:
- pcieep0_ecsr_syscon (PCIe endpoint 0 externel syscon)
- pcieep1_ecsr_syscon
- host0_syscon (Host0 syscon)
- host1_syscon
- husb0_syscon (Host USB 0 syscon)
- husb1_syscon
- husbd0_syscon (Host USB device 0 syscon)
- husbd1_syscon
- husbcmn_syscon (Host USB common syscon)
- gpu0_syscon (GPU0 syscon)
- gpu1_syscon
- b2h_syscon (BMC to Host syscon)
- h2b_syscon (Host to BMC syscon)
- vout_syscon (Video output syscon)
- pcierp_ecsr_syscon (PCIe root port externel syscon)
- pcierp_syscon (PCIe root port syscon)
- usb_syscon
- npu_syscon
- per0_syscon (Peripheral 0 syscon)
- per1_syscon
- per2_syscon
- per3_syscon
- sys0_syscon (System 0 syscon)
- sys1_syscon
- sys2_syscon
- strap_syscon
- sfc0_filter_syscon (SFC0 filter syscon)
- sfc1_filter_syscon
- sfc2_filter_syscon

Some syscon modules contain PLL, reset. This series adds related drivers for PLL and reset.

This series depends on the series:
[1]: https://lore.kernel.org/all/[email protected]/

changes since v5:
- Remove PATCH 1/7/8 in v5

PATCH 1 (in v6):
- Split a PLL into 3 clock modules: VCO, POSTDIV, and OUT.
- Implement the PLL registration as a generic interface, provided for specific PLLs to call.
- Since the PLL enable/disable function is optional, the new version decides to remove this implementation and keep the PLL always on. (This may differ from the email reply in v5.)
- Remove the debugfs-related implementation.
- Add a VCO operating frequency range limit for the PLL.
- Stop recording the PLL frequency, and instead calculate it from the multiplier factor.

PATCH 2&3(in v6):
- Make corresponding adjustments due to the changes in PATCH 1.

PATCH 5(in v6):
Make minor adjustments due to the changes in series [1], with no functional changes:
- select RESET_STARFIVE_COMMON ==> select RESET_STARFIVE_JH71X0

v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
V1: https://lore.kernel.org/all/[email protected]/

Changhuang Liang (5):
clk: starfive: Add system-0 domain PLL clock driver
clk: starfive: Add Peripheral-0 domain PLL clock driver
clk: starfive: Add Peripheral-1 domain PLL clock driver
reset: starfive: Introduce active_low
reset: starfive: Add syscon reset driver support

 drivers/clk/starfive/Kconfig                  |  28 ++
 drivers/clk/starfive/Makefile                 |   3 +
 .../starfive/clk-starfive-jhb100-per-pll.c    |  95 ++++
 .../clk/starfive/clk-starfive-jhb100-pll.c    | 425 ++++++++++++++++++
 .../clk/starfive/clk-starfive-jhb100-pll.h    |  63 +++
 .../starfive/clk-starfive-jhb100-sys0-pll.c   |  69 +++
 drivers/reset/starfive/Kconfig                |   9 +
 drivers/reset/starfive/Makefile               |   1 +
 .../reset/starfive/reset-starfive-jh71x0.c    |   3 +-
 .../reset/starfive/reset-starfive-jh71x0.h    |   6 +
 .../starfive/reset-starfive-jhb100-syscon.c   |  61 +++
 11 files changed, 762 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/starfive/clk-starfive-jhb100-per-pll.c
 create mode 100644 drivers/clk/starfive/clk-starfive-jhb100-pll.c
 create mode 100644 drivers/clk/starfive/clk-starfive-jhb100-pll.h
 create mode 100644 drivers/clk/starfive/clk-starfive-jhb100-sys0-pll.c
 create mode 100644 drivers/reset/starfive/reset-starfive-jhb100-syscon.c

--
2.25.1

#1 lore raw

PATCH v6 1/5 clk: starfive: Add system-0 domain PLL clock driver

Add system-0 domain PLL clock driver for StarFive JHB100 SoC.

The PLL itself is a building block shared by several system controllers of the SoC, so it is implemented as a library. Each PLL is described with three clocks matching the hardware topology: the VCO, a power-of-two post divider and the output selecting one of them.

The VCO multipliers are either taken from a table or computed from the requested rate. Rates are always derived from the actual parent rate.

The system-0 PLLs are registered by a platform driver bound to the device created by the owner of the sys0 system controller.

---
 drivers/clk/starfive/Kconfig                  |  16 +
 drivers/clk/starfive/Makefile                 |   2 +
 .../clk/starfive/clk-starfive-jhb100-pll.c    | 425 ++++++++++++++++++
 .../clk/starfive/clk-starfive-jhb100-pll.h    |  63 +++
 .../starfive/clk-starfive-jhb100-sys0-pll.c   |  69 +++
 5 files changed, 575 insertions(+)
 create mode 100644 drivers/clk/starfive/clk-starfive-jhb100-pll.c
 create mode 100644 drivers/clk/starfive/clk-starfive-jhb100-pll.h
 create mode 100644 drivers/clk/starfive/clk-starfive-jhb100-sys0-pll.c
drivers/clk/starfive/Kconfig +16 -0
index 1c9dd5d47cb8..4a7c67445f4c 100644
@@ -113,6 +113,9 @@ config CLK_STARFIVE_JHB100_PER3
 	  Say yes here to support the peripheral-3 clock controller
 	  on the StarFive JHB100 SoC.
 
+config CLK_STARFIVE_JHB100_PLL
+	bool
+
 config CLK_STARFIVE_JHB100_SYS0
 	bool "StarFive JHB100 system-0 clock support"
 	depends on ARCH_STARFIVE || COMPILE_TEST
@@ -123,6 +126,19 @@ config CLK_STARFIVE_JHB100_SYS0
 	  Say yes here to support the system-0 clock controller on the
 	  StarFive JHB100 SoC.
 
+config CLK_STARFIVE_JHB100_SYS0_PLL
+	bool "StarFive JHB100 system-0 PLL clock support"
+	depends on ARCH_STARFIVE || COMPILE_TEST
+	depends on STARFIVE_JHB100_SOCINFO
+	select CLK_STARFIVE_JHB100_PLL
+	select MFD_SYSCON
+	default ARCH_STARFIVE
+	help
+	  Say yes here to support the PLL2 to PLL5 clock generators found
+	  in the system-0 system controller of the StarFive JHB100 SoC.
+	  The device is instantiated by the JHB100 SoC information driver,
+	  which owns the system-0 system controller.
+
 config CLK_STARFIVE_JHB100_SYS1
 	bool "StarFive JHB100 system-1 clock support"
 	depends on ARCH_STARFIVE || COMPILE_TEST
drivers/clk/starfive/Makefile +2 -0
index 2c4554c2e70e..3a8f75c55c96 100644
@@ -15,6 +15,8 @@ obj-$(CONFIG_CLK_STARFIVE_JHB100_PER0)		+= clk-starfive-jhb100-per0.o
 obj-$(CONFIG_CLK_STARFIVE_JHB100_PER1)		+= clk-starfive-jhb100-per1.o
 obj-$(CONFIG_CLK_STARFIVE_JHB100_PER2)		+= clk-starfive-jhb100-per2.o
 obj-$(CONFIG_CLK_STARFIVE_JHB100_PER3)		+= clk-starfive-jhb100-per3.o
+obj-$(CONFIG_CLK_STARFIVE_JHB100_PLL)		+= clk-starfive-jhb100-pll.o
 obj-$(CONFIG_CLK_STARFIVE_JHB100_SYS0)		+= clk-starfive-jhb100-sys0.o
+obj-$(CONFIG_CLK_STARFIVE_JHB100_SYS0_PLL)	+= clk-starfive-jhb100-sys0-pll.o
 obj-$(CONFIG_CLK_STARFIVE_JHB100_SYS1)		+= clk-starfive-jhb100-sys1.o
 obj-$(CONFIG_CLK_STARFIVE_JHB100_SYS2)		+= clk-starfive-jhb100-sys2.o
drivers/clk/starfive/clk-starfive-jhb100-pll.c new file +425 -0

425 lines not on this page · raw message

drivers/clk/starfive/clk-starfive-jhb100-pll.h new file +63 -0

63 lines not on this page · raw message

drivers/clk/starfive/clk-starfive-jhb100-sys0-pll.c new file +69 -0

69 lines not on this page · raw message

Signature · 7 lines
2.25.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#2 lore raw

PATCH v6 2/5 clk: starfive: Add Peripheral-0 domain PLL clock driver

In reply to Changhuang Liang

Add Peripheral-0 domain PLL clock driver support for StarFive JHB100 SoC. It binds to the per0 system controller node and registers PLL6 using the JHB100 PLL library.

---
 drivers/clk/starfive/Kconfig                  | 12 +++
 drivers/clk/starfive/Makefile                 |  1 +
 .../starfive/clk-starfive-jhb100-per-pll.c    | 76 +++++++++++++++++++
 3 files changed, 89 insertions(+)
 create mode 100644 drivers/clk/starfive/clk-starfive-jhb100-per-pll.c
drivers/clk/starfive/Kconfig +12 -0
index 4a7c67445f4c..00c46f5ec976 100644
@@ -113,6 +113,18 @@ config CLK_STARFIVE_JHB100_PER3
 	  Say yes here to support the peripheral-3 clock controller
 	  on the StarFive JHB100 SoC.
 
+config CLK_STARFIVE_JHB100_PER_PLL
+	bool "StarFive JHB100 peripheral PLL clock support"
+	depends on ARCH_STARFIVE || COMPILE_TEST
+	select CLK_STARFIVE_JHB100_PLL
+	select MFD_SYSCON
+	default ARCH_STARFIVE
+	help
+	  Say yes here to support the PLL6 clock generator found in the
+	  peripheral-0 system controller of the StarFive JHB100 SoC. It
+	  provides the parent clock of the peripheral-0 clock
+	  controller.
+
 config CLK_STARFIVE_JHB100_PLL
 	bool
 
drivers/clk/starfive/Makefile +1 -0
index 3a8f75c55c96..e31ded58bd6f 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_CLK_STARFIVE_JHB100_PER0)		+= clk-starfive-jhb100-per0.o
 obj-$(CONFIG_CLK_STARFIVE_JHB100_PER1)		+= clk-starfive-jhb100-per1.o
 obj-$(CONFIG_CLK_STARFIVE_JHB100_PER2)		+= clk-starfive-jhb100-per2.o
 obj-$(CONFIG_CLK_STARFIVE_JHB100_PER3)		+= clk-starfive-jhb100-per3.o
+obj-$(CONFIG_CLK_STARFIVE_JHB100_PER_PLL)	+= clk-starfive-jhb100-per-pll.o
 obj-$(CONFIG_CLK_STARFIVE_JHB100_PLL)		+= clk-starfive-jhb100-pll.o
 obj-$(CONFIG_CLK_STARFIVE_JHB100_SYS0)		+= clk-starfive-jhb100-sys0.o
 obj-$(CONFIG_CLK_STARFIVE_JHB100_SYS0_PLL)	+= clk-starfive-jhb100-sys0-pll.o
drivers/clk/starfive/clk-starfive-jhb100-per-pll.c new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw

PATCH v6 3/5 clk: starfive: Add Peripheral-1 domain PLL clock driver

In reply to Changhuang Liang

Add Peripheral-1 domain PLL clock driver support for StarFive JHB100 SoC. The peripheral PLL driver now also binds to the per1 system controller node and registers PLL7 using the JHB100 PLL library.

---
 drivers/clk/starfive/Kconfig                  |  8 ++++----
 .../starfive/clk-starfive-jhb100-per-pll.c    | 19 +++++++++++++++++++
 2 files changed, 23 insertions(+), 4 deletions(-)
drivers/clk/starfive/Kconfig +4 -4
index 00c46f5ec976..1bf64f1b6c58 100644
@@ -120,10 +120,10 @@ config CLK_STARFIVE_JHB100_PER_PLL
 	select MFD_SYSCON
 	default ARCH_STARFIVE
 	help
-	  Say yes here to support the PLL6 clock generator found in the
-	  peripheral-0 system controller of the StarFive JHB100 SoC. It
-	  provides the parent clock of the peripheral-0 clock
-	  controller.
+	  Say yes here to support the PLL6 and PLL7 clock generators found
+	  in the peripheral-0 and peripheral-1 system controllers of the
+	  StarFive JHB100 SoC. They provide the parent clocks of the
+	  peripheral-0 and peripheral-1 clock controllers.
 
 config CLK_STARFIVE_JHB100_PLL
 	bool
drivers/clk/starfive/clk-starfive-jhb100-per-pll.c +19 -0
index d38116f16935..ef01f7d1d5f6 100644
@@ -19,6 +19,7 @@
 #include "clk-starfive-jhb100-pll.h"
 
 #define JHB100_PLL6_OFFSET		0x00
+#define JHB100_PLL7_OFFSET		0x40
 
 struct jhb100_per_pll_data {
 	const struct jhb100_pll_info *info;
@@ -39,6 +40,20 @@ static const struct jhb100_per_pll_data jhb100_per0_pll_data = {
 	.num = ARRAY_SIZE(jhb100_per0_pll_info),
 };
 
+static const struct jhb100_pll_mult jhb100_pll7_mults[] = {
+	{ .fbdiv = 156, .frac = 0, .refdiv = 1 },
+};
+
+static const struct jhb100_pll_info jhb100_per1_pll_info[] = {
+	JHB100_PLL(JHB100_PER1PLL_PLL7_OUT, "pll7", JHB100_PLL7_OFFSET,
+		   jhb100_pll7_mults, ARRAY_SIZE(jhb100_pll7_mults)),
+};
+
+static const struct jhb100_per_pll_data jhb100_per1_pll_data = {
+	.info = jhb100_per1_pll_info,
+	.num = ARRAY_SIZE(jhb100_per1_pll_info),
+};
+
 static int jhb100_per_pll_probe(struct platform_device *pdev)
 {
 	const struct jhb100_per_pll_data *data;
@@ -62,6 +77,10 @@ static const struct of_device_id jhb100_per_pll_match[] = {
 		.compatible = "starfive,jhb100-per0-syscon",
 		.data = &jhb100_per0_pll_data,
 	},
+	{
+		.compatible = "starfive,jhb100-per1-syscon",
+		.data = &jhb100_per1_pll_data,
+	},
 	{ /* sentinel */ }
 };
 
Signature · 7 lines
2.25.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#4 lore raw

PATCH v6 4/5 reset: starfive: Introduce active_low

In reply to Changhuang Liang

The JHB100 SoC supports inverted operations for reset assertion/deassertion, introducing an active_low field to distinguish between different operation logics.

---
 drivers/reset/starfive/reset-starfive-jh71x0.c | 3 ++-
 drivers/reset/starfive/reset-starfive-jh71x0.h | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/reset/starfive/reset-starfive-jh71x0.c +2 -1
index fd1c755a0017..f48959b66f7c 100644
@@ -52,6 +52,7 @@ static int jh71x0_reset_update(struct reset_controller_dev *rcdev,
 			       unsigned long id, bool assert)
 {
 	struct jh71x0_reset *data = jh71x0_reset_from(rcdev);
+	bool active_low = data->info && data->info->active_low;
 	unsigned long offset, flags;
 	void __iomem *reg_assert;
 	void __iomem *reg_status;
@@ -76,7 +77,7 @@ static int jh71x0_reset_update(struct reset_controller_dev *rcdev,
 	spin_lock_irqsave(&data->lock, flags);
 
 	value = readl(reg_assert);
-	if (assert)
+	if (assert != active_low)
 		value |= mask;
 	else
 		value &= ~mask;
drivers/reset/starfive/reset-starfive-jh71x0.h +6 -0
index 36f198139602..7a967eeb3181 100644
@@ -15,6 +15,12 @@ struct jh71x0_reset_info {
 	unsigned int nr_resets;
 	unsigned int assert_offset;
 	unsigned int status_offset;
+
+	/*
+	 * If true, the reset is asserted by clearing the bit and deasserted
+	 * by setting it. If false, it is the other way around.
+	 */
+	bool active_low;
 	bool discontiguous;
 	const struct jh71x0_reset_map *map;
 };
Signature · 7 lines
2.25.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#5 lore raw

PATCH v6 5/5 reset: starfive: Add syscon reset driver support

In reply to Changhuang Liang

Add syscon reset driver for JHB100 SoC.

---
 drivers/reset/starfive/Kconfig                |  9 +++
 drivers/reset/starfive/Makefile               |  1 +
 .../starfive/reset-starfive-jhb100-syscon.c   | 61 +++++++++++++++++++
 3 files changed, 71 insertions(+)
 create mode 100644 drivers/reset/starfive/reset-starfive-jhb100-syscon.c
drivers/reset/starfive/Kconfig +9 -0
index 84baefbaee14..be948b855c79 100644
@@ -28,3 +28,12 @@ config RESET_STARFIVE_JHB100
 	default ARCH_STARFIVE
 	help
 	  This enables the reset controller driver for the StarFive JHB100 SoC.
+
+config RESET_STARFIVE_JHB100_SYSCON
+	tristate "StarFive JHB100 SYSCON Reset Driver"
+	depends on ARCH_STARFIVE || COMPILE_TEST
+	select RESET_STARFIVE_JH71X0
+	default m if ARCH_STARFIVE
+	help
+	  This enables the SYSCON reset controller driver for the StarFive
+	  JHB100 SoC.
drivers/reset/starfive/Makefile +1 -0
index d781103355d3..f568938d0219 100644
@@ -4,3 +4,4 @@ obj-$(CONFIG_RESET_STARFIVE_JH71X0)		+= reset-starfive-jh71x0.o
 obj-$(CONFIG_RESET_STARFIVE_JH7100)		+= reset-starfive-jh7100.o
 obj-$(CONFIG_RESET_STARFIVE_JH7110)		+= reset-starfive-jh7110.o
 obj-$(CONFIG_RESET_STARFIVE_JHB100)		+= reset-starfive-jhb100.o
+obj-$(CONFIG_RESET_STARFIVE_JHB100_SYSCON)	+= reset-starfive-jhb100-syscon.o
drivers/reset/starfive/reset-starfive-jhb100-syscon.c new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
2.25.1
#6 lore raw
In reply to Changhuang Liang
Quoted 31 lines · Changhuang Liang

StarFive JHB100 has many syscon modules, as listed below:
- pcieep0_ecsr_syscon (PCIe endpoint 0 externel syscon)
- pcieep1_ecsr_syscon
- host0_syscon (Host0 syscon)
- host1_syscon
- husb0_syscon (Host USB 0 syscon)
- husb1_syscon
- husbd0_syscon (Host USB device 0 syscon)
- husbd1_syscon
- husbcmn_syscon (Host USB common syscon)
- gpu0_syscon (GPU0 syscon)
- gpu1_syscon
- b2h_syscon (BMC to Host syscon)
- h2b_syscon (Host to BMC syscon)
- vout_syscon (Video output syscon)
- pcierp_ecsr_syscon (PCIe root port externel syscon)
- pcierp_syscon (PCIe root port syscon)
- usb_syscon
- npu_syscon
- per0_syscon (Peripheral 0 syscon)
- per1_syscon
- per2_syscon
- per3_syscon
- sys0_syscon (System 0 syscon)
- sys1_syscon
- sys2_syscon
- strap_syscon
- sfc0_filter_syscon (SFC0 filter syscon)
- sfc1_filter_syscon
- sfc2_filter_syscon

Quoted 5 lines

Some syscon modules contain PLL, reset. This series adds related drivers for PLL and reset.

This series depends on the series:
[1]: https://lore.kernel.org/all/[email protected]/

There is still work going this dependency, on things you depend on. Please re-post when things settle, taking into account feedback on this dependency.

If you can use b4 pre-requisite to mark your dependencies, it makes our life simpler as it help automation pick it up. Thanks

https://b4.docs.kernel.org/en/latest/contributor/prep.html#working-with-series-dependencies

Signature · 1 line
Jerome