summaryrefslogtreecommitdiff
path: root/src/southbridge
diff options
context:
space:
mode:
authorTobias Diedrich <ranma+coreboot@tdiedrich.de>2010-11-07 18:46:13 +0000
committerRudolf Marek <r.marek@assembler.cz>2010-11-07 18:46:13 +0000
commitef2928e708b881d6d54c2308a4c596a6d003743b (patch)
treeecc52b5d2b1eddcc1309c62b52314698551ad4d8 /src/southbridge
parent6953eeb3427c8f72d88d8eff52cb211bc2f224dc (diff)
Instead of duplicating the pci_locate_device calls multiple times,
add a get_vt8237_lpc() function. Signed-off-by: Tobias Diedrich <ranma+coreboot@tdiedrich.de> Acked-by: Rudolf Marek <r.marek@assembler.cz> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@6040 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/southbridge')
-rw-r--r--src/southbridge/via/vt8237r/vt8237r_early_smbus.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/src/southbridge/via/vt8237r/vt8237r_early_smbus.c b/src/southbridge/via/vt8237r/vt8237r_early_smbus.c
index 4372a4a89d..83eb227932 100644
--- a/src/southbridge/via/vt8237r/vt8237r_early_smbus.c
+++ b/src/southbridge/via/vt8237r/vt8237r_early_smbus.c
@@ -134,6 +134,21 @@ u8 smbus_read_byte(u8 dimm, u8 offset)
#define PSONREADY_TIMEOUT 0x7fffffff
+static device_t get_vt8237_lpc(void)
+{
+ device_t dev;
+
+ /* Power management controller */
+ dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA,
+ PCI_DEVICE_ID_VIA_VT8237R_LPC), 0);
+ if (dev != PCI_DEV_INVALID)
+ return dev;
+
+ dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA,
+ PCI_DEVICE_ID_VIA_VT8237S_LPC), 0);
+ return dev;
+}
+
/**
* Enable the SMBus on VT8237R-based systems.
*/
@@ -143,15 +158,9 @@ void enable_smbus(void)
int loops;
/* Power management controller */
- dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA,
- PCI_DEVICE_ID_VIA_VT8237R_LPC), 0);
- if (dev == PCI_DEV_INVALID) {
- /* Power management controller */
- dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA,
- PCI_DEVICE_ID_VIA_VT8237S_LPC), 0);
- if (dev == PCI_DEV_INVALID)
- die("Power management controller not found\n");
- }
+ dev = get_vt8237_lpc();
+ if (dev == PCI_DEV_INVALID)
+ die("Power management controller not found\n");
/* Make sure the RTC power well is up before touching smbus. */
loops = 0;
@@ -292,15 +301,9 @@ void enable_rom_decode(void)
device_t dev;
/* Power management controller */
- dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA,
- PCI_DEVICE_ID_VIA_VT8237R_LPC), 0);
- if (dev == PCI_DEV_INVALID) {
- /* Power management controller */
- dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA,
- PCI_DEVICE_ID_VIA_VT8237S_LPC), 0);
- if (dev == PCI_DEV_INVALID)
- return;
- }
+ dev = get_vt8237_lpc();
+ if (dev == PCI_DEV_INVALID)
+ return;
/* ROM decode last 1MB FFC00000 - FFFFFFFF. */
pci_write_config8(dev, 0x41, 0x7f);
@@ -316,15 +319,9 @@ static int acpi_is_wakeup_early(void) {
print_debug("IN TEST WAKEUP\n");
/* Power management controller */
- dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA,
- PCI_DEVICE_ID_VIA_VT8237R_LPC), 0);
- if (dev == PCI_DEV_INVALID) {
- /* Power management controller */
- dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA,
- PCI_DEVICE_ID_VIA_VT8237S_LPC), 0);
- if (dev == PCI_DEV_INVALID)
- die("Power management controller not found\n");
- }
+ dev = get_vt8237_lpc();
+ if (dev == PCI_DEV_INVALID)
+ die("Power management controller not found\n");
/* Set ACPI base address to I/O VT8237R_ACPI_IO_BASE. */
pci_write_config16(dev, 0x88, VT8237R_ACPI_IO_BASE | 0x1);