81ffc1c7d502b7ea80fcf9cc94793d6ab25c4fc3
[coreboot.git] / src / southbridge / amd / sb700 / early_setup.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2010 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 #ifndef _SB700_EARLY_SETUP_C_
21 #define _SB700_EARLY_SETUP_C_
22
23 #include <reset.h>
24 #include <arch/cpu.h>
25 #include "sb700.h"
26 #include "smbus.c"
27
28 #define SMBUS_IO_BASE 0x6000    /* Is it a temporary SMBus I/O base address? */
29          /*SIZE 0x40 */
30
31 static void pmio_write(u8 reg, u8 value)
32 {
33         outb(reg, PM_INDEX);
34         outb(value, PM_INDEX + 1);
35 }
36
37 static u8 pmio_read(u8 reg)
38 {
39         outb(reg, PM_INDEX);
40         return inb(PM_INDEX + 1);
41 }
42
43 /* RPR 2.28: Get SB ASIC Revision. */
44 static u8 set_sb700_revision(void)
45 {
46         device_t dev;
47         u8 rev_id, enable_14Mhz, byte;
48         u8 rev = 0;
49
50         /* if (rev != 0) return rev; */
51
52         dev = pci_locate_device(PCI_ID(0x1002, 0x4385), 0);
53
54         if (dev == PCI_DEV_INVALID) {
55                 die("SMBUS controller not found\n");
56                 /* NOT REACHED */
57         }
58         rev_id =  pci_read_config8(dev, 0x08);
59
60         if (rev_id == 0x39) {
61                 enable_14Mhz = (pmio_read(0x53) >> 6) & 1;
62                 if (enable_14Mhz == 0x0)
63                         rev = 0x11;     /* A11 */
64                 else if (enable_14Mhz == 0x1) {
65                         /* This happens, if does, only once. So later if we need to get
66                          * the revision ID, we don't have to make such a big function.
67                          * We just get reg 0x8 in smbus dev. 0x39 is A11, 0x3A is A12. */
68                         rev = 0x12;
69                         byte = pci_read_config8(dev, 0x40);
70                         byte |= 1 << 0;
71                         pci_write_config8(dev, 0x40, byte);
72
73                         pci_write_config8(dev, 0x08, 0x3A); /* Change 0x39 to 0x3A. */
74
75                         byte &= ~(1 << 0);
76                         pci_write_config8(dev, 0x40, byte);
77                 }
78         } else if (rev_id == 0x3A) { /* A12 will be 0x3A after BIOS is initialized */
79                 rev = 0x12;
80         } else if (rev_id == 0x3C) {
81                 rev = 0x14;
82         } else if (rev_id == 0x3D) {
83                 rev = 0x15;
84         } else
85                 die("It is not SB700 or SB710\n");
86
87         return rev;
88 }
89
90 /***************************************
91 * Legacy devices are mapped to LPC space.
92 *       Serial port 0
93 *       KBC Port
94 *       ACPI Micro-controller port
95 *       LPC ROM size
96 *       This function does not change port 0x80 decoding.
97 *       Console output through any port besides 0x3f8 is unsupported.
98 *       If you use FWH ROMs, you have to setup IDSEL.
99 ***************************************/
100 static void sb700_lpc_init(void)
101 {
102         u8 reg8;
103         u32 reg32;
104         device_t dev;
105
106         dev = pci_locate_device(PCI_ID(0x1002, 0x4385), 0);     /* SMBUS controller */
107         /* NOTE: Set BootTimerDisable, otherwise it would keep rebooting!!
108          * This bit has no meaning if debug strap is not enabled. So if the
109          * board keeps rebooting and the code fails to reach here, we could
110          * disable the debug strap first. */
111         reg32 = pci_read_config32(dev, 0x4C);
112         reg32 |= 1 << 31;
113         pci_write_config32(dev, 0x4C, reg32);
114
115         /* Enable lpc controller */
116         reg32 = pci_read_config32(dev, 0x64);
117         reg32 |= 1 << 20;
118         pci_write_config32(dev, 0x64, reg32);
119
120         dev = pci_locate_device(PCI_ID(0x1002, 0x439d), 0);     /* LPC Controller */
121         /* Decode port 0x3f8-0x3ff (Serial 0) */
122         // XXX Serial port decode on LPC is hardcoded to 0x3f8
123         reg8 = pci_read_config8(dev, 0x44);
124         reg8 |= 1 << 6;
125         pci_write_config8(dev, 0x44, reg8);
126
127         /* Decode port 0x60 & 0x64 (PS/2 keyboard) and port 0x62 & 0x66 (ACPI)*/
128         reg8 = pci_read_config8(dev, 0x47);
129         reg8 |= (1 << 5) | (1 << 6);
130         pci_write_config8(dev, 0x47, reg8);
131
132         /* Enable PrefetchEnSPIFromHost to speed up SPI flash read (does not affect LPC) */
133         reg8 = pci_read_config8(dev, 0xbb);
134         reg8 |= 1 << 0;
135         pci_write_config8(dev, 0xbb, reg8);
136
137         /* SuperIO, LPC ROM */
138         reg8 = pci_read_config8(dev, 0x48);
139         /* Decode ports 0x2e-0x2f, 0x4e-0x4f (SuperI/O configuration) */
140         reg8 |= (1 << 1) | (1 << 0);
141         /* Decode variable LPC ROM address ranges 1&2 (see register 0x68-0x6b, 0x6c-0x6f) */
142         reg8 |= (1 << 3) | (1 << 4);
143         /* Decode port 0x70-0x73 (RTC) */
144         reg8 |= 1 << 6;
145         pci_write_config8(dev, 0x48, reg8);
146
147         /* hardware should enable LPC ROM by pin straps */
148         /* ROM access at 0xFFF80000/0xFFF00000 - 0xFFFFFFFF */
149         /* See detail in 43366_sb700_bdg_nda_1.01.pdf page 17. */
150         /* enable LPC ROM range mirroring start 0x000e(0000) */
151         pci_write_config16(dev, 0x68, 0x000e);
152         /* enable LPC ROM range mirroring end   0x000f(ffff) */
153         pci_write_config16(dev, 0x6a, 0x000f);
154         /* enable LPC ROM range start, 0xfff8(0000): 512KB, 0xfff0(0000): 1MB */
155         pci_write_config16(dev, 0x6c, 0xfff0);
156         /* enable LPC ROM range end at 0xffff(ffff) */
157         pci_write_config16(dev, 0x6e, 0xffff);
158 }
159
160 /* what is its usage? */
161 static u32 get_sbdn(u32 bus)
162 {
163         device_t dev;
164
165         /* Find the device. */
166         dev = pci_locate_device_on_bus(PCI_ID(0x1002, 0x4385), bus);
167         return (dev >> 15) & 0x1f;
168 }
169
170 static u8 dual_core(void)
171 {
172         return (pci_read_config32(PCI_DEV(0, 0x18, 3), 0xE8) & (0x3<<12)) != 0;
173 }
174
175 /*
176  * RPR 2.4 C-state and VID/FID change for the K8 platform.
177  */
178 static void enable_fid_change_on_sb(u32 sbbusn, u32 sbdn)
179 {
180         u8 byte;
181         byte = pmio_read(0x9a);
182         byte &= ~0x34;
183         if (dual_core())
184                 byte |= 0x34;
185         else
186                 byte |= 0x04;
187         pmio_write(0x9a, byte);
188
189         byte = pmio_read(0x8f);
190         byte &= ~0x30;
191         byte |= 0x20;
192         pmio_write(0x8f, byte);
193
194         pmio_write(0x8b, 0x01); /* TODO: if the HT Link is 200 MHz, it is 0x0A. It doesnt often happen. */
195         pmio_write(0x8a, 0x90);
196
197         pmio_write(0x88, 0x10);
198
199         byte = pmio_read(0x7c);
200         byte |= 0x03;
201         pmio_write(0x7c, byte);
202
203         /* Must be 0 for K8 platform. */
204         byte = pmio_read(0x68);
205         byte &= ~0x01;
206         pmio_write(0x68, byte);
207         /* Must be 0 for K8 platform. */
208         byte = pmio_read(0x8d);
209         byte &= ~(1<<6);
210         pmio_write(0x8d, byte);
211
212         byte = pmio_read(0x61);
213         byte &= ~0x04;
214         pmio_write(0x61, byte);
215
216         byte = pmio_read(0x42);
217         byte &= ~0x04;
218         pmio_write(0x42, byte);
219
220         pmio_write(0x89, 0x10);
221 }
222
223 void hard_reset(void)
224 {
225         set_bios_reset();
226
227         /* full reset */
228         outb(0x0a, 0x0cf9);
229         outb(0x0e, 0x0cf9);
230 }
231
232 void soft_reset(void)
233 {
234         set_bios_reset();
235         /* link reset */
236         outb(0x06, 0x0cf9);
237 }
238
239 void sb700_pci_port80(void)
240 {
241         u8 byte;
242         device_t dev;
243
244         /* P2P Bridge */
245         dev = pci_locate_device(PCI_ID(0x1002, 0x4384), 0);
246
247         /* Chip Control: Enable subtractive decoding */
248         byte = pci_read_config8(dev, 0x40);
249         byte |= 1 << 5;
250         pci_write_config8(dev, 0x40, byte);
251
252         /* Misc Control: Enable subtractive decoding if 0x40 bit 5 is set */
253         byte = pci_read_config8(dev, 0x4B);
254         byte |= 1 << 7;
255         pci_write_config8(dev, 0x4B, byte);
256
257         /* The same IO Base and IO Limit here is meaningful because we set the
258          * bridge to be subtractive. During early setup stage, we have to make
259          * sure that data can go through port 0x80.
260          */
261         /* IO Base: 0xf000 */
262         byte = pci_read_config8(dev, 0x1C);
263         byte |= 0xF << 4;
264         pci_write_config8(dev, 0x1C, byte);
265
266         /* IO Limit: 0xf000 */
267         byte = pci_read_config8(dev, 0x1D);
268         byte |= 0xF << 4;
269         pci_write_config8(dev, 0x1D, byte);
270
271         /* PCI Command: Enable IO response */
272         byte = pci_read_config8(dev, 0x04);
273         byte |= 1 << 0;
274         pci_write_config8(dev, 0x04, byte);
275
276         /* LPC controller */
277         dev = pci_locate_device(PCI_ID(0x1002, 0x439D), 0);
278
279         byte = pci_read_config8(dev, 0x4A);
280         byte &= ~(1 << 5);      /* disable lpc port 80 */
281         pci_write_config8(dev, 0x4A, byte);
282 }
283
284 void sb700_lpc_port80(void)
285 {
286         u8 byte;
287         device_t dev;
288         u32 reg32;
289
290         /* Enable LPC controller */
291         dev = pci_locate_device(PCI_ID(0x1002, 0x4385), 0);
292         reg32 = pci_read_config32(dev, 0x64);
293         reg32 |= 0x00100000;    /* lpcEnable */
294         pci_write_config32(dev, 0x64, reg32);
295
296         /* Enable port 80 LPC decode in pci function 3 configuration space. */
297         dev = pci_locate_device(PCI_ID(0x1002, 0x439d), 0);
298         byte = pci_read_config8(dev, 0x4a);
299         byte |= 1 << 5;         /* enable port 80 */
300         pci_write_config8(dev, 0x4a, byte);
301 }
302
303 /* sbDevicesPorInitTable */
304 static void sb700_devices_por_init(void)
305 {
306         device_t dev;
307         u8 byte;
308
309         printk(BIOS_INFO, "sb700_devices_por_init()\n");
310         /* SMBus Device, BDF:0-20-0 */
311         printk(BIOS_INFO, "sb700_devices_por_init(): SMBus Device, BDF:0-20-0\n");
312         dev = pci_locate_device(PCI_ID(0x1002, 0x4385), 0);
313
314         if (dev == PCI_DEV_INVALID) {
315                 die("SMBUS controller not found\n");
316                 /* NOT REACHED */
317         }
318         printk(BIOS_INFO, "SMBus controller enabled, sb revision is A%x\n",
319                     set_sb700_revision());
320
321         /* sbPorAtStartOfTblCfg */
322         /* Set A-Link bridge access address. This address is set at device 14h, function 0, register 0xf0.
323          * This is an I/O address. The I/O address must be on 16-byte boundry.  */
324         pci_write_config32(dev, 0xf0, AB_INDX);
325
326         /* To enable AB/BIF DMA access, a specific register inside the BIF register space needs to be configured first. */
327         /* 4.3:Enables the SB700 to send transactions upstream over A-Link Express interface. */
328         axcfg_reg(0x04, 1 << 2, 1 << 2);
329         axindxc_reg(0x21, 0xff, 0);
330
331         /* 2.5:Enabling Non-Posted Memory Write for the K8 Platform */
332         axindxc_reg(0x10, 1 << 9, 1 << 9);
333         /* END of sbPorAtStartOfTblCfg */
334
335         /* sbDevicesPorInitTables */
336         /* set smbus iobase */
337         pci_write_config32(dev, 0x90, SMBUS_IO_BASE | 1);
338
339         /* enable smbus controller interface */
340         byte = pci_read_config8(dev, 0xd2);
341         byte |= (1 << 0);
342         pci_write_config8(dev, 0xd2, byte);
343
344         /* KB2RstEnable */
345         pci_write_config8(dev, 0x40, 0x44);
346
347         /* Enable ISA Address 0-960K decoding */
348         pci_write_config8(dev, 0x48, 0x0f);
349
350         /* Enable ISA  Address 0xC0000-0xDFFFF decode */
351         pci_write_config8(dev, 0x49, 0xff);
352
353         /* Enable decode cycles to IO C50, C51, C52 GPM controls. */
354         byte = pci_read_config8(dev, 0x41);
355         byte &= 0x80;
356         byte |= 0x33;
357         pci_write_config8(dev, 0x41, byte);
358
359         /* Legacy DMA Prefetch Enhancement, CIM masked it. */
360         /* pci_write_config8(dev, 0x43, 0x1); */
361
362         /* Disabling Legacy USB Fast SMI# */
363         byte = pci_read_config8(dev, 0x62);
364         byte |= 0x24;
365         pci_write_config8(dev, 0x62, byte);
366
367         /* Features Enable */
368         pci_write_config32(dev, 0x64, 0x829E79BF); /* bit10: Enables the HPET interrupt. */
369
370         /* SerialIrq Control */
371         pci_write_config8(dev, 0x69, 0x90);
372
373         /* Test Mode, PCIB_SReset_En Mask is set. */
374         pci_write_config8(dev, 0x6c, 0x20);
375
376         /* IO Address Enable, CIM set 0x78 only and masked 0x79. */
377         /*pci_write_config8(dev, 0x79, 0x4F); */
378         pci_write_config8(dev, 0x78, 0xFF);
379
380         /* Set smbus iospace enable, I don't know why write 0x04 into reg5 that is reserved */
381         pci_write_config16(dev, 0x4, 0x0407);
382
383         /* clear any lingering errors, so the transaction will run */
384         outb(inb(SMBUS_IO_BASE + SMBHSTSTAT), SMBUS_IO_BASE + SMBHSTSTAT);
385
386         /* IDE Device, BDF:0-20-1 */
387         printk(BIOS_INFO, "sb700_devices_por_init(): IDE Device, BDF:0-20-1\n");
388         dev = pci_locate_device(PCI_ID(0x1002, 0x439C), 0);
389         /* Disable prefetch */
390         byte = pci_read_config8(dev, 0x63);
391         byte |= 0x1;
392         pci_write_config8(dev, 0x63, byte);
393
394         /* LPC Device, BDF:0-20-3 */
395         printk(BIOS_INFO, "sb700_devices_por_init(): LPC Device, BDF:0-20-3\n");
396         dev = pci_locate_device(PCI_ID(0x1002, 0x439D), 0);
397         /* DMA enable */
398         pci_write_config8(dev, 0x40, 0x04);
399
400         /* IO Port Decode Enable */
401         pci_write_config8(dev, 0x44, 0xFF);
402         pci_write_config8(dev, 0x45, 0xFF);
403         pci_write_config8(dev, 0x46, 0xC3);
404         pci_write_config8(dev, 0x47, 0xFF);
405
406         /* IO/Mem Port Decode Enable, I don't know why CIM disable some ports.
407          *  Disable LPC TimeOut counter, enable SuperIO Configuration Port (2e/2f),
408          * Alternate SuperIO Configuration Port (4e/4f), Wide Generic IO Port (64/65).
409          * Enable bits for LPC ROM memory address range 1&2 for 1M ROM setting.*/
410         byte = pci_read_config8(dev, 0x48);
411         byte |= (1 << 1) | (1 << 0);    /* enable Super IO config port 2e-2h, 4e-4f */
412         byte |= (1 << 3) | (1 << 4);    /* enable for LPC ROM address range1&2, Enable 512KB rom access at 0xFFF80000 - 0xFFFFFFFF */
413         byte |= 1 << 6;         /* enable for RTC I/O range */
414         pci_write_config8(dev, 0x48, byte);
415         pci_write_config8(dev, 0x49, 0xFF);
416         /* Enable 0x480-0x4bf, 0x4700-0x470B */
417         byte = pci_read_config8(dev, 0x4A);
418         byte |= ((1 << 1) + (1 << 6));  /*0x42, save the configuraion for port 0x80. */
419         pci_write_config8(dev, 0x4A, byte);
420
421         /* Set LPC ROM size, it has been done in sb700_lpc_init().
422          * enable LPC ROM range, 0xfff8: 512KB, 0xfff0: 1MB;
423          * enable LPC ROM range, 0xfff8: 512KB, 0xfff0: 1MB
424          * pci_write_config16(dev, 0x68, 0x000e)
425          * pci_write_config16(dev, 0x6c, 0xfff0);*/
426
427         /* Enable Tpm12_en and Tpm_legacy. I don't know what is its usage and copied from CIM. */
428         pci_write_config8(dev, 0x7C, 0x05);
429
430         /* P2P Bridge, BDF:0-20-4, the configuration of the registers in this dev are copied from CIM,
431          */
432         printk(BIOS_INFO, "sb700_devices_por_init(): P2P Bridge, BDF:0-20-4\n");
433         dev = pci_locate_device(PCI_ID(0x1002, 0x4384), 0);
434
435         /* Arbiter enable. */
436         pci_write_config8(dev, 0x43, 0xff);
437
438         /* Set PCDMA request into hight priority list. */
439         /* pci_write_config8(dev, 0x49, 0x1) */ ;
440
441         pci_write_config8(dev, 0x40, 0x26);
442
443         pci_write_config8(dev, 0x0d, 0x40);
444         pci_write_config8(dev, 0x1b, 0x40);
445         /* Enable PCIB_DUAL_EN_UP will fix potential problem with PCI cards. */
446         pci_write_config8(dev, 0x50, 0x01);
447
448         /* SATA Device, BDF:0-17-0, Non-Raid-5 SATA controller */
449         printk(BIOS_INFO, "sb700_devices_por_init(): SATA Device, BDF:0-18-0\n");
450         dev = pci_locate_device(PCI_ID(0x1002, 0x4390), 0);
451
452         /*PHY Global Control*/
453         pci_write_config16(dev, 0x86, 0x2C00);
454 }
455
456 /* sbPmioPorInitTable, Pre-initializing PMIO register space
457 * The power management (PM) block is resident in the PCI/LPC/ISA bridge.
458 * The PM regs are accessed via IO mapped regs 0xcd6 and 0xcd7.
459 * The index address is first programmed into IO reg 0xcd6.
460 * Read or write values are accessed through IO reg 0xcd7.
461 */
462 static void sb700_pmio_por_init(void)
463 {
464         u8 byte;
465
466         printk(BIOS_INFO, "sb700_pmio_por_init()\n");
467         /* K8KbRstEn, KB_RST# control for K8 system. */
468         byte = pmio_read(0x66);
469         byte |= 0x20;
470         pmio_write(0x66, byte);
471
472         /* RPR2.31 PM_TURN_OFF_MSG during ASF Shutdown. */
473         if (get_sb700_revision(pci_locate_device(PCI_ID(0x1002, 0x4385), 0)) <= 0x12) {
474                 byte = pmio_read(0x65);
475                 byte &= ~(1 << 7);
476                 pmio_write(0x65, byte);
477
478                 byte = pmio_read(0x75);
479                 byte &= 0xc0;
480                 byte |= 0x05;
481                 pmio_write(0x75, byte);
482
483                 byte = pmio_read(0x52);
484                 byte &= 0xc0;
485                 byte |= 0x08;
486                 pmio_write(0x52, byte);
487         } else {
488                 byte = pmio_read(0xD7);
489                 byte |= 1 << 0;
490                 pmio_write(0xD7, byte);
491
492                 byte = pmio_read(0x65);
493                 byte |= 1 << 7;
494                 pmio_write(0x65, byte);
495
496                 byte = pmio_read(0x75);
497                 byte &= 0xc0;
498                 byte |= 0x01;
499                 pmio_write(0x75, byte);
500
501                 byte = pmio_read(0x52);
502                 byte &= 0xc0;
503                 byte |= 0x02;
504                 pmio_write(0x52, byte);
505
506         }
507
508         /* Watch Dog Timer Control
509          * Set watchdog time base to 0xfec000f0 to avoid SCSI card boot failure.
510          * But I don't find WDT is enabled in SMBUS 0x41 bit3 in CIM.
511          */
512         pmio_write(0x6c, 0xf0);
513         pmio_write(0x6d, 0x00);
514         pmio_write(0x6e, 0xc0);
515         pmio_write(0x6f, 0xfe);
516
517         /* rpr2.15: Enabling Spread Spectrum */
518         byte = pmio_read(0x42);
519         byte |= 1 << 7;
520         pmio_write(0x42, byte);
521         /* TODO: Check if it is necessary. IDE reset */
522         byte = pmio_read(0xB2);
523         byte |= 1 << 0;
524         pmio_write(0xB2, byte);
525 }
526
527 /*
528 * Add any south bridge setting.
529 */
530 static void sb700_pci_cfg(void)
531 {
532         device_t dev;
533         u8 byte;
534
535         /* SMBus Device, BDF:0-20-0 */
536         dev = pci_locate_device(PCI_ID(0x1002, 0x4385), 0);
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
548         /* IDE Device, BDF:0-20-1 */
549         dev = pci_locate_device(PCI_ID(0x1002, 0x439C), 0);
550         /* Enable IDE Explicit prefetch, 0x63[0] clear */
551         byte = pci_read_config8(dev, 0x63);
552         byte &= 0xfe;
553         pci_write_config8(dev, 0x63, byte);
554
555         /* LPC Device, BDF:0-20-3 */
556         /* The code below is ported from old chipset. It is not
557          * mentioned in RPR. But I keep them. The registers and the
558          * comments are compatible. */
559         dev = pci_locate_device(PCI_ID(0x1002, 0x439D), 0);
560         /* Enabling LPC DMA function. */
561         byte = pci_read_config8(dev, 0x40);
562         byte |= (1 << 2);
563         pci_write_config8(dev, 0x40, byte);
564         /* Disabling LPC TimeOut. 0x48[7] clear. */
565         byte = pci_read_config8(dev, 0x48);
566         byte &= 0x7f;
567         pci_write_config8(dev, 0x48, byte);
568         /* Disabling LPC MSI Capability, 0x78[1] clear. */
569         byte = pci_read_config8(dev, 0x78);
570         byte &= 0xfd;
571         pci_write_config8(dev, 0x78, byte);
572
573         /* SATA Device, BDF:0-17-0, Non-Raid-5 SATA controller */
574         dev = pci_locate_device(PCI_ID(0x1002, 0x4390), 0);
575         /* rpr7.12 SATA MSI and D3 Power State Capability. */
576         byte = pci_read_config8(dev, 0x40);
577         byte |= 1 << 0;
578         pci_write_config8(dev, 0x40, byte);
579         if (get_sb700_revision(pci_locate_device(PCI_ID(0x1002, 0x4385), 0)) <= 0x12)
580                 pci_write_config8(dev, 0x34, 0x70); /* set 0x61 to 0x70 if S1 is not supported. */
581         else
582                 pci_write_config8(dev, 0x34, 0x50); /* set 0x61 to 0x50 if S1 is not supported. */
583         byte &= ~(1 << 0);
584         pci_write_config8(dev, 0x40, byte);
585 }
586
587 /*
588 */
589 static void sb700_por_init(void)
590 {
591         /* sbDevicesPorInitTable + sbK8PorInitTable */
592         sb700_devices_por_init();
593
594         /* sbPmioPorInitTable + sbK8PmioPorInitTable */
595         sb700_pmio_por_init();
596 }
597
598 /*
599 * It should be called during early POST after memory detection and BIOS shadowing but before PCI bus enumeration.
600 */
601 static void sb700_before_pci_init(void)
602 {
603         sb700_pci_cfg();
604 }
605
606 /*
607 * This function should be called after enable_sb700_smbus().
608 */
609 static void sb700_early_setup(void)
610 {
611         printk(BIOS_INFO, "sb700_early_setup()\n");
612         sb700_por_init();
613 }
614
615 static int smbus_read_byte(u32 device, u32 address)
616 {
617         return do_smbus_read_byte(SMBUS_IO_BASE, device, address);
618 }
619 #endif