1 #include <console/console.h>
5 #include <part/sizeram.h>
6 #include <device/device.h>
7 #include <device/pci.h>
8 #include <device/chip.h>
14 struct mem_range *sizeram(void)
16 static struct mem_range mem[4];
17 /* the units of tolm are 64 KB */
18 /* the units of drb16 are 64 MB */
19 uint16_t tolm, remapbase, remaplimit, drb16;
20 uint16_t tolm_r, remapbase_r, remaplimit_r;
25 dev = dev_find_slot(0, 0); // d0f0
27 printk_err("Cannot find PCI: 0:0\n");
31 /* Calculate and report the top of low memory and
34 /* Test if the remap memory high option is set */
36 // if(get_option(&remap_high, "remap_memory_high")){
39 printk_debug("remap_high is %d\n", remap_high);
40 /* get out the value of the highest DRB. This tells the end of
41 * physical memory. The units are ticks of 64 MB i.e. 1 means
44 drb = pci_read_config8(dev, 0x67);
45 drb16 = (uint16_t)drb;
46 if(remap_high && (drb16 > 0x08)) {
47 /* We only come here if we have at least 512MB of memory,
48 * so it is safe to hard code tolm.
53 /* i.e 0x40 * 0x40 is 0x1000 which is 4 GB */
55 /* There is more than 4GB of memory put
56 * the remap window at the end of ram.
59 remaplimit = remapbase + 0x38;
63 remaplimit = remapbase + (drb16-8);
67 tolm = (uint16_t)((dev_root.resource[1].base >> 16)&0x0f800);
68 if((tolm>>8) >= (drb16<<2)) {
75 remaplimit = remapbase + ((0x0040-(tolm>>10))-1);
78 /* Write the ram configruation registers,
79 * preserving the reserved bits.
81 tolm_r = pci_read_config16(dev, 0xc4);
82 tolm |= (tolm_r & 0x7ff);
83 pci_write_config16(dev, 0xc4, tolm);
84 remapbase_r = pci_read_config16(dev, 0xc6);
85 remapbase |= (remapbase_r & 0xfc00);
86 pci_write_config16(dev, 0xc6, remapbase);
87 remaplimit_r = pci_read_config16(dev, 0xc8);
88 remaplimit |= (remaplimit_r & 0xfc00);
89 pci_write_config16(dev, 0xc8, remaplimit);
92 printk_debug("mem info tolm = %x, drb = %x, pci_memory_base = %x, remap = %x-%x\n",tolm,drb,pci_memory_base,remapbase,remaplimit);
98 /* Convert size in 64K bytes to size in K bytes */
99 mem[1].sizek = (tolm << 6) - mem[1].basek;
102 if ((drb << 16) > (tolm << 6)) {
103 /* We don't need to consider the remap window
104 * here because we put it immediately after the
106 * All we must do is calculate the amount
107 * of unused memory and report it at 4GB.
109 mem[2].basek = 4096*1024;
110 mem[2].sizek = (drb << 16) - (tolm << 6);
117 static void enumerate(struct chip *chip)
119 extern struct device_operations default_pci_ops_bus;
120 chip_enumerate(chip);
121 chip->dev->ops = &default_pci_ops_bus;
124 static void northbridge_init(struct chip *chip, enum chip_pass pass)
127 struct northbridge_intel_e7501_config *conf =
128 (struct northbridge_intel_e7501_config *)chip->chip_info;
131 case CONF_PASS_PRE_PCI:
134 case CONF_PASS_POST_PCI:
137 case CONF_PASS_PRE_BOOT:
147 struct chip_control northbridge_intel_e7501_control = {
148 .enumerate = enumerate,
149 // .enable = northbridge_init,
150 .name = "intel E7501 Northbridge",