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