3 * by yinghai.lu@amd.com
6 static void bcm5785_enable_rom(void)
11 /* Enable 4MB rom access at 0xFFC00000 - 0xFFFFFFFF */
12 /* Locate the BCM 5785 SB PCI Main */
13 addr = pci_locate_device(PCI_ID(0x1166, 0x0205), 0); // 0x0201?
15 /* Set the 4MB enable bit bit */
16 byte = pci_read_config8(addr, 0x41);
18 pci_write_config8(addr, 0x41, byte);
21 static void bcm5785_enable_lpc(void)
27 dev = pci_locate_device(PCI_ID(0x1166, 0x0234), 0);
30 byte = pci_read_config8(dev, 0x44);
33 pci_write_config8(dev, 0x44, byte);
36 byte = pci_read_config8(dev, 0x48);
37 /* superio port 0x2e/4e enable */
39 pci_write_config8(dev, 0x48, byte);
42 static void bcm5785_enable_wdt_port_cf9(void)
48 dev = pci_locate_device(PCI_ID(0x1166, 0x0205), 0);
50 dword_old = pci_read_config32(dev, 0x4c);
51 dword = dword_old | (1<<4); //enable Timer Func
52 if(dword != dword_old ) {
53 pci_write_config32(dev, 0x4c, dword);
56 dword_old = pci_read_config32(dev, 0x6c);
57 dword = dword_old | (1<<9); //unhide Timer Func in pci space
58 if(dword != dword_old ) {
59 pci_write_config32(dev, 0x6c, dword);
62 dev = pci_locate_device(PCI_ID(0x1166, 0x0238), 0);
65 pci_write_config8(dev, 0x40, (1<<2));
68 static unsigned get_sbdn(unsigned bus)
73 * There can only be one 8111 on a hypertransport chain/bus.
75 dev = pci_locate_device_on_bus(
76 PCI_ID(0x1166, 0x0036),
79 return (dev>>15) & 0x1f;
85 static void enable_fid_change_on_sb(unsigned sbbusn, unsigned sbdn)
104 static void ldtstop_sb(void)
110 void hard_reset(void)
112 bcm5785_enable_wdt_port_cf9();
121 void soft_reset(void)
123 bcm5785_enable_wdt_port_cf9();
128 // outb(0x02, 0x0cf9);
135 static void bcm5785_enable_msg(void)
142 dev = pci_locate_device(PCI_ID(0x1166, 0x0205), 0);
144 byte = pci_read_config8(dev, 0x42);
145 byte = (1<<1); //enable a20
146 pci_write_config8(dev, 0x42, byte);
148 dword_old = pci_read_config32(dev, 0x6c);
149 // bit 5: enable A20 Message
150 // bit 4: enable interrupt messages
151 // bit 3: enable reset init message
152 // bit 2: enable keyboard init message
153 // bit 1: enable upsteam messages
154 // bit 0: enable shutdowm message to init generation
155 dword = dword_old | (1<<5) | (1<<3) | (1<<2) | (1<<1) | (1<<0); // bit 1 and bit 4 must be set, otherwise interrupt msg will not be delivered to the processor
156 if(dword != dword_old ) {
157 pci_write_config32(dev, 0x6c, dword);
162 static void bcm5785_early_setup(void)
169 // enable device on bcm5785 at first
170 dev = pci_locate_device(PCI_ID(0x1166, 0x0205), 0);
171 dword = pci_read_config32(dev, 0x64);
172 dword |= (1<<15) | (1<<11) | (1<<3); // ioapci enable
173 dword |= (1<<8); // USB enable
174 dword |= /* (1<<27)|*/(1<<14); // IDE enable
175 pci_write_config32(dev, 0x64, dword);
177 byte = pci_read_config8(dev, 0x84);
178 byte |= (1<<0); // SATA enable
179 pci_write_config8(dev, 0x84, byte);
181 // WDT and cf9 for later in coreboot_ram to call hard_reset
182 bcm5785_enable_wdt_port_cf9();
184 bcm5785_enable_msg();
189 byte = pci_read_config8(dev, 0x4e);
190 byte |= (1<<4); //enable IDE ext regs
191 pci_write_config8(dev, 0x4e, byte);
194 dev = pci_locate_device(PCI_ID(0x1166, 0x0214), 0);
195 byte = pci_read_config8(dev, 0x48);
196 byte &= ~1; // disable pri channel
197 pci_write_config8(dev, 0x48, byte);
198 pci_write_config8(dev, 0xb0, 0x01);
199 pci_write_config8(dev, 0xb2, 0x02);
200 byte = pci_read_config8(dev, 0x06);
201 byte |= (1<<4); // so b0, b2 can not be changed from now
202 pci_write_config8(dev, 0x06, byte);
203 byte = pci_read_config8(dev, 0x49);
204 byte |= 1; // enable second channel
205 pci_write_config8(dev, 0x49, byte);
208 dev = pci_locate_device(PCI_ID(0x1166, 0x0234), 0);
210 byte = pci_read_config8(dev, 0x40);
211 byte |= (1<<3)|(1<<2); // LPC Retry, LPC to PCI DMA enable
212 pci_write_config8(dev, 0x40, byte);
214 pci_write_config32(dev, 0x60, 0x0000ffff); // LPC Memory hole start and end
217 pci_write_config8(dev, 0x90, 0x40);
218 pci_write_config8(dev, 0x92, 0x06);
219 pci_write_config8(dev, 0x9c, 0x7c); //PHY timinig register
220 pci_write_config8(dev, 0xa4, 0x02); //mask reg - low/full speed func
221 pci_write_config8(dev, 0xa5, 0x02); //mask reg - low/full speed func
222 pci_write_config8(dev, 0xa6, 0x00); //mask reg - high speed func
223 pci_write_config8(dev, 0xb4, 0x40);