Fix/amend the incorrect pnp_dev_info[] items for the ITE IT8712F Super I/O.
[coreboot.git] / src / southbridge / amd / sb600 / stage1.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 Advanced Micro Devices, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19 #include <types.h>
20 #include <lib.h>
21 #include <console.h>
22 #include <device/pci.h>
23 #include <msr.h>
24 #include <legacy.h>
25 #include <device/pci.h>
26 #include <statictree.h>
27 #include <config.h>
28 #include <io.h>
29 BORKED
30 #define SMBUS_IO_BASE 0x1000    /* Is it a temporary SMBus I/O base address? */
31          /*SIZE 0x40 */
32
33 /* Get SB ASIC Revision.*/
34 static u8 get_sb600_revision()
35 {
36         u32 dev;
37         pci_conf1_find_device(0x1002,  0x4385, &dev);
38
39         if (dev == PCI_DEV_INVALID) {
40                 die("SMBUS controller not found\r\n");
41         }
42         return pci_conf1_read_config8(dev, 0x08);
43 }
44
45
46 /***************************************
47 * Legacy devices are mapped to LPC space.
48 *       serial port 0
49 *       KBC Port
50 *       ACPI Micro-controller port
51 *       LPC ROM size,
52 * NOTE: Call me ASAP, because I will reset LPC ROM size!
53 ***************************************/
54 static void sb600_lpc_init(void)
55 {
56         u8 reg8;
57         u32 reg32;
58         u32 dev;
59
60         /* Enable lpc controller */
61         pci_conf1_find_device(0x1002,  0x4385, &dev);   /* SMBUS controller */
62         reg32 = pci_conf1_read_config32(dev, 0x64);
63         reg32 |= 0x00100000;
64         pci_conf1_write_config32(dev, 0x64, reg32);
65
66         pci_conf1_find_device(0x1002,  0x438d, &dev);   /* LPC Controller */
67         /* Serial 0 */
68         reg8 = pci_conf1_read_config8(dev, 0x44);
69         reg8 |= (1 << 6);
70         pci_conf1_write_config8(dev, 0x44, reg8);
71
72         /* PS/2 keyboard, ACPI */
73         reg8 = pci_conf1_read_config8(dev, 0x47);
74         reg8 |= (1 << 5) | (1 << 6);
75         pci_conf1_write_config8(dev, 0x47, reg8);
76
77         /* SuperIO, LPC ROM */
78         reg8 = pci_conf1_read_config8(dev, 0x48);
79         reg8 |= (1 << 1) | (1 << 0);    /* enable Super IO config port 2e-2h, 4e-4f */
80         reg8 |= (1 << 3) | (1 << 4);    /* enable for LPC ROM address range1&2, Enable 512KB rom access at 0xFFF80000 - 0xFFFFFFFF  */
81         reg8 |= 1 << 6;         /* enable for RTC I/O range */
82         pci_conf1_write_config8(dev, 0x48, reg8);
83
84         /* hardware should enable LPC ROM by pin strapes */
85         /*  rom access at 0xFFF80000/0xFFF00000 - 0xFFFFFFFF */
86         /* See detail in BDG-215SB600-03.pdf page 15. */
87         pci_conf1_write_config16(dev, 0x68, 0x000e);    /* enable LPC ROM range, 0xfff8: 512KB, 0xfff0: 1MB; */
88         pci_conf1_write_config16(dev, 0x6c, 0xfff0);    /* enable LPC ROM range, 0xfff8: 512KB, 0xfff0: 1MB  */
89 }
90
91 /* what is its usage? */
92 static u32 get_sbdn(u32 bus)
93 {
94         u32 dev;
95
96         /* Find the device. */
97         pci_conf1_find_on_bus(bus, 0x1002, 0x4385, &dev);
98         return (dev >> 15) & 0x1f;
99 }
100
101
102 static u8 dual_core()
103 {
104         if(((cpuid_eax(0x80000000) & ~0xff) >= 8)) {
105                 if(cpuid_ecx(0x80000008) & 1)
106                         return 1;
107         }
108         return 0;
109 }
110
111 /*
112 SB600 VFSMAF (VID/FID System Management Action Field)  is 010b by default.
113 RPR 2.3.3 C-state and VID/FID change for the K8 platform.
114 */
115 static void enable_fid_change_on_sb(u32 sbbusn, u32 sbdn)
116 {
117         u8 byte;
118         byte = pmio_read(0x9a);
119         byte &= ~0x34;
120         if(dual_core())
121                 byte |= 0x34;
122         else
123                 byte |= 0x04;
124         pmio_write(0x9a, byte);
125
126         byte = pmio_read(0x8f);
127         byte &= ~0x30;
128         byte |= 0x20;
129         pmio_write(0x8f, byte);
130
131         pmio_write(0x8b, 0x01);
132         pmio_write(0x8a, 0x90);
133
134         if(get_sb600_revision() > 0x13)
135                 pmio_write(0x88, 0x10);
136         else
137                 pmio_write(0x88, 0x06);
138
139         byte = pmio_read(0x7c);
140         byte &= ~0x01;
141         byte |= 0x01;
142         pmio_write(0x7c, byte);
143
144         /*Must be 0 for K8 platform.*/
145         byte = pmio_read(0x68);
146         byte &= ~0x01;
147         pmio_write(0x68, byte);
148         /*Must be 0 for K8 platform.*/
149         byte = pmio_read(0x8d);
150         byte &= ~(1<<6);
151         pmio_write(0x8d, byte);
152
153         byte = pmio_read(0x61);
154         byte &= ~0x04;
155         pmio_write(0x61, byte);
156
157         byte = pmio_read(0x42);
158         byte &= ~0x04;
159         pmio_write(0x42, byte);
160
161         if(get_sb600_revision() == 0x14) {
162                 pmio_write(0x89, 0x10);
163
164                 byte = pmio_read(0x52);
165                 byte |= 0x80;
166                 pmio_write(0x52, byte);
167         }
168 }
169
170
171 static void hard_reset(void)
172 {
173         set_bios_reset();
174
175         /* full reset */
176         outb(0x0a, 0x0cf9);
177         outb(0x0e, 0x0cf9);
178 }
179
180 static void soft_reset(void)
181 {
182         set_bios_reset();
183         /* link reset */
184         outb(0x06, 0x0cf9);
185 }
186
187
188 static void sb600_pci_port80()
189 {
190         u8 byte;
191         u32 dev;
192
193         /* P2P Bridge */
194         pci_conf1_find_device(0x1002,  0x4384, &dev);
195
196         byte = pci_conf1_read_config8(dev, 0x40);
197         byte |= 1 << 5;
198         pci_conf1_write_config8(dev, 0x40, byte);
199
200         byte = pci_conf1_read_config8(dev, 0x4B);
201         byte |= 1 << 7;
202         pci_conf1_write_config8(dev, 0x4B, byte);
203
204         byte = pci_conf1_read_config8(dev, 0x1C);
205         byte |= 0xF << 4;
206         pci_conf1_write_config8(dev, 0x1C, byte);
207
208         byte = pci_conf1_read_config8(dev, 0x1D);
209         byte |= 0xF << 4;
210         pci_conf1_write_config8(dev, 0x1D, byte);
211
212         byte = pci_conf1_read_config8(dev, 0x04);
213         byte |= 1 << 0;
214         pci_conf1_write_config8(dev, 0x04, byte);
215
216         pci_conf1_find_device(0x1002,  0x438D, &dev);
217
218         byte = pci_conf1_read_config8(dev, 0x4A);
219         byte &= ~(1 << 5);      /* disable lpc port 80 */
220         pci_conf1_write_config8(dev, 0x4A, byte);
221 }
222
223 static void sb600_lpc_port80(void)
224 {
225         u8 byte;
226         u32 dev;
227         u32 reg32;
228
229         /* enable lpc controller */
230         pci_conf1_find_device(0x1002,  0x4385, &dev);
231         reg32 = pci_conf1_read_config32(dev, 0x64);
232         reg32 |= 0x00100000;    /* lpcEnable */
233         pci_conf1_write_config32(dev, 0x64, reg32);
234
235         /* enable prot80 LPC decode in pci function 3 configuration space. */
236         pci_conf1_find_device(0x1002,  0x438d, &dev);
237         byte = pci_conf1_read_config8(dev, 0x4a);
238         byte |= 1 << 5;         /* enable port 80 */
239         pci_conf1_write_config8(dev, 0x4a, byte);
240 }
241
242
243 /* sbDevicesPorInitTable */
244 static void sb600_devices_por_init()
245 {
246         u32 dev;
247         u8 byte;
248
249         printk(BIOS_INFO, "sb600_devices_por_init()\n");
250         /* SMBus Device, BDF:0-20-0 */
251         printk(BIOS_INFO, "sb600_devices_por_init(): SMBus Device, BDF:0-20-0\n");
252         pci_conf1_find_device(0x1002,  0x4385, &dev);
253
254         if (dev == PCI_DEV_INVALID) {
255                 die("SMBUS controller not found\r\n");
256         }
257         printk(BIOS_INFO, "SMBus controller enabled, sb revision is 0x%x\r\n",
258                     get_sb600_revision());
259
260         /* sbPorAtStartOfTblCfg */
261         /* Set A-Link bridge access address. This address is set at device 14h, function 0, register 0xf0.
262          * This is an I/O address. The I/O address must be on 16-byte boundry.  */
263         pci_conf1_write_config32(dev, 0xf0, AB_INDX);
264
265         /* To enable AB/BIF DMA access, a specific register inside the BIF register space needs to be configured first. */
266         /*Enables the SB600 to send transactions upstream over A-Link Express interface. */
267         axcfg_reg(0x04, 1 << 2, 1 << 2);
268         axindxc_reg(0x21, 0xff, 0);
269
270         /* 2.3.5:Enabling Non-Posted Memory Write for the K8 Platform */
271         axindxc_reg(0x10, 1 << 9, 1 << 9);
272         /* END of sbPorAtStartOfTblCfg */
273
274         /* sbDevicesPorInitTables */
275         /* set smbus iobase */
276         pci_conf1_write_config32(dev, 0x10, SMBUS_IO_BASE | 1);
277
278         /* enable smbus controller interface */
279         byte = pci_conf1_read_config8(dev, 0xd2);
280         byte |= (1 << 0);
281         pci_conf1_write_config8(dev, 0xd2, byte);
282
283         /* set smbus 1, ASF 2.0 (Alert Standard Format), iobase */
284         pci_conf1_write_config16(dev, 0x58, SMBUS_IO_BASE | 0x11);
285
286         /* TODO: I don't know the useage of followed two lines. I copied them from CIM. */
287         pci_conf1_write_config8(dev, 0x0a, 0x1);
288         pci_conf1_write_config8(dev, 0x0b, 0x6);
289
290         /* KB2RstEnable */
291         pci_conf1_write_config8(dev, 0x40, 0xd4);
292
293         /* Enable ISA Address 0-960K decoding */
294         pci_conf1_write_config8(dev, 0x48, 0x0f);
295
296         /* Enable ISA  Address 0xC0000-0xDFFFF decode */
297         pci_conf1_write_config8(dev, 0x49, 0xff);
298
299         /* Enable decode cycles to IO C50, C51, C52 GPM controls. */
300         byte = pci_conf1_read_config8(dev, 0x41);
301         byte &= 0x80;
302         byte |= 0x33;
303         pci_conf1_write_config8(dev, 0x41, byte);
304
305         /* Legacy DMA Prefetch Enhancement, CIM masked it. */
306         /* pci_conf1_write_config8(dev, 0x43, 0x1); */
307
308         /* Disabling Legacy USB Fast SMI# */
309         byte = pci_conf1_read_config8(dev, 0x62);
310         byte |= 0x24;
311         pci_conf1_write_config8(dev, 0x62, byte);
312
313         /* Features Enable */
314         pci_conf1_write_config32(dev, 0x64, 0x829E79BF);
315
316         /* SerialIrq Control */
317         pci_conf1_write_config8(dev, 0x69, 0x90);
318
319         /* Test Mode, PCIB_SReset_En Mask is set. */
320         pci_conf1_write_config8(dev, 0x6c, 0x20);
321
322         /* IO Address Enable, CIM set 0x78 only and masked 0x79. */
323         /*pci_conf1_write_config8(dev, 0x79, 0x4F); */
324         pci_conf1_write_config8(dev, 0x78, 0xFF);
325
326         /* This register is not used on sb600. It came from older chipset. */
327         /*pci_conf1_write_config8(dev, 0x95, 0xFF); */
328
329         /* Set smbus iospace enable, I don't know why write 0x04 into reg5 that is reserved */
330         pci_conf1_write_config16(dev, 0x4, 0x0407);
331
332         /* clear any lingering errors, so the transaction will run */
333         outb(inb(SMBUS_IO_BASE + SMBHSTSTAT), SMBUS_IO_BASE + SMBHSTSTAT);
334
335         /* IDE Device, BDF:0-20-1 */
336         printk(BIOS_INFO, "sb600_devices_por_init(): IDE Device, BDF:0-20-1\n");
337         pci_conf1_find_device(0x1002,  0x438C, &dev);
338         /* Disable prefetch */
339         byte = pci_conf1_read_config8(dev, 0x63);
340         byte |= 0x1;
341         pci_conf1_write_config8(dev, 0x63, byte);
342
343         /* LPC Device, BDF:0-20-3 */
344         printk(BIOS_INFO, "sb600_devices_por_init(): LPC Device, BDF:0-20-3\n");
345         pci_conf1_find_device(0x1002,  0x438D, &dev);
346         /* DMA enable */
347         pci_conf1_write_config8(dev, 0x40, 0x04);
348
349         /* IO Port Decode Enable */
350         pci_conf1_write_config8(dev, 0x44, 0xFF);
351         pci_conf1_write_config8(dev, 0x45, 0xFF);
352         pci_conf1_write_config8(dev, 0x46, 0xC3);
353         pci_conf1_write_config8(dev, 0x47, 0xFF);
354
355         /* IO/Mem Port Decode Enable, I don't know why CIM disable some ports.
356          *  Disable LPC TimeOut counter, enable SuperIO Configuration Port (2e/2f),
357          * Alternate SuperIO Configuration Port (4e/4f), Wide Generic IO Port (64/65).
358          * Enable bits for LPC ROM memory address range 1&2 for 1M ROM setting.*/
359         byte = pci_conf1_read_config8(dev, 0x48);
360         byte |= (1 << 1) | (1 << 0);    /* enable Super IO config port 2e-2h, 4e-4f */
361         byte |= (1 << 3) | (1 << 4);    /* enable for LPC ROM address range1&2, Enable 512KB rom access at 0xFFF80000 - 0xFFFFFFFF */
362         byte |= 1 << 6;         /* enable for RTC I/O range */
363         pci_conf1_write_config8(dev, 0x48, byte);
364         pci_conf1_write_config8(dev, 0x49, 0xFF);
365         /* Enable 0x480-0x4bf, 0x4700-0x470B */
366         byte = pci_conf1_read_config8(dev, 0x4A);
367         byte |= ((1 << 1) + (1 << 6));  /*0x42, save the configuraion for port 0x80. */
368         pci_conf1_write_config8(dev, 0x4A, byte);
369
370         /* Set LPC ROM size, it has been done in sb600_lpc_init(). 
371          * enable LPC ROM range, 0xfff8: 512KB, 0xfff0: 1MB;
372          * enable LPC ROM range, 0xfff8: 512KB, 0xfff0: 1MB
373          * pci_conf1_write_config16(dev, 0x68, 0x000e)
374          * pci_conf1_write_config16(dev, 0x6c, 0xfff0);*/
375
376         /* Enable Tpm12_en and Tpm_legacy. I don't know what is its usage and copied from CIM. */
377         pci_conf1_write_config8(dev, 0x7C, 0x05);
378
379         /* P2P Bridge, BDF:0-20-4, the configuration of the registers in this dev are copied from CIM, 
380          * TODO: I don't know what are their mean? */
381         printk(BIOS_INFO, "sb600_devices_por_init(): P2P Bridge, BDF:0-20-4\n");
382         pci_conf1_find_device(0x1002,  0x4384, &dev);
383         /* I don't know why CIM tried to write into a read-only reg! */
384         /*pci_conf1_write_config8(dev, 0x0c, 0x20) */ ;
385
386         /* Arbiter enable. */
387         pci_conf1_write_config8(dev, 0x43, 0xff);
388
389         /* Set PCDMA request into hight priority list. */
390         /* pci_conf1_write_config8(dev, 0x49, 0x1) */ ;
391
392         pci_conf1_write_config8(dev, 0x40, 0x26);
393
394         /* I don't know why CIM set reg0x1c as 0x11. 
395          * System will block at sdram_initialize() if I set it before call sdram_initialize().
396          * If it is necessary to set reg0x1c as 0x11, please call this function after sdram_initialize().
397          * pci_conf1_write_config8(dev, 0x1c, 0x11);
398          * pci_conf1_write_config8(dev, 0x1d, 0x11);*/
399
400         /*CIM set this register; but I didn't find its description in RPR.
401         On DBM690T platform, I didn't find different between set and skip this register.
402         But on Filbert platform, the DEBUG message from serial port on Peanut board can't be displayed
403         after the bit0 of this register is set.
404         pci_conf1_write_config8(dev, 0x04, 0x21);
405         */
406         pci_conf1_write_config8(dev, 0x0d, 0x40);
407         pci_conf1_write_config8(dev, 0x1b, 0x40);
408         /* Enable PCIB_DUAL_EN_UP will fix potential problem with PCI cards. */
409         pci_conf1_write_config8(dev, 0x50, 0x01);
410
411         /* SATA Device, BDF:0-18-0, Non-Raid-5 SATA controller */
412         printk(BIOS_INFO, "sb600_devices_por_init(): SATA Device, BDF:0-18-0\n");
413         pci_conf1_find_device(0x1002,  0x4380, &dev);
414
415         /*PHY Global Control, we are using A14.
416          * default:  0x2c40 for ASIC revision A12 and below
417          *      0x2c00 for ASIC revision A13 and above.*/
418         pci_conf1_write_config16(dev, 0x86, 0x2C00);
419
420         /* PHY Port0-3 Control */
421         pci_conf1_write_config32(dev, 0x88, 0xB400DA);
422         pci_conf1_write_config32(dev, 0x8c, 0xB400DA);
423         pci_conf1_write_config32(dev, 0x90, 0xB400DA);
424         pci_conf1_write_config32(dev, 0x94, 0xB400DA);
425
426         /* Port0-3 BIST Control/Status */
427         pci_conf1_write_config8(dev, 0xa5, 0xB8);
428         pci_conf1_write_config8(dev, 0xad, 0xB8);
429         pci_conf1_write_config8(dev, 0xb5, 0xB8);
430         pci_conf1_write_config8(dev, 0xbd, 0xB8);
431 }
432
433 /* sbPmioPorInitTable, Pre-initializing PMIO register space
434 * The power management (PM) block is resident in the PCI/LPC/ISA bridge.
435 * The PM regs are accessed via IO mapped regs 0xcd6 and 0xcd7.
436 * The index address is first programmed into IO reg 0xcd6.
437 * Read or write values are accessed through IO reg 0xcd7.
438 */
439 static void sb600_pmio_por_init()
440 {
441         u8 byte;
442
443         printk(BIOS_INFO, "sb600_pmio_por_init()\n");
444         /* K8KbRstEn, KB_RST# control for K8 system. */
445         byte = pmio_read(0x66);
446         byte |= 0x20;
447         pmio_write(0x66, byte);
448
449         /* RPR2.3.4 S3/S4/S5 Function for the K8 Platform. */
450         byte = pmio_read(0x52);
451         byte &= 0xc0;
452         byte |= 0x08;
453         pmio_write(0x52, byte);
454
455         /* C state enable and SLP enable in C states. */
456         byte = pmio_read(0x67);
457         byte |= 0x6;
458         pmio_write(0x67, byte);
459
460         /* CIM sets 0x0e, but bit2 is for P4 system. */
461         byte = pmio_read(0x68);
462         byte &= 0xf0;
463         byte |= 0x0c;
464         pmio_write(0x68, byte);
465
466         /* Watch Dog Timer Control
467          * Set watchdog time base to 0xfec000f0 to avoid SCSI card boot failure.
468          * But I don't find WDT is enabled in SMBUS 0x41 bit3 in CIM.
469          */
470         pmio_write(0x6c, 0xf0);
471         pmio_write(0x6d, 0x00);
472         pmio_write(0x6e, 0xc0);
473         pmio_write(0x6f, 0xfe);
474
475         /* rpr2.14: Enables HPET periodical mode */
476         byte = pmio_read(0x9a);
477         byte |= 1 << 7;
478         pmio_write(0x9a, byte);
479         byte = pmio_read(0x9f);
480         byte |= 1 << 5;
481         pmio_write(0x9f, byte);
482         byte = pmio_read(0x9e);
483         byte |= (1 << 6) | (1 << 7);
484         pmio_write(0x9e, byte);
485
486         /* rpr2.14: Hides SM bus controller Bar1 where stores HPET MMIO base address */
487         byte = pmio_read(0x55);
488         byte |= 1 << 7;
489         pmio_write(0x55, byte);
490
491         /* rpr2.14: Make HPET MMIO decoding controlled by the memory enable bit in command register of LPC ISA bridage */
492         byte = pmio_read(0x52);
493         byte |= 1 << 6;
494         pmio_write(0x52, byte);
495
496         /* rpr2.22: PLL Reset */
497         byte = pmio_read(0x86);
498         byte |= 1 << 7;
499         pmio_write(0x86, byte);
500
501         /* rpr2.3.3 */
502         /* This provides 16us delay before the assertion of LDTSTP# when C3 is entered.
503         * The delay will allow USB DMA to go on in a continuous manner
504         */
505         pmio_write(0x89, 0x10);
506         /* Set this bit to allow pop-up request being latched during the minimum LDTSTP# assertion time */
507         byte = pmio_read(0x52);
508         byte |= 1 << 7;
509         pmio_write(0x52, byte);
510
511         /* rpr2.15: ASF Remote Control Action */
512         byte = pmio_read(0x9f);
513         byte |= 1 << 6;
514         pmio_write(0x9f, byte);
515
516         /* rpr2.19: Enabling Spread Spectrum */
517         byte = pmio_read(0x42);
518         byte |= 1 << 7;
519         pmio_write(0x42, byte);
520 }
521
522 /*
523 * Compliant with CIM_48's sbPciCfg.
524 * Add any south bridge setting.
525 */
526 static void sb600_pci_cfg()
527 {
528         u32 dev;
529         u8 byte;
530
531         /* SMBus Device, BDF:0-20-0 */
532         pci_conf1_find_device(0x1002,  0x4385, &dev);
533         /* Eable the hidden revision ID, available after A13. */
534         byte = pci_conf1_read_config8(dev, 0x70);
535         byte |= (1 << 8);
536         pci_conf1_write_config8(dev, 0x70, byte);
537         /* rpr2.20 Disable Timer IRQ Enhancement for proper operation of the 8254 timer, 0xae[5]. */
538         byte = pci_conf1_read_config8(dev, 0xae);
539         byte |= (1 << 5);
540         pci_conf1_write_config8(dev, 0xae, byte);
541
542         /* Enable watchdog decode timer */
543         byte = pci_conf1_read_config8(dev, 0x41);
544         byte |= (1 << 3);
545         pci_conf1_write_config8(dev, 0x41, byte);
546
547         /* Set to 1 to reset USB on the software (such as IO-64 or IO-CF9 cycles) 
548          * generated PCIRST#. */
549         byte = pmio_read(0x65);
550         byte |= (1 << 4);
551         pmio_write(0x65, byte);
552         /*For A13 and above. */
553         if (get_sb600_revision() > 0x12) {
554                 /* rpr2.16 C-State Reset, PMIO 0x9f[7]. */
555                 byte = pmio_read(0x9f);
556                 byte |= (1 << 7);
557                 pmio_write(0x9f, byte);
558                 /* rpr2.17 PCI Clock Period will increase to 30.8ns. 0x53[7]. */
559                 byte = pmio_read(0x53);
560                 byte |= (1 << 7);
561                 pmio_write(0x53, byte);
562         }
563
564         /* IDE Device, BDF:0-20-1 */
565         pci_conf1_find_device(0x1002,  0x438C, &dev);
566         /* Enable IDE Explicit prefetch, 0x63[0] clear */
567         byte = pci_conf1_read_config8(dev, 0x63);
568         byte &= 0xfe;
569         pci_conf1_write_config8(dev, 0x63, byte);
570
571         /* LPC Device, BDF:0-20-3 */
572         pci_conf1_find_device(0x1002,  0x438D, &dev);
573         /* rpr7.2 Enabling LPC DMA function. */
574         byte = pci_conf1_read_config8(dev, 0x40);
575         byte |= (1 << 2);
576         pci_conf1_write_config8(dev, 0x40, byte);
577         /* rpr7.3 Disabling LPC TimeOut. 0x48[7] clear. */
578         byte = pci_conf1_read_config8(dev, 0x48);
579         byte &= 0x7f;
580         pci_conf1_write_config8(dev, 0x48, byte);
581         /* rpr7.5 Disabling LPC MSI Capability, 0x78[1] clear. */
582         byte = pci_conf1_read_config8(dev, 0x78);
583         byte &= 0xfd;
584         pci_conf1_write_config8(dev, 0x78, byte);
585
586         /* SATA Device, BDF:0-18-0, Non-Raid-5 SATA controller */
587         pci_conf1_find_device(0x1002,  0x4380, &dev);
588         /* rpr6.8 Disabling SATA MSI Capability, for A13 and above, 0x42[7]. */
589         if (0x12 < get_sb600_revision()) {
590                 u32 reg32;
591                 reg32 = pci_conf1_read_config32(dev, 0x40);
592                 reg32 |= (1 << 23);
593                 pci_conf1_write_config32(dev, 0x40, reg32);
594         }
595
596         /* EHCI Device, BDF:0-19-5, ehci usb controller */
597         pci_conf1_find_device(0x1002,  0x4386, &dev);
598         /* rpr5.10 Disabling USB EHCI MSI Capability. 0x50[6]. */
599         byte = pci_conf1_read_config8(dev, 0x50);
600         byte |= (1 << 6);
601         pci_conf1_write_config8(dev, 0x50, byte);
602
603         /* OHCI0 Device, BDF:0-19-0, ohci usb controller #0 */
604         pci_conf1_find_device(0x1002,  0x4387, &dev);
605         /* rpr5.11 Disabling USB OHCI MSI Capability. 0x40[12:8]=0x1f. */
606         byte = pci_conf1_read_config8(dev, 0x41);
607         byte |= 0x1f;
608         pci_conf1_write_config8(dev, 0x41, byte);
609
610 }
611
612 /*
613 * Compliant with CIM_48's ATSBPowerOnResetInitJSP
614 */
615 static void sb600_por_init()
616 {
617         /* sbDevicesPorInitTable + sbK8PorInitTable */
618         sb600_devices_por_init();
619
620         /* sbPmioPorInitTable + sbK8PmioPorInitTable */
621         sb600_pmio_por_init();
622 }
623
624 /*
625 * Compliant with CIM_48's AtiSbBeforePciInit
626 * It should be called during early POST after memory detection and BIOS shadowing but before PCI bus enumeration.
627 */
628 static void sb600_before_pci_init()
629 {
630         sb600_pci_cfg();
631 }
632
633 /*
634 * This function should be called after enable_sb600_smbus().
635 */
636 static void sb600_stage1(void)
637 {
638         printk(BIOS_INFO, "sb600_early_setup()\n");
639         sb600_por_init();
640 }