pci.h: move include into own wrapper

Split the include of hwaccess and libpci. There is no need to have pci.h
included in hwaccess.

Change-Id: Ibf00356f0ef5cc92e0ec99f8fe5cdda56f47b166
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/58883
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72264
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/amd_imc.c b/amd_imc.c
index a692199..d995d4d 100644
--- a/amd_imc.c
+++ b/amd_imc.c
@@ -19,6 +19,7 @@
 #include "programmer.h"
 #include "hwaccess.h"
 #include "spi.h"
+#include "platform/pci.h"
 
 /* same as serverengines */
 static void enter_conf_mode_ec(uint16_t port)
diff --git a/atahpt.c b/atahpt.c
index 5181e2d..f124eee 100644
--- a/atahpt.c
+++ b/atahpt.c
@@ -19,6 +19,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define BIOS_ROM_ADDR		0x90
 #define BIOS_ROM_DATA		0x94
diff --git a/atapromise.c b/atapromise.c
index cd7bca4..75448e6 100644
--- a/atapromise.c
+++ b/atapromise.c
@@ -19,6 +19,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define MAX_ROM_DECODE (32 * 1024)
 #define ADDR_MASK (MAX_ROM_DECODE - 1)
diff --git a/atavia.c b/atavia.c
index 45593f6..6a8ec1f 100644
--- a/atavia.c
+++ b/atavia.c
@@ -21,6 +21,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define PCI_VENDOR_ID_VIA	0x1106
 
diff --git a/board_enable.c b/board_enable.c
index 959b49d..6f447c2 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -27,6 +27,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #if defined(__i386__) || defined(__x86_64__)
 /*
diff --git a/chipset_enable.c b/chipset_enable.c
index f052685..2e9da55 100644
--- a/chipset_enable.c
+++ b/chipset_enable.c
@@ -35,6 +35,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define NOT_DONE_YET 1
 
diff --git a/drkaiser.c b/drkaiser.c
index 7ae73ab..8d5937c 100644
--- a/drkaiser.c
+++ b/drkaiser.c
@@ -18,6 +18,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define PCI_VENDOR_ID_DRKAISER		0x1803
 
diff --git a/gfxnvidia.c b/gfxnvidia.c
index 85d6d71..1bf656c 100644
--- a/gfxnvidia.c
+++ b/gfxnvidia.c
@@ -20,6 +20,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define PCI_VENDOR_ID_NVIDIA	0x10de
 
diff --git a/hwaccess.h b/hwaccess.h
index 97fc14a..e5edcfa 100644
--- a/hwaccess.h
+++ b/hwaccess.h
@@ -20,23 +20,6 @@
 #ifndef __HWACCESS_H__
 #define __HWACCESS_H__ 1
 
-#if NEED_PCI == 1
-/*
- * libpci headers use the variable name "index" which triggers shadowing
- * warnings on systems which have the index() function in a default #include
- * or as builtin.
- */
-#define index shadow_workaround_index
-
-#if !defined (PCIUTILS_PCI_H)
-#include <pci/pci.h>
-#else
-#include <pciutils/pci.h>
-#endif
-
-#undef index
-#endif /* NEED_PCI == 1 */
-
 void mmio_writeb(uint8_t val, void *addr);
 void mmio_writew(uint16_t val, void *addr);
 void mmio_writel(uint32_t val, void *addr);
diff --git a/internal.c b/internal.c
index 9cd9cf7..1c4b66a 100644
--- a/internal.c
+++ b/internal.c
@@ -20,6 +20,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass)
 {
diff --git a/it8212.c b/it8212.c
index 805582b..f7b27cb 100644
--- a/it8212.c
+++ b/it8212.c
@@ -18,6 +18,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 static uint8_t *it8212_bar = NULL;
 
diff --git a/mcp6x_spi.c b/mcp6x_spi.c
index 15122af..7444631 100644
--- a/mcp6x_spi.c
+++ b/mcp6x_spi.c
@@ -24,6 +24,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 /* Bit positions for each pin. */
 
diff --git a/nic3com.c b/nic3com.c
index c03692e..dde0330 100644
--- a/nic3com.c
+++ b/nic3com.c
@@ -18,6 +18,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define BIOS_ROM_ADDR		0x04
 #define BIOS_ROM_DATA		0x08
diff --git a/nicintel.c b/nicintel.c
index b3f24a3..4327112 100644
--- a/nicintel.c
+++ b/nicintel.c
@@ -19,6 +19,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 static uint8_t *nicintel_bar;
 static uint8_t *nicintel_control_bar;
diff --git a/nicintel_eeprom.c b/nicintel_eeprom.c
index a8b9333..c52ed37 100644
--- a/nicintel_eeprom.c
+++ b/nicintel_eeprom.c
@@ -35,6 +35,7 @@
 #include "spi.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define PCI_VENDOR_ID_INTEL 0x8086
 #define MEMMAP_SIZE 0x1c /* Only EEC, EERD and EEWR are needed. */
diff --git a/nicintel_spi.c b/nicintel_spi.c
index d487161..66c24a7 100644
--- a/nicintel_spi.c
+++ b/nicintel_spi.c
@@ -35,6 +35,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define PCI_VENDOR_ID_INTEL 0x8086
 #define MEMMAP_SIZE getpagesize()
diff --git a/nicnatsemi.c b/nicnatsemi.c
index b4c3431..933d3a9 100644
--- a/nicnatsemi.c
+++ b/nicnatsemi.c
@@ -18,6 +18,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define PCI_VENDOR_ID_NATSEMI	0x100b
 
diff --git a/nicrealtek.c b/nicrealtek.c
index 3957e9f..e8616fd 100644
--- a/nicrealtek.c
+++ b/nicrealtek.c
@@ -18,6 +18,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define PCI_VENDOR_ID_REALTEK	0x10ec
 #define PCI_VENDOR_ID_SMC1211	0x1113
diff --git a/ogp_spi.c b/ogp_spi.c
index d9e47fa..31f7b8d 100644
--- a/ogp_spi.c
+++ b/ogp_spi.c
@@ -19,6 +19,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define PCI_VENDOR_ID_OGP 0x1227
 
diff --git a/pcidev.c b/pcidev.c
index 2c6bbed..1ec6455 100644
--- a/pcidev.c
+++ b/pcidev.c
@@ -19,7 +19,7 @@
 #include <string.h>
 #include "flash.h"
 #include "programmer.h"
-#include "hwaccess.h"
+#include "platform/pci.h"
 
 struct pci_access *pacc;
 
diff --git a/platform/pci.h b/platform/pci.h
new file mode 100644
index 0000000..fdb0f48
--- /dev/null
+++ b/platform/pci.h
@@ -0,0 +1,25 @@
+/*
+ * This is a wrapper for libpci.
+ * ...
+ */
+
+
+#ifndef __PLATFORM_PCI_H__
+#define __PLATFORM_PCI_H__
+
+/*
+ * An old libpci version seems to use the variable name "index" which triggers
+ * shadowing warnings on systems which have the index() function in a default
+ * #include or as builtin.
+ */
+#define index shadow_workaround_index
+
+#if defined (PCIUTILS_PCI_H)
+#include <pciutils/pci.h>
+#else
+#include <pci/pci.h>
+#endif
+
+#undef index
+
+#endif /* __PLATFORM_PCI_H__ */
diff --git a/satamv.c b/satamv.c
index 2583e29..f824d87 100644
--- a/satamv.c
+++ b/satamv.c
@@ -20,6 +20,7 @@
 #include "flash.h"
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 static uint8_t *mv_bar;
 static uint16_t mv_iobar;
diff --git a/satasii.c b/satasii.c
index 4b13e90..6ab574a 100644
--- a/satasii.c
+++ b/satasii.c
@@ -18,6 +18,7 @@
 
 #include "programmer.h"
 #include "hwaccess.h"
+#include "platform/pci.h"
 
 #define PCI_VENDOR_ID_SII	0x1095
 
diff --git a/sb600spi.c b/sb600spi.c
index c51f0ce..d0bf68f 100644
--- a/sb600spi.c
+++ b/sb600spi.c
@@ -25,6 +25,7 @@
 #include "programmer.h"
 #include "hwaccess.h"
 #include "spi.h"
+#include "platform/pci.h"
 
 /* This struct is unused, but helps visualize the SB600 SPI BAR layout.
  *struct sb600_spi_controller {