- First stab at running linuxbios without the old static device tree.
[coreboot.git] / src / mainboard / via / epia-m / 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
7 #include <arch/io.h>
8 #include "chip.h"
9
10 void vga_enable_console();
11
12
13 static int
14 mainboard_scan_bus(device_t root, int maxbus) 
15 {
16         int retval;
17         printk_spew("%s: root %p maxbus %d\n", __FUNCTION__, root, maxbus);
18         retval = pci_scan_bus(root->bus, 0, 0xff, maxbus);
19         printk_spew("DONE %s: return %d\n", __FUNCTION__, maxbus);
20         return maxbus;
21 }
22
23 void vga_fixup(void) {
24         // we do this right here because:
25         // - all the hardware is working, and some VGA bioses seem to need
26         //   that
27         // - we need page 0 below for linuxbios tables.
28
29         printk_debug("INSTALL REAL-MODE IDT\n");
30         setup_realmode_idt();
31         printk_debug("DO THE VGA BIOS\n");
32         do_vgabios();
33         post_code(0x93);
34         vga_enable_console();
35
36
37 }
38  
39 void write_protect_vgabios(void)
40 {
41         device_t dev;
42  
43         printk_info("write_protect_vgabios\n");
44         dev = dev_find_device(PCI_VENDOR_ID_VIA, 0x3123, 0);
45         if(dev)
46                 pci_write_config8(dev, 0x61, 0xaa);
47  
48 }
49
50 static void
51 enable(struct chip *chip, enum chip_pass pass)
52 {
53
54         struct mainboard_tyan_s4882_config *conf = 
55                 (struct mainboard_tyan_s4882_config *)chip->chip_info;
56
57         switch (pass) {
58                 default: break;
59 //              case CONF_PASS_PRE_CONSOLE:
60 //              case CONF_PASS_PRE_PCI:
61                 case CONF_PASS_POST_PCI:                
62 //                case CONF_PASS_PRE_BOOT:
63 //                      if (conf->fixup_scsi)
64 //                              onboard_scsi_fixup();
65 //                      if (conf->fixup_vga)
66 //                              vga_fixup();
67                         printk_debug("mainboard fixup pass %d done\r\n",
68                                         pass);
69                         break;
70         }
71
72 }
73 static struct device_operations mainboard_operations = {
74         .read_resources   = root_dev_read_resources,
75         .set_resources    = root_dev_set_resources,
76         .enable_resources = enable_childrens_resources,
77         .init             = 0,
78         .scan_bus         = mainboard_scan_bus,
79         .enable           = 0,
80 };
81
82 static void enumerate(struct chip *chip)
83 {
84         struct chip *child;
85         dev_root.ops = &mainboard_operations;
86         chip->dev = &dev_root;
87         chip->bus = 0;
88         for(child = chip->children; child; child = child->next) {
89                 child->bus = &dev_root.link[0];
90         }
91 }
92 struct chip_control mainboard_via_epia_m_control = {
93         .enumerate = enumerate, 
94         .name      = "VIA EPIA-M mainboard ",
95         .enable = enable
96 };
97