remove trailing whitespace
[coreboot.git] / src / mainboard / getac / p470 / 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 <device/pci_def.h>
25 #include <arch/io.h>
26 #include <boot/tables.h>
27 #include <delay.h>
28 #include "chip.h"
29 #include "hda_verb.h"
30
31 #include "ec_oem.c"
32
33 #define MAX_LCD_BRIGHTNESS      0xd8
34
35 static void ec_enable(void)
36 {
37         u16 keymap;
38         /* Enable Hotkey SCI */
39
40         /* Fn key map; F1 = [0] ... F12 = [11] */
41         keymap = 0x5f1;
42         send_ec_oem_command(0x45);
43         send_ec_oem_data(0x09); // SCI
44         // send_ec_oem_data(0x08); // SMI#
45         send_ec_oem_data(keymap >> 8);
46         send_ec_oem_data(keymap & 0xff);
47
48         /* Enable Backlight */
49         ec_write(0x17, MAX_LCD_BRIGHTNESS);
50
51         /* Notify EC system is in ACPI mode */
52         send_ec_oem_command(0x5e);
53         send_ec_oem_data(0xea);
54         send_ec_oem_data(0x0c);
55         send_ec_oem_data(0x01);
56 }
57
58 static void pcie_limit_power(void)
59 {
60 #if 0
61         // This piece of code needs further debugging as it crashes the
62         // machine. It should set the slot numbers and enable power
63         // limitation for the PCIe slots.
64
65         device_t dev;
66
67         dev = dev_find_slot(0, PCI_DEVFN(28,0));
68         if (dev) pci_write_config32(dev, 0x54, 0x0010a0e0);
69
70         dev = dev_find_slot(0, PCI_DEVFN(28,1));
71         if (dev) pci_write_config32(dev, 0x54, 0x0018a0e0);
72
73         dev = dev_find_slot(0, PCI_DEVFN(28,2));
74         if (dev) pci_write_config32(dev, 0x54, 0x0020a0e0);
75
76         dev = dev_find_slot(0, PCI_DEVFN(28,3));
77         if (dev) pci_write_config32(dev, 0x54, 0x0028a0e0);
78 #endif
79 }
80
81 static void verb_setup(void)
82 {
83         cim_verb_data = mainboard_cim_verb_data;
84         cim_verb_data_size = sizeof(mainboard_cim_verb_data);
85 }
86
87 static void mainboard_init(device_t dev)
88 {
89         ec_enable();
90 }
91
92 // mainboard_enable is executed as first thing after
93 // enumerate_buses(). Is there no mainboard_init()?
94 static void mainboard_enable(device_t dev)
95 {
96         dev->ops->init = mainboard_init;
97         pcie_limit_power();
98         verb_setup();
99 }
100
101 struct chip_operations mainboard_ops = {
102         CHIP_NAME("Getac P470 Rugged Notebook")
103         .enable_dev = mainboard_enable,
104 };
105