- First stab at running linuxbios without the old static device tree.
[coreboot.git] / src / mainboard / tyan / s2882 / 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 //#include "lsi_scsi.c"
10 unsigned long initial_apicid[CONFIG_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 0
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 0 
95         for(i=0;i<=5;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_s2882_config *conf = 
145                 (struct mainboard_tyan_s2882_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",pass);
158                         break;
159         }
160
161 }
162 void final_mainboard_fixup(void)
163 {
164 #if 0
165         enable_ide_devices();
166 #endif
167 }
168 static struct device_operations mainboard_operations = {
169         .read_resources   = root_dev_read_resources,
170         .set_resources    = root_dev_set_resources,
171         .enable_resources = enable_childrens_resources,
172         .init             = 0,
173         .scan_bus         = amdk8_scan_root_bus,
174         .enable           = 0,
175 };
176
177 static void enumerate(struct chip *chip)
178 {
179         struct chip *child;
180         dev_root.ops = &mainboard_operations;
181         chip->dev = &dev_root;
182         chip->bus = 0;
183         for(child = chip->children; child; child = child->next) {
184                 child->bus = &dev_root.link[0];
185         }
186 }
187 struct chip_control mainboard_tyan_s2882_control = {
188         .enable = enable,
189         .enumerate = enumerate,
190         .name      = "Tyan s2882 mainboard ",
191 };
192