Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / src / mainboard / roda / rk886ex / mainboard.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007-2009 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; version 2 of
9  * the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19  * MA 02110-1301 USA
20  */
21
22 #include <console/console.h>
23 #include <device/device.h>
24 #include <arch/io.h>
25 #include <boot/tables.h>
26 #include <delay.h>
27 #if CONFIG_PCI_OPTION_ROM_RUN_YABEL
28 #include <x86emu/x86emu.h>
29 #endif
30 #include <arch/coreboot_tables.h>
31 #include "chip.h"
32
33 #include "ec.h"
34 #include "m3885.h"
35
36 #define DUMP_RUNTIME_REGISTERS 0
37
38 static void backlight_enable(void)
39 {
40 #if 0
41 // Disabled, don't let the X9511 burn out
42         int i;
43
44         /* P56 is Brightness Up, and it needs a Pulse instead of a
45          * Level
46          */
47         for (i=0; i < 28; i++) {
48                 //m3885_gpio(M3885_GPIO_PULSE|M3885_GPIO_SET|M3885_GPIO_P56);
49                 m3885_gpio(M3885_GPIO_PULSE|M3885_GPIO_TOGGLE|M3885_GPIO_P56);
50         }
51 #endif
52         printk(BIOS_DEBUG, "Display I/O: 0x%02x\n", inb(0x60f));
53 }
54
55 #if CONFIG_PCI_OPTION_ROM_RUN_YABEL
56 static int int15_handler(void)
57 {
58         u8 display_id;
59 #define BOOT_DISPLAY_DEFAULT    0
60 #define BOOT_DISPLAY_CRT        (1 << 0)
61 #define BOOT_DISPLAY_TV         (1 << 1)
62 #define BOOT_DISPLAY_EFP        (1 << 2)
63 #define BOOT_DISPLAY_LCD        (1 << 3)
64 #define BOOT_DISPLAY_CRT2       (1 << 4)
65 #define BOOT_DISPLAY_TV2        (1 << 5)
66 #define BOOT_DISPLAY_EFP2       (1 << 6)
67 #define BOOT_DISPLAY_LCD2       (1 << 7)
68
69         printk(BIOS_DEBUG, "%s: AX=%04x BX=%04x CX=%04x DX=%04x\n",
70                           __func__, M.x86.R_AX, M.x86.R_BX, M.x86.R_CX, M.x86.R_DX);
71
72         switch (M.x86.R_AX) {
73         case 0x5f35: /* Boot Display */
74                 M.x86.R_AX = 0x005f; // Success
75                 M.x86.R_CL = BOOT_DISPLAY_DEFAULT;
76                 break;
77         case 0x5f40: /* Boot Panel Type */
78                 /* LCD panel type is SIO GPIO40-43 */
79                 // display_id = inb(0x60f) & 0x0f;
80                 display_id = 3;
81                 // M.x86.R_AX = 0x015f; // Supported but failed
82                 M.x86.R_AX = 0x005f; // Success
83                 M.x86.R_CL = display_id;
84                 break;
85         default:
86                 /* Interrupt was not handled */
87                 return 0;
88         }
89
90         /* Interrupt handled */
91         return 1;
92 }
93
94 static void int15_install(void)
95 {
96         typedef int (* yabel_handleIntFunc)(void);
97         extern yabel_handleIntFunc yabel_intFuncArray[256];
98         yabel_intFuncArray[0x15] = int15_handler;
99 }
100 #endif
101
102 #if DUMP_RUNTIME_REGISTERS
103 static void dump_runtime_registers(void)
104 {
105         int i;
106
107         printk(BIOS_DEBUG, "SuperIO runtime register block:\n");
108         for (i=0; i<0x10; i++)
109                 printk(BIOS_DEBUG, "%02x ", i);
110         printk(BIOS_DEBUG, "\n");
111         for (i=0; i<0x10; i++)
112                 printk(BIOS_DEBUG, "%02x ", inb(0x600 +i));
113         printk(BIOS_DEBUG, "\n");
114 }
115 #endif
116
117 static void mainboard_enable(device_t dev)
118 {
119         /* Configure the MultiKey controller */
120         // m3885_configure_multikey();
121
122         /* Enable LCD Backlight */
123         backlight_enable();
124
125         /* Disable Dummy DCC -> GP45 = 1 */
126         outb(inb(0x60f) | (1 << 5), 0x60f);
127
128 #if CONFIG_PCI_OPTION_ROM_RUN_YABEL
129         /* Install custom int15 handler for VGA OPROM */
130         int15_install();
131 #endif
132 #if DUMP_RUNTIME_REGISTERS
133         dump_runtime_registers();
134 #endif
135 }
136
137 int add_mainboard_resources(struct lb_memory *mem)
138 {
139         return add_northbridge_resources(mem);
140 }
141
142 struct chip_operations mainboard_ops = {
143         CHIP_NAME("Roda Computer GmbH RK886EX Rugged Notebook (ROCKY3+)")
144         .enable_dev = mainboard_enable,
145 };
146