blob: c2aaaa93cf910dc6fdfea434f73136116095a4e7 [file] [log] [blame]
Sven Schnellee2ca71e2011-02-14 20:02:47 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
5 * Copyright (C) 2011 Sven Schnelle <svens@stackframe.org>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
10 * the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
20 * MA 02110-1301 USA
21 */
22
23#include <console/console.h>
24#include <device/device.h>
25#include <arch/io.h>
26#include <boot/tables.h>
27#include <delay.h>
28#include <arch/coreboot_tables.h>
29#include "chip.h"
30#include <device/pci_def.h>
31#include <device/pci_ops.h>
32#include <arch/io.h>
33#include <ec/lenovo/pmh7/pmh7.h>
34#include <ec/acpi/ec.h>
Sven Schnelle8099cbf2011-04-04 10:57:17 +000035#include <northbridge/intel/i945/i945.h>
Sven Schnellee2ca71e2011-02-14 20:02:47 +000036
37static void backlight_enable(void)
38{
39 pmh7_register_set_bit(0x50, 5);
40}
41
42static void trackpoint_enable(void)
43{
44 ec_write(0x0b, 0x03);
45}
46
47static void wlan_enable(void)
48{
49 ec_write(0x3a, 0x20);
50}
51
Sven Schnelleb31eb3e2011-04-05 13:00:14 +000052static void log_ec_version(void)
Sven Schnellee2ca71e2011-02-14 20:02:47 +000053{
Sven Schnellebdb10592011-04-04 12:33:54 +000054 unsigned char ecfw[9], c;
55 u16 fwvh, fwvl;
Sven Schnellebdb10592011-04-04 12:33:54 +000056 int i;
57
58 for(i = 0; i < 8; i++) {
59 c = ec_read(0xf0 + i);
60 if (c < 0x20 || c > 0x7f)
61 break;
62 ecfw[i] = c;
63 }
64 ecfw[i] = '\0';
65
66 fwvh = ec_read(0xe9);
67 fwvl = ec_read(0xe8);
68
69 printk(BIOS_INFO, "EC Firmware ID %s, Version %d.%d%d%c\n", ecfw,
70 fwvh >> 4, fwvh & 0x0f, fwvl >> 4, 0x41 + (fwvl & 0xf));
Sven Schnelleb31eb3e2011-04-05 13:00:14 +000071}
72
73static void mainboard_enable(device_t dev)
74{
75 device_t dev0;
76
77 log_ec_version();
Sven Schnelle8099cbf2011-04-04 10:57:17 +000078
Sven Schnellee2ca71e2011-02-14 20:02:47 +000079 backlight_enable();
80 trackpoint_enable();
Sven Schnelleb31eb3e2011-04-05 13:00:14 +000081
Sven Schnellee2ca71e2011-02-14 20:02:47 +000082 /* FIXME: this should be ACPI's task
83 * but for now, enable it here */
84 wlan_enable();
85
86 /* enable ACPI events */
87 ec_write(0x00, 0xa6);
88 ec_write(0x01, 0x05);
89
90 ec_write(0x02, 0xa0);
91 ec_write(0x03, 0x05);
92
93 /* set mask of enabled beeps */
94 ec_write(0x04, 0xfe);
95 ec_write(0x05, 0x96);
96
97 /* Unknown, but required for hotkeys
98 Maybe a mask for enabled keys? */
99
100 ec_write(0x12, 0xff);
101 ec_write(0x13, 0xff);
102 ec_write(0x14, 0xf4);
103 ec_write(0x15, 0x3c);
Sven Schnelle46789142011-04-04 10:56:52 +0000104
105 /* enable Audio */
106 ec_clr_bit(0x3a, 0);
Sven Schnelle8099cbf2011-04-04 10:57:17 +0000107
108 /* If we're resuming from suspend, blink suspend LED */
109 dev0 = dev_find_slot(0, PCI_DEVFN(0,0));
110 if (dev0 && pci_read_config32(dev0, SKPAD) == 0xcafed00d)
111 ec_write(0x0c, 0xc7);
Sven Schnellee2ca71e2011-02-14 20:02:47 +0000112}
113
114struct chip_operations mainboard_ops = {
115 CHIP_NAME(CONFIG_MAINBOARD_VENDOR " " CONFIG_MAINBOARD_PART_NUMBER)
116 .enable_dev = mainboard_enable,
117};
118