From: "Pali Rohár" <pali@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH 2/2] arm64: a37xx: pci: Assert PERST# signal when unloading driver
Date: Wed, 19 Aug 2020 15:57:07 +0200 [thread overview]
Message-ID: <20200819135707.15486-2-pali@kernel.org> (raw)
In-Reply-To: <20200819135707.15486-1-pali@kernel.org>
This change ensures that PCIe card is put into reset state when U-Boot
stops using it.
DM_FLAG_OS_PREPARE ensures that U-Boot executes driver's remove callback
prior booting Linux kernel.
Linux kernel pci-aardvark driver needs to reset PCIe card via PERST# signal
prior initializing it. If it does not issue reset then some PCIe cards
(specially Compex WiFi cards) are not detected at all.
Putting PCIe card into reset state prior booting Linux kernel would ensure
that card would be properly reset at time when Linux kernel starts
initializing pci-aardvark driver.
Signed-off-by: Pali Roh?r <pali@kernel.org>
---
drivers/pci/pci-aardvark.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/pci-aardvark.c b/drivers/pci/pci-aardvark.c
index 5b3f23c184..8996be5309 100644
--- a/drivers/pci/pci-aardvark.c
+++ b/drivers/pci/pci-aardvark.c
@@ -148,6 +148,9 @@ struct pcie_advk {
void *base;
int first_busno;
struct udevice *dev;
+#if CONFIG_IS_ENABLED(DM_GPIO)
+ struct gpio_desc reset_gpio;
+#endif
};
static inline void advk_writel(struct pcie_advk *pcie, uint val, uint reg)
@@ -614,9 +617,7 @@ static int pcie_advk_probe(struct udevice *dev)
struct pcie_advk *pcie = dev_get_priv(dev);
#if CONFIG_IS_ENABLED(DM_GPIO)
- struct gpio_desc reset_gpio;
-
- gpio_request_by_name(dev, "reset-gpios", 0, &reset_gpio,
+ gpio_request_by_name(dev, "reset-gpios", 0, &pcie->reset_gpio,
GPIOD_IS_OUT);
/*
* Issue reset to add-in card through the dedicated GPIO.
@@ -631,11 +632,11 @@ static int pcie_advk_probe(struct udevice *dev)
* possible before PCIe PHY initialization. Moreover, the PCIe
* clock should be gated as well.
*/
- if (dm_gpio_is_valid(&reset_gpio)) {
+ if (dm_gpio_is_valid(&pcie->reset_gpio)) {
dev_dbg(pcie->dev, "Toggle PCIE Reset GPIO ...\n");
- dm_gpio_set_value(&reset_gpio, 1);
+ dm_gpio_set_value(&pcie->reset_gpio, 1);
mdelay(200);
- dm_gpio_set_value(&reset_gpio, 0);
+ dm_gpio_set_value(&pcie->reset_gpio, 0);
}
#else
dev_dbg(pcie->dev, "PCIE Reset on GPIO support is missing\n");
@@ -647,6 +648,18 @@ static int pcie_advk_probe(struct udevice *dev)
return pcie_advk_setup_hw(pcie);
}
+static int pcie_advk_remove(struct udevice *dev)
+{
+#if CONFIG_IS_ENABLED(DM_GPIO)
+ struct pcie_advk *pcie = dev_get_priv(dev);
+
+ if (dm_gpio_is_valid(&pcie->reset_gpio))
+ dm_gpio_set_value(&pcie->reset_gpio, 1);
+#endif /* DM_GPIO */
+
+ return 0;
+}
+
/**
* pcie_advk_ofdata_to_platdata() - Translate from DT to device state
*
@@ -687,5 +700,7 @@ U_BOOT_DRIVER(pcie_advk) = {
.ops = &pcie_advk_ops,
.ofdata_to_platdata = pcie_advk_ofdata_to_platdata,
.probe = pcie_advk_probe,
+ .remove = pcie_advk_remove,
+ .flags = DM_FLAG_OS_PREPARE,
.priv_auto_alloc_size = sizeof(struct pcie_advk),
};
--
2.20.1
next prev parent reply other threads:[~2020-08-19 13:57 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-19 13:57 [PATCH 1/2] arm64: a37xx: pci: Make PCIe Reset GPIO DT compatible with Linux kernel DT Pali Rohár
2020-08-19 13:57 ` Pali Rohár [this message]
2020-08-19 17:31 ` [EXT] [PATCH 2/2] arm64: a37xx: pci: Assert PERST# signal when unloading driver Kostya Porotchkin
2020-08-20 7:53 ` Stefan Roese
2020-08-20 5:05 ` Stefan Roese
2020-08-20 7:43 ` Pali Rohár
2020-08-20 7:48 ` Stefan Roese
2020-08-20 7:52 ` Pali Rohár
2020-08-20 8:00 ` Stefan Roese
2020-08-25 8:46 ` Pali Rohár
2020-08-25 9:03 ` Stefan Roese
2020-08-20 8:06 ` [EXT] " Kostya Porotchkin
2020-08-27 16:27 ` Andre Heider
2020-08-31 13:03 ` Stefan Roese
2020-08-19 17:28 ` [EXT] [PATCH 1/2] arm64: a37xx: pci: Make PCIe Reset GPIO DT compatible with Linux kernel DT Kostya Porotchkin
2020-08-20 5:09 ` Stefan Roese
2020-08-20 5:03 ` Stefan Roese
2020-08-20 7:35 ` [EXT] " Kostya Porotchkin
2020-08-25 8:45 ` [PATCH] arm64: a37xx: pci: Depends on DM_GPIO Pali Rohár
2020-08-25 9:03 ` Stefan Roese
2020-08-27 16:27 ` Andre Heider
2020-08-31 13:05 ` Stefan Roese
2020-08-27 16:27 ` [PATCH 1/2] arm64: a37xx: pci: Make PCIe Reset GPIO DT compatible with Linux kernel DT Andre Heider
2020-08-31 13:03 ` Stefan Roese
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=20200819135707.15486-2-pali@kernel.org \
--to=pali@kernel.org \
--cc=u-boot@lists.denx.de \
/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