Skip to contentSkip to conversation

clk/resets: baikal-t1: Add DDR/PCIe resets and xGMAC/SATA fixes

PATCH Superseded Serge Semin 4 participants 14 messages Jun 10, 2022 – Jun 20, 2022

Subsystems (5)

v4 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v4 cover clk/resets: baikal-t1: Add DDR/PCIe resets and xGMAC/SATA fixes

Short summary regarding this patchset. The series starts from fixing a wrong semantic of the device managed optional exclusive bulk reset control getter. Then we suggest a fix of the clocks glitching cause by the Renesas 5P49V6901 chip in some circumstances. Afterwards a few more modifications are introduced to finally finish the Baikal-T1 CCU unit support up and prepare the code before adding the Baikal-T1 PCIe/xGMAC support. First of all it turned out I specified wrong DW xGMAC PTP reference clock divider in my initial patches. It must be 8, not 10. Secondly I was wrong to add a joint xGMAC Ref and PTP clock instead of having them separately defined. The SoC manual describes these clocks as separate fixed clock wrappers. Finally in order to close the SoC clock/reset support up we need to add the DDR and PCIe interfaces reset controls support. It's done in two steps. First I've moved the reset-controls-related code into a dedicated module. Then the DDR/PCIe reset-control functionality is added. As the series finalization we've decided to convert the Baikal-T1 clock/reset source drivers to mainly being the platform device driver and pre-initialize the basic clocks only at the early kernel boot stages.

Changelog v2:
- Resubmit the series with adding @Philipp to the list of the recipients.

Changelog v3:
- No comments. Just resend the series.
- Rebased from v5.17 onto v5.18-rc3.

Changelog v4:
- Completely split the CCU Dividers and Resets functionality up. (@Stephen)
- Add a new fixes patch: "clk: baikal-t1: Actually enable SATA internal ref clock".
- Add a new fixes patch: "reset: Fix devm bulk optional exclusive control getter".
- Add a new fixes patch: "clk: vc5: Fix 5P49V6901 outputs disabling when enabling FOD".
- Add a new feagure patch: "clk: baikal-t1: Convert to platform device driver".
- Change the internal clock ID to the XGMAC-referred name.
- Rebase onto the kernel v5.18.

Serge Semin (8):
reset: Fix devm bulk optional exclusive control getter
clk: vc5: Fix 5P49V6901 outputs disabling when enabling FOD
clk: baikal-t1: Fix invalid xGMAC PTP clock divider
clk: baikal-t1: Add shared xGMAC ref/ptp clocks internal parent
clk: baikal-t1: Add SATA internal ref clock buffer
clk: baikal-t1: Move reset-controls code into a dedicated module
clk: baikal-t1: Add DDR/PCIe directly controlled resets support
clk: baikal-t1: Convert to platform device driver

 drivers/clk/baikal-t1/Kconfig       |  12 +-
 drivers/clk/baikal-t1/Makefile      |   1 +
 drivers/clk/baikal-t1/ccu-div.c     |  84 +++++++--
 drivers/clk/baikal-t1/ccu-div.h     |  17 +-
 drivers/clk/baikal-t1/ccu-pll.h     |   8 +
 drivers/clk/baikal-t1/ccu-rst.c     |  99 ++++++++++
 drivers/clk/baikal-t1/ccu-rst.h     |  79 ++++++++
 drivers/clk/baikal-t1/clk-ccu-div.c | 272 +++++++++++++++++-----------
 drivers/clk/baikal-t1/clk-ccu-pll.c | 128 ++++++++++---
 drivers/clk/baikal-t1/clk-ccu-rst.c | 257 ++++++++++++++++++++++++++
 drivers/clk/clk-versaclock5.c       |   2 +-
 include/dt-bindings/reset/bt1-ccu.h |   9 +
 include/linux/reset.h               |   2 +-
 13 files changed, 814 insertions(+), 156 deletions(-)
 create mode 100644 drivers/clk/baikal-t1/ccu-rst.c
 create mode 100644 drivers/clk/baikal-t1/ccu-rst.h
 create mode 100644 drivers/clk/baikal-t1/clk-ccu-rst.c
Signature · 1 line
2.35.1
#1 lore raw

PATCH v4 1/8 reset: Fix devm bulk optional exclusive control getter

Most likely due to copy-paste mistake the device managed version of the denoted reset control getter has been implemented with invalid semantic, which can be immediately spotted by having "WARN_ON(shared && acquired)" warning in the system log as soon as the method is called. Anyway let's fix it by altering the boolean arguments passed to the __devm_reset_control_bulk_get() method from
- shared = true, optional = false, acquired = true
to
+ shared = false, optional = true, acquired = true
That's what they were supposed to be in the first place (see the non-devm version of the same method: reset_control_bulk_get_optional_exclusive()).

Fixes 48d71395896d ("reset: Add reset_control_bulk API")

---

Changelog v4:
- This is a new patch added on v4 lap of the series.

---
 include/linux/reset.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/reset.h +1 -1
index 8a21b5756c3e..514ddf003efc 100644
@@ -731,7 +731,7 @@ static inline int __must_check
 devm_reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs,
 					       struct reset_control_bulk_data *rstcs)
 {
-	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, true, false, true);
+	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, true);
 }
 
 /**
Signature · 1 line
2.35.1
#2 lore raw

PATCH v4 2/8 clk: vc5: Fix 5P49V6901 outputs disabling when enabling FOD

In reply to Serge Semin

We have discovered random glitches during the system boot up procedure. The problem investigation led us to the weird outcomes: when none of the Renesas 5P49V6901 ports are explicitly enabled by the kernel driver, the glitches disappeared. It was a mystery since the SoC external clock domains were fed with different 5P49V6901 outputs. The driver code didn't seem like bogus either. We almost despaired to find out a root cause when the solution was found for a more modern revision of the chip. It turned out the 5P49V6901 clock generator stopped its output for a short period of time during the VC5_OUT_DIV_CONTROL register writing. The same problem has was found for the 5P49V6965 revision of the chip and the was successfully fixed in commit fc336ae622df ("clk: vc5: fix output disabling when enabling a FOD") by enabling the "bypass_sync" flag hidden inside "Unused Factory Reserved Register". Even though the 5P49V6901 registers description and programming guide doesn't provide any intel regarding that flag, setting it up anyway in the officially unused register completely eliminated the denoted glitches. Thus let's activate the functionality submitted in commit fc336ae622df ("clk: vc5: fix output disabling when enabling a FOD") for the Renesas 5P49V6901 chip too in order to remove the ports implicit inter-dependency.

Fixes dbf6b16f5683 ("clk: vc5: Add support for IDT VersaClock 5P49V6901")

---

Changelog v4:
- This is a new patch added on v4 lap of the series.

---
 drivers/clk/clk-versaclock5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-versaclock5.c +1 -1
index e7be3e54b9be..03cfef494b49 100644
@@ -1204,7 +1204,7 @@ static const struct vc5_chip_info idt_5p49v6901_info = {
 	.model = IDT_VC6_5P49V6901,
 	.clk_fod_cnt = 4,
 	.clk_out_cnt = 5,
-	.flags = VC5_HAS_PFD_FREQ_DBL,
+	.flags = VC5_HAS_PFD_FREQ_DBL | VC5_HAS_BYPASS_SYNC_BIT,
 };
 
 static const struct vc5_chip_info idt_5p49v6965_info = {
Signature · 1 line
2.35.1
#3 lore raw

Re: [PATCH v4 2/8] clk: vc5: Fix 5P49V6901 outputs disabling when enabling FOD

Quoted 10 lines · Serge Semin

We have discovered random glitches during the system boot up procedure. The problem investigation led us to the weird outcomes: when none of the Renesas 5P49V6901 ports are explicitly enabled by the kernel driver, the glitches disappeared. It was a mystery since the SoC external clock domains were fed with different 5P49V6901 outputs. The driver code didn't seem like bogus either. We almost despaired to find out a root cause when the solution was found for a more modern revision of the chip. It turned out the 5P49V6901 clock generator stopped its output for a short period of time during the VC5_OUT_DIV_CONTROL register writing. The same problem has was found for the 5P49V6965 revision of the chip and the was successfully

s/was found/been found/, s/the was/that was/?

Quoted 10 lines

fixed in commit fc336ae622df ("clk: vc5: fix output disabling when enabling a FOD") by enabling the "bypass_sync" flag hidden inside "Unused Factory Reserved Register". Even though the 5P49V6901 registers description and programming guide doesn't provide any intel regarding that flag, setting it up anyway in the officially unused register completely eliminated the denoted glitches. Thus let's activate the functionality submitted in commit fc336ae622df ("clk: vc5: fix output disabling when enabling a FOD") for the Renesas 5P49V6901 chip too in order to remove the ports implicit inter-dependency.

Quoted 2 lines
Fixes dbf6b16f5683 ("clk: vc5: Add support for IDT VersaClock 5P49V6901")

[...]

MBR, Sergey

#4 lore raw

Re: [PATCH v4 2/8] clk: vc5: Fix 5P49V6901 outputs disabling when enabling FOD

Quoted 14 lines · Sergey Shtylyov
Quoted 10 lines · Serge Semin

We have discovered random glitches during the system boot up procedure. The problem investigation led us to the weird outcomes: when none of the Renesas 5P49V6901 ports are explicitly enabled by the kernel driver, the glitches disappeared. It was a mystery since the SoC external clock domains were fed with different 5P49V6901 outputs. The driver code didn't seem like bogus either. We almost despaired to find out a root cause when the solution was found for a more modern revision of the chip. It turned out the 5P49V6901 clock generator stopped its output for a short period of time during the VC5_OUT_DIV_CONTROL register writing. The same problem has was found for the 5P49V6965 revision of the chip and the was successfully

Quoted 1 line

s/was found/been found/, s/the was/that was/?

Right. Thanks.)

-Sergey

Quoted 17 lines
Quoted 11 lines

fixed in commit fc336ae622df ("clk: vc5: fix output disabling when enabling a FOD") by enabling the "bypass_sync" flag hidden inside "Unused Factory Reserved Register". Even though the 5P49V6901 registers description and programming guide doesn't provide any intel regarding that flag, setting it up anyway in the officially unused register completely eliminated the denoted glitches. Thus let's activate the functionality submitted in commit fc336ae622df ("clk: vc5: fix output disabling when enabling a FOD") for the Renesas 5P49V6901 chip too in order to remove the ports implicit inter-dependency.

Quoted 2 lines
Fixes dbf6b16f5683 ("clk: vc5: Add support for IDT VersaClock 5P49V6901")

[...]

MBR, Sergey

maintainer Reviewed-by Reviewed-by on v4 2/8
#5 lore raw

Re: [PATCH v4 2/8] clk: vc5: Fix 5P49V6901 outputs disabling when enabling FOD

In reply to Serge Semin

Hi Serge,

thank you for your patch!

Quoted 11 lines · Serge Semin

We have discovered random glitches during the system boot up procedure. The problem investigation led us to the weird outcomes: when none of the Renesas 5P49V6901 ports are explicitly enabled by the kernel driver, the glitches disappeared. It was a mystery since the SoC external clock domains were fed with different 5P49V6901 outputs. The driver code didn't seem like bogus either. We almost despaired to find out a root cause when the solution was found for a more modern revision of the chip. It turned out the 5P49V6901 clock generator stopped its output for a short period of time during the VC5_OUT_DIV_CONTROL register writing. The same problem has was found for the 5P49V6965 revision of the chip and the was successfully fixed in commit fc336ae622df ("clk: vc5: fix output disabling when

Quoted 8 lines

enabling a FOD") by enabling the "bypass_sync" flag hidden inside "Unused Factory Reserved Register". Even though the 5P49V6901 registers description and programming guide doesn't provide any intel regarding that flag, setting it up anyway in the officially unused register completely eliminated the denoted glitches. Thus let's activate the functionality submitted in commit fc336ae622df ("clk: vc5: fix output disabling when enabling a FOD") for the Renesas 5P49V6901 chip too in order to remove the ports implicit inter-dependency.

Sadly, you have been through the same troubles I had on the 6965.

Quoted 2 lines
Fixes dbf6b16f5683 ("clk: vc5: Add support for IDT VersaClock 5P49V6901")

(not sure which address is appropriate as I sent patches to update to the Bootlin one and they are being applied one y one on the various maintainers branches)

Signature · 1 line
Luca
#6 lore raw

Re: [PATCH v4 2/8] clk: vc5: Fix 5P49V6901 outputs disabling when enabling FOD

Quoted 26 lines · Luca Ceresoli

Hi Serge,

thank you for your patch!

Quoted 11 lines · Serge Semin

We have discovered random glitches during the system boot up procedure. The problem investigation led us to the weird outcomes: when none of the Renesas 5P49V6901 ports are explicitly enabled by the kernel driver, the glitches disappeared. It was a mystery since the SoC external clock domains were fed with different 5P49V6901 outputs. The driver code didn't seem like bogus either. We almost despaired to find out a root cause when the solution was found for a more modern revision of the chip. It turned out the 5P49V6901 clock generator stopped its output for a short period of time during the VC5_OUT_DIV_CONTROL register writing. The same problem has was found for the 5P49V6965 revision of the chip and the was successfully fixed in commit fc336ae622df ("clk: vc5: fix output disabling when

Quoted 8 lines

enabling a FOD") by enabling the "bypass_sync" flag hidden inside "Unused Factory Reserved Register". Even though the 5P49V6901 registers description and programming guide doesn't provide any intel regarding that flag, setting it up anyway in the officially unused register completely eliminated the denoted glitches. Thus let's activate the functionality submitted in commit fc336ae622df ("clk: vc5: fix output disabling when enabling a FOD") for the Renesas 5P49V6901 chip too in order to remove the ports implicit inter-dependency.

Quoted 1 line

Sadly, you have been through the same troubles I had on the 6965.

Hi Luca

Yeah, it was a nightmare fixing that weird problem. Thanks god you have committed the solution. Last time I had to face something similar was when I was fixing a problem in the IDT NTB controller, which caused PCIe MRd TLPs successfully passed from one side to another, but not in the opposite direction. I spent months trying to figure out the root cause of the problem or at least find some workaround. I wrote several messages to the support team but for some reason they didn't respond. After all the struggle I've found the IDT PCIe bridges configuration tool, hacked it's XML config files where I found the info regarding the Vendor-specific PCIe config-space undocumented flags. It turned out that by default the controller discarded the PCIe MRd responses coming from the link-partner with non-zero device number. In order to make things working a vendor-specific flag needed to be set.

Quoted 10 lines
Quoted 3 lines
Fixes dbf6b16f5683 ("clk: vc5: Add support for IDT VersaClock 5P49V6901")

(not sure which address is appropriate as I sent patches to update to the Bootlin one and they are being applied one y one on the various maintainers branches)

Thanks. I'll use the top one then since it was used in the patch Author tag.

-Sergey

Quoted 3 lines
Signature · 2 lines
-- 
Luca
#7 lore raw

PATCH v4 3/8 clk: baikal-t1: Fix invalid xGMAC PTP clock divider

In reply to Serge Semin

Most likely due to copy-paste mistake the divider has been set to 10 while according to the SoC reference manual it's supposed to be 8 thus having PTP clock frequency of 156.25 MHz.

Fixes 353afa3a8d2e ("clk: Add Baikal-T1 CCU Dividers driver")
---
 drivers/clk/baikal-t1/clk-ccu-div.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/baikal-t1/clk-ccu-div.c +1 -1
index f141fda12b09..ea77eec40ddd 100644
@@ -207,7 +207,7 @@ static const struct ccu_div_info sys_info[] = {
 	CCU_DIV_GATE_INFO(CCU_SYS_XGMAC_REF_CLK, "sys_xgmac_ref_clk",
 			  "eth_clk", CCU_SYS_XGMAC_BASE, 8),
 	CCU_DIV_FIXED_INFO(CCU_SYS_XGMAC_PTP_CLK, "sys_xgmac_ptp_clk",
-			   "eth_clk", 10),
+			   "eth_clk", 8),
 	CCU_DIV_GATE_INFO(CCU_SYS_USB_CLK, "sys_usb_clk",
 			  "eth_clk", CCU_SYS_USB_BASE, 10),
 	CCU_DIV_VAR_INFO(CCU_SYS_PVT_CLK, "sys_pvt_clk",
Signature · 1 line
2.35.1
#8 lore raw

PATCH v4 4/8 clk: baikal-t1: Add shared xGMAC ref/ptp clocks internal parent

In reply to Serge Semin

Baikal-T1 CCU reference manual says that both xGMAC reference and xGMAC PTP clocks are generated by two different wrappers with the same constant divider thus each producing a 156.25 MHz signal. But for some reason both of these clock sources are gated by a single switch-flag in the CCU registers space - CCU_SYS_XGMAC_BASE.BIT(0). In order to make the clocks handled independently we need to define a shared parental gate so the base clock signal would be switched off only if both of the child-clocks are disabled.

Note the ID is intentionally set to -2 since we are going to add a one more internal clock identifier in the next commit.

Fixes 353afa3a8d2e ("clk: Add Baikal-T1 CCU Dividers driver")

---

Changelog v4:
- Change the ID macro name to the more descriptive CCU_SYS_XGMAC_CLK.

---
 drivers/clk/baikal-t1/ccu-div.c     | 1 +
 drivers/clk/baikal-t1/ccu-div.h     | 6 ++++++
 drivers/clk/baikal-t1/clk-ccu-div.c | 8 +++++---
 3 files changed, 12 insertions(+), 3 deletions(-)
drivers/clk/baikal-t1/ccu-div.c +1 -0
index 4062092d67f9..bbfa3526ee10 100644
@@ -579,6 +579,7 @@ struct ccu_div *ccu_div_hw_register(const struct ccu_div_init_data *div_init)
 		goto err_free_div;
 	}
 	parent_data.fw_name = div_init->parent_name;
+	parent_data.name = div_init->parent_name;
 	hw_init.parent_data = &parent_data;
 	hw_init.num_parents = 1;
 
drivers/clk/baikal-t1/ccu-div.h +6 -0
index 795665caefbd..b6a9c8e45318 100644
@@ -13,6 +13,12 @@
 #include <linux/bits.h>
 #include <linux/of.h>
 
+/*
+ * CCU Divider private clock IDs
+ * @CCU_SYS_XGMAC_CLK: CCU XGMAC internal clock
+ */
+#define CCU_SYS_XGMAC_CLK		-2
+
 /*
  * CCU Divider private flags
  * @CCU_DIV_SKIP_ONE: Due to some reason divider can't be set to 1.
drivers/clk/baikal-t1/clk-ccu-div.c +5 -3
index ea77eec40ddd..3953ae5664be 100644
@@ -204,10 +204,12 @@ static const struct ccu_div_info sys_info[] = {
 			  "eth_clk", CCU_SYS_GMAC1_BASE, 5),
 	CCU_DIV_FIXED_INFO(CCU_SYS_GMAC1_PTP_CLK, "sys_gmac1_ptp_clk",
 			   "eth_clk", 10),
-	CCU_DIV_GATE_INFO(CCU_SYS_XGMAC_REF_CLK, "sys_xgmac_ref_clk",
-			  "eth_clk", CCU_SYS_XGMAC_BASE, 8),
+	CCU_DIV_GATE_INFO(CCU_SYS_XGMAC_CLK, "sys_xgmac_clk",
+			  "eth_clk", CCU_SYS_XGMAC_BASE, 1),
+	CCU_DIV_FIXED_INFO(CCU_SYS_XGMAC_REF_CLK, "sys_xgmac_ref_clk",
+			   "sys_xgmac_clk", 8),
 	CCU_DIV_FIXED_INFO(CCU_SYS_XGMAC_PTP_CLK, "sys_xgmac_ptp_clk",
-			   "eth_clk", 8),
+			   "sys_xgmac_clk", 8),
 	CCU_DIV_GATE_INFO(CCU_SYS_USB_CLK, "sys_usb_clk",
 			  "eth_clk", CCU_SYS_USB_BASE, 10),
 	CCU_DIV_VAR_INFO(CCU_SYS_PVT_CLK, "sys_pvt_clk",
Signature · 1 line
2.35.1
#9 lore raw

PATCH v4 5/8 clk: baikal-t1: Add SATA internal ref clock buffer

In reply to Serge Semin

It turns out the internal SATA reference clock signal will stay unavailable for the SATA interface consumer until the buffer on it's way is ungated. So aside with having the actual clock divider enabled we need to ungate a buffer placed on the signal way to the SATA controller (most likely some rudiment from the initial SoC release). Seeing the switch flag is placed in the same register as the SATA-ref clock divider at a non-standard ffset, let's implement it as a separate clock controller with the set-rate propagation to the parental clock divider wrapper. As such we'll be able to disable/enable and still change the original clock source rate.

Fixes 353afa3a8d2e ("clk: Add Baikal-T1 CCU Dividers driver")

---

Changelog v4:
- This is a new patch created on v4 lap of the series.

---
 drivers/clk/baikal-t1/ccu-div.c     | 64 +++++++++++++++++++++++++++++
 drivers/clk/baikal-t1/ccu-div.h     |  4 ++
 drivers/clk/baikal-t1/clk-ccu-div.c | 18 +++++++-
 3 files changed, 85 insertions(+), 1 deletion(-)
drivers/clk/baikal-t1/ccu-div.c +64 -0
index bbfa3526ee10..a6642f3d33d4 100644
@@ -34,6 +34,7 @@
 #define CCU_DIV_CTL_CLKDIV_MASK(_width) \
 	GENMASK((_width) + CCU_DIV_CTL_CLKDIV_FLD - 1, CCU_DIV_CTL_CLKDIV_FLD)
 #define CCU_DIV_CTL_LOCK_SHIFTED	BIT(27)
+#define CCU_DIV_CTL_GATE_REF_BUF	BIT(28)
 #define CCU_DIV_CTL_LOCK_NORMAL		BIT(31)
 
 #define CCU_DIV_RST_DELAY_US		1
@@ -170,6 +171,40 @@ static int ccu_div_gate_is_enabled(struct clk_hw *hw)
 	return !!(val & CCU_DIV_CTL_EN);
 }
 
+static int ccu_div_buf_enable(struct clk_hw *hw)
+{
+	struct ccu_div *div = to_ccu_div(hw);
+	unsigned long flags;
+
+	spin_lock_irqsave(&div->lock, flags);
+	regmap_update_bits(div->sys_regs, div->reg_ctl,
+			   CCU_DIV_CTL_GATE_REF_BUF, 0);
+	spin_unlock_irqrestore(&div->lock, flags);
+
+	return 0;
+}
+
+static void ccu_div_buf_disable(struct clk_hw *hw)
+{
+	struct ccu_div *div = to_ccu_div(hw);
+	unsigned long flags;
+
+	spin_lock_irqsave(&div->lock, flags);
+	regmap_update_bits(div->sys_regs, div->reg_ctl,
+			   CCU_DIV_CTL_GATE_REF_BUF, CCU_DIV_CTL_GATE_REF_BUF);
+	spin_unlock_irqrestore(&div->lock, flags);
+}
+
+static int ccu_div_buf_is_enabled(struct clk_hw *hw)
+{
+	struct ccu_div *div = to_ccu_div(hw);
+	u32 val = 0;
+
+	regmap_read(div->sys_regs, div->reg_ctl, &val);
+
+	return !(val & CCU_DIV_CTL_GATE_REF_BUF);
+}
+
 static unsigned long ccu_div_var_recalc_rate(struct clk_hw *hw,
 					     unsigned long parent_rate)
 {
@@ -323,6 +358,7 @@ static const struct ccu_div_dbgfs_bit ccu_div_bits[] = {
 	CCU_DIV_DBGFS_BIT_ATTR("div_en", CCU_DIV_CTL_EN),
 	CCU_DIV_DBGFS_BIT_ATTR("div_rst", CCU_DIV_CTL_RST),
 	CCU_DIV_DBGFS_BIT_ATTR("div_bypass", CCU_DIV_CTL_SET_CLKDIV),
+	CCU_DIV_DBGFS_BIT_ATTR("div_buf", CCU_DIV_CTL_GATE_REF_BUF),
 	CCU_DIV_DBGFS_BIT_ATTR("div_lock", CCU_DIV_CTL_LOCK_NORMAL)
 };
 
@@ -441,6 +477,9 @@ static void ccu_div_var_debug_init(struct clk_hw *hw, struct dentry *dentry)
 			continue;
 		}
 
+		if (!strcmp("div_buf", name))
+			continue;
+
 		bits[didx] = ccu_div_bits[bidx];
 		bits[didx].div = div;
 
@@ -477,6 +516,21 @@ static void ccu_div_gate_debug_init(struct clk_hw *hw, struct dentry *dentry)
 				   &ccu_div_dbgfs_fixed_clkdiv_fops);
 }
 
+static void ccu_div_buf_debug_init(struct clk_hw *hw, struct dentry *dentry)
+{
+	struct ccu_div *div = to_ccu_div(hw);
+	struct ccu_div_dbgfs_bit *bit;
+
+	bit = kmalloc(sizeof(*bit), GFP_KERNEL);
+	if (!bit)
+		return;
+
+	*bit = ccu_div_bits[3];
+	bit->div = div;
+	debugfs_create_file_unsafe(bit->name, ccu_div_dbgfs_mode, dentry, bit,
+				   &ccu_div_dbgfs_bit_fops);
+}
+
 static void ccu_div_fixed_debug_init(struct clk_hw *hw, struct dentry *dentry)
 {
 	struct ccu_div *div = to_ccu_div(hw);
@@ -489,6 +543,7 @@ static void ccu_div_fixed_debug_init(struct clk_hw *hw, struct dentry *dentry)
 
 #define ccu_div_var_debug_init NULL
 #define ccu_div_gate_debug_init NULL
+#define ccu_div_buf_debug_init NULL
 #define ccu_div_fixed_debug_init NULL
 
 #endif /* !CONFIG_DEBUG_FS */
@@ -520,6 +575,13 @@ static const struct clk_ops ccu_div_gate_ops = {
 	.debug_init = ccu_div_gate_debug_init
 };
 
+static const struct clk_ops ccu_div_buf_ops = {
+	.enable = ccu_div_buf_enable,
+	.disable = ccu_div_buf_disable,
+	.is_enabled = ccu_div_buf_is_enabled,
+	.debug_init = ccu_div_buf_debug_init
+};
+
 static const struct clk_ops ccu_div_fixed_ops = {
 	.recalc_rate = ccu_div_fixed_recalc_rate,
 	.round_rate = ccu_div_fixed_round_rate,
@@ -566,6 +628,8 @@ struct ccu_div *ccu_div_hw_register(const struct ccu_div_init_data *div_init)
 	} else if (div_init->type == CCU_DIV_GATE) {
 		hw_init.ops = &ccu_div_gate_ops;
 		div->divider = div_init->divider;
+	} else if (div_init->type == CCU_DIV_BUF) {
+		hw_init.ops = &ccu_div_buf_ops;
 	} else if (div_init->type == CCU_DIV_FIXED) {
 		hw_init.ops = &ccu_div_fixed_ops;
 		div->divider = div_init->divider;
drivers/clk/baikal-t1/ccu-div.h +4 -0
index b6a9c8e45318..4eb49ff4803c 100644
@@ -15,8 +15,10 @@
 
 /*
  * CCU Divider private clock IDs
+ * @CCU_SYS_SATA_CLK: CCU SATA internal clock
  * @CCU_SYS_XGMAC_CLK: CCU XGMAC internal clock
  */
+#define CCU_SYS_SATA_CLK		-1
 #define CCU_SYS_XGMAC_CLK		-2
 
 /*
@@ -37,11 +39,13 @@
  * enum ccu_div_type - CCU Divider types
  * @CCU_DIV_VAR: Clocks gate with variable divider.
  * @CCU_DIV_GATE: Clocks gate with fixed divider.
+ * @CCU_DIV_BUF: Clock gate with no divider.
  * @CCU_DIV_FIXED: Ungateable clock with fixed divider.
  */
 enum ccu_div_type {
 	CCU_DIV_VAR,
 	CCU_DIV_GATE,
+	CCU_DIV_BUF,
 	CCU_DIV_FIXED
 };
 
drivers/clk/baikal-t1/clk-ccu-div.c +17 -1
index 3953ae5664be..90f4fda406ee 100644
@@ -76,6 +76,16 @@
 		.divider = _divider				\
 	}
 
+#define CCU_DIV_BUF_INFO(_id, _name, _pname, _base, _flags)	\
+	{							\
+		.id = _id,					\
+		.name = _name,					\
+		.parent_name = _pname,				\
+		.base = _base,					\
+		.type = CCU_DIV_BUF,				\
+		.flags = _flags					\
+	}
+
 #define CCU_DIV_FIXED_INFO(_id, _name, _pname, _divider)	\
 	{							\
 		.id = _id,					\
@@ -188,11 +198,14 @@ static const struct ccu_div_rst_map axi_rst_map[] = {
  * for the SoC devices registers IO-operations.
  */
 static const struct ccu_div_info sys_info[] = {
-	CCU_DIV_VAR_INFO(CCU_SYS_SATA_REF_CLK, "sys_sata_ref_clk",
+	CCU_DIV_VAR_INFO(CCU_SYS_SATA_CLK, "sys_sata_clk",
 			 "sata_clk", CCU_SYS_SATA_REF_BASE, 4,
 			 CLK_SET_RATE_GATE,
 			 CCU_DIV_SKIP_ONE | CCU_DIV_LOCK_SHIFTED |
 			 CCU_DIV_RESET_DOMAIN),
+	CCU_DIV_BUF_INFO(CCU_SYS_SATA_REF_CLK, "sys_sata_ref_clk",
+			 "sys_sata_clk", CCU_SYS_SATA_REF_BASE,
+			 CLK_SET_RATE_PARENT),
 	CCU_DIV_VAR_INFO(CCU_SYS_APB_CLK, "sys_apb_clk",
 			 "pcie_clk", CCU_SYS_APB_BASE, 5,
 			 CLK_IS_CRITICAL, CCU_DIV_RESET_DOMAIN),
@@ -398,6 +411,9 @@ static int ccu_div_clk_register(struct ccu_div_data *data)
 			init.base = info->base;
 			init.sys_regs = data->sys_regs;
 			init.divider = info->divider;
+		} else if (init.type == CCU_DIV_BUF) {
+			init.base = info->base;
+			init.sys_regs = data->sys_regs;
 		} else {
 			init.divider = info->divider;
 		}
Signature · 1 line
2.35.1
#10 lore raw

PATCH v4 6/8 clk: baikal-t1: Move reset-controls code into a dedicated module

In reply to Serge Semin

Before adding the directly controlled resets support it's reasonable to move the existing resets control functionality into a dedicated object for the sake of the CCU dividers clock driver simplification. After the new functionality was added clk-ccu-div.c would have got to a mixture of the weakly dependent clocks and resets methods. Splitting the methods up into the two objects will make the code easier to read and maintain. It shall also improve the code scalability (though hopefully we won't need this part that much in the future).

As it was done for the CCU PLLs and Dividers the reset control functionality in its turn has been split up into two sub-modules:
hw-interface and generic reset device description. This commit doesn't provide any change in the CCU reset module semantics. As before it supports the trigger-like CCU resets only, which are responsible for the AXI-bus, APB-bus and SATA-ref blocks reset. The assert/de-assert-capable reset controls support will be added in the next commit.

Note the CCU Clock dividers and resets functionality split up was possible due to not having any side-effects (at least we didn't found ones) of the regmap-based concurrent access of the common CCU dividers/reset CSRs.

---

Changelog v4:
- Completely split CCU Dividers and Resets functionality. (@Stephen)

---
 drivers/clk/baikal-t1/Kconfig       |  12 +-
 drivers/clk/baikal-t1/Makefile      |   1 +
 drivers/clk/baikal-t1/ccu-div.c     |  19 ---
 drivers/clk/baikal-t1/ccu-div.h     |   4 +-
 drivers/clk/baikal-t1/ccu-rst.c     |  43 +++++
 drivers/clk/baikal-t1/ccu-rst.h     |  67 ++++++++
 drivers/clk/baikal-t1/clk-ccu-div.c | 101 +++---------
 drivers/clk/baikal-t1/clk-ccu-rst.c | 236 ++++++++++++++++++++++++++++
 8 files changed, 384 insertions(+), 99 deletions(-)
 create mode 100644 drivers/clk/baikal-t1/ccu-rst.c
 create mode 100644 drivers/clk/baikal-t1/ccu-rst.h
 create mode 100644 drivers/clk/baikal-t1/clk-ccu-rst.c
drivers/clk/baikal-t1/Kconfig +11 -1
index 03102f1094bc..56a4ff1d8bf0 100644
@@ -29,7 +29,6 @@ config CLK_BT1_CCU_PLL
 
 config CLK_BT1_CCU_DIV
 	bool "Baikal-T1 CCU Dividers support"
-	select RESET_CONTROLLER
 	select MFD_SYSCON
 	default MIPS_BAIKAL_T1
 	help
@@ -39,4 +38,15 @@ config CLK_BT1_CCU_DIV
 	  either gateable or ungateable. Some of the CCU dividers can be as well
 	  used to reset the domains they're supplying clock to.
 
+config CLK_BT1_CCU_RST
+	bool "Baikal-T1 CCU Resets support"
+	select RESET_CONTROLLER
+	select MFD_SYSCON
+	default MIPS_BAIKAL_T1
+	help
+	  Enable this to support the CCU reset blocks responsible for the
+	  AXI-bus and some subsystems reset. These are mainly the
+	  sef-deasserted reset controls but there are several lines which
+	  can be directly asserted/de-asserted (PCIe and DDR sub-domains).
+
 endif
drivers/clk/baikal-t1/Makefile +1 -0
index b3b9590b95ed..99e97f168417 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_CLK_BT1_CCU_PLL) += ccu-pll.o clk-ccu-pll.o
 obj-$(CONFIG_CLK_BT1_CCU_DIV) += ccu-div.o clk-ccu-div.o
+obj-$(CONFIG_CLK_BT1_CCU_RST) += ccu-rst.o clk-ccu-rst.o
drivers/clk/baikal-t1/ccu-div.c +0 -19
index a6642f3d33d4..8d5fc7158f33 100644
@@ -37,7 +37,6 @@
 #define CCU_DIV_CTL_GATE_REF_BUF	BIT(28)
 #define CCU_DIV_CTL_LOCK_NORMAL		BIT(31)
 
-#define CCU_DIV_RST_DELAY_US		1
 #define CCU_DIV_LOCK_CHECK_RETRIES	50
 
 #define CCU_DIV_CLKDIV_MIN		0
@@ -323,24 +322,6 @@ static int ccu_div_fixed_set_rate(struct clk_hw *hw, unsigned long rate,
 	return 0;
 }
 
-int ccu_div_reset_domain(struct ccu_div *div)
-{
-	unsigned long flags;
-
-	if (!div || !(div->features & CCU_DIV_RESET_DOMAIN))
-		return -EINVAL;
-
-	spin_lock_irqsave(&div->lock, flags);
-	regmap_update_bits(div->sys_regs, div->reg_ctl,
-			   CCU_DIV_CTL_RST, CCU_DIV_CTL_RST);
-	spin_unlock_irqrestore(&div->lock, flags);
-
-	/* The next delay must be enough to cover all the resets. */
-	udelay(CCU_DIV_RST_DELAY_US);
-
-	return 0;
-}
-
 #ifdef CONFIG_DEBUG_FS
 
 struct ccu_div_dbgfs_bit {
drivers/clk/baikal-t1/ccu-div.h +1 -3
index 4eb49ff4803c..ff97bb30fcc3 100644
@@ -28,7 +28,7 @@
  * @CCU_DIV_SKIP_ONE_TO_THREE: For some reason divider can't be within [1,3].
  *			       It can be either 0 or greater than 3.
  * @CCU_DIV_LOCK_SHIFTED: Find lock-bit at non-standard position.
- * @CCU_DIV_RESET_DOMAIN: Provide reset clock domain method.
+ * @CCU_DIV_RESET_DOMAIN: There is a clock domain reset handle.
  */
 #define CCU_DIV_SKIP_ONE		BIT(1)
 #define CCU_DIV_SKIP_ONE_TO_THREE	BIT(2)
@@ -115,6 +115,4 @@ struct ccu_div *ccu_div_hw_register(const struct ccu_div_init_data *init);
 
 void ccu_div_hw_unregister(struct ccu_div *div);
 
-int ccu_div_reset_domain(struct ccu_div *div);
-
 #endif /* __CLK_BT1_CCU_DIV_H__ */
drivers/clk/baikal-t1/ccu-rst.c new file +43 -0

43 lines not on this page · raw message

drivers/clk/baikal-t1/ccu-rst.h new file +67 -0

67 lines not on this page · raw message

drivers/clk/baikal-t1/clk-ccu-div.c +25 -76

166 lines not on this page · raw message

drivers/clk/baikal-t1/clk-ccu-rst.c new file +236 -0

236 lines not on this page · raw message

Signature · 1 line
2.35.1
#11 lore raw

PATCH v4 7/8 clk: baikal-t1: Add DDR/PCIe directly controlled resets support

In reply to Serge Semin

Aside with a set of the trigger-like resets Baikal-T1 CCU provides two additional blocks with directly controlled reset signals. In particular it concerns DDR full and initial resets and various PCIe sub-domains resets. Let's add the direct reset assertion/de-assertion of the corresponding flags support into the Baikal-T1 CCU driver then. It will be required at least for the PCIe platform driver. Obviously the DDR controller isn't supposed to be fully reset in the kernel, so the corresponding controls are added just for the sake of the interface implementation completeness.

---
 drivers/clk/baikal-t1/ccu-rst.c     | 56 +++++++++++++++++++++++++++++
 drivers/clk/baikal-t1/ccu-rst.h     | 12 +++++++
 drivers/clk/baikal-t1/clk-ccu-rst.c | 21 +++++++++++
 include/dt-bindings/reset/bt1-ccu.h |  9 +++++
 4 files changed, 98 insertions(+)
drivers/clk/baikal-t1/ccu-rst.c +56 -0
index b355bf0b399a..a3b41cbe6230 100644
@@ -30,6 +30,9 @@ static int ccu_rst_reset(struct reset_controller_dev *rcdev, unsigned long idx)
 		return PTR_ERR(rst);
 	}
 
+	if (rst->type != CCU_RST_TRIG)
+		return -EOPNOTSUPP;
+
 	regmap_update_bits(rst->sys_regs, rst->reg_ctl, rst->mask, rst->mask);
 
 	/* The next delay must be enough to cover all the resets. */
@@ -38,6 +41,59 @@ static int ccu_rst_reset(struct reset_controller_dev *rcdev, unsigned long idx)
 	return 0;
 }
 
+static int ccu_rst_set(struct reset_controller_dev *rcdev,
+		       unsigned long idx, bool high)
+{
+	struct ccu_rst *rst;
+
+	rst = ccu_rst_get_desc(rcdev, idx);
+	if (IS_ERR(rst)) {
+		pr_err("Invalid reset index %lu specified\n", idx);
+		return PTR_ERR(rst);
+	}
+
+	if (rst->type != CCU_RST_DIR)
+		return high ? -EOPNOTSUPP : 0;
+
+	return regmap_update_bits(rst->sys_regs, rst->reg_ctl,
+				  rst->mask, high ? rst->mask : 0);
+}
+
+static int ccu_rst_assert(struct reset_controller_dev *rcdev,
+			  unsigned long idx)
+{
+	return ccu_rst_set(rcdev, idx, true);
+}
+
+static int ccu_rst_deassert(struct reset_controller_dev *rcdev,
+			    unsigned long idx)
+{
+	return ccu_rst_set(rcdev, idx, false);
+}
+
+static int ccu_rst_status(struct reset_controller_dev *rcdev,
+			  unsigned long idx)
+{
+	struct ccu_rst *rst;
+	u32 val;
+
+	rst = ccu_rst_get_desc(rcdev, idx);
+	if (IS_ERR(rst)) {
+		pr_err("Invalid reset index %lu specified\n", idx);
+		return PTR_ERR(rst);
+	}
+
+	if (rst->type != CCU_RST_DIR)
+		return -EOPNOTSUPP;
+
+	regmap_read(rst->sys_regs, rst->reg_ctl, &val);
+
+	return !!(val & rst->mask);
+}
+
 const struct reset_control_ops ccu_rst_ops = {
 	.reset = ccu_rst_reset,
+	.assert = ccu_rst_assert,
+	.deassert = ccu_rst_deassert,
+	.status = ccu_rst_status,
 };
drivers/clk/baikal-t1/ccu-rst.h +12 -0
index d03bae4b7a05..7b9b9c81f5c9 100644
@@ -12,6 +12,16 @@
 
 struct ccu_rst_data;
 
+/*
+ * enum ccu_rst_type - CCU Reset types
+ * @CCU_RST_TRIG: Self-deasserted reset signal.
+ * @CCU_RST_DIR: Directly controlled reset signal.
+ */
+enum ccu_rst_type {
+	CCU_RST_TRIG,
+	CCU_RST_DIR,
+};
+
 /*
  * struct ccu_rst_init_data - CCU Resets initialization data
  * @sys_regs: Baikal-T1 System Controller registers map.
@@ -25,12 +35,14 @@ struct ccu_rst_init_data {
 /*
  * struct ccu_rst - CCU Reset descriptor
  * @id: Reset identifier.
+ * @type: Reset control type.
  * @reg_ctl: Reset control register base address.
  * @sys_regs: Baikal-T1 System Controller registers map.
  * @mask: Reset bitmask (normally it's just a single bit flag).
  */
 struct ccu_rst {
 	unsigned int id;
+	enum ccu_rst_type type;
 	unsigned int reg_ctl;
 	struct regmap *sys_regs;
 	u32 mask;
drivers/clk/baikal-t1/clk-ccu-rst.c +21 -0
index b10857f48b8b..592a95308c62 100644
@@ -33,18 +33,30 @@
 #define CCU_AXI_HWA_BASE		0x054
 #define CCU_AXI_SRAM_BASE		0x058
 
+#define CCU_SYS_DDR_BASE		0x02c
 #define CCU_SYS_SATA_REF_BASE		0x060
 #define CCU_SYS_APB_BASE		0x064
+#define CCU_SYS_PCIE_BASE		0x144
 
 #define CCU_RST_TRIG(_id, _base, _ofs)		\
 	{					\
 		.id = _id,			\
+		.type = CCU_RST_TRIG,		\
+		.base = _base,			\
+		.mask = BIT(_ofs),		\
+	}
+
+#define CCU_RST_DIR(_id, _base, _ofs)		\
+	{					\
+		.id = _id,			\
+		.type = CCU_RST_DIR,		\
 		.base = _base,			\
 		.mask = BIT(_ofs),		\
 	}
 
 struct ccu_rst_info {
 	unsigned int id;
+	enum ccu_rst_type type;
 	unsigned int base;
 	unsigned int mask;
 };
@@ -89,6 +101,15 @@ static const struct ccu_rst_info axi_rst_info[] = {
 static const struct ccu_rst_info sys_rst_info[] = {
 	CCU_RST_TRIG(CCU_SYS_SATA_REF_RST, CCU_SYS_SATA_REF_BASE, 1),
 	CCU_RST_TRIG(CCU_SYS_APB_RST, CCU_SYS_APB_BASE, 1),
+	CCU_RST_DIR(CCU_SYS_DDR_FULL_RST, CCU_SYS_DDR_BASE, 1),
+	CCU_RST_DIR(CCU_SYS_DDR_INIT_RST, CCU_SYS_DDR_BASE, 2),
+	CCU_RST_DIR(CCU_SYS_PCIE_PCS_PHY_RST, CCU_SYS_PCIE_BASE, 0),
+	CCU_RST_DIR(CCU_SYS_PCIE_PIPE0_RST, CCU_SYS_PCIE_BASE, 4),
+	CCU_RST_DIR(CCU_SYS_PCIE_CORE_RST, CCU_SYS_PCIE_BASE, 8),
+	CCU_RST_DIR(CCU_SYS_PCIE_PWR_RST, CCU_SYS_PCIE_BASE, 9),
+	CCU_RST_DIR(CCU_SYS_PCIE_STICKY_RST, CCU_SYS_PCIE_BASE, 10),
+	CCU_RST_DIR(CCU_SYS_PCIE_NSTICKY_RST, CCU_SYS_PCIE_BASE, 11),
+	CCU_RST_DIR(CCU_SYS_PCIE_HOT_RST, CCU_SYS_PCIE_BASE, 12),
 };
 
 struct ccu_rst *ccu_rst_get_desc(struct reset_controller_dev *rcdev, unsigned long idx)
include/dt-bindings/reset/bt1-ccu.h +9 -0
index 3578e83026bc..c691efaa678f 100644
@@ -21,5 +21,14 @@
 
 #define CCU_SYS_SATA_REF_RST		0
 #define CCU_SYS_APB_RST			1
+#define CCU_SYS_DDR_FULL_RST		2
+#define CCU_SYS_DDR_INIT_RST		3
+#define CCU_SYS_PCIE_PCS_PHY_RST	4
+#define CCU_SYS_PCIE_PIPE0_RST		5
+#define CCU_SYS_PCIE_CORE_RST		6
+#define CCU_SYS_PCIE_PWR_RST		7
+#define CCU_SYS_PCIE_STICKY_RST		8
+#define CCU_SYS_PCIE_NSTICKY_RST	9
+#define CCU_SYS_PCIE_HOT_RST		10
 
 #endif /* __DT_BINDINGS_RESET_BT1_CCU_H */
Signature · 1 line
2.35.1
#12 lore raw

PATCH v4 8/8 clk: baikal-t1: Convert to platform device driver

In reply to Serge Semin

In accordance with the way the MIPS platform is normally design there are only six clock sources which need to be available on the kernel start in order to one end up booting correctly:
+ CPU PLL: needed by the r4k and MIPS GIC timer drivers. The former one is initialized by the arch code, while the later one is implemented in the mips-gic-timer.c driver as the OF-declared timer.
+ PCIe PLL: required as a parental clock source for the APB/timer domains.
+ APB clock: needed in order to access all the SoC CSRs at least for the timer OF-declared drivers.
+ APB Timer{0-2} clocks: these are the DW APB timers which drivers dw_apb_timer_of.c are implemented as the OF-declared timers.

So as long as the clocks above are available early the kernel will normally work. Let's convert the Baikal-T1 CCU drivers to the platform device drivers keeping that in mind.

Generally speaking the conversion isn't that complicated since the driver infrastructure has been designed as flexible enough for that. First we need to add a new PLL/Divider clock features flag which indicates the corresponding clock source as a basic one and that clock sources will be available on the kernel early boot stages. Second the internal PLL/Divider descriptors need to be initialized with -EPROBE_DEFER value as the corresponding clock source is unavailable at the early stages. They will be allocated and initialized on the Baikal-T1 clock platform driver probe procedure. Finally the already available PLL/Divider init functions need to be split up into two ones: init procedure performed in the framework of the OF-declared clock initialization (of_clk_init()), and the probe procedure called by the platform devices bus driver. Note the later method will just continue the system clocks initialization started in the former one.

---

Changelog v4:
- This is a new patch created on v4 lap of the series to make @Stephen a bit more happy about this series.)

---
 drivers/clk/baikal-t1/ccu-div.h     |   3 +
 drivers/clk/baikal-t1/ccu-pll.h     |   8 ++
 drivers/clk/baikal-t1/clk-ccu-div.c | 149 +++++++++++++++++++++++-----
 drivers/clk/baikal-t1/clk-ccu-pll.c | 128 +++++++++++++++++++-----
 4 files changed, 235 insertions(+), 53 deletions(-)
drivers/clk/baikal-t1/ccu-div.h +3 -0
index ff97bb30fcc3..76d8ee44d415 100644
@@ -23,6 +23,8 @@
 
 /*
  * CCU Divider private flags
+ * @CCU_DIV_BASIC: Basic divider clock required by the kernel as early as
+ *		   possible.
  * @CCU_DIV_SKIP_ONE: Due to some reason divider can't be set to 1.
  *		      It can be 0 though, which is functionally the same.
  * @CCU_DIV_SKIP_ONE_TO_THREE: For some reason divider can't be within [1,3].
@@ -30,6 +32,7 @@
  * @CCU_DIV_LOCK_SHIFTED: Find lock-bit at non-standard position.
  * @CCU_DIV_RESET_DOMAIN: There is a clock domain reset handle.
  */
+#define CCU_DIV_BASIC			BIT(0)
 #define CCU_DIV_SKIP_ONE		BIT(1)
 #define CCU_DIV_SKIP_ONE_TO_THREE	BIT(2)
 #define CCU_DIV_LOCK_SHIFTED		BIT(3)
drivers/clk/baikal-t1/ccu-pll.h +8 -0
index 76cd9132a219..a71bfd7b90ec 100644
@@ -13,6 +13,12 @@
 #include <linux/bits.h>
 #include <linux/of.h>
 
+/*
+ * CCU PLL private flags
+ * @CCU_PLL_BASIC: Basic PLL required by the kernel as early as possible.
+ */
+#define CCU_PLL_BASIC		BIT(0)
+
 /*
  * struct ccu_pll_init_data - CCU PLL initialization data
  * @id: Clock private identifier.
@@ -22,6 +28,7 @@
  * @sys_regs: Baikal-T1 System Controller registers map.
  * @np: Pointer to the node describing the CCU PLLs.
  * @flags: PLL clock flags.
+ * @features: PLL private features.
  */
 struct ccu_pll_init_data {
 	unsigned int id;
@@ -31,6 +38,7 @@ struct ccu_pll_init_data {
 	struct regmap *sys_regs;
 	struct device_node *np;
 	unsigned long flags;
+	unsigned long features;
 };
 
 /*
drivers/clk/baikal-t1/clk-ccu-div.c +122 -27

242 lines not on this page · raw message

drivers/clk/baikal-t1/clk-ccu-pll.c +102 -26

219 lines not on this page · raw message

Signature · 1 line
2.35.1
#13 lore raw
In reply to Serge Semin

Hi @Philipp,
Could you have a look at the reset-related patches of series? One of them is a fix and another one concerns the reset-part of the Clock/Reset controller embedded into our SoC.

Hi @Stephen,
The series has been here for about four months now. Can we speed the review up somehow?

-Sergey

Quoted 80 lines · Serge Semin

Short summary regarding this patchset. The series starts from fixing a wrong semantic of the device managed optional exclusive bulk reset control getter. Then we suggest a fix of the clocks glitching cause by the Renesas 5P49V6901 chip in some circumstances. Afterwards a few more modifications are introduced to finally finish the Baikal-T1 CCU unit support up and prepare the code before adding the Baikal-T1 PCIe/xGMAC support. First of all it turned out I specified wrong DW xGMAC PTP reference clock divider in my initial patches. It must be 8, not 10. Secondly I was wrong to add a joint xGMAC Ref and PTP clock instead of having them separately defined. The SoC manual describes these clocks as separate fixed clock wrappers. Finally in order to close the SoC clock/reset support up we need to add the DDR and PCIe interfaces reset controls support. It's done in two steps. First I've moved the reset-controls-related code into a dedicated module. Then the DDR/PCIe reset-control functionality is added. As the series finalization we've decided to convert the Baikal-T1 clock/reset source drivers to mainly being the platform device driver and pre-initialize the basic clocks only at the early kernel boot stages.

Changelog v2:
- Resubmit the series with adding @Philipp to the list of the recipients.

Changelog v3:
- No comments. Just resend the series.
- Rebased from v5.17 onto v5.18-rc3.

Changelog v4:
- Completely split the CCU Dividers and Resets functionality up. (@Stephen)
- Add a new fixes patch: "clk: baikal-t1: Actually enable SATA internal ref clock".
- Add a new fixes patch: "reset: Fix devm bulk optional exclusive control getter".
- Add a new fixes patch: "clk: vc5: Fix 5P49V6901 outputs disabling when enabling FOD".
- Add a new feagure patch: "clk: baikal-t1: Convert to platform device driver".
- Change the internal clock ID to the XGMAC-referred name.
- Rebase onto the kernel v5.18.

Serge Semin (8):
reset: Fix devm bulk optional exclusive control getter
clk: vc5: Fix 5P49V6901 outputs disabling when enabling FOD
clk: baikal-t1: Fix invalid xGMAC PTP clock divider
clk: baikal-t1: Add shared xGMAC ref/ptp clocks internal parent
clk: baikal-t1: Add SATA internal ref clock buffer
clk: baikal-t1: Move reset-controls code into a dedicated module
clk: baikal-t1: Add DDR/PCIe directly controlled resets support
clk: baikal-t1: Convert to platform device driver

 drivers/clk/baikal-t1/Kconfig       |  12 +-
 drivers/clk/baikal-t1/Makefile      |   1 +
 drivers/clk/baikal-t1/ccu-div.c     |  84 +++++++--
 drivers/clk/baikal-t1/ccu-div.h     |  17 +-
 drivers/clk/baikal-t1/ccu-pll.h     |   8 +
 drivers/clk/baikal-t1/ccu-rst.c     |  99 ++++++++++
 drivers/clk/baikal-t1/ccu-rst.h     |  79 ++++++++
 drivers/clk/baikal-t1/clk-ccu-div.c | 272 +++++++++++++++++-----------
 drivers/clk/baikal-t1/clk-ccu-pll.c | 128 ++++++++++---
 drivers/clk/baikal-t1/clk-ccu-rst.c | 257 ++++++++++++++++++++++++++
 drivers/clk/clk-versaclock5.c       |   2 +-
 include/dt-bindings/reset/bt1-ccu.h |   9 +
 include/linux/reset.h               |   2 +-
 13 files changed, 814 insertions(+), 156 deletions(-)
 create mode 100644 drivers/clk/baikal-t1/ccu-rst.c
 create mode 100644 drivers/clk/baikal-t1/ccu-rst.h
 create mode 100644 drivers/clk/baikal-t1/clk-ccu-rst.c
Signature · 1 line
2.35.1