This is the sata irq patch for s2895 and ultra40. It also changes some broken
[coreboot.git] / src / mainboard / tyan / s2892 / failover.c
1 #define ASSEMBLY 1
2 #include <stdint.h>
3 #include <device/pci_def.h>
4 #include <device/pci_ids.h>
5 #include <arch/io.h>
6 #include <arch/romcc_io.h>
7 #include <cpu/x86/lapic.h>
8 #include "pc80/mc146818rtc_early.c"
9
10 #include "southbridge/nvidia/ck804/ck804_enable_rom.c"
11 #include "northbridge/amd/amdk8/early_ht.c"
12 #include "cpu/x86/lapic/boot_cpu.c"
13 #include "cpu/x86/mtrr/earlymtrr.c"
14 #include "northbridge/amd/amdk8/reset_test.c"
15
16 static void sio_setup(void)
17 {
18         
19         unsigned value;
20         uint32_t dword;
21         uint8_t byte;
22
23         byte = pci_read_config32(PCI_DEV(0, CK804_DEVN_BASE+1 , 0), 0x7b);
24         byte |= 0x20; 
25         pci_write_config8(PCI_DEV(0, CK804_DEVN_BASE+1 , 0), 0x7b, byte);
26         
27         dword = pci_read_config32(PCI_DEV(0, CK804_DEVN_BASE+1 , 0), 0xa0);
28         dword |= (1<<0);  
29         pci_write_config32(PCI_DEV(0, CK804_DEVN_BASE+1 , 0), 0xa0, dword);
30
31
32 }
33
34 #if CONFIG_LOGICAL_CPUS==1
35 #include "cpu/amd/dualcore/dualcore_id.c"
36 #endif
37
38 static unsigned long main(unsigned long bist)
39 {
40         /* Make cerain my local apic is useable */
41         enable_lapic();
42
43         /* Is this a cpu only reset? */
44         if (early_mtrr_init_detected()) {
45                 if (last_boot_normal()) {
46                         goto normal_image;
47                 } else {
48                         goto fallback_image;
49                 }
50         }
51         
52         /* Is this a secondary cpu? */
53         if (!boot_cpu()) {
54                 if (last_boot_normal()) {
55                         goto normal_image;
56                 } else {
57                         goto fallback_image;
58                 }
59         }
60
61         /* Nothing special needs to be done to find bus 0 */
62         /* Allow the HT devices to be found */
63         
64         enumerate_ht_chain();
65
66         sio_setup();
67
68         /* Setup the ck804 */
69         ck804_enable_rom();
70
71         /* Is this a deliberate reset by the bios */
72         if (bios_reset_detected() && last_boot_normal()) {
73                 goto normal_image;
74         }
75         /* This is the primary cpu how should I boot? */
76         else if (do_normal_boot()) {
77                 goto normal_image;
78         }
79         else {
80                 goto fallback_image;
81         }
82  normal_image:
83         asm volatile ("jmp __normal_image" 
84                 : /* outputs */ 
85                 : "a" (bist) /* inputs */
86                 : /* clobbers */
87                 );
88  fallback_image:
89         return bist;
90 }