1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 15:12:36 +02:00

pcidev: Move pci_dev_find() from internal to canonical place

Also rename to `pcidev_find()` in fitting with pcidev.c helpers.

BUG=b:220950271
TEST=```sudo ./flashrom -p internal -r /tmp/bios
<snip>
Found Programmer flash chip "Opaque flash chip" (16384 kB, Programmer-specific) mapped at physical address 0x0000000000000000.
Reading flash... done.
```

Change-Id: Ie21f87699481a84398ca4450b3f03548f0528191
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/59280
Reviewed-by: Thomas Heijligen <src@posteo.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Edward O'Callaghan 2021-11-13 17:59:18 +11:00 committed by Edward O'Callaghan
parent 855b898331
commit 1b1066e2d5
6 changed files with 32 additions and 33 deletions

View File

@ -893,7 +893,7 @@ static int board_asus_p3b_f(void)
uint16_t smbba; uint16_t smbba;
uint8_t b; uint8_t b;
dev = pci_dev_find(0x8086, 0x7113); /* Intel PIIX4, PM/SMBus function. */ dev = pcidev_find(0x8086, 0x7113); /* Intel PIIX4, PM/SMBus function. */
if (!dev) { if (!dev) {
msg_perr("\nERROR: Intel PIIX4 PM not found.\n"); msg_perr("\nERROR: Intel PIIX4 PM not found.\n");
return -1; return -1;
@ -1045,7 +1045,7 @@ static int board_ecs_geforce6100sm_m(void)
struct pci_dev *dev; struct pci_dev *dev;
uint32_t tmp; uint32_t tmp;
dev = pci_dev_find(0x10DE, 0x03EB); /* NVIDIA MCP61 SMBus. */ dev = pcidev_find(0x10DE, 0x03EB); /* NVIDIA MCP61 SMBus. */
if (!dev) { if (!dev) {
msg_perr("\nERROR: NVIDIA MCP61 SMBus not found.\n"); msg_perr("\nERROR: NVIDIA MCP61 SMBus not found.\n");
return -1; return -1;
@ -1273,7 +1273,7 @@ static int board_sun_ultra_40_m2(void)
if (ret) if (ret)
return ret; return ret;
dev = pci_dev_find(0x10de, 0x0364); /* NVIDIA MCP55 LPC bridge */ dev = pcidev_find(0x10de, 0x0364); /* NVIDIA MCP55 LPC bridge */
if (!dev) { if (!dev) {
msg_perr("\nERROR: NVIDIA MCP55 LPC bridge not found.\n"); msg_perr("\nERROR: NVIDIA MCP55 LPC bridge not found.\n");
return -1; return -1;
@ -1343,7 +1343,7 @@ static int amd_sbxxx_gpio9_raise(void)
struct pci_dev *dev; struct pci_dev *dev;
uint32_t reg; uint32_t reg;
dev = pci_dev_find(0x1002, 0x4372); /* AMD SMBus controller */ dev = pcidev_find(0x1002, 0x4372); /* AMD SMBus controller */
if (!dev) { if (!dev) {
msg_perr("\nERROR: AMD SMBus Controller (0x4372) not found.\n"); msg_perr("\nERROR: AMD SMBus Controller (0x4372) not found.\n");
return -1; return -1;
@ -1407,7 +1407,7 @@ static int intel_piix4_gpo_set(unsigned int gpo, int raise)
{0} {0}
}; };
dev = pci_dev_find(0x8086, 0x7110); /* Intel PIIX4 ISA bridge */ dev = pcidev_find(0x8086, 0x7110); /* Intel PIIX4 ISA bridge */
if (!dev) { if (!dev) {
msg_perr("\nERROR: Intel PIIX4 ISA bridge not found.\n"); msg_perr("\nERROR: Intel PIIX4 ISA bridge not found.\n");
return -1; return -1;
@ -1426,7 +1426,7 @@ static int intel_piix4_gpo_set(unsigned int gpo, int raise)
return -1; return -1;
} }
dev = pci_dev_find(0x8086, 0x7113); /* Intel PIIX4 PM */ dev = pcidev_find(0x8086, 0x7113); /* Intel PIIX4 PM */
if (!dev) { if (!dev) {
msg_perr("\nERROR: Intel PIIX4 PM not found.\n"); msg_perr("\nERROR: Intel PIIX4 PM not found.\n");
return -1; return -1;
@ -1941,7 +1941,7 @@ static int via_apollo_gpo_set(int gpio, int raise)
uint32_t base, tmp; uint32_t base, tmp;
/* VT82C686 power management */ /* VT82C686 power management */
dev = pci_dev_find(0x1106, 0x3057); dev = pcidev_find(0x1106, 0x3057);
if (!dev) { if (!dev) {
msg_perr("\nERROR: VT82C686 PM device not found.\n"); msg_perr("\nERROR: VT82C686 PM device not found.\n");
return -1; return -1;
@ -2014,7 +2014,7 @@ static int sis_gpio0_raise_and_w836xx_memw(void)
struct pci_dev *dev; struct pci_dev *dev;
uint16_t base, temp; uint16_t base, temp;
dev = pci_dev_find(0x1039, 0x0962); dev = pcidev_find(0x1039, 0x0962);
if (!dev) { if (!dev) {
msg_perr("Expected south bridge not found\n"); msg_perr("Expected south bridge not found\n");
return 1; return 1;
@ -2078,7 +2078,7 @@ static int board_mitac_6513wu(void)
uint16_t rt_port; uint16_t rt_port;
uint8_t val; uint8_t val;
dev = pci_dev_find(0x8086, 0x2410); /* Intel 82801AA ISA bridge */ dev = pcidev_find(0x8086, 0x2410); /* Intel 82801AA ISA bridge */
if (!dev) { if (!dev) {
msg_perr("\nERROR: Intel 82801AA ISA bridge not found.\n"); msg_perr("\nERROR: Intel 82801AA ISA bridge not found.\n");
return -1; return -1;
@ -2603,13 +2603,13 @@ static const struct board_match *board_match_name(const char *vendor, const char
if (!cur_model || strcasecmp(cur_model, model)) if (!cur_model || strcasecmp(cur_model, model))
continue; continue;
if (!pci_dev_find(board->first_vendor, board->first_device)) { if (!pcidev_find(board->first_vendor, board->first_device)) {
msg_pdbg("Odd. Board name \"%s\":\"%s\" matches, but first PCI device %04x:%04x " msg_pdbg("Odd. Board name \"%s\":\"%s\" matches, but first PCI device %04x:%04x "
"doesn't.\n", vendor, model, board->first_vendor, board->first_device); "doesn't.\n", vendor, model, board->first_vendor, board->first_device);
continue; continue;
} }
if (!pci_dev_find(board->second_vendor, board->second_device)) { if (!pcidev_find(board->second_vendor, board->second_device)) {
msg_pdbg("Odd. Board name \"%s\":\"%s\" matches, but second PCI device %04x:%04x " msg_pdbg("Odd. Board name \"%s\":\"%s\" matches, but second PCI device %04x:%04x "
"doesn't.\n", vendor, model, board->second_vendor, board->second_device); "doesn't.\n", vendor, model, board->second_vendor, board->second_device);
continue; continue;
@ -2658,7 +2658,7 @@ static const struct board_match *board_match_pci_ids(enum board_match_phase phas
board->second_card_device)) board->second_card_device))
continue; continue;
} else { } else {
if (!pci_dev_find(board->second_vendor, if (!pcidev_find(board->second_vendor,
board->second_device)) board->second_device))
continue; continue;
} }

View File

@ -1117,7 +1117,7 @@ static int enable_flash_vt823x(struct pci_dev *dev, const char *name)
static int enable_flash_vt_vx(struct pci_dev *dev, const char *name) static int enable_flash_vt_vx(struct pci_dev *dev, const char *name)
{ {
struct pci_dev *south_north = pci_dev_find(0x1106, 0xa353); struct pci_dev *south_north = pcidev_find(0x1106, 0xa353);
if (south_north == NULL) { if (south_north == NULL) {
msg_perr("Could not find South-North Module Interface Control device!\n"); msg_perr("Could not find South-North Module Interface Control device!\n");
return ERROR_FATAL; return ERROR_FATAL;
@ -1557,7 +1557,7 @@ static int enable_flash_sb400(struct pci_dev *dev, const char *name)
struct pci_dev *smbusdev; struct pci_dev *smbusdev;
/* Look for the SMBus device. */ /* Look for the SMBus device. */
smbusdev = pci_dev_find(0x1002, 0x4372); smbusdev = pcidev_find(0x1002, 0x4372);
if (!smbusdev) { if (!smbusdev) {
msg_perr("ERROR: SMBus device not found. Aborting.\n"); msg_perr("ERROR: SMBus device not found. Aborting.\n");
@ -2163,7 +2163,7 @@ int chipset_flash_enable(void)
/* Now let's try to find the chipset we have... */ /* Now let's try to find the chipset we have... */
for (i = 0; chipset_enables[i].vendor_name != NULL; i++) { for (i = 0; chipset_enables[i].vendor_name != NULL; i++) {
dev = pci_dev_find(chipset_enables[i].vendor_id, dev = pcidev_find(chipset_enables[i].vendor_id,
chipset_enables[i].device_id); chipset_enables[i].device_id);
if (!dev) if (!dev)
continue; continue;

View File

@ -34,17 +34,6 @@ int force_boardmismatch = 0;
enum chipbustype internal_buses_supported = BUS_NONE; enum chipbustype internal_buses_supported = BUS_NONE;
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device)
{
struct pci_filter filter;
pci_filter_init(NULL, &filter);
filter.vendor = vendor;
filter.device = device;
return pcidev_scandev(&filter, NULL);
}
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
void probe_superio(void) void probe_superio(void)
{ {

View File

@ -176,6 +176,17 @@ struct pci_dev *pcidev_card_find(uint16_t vendor, uint16_t device,
return NULL; return NULL;
} }
struct pci_dev *pcidev_find(uint16_t vendor, uint16_t device)
{
struct pci_filter filter;
pci_filter_init(NULL, &filter);
filter.vendor = vendor;
filter.device = device;
return pcidev_scandev(&filter, NULL);
}
struct pci_dev *pcidev_getdevfn(struct pci_dev *dev, const int func) struct pci_dev *pcidev_getdevfn(struct pci_dev *dev, const int func)
{ {
#if !defined(OLD_PCI_GET_DEV) #if !defined(OLD_PCI_GET_DEV)

View File

@ -129,6 +129,7 @@ struct pci_dev *pcidev_scandev(struct pci_filter *filter, struct pci_dev *start)
struct pci_dev *pcidev_getdevfn(struct pci_dev *dev, const int func); struct pci_dev *pcidev_getdevfn(struct pci_dev *dev, const int func);
struct pci_dev *pcidev_find_vendorclass(uint16_t vendor, uint16_t devclass); struct pci_dev *pcidev_find_vendorclass(uint16_t vendor, uint16_t devclass);
struct pci_dev *pcidev_card_find(uint16_t vendor, uint16_t device, uint16_t card_vendor, uint16_t card_device); struct pci_dev *pcidev_card_find(uint16_t vendor, uint16_t device, uint16_t card_vendor, uint16_t card_device);
struct pci_dev *pcidev_find(uint16_t vendor, uint16_t device);
/* rpci_write_* are reversible writes. The original PCI config space register /* rpci_write_* are reversible writes. The original PCI config space register
* contents will be restored on shutdown. * contents will be restored on shutdown.
* To clone the pci_dev instances internally, the `pacc` global * To clone the pci_dev instances internally, the `pacc` global
@ -261,9 +262,7 @@ extern int superio_count;
#define SUPERIO_VENDOR_ITE 0x1 #define SUPERIO_VENDOR_ITE 0x1
#define SUPERIO_VENDOR_WINBOND 0x2 #define SUPERIO_VENDOR_WINBOND 0x2
#endif #endif
#if NEED_PCI == 1
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
#endif
#if CONFIG_INTERNAL == 1 #if CONFIG_INTERNAL == 1
extern int is_laptop; extern int is_laptop;
extern int laptop_ok; extern int laptop_ok;

View File

@ -60,7 +60,7 @@ struct sb600spi_data {
static int find_smbus_dev_rev(uint16_t vendor, uint16_t device) static int find_smbus_dev_rev(uint16_t vendor, uint16_t device)
{ {
struct pci_dev *smbus_dev = pci_dev_find(vendor, device); struct pci_dev *smbus_dev = pcidev_find(vendor, device);
if (!smbus_dev) { if (!smbus_dev) {
msg_pdbg("No SMBus device with ID %04X:%04X found.\n", vendor, device); msg_pdbg("No SMBus device with ID %04X:%04X found.\n", vendor, device);
msg_perr("ERROR: SMBus device not found. Not enabling SPI.\n"); msg_perr("ERROR: SMBus device not found. Not enabling SPI.\n");
@ -734,11 +734,11 @@ int sb600_probe_spi(struct pci_dev *dev)
} }
/* Look for the SMBus device. */ /* Look for the SMBus device. */
smbus_dev = pci_dev_find(0x1002, 0x4385); smbus_dev = pcidev_find(0x1002, 0x4385);
if (!smbus_dev) if (!smbus_dev)
smbus_dev = pci_dev_find(0x1022, 0x780b); /* AMD FCH */ smbus_dev = pcidev_find(0x1022, 0x780b); /* AMD FCH */
if (!smbus_dev) if (!smbus_dev)
smbus_dev = pci_dev_find(0x1022, 0x790b); /* AMD FP4 */ smbus_dev = pcidev_find(0x1022, 0x790b); /* AMD FP4 */
if (!smbus_dev) { if (!smbus_dev) {
msg_perr("ERROR: SMBus device not found. Not enabling SPI.\n"); msg_perr("ERROR: SMBus device not found. Not enabling SPI.\n");
return ERROR_NONFATAL; return ERROR_NONFATAL;