- First stab at running linuxbios without the old static device tree.
[coreboot.git] / src / mainboard / tyan / s2875 / mainboard.c
1 #include <console/console.h>
2 #include <device/device.h>
3 #include <device/pci.h>
4 #include <device/pci_ids.h>
5 #include <device/pci_ops.h>
6 #include "../../../northbridge/amd/amdk8/northbridge.h"
7 #include "chip.h"
8 //#include <part/mainboard.h>
9 unsigned long initial_apicid[CONFIG_MAX_CPUS] =
10 {
11         0,1
12 };
13 #if 0
14 static void fixup_lsi_53c1030(struct device *pdev)
15 {
16 //      uint8_t byte;
17         uint16_t word;
18
19         byte = 1;
20         pci_write_config8(pdev, 0xff, byte);
21            // Set the device id 
22 //      pci_write_config_word(pdev, PCI_DEVICE_ID, PCI_DEVICE_ID_LSILOGIC_53C1030);
23            // Set the subsytem vendor id 
24 //      pci_write_config16(pdev, PCI_SUBSYSTEM_VENDOR_ID, PCI_VENDOR_ID_TYAN);  
25         word = 0x10f1;
26         pci_write_config16(pdev, PCI_SUBSYSTEM_VENDOR_ID, word);
27             // Set the subsytem id 
28         word = 0x2880;
29         pci_write_config16(pdev, PCI_SUBSYSTEM_ID, word);
30             // Disable writes to the device id 
31         byte = 0;
32         pci_write_config8(pdev, 0xff, byte);
33
34 //      lsi_scsi_init(pdev);
35         
36 }
37 #endif
38 //extern static void lsi_scsi_init(struct device *dev);
39 #if 0
40 static void print_pci_regs(struct device *dev)
41 {
42       uint8_t byte;
43       int i;
44
45       for(i=0;i<256;i++) {
46              byte = pci_read_config8(dev, i);
47    
48              if((i%16)==0) printk_debug("\n%02x:",i);
49              printk_debug(" %02x",byte);
50       }
51       printk_debug("\n");
52         
53 //        pci_write_config8(dev, 0x4, byte);
54
55 }
56 #endif
57 #if 0
58 static void print_mem(void)
59 {
60         int i;
61         int low_1MB = 0;
62         for(i=low_1MB;i<low_1MB+1024*4;i++) {
63              if((i%16)==0) printk_debug("\n %08x:",i);
64              printk_debug(" %02x ",(unsigned char)*((unsigned char *)i));
65              }
66
67         for(i=low_1MB;i<low_1MB+1024*4;i++) {
68              if((i%16)==0) printk_debug("\n %08x:",i);
69              printk_debug(" %c ",(unsigned char)*((unsigned char *)i));
70              }
71  }
72 #endif
73 #if 0
74 static void amd8111_enable_rom(void)
75 {
76         uint8_t byte;
77         struct device *dev;
78
79         /* Enable 4MB rom access at 0xFFC00000 - 0xFFFFFFFF */
80         /* Locate the amd8111 */
81         dev = dev_find_device(0x1022, 0x7468, 0);
82
83         /* Set the 4MB enable bit bit */
84         byte = pci_read_config8(dev, 0x43);
85         byte |= 0x80;
86         pci_write_config8(dev, 0x43, byte);
87 }
88 #endif
89 #if 0
90 static void onboard_scsi_fixup(void)
91 {
92         struct device *dev;
93 #if 1 
94         unsigned char i,j,k;
95
96         for(i=0;i<=6;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 #endif
123 #if 0
124 static void vga_fixup(void) {
125         // we do this right here because:
126         // - all the hardware is working, and some VGA bioses seem to need
127         //   that
128         // - we need page 0 below for linuxbios tables.
129 #if CONFIG_REALMODE_IDT == 1
130         printk_debug("INSTALL REAL-MODE IDT\n");
131         setup_realmode_idt();
132 #endif
133 #if CONFIG_VGABIOS == 1
134         printk_debug("DO THE VGA BIOS\n");
135         do_vgabios(0x0600);
136         post_code(0x93);
137 #endif
138
139 }
140
141 #endif
142  
143
144 static void
145 enable(struct chip *chip, enum chip_pass pass)
146 {
147
148         struct mainboard_tyan_s2875_config *conf = 
149                 (struct mainboard_tyan_s2875_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 void final_mainboard_fixup(void)
168 {
169 #if 0
170         enable_ide_devices();
171 #endif
172 }
173 static struct device_operations mainboard_operations = {
174         .read_resources   = root_dev_read_resources,
175         .set_resources    = root_dev_set_resources,
176         .enable_resources = enable_childrens_resources,
177         .init             = 0,
178         .scan_bus         = amdk8_scan_root_bus,
179         .enable           = 0,
180 };
181
182 static void enumerate(struct chip *chip)
183 {
184         struct chip *child;
185         dev_root.ops = &mainboard_operations;
186         chip->dev = &dev_root;
187         chip->bus = 0;
188         for(child = chip->children; child; child = child->next) {
189                 child->bus = &dev_root.link[0];
190         }
191 }
192 struct chip_control mainboard_tyan_s2875_control = {
193         .enable = enable,
194         .enumerate = enumerate,
195         .name      = "Tyan s2875 mainboard ",
196 };