af8c1ad479ae4af4bcb2df72591f9221a8b0b149
[coreboot.git] / src / mainboard / tyan / s2885 / mainboard.c
1 #include <console/console.h>
2 #include <device/device.h>
3 #include <device/chip.h>
4 #include <device/pci.h>
5 #include <device/pci_ids.h>
6 #include <device/pci_ops.h>
7 #include "chip.h"
8 //#include <part/mainboard.h>
9 //#include "lsi_scsi.c"
10 unsigned long initial_apicid[MAX_CPUS] =
11 {
12         0,1
13 };
14 #if 0
15 static void fixup_lsi_53c1030(struct device *pdev)
16 {
17 //      uint8_t byte;
18         uint16_t word;
19
20         byte = 1;
21         pci_write_config8(pdev, 0xff, byte);
22            // Set the device id 
23 //      pci_write_config_word(pdev, PCI_DEVICE_ID, PCI_DEVICE_ID_LSILOGIC_53C1030);
24            // Set the subsytem vendor id 
25 //      pci_write_config16(pdev, PCI_SUBSYSTEM_VENDOR_ID, PCI_VENDOR_ID_TYAN);  
26         word = 0x10f1;
27         pci_write_config16(pdev, PCI_SUBSYSTEM_VENDOR_ID, word);
28             // Set the subsytem id 
29         word = 0x2880;
30         pci_write_config16(pdev, PCI_SUBSYSTEM_ID, word);
31             // Disable writes to the device id 
32         byte = 0;
33         pci_write_config8(pdev, 0xff, byte);
34
35 //      lsi_scsi_init(pdev);
36         
37 }
38 #endif
39 //extern static void lsi_scsi_init(struct device *dev);
40 #if 1
41 static void print_pci_regs(struct device *dev)
42 {
43       uint8_t byte;
44       int i;
45
46       for(i=0;i<256;i++) {
47              byte = pci_read_config8(dev, i);
48    
49              if((i%16)==0) printk_info("\n%02x:",i);
50              printk_debug(" %02x",byte);
51       }
52       printk_debug("\n");
53         
54 //        pci_write_config8(dev, 0x4, byte);
55
56 }
57 #endif
58 #if 0
59 static void print_mem(void)
60 {
61         int i;
62         int low_1MB = 0;
63         for(i=low_1MB;i<low_1MB+1024*4;i++) {
64              if((i%16)==0) printk_debug("\n %08x:",i);
65              printk_debug(" %02x ",(unsigned char)*((unsigned char *)i));
66              }
67
68         for(i=low_1MB;i<low_1MB+1024*4;i++) {
69              if((i%16)==0) printk_debug("\n %08x:",i);
70              printk_debug(" %c ",(unsigned char)*((unsigned char *)i));
71              }
72  }
73 #endif
74 #if 0
75 static void amd8111_enable_rom(void)
76 {
77         uint8_t byte;
78         struct device *dev;
79
80         /* Enable 4MB rom access at 0xFFC00000 - 0xFFFFFFFF */
81         /* Locate the amd8111 */
82         dev = dev_find_device(0x1022, 0x7468, 0);
83
84         /* Set the 4MB enable bit bit */
85         byte = pci_read_config8(dev, 0x43);
86         byte |= 0x80;
87         pci_write_config8(dev, 0x43, byte);
88 }
89 #endif
90 static void onboard_scsi_fixup(void)
91 {
92        struct device *dev;
93         unsigned char i,j,k;
94 #if 1
95         for(i=0;i<=4;i++) {
96                 for(j=0;j<=0x1f;j++) {
97                         for (k=0;k<=6;k++){
98                                 dev = dev_find_slot(i, PCI_DEVFN(j, k));
99                                 if (dev) {
100                                         printk_debug("%02x:%02x:%02x",i,j,k);
101                                         print_pci_regs(dev);
102                                 }
103                         }
104                 }
105         }
106 #endif
107
108
109 #if 0
110         dev = dev_find_device(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C1030,0);
111         if(!dev) {
112                 printk_info("LSI_SCSI_FW_FIXUP: No Device Found!");
113                 return;
114         }
115
116         lsi_scsi_init(dev); 
117 #endif
118 //      print_mem();
119 //      amd8111_enable_rom();
120 }
121 /*
122 static void vga_fixup(void) {
123         // we do this right here because:
124         // - all the hardware is working, and some VGA bioses seem to need
125         //   that
126         // - we need page 0 below for linuxbios tables.
127 #if CONFIG_REALMODE_IDT == 1
128         printk_debug("INSTALL REAL-MODE IDT\n");
129         setup_realmode_idt();
130 #endif
131 #if CONFIG_VGABIOS == 1
132         printk_debug("DO THE VGA BIOS\n");
133         do_vgabios();
134         post_code(0x93);
135 #endif
136
137 }
138  */
139
140 static void
141 enable(struct chip *chip, enum chip_pass pass)
142 {
143
144         struct mainboard_tyan_s2885_config *conf = 
145                 (struct mainboard_tyan_s2885_config *)chip->chip_info;
146
147         switch (pass) {
148                 default: break;
149 //              case CONF_PASS_PRE_CONSOLE:
150 //              case CONF_PASS_PRE_PCI:
151 //              case CONF_PASS_POST_PCI:                
152                 case CONF_PASS_PRE_BOOT:
153                         if (conf->fixup_scsi)
154                                 onboard_scsi_fixup();
155 //                      if (conf->fixup_vga)
156 //                              vga_fixup();
157                         printk_debug("mainboard fixup pass %d done\r\n",
158                                         pass);
159                         break;
160         }
161
162 }
163 void final_mainboard_fixup(void)
164 {
165 #if 0
166         enable_ide_devices();
167 #endif
168 }
169
170 struct chip_control mainboard_tyan_s2885_control = {
171                 .enable= enable,
172                 .name=   "Tyan s2885 mainboard "
173 };
174