pnp: Allow searching PNP device by port and device ID.

To access superio in ramstage, we need to find the device by PNP path.

Original-Change-Id: Iea4451381545f7c401e212ac7d7567a32aa92b25
Original-Reviewed-on: https://chromium-review.googlesource.com/190841

BRANCH=zako
BUG=chrome-os-partner:25024
TEST=emerge-zako chromeos-coreboot-zako

Change-Id: I6118177e5d62b32596caeb119800e8716c998a90
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/190972
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
This commit is contained in:
Hung-Te Lin 2014-03-20 12:04:33 +08:00 committed by chrome-internal-fetch
commit 997f005737
2 changed files with 24 additions and 0 deletions

View file

@ -113,6 +113,29 @@ device_t dev_find_lapic(unsigned apic_id)
return result;
}
/**
* Find a PNP device of given port and device ID.
*
* @param port A PNP port ID.
* @param device A PNP device ID.
* @return Pointer to the device struct.
*/
struct device *dev_find_pnp(unsigned int port, unsigned int device)
{
struct device *dev, *result;
result = NULL;
for (dev = all_devices; dev; dev = dev->next) {
if ((dev->path.type == DEVICE_PATH_PNP) &&
(dev->path.pnp.port == port) &&
(dev->path.pnp.device == device)) {
result = dev;
break;
}
}
return result;
}
/**
* Find a device of a given vendor and type.
*

View file

@ -159,6 +159,7 @@ device_t dev_find_class (unsigned int class, device_t from);
device_t dev_find_slot (unsigned int bus, unsigned int devfn);
device_t dev_find_slot_on_smbus (unsigned int bus, unsigned int addr);
device_t dev_find_lapic(unsigned apic_id);
device_t dev_find_pnp(unsigned int port, unsigned int device);
int dev_count_cpu(void);
void remap_bsp_lapic(struct bus *cpu_bus);