PCI: amlogic: Make PCIe working reliably on AXG platforms
Subsystems (7)
cover PCI: amlogic: Make PCIe working reliably on AXG platforms
PCIe device probing failures have been seen on some AXG platforms and were due to unreliable clock signal output. Setting HHI_MIPI_CNTL0[26] bit solved the problem. After being contacted about this, vendor reported that this bit was linked to PCIe PLL CML output.
This serie adds a way to set this bit through AXG clock gating logic. Platforms having this kind of issue could make use of this gating by applying a patch to their devicetree similar to:
clocks = <&clkc CLKID_USB
&clkc CLKID_MIPI_ENABLE
&clkc CLKID_PCIE_A
- &clkc CLKID_PCIE_CML_EN0>;
+ &clkc CLKID_PCIE_CML_EN0
+ &clkc CLKID_PCIE_PLL_CML_ENABLE>;
clock-names = "pcie_general",
"pcie_mipi_en",
"pcie",
- "port";
+ "port",
+ "pll_cml_en";
resets = <&reset RESET_PCIE_PHY>,
<&reset RESET_PCIE_A>,
<&reset RESET_PCIE_APB>;Remi Pommarel (2):
clk: meson: axg: add pcie pll cml gating
PCI: amlogic: Use PCIe pll gate when available
drivers/clk/meson/axg.c | 3 +++ drivers/clk/meson/axg.h | 2 +- drivers/pci/controller/dwc/pci-meson.c | 5 +++++ include/dt-bindings/clock/axg-clkc.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-)
Signature · 1 line
2.24.0
PATCH 1/2 clk: meson: axg: add pcie pll cml gating
PCIE_PLL_CML_ENABLE is used to enable or disable pcie clock PAD output reliably on AXG platforms.
--- drivers/clk/meson/axg.c | 3 +++ drivers/clk/meson/axg.h | 2 +- include/dt-bindings/clock/axg-clkc.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/clk/meson/axg.c +3 -0
@@ -1142,6 +1142,7 @@ static MESON_GATE(axg_vpu_intr, HHI_GCLK_MPEG2, 25); static MESON_GATE(axg_sec_ahb_ahb3_bridge, HHI_GCLK_MPEG2, 26); static MESON_GATE(axg_gic, HHI_GCLK_MPEG2, 30); static MESON_GATE(axg_mipi_enable, HHI_MIPI_CNTL0, 29); +static MESON_GATE(axg_pcie_pll_cml_enable, HHI_MIPI_CNTL0, 26);/* Always On (AO) domain gates */
@@ -1246,6 +1247,7 @@ static struct clk_hw_onecell_data axg_hw_onecell_data = { [CLKID_HIFI_PLL_DCO] = &axg_hifi_pll_dco.hw, [CLKID_PCIE_PLL_DCO] = &axg_pcie_pll_dco.hw, [CLKID_PCIE_PLL_OD] = &axg_pcie_pll_od.hw, + [CLKID_PCIE_PLL_CML_ENABLE] = &axg_pcie_pll_cml_enable.hw, [NR_CLKS ] =NULL , }, .num = NR_CLKS,
@@ -1341,6 +1343,7 @@ static struct clk_regmap *const axg_clk_regmaps[] = { &axg_hifi_pll_dco, &axg_pcie_pll_dco, &axg_pcie_pll_od, + &axg_pcie_pll_cml_enable, }; static const struct meson_eeclkc_data axg_clkc_data = {
drivers/clk/meson/axg.h +1 -1
@@ -140,7 +140,7 @@#define CLKID_PCIE_PLL_DCO 89#define CLKID_PCIE_PLL_OD 90 -#define NR_CLKS 91 +#define NR_CLKS 92/* include the CLKIDs that have been made part of the DT binding */ #include <dt-bindings/clock/axg-clkc.h>
include/dt-bindings/clock/axg-clkc.h +1 -0
@@ -72,5 +72,6 @@#define CLKID_PCIE_CML_EN1 80#define CLKID_MIPI_ENABLE 81#define CLKID_GEN_CLK 84 +#define CLKID_PCIE_PLL_CML_ENABLE 91#endif /* __AXG_CLKC_H */
Signature · 1 line
2.24.0
Martin Blumenstingl
reviewerRe: [PATCH 1/2] clk: meson: axg: add pcie pll cml gating
Hi Remi,
On Sun, Dec 8, 2019 at 9:56 PM Remi Pommarel <[email protected]> wrote:
[...]
Quoted 1 line
+static
MESON_GATE(axg_pcie_pll_cml_enable, HHI_MIPI_CNTL0, 26);
we already have CLKID_PCIE_CML_EN0
do you know how this new one is related (in terms of clock hierarchy) to the existing one?
[...]
include/dt-bindings/clock/axg-clkc.h line 75
Quoted 7 lines
include/dt-bindings/clock/axg-clkc.h +1
-0@@ -72,5 +72,6 @@#define CLKID_PCIE_CML_EN1 80#define CLKID_MIPI_ENABLE 81#define CLKID_GEN_CLK 84 +#define CLKID_PCIE_PLL_CML_ENABLE 91
this has to be a separate patch if you want the .dts patch to go into the same cycle
the .dts change depends on this one. what we typically do is to apply the dt-bindings patches to a separate clock branch, create an immutable tag and then Kevin pulls that into his dt64 branch. the clock controller changes go into a separate patch in the clk-meson/drivers branch to avoid conflicts with other driver changes
Martin
PATCH 2/2 PCI: amlogic: Use PCIe pll gate when available
In reply to Remi PommarelIn order to get PCIe working reliably on some AXG platforms, PCIe pll cml needs to be enabled. This is done by using the PCIE_PLL_CML_ENABLE clock gate.
This clock gate is optional, so do not fail if it is missing in the devicetree.
--- drivers/pci/controller/dwc/pci-meson.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/pci/controller/dwc/pci-meson.c +5 -0
@@ -89,6 +89,7 @@ struct meson_pcie_clk_res {struct clk *mipi_gate;struct clk *port_clk;struct clk *general_clk; +struct clk *pll_cml_gate; };struct meson_pcie_rc_reset {
@@ -300,6 +301,10 @@ static int meson_pcie_probe_clocks(struct meson_pcie *mp)if (IS_ERR (res->clk))return PTR_ERR (res->clk); + res->pll_cml_gate =meson_pcie_probe_clock (dev,"pll_cml_en" ,0 ); +if (IS_ERR (res->pll_cml_gate)) + res->pll_cml_gate =NULL ; +return 0 ; }
Signature · 1 line
2.24.0
Re: [PATCH 2/2] PCI: amlogic: Use PCIe pll gate when available
Quoted 3 lines · Remi Pommarel
In order to get PCIe working reliably on some AXG platforms, PCIe pll cml needs to be enabled. This is done by using the
PCIE_PLL_CML_ENABLEclock gate.
s/cml/CML/
In addition to Jerome's feedback - it would also be helpful to explain when CML outputs should be enabled, i.e. which platforms and why those ones?
Quoted 3 lines
This clock gate is optional, so do not fail if it is missing in the devicetree.
If certain platforms require PCIE_PLL_CML_ENABLE to work reliably and thus the clock is specified in the device tree - then surely if there is an error in enabling the clock we should fail? I.e. should you only ignore -ENOENT here?
Thanks,
Andrew Murray
Quoted 32 lines
Signed-off-by Remi Pommarel <[email protected]>--- drivers/pci/controller/dwc/pci-meson.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/pci/controller/dwc/pci-meson.c +5
-0@@ -89,6 +89,7 @@ struct meson_pcie_clk_res {struct clk *mipi_gate;struct clk *port_clk;struct clk *general_clk; +struct clk *pll_cml_gate; };struct meson_pcie_rc_reset {@@ -300,6 +301,10 @@ static int meson_pcie_probe_clocks(struct meson_pcie *mp)if (IS_ERR (res->clk))return PTR_ERR (res->clk); + res->pll_cml_gate =meson_pcie_probe_clock (dev,"pll_cml_en" ,0 ); +if (IS_ERR (res->pll_cml_gate)) + res->pll_cml_gate =NULL ; +return 0 ; }Signature · 1 line
2.24.0
Re: [PATCH 2/2] PCI: amlogic: Use PCIe pll gate when available
Quoted 12 lines · Andrew Murray
Quoted 3 lines · Remi Pommarel
In order to get PCIe working reliably on some AXG platforms, PCIe pll cml needs to be enabled. This is done by using the
PCIE_PLL_CML_ENABLEclock gate.s/cml/CML/
In addition to Jerome's feedback - it would also be helpful to explain when CML outputs should be enabled, i.e. which platforms and why those ones?
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
This clock gate is optional, so do not fail if it is missing in the devicetree.
If certain platforms require
PCIE_PLL_CML_ENABLEto work reliably and thus the clock is specified in the device tree - then surely if there is an error in enabling the clock we should fail? I.e. should you only ignore-ENOENThere?
Good point. Will do.
Thanks
Signature · 1 line
Remi
Quoted 37 lines
Thanks,
Andrew Murray
Quoted 32 lines
Signed-off-by Remi Pommarel <[email protected]>--- drivers/pci/controller/dwc/pci-meson.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/pci/controller/dwc/pci-meson.c +5
-0@@ -89,6 +89,7 @@ struct meson_pcie_clk_res {struct clk *mipi_gate;struct clk *port_clk;struct clk *general_clk; +struct clk *pll_cml_gate; };struct meson_pcie_rc_reset {@@ -300,6 +301,10 @@ static int meson_pcie_probe_clocks(struct meson_pcie *mp)if (IS_ERR (res->clk))return PTR_ERR (res->clk); + res->pll_cml_gate =meson_pcie_probe_clock (dev,"pll_cml_en" ,0 ); +if (IS_ERR (res->pll_cml_gate)) + res->pll_cml_gate =NULL ; +return 0 ; }Signature · 1 line
2.24.0
Jerome Brunet
maintainerQuoted 4 lines · Remi Pommarel
PCIe device probing failures have been seen on some AXG platforms and were due to unreliable clock signal output. Setting HHI_MIPI_CNTL0[26] bit solved the problem. After being contacted about this, vendor reported that this bit was linked to PCIe PLL CML output.
Thanks for reporting the problem.
As Martin pointed out, the CML outputs already exist in the AXG clock controller but are handled using HHI_PCIE_PLL_CNTL6. Although incomplete, it seems to be aligned with the datasheet I have (v0.9)
According to the same document, HHI_MIPI_CNTL0 belong to the MIPI Phy. Unfortunately bit 26 is not documented
AFAICT, the clock controller is not appropriate driver to deal with this register/bit
Quoted 10 lines
This serie adds a way to set this bit through AXG clock gating logic. Platforms having this kind of issue could make use of this gating by applying a patch to their devicetree similar to:
clocks = <&clkc
CLKID_USB
&clkcCLKID_MIPI_ENABLE
&clkcCLKID_PCIE_A(quoted diff) +1
-1- &clkc CLKID_PCIE_CML_EN0>; + &clkc CLKID_PCIE_CML_EN0
Review
Quoted 10 lines
(quoted diff) +3
-1+ &clkc CLKID_PCIE_PLL_CML_ENABLE>; clock-names = "pcie_general", "pcie_mipi_en", "pcie", - "port"; + "port", + "pll_cml_en"; resets = <&reset RESET_PCIE_PHY>, <&reset RESET_PCIE_A>, <&reset RESET_PCIE_APB>;
A few remarks for your future patches:
* You need to document any need binding you introduce:
It means that there should have been a patch in Documentation/devicetree/... before using your newclock name in the pcie driver. As Martin pointed out, dt-bindings should be dealt with in their own patches
Quoted 4 lines
Remi Pommarel (2):
clk: meson: axg: add pcie pll cml gating
Whenever possible, patches intended for different maintainers should be sent separately (different series)
Quoted 7 lines
PCI: amlogic: Use PCIe pll gate when available
drivers/clk/meson/axg.c | 3 +++ drivers/clk/meson/axg.h | 2 +- drivers/pci/controller/dwc/pci-meson.c | 5 +++++ include/dt-bindings/clock/axg-clkc.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-)
Quoted 14 lines · Jerome Brunet
Quoted 4 lines · Remi Pommarel
PCIe device probing failures have been seen on some AXG platforms and were due to unreliable clock signal output. Setting HHI_MIPI_CNTL0[26] bit solved the problem. After being contacted about this, vendor reported that this bit was linked to PCIe PLL CML output.
Thanks for reporting the problem.
As Martin pointed out, the CML outputs already exist in the AXG clock controller but are handled using
HHI_PCIE_PLL_CNTL6. Although incomplete, it seems to be aligned with the datasheet I have (v0.9)
Quoted 6 lines
According to the same document,
HHI_MIPI_CNTL0belong to the MIPI Phy. Unfortunately bit 26 is not documentedAFAICT, the clock controller is not appropriate driver to deal with this register/bit
Regarding both @Martin's and your remark.
Unfortunately the documentation I have and vendor feedback are a bit vague to me. I do agree that CLKID_PCIE_PLL_CML_ENABLE is not a proper name for this bit because this register is MIPI related.
Here is the information I got from the vendor [1]. As you can see HHI_MIPI_CNTL0[29] and HHI_MIPI_CNTL0[26] are related together, and HHI_MIPI_CNTL0[29] is implemented in the clock controller as axg_mipi_enable which is why I used this driver for HHI_MIPI_CNTL0[26].
So maybe I could rename this bit to something MIPI related ?
Quoted 31 lines
Quoted 10 lines
This serie adds a way to set this bit through AXG clock gating logic. Platforms having this kind of issue could make use of this gating by applying a patch to their devicetree similar to:
clocks = <&clkc
CLKID_USB
&clkcCLKID_MIPI_ENABLE
&clkcCLKID_PCIE_A(quoted diff) +1
-1- &clkc CLKID_PCIE_CML_EN0>; + &clkc CLKID_PCIE_CML_EN0Review
Quoted 10 lines
(quoted diff) +3
-1+ &clkc CLKID_PCIE_PLL_CML_ENABLE>; clock-names = "pcie_general", "pcie_mipi_en", "pcie", - "port"; + "port", + "pll_cml_en"; resets = <&reset RESET_PCIE_PHY>, <&reset RESET_PCIE_A>, <&reset RESET_PCIE_APB>;A few remarks for your future patches:
* You need to document any need binding you introduce:
It means that there should have been a patch inDocumentation/devicetree/... before using your newclock name in the pcie driver. As Martin pointed out, dt-bindings should be dealt with in their own patchesQuoted 2 lines
Quoted 5 lines
Quoted 2 lines
Remi Pommarel (2):
clk: meson: axg: add pcie pll cml gatingWhenever possible, patches intended for different maintainers should be sent separately (different series)
Thanks, will do both of the above remarks.
Quoted 9 lines
Quoted 8 lines
PCI: amlogic: Use PCIe pll gate when available
drivers/clk/meson/axg.c | 3 +++ drivers/clk/meson/axg.h | 2 +- drivers/pci/controller/dwc/pci-meson.c | 5 +++++ include/dt-bindings/clock/axg-clkc.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-)
Thanks for reviewing this.
[1] https://i.snipboard.io/bHMPeq.jpg
Signature · 1 line
Remi
Martin Blumenstingl
reviewerHi Remi,
Quoted 25 lines · Remi Pommarel
Quoted 14 lines · Jerome Brunet
Quoted 4 lines · Remi Pommarel
PCIe device probing failures have been seen on some AXG platforms and were due to unreliable clock signal output. Setting HHI_MIPI_CNTL0[26] bit solved the problem. After being contacted about this, vendor reported that this bit was linked to PCIe PLL CML output.
Thanks for reporting the problem.
As Martin pointed out, the CML outputs already exist in the AXG clock controller but are handled using
HHI_PCIE_PLL_CNTL6. Although incomplete, it seems to be aligned with the datasheet I have (v0.9)Quoted 6 lines
According to the same document,
HHI_MIPI_CNTL0belong to the MIPI Phy. Unfortunately bit 26 is not documentedAFAICT, the clock controller is not appropriate driver to deal with this register/bit
Regarding both @Martin's and your remark.
Quoted 8 lines
Unfortunately the documentation I have and vendor feedback are a bit vague to me. I do agree that
CLKID_PCIE_PLL_CML_ENABLEis not a proper name for this bit because this register is MIPI related.Here is the information I got from the vendor [1]. As you can see HHI_MIPI_CNTL0[29] and HHI_MIPI_CNTL0[26] are related together, and HHI_MIPI_CNTL0[29] is implemented in the clock controller as
axg_mipi_enablewhich is why I used this driver for HHI_MIPI_CNTL0[26].
I agree, the details you got so far are unfortunately pretty vague (with my knowledge at least)
from my experience Amlogic has very good documentation internally, so I'm sure that more details are available.
Yue Wang (the Amlogic PCIe controller maintainer) is already Cc'ed and I added Jianxin. I hope that they can explain the meaning of bis 26 and 29 in HHI_MIPI_CNTL0 on the AXG SoCs (assuming Remi's contact at Amlogic can't) and how they are related to the PCIe controller (even though they're in a MIPI related register).
Martin
Jerome Brunet
maintainerQuoted 24 lines · Remi Pommarel
Quoted 14 lines · Jerome Brunet
Quoted 4 lines · Remi Pommarel
PCIe device probing failures have been seen on some AXG platforms and were due to unreliable clock signal output. Setting HHI_MIPI_CNTL0[26] bit solved the problem. After being contacted about this, vendor reported that this bit was linked to PCIe PLL CML output.
Thanks for reporting the problem.
As Martin pointed out, the CML outputs already exist in the AXG clock controller but are handled using
HHI_PCIE_PLL_CNTL6. Although incomplete, it seems to be aligned with the datasheet I have (v0.9)Quoted 6 lines
According to the same document,
HHI_MIPI_CNTL0belong to the MIPI Phy. Unfortunately bit 26 is not documentedAFAICT, the clock controller is not appropriate driver to deal with this register/bit
Regarding both @Martin's and your remark.
Quoted 9 lines
Unfortunately the documentation I have and vendor feedback are a bit vague to me. I do agree that
CLKID_PCIE_PLL_CML_ENABLEis not a proper name for this bit because this register is MIPI related.Here is the information I got from the vendor [1]. As you can see HHI_MIPI_CNTL0[29] and HHI_MIPI_CNTL0[26] are related together, and HHI_MIPI_CNTL0[29] is implemented in the clock controller as
axg_mipi_enablewhich is why I used this driver for HHI_MIPI_CNTL0[26].
Seems I should have paid more attention when axg_mipi_enable. Bit 29 is yet another undocumented bit
Quoted 1 line
So maybe I could rename this bit to something MIPI related ?
This register region is simply not part of the main clock controller. The bits in it are not related to this controller but the MIPI PHY. It should not have been mapped in this way to begin with.
I can see how it would be convient to model this with a gate to just flip the bit when needed but it is just wrong.
The documentation says the register are for the MIPI analog PHY, it should be implemented as such and used by the PCIe as needed.
Of course, fixing this (remapping the region and removing axg_mipi_enable) will be a bit messy. If you want to make that MIPI Phy driver, I can help you with the clock part.
Quoted 53 lines
Quoted 32 lines
Quoted 11 lines
This serie adds a way to set this bit through AXG clock gating logic. Platforms having this kind of issue could make use of this gating by applying a patch to their devicetree similar to:
clocks = <&clkc
CLKID_USB
&clkcCLKID_MIPI_ENABLE
&clkcCLKID_PCIE_A(quoted diff) +1
-1- &clkc CLKID_PCIE_CML_EN0>; + &clkc CLKID_PCIE_CML_EN0Review
Quoted 10 lines
(quoted diff) +3
-1+ &clkc CLKID_PCIE_PLL_CML_ENABLE>; clock-names = "pcie_general", "pcie_mipi_en", "pcie", - "port"; + "port", + "pll_cml_en"; resets = <&reset RESET_PCIE_PHY>, <&reset RESET_PCIE_A>, <&reset RESET_PCIE_APB>;A few remarks for your future patches:
* You need to document any need binding you introduce:
It means that there should have been a patch inDocumentation/devicetree/... before using your newclock name in the pcie driver. As Martin pointed out, dt-bindings should be dealt with in their own patchesQuoted 2 lines
Quoted 5 lines
Quoted 2 lines
Remi Pommarel (2):
clk: meson: axg: add pcie pll cml gatingWhenever possible, patches intended for different maintainers should be sent separately (different series)
Thanks, will do both of the above remarks.
Quoted 9 lines
Quoted 8 lines
PCI: amlogic: Use PCIe pll gate when available
drivers/clk/meson/axg.c | 3 +++ drivers/clk/meson/axg.h | 2 +- drivers/pci/controller/dwc/pci-meson.c | 5 +++++ include/dt-bindings/clock/axg-clkc.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-)Thanks for reviewing this.