1 #include <console/console.h>
5 #include <part/sizeram.h>
6 #include <device/device.h>
7 #include <device/pci.h>
8 #include <device/hypertransport.h>
9 #include <device/chip.h>
14 #include "northbridge.h"
16 static const uint8_t ramregs[] = {0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
19 struct mem_range *sizeram(void)
21 unsigned long mmio_basek;
22 static struct mem_range mem[10];
25 unsigned char rambits;
27 dev = dev_find_slot(0, 0);
29 printk_err("Cannot find PCI: 0:0\n");
35 while(idx < sizeof(mem)/sizeof(mem[0])) {
40 for(rambits = 0, i = 0; i < sizeof(ramregs)/sizeof(ramregs[0]); i++) {
42 reg = pci_read_config8(dev, ramregs[i]);
43 /* these are ENDING addresses, not sizes.
44 * if there is memory in this slot, then reg will be > rambits.
45 * So we just take the max, that gives us total.
46 * We take the highest one to cover for once and future linuxbios
47 * bugs. We warn about bugs.
52 printk_err("ERROR! register 0x%x is not set!\n",
56 printk_debug("I would set ram size to 0x%x Kbytes\n", (rambits)*8*1024);
57 mem[0].sizek = rambits*8*1024;
59 for(i = 0; i < idx; i++) {
60 printk_debug("mem[%d].basek = %08x mem[%d].sizek = %08x\n",
61 i, mem[i].basek, i, mem[i].sizek);
67 static void enumerate(struct chip *chip)
69 extern struct device_operations default_pci_ops_bus;
71 chip->dev->ops = &default_pci_ops_bus;
75 * This fixup is based on capturing values from an Award bios. Without
76 * this fixup the DMA write performance is awful (i.e. hdparm -t /dev/hda is 20x
77 * slower than normal, ethernet drops packets).
78 * Apparently these registers govern some sort of bus master behavior.
80 static void random_fixup() {
81 device_t pcidev = dev_find_slot(0, 0);
83 printk_spew("VT8601 random fixup ...\n");
85 pci_write_config8(pcidev, 0x70, 0xc0);
86 pci_write_config8(pcidev, 0x71, 0x88);
87 pci_write_config8(pcidev, 0x72, 0xec);
88 pci_write_config8(pcidev, 0x73, 0x0c);
89 pci_write_config8(pcidev, 0x74, 0x0e);
90 pci_write_config8(pcidev, 0x75, 0x81);
91 pci_write_config8(pcidev, 0x76, 0x52);
95 static void northbridge_init(struct chip *chip, enum chip_pass pass)
98 struct northbridge_via_vt8601_config *conf =
99 (struct northbridge_via_vt8601_config *)chip->chip_info;
102 case CONF_PASS_PRE_PCI:
105 case CONF_PASS_POST_PCI:
108 case CONF_PASS_PRE_BOOT:
118 struct chip_control northbridge_via_vt8601_control = {
119 .enumerate = enumerate,
120 .enable = northbridge_init,
121 .name = "VIA vt8601 Northbridge",