3 * by yinghai.lu@amd.com
8 #include "bcm5785_enable_rom.c"
10 static void bcm5785_enable_lpc(void)
16 dev = pci_locate_device(PCI_ID(0x1166, 0x0234), 0);
19 byte = pci_read_config8(dev, 0x44);
22 pci_write_config8(dev, 0x44, byte);
25 byte = pci_read_config8(dev, 0x48);
26 /* superio port 0x2e/4e enable */
28 pci_write_config8(dev, 0x48, byte);
31 static void bcm5785_enable_wdt_port_cf9(void)
37 dev = pci_locate_device(PCI_ID(0x1166, 0x0205), 0);
39 dword_old = pci_read_config32(dev, 0x4c);
40 dword = dword_old | (1<<4); //enable Timer Func
41 if(dword != dword_old ) {
42 pci_write_config32(dev, 0x4c, dword);
45 dword_old = pci_read_config32(dev, 0x6c);
46 dword = dword_old | (1<<9); //unhide Timer Func in pci space
47 if(dword != dword_old ) {
48 pci_write_config32(dev, 0x6c, dword);
51 dev = pci_locate_device(PCI_ID(0x1166, 0x0238), 0);
54 pci_write_config8(dev, 0x40, (1<<2));
57 unsigned get_sbdn(unsigned bus)
62 * There can only be one bcm5785 on a hypertransport chain/bus.
64 dev = pci_locate_device_on_bus(
65 PCI_ID(0x1166, 0x0036),
68 return (dev>>15) & 0x1f;
74 void enable_fid_change_on_sb(unsigned sbbusn, unsigned sbdn)
101 bcm5785_enable_wdt_port_cf9();
110 void soft_reset(void)
112 bcm5785_enable_wdt_port_cf9();
117 // outb(0x02, 0x0cf9);
124 static void bcm5785_enable_msg(void)
131 dev = pci_locate_device(PCI_ID(0x1166, 0x0205), 0);
133 byte = pci_read_config8(dev, 0x42);
134 byte = (1<<1); //enable a20
135 pci_write_config8(dev, 0x42, byte);
137 dword_old = pci_read_config32(dev, 0x6c);
138 // bit 5: enable A20 Message
139 // bit 4: enable interrupt messages
140 // bit 3: enable reset init message
141 // bit 2: enable keyboard init message
142 // bit 1: enable upsteam messages
143 // bit 0: enable shutdowm message to init generation
144 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
145 if(dword != dword_old ) {
146 pci_write_config32(dev, 0x6c, dword);
151 static void bcm5785_early_setup(void)
158 // enable device on bcm5785 at first
159 dev = pci_locate_device(PCI_ID(0x1166, 0x0205), 0);
160 dword = pci_read_config32(dev, 0x64);
161 dword |= (1<<15) | (1<<11) | (1<<3); // ioapci enable
162 dword |= (1<<8); // USB enable
163 dword |= /* (1<<27)|*/(1<<14); // IDE enable
164 pci_write_config32(dev, 0x64, dword);
166 byte = pci_read_config8(dev, 0x84);
167 byte |= (1<<0); // SATA enable
168 pci_write_config8(dev, 0x84, byte);
170 // WDT and cf9 for later in coreboot_ram to call hard_reset
171 bcm5785_enable_wdt_port_cf9();
173 bcm5785_enable_msg();
178 byte = pci_read_config8(dev, 0x4e);
179 byte |= (1<<4); //enable IDE ext regs
180 pci_write_config8(dev, 0x4e, byte);
183 dev = pci_locate_device(PCI_ID(0x1166, 0x0214), 0);
184 byte = pci_read_config8(dev, 0x48);
185 byte &= ~1; // disable pri channel
186 pci_write_config8(dev, 0x48, byte);
187 pci_write_config8(dev, 0xb0, 0x01);
188 pci_write_config8(dev, 0xb2, 0x02);
189 byte = pci_read_config8(dev, 0x06);
190 byte |= (1<<4); // so b0, b2 can not be changed from now
191 pci_write_config8(dev, 0x06, byte);
192 byte = pci_read_config8(dev, 0x49);
193 byte |= 1; // enable second channel
194 pci_write_config8(dev, 0x49, byte);
197 dev = pci_locate_device(PCI_ID(0x1166, 0x0234), 0);
199 byte = pci_read_config8(dev, 0x40);
200 byte |= (1<<3)|(1<<2); // LPC Retry, LPC to PCI DMA enable
201 pci_write_config8(dev, 0x40, byte);
203 pci_write_config32(dev, 0x60, 0x0000ffff); // LPC Memory hole start and end
206 pci_write_config8(dev, 0x90, 0x40);
207 pci_write_config8(dev, 0x92, 0x06);
208 pci_write_config8(dev, 0x9c, 0x7c); //PHY timinig register
209 pci_write_config8(dev, 0xa4, 0x02); //mask reg - low/full speed func
210 pci_write_config8(dev, 0xa5, 0x02); //mask reg - low/full speed func
211 pci_write_config8(dev, 0xa6, 0x00); //mask reg - high speed func
212 pci_write_config8(dev, 0xb4, 0x40);