Re: [v8,3/7] PCI: mediatek-gen3: Add MediaTek Gen3 driver for MT8192
From: Pali Rohár <pali@kernel.org>
Date: 2021-03-29 22:59:34
Also in:
linux-devicetree, linux-mediatek, linux-pci, lkml
On Thursday 18 March 2021 13:48:07 Jianjun Wang wrote:
On Thu, 2021-03-18 at 01:02 +0100, Pali Rohár wrote:quoted
On Saturday 13 March 2021 15:43:14 Jianjun Wang wrote:quoted
On Thu, 2021-03-11 at 13:38 +0100, Pali Rohár wrote:quoted
On Wednesday 24 February 2021 14:11:28 Jianjun Wang wrote:quoted
+ + /* Check if the link is up or not */ + err = readl_poll_timeout(port->base + PCIE_LINK_STATUS_REG, val, + !!(val & PCIE_PORT_LINKUP), 20, + 50 * USEC_PER_MSEC);IIRC, you need to wait at least 100ms after de-asserting PERST# signal as it is required by PCIe specs and also because experiments proved that some Compex wifi cards (e.g. WLE900VX) are not detected if you do not wait this minimal time.Yes, this should be 100ms, I will fix it at next version, thanks for your review.In past Bjorn suggested to use msleep(PCI_PM_D3COLD_WAIT); macro for this step during reviewing aardvark driver. https://lore.kernel.org/linux-pci/20190426161050.GA189964@google.com/ (local) And next iteration used this PCI_PM_D3COLD_WAIT macro instead of 100: https://lore.kernel.org/linux-pci/20190522213351.21366-2-repk@triplefau.lt/ (local)Sure, I will use PCI_PM_D3COLD_WAIT macro instead in the next version. Thanks.
Anyway, now I found out that kernel has functions for this waiting: pcie_wait_for_link_delay() and pcie_wait_for_link() Function is called from pci_bridge_wait_for_secondary_bus(). But in current form it is not usable for native controller drivers. This looks like another candidate for code de-duplication or providing "framework". Lorenzo, as maintainer of native controller drivers, do you have some ideas about providing "framework", common functions or something for avoiding to implement same code patterns in every native controller driver, which is de-facto standard PCIe codepath? Including a way how to export PERST# reset gpio? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel