Changeset 3644 for trunk/coreboot-v2
- Timestamp:
- 10/09/08 19:08:32 (3 months ago)
- Location:
- trunk/coreboot-v2/src/northbridge/via/cn700
- Files:
-
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/coreboot-v2/src/northbridge/via/cn700/agp.c
r3113 r3644 33 33 { 34 34 u32 reg32; 35 36 /* Some of this may not be necessary, 37 * it should be handled by the OS */ 35 36 /* Some of this may not be necessary (should be handled by the OS). */ 38 37 printk_debug("Enabling AGP.\n"); 39 40 /* Allow R/W access to AGP registers */38 39 /* Allow R/W access to AGP registers. */ 41 40 pci_write_config8(dev, 0x4d, 0x15); 42 43 /* Setup PCI latency timer */41 42 /* Setup PCI latency timer. */ 44 43 pci_write_config8(dev, 0xd, 0x8); 45 46 /* Set to AGP 3.0 Mode, which should theoretically render the rest of 47 * the registers set here pointless */ 44 45 /* 46 * Set to AGP 3.0 Mode, which should theoretically render the rest of 47 * the registers set here pointless. 48 */ 48 49 pci_write_config8(dev, 0x84, 0xb); 49 50 50 51 /* AGP Request Queue Size */ 51 52 pci_write_config8(dev, 0x4a, 0x1f); 52 /* AGP Hardware Support (default 0xc4) 53 54 /* 55 * AGP Hardware Support (default 0xc4) 53 56 * 7: AGP SBA Enable (1 to Enable) 54 57 * 6: AGP Enable … … 58 61 * 2: AGP4X Mode Enable 59 62 * 1: AGP2X Mode Enable 60 * 0: AGP1X Mode Enable */ 63 * 0: AGP1X Mode Enable 64 */ 61 65 pci_write_config8(dev, 0x4b, 0xc4); 62 66 63 67 /* Enable AGP Backdoor */ 64 68 pci_write_config8(dev, 0xb5, 0x03); 65 66 /* Set aperture to 32 MB*/67 /* TODO: Use config option, explain how it works */69 70 /* Set aperture to 32 MB. */ 71 /* TODO: Use config option, explain how it works. */ 68 72 pci_write_config32(dev, 0x94, 0x00010f38); 69 /* Set GART Table Base Address (31:12) */73 /* Set GART Table Base Address (31:12). */ 70 74 pci_write_config32(dev, 0x98, (0x1558 << 12)); 71 /* Set AGP Aperture Base */75 /* Set AGP Aperture Base. */ 72 76 pci_write_config32(dev, 0x10, 0xf8000008); 73 77 74 /* Enable CPU/PMSTR GART Access */78 /* Enable CPU/PMSTR GART Access. */ 75 79 reg32 = pci_read_config8(dev, 0xbf); 76 80 reg32 |= 0x80; 77 81 pci_write_config8(dev, 0xbf, reg32); 78 82 79 83 /* Enable AGP Aperture. */ 80 84 reg32 = pci_read_config32(dev, 0x94); … … 85 89 pci_write_config8(dev, 0xbc, 0x21); 86 90 pci_write_config8(dev, 0xbd, 0xd2); 87 88 /* AGP Pad, driving strength, and delay control */ 89 /* All this should be constant, seeing as the 90 * VGA controller is onboard */ 91 92 /* 93 * AGP Pad, driving strength, and delay control. All this should be 94 * constant, seeing as the VGA controller is onboard. 95 */ 91 96 pci_write_config8(dev, 0x40, 0xc7); 92 97 pci_write_config8(dev, 0x41, 0xdb); … … 94 99 pci_write_config8(dev, 0x43, 0xdb); 95 100 pci_write_config8(dev, 0x44, 0x24); 96 101 97 102 /* AGPC CKG Control */ 98 103 pci_write_config8(dev, 0xc0, 0x02); … … 109 114 110 115 static const struct pci_driver agp_driver __pci_driver = { 111 .ops = &agp_operations,116 .ops = &agp_operations, 112 117 .vendor = PCI_VENDOR_ID_VIA, 113 118 .device = PCI_DEVICE_ID_VIA_CN700_AGP, 114 119 }; 115 120 116 /* This is the AGP 3.0 "bridge" @Bus 0 Device 1 Func 0. When using AGP 3.0, the 117 config in this device takes presidence. We configure both just to be safe. */ 121 /* 122 * This is the AGP 3.0 "bridge" @Bus 0 Device 1 Func 0. When using AGP 3.0, the 123 * config in this device takes presidence. We configure both just to be safe. 124 */ 118 125 static void agp_bridge_init(device_t dev) 119 126 { 120 printk_debug("Setting up AGP Bridge device\n"); 127 printk_debug("Setting up AGP bridge device\n"); 128 121 129 pci_write_config16(dev, 0x4, 0x0007); 122 130 … … 125 133 /* Subordinate Bus Number */ 126 134 pci_write_config8(dev, 0x1a, 0x01); 127 /* I O Base */135 /* I/O Base */ 128 136 pci_write_config8(dev, 0x1c, 0xd0); 129 /* I O Limit */137 /* I/O Limit */ 130 138 pci_write_config8(dev, 0x1d, 0xd0); 131 139 132 140 /* Memory Base */ 133 141 pci_write_config16(dev, 0x20, 0xfb00); … … 160 168 161 169 static const struct pci_driver agp_bridge_driver __pci_driver = { 162 .ops = &agp_bridge_operations,170 .ops = &agp_bridge_operations, 163 171 .vendor = PCI_VENDOR_ID_VIA, 164 172 .device = PCI_DEVICE_ID_VIA_CN700_BRIDGE, -
trunk/coreboot-v2/src/northbridge/via/cn700/chip.h
r3113 r3644 19 19 */ 20 20 21 struct northbridge_via_cn700_config 22 { 21 struct northbridge_via_cn700_config { 23 22 }; 24 23 -
trunk/coreboot-v2/src/northbridge/via/cn700/cn700.h
r3113 r3644 20 20 21 21 #ifndef __ROMCC__ 22 static void cn700_noop(){} 22 static void cn700_noop() 23 { 24 } 23 25 #endif 24 26 25 27 /* VGA stuff */ 26 #define SR_INDEX 0x3c427 #define SR_DATA 0x3c528 #define CRTM_INDEX 0x3b429 #define CRTM_DATA 0x3b530 #define CRTC_INDEX 0x3d431 #define CRTC_DATA 0x3d528 #define SR_INDEX 0x3c4 29 #define SR_DATA 0x3c5 30 #define CRTM_INDEX 0x3b4 31 #define CRTM_DATA 0x3b5 32 #define CRTC_INDEX 0x3d4 33 #define CRTC_DATA 0x3d5 32 34 33 /* Memory Controller Registers */35 /* Memory controller registers */ 34 36 #define RANK0_END 0x40 35 37 #define RANK1_END 0x41 … … 46 48 #define CH_A_MD_OUTPUT_DELAY 0x71 47 49 48 /* RAM Init Commands */50 /* RAM init commands */ 49 51 #define RAM_COMMAND_NORMAL 0x0 50 52 #define RAM_COMMAND_NOP 0x1 -
trunk/coreboot-v2/src/northbridge/via/cn700/northbridge.c
r3334 r3644 39 39 device_t vlink_dev; 40 40 u16 reg16; 41 u8 ranks; 42 u8 pagec, paged, pagee, pagef; 43 u8 shadowreg; 44 45 /* Set up the vga framebuffer size */ 41 u8 ranks, pagec, paged, pagee, pagef, shadowreg; 42 43 /* Set up the VGA framebuffer size. */ 46 44 reg16 = (log2(CONFIG_VIDEO_MB) << 12) | (1 << 15); 47 45 pci_write_config16(dev, 0xa0, reg16); 48 49 /* Set up VGA timers */46 47 /* Set up VGA timers. */ 50 48 pci_write_config8(dev, 0xa2, 0x44); 51 49 52 50 for (ranks = 0x4b; ranks >= 0x48; ranks--) { 53 51 if (pci_read_config8(dev, ranks)) { … … 65 63 pci_write_config8(dev, 0xb8, 0x08); 66 64 67 /* shadown ram*/65 /* Shadow RAM */ 68 66 pagec = 0xff, paged = 0xff, pagee = 0xff, pagef = 0x30; 69 67 /* PAGE C, D, E are all read write enable */ … … 76 74 pci_write_config8(dev, 0x83, shadowreg); 77 75 /* vlink mirror */ 78 vlink_dev = dev_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CN700_VLINK, 0); 76 vlink_dev = dev_find_device(PCI_VENDOR_ID_VIA, 77 PCI_DEVICE_ID_VIA_CN700_VLINK, 0); 79 78 if (vlink_dev) { 80 79 pci_write_config8(vlink_dev, 0x61, pagec); 81 80 pci_write_config8(vlink_dev, 0x62, paged); 82 81 pci_write_config8(vlink_dev, 0x64, pagee); 82 83 83 shadowreg = pci_read_config8(vlink_dev, 0x63); 84 84 shadowreg |= pagef; … … 89 89 static const struct device_operations memctrl_operations = { 90 90 .read_resources = cn700_noop, 91 .init = memctrl_init,91 .init = memctrl_init, 92 92 }; 93 93 94 94 static const struct pci_driver memctrl_driver __pci_driver = { 95 .ops = &memctrl_operations,95 .ops = &memctrl_operations, 96 96 .vendor = PCI_VENDOR_ID_VIA, 97 97 .device = PCI_DEVICE_ID_VIA_CN700_MEMCTRL, … … 100 100 static void pci_domain_read_resources(device_t dev) 101 101 { 102 struct resource *resource;102 struct resource *resource; 103 103 104 104 printk_spew("Entering cn700 pci_domain_read_resources.\n"); 105 105 106 /* Initialize the system wide io space constraints*/107 resource = new_resource(dev, IOINDEX_SUBTRACTIVE(0,0));108 resource->limit = 0xffffUL;109 resource->flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE |110 IORESOURCE_ASSIGNED;111 112 /* Initialize the system wide memory resources constraints*/113 resource = new_resource(dev, IOINDEX_SUBTRACTIVE(1,0));114 resource->limit = 0xffffffffULL;115 resource->flags = IORESOURCE_MEM | IORESOURCE_SUBTRACTIVE |116 IORESOURCE_ASSIGNED;106 /* Initialize the system wide I/O space constraints. */ 107 resource = new_resource(dev, IOINDEX_SUBTRACTIVE(0, 0)); 108 resource->limit = 0xffffUL; 109 resource->flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE | 110 IORESOURCE_ASSIGNED; 111 112 /* Initialize the system wide memory resources constraints. */ 113 resource = new_resource(dev, IOINDEX_SUBTRACTIVE(1, 0)); 114 resource->limit = 0xffffffffULL; 115 resource->flags = IORESOURCE_MEM | IORESOURCE_SUBTRACTIVE | 116 IORESOURCE_ASSIGNED; 117 117 118 118 printk_spew("Leaving cn700 pci_domain_read_resources.\n"); … … 120 120 121 121 static void ram_resource(device_t dev, unsigned long index, 122 unsigned long basek, unsigned long sizek)123 { 124 struct resource *resource;125 126 if (!sizek) { 127 return;128 } 129 resource = new_resource(dev, index);130 resource->base = ((resource_t)basek) << 10;131 resource->size = ((resource_t)sizek) << 10;132 resource->flags = IORESOURCE_MEM | IORESOURCE_CACHEABLE | \ 133 IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;122 unsigned long basek, unsigned long sizek) 123 { 124 struct resource *resource; 125 126 if (!sizek) 127 return; 128 129 resource = new_resource(dev, index); 130 resource->base = ((resource_t) basek) << 10; 131 resource->size = ((resource_t) sizek) << 10; 132 resource->flags = IORESOURCE_MEM | IORESOURCE_CACHEABLE | 133 IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED; 134 134 } 135 135 … … 138 138 struct resource **best_p = gp; 139 139 struct resource *best; 140 140 141 best = *best_p; 141 if (!best || (best->base > new->base)) {142 if (!best || (best->base > new->base)) 142 143 best = new; 143 }144 144 *best_p = best; 145 145 } … … 147 147 static u32 find_pci_tolm(struct bus *bus) 148 148 { 149 print_debug("Entering find_pci_tolm\n");150 149 struct resource *min; 151 150 u32 tolm; 151 152 print_debug("Entering find_pci_tolm\n"); 153 152 154 min = 0; 153 search_bus_resources(bus, IORESOURCE_MEM, IORESOURCE_MEM, tolm_test, &min); 155 search_bus_resources(bus, IORESOURCE_MEM, IORESOURCE_MEM, 156 tolm_test, &min); 154 157 tolm = 0xffffffffUL; 155 if (min && tolm > min->base) {158 if (min && tolm > min->base) 156 159 tolm = min->base; 157 } 160 158 161 print_debug("Leaving find_pci_tolm\n"); 162 159 163 return tolm; 160 164 } … … 162 166 static void pci_domain_set_resources(device_t dev) 163 167 { 164 /* 165 * the order is important to find the correct ram size. 166 */ 167 static const u8 ramregs[] = {0x43, 0x42, 0x41, 0x40}; 168 /* The order is important to find the correct RAM size. */ 169 static const u8 ramregs[] = { 0x43, 0x42, 0x41, 0x40 }; 168 170 device_t mc_dev; 169 u32 pci_tolm;171 u32 pci_tolm; 170 172 171 173 printk_spew("Entering cn700 pci_domain_set_resources.\n"); 172 174 173 pci_tolm = find_pci_tolm(&dev->link[0]);174 mc_dev = dev_find_device(PCI_VENDOR_ID_VIA, 175 PCI_DEVICE_ID_VIA_CN700_MEMCTRL, 0);175 pci_tolm = find_pci_tolm(&dev->link[0]); 176 mc_dev = dev_find_device(PCI_VENDOR_ID_VIA, 177 PCI_DEVICE_ID_VIA_CN700_MEMCTRL, 0); 176 178 177 179 if (mc_dev) { … … 181 183 182 184 /* 183 * once the register value is not zero, the ramsize is184 * this register's value multiply 64 * 1024 * 1024 185 * Once the register value is not zero, the RAM size is 186 * this register's value multiply 64 * 1024 * 1024. 185 187 */ 186 for(rambits = 0, i = 0; i < ARRAY_SIZE(ramregs); i++) { 187 unsigned char reg; 188 for (rambits = 0, i = 0; i < ARRAY_SIZE(ramregs); i++) { 188 189 rambits = pci_read_config8(mc_dev, ramregs[i]); 189 190 if (rambits != 0) 190 191 break; 191 192 } 192 193 193 194 tomk = rambits * 64 * 1024; 194 195 printk_spew("tomk is 0x%x\n", tomk); 195 /* Compute the Top Of Low Memory , in Kb*/196 /* Compute the Top Of Low Memory (TOLM), in Kb. */ 196 197 tolmk = pci_tolm >> 10; 197 198 if (tolmk >= tomk) { … … 199 200 tolmk = tomk; 200 201 } 201 /* Report the memory regions */202 /* Report the memory regions. */ 202 203 idx = 10; 203 204 /* TODO: Hole needed? */ 204 ram_resource(dev, idx++, 0, 640); /* first 640k */ 205 /* Leave a hole for vga, 0xa0000 - 0xc0000 */ 206 ram_resource(dev, idx++, 768, (tolmk - 768 - CONFIG_VIDEO_MB * 1024)); 205 ram_resource(dev, idx++, 0, 640); /* First 640k */ 206 /* Leave a hole for VGA, 0xa0000 - 0xc0000 */ 207 ram_resource(dev, idx++, 768, 208 (tolmk - 768 - CONFIG_VIDEO_MB * 1024)); 207 209 } 208 210 assign_resources(&dev->link[0]); … … 213 215 printk_debug("Entering cn700 pci_domain_scan_bus.\n"); 214 216 215 max = pci_scan_bus(&dev->link[0], PCI_DEVFN(0, 0), 0xff, max);216 return max;217 max = pci_scan_bus(&dev->link[0], PCI_DEVFN(0, 0), 0xff, max); 218 return max; 217 219 } 218 220 219 221 static const struct device_operations pci_domain_ops = { 220 .read_resources = pci_domain_read_resources,221 .set_resources = pci_domain_set_resources,222 .enable_resources = enable_childrens_resources,223 .init = 0,224 .scan_bus = pci_domain_scan_bus,225 }; 222 .read_resources = pci_domain_read_resources, 223 .set_resources = pci_domain_set_resources, 224 .enable_resources = enable_childrens_resources, 225 .init = 0, 226 .scan_bus = pci_domain_scan_bus, 227 }; 226 228 227 229 static void cpu_bus_init(device_t dev) 228 230 { 229 initialize_cpus(&dev->link[0]);231 initialize_cpus(&dev->link[0]); 230 232 } 231 233 … … 235 237 236 238 static const struct device_operations cpu_bus_ops = { 237 .read_resources = cpu_bus_noop,238 .set_resources = cpu_bus_noop,239 .enable_resources = cpu_bus_noop,240 .init = cpu_bus_init,241 .scan_bus = 0,239 .read_resources = cpu_bus_noop, 240 .set_resources = cpu_bus_noop, 241 .enable_resources = cpu_bus_noop, 242 .init = cpu_bus_init, 243 .scan_bus = 0, 242 244 }; 243 245 … … 246 248 printk_spew("In cn700 enable_dev for device %s.\n", dev_path(dev)); 247 249 248 /* Set the operations if it is a special bus type*/249 if (dev->path.type == DEVICE_PATH_PCI_DOMAIN) {250 dev->ops = &pci_domain_ops;250 /* Set the operations if it is a special bus type. */ 251 if (dev->path.type == DEVICE_PATH_PCI_DOMAIN) { 252 dev->ops = &pci_domain_ops; 251 253 pci_set_method(dev); 252 } 253 else if (dev->path.type == DEVICE_PATH_APIC_CLUSTER) { 254 dev->ops = &cpu_bus_ops; 255 } 254 } else if (dev->path.type == DEVICE_PATH_APIC_CLUSTER) { 255 dev->ops = &cpu_bus_ops; 256 } 256 257 } 257 258 -
trunk/coreboot-v2/src/northbridge/via/cn700/raminit.c
r3556 r3644 26 26 #include "cn700.h" 27 27 28 // #define DEBUG_RAM_SETUP 128 // #define DEBUG_RAM_SETUP 1 29 29 30 30 #ifdef DEBUG_RAM_SETUP … … 61 61 62 62 /** 63 * Configure the bus between the cpuand the northbridge. This might be able to63 * Configure the bus between the CPU and the northbridge. This might be able to 64 64 * be moved to post-ram code in the future. For the most part, these registers 65 65 * should not be messed around with. These are too complex to explain short of … … 68 68 * try the values from your factory BIOS. 69 69 * 70 * TODO: Changing the DRAM frequency doesn't work (hard lockup) 71 * 72 * @param dev The northbridge's CPU Host Interface (D0F2) 70 * TODO: Changing the DRAM frequency doesn't work (hard lockup). 71 * 72 * @param dev The northbridge's CPU Host Interface (D0F2). 73 73 */ 74 74 static void c7_cpu_setup(device_t dev) … … 88 88 pci_write_config8(dev, 0x56, 0x01); 89 89 /* Miscellaneous Control */ 90 /* DRAM Operating Frequency (Bits 7:5) 91 * 000 : 100MHz 001 : 133MHz 92 * 010 : 166MHz 011 : 200MHz 93 * 100 : 266MHz 101 : 333MHz 94 * 110/111 : Reserved */ 90 /* 91 * DRAM Operating Frequency (bits 7:5) 92 * 000 : 100MHz 001 : 133MHz 93 * 010 : 166MHz 011 : 200MHz 94 * 100 : 266MHz 101 : 333MHz 95 * 110/111 : Reserved 96 */ 95 97 /* CPU Miscellaneous Control */ 96 pci_write_config8(dev, 0x59, 0x44); 98 pci_write_config8(dev, 0x59, 0x44); 97 99 /* Write Policy */ 98 100 pci_write_config8(dev, 0x5d, 0xb2); … … 113 115 pci_write_config8(dev, 0x66, 0xff); 114 116 pci_write_config8(dev, 0x67, 0x30); 115 116 /* Host Bus I O Circuit (See datasheet) */117 118 /* Host Bus I/O Circuit (see datasheet) */ 117 119 /* Host Address Pullup/down Driving */ 118 120 pci_write_config8(dev, 0x70, 0x11); … … 134 136 /* Address Strobe Input Delay Control */ 135 137 pci_write_config8(dev, 0x7a, 0x24); 136 / / Address CKG Rising/Falling Time Control138 /* Address CKG Rising/Falling Time Control */ 137 139 pci_write_config8(dev, 0x7b, 0xaa); 138 140 /* Address CKG Clock Rising/Falling Time Control */ … … 149 151 150 152 /** 151 * Set up dram size according to spd data. Eventually, DRAM timings should be153 * Set up DRAM size according to SPD data. Eventually, DRAM timings should be 152 154 * done in a similar manner. 153 155 * 154 * @param ctrl The northbridge devices and spdaddresses.156 * @param ctrl The northbridge devices and SPD addresses. 155 157 */ 156 158 static void sdram_set_size(const struct mem_controller *ctrl) … … 160 162 ranks = spd_read_byte(ctrl->channel0[0], SPD_NUM_DIMM_BANKS); 161 163 ranks = (ranks & 0x07) + 1; 162 density = spd_read_byte(ctrl->channel0[0], SPD_DENSITY_OF_EACH_ROW_ON_MODULE);163 switch (density)164 {165 case 0x80:166 result = 0x08; /* 512MB / 64MB = 0x08 */167 break;168 case 0x40:169 result = 0x04;170 break;171 case 0x20:172 result = 0x02;173 break;174 case 0x10:175 result = 0xff; /* 16GB */176 break;177 case 0x08:178 result = 0xff; /* 8GB */179 break;180 case 0x04:181 result = 0xff; /* 4GB */182 break;183 case 0x02:184 result = 0x20; /* 2GB */185 break;186 case 0x01:187
