s4880
[coreboot.git] / src / mainboard / tyan / s4880 / 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,2,3
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 = 0x4880;
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_debug("\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 #if 0
92 static void onboard_scsi_fixup(void)
93 {
94         struct device *dev;
95 #if 0
96         unsigned char i,j,k;
97
98         for(i=0;i<=6;i++) {
99                 for(j=0;j<=0x1f;j++) {
100                         for (k=0;k<=6;k++){
101                                 dev = dev_find_slot(i, PCI_DEVFN(j, k));
102                                 if (dev) {
103                                         printk_debug("%02x:%02x:%02x",i,j,k);
104                                         print_pci_regs(dev);
105                                 }
106                         }
107                 }
108         }
109 #endif
110
111
112 #if 0
113         dev = dev_find_device(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C1030,0);
114         if(!dev) {
115                 printk_info("LSI_SCSI_FW_FIXUP: No Device Found!");
116                 return;
117         }
118
119         lsi_scsi_init(dev); 
120 #endif
121 //      print_mem();
122 //      amd8111_enable_rom();
123 }
124 #endif
125 #if 0
126 static void vga_fixup(void) {
127         // we do this right here because:
128         // - all the hardware is working, and some VGA bioses seem to need
129         //   that
130         // - we need page 0 below for linuxbios tables.
131 #if CONFIG_REALMODE_IDT == 1
132         printk_debug("INSTALL REAL-MODE IDT\n");
133         setup_realmode_idt();
134 #endif
135 #if CONFIG_VGABIOS == 1
136         printk_debug("DO THE VGA BIOS\n");
137         do_vgabios();
138         post_code(0x93);
139 #endif
140
141 }
142 #endif 
143
144 static void
145 enable(struct chip *chip, enum chip_pass pass)
146 {
147
148         struct mainboard_tyan_s4880_config *conf = 
149                 (struct mainboard_tyan_s4880_config *)chip->chip_info;
150
151         switch (pass) {
152                 default: break;
153 //              case CONF_PASS_PRE_CONSOLE:
154 //              case CONF_PASS_PRE_PCI:
155 //              case CONF_PASS_POST_PCI:                
156                 case CONF_PASS_PRE_BOOT:
157 //                      if (conf->fixup_scsi)
158 //                              onboard_scsi_fixup();
159 //                      if (conf->fixup_vga)
160 //                              vga_fixup();
161                         printk_debug("mainboard fixup pass %d done\r\n",
162                                         pass);
163                         break;
164         }
165
166 }
167 static struct device_operations mainboard_operations = {
168         .read_resources   = root_dev_read_resources,
169         .set_resources    = root_dev_set_resources,
170         .enable_resources = enable_childrens_resources,
171         .init             = 0,
172         .scan_bus         = amdk8_scan_root_bus,
173         .enable           = 0,
174 };
175
176 static void enumerate(struct chip *chip)
177 {
178         struct chip *child;
179         dev_root.ops = &mainboard_operations;
180         chip->dev = &dev_root;
181         chip->bus = 0;
182         for(child = chip->children; child; child = child->next) {
183                 child->bus = &dev_root.link[0];
184         }
185 }
186 struct chip_control mainboard_tyan_s4880_control = {
187         .enable = enable,
188         .enumerate = enumerate,
189         .name      = "Tyan s4880 mainboard ",
190 };
191
192