Skip to contentSkip to conversation

imx: ventana: Add pci fixup for PLX switch

PATCH New Tim Harvey 2 participants 7 messages Aug 8, 2014 – Sep 9, 2014 PCI

lore
Share & tools
lore

Tim Harvey

author
#0 lore raw

cover imx: ventana: Add pci fixup for PLX switch

Many of the Gateworks Ventana boards have a PLX PCIe switch where GPIO on the switch is used as the PERST# of the downstream ports. In the Linux kernel there is a PCI fixup that asserts these properly when the upstream port is enumerated.

The first patch in this serial adds a board_pci_fixup_dev function define to allow hooking similarly to the kernel pci fixup functionality.

The second patch uses the board_pci_fixup_dev function to perform the GPIO configuration on the switch for the downstream ports.

Tim Harvey (2):
pci: add support for board_pci_fixup_dev function
imx: ventana: add pci fixup for PLX PEX860x switch GPIO

 board/gateworks/gw_ventana/gw_ventana.c | 30 ++++++++++++++++++++++++++++++
 drivers/pci/pci.c                       |  4 ++++
 include/configs/gw_ventana.h            |  1 +
 include/pci.h                           |  7 +++++++
 4 files changed, 42 insertions(+)
Signature · 1 line
1.8.3.2
author
#1 lore raw

PATCH 1/2 pci: add support for board_pci_fixup_dev function

Some board-level drivers may wish to have per-device fixup functions for PCI devices.

---
 drivers/pci/pci.c | 4 ++++
 include/pci.h     | 7 +++++++
 2 files changed, 11 insertions(+)
drivers/pci/pci.c +4 -0
index ed113bf..e269468 100644
@@ -648,6 +648,10 @@ int pci_hose_scan_bus(struct pci_controller *hose, int bus)
 		pci_hose_read_config_word(hose, dev, PCI_DEVICE_ID, &device);
 		pci_hose_read_config_word(hose, dev, PCI_CLASS_DEVICE, &class);
 
+#ifdef CONFIG_PCI_FIXUP_DEV
+		board_pci_fixup_dev(hose, dev, vendor, device, class);
+#endif
+
 #ifdef CONFIG_PCI_SCAN_SHOW
 		indent++;
 
include/pci.h +7 -0
index 461f17c..2ff7365 100644
@@ -659,6 +659,13 @@ extern int pci_hose_find_cap_start(struct pci_controller *hose, pci_dev_t dev,
 extern int pci_find_cap(struct pci_controller *hose, pci_dev_t dev, int pos,
 			int cap);
 
+#ifdef CONFIG_PCI_FIXUP_DEV
+extern void board_pci_fixup_dev(struct pci_controller *hose, pci_dev_t dev,
+				unsigned short vendor,
+				unsigned short device,
+				unsigned short class);
+#endif
+
 const char * pci_class_str(u8 class);
 int pci_last_busno(void);
 
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH 1/2 pci: add support for board_pci_fixup_dev function

Hi Tim,

Quoted 5 lines · Tim Harvey

Some board-level drivers may wish to have per-device fixup functions for PCI devices.

---

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
author
#3 lore raw

PATCH 2/2 imx: ventana: add pci fixup for PLX PEX860x switch GPIO

In reply to Tim Harvey

Most Gateworks Ventana boards use a PLX PEX860x PCIe switch for PCIe expansion. These boards use GPIO on the PLX device as PERST# for the downstream ports thus we assert this when the PLX is enumerated.

---
 board/gateworks/gw_ventana/gw_ventana.c | 30 ++++++++++++++++++++++++++++++
 include/configs/gw_ventana.h            |  1 +
 2 files changed, 31 insertions(+)
board/gateworks/gw_ventana/gw_ventana.c +30 -0
index 70b90d8..186cd38 100644
@@ -31,6 +31,7 @@
 #include <mmc.h>
 #include <mtd_node.h>
 #include <netdev.h>
+#include <pci.h>
 #include <power/pmic.h>
 #include <power/ltc3676_pmic.h>
 #include <power/pfuze100_pmic.h>
@@ -1092,6 +1093,35 @@ int imx6_pcie_toggle_reset(void)
 	}
 	return 0;
 }
+
+/*
+ * Most Ventana boards have a PLX PEX860x PCIe switch onboard and use its
+ * GPIO's as PERST# signals for its downstream ports - configure the GPIO's
+ * properly and assert reset for 100ms.
+ */
+void board_pci_fixup_dev(struct pci_controller *hose, pci_dev_t dev,
+			 unsigned short vendor, unsigned short device,
+			 unsigned short class)
+{
+	u32 dw;
+
+	debug("%s: %02d:%02d.%02d: %04x:%04x\n", __func__,
+	      PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev), vendor, device);
+	if (vendor == PCI_VENDOR_ID_PLX &&
+	    (device & 0xfff0) == 0x8600 &&
+	    PCI_DEV(dev) == 0 && PCI_FUNC(dev) == 0) {
+		debug("configuring PLX 860X downstream PERST#\n");
+		pci_hose_read_config_dword(hose, dev, 0x62c, &dw);
+		dw |= 0xaaa8; /* GPIO1-7 outputs */
+		pci_hose_write_config_dword(hose, dev, 0x62c, dw);
+
+		pci_hose_read_config_dword(hose, dev, 0x644, &dw);
+		dw |= 0xfe;   /* GPIO1-7 output high */
+		pci_hose_write_config_dword(hose, dev, 0x644, dw);
+
+		mdelay(100);
+	}
+}
 #endif /* CONFIG_CMD_PCI */
 
 #ifdef CONFIG_SERIAL_TAG
include/configs/gw_ventana.h +1 -0
index b991b09..0e5c200 100644
@@ -141,6 +141,7 @@
 #define CONFIG_PCI
 #define CONFIG_PCI_PNP
 #define CONFIG_PCI_SCAN_SHOW
+#define CONFIG_PCI_FIXUP_DEV
 #define CONFIG_PCIE_IMX
 #endif
 
Signature · 1 line
1.8.3.2
#4 lore raw

PATCH 2/2 imx: ventana: add pci fixup for PLX PEX860x switch GPIO

Hi Tim,

Quoted 6 lines · Tim Harvey

Most Gateworks Ventana boards use a PLX PEX860x PCIe switch for PCIe expansion. These boards use GPIO on the PLX device as PERST# for the downstream ports thus we assert this when the PLX is enumerated.

---

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
author
#5 lore raw

cover imx: ventana: Add pci fixup for PLX switch

In reply to Tim Harvey
Quoted 15 lines · Tim Harvey

Many of the Gateworks Ventana boards have a PLX PCIe switch where GPIO on the switch is used as the PERST# of the downstream ports. In the Linux kernel there is a PCI fixup that asserts these properly when the upstream port is enumerated.

The first patch in this serial adds a board_pci_fixup_dev function define to allow hooking similarly to the kernel pci fixup functionality.

The second patch uses the board_pci_fixup_dev function to perform the GPIO configuration on the switch for the downstream ports.

Tim Harvey (2):
pci: add support for board_pci_fixup_dev function
imx: ventana: add pci fixup for PLX PEX860x switch GPIO

Quoted 9 lines
 board/gateworks/gw_ventana/gw_ventana.c | 30 ++++++++++++++++++++++++++++++
 drivers/pci/pci.c                       |  4 ++++
 include/configs/gw_ventana.h            |  1 +
 include/pci.h                           |  7 +++++++
 4 files changed, 42 insertions(+)

--
1.8.3.2

Any comments on these? I'm wondering if there is someone else I should be including with regards to reviewing pci changes.

Regards,

Tim

#6 lore raw

cover imx: ventana: Add pci fixup for PLX switch

Quoted 22 lines · Tim Harvey
Quoted 21 lines · Tim Harvey

Many of the Gateworks Ventana boards have a PLX PCIe switch where GPIO on the switch is used as the PERST# of the downstream ports. In the Linux kernel there is a PCI fixup that asserts these properly when the upstream port is enumerated.

The first patch in this serial adds a board_pci_fixup_dev function define to allow hooking similarly to the kernel pci fixup functionality.

The second patch uses the board_pci_fixup_dev function to perform the GPIO configuration on the switch for the downstream ports.

Tim Harvey (2):
pci: add support for board_pci_fixup_dev function
imx: ventana: add pci fixup for PLX PEX860x switch GPIO

 board/gateworks/gw_ventana/gw_ventana.c | 30 ++++++++++++++++++++++++++++++
 drivers/pci/pci.c                       |  4 ++++
 include/configs/gw_ventana.h            |  1 +
 include/pci.h                           |  7 +++++++
 4 files changed, 42 insertions(+)
Quoted 7 lines
Quoted 3 lines

--
1.8.3.2

Any comments on these? I'm wondering if there is someone else I should be including with regards to reviewing pci changes.

No comment, and I do not see any bad influence on other boards - I am going to apply them.

Regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================