3 * by yinghai.lu@amd.com
7 #include "bcm5785_enable_rom.c"
9 static void bcm5785_enable_lpc(void)
15 dev = pci_locate_device(PCI_ID(0x1166, 0x0234), 0);
18 byte = pci_read_config8(dev, 0x44);
21 pci_write_config8(dev, 0x44, byte);
24 byte = pci_read_config8(dev, 0x48);
25 /* superio port 0x2e/4e enable */
27 pci_write_config8(dev, 0x48, byte);
30 static void bcm5785_enable_wdt_port_cf9(void)
36 dev = pci_locate_device(PCI_ID(0x1166, 0x0205), 0);
38 dword_old = pci_read_config32(dev, 0x4c);
39 dword = dword_old | (1<<4); //enable Timer Func
40 if(dword != dword_old ) {
41 pci_write_config32(dev, 0x4c, dword);
44 dword_old = pci_read_config32(dev, 0x6c);
45 dword = dword_old | (1<<9); //unhide Timer Func in pci space
46 if(dword != dword_old ) {
47 pci_write_config32(dev, 0x6c, dword);
50 dev = pci_locate_device(PCI_ID(0x1166, 0x0238), 0);
53 pci_write_config8(dev, 0x40, (1<<2));
56 static unsigned get_sbdn(unsigned bus)
61 * There can only be one 8111 on a hypertransport chain/bus.
63 dev = pci_locate_device_on_bus(
64 PCI_ID(0x1166, 0x0036),
67 return (dev>>15) & 0x1f;
73 static void enable_fid_change_on_sb(unsigned sbbusn, unsigned sbdn)
92 static void ldtstop_sb(void)
100 bcm5785_enable_wdt_port_cf9();
109 void soft_reset(void)
111 bcm5785_enable_wdt_port_cf9();
116 // outb(0x02, 0x0cf9);
123 static void bcm5785_enable_msg(void)
130 dev = pci_locate_device(PCI_ID(0x1166, 0x0205), 0);
132 byte = pci_read_config8(dev, 0x42);
133 byte = (1<<1); //enable a20
134 pci_write_config8(dev, 0x42, byte);
136 dword_old = pci_read_config32(dev, 0x6c);
137 // bit 5: enable A20 Message
138 // bit 4: enable interrupt messages
139 // bit 3: enable reset init message
140 // bit 2: enable keyboard init message
141 // bit 1: enable upsteam messages
142 // bit 0: enable shutdowm message to init generation
143 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
144 if(dword != dword_old ) {
145 pci_write_config32(dev, 0x6c, dword);
150 static void bcm5785_early_setup(void)
157 // enable device on bcm5785 at first
158 dev = pci_locate_device(PCI_ID(0x1166, 0x0205), 0);
159 dword = pci_read_config32(dev, 0x64);
160 dword |= (1<<15) | (1<<11) | (1<<3); // ioapci enable
161 dword |= (1<<8); // USB enable
162 dword |= /* (1<<27)|*/(1<<14); // IDE enable
163 pci_write_config32(dev, 0x64, dword);
165 byte = pci_read_config8(dev, 0x84);
166 byte |= (1<<0); // SATA enable
167 pci_write_config8(dev, 0x84, byte);
169 // WDT and cf9 for later in coreboot_ram to call hard_reset
170 bcm5785_enable_wdt_port_cf9();
172 bcm5785_enable_msg();
177 byte = pci_read_config8(dev, 0x4e);
178 byte |= (1<<4); //enable IDE ext regs
179 pci_write_config8(dev, 0x4e, byte);
182 dev = pci_locate_device(PCI_ID(0x1166, 0x0214), 0);
183 byte = pci_read_config8(dev, 0x48);
184 byte &= ~1; // disable pri channel
185 pci_write_config8(dev, 0x48, byte);
186 pci_write_config8(dev, 0xb0, 0x01);
187 pci_write_config8(dev, 0xb2, 0x02);
188 byte = pci_read_config8(dev, 0x06);
189 byte |= (1<<4); // so b0, b2 can not be changed from now
190 pci_write_config8(dev, 0x06, byte);
191 byte = pci_read_config8(dev, 0x49);
192 byte |= 1; // enable second channel
193 pci_write_config8(dev, 0x49, byte);
196 dev = pci_locate_device(PCI_ID(0x1166, 0x0234), 0);
198 byte = pci_read_config8(dev, 0x40);
199 byte |= (1<<3)|(1<<2); // LPC Retry, LPC to PCI DMA enable
200 pci_write_config8(dev, 0x40, byte);
202 pci_write_config32(dev, 0x60, 0x0000ffff); // LPC Memory hole start and end
205 pci_write_config8(dev, 0x90, 0x40);
206 pci_write_config8(dev, 0x92, 0x06);
207 pci_write_config8(dev, 0x9c, 0x7c); //PHY timinig register
208 pci_write_config8(dev, 0xa4, 0x02); //mask reg - low/full speed func
209 pci_write_config8(dev, 0xa5, 0x02); //mask reg - low/full speed func
210 pci_write_config8(dev, 0xa6, 0x00); //mask reg - high speed func
211 pci_write_config8(dev, 0xb4, 0x40);