* [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring
@ 2024-11-29 23:20 Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up() Lorenzo Bianconi
` (6 more replies)
0 siblings, 7 replies; 12+ messages in thread
From: Lorenzo Bianconi @ 2024-11-29 23:20 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
Minor fixes and code refactoring in mtk_pcie_en7581_power_up() routine
---
Changes in v5:
- fix comment in patch 3/6
- fix commit log in patch 5/6
- Link to v4: https://lore.kernel.org/r/20241118-pcie-en7581-fixes-v4-0-24bb61703ad7@kernel.org
Changes in v4:
- fix comment in patch 4/6
- Link to v3: https://lore.kernel.org/r/20241116-pcie-en7581-fixes-v3-0-f7add3afc27e@kernel.org
Changes in v3:
- add trivial patches 5/6 and 6/6 to the series
- rename err_clk_init in err_clk_prepare_enable
- fix commit log for patches 2/6 and 3/6
- Link to v2: https://lore.kernel.org/r/20241109-pcie-en7581-fixes-v2-0-0ea3a4af994f@kernel.org
Changes in v2:
- added trivial patch 4/4
- improved commit logs and comments
- introduced PCIE_MTK_RESET_TIME_US macro
- Link to v1: https://lore.kernel.org/r/20241107-pcie-en7581-fixes-v1-0-af0c872323c7@kernel.org
---
Lorenzo Bianconi (6):
PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up()
PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() in mtk_pcie_en7581_power_up()
PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
PCI: mediatek-gen3: Add comment about initialization order in mtk_pcie_en7581_power_up()
PCI: mediatek-gen3: Add reset delay in mtk_pcie_en7581_power_up()
PCI: mediatek-gen3: rely on msleep() in mtk_pcie_en7581_power_up()
drivers/clk/clk-en7523.c | 1 -
drivers/pci/controller/pcie-mediatek-gen3.c | 61 ++++++++++++++++++-----------
2 files changed, 38 insertions(+), 24 deletions(-)
---
base-commit: ac9626f643ea9cde795811d924388fa49f2c4c0c
change-id: 20241107-pcie-en7581-fixes-296505fd2353
Best regards,
--
Lorenzo Bianconi <lorenzo@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v5 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up()
2024-11-29 23:20 [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
@ 2024-11-29 23:20 ` Lorenzo Bianconi
2024-12-30 17:57 ` Bjorn Helgaas
2024-11-29 23:20 ` [PATCH v5 2/6] PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() " Lorenzo Bianconi
` (5 subsequent siblings)
6 siblings, 1 reply; 12+ messages in thread
From: Lorenzo Bianconi @ 2024-11-29 23:20 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
Even if this is not a real issue since Airoha EN7581 SoC does not require
the mac reset line, add missing reset_control_deassert() for mac reset
line in mtk_pcie_en7581_power_up() callback.
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index 64ef8ff71b0357b9bf9ad8484095b7aa60c22271..4d1c797a32c236faf79428eb8a83708e9c4f21d8 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -942,6 +942,9 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
*/
mdelay(PCIE_EN7581_RESET_TIME_MS);
+ /* MAC power on and enable transaction layer clocks */
+ reset_control_deassert(pcie->mac_reset);
+
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
@@ -976,6 +979,7 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
err_clk_prepare:
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
+ reset_control_assert(pcie->mac_reset);
reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
err_phy_deassert:
phy_power_off(pcie->phy);
--
2.47.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 2/6] PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() in mtk_pcie_en7581_power_up()
2024-11-29 23:20 [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up() Lorenzo Bianconi
@ 2024-11-29 23:20 ` Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up() Lorenzo Bianconi
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Bianconi @ 2024-11-29 23:20 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
Replace clk_bulk_prepare() and clk_bulk_enable() with
clk_bulk_prepare_enable() in mtk_pcie_en7581_power_up() routine.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index 4d1c797a32c236faf79428eb8a83708e9c4f21d8..3cfcb45d31508142d28d338ff213f70de9b4e608 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -948,12 +948,6 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
- err = clk_bulk_prepare(pcie->num_clks, pcie->clks);
- if (err) {
- dev_err(dev, "failed to prepare clock\n");
- goto err_clk_prepare;
- }
-
val = FIELD_PREP(PCIE_VAL_LN0_DOWNSTREAM, 0x47) |
FIELD_PREP(PCIE_VAL_LN1_DOWNSTREAM, 0x47) |
FIELD_PREP(PCIE_VAL_LN0_UPSTREAM, 0x41) |
@@ -966,17 +960,15 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
FIELD_PREP(PCIE_K_FINETUNE_MAX, 0xf);
writel_relaxed(val, pcie->base + PCIE_PIPE4_PIE8_REG);
- err = clk_bulk_enable(pcie->num_clks, pcie->clks);
+ err = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks);
if (err) {
dev_err(dev, "failed to prepare clock\n");
- goto err_clk_enable;
+ goto err_clk_prepare_enable;
}
return 0;
-err_clk_enable:
- clk_bulk_unprepare(pcie->num_clks, pcie->clks);
-err_clk_prepare:
+err_clk_prepare_enable:
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
reset_control_assert(pcie->mac_reset);
--
2.47.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
2024-11-29 23:20 [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up() Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 2/6] PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() " Lorenzo Bianconi
@ 2024-11-29 23:20 ` Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 4/6] PCI: mediatek-gen3: Add comment about initialization order in mtk_pcie_en7581_power_up() Lorenzo Bianconi
` (3 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Bianconi @ 2024-11-29 23:20 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
In order to make the code more readable, the reset_control_bulk_assert()
for PHY reset lines is moved to make it pair with
reset_control_bulk_deassert() in mtk_pcie_power_up() and
mtk_pcie_en7581_power_up(). The same change is done for
reset_control_assert() used to assert MAC reset line.
Introduce PCIE_MTK_RESET_TIME_US macro for the time needed to
complete PCIe reset on MediaTek controller.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index 3cfcb45d31508142d28d338ff213f70de9b4e608..6c5e1fb16d17de0325d66277e0508b781fe45112 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -125,6 +125,8 @@
#define MAX_NUM_PHY_RESETS 3
+#define PCIE_MTK_RESET_TIME_US 10
+
/* Time in ms needed to complete PCIe reset on EN7581 SoC */
#define PCIE_EN7581_RESET_TIME_MS 100
@@ -913,9 +915,14 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
u32 val;
/*
- * Wait for the time needed to complete the bulk assert in
- * mtk_pcie_setup for EN7581 SoC.
+ * The controller may have been left out of reset by the bootloader
+ * so make sure that we get a clean start by asserting resets here.
*/
+ reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
+ pcie->phy_resets);
+ reset_control_assert(pcie->mac_reset);
+
+ /* Wait for the time needed to complete the reset lines assert. */
mdelay(PCIE_EN7581_RESET_TIME_MS);
err = phy_init(pcie->phy);
@@ -986,6 +993,15 @@ static int mtk_pcie_power_up(struct mtk_gen3_pcie *pcie)
struct device *dev = pcie->dev;
int err;
+ /*
+ * The controller may have been left out of reset by the bootloader
+ * so make sure that we get a clean start by asserting resets here.
+ */
+ reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
+ pcie->phy_resets);
+ reset_control_assert(pcie->mac_reset);
+ usleep_range(PCIE_MTK_RESET_TIME_US, 2 * PCIE_MTK_RESET_TIME_US);
+
/* PHY power on and enable pipe clock */
err = reset_control_bulk_deassert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
if (err) {
@@ -1070,14 +1086,6 @@ static int mtk_pcie_setup(struct mtk_gen3_pcie *pcie)
* counter since the bulk is shared.
*/
reset_control_bulk_deassert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
- /*
- * The controller may have been left out of reset by the bootloader
- * so make sure that we get a clean start by asserting resets here.
- */
- reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
-
- reset_control_assert(pcie->mac_reset);
- usleep_range(10, 20);
/* Don't touch the hardware registers before power up */
err = pcie->soc->power_up(pcie);
--
2.47.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 4/6] PCI: mediatek-gen3: Add comment about initialization order in mtk_pcie_en7581_power_up()
2024-11-29 23:20 [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
` (2 preceding siblings ...)
2024-11-29 23:20 ` [PATCH v5 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up() Lorenzo Bianconi
@ 2024-11-29 23:20 ` Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 5/6] PCI: mediatek-gen3: Add reset delay " Lorenzo Bianconi
` (2 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Bianconi @ 2024-11-29 23:20 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
Add a comment in mtk_pcie_en7581_power_up() to clarify, unlike the other
MediaTek Gen3 controllers, the Airoha EN7581 requires PHY initialization
and power-on before PHY reset deassert.
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index 6c5e1fb16d17de0325d66277e0508b781fe45112..01e8fde96080fa55f6c23c7d1baab6e22c49fcff 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -925,6 +925,10 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
/* Wait for the time needed to complete the reset lines assert. */
mdelay(PCIE_EN7581_RESET_TIME_MS);
+ /*
+ * Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
+ * requires PHY initialization and power-on before PHY reset deassert.
+ */
err = phy_init(pcie->phy);
if (err) {
dev_err(dev, "failed to initialize PHY\n");
--
2.47.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 5/6] PCI: mediatek-gen3: Add reset delay in mtk_pcie_en7581_power_up()
2024-11-29 23:20 [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
` (3 preceding siblings ...)
2024-11-29 23:20 ` [PATCH v5 4/6] PCI: mediatek-gen3: Add comment about initialization order in mtk_pcie_en7581_power_up() Lorenzo Bianconi
@ 2024-11-29 23:20 ` Lorenzo Bianconi
2025-01-03 18:35 ` Bjorn Helgaas
2024-11-29 23:20 ` [PATCH v5 6/6] PCI: mediatek-gen3: rely on msleep() " Lorenzo Bianconi
2024-12-22 21:15 ` [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Krzysztof Wilczyński
6 siblings, 1 reply; 12+ messages in thread
From: Lorenzo Bianconi @ 2024-11-29 23:20 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
causing occasional PCIe link down issues. In order to overcome the
problem, PCIe block is reset using REG_PCI_CONTROL (0x88) and
REG_RESET_CONTROL (0x834) registers available in the clock module
running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
In order to make the code more readable, move the wait for the time
needed to complete the PCIe reset from en7581_pci_enable() to
mtk_pcie_en7581_power_up().
Reduce reset timeout from 250ms to the standard PCIE_T_PVPERL_MS value
(100ms) since it has no impact on the driver behavior.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/clk/clk-en7523.c | 1 -
drivers/pci/controller/pcie-mediatek-gen3.c | 7 +++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
index 22fbea61c3dcc05e63f8fa37e203c62b2a6fe79e..bf9d9594bef8a54316e28e56a1642ecb0562377a 100644
--- a/drivers/clk/clk-en7523.c
+++ b/drivers/clk/clk-en7523.c
@@ -393,7 +393,6 @@ static int en7581_pci_enable(struct clk_hw *hw)
REG_PCI_CONTROL_PERSTOUT;
val = readl(np_base + REG_PCI_CONTROL);
writel(val | mask, np_base + REG_PCI_CONTROL);
- msleep(250);
return 0;
}
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index 01e8fde96080fa55f6c23c7d1baab6e22c49fcff..da01e741ff290464d28e172879520dbe0670cc41 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -977,6 +977,13 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
goto err_clk_prepare_enable;
}
+ /*
+ * Airoha EN7581 performs PCIe reset via clk callabacks since it has a
+ * hw issue with PCIE_PE_RSTB signal. Add wait for the time needed to
+ * complete the PCIe reset.
+ */
+ msleep(PCIE_T_PVPERL_MS);
+
return 0;
err_clk_prepare_enable:
--
2.47.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 6/6] PCI: mediatek-gen3: rely on msleep() in mtk_pcie_en7581_power_up()
2024-11-29 23:20 [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
` (4 preceding siblings ...)
2024-11-29 23:20 ` [PATCH v5 5/6] PCI: mediatek-gen3: Add reset delay " Lorenzo Bianconi
@ 2024-11-29 23:20 ` Lorenzo Bianconi
2024-12-22 21:15 ` [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Krzysztof Wilczyński
6 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Bianconi @ 2024-11-29 23:20 UTC (permalink / raw)
To: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd
Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-clk,
Lorenzo Bianconi
Since mtk_pcie_en7581_power_up() runs in non-atomic context, rely on
msleep() routine instead of mdelay().
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index da01e741ff290464d28e172879520dbe0670cc41..0b4367fe2c3387ac55f4f44d8c2aace4df840a37 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -923,7 +923,7 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
reset_control_assert(pcie->mac_reset);
/* Wait for the time needed to complete the reset lines assert. */
- mdelay(PCIE_EN7581_RESET_TIME_MS);
+ msleep(PCIE_EN7581_RESET_TIME_MS);
/*
* Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
@@ -951,7 +951,7 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
* Wait for the time needed to complete the bulk de-assert above.
* This time is specific for EN7581 SoC.
*/
- mdelay(PCIE_EN7581_RESET_TIME_MS);
+ msleep(PCIE_EN7581_RESET_TIME_MS);
/* MAC power on and enable transaction layer clocks */
reset_control_deassert(pcie->mac_reset);
--
2.47.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring
2024-11-29 23:20 [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
` (5 preceding siblings ...)
2024-11-29 23:20 ` [PATCH v5 6/6] PCI: mediatek-gen3: rely on msleep() " Lorenzo Bianconi
@ 2024-12-22 21:15 ` Krzysztof Wilczyński
6 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Wilczyński @ 2024-12-22 21:15 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi, Manivannan Sadhasivam,
Rob Herring, Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd,
linux-pci, linux-mediatek, linux-arm-kernel, linux-clk
Hello,
> Minor fixes and code refactoring in mtk_pcie_en7581_power_up() routine
Applied to controller/mediatek, thank you!
[01/06] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up()
https://git.kernel.org/pci/pci/c/3b2ea2d9a669
[02/06] PCI: mediatek-gen3: Use clk_bulk_prepare_enable() in mtk_pcie_en7581_power_up()
https://git.kernel.org/pci/pci/c/a28adc4d00b7
[03/06] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
https://git.kernel.org/pci/pci/c/599e5a6bc452
[04/06] PCI: mediatek-gen3: Add comment about initialization order in mtk_pcie_en7581_power_up()
https://git.kernel.org/pci/pci/c/cdd822338f1b
[05/06] PCI: mediatek-gen3: Add reset delay in mtk_pcie_en7581_power_up()
https://git.kernel.org/pci/pci/c/6c042f72a930
[06/06] PCI: mediatek-gen3: Use msleep() in mtk_pcie_en7581_power_up()
https://git.kernel.org/pci/pci/c/90fcb3d015ef
Krzysztof
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up()
2024-11-29 23:20 ` [PATCH v5 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up() Lorenzo Bianconi
@ 2024-12-30 17:57 ` Bjorn Helgaas
2025-01-02 11:21 ` Lorenzo Bianconi
0 siblings, 1 reply; 12+ messages in thread
From: Bjorn Helgaas @ 2024-12-30 17:57 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd,
linux-pci, linux-mediatek, linux-arm-kernel, linux-clk
On Sat, Nov 30, 2024 at 12:20:10AM +0100, Lorenzo Bianconi wrote:
> Even if this is not a real issue since Airoha EN7581 SoC does not require
> the mac reset line, add missing reset_control_deassert() for mac reset
> line in mtk_pcie_en7581_power_up() callback.
s/mac/MAC/ in English text since "mac" is an acronym, not a real word
This doesn't really say why we need this patch.
This adds both assert and deassert, so it doesn't really look like
adding a *missing* deassert.
On EN7581, is mac_reset optional or always absent?
If mac_reset is always absent for EN7581, why add this patch at all?
If it's optional, say so.
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/pci/controller/pcie-mediatek-gen3.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index 64ef8ff71b0357b9bf9ad8484095b7aa60c22271..4d1c797a32c236faf79428eb8a83708e9c4f21d8 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -942,6 +942,9 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> */
> mdelay(PCIE_EN7581_RESET_TIME_MS);
>
> + /* MAC power on and enable transaction layer clocks */
> + reset_control_deassert(pcie->mac_reset);
> +
> pm_runtime_enable(dev);
> pm_runtime_get_sync(dev);
>
> @@ -976,6 +979,7 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> err_clk_prepare:
> pm_runtime_put_sync(dev);
> pm_runtime_disable(dev);
> + reset_control_assert(pcie->mac_reset);
> reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
> err_phy_deassert:
> phy_power_off(pcie->phy);
>
> --
> 2.47.0
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up()
2024-12-30 17:57 ` Bjorn Helgaas
@ 2025-01-02 11:21 ` Lorenzo Bianconi
0 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Bianconi @ 2025-01-02 11:21 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd,
linux-pci, linux-mediatek, linux-arm-kernel, linux-clk
[-- Attachment #1: Type: text/plain, Size: 2745 bytes --]
> On Sat, Nov 30, 2024 at 12:20:10AM +0100, Lorenzo Bianconi wrote:
> > Even if this is not a real issue since Airoha EN7581 SoC does not require
> > the mac reset line, add missing reset_control_deassert() for mac reset
> > line in mtk_pcie_en7581_power_up() callback.
Hi Bjorn,
since this patch is already in Krzysztof's controller/mediatek branch, do you
want to repost the full series or just incremental changes?
>
> s/mac/MAC/ in English text since "mac" is an acronym, not a real word
ack, I will fix it.
>
> This doesn't really say why we need this patch.
>
> This adds both assert and deassert, so it doesn't really look like
> adding a *missing* deassert.
>
> On EN7581, is mac_reset optional or always absent?
AFAIK mac_reset is never used on EN7581. We added it since we were discussing in
[0] to move the reset asssert/deassert callbacks in the same routine (in the
original codeabse we have reset_control_assert(pcie->mac_reset) in mtk_pcie_setup()
and reset_control_deassert(pcie->mac_reset) in mtk_pcie_power_up()).
I think we can remove mac_reset support at all for EN7581. What do you prefer?
Regards,
Lorenzo
[0] https://lore.kernel.org/linux-pci/20241106233123.GA1580663@bhelgaas/
>
> If mac_reset is always absent for EN7581, why add this patch at all?
> If it's optional, say so.
>
> > Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > drivers/pci/controller/pcie-mediatek-gen3.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> > index 64ef8ff71b0357b9bf9ad8484095b7aa60c22271..4d1c797a32c236faf79428eb8a83708e9c4f21d8 100644
> > --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> > @@ -942,6 +942,9 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> > */
> > mdelay(PCIE_EN7581_RESET_TIME_MS);
> >
> > + /* MAC power on and enable transaction layer clocks */
> > + reset_control_deassert(pcie->mac_reset);
> > +
> > pm_runtime_enable(dev);
> > pm_runtime_get_sync(dev);
> >
> > @@ -976,6 +979,7 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> > err_clk_prepare:
> > pm_runtime_put_sync(dev);
> > pm_runtime_disable(dev);
> > + reset_control_assert(pcie->mac_reset);
> > reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
> > err_phy_deassert:
> > phy_power_off(pcie->phy);
> >
> > --
> > 2.47.0
> >
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 5/6] PCI: mediatek-gen3: Add reset delay in mtk_pcie_en7581_power_up()
2024-11-29 23:20 ` [PATCH v5 5/6] PCI: mediatek-gen3: Add reset delay " Lorenzo Bianconi
@ 2025-01-03 18:35 ` Bjorn Helgaas
2025-01-08 9:41 ` Lorenzo Bianconi
0 siblings, 1 reply; 12+ messages in thread
From: Bjorn Helgaas @ 2025-01-03 18:35 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd,
linux-pci, linux-mediatek, linux-arm-kernel, linux-clk
If you repost this series, here are a few comments/typos. Otherwise
we can do the trivial updates on the branch.
In subject: this patch doesn't *add* a delay; it *moves* it.
On Sat, Nov 30, 2024 at 12:20:14AM +0100, Lorenzo Bianconi wrote:
> Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
> causing occasional PCIe link down issues. In order to overcome the
> problem, PCIe block is reset using REG_PCI_CONTROL (0x88) and
> REG_RESET_CONTROL (0x834) registers available in the clock module
> running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
Add parens after clk_bulk_prepare_enable.
> In order to make the code more readable, move the wait for the time
> needed to complete the PCIe reset from en7581_pci_enable() to
> mtk_pcie_en7581_power_up().
> Reduce reset timeout from 250ms to the standard PCIE_T_PVPERL_MS value
> (100ms) since it has no impact on the driver behavior.
>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Acked-by: Stephen Boyd <sboyd@kernel.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/clk/clk-en7523.c | 1 -
> drivers/pci/controller/pcie-mediatek-gen3.c | 7 +++++++
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
> index 22fbea61c3dcc05e63f8fa37e203c62b2a6fe79e..bf9d9594bef8a54316e28e56a1642ecb0562377a 100644
> --- a/drivers/clk/clk-en7523.c
> +++ b/drivers/clk/clk-en7523.c
> @@ -393,7 +393,6 @@ static int en7581_pci_enable(struct clk_hw *hw)
> REG_PCI_CONTROL_PERSTOUT;
> val = readl(np_base + REG_PCI_CONTROL);
> writel(val | mask, np_base + REG_PCI_CONTROL);
> - msleep(250);
>
> return 0;
> }
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index 01e8fde96080fa55f6c23c7d1baab6e22c49fcff..da01e741ff290464d28e172879520dbe0670cc41 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -977,6 +977,13 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> goto err_clk_prepare_enable;
> }
>
> + /*
> + * Airoha EN7581 performs PCIe reset via clk callabacks since it has a
> + * hw issue with PCIE_PE_RSTB signal. Add wait for the time needed to
> + * complete the PCIe reset.
s/callabacks/callbacks/
> + */
> + msleep(PCIE_T_PVPERL_MS);
> +
> return 0;
>
> err_clk_prepare_enable:
>
> --
> 2.47.0
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 5/6] PCI: mediatek-gen3: Add reset delay in mtk_pcie_en7581_power_up()
2025-01-03 18:35 ` Bjorn Helgaas
@ 2025-01-08 9:41 ` Lorenzo Bianconi
0 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Bianconi @ 2025-01-08 9:41 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Ryder Lee, Jianjun Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Philipp Zabel, Matthias Brugger,
AngeloGioacchino Del Regno, Michael Turquette, Stephen Boyd,
linux-pci, linux-mediatek, linux-arm-kernel, linux-clk
[-- Attachment #1: Type: text/plain, Size: 2876 bytes --]
>
> If you repost this series, here are a few comments/typos. Otherwise
> we can do the trivial updates on the branch.
>
> In subject: this patch doesn't *add* a delay; it *moves* it.
ack, I will fix it.
>
> On Sat, Nov 30, 2024 at 12:20:14AM +0100, Lorenzo Bianconi wrote:
> > Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
> > causing occasional PCIe link down issues. In order to overcome the
> > problem, PCIe block is reset using REG_PCI_CONTROL (0x88) and
> > REG_RESET_CONTROL (0x834) registers available in the clock module
> > running clk_bulk_prepare_enable in mtk_pcie_en7581_power_up().
>
> Add parens after clk_bulk_prepare_enable.
ack, I will fix it.
>
> > In order to make the code more readable, move the wait for the time
> > needed to complete the PCIe reset from en7581_pci_enable() to
> > mtk_pcie_en7581_power_up().
> > Reduce reset timeout from 250ms to the standard PCIE_T_PVPERL_MS value
> > (100ms) since it has no impact on the driver behavior.
> >
> > Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> > Acked-by: Stephen Boyd <sboyd@kernel.org>
> > Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > drivers/clk/clk-en7523.c | 1 -
> > drivers/pci/controller/pcie-mediatek-gen3.c | 7 +++++++
> > 2 files changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
> > index 22fbea61c3dcc05e63f8fa37e203c62b2a6fe79e..bf9d9594bef8a54316e28e56a1642ecb0562377a 100644
> > --- a/drivers/clk/clk-en7523.c
> > +++ b/drivers/clk/clk-en7523.c
> > @@ -393,7 +393,6 @@ static int en7581_pci_enable(struct clk_hw *hw)
> > REG_PCI_CONTROL_PERSTOUT;
> > val = readl(np_base + REG_PCI_CONTROL);
> > writel(val | mask, np_base + REG_PCI_CONTROL);
> > - msleep(250);
> >
> > return 0;
> > }
> > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> > index 01e8fde96080fa55f6c23c7d1baab6e22c49fcff..da01e741ff290464d28e172879520dbe0670cc41 100644
> > --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> > @@ -977,6 +977,13 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> > goto err_clk_prepare_enable;
> > }
> >
> > + /*
> > + * Airoha EN7581 performs PCIe reset via clk callabacks since it has a
> > + * hw issue with PCIE_PE_RSTB signal. Add wait for the time needed to
> > + * complete the PCIe reset.
>
> s/callabacks/callbacks/
ack, I will fix it.
Regards,
Lorenzo
>
> > + */
> > + msleep(PCIE_T_PVPERL_MS);
> > +
> > return 0;
> >
> > err_clk_prepare_enable:
> >
> > --
> > 2.47.0
> >
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-01-08 9:54 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-29 23:20 [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 1/6] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up() Lorenzo Bianconi
2024-12-30 17:57 ` Bjorn Helgaas
2025-01-02 11:21 ` Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 2/6] PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() " Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 3/6] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up() Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 4/6] PCI: mediatek-gen3: Add comment about initialization order in mtk_pcie_en7581_power_up() Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 5/6] PCI: mediatek-gen3: Add reset delay " Lorenzo Bianconi
2025-01-03 18:35 ` Bjorn Helgaas
2025-01-08 9:41 ` Lorenzo Bianconi
2024-11-29 23:20 ` [PATCH v5 6/6] PCI: mediatek-gen3: rely on msleep() " Lorenzo Bianconi
2024-12-22 21:15 ` [PATCH v5 0/6] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Krzysztof Wilczyński
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.