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