diff mbox series

[u-boot-next,06/12] pci: tegra: Use PCI_CONF1_EXT_ADDRESS() macro

Message ID 20211126104252.5443-7-pali@kernel.org
State Accepted
Commit 86be29e9d985b57e03e2eede6394e0c1edc6660a
Delegated to: Tom Rini
Headers show
Series Common U-Boot macros for PCI Configuration Mechanism #1 | expand

Commit Message

Pali Rohár Nov. 26, 2021, 10:42 a.m. UTC
PCI tegra driver uses extended format of Config Address for PCI
Configuration Mechanism #1 but with cleared Enable bit.

So use new U-Boot macro PCI_CONF1_EXT_ADDRESS() with clearing
PCI_CONF1_ENABLE bit and remove old custom driver address function.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 drivers/pci/pci_tegra.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Simon Glass Dec. 28, 2021, 8:32 a.m. UTC | #1
On Fri, 26 Nov 2021 at 03:43, Pali Rohár <pali@kernel.org> wrote:
>
> PCI tegra driver uses extended format of Config Address for PCI
> Configuration Mechanism #1 but with cleared Enable bit.
>
> So use new U-Boot macro PCI_CONF1_EXT_ADDRESS() with clearing
> PCI_CONF1_ENABLE bit and remove old custom driver address function.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
> ---
>  drivers/pci/pci_tegra.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Jan. 13, 2022, 1:51 a.m. UTC | #2
On Fri, Nov 26, 2021 at 11:42:46AM +0100, Pali Rohár wrote:

> PCI tegra driver uses extended format of Config Address for PCI
> Configuration Mechanism #1 but with cleared Enable bit.
> 
> So use new U-Boot macro PCI_CONF1_EXT_ADDRESS() with clearing
> PCI_CONF1_ENABLE bit and remove old custom driver address function.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/pci/pci_tegra.c b/drivers/pci/pci_tegra.c
index 9cb4414836f8..fc05ee00f1fc 100644
--- a/drivers/pci/pci_tegra.c
+++ b/drivers/pci/pci_tegra.c
@@ -275,13 +275,6 @@  static void rp_writel(struct tegra_pcie_port *port, unsigned long value,
 	writel(value, port->regs.start + offset);
 }
 
-static unsigned long tegra_pcie_conf_offset(pci_dev_t bdf, int where)
-{
-	return ((where & 0xf00) << 16) | (PCI_BUS(bdf) << 16) |
-	       (PCI_DEV(bdf) << 11) | (PCI_FUNC(bdf) << 8) |
-	       (where & 0xfc);
-}
-
 static int tegra_pcie_conf_address(struct tegra_pcie *pcie, pci_dev_t bdf,
 				   int where, unsigned long *address)
 {
@@ -305,7 +298,9 @@  static int tegra_pcie_conf_address(struct tegra_pcie *pcie, pci_dev_t bdf,
 			return -EFAULT;
 #endif
 
-		*address = pcie->cs.start + tegra_pcie_conf_offset(bdf, where);
+		*address = pcie->cs.start +
+			   (PCI_CONF1_EXT_ADDRESS(PCI_BUS(bdf), PCI_DEV(bdf),
+			    PCI_FUNC(bdf), where) & ~PCI_CONF1_ENABLE);
 		return 0;
 	}
 }