From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: "Ryder Lee" <ryder.lee@mediatek.com>,
"Jianjun Wang" <jianjun.wang@mediatek.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
linux-pci@vger.kernel.org, linux-mediatek@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 3/4] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()
Date: Fri, 15 Nov 2024 10:15:07 +0100 [thread overview]
Message-ID: <ZzcRG3OInXZ2TP-Z@lore-rh-laptop> (raw)
In-Reply-To: <20241115090231.nwmxl6acspxqflpc@thinkpad>
[-- Attachment #1: Type: text/plain, Size: 3736 bytes --]
> On Sat, Nov 09, 2024 at 10:28:39AM +0100, Lorenzo Bianconi wrote:
> > In order to make the code more readable, move phy and mac reset lines
> > assert/de-assert configuration in .power_up() callback
> > (mtk_pcie_en7581_power_up()/mtk_pcie_power_up()).
> >
>
> I don't understand how moving the code (duplicting it also) makes the code more
> readable. Could you please explain?
Hi Manivannan,
this has been requested by Bjorn in
https://patchwork.kernel.org/project/linux-pci/patch/aca00bd672ee576ad96d279414fc0835ff31f637.1720022580.git.lorenzo@kernel.org/#26110282
>
> > Introduce PCIE_MTK_RESET_TIME_US macro for the time needed to
> > complete PCIe reset on MediaTek controller.
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > drivers/pci/controller/pcie-mediatek-gen3.c | 28 ++++++++++++++++++++--------
> > 1 file changed, 20 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> > index 8c8c733a145634cdbfefd339f4a692f25a6e24de..1ad93d2407810ba873d9a16da96208b3cc0c3011 100644
> > --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> > @@ -120,6 +120,9 @@
> >
> > #define MAX_NUM_PHY_RESETS 3
> >
> > +/* Time in us needed to complete PCIe reset on MediaTek controller */
>
> No need of this comment. Macro name itself is explanatory.
ack, I will fix it.
Regards,
Lorenzo
>
> - Mani
>
> > +#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
> >
> > @@ -867,6 +870,14 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
> > int err;
> > u32 val;
> >
> > + /*
> > + * 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 bulk assert in
> > * mtk_pcie_setup for EN7581 SoC.
> > @@ -941,6 +952,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) {
> > @@ -1013,14 +1033,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
> >
>
> --
> மணிவண்ணன் சதாசிவம்
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2024-11-15 9:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-09 9:28 [PATCH v2 0/4] PCI: mediatek-gen3: mtk_pcie_en7581_power_up() code refactoring Lorenzo Bianconi
2024-11-09 9:28 ` [PATCH v2 1/4] PCI: mediatek-gen3: Add missing reset_control_deassert() for mac_rst in mtk_pcie_en7581_power_up() Lorenzo Bianconi
2024-11-15 8:52 ` Manivannan Sadhasivam
2024-11-09 9:28 ` [PATCH v2 2/4] PCI: mediatek-gen3: rely on clk_bulk_prepare_enable() " Lorenzo Bianconi
2024-11-15 8:59 ` Manivannan Sadhasivam
2024-11-09 9:28 ` [PATCH v2 3/4] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up() Lorenzo Bianconi
2024-11-15 9:02 ` Manivannan Sadhasivam
2024-11-15 9:15 ` Lorenzo Bianconi [this message]
2024-11-15 12:37 ` Manivannan Sadhasivam
2024-11-15 13:15 ` Lorenzo Bianconi
2024-11-09 9:28 ` [PATCH v2 4/4] PCI: mediatek-gen3: Add comment about initialization order in mtk_pcie_en7581_power_up() Lorenzo Bianconi
2024-11-15 9:05 ` Manivannan Sadhasivam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZzcRG3OInXZ2TP-Z@lore-rh-laptop \
--to=lorenzo@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bhelgaas@google.com \
--cc=jianjun.wang@mediatek.com \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=ryder.lee@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).