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