Skip to content

Commit e4c7dfd

Browse files
LorenzoBianconikwilczynski
authored andcommitted
PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
In order to make the code more readable, the reset_control_bulk_assert() function 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. Link: https://lore.kernel.org/r/20250108-pcie-en7581-fixes-v6-2-21ac939a3b9b@kernel.org Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
1 parent 0e7a622 commit e4c7dfd

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

drivers/pci/controller/pcie-mediatek-gen3.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@
125125

126126
#define MAX_NUM_PHY_RESETS 3
127127

128+
#define PCIE_MTK_RESET_TIME_US 10
129+
128130
/* Time in ms needed to complete PCIe reset on EN7581 SoC */
129131
#define PCIE_EN7581_RESET_TIME_MS 100
130132

@@ -913,9 +915,14 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
913915
u32 val;
914916

915917
/*
916-
* Wait for the time needed to complete the bulk assert in
917-
* mtk_pcie_setup for EN7581 SoC.
918+
* The controller may have been left out of reset by the bootloader
919+
* so make sure that we get a clean start by asserting resets here.
918920
*/
921+
reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
922+
pcie->phy_resets);
923+
reset_control_assert(pcie->mac_reset);
924+
925+
/* Wait for the time needed to complete the reset lines assert. */
919926
mdelay(PCIE_EN7581_RESET_TIME_MS);
920927

921928
err = phy_init(pcie->phy);
@@ -982,6 +989,15 @@ static int mtk_pcie_power_up(struct mtk_gen3_pcie *pcie)
982989
struct device *dev = pcie->dev;
983990
int err;
984991

992+
/*
993+
* The controller may have been left out of reset by the bootloader
994+
* so make sure that we get a clean start by asserting resets here.
995+
*/
996+
reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
997+
pcie->phy_resets);
998+
reset_control_assert(pcie->mac_reset);
999+
usleep_range(PCIE_MTK_RESET_TIME_US, 2 * PCIE_MTK_RESET_TIME_US);
1000+
9851001
/* PHY power on and enable pipe clock */
9861002
err = reset_control_bulk_deassert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
9871003
if (err) {
@@ -1066,14 +1082,6 @@ static int mtk_pcie_setup(struct mtk_gen3_pcie *pcie)
10661082
* counter since the bulk is shared.
10671083
*/
10681084
reset_control_bulk_deassert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
1069-
/*
1070-
* The controller may have been left out of reset by the bootloader
1071-
* so make sure that we get a clean start by asserting resets here.
1072-
*/
1073-
reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
1074-
1075-
reset_control_assert(pcie->mac_reset);
1076-
usleep_range(10, 20);
10771085

10781086
/* Don't touch the hardware registers before power up */
10791087
err = pcie->soc->power_up(pcie);

0 commit comments

Comments
 (0)