aboutsummaryrefslogtreecommitdiff
path: root/src/device/device_romstage.c
diff options
context:
space:
mode:
authorStefan Reinauer <reinauer@chromium.org>2012-11-30 12:34:04 -0800
committerRonald G. Minnich <rminnich@gmail.com>2012-11-30 23:59:58 +0100
commit8d7115560d469f901d7d8ccb242d0b437e7394aa (patch)
tree0f1b4bd63c48a233c49d5a9ca15f08a1675d1ff4 /src/device/device_romstage.c
parent4b6be985aae8bff84ae442e7be7669e93694fa1e (diff)
Rename devices -> device
to match src/include/device Change-Id: I5d0e5b4361c34881a3b81347aac48738cb5b9af0 Signed-off-by: Stefan Reinauer <reinauer@google.com> Reviewed-on: http://review.coreboot.org/1960 Tested-by: build bot (Jenkins) Reviewed-by: David Hendricks <dhendrix@chromium.org>
Diffstat (limited to 'src/device/device_romstage.c')
-rw-r--r--src/device/device_romstage.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/device/device_romstage.c b/src/device/device_romstage.c
new file mode 100644
index 0000000000..475f94aeaf
--- /dev/null
+++ b/src/device/device_romstage.c
@@ -0,0 +1,80 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2003-2004 Linux Networx
+ * (Written by Eric Biederman <ebiederman@lnxi.com> for Linux Networx)
+ * Copyright (C) 2003 Greg Watson <jarrah@users.sourceforge.net>
+ * Copyright (C) 2004 Li-Ta Lo <ollie@lanl.gov>
+ * Copyright (C) 2005-2006 Tyan
+ * (Written by Yinghai Lu <yhlu@tyan.com> for Tyan)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <device/device.h>
+#include <device/path.h>
+#include <device/pci.h>
+#include <device/resource.h>
+
+/** Linked list of ALL devices */
+ROMSTAGE_CONST struct device * ROMSTAGE_CONST all_devices = &dev_root;
+
+/**
+ * Given a PCI bus and a devfn number, find the device structure.
+ *
+ * @param bus The bus number.
+ * @param devfn A device/function number.
+ * @return Pointer to the device structure (if found), 0 otherwise.
+ */
+ROMSTAGE_CONST struct device *dev_find_slot(unsigned int bus,
+ unsigned int devfn)
+{
+ ROMSTAGE_CONST struct device *dev, *result;
+
+ result = 0;
+ for (dev = all_devices; dev; dev = dev->next) {
+ if ((dev->path.type == DEVICE_PATH_PCI) &&
+ (dev->bus->secondary == bus) &&
+ (dev->path.pci.devfn == devfn)) {
+ result = dev;
+ break;
+ }
+ }
+ return result;
+}
+
+/**
+ * Given an SMBus bus and a device number, find the device structure.
+ *
+ * @param bus The bus number.
+ * @param addr A device number.
+ * @return Pointer to the device structure (if found), 0 otherwise.
+ */
+ROMSTAGE_CONST struct device *dev_find_slot_on_smbus(unsigned int bus,
+ unsigned int addr)
+{
+ ROMSTAGE_CONST struct device *dev, *result;
+
+ result = 0;
+ for (dev = all_devices; dev; dev = dev->next) {
+ if ((dev->path.type == DEVICE_PATH_I2C) &&
+ (dev->bus->secondary == bus) &&
+ (dev->path.i2c.device == addr)) {
+ result = dev;
+ break;
+ }
+ }
+ return result;
+}
+