Patrick Georgi ([email protected]) just uploaded a new patch set to 
gerrit, which you can find at http://review.coreboot.org/1623

-gerrit

commit cfc0e5de180d904d9af4cd65979c5631242a3f71
Author: Nico Huber <[email protected]>
Date:   Wed Jul 25 10:33:05 2012 +0200

    Add initialization hook for chips
    
    Add an init() function to the chip_operations which will be called
    before bus enumeration. This allows to disable unused devices before
    they get enumerated.
    
    Change-Id: I63dd9cbfc7b5995ccafb7bf7a81dc71fc67906a0
    Signed-off-by: Nico Huber <[email protected]>
---
 src/boot/hardwaremain.c     |  3 +++
 src/devices/device.c        | 20 ++++++++++++++++++++
 src/include/device/device.h |  5 ++++-
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/boot/hardwaremain.c b/src/boot/hardwaremain.c
index 099ab3a..e9397c4 100644
--- a/src/boot/hardwaremain.c
+++ b/src/boot/hardwaremain.c
@@ -86,6 +86,9 @@ void hardwaremain(int boot_complete)
 #if CONFIG_COLLECT_TIMESTAMPS
        timestamps[1] = rdtsc();
 #endif
+       /* Initialize chips early, they might disable unused devices. */
+       dev_initialize_chips();
+
        /* Find the devices we don't have hard coded knowledge about. */
        dev_enumerate();
        post_code(POST_DEVICE_ENUMERATION_COMPLETE);
diff --git a/src/devices/device.c b/src/devices/device.c
index f021c9b..03e7ea7 100644
--- a/src/devices/device.c
+++ b/src/devices/device.c
@@ -52,6 +52,26 @@ extern struct device *last_dev;
 /** Linked list of free resources */
 struct resource *free_resources = NULL;
 
+/**
+ * Initialize all chips of statically known devices.
+ *
+ * Will be called before bus enumeration to initialize chips stated in the
+ * device tree.
+ */
+void dev_initialize_chips(void)
+{
+       struct device *dev;
+
+       for (dev = all_devices; dev; dev = dev->next) {
+               /* Initialize chip if we haven't yet. */
+               if (dev->chip_ops && dev->chip_ops->init &&
+                               !dev->chip_ops->initialized) {
+                       dev->chip_ops->init(dev->chip_info);
+                       dev->chip_ops->initialized = 1;
+               }
+       }
+}
+
 DECLARE_SPIN_LOCK(dev_lock)
 
 #if CONFIG_GFXUMA
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 642a4a6..8ea00cc 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -16,6 +16,8 @@ struct smbus_bus_operations;
 /* Chip operations */
 struct chip_operations {
        void (*enable_dev)(struct device *dev);
+       void (*init)(void *chip_info);
+       unsigned int initialized : 1;
        const char *name;
 #if CONFIG_GENERATE_SMBIOS_TABLES
        int (*get_smbios_data)(device_t dev, int *handle, unsigned long 
*current);
@@ -103,7 +105,7 @@ struct device {
 
        struct device_operations *ops;
 #ifndef __PRE_RAM__
-       const struct chip_operations *chip_ops;
+       struct chip_operations *chip_ops;
 #endif
        ROMSTAGE_CONST void *chip_info;
 };
@@ -125,6 +127,7 @@ extern uint64_t uma_memory_size;
 
 /* Generic device interface functions */
 device_t alloc_dev(struct bus *parent, struct device_path *path);
+void dev_initialize_chips(void);
 void dev_enumerate(void);
 void dev_configure(void);
 void dev_enable(void);

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to