My example.
On the VT8231 south bridge, you need to set some bits very early in the game to make sure PCI devices are on or off, as needed by the motherboard.
So, in via/epia/auto.c, we have this:
static void enable_mainboard_devices(void) { device_t dev; /* dev 0 for southbridge */
dev = pci_locate_device(PCI_ID(0x1106,0x8231), 0);
if (dev == PCI_DEV_INVALID) { die("Southbridge not found!!!\n"); } pci_write_config8(dev, 0x50, 7); pci_write_config8(dev, 0x51, 0xff); #if 0 // This early setup switches IDE into compatibility mode before PCI gets // // a chance to assign I/Os // movl $CONFIG_ADDR(0, 0x89, 0x42), %eax // // movb $0x09, %dl // movb $0x00, %dl // PCI_WRITE_CONFIG_BYTE // #endif /* we do this here as in V2, we can not yet do raw operations * to pci! */ dev++; /* ICKY */ pci_write_config8(dev, 0x42, 0); }
OK, so I have some chip-specific stuff in the mainboard auto.c. Which means that other mainboards that use that chip have to use this code. First the authors of that code have to find this code. Chip-specific code like this should be in the southbridge chip code, not the mainboard code.
How do I want this to work?
Like this:
in via/vt8231/vt8231.c: static void southbridge_init(struct chip *chip, enum chip_pass pass) {
struct southbridge_via_vt8231_config *conf = (struct southbridge_via_vt8231_config *)chip->chip_info;
switch (pass) { case CONF_PASS_PRE_PCI: vt8231_pci_enable(conf); /* called BEFORE PCI scan */ break; }
}
I want that vt8231_pci_enable function called BEFORE any PCI config is done. But, as things stand, all the functions available in the C code depend on the dynamic device tree having been configure. But I need to call this function before that happens. The things that the function will do are determined in mainboard Config.lb, viz:
northbridge via/vt8601 "vt8601" southbridge via/vt8231 "vt8231" register "enable_usb" = "0" register "enable_native_ide" = "1" register "enable_com_ports" = "1" register "enable_keyboard" = "0" register "enable_nvram" = "1" end end
So, to make sure the PCI scan behave correctly and builds the dynamic tree correctly, I need to take actions BEFORE the PCI scan occurs. But the PCI functions provided to the C code only work AFTER the PCI scan occurs. Hence the problem.
This problem did not occur in v1.
I'd like the solution to be very simple ...
ron