switch-coreboot/include/device
Ronald G. Minnich 7e806b90e6 This change is for tidying up some unfinished business in the device code.
I just uncovered this problem while trying to get the lx going. 

The symptom was that the northbridge ops were never getting run, 
in particular the phase 2 ops for the geodelx were not running. The 
reason was that the ops struct member for the device was not set. 

How is the ops struct member set? 
Currently, the ops vector for a static device (i.e. a device created from the 
dts) has to be set by hand, as in mainboard/emulation/qemu-x86/dts:
	domain0 {
		/config/("northbridge/intel/i440bxemulation");
		ops = "i440bxemulation_pcidomainops";

This requirement is ridiculous (it's my fault). If we know the part, 
and have the dts, we should not have to explicitly name the ops. In fact the
constructors array, defined at the end of the various device files, makes 
searching for an ops struct for a dynamic device automatic. We should 
support this automatic behavior for static devices too. 

Given the function find_constructor
in device/device.c, why don't we just use that? The problem is that we did 
not set up the device struct to include a device id, just a device path, and
find_constructor requires a device_id -- which makes sense, I hope, 
as the path is its pci path (e.g. 0:1.0) and the constructors are defined by the 
device id (i.e. it is the same constructor for a given part, no matter how many
of the part we have). 

So, as a start to fixing this limitation (this is going to take several patches), 
I've done the following:
1. add a struct device_id to the device struct. 
2. extended the dev_init code in device/device.c -- this is the first function
    called from lib/stage2.c -- to find a constructor for the dev->id and, if
    found, set dev->ops to it. 

Result: for static devices with the id set, the ops pointer will be set 
automatically. Coreboot builds fine with this change. 

The next change will be to add dtc commands to set ids. 
Currently, we have commands like pcipath, pcidomain, etc.; 
the new commands will look like pciid, domainid, etc. Once we have these
commands, we will have made it possible to set ops automatically. We 
can just set the ids in the device dts file, and users will never have to 
see any of this complication. 

The final change will be a bit more complicated. Right now, if you look in, 
e.g., northbridge/amd/geodelx/dts, you'll see that we have one dts, but 
the northbridge plays three roles. We can't easily contain those three 
roles in one dts (I am open to suggestions showing I am wrong). 
I am going to propose that we have more than one dts file
in a directory, so instead of 
northbridge/amd/geodelx/dts 
we would have
northbridge/amd/geodelx/dtsdomain
northbridge/amd/geodelx/dtsapic
northbridge/amd/geodelx/dtspci
so that we could set the variables for each of these individual components. 

There is no need to split geodelx.c into three .c files, however. 

Finally, I will be removing the archaic vendor and device unsigned's from
the device struct in future, but as I say, I am trying to stage these changes
to keep them understandable. 

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>


Acked-by: Peter Stuge <peter@stuge.se>


git-svn-id: svn://coreboot.org/repository/coreboot-v3@556 f3766cd6-281f-0410-b1cd-43a5c92072e9
2008-01-17 16:32:12 +00:00
..
agp.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00
cardbus.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00
device.h This change is for tidying up some unfinished business in the device code. 2008-01-17 16:32:12 +00:00
hypertransport.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00
hypertransport_def.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00
path.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00
pci.h Move the code from northbridgelib.c to pci_device.c. 2007-12-04 21:06:52 +00:00
pci_def.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00
pci_ids.h Add (and use) the new PCI IDs: 2007-07-12 01:03:05 +00:00
pci_ops.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00
pci_rom.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00
pcie.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00
pcix.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00
pnp.h Various coding style and cosmetic fixes (trivial). 2007-10-31 02:40:17 +00:00
resource.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00
smbus.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00
smbus_def.h Use the same naming convention and placement for "include guards" in 2007-05-21 06:48:47 +00:00