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