2 * This file is part of the coreboot project.
4 * Copyright (C) 2011 Sven Schnelle <svens@stackframe.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <console/console.h>
22 #include <device/device.h>
23 #include <ec/acpi/ec.h>
24 #include <device/pnp.h>
28 #include <pc80/mc146818rtc.h>
30 void h8_trackpoint_enable(int on)
32 ec_write(H8_TRACKPOINT_CTRL,
33 on ? H8_TRACKPOINT_ON : H8_TRACKPOINT_OFF);
37 void h8_wlan_enable(int on)
45 static void h8_log_ec_version(void)
47 unsigned char ecfw[9], c;
51 for(i = 0; i < 8; i++) {
52 c = ec_read(0xf0 + i);
53 if (c < 0x20 || c > 0x7f)
62 printk(BIOS_INFO, "EC Firmware ID %s, Version %d.%d%d%c\n", ecfw,
63 fwvh >> 4, fwvh & 0x0f, fwvl >> 4, 0x41 + (fwvl & 0xf));
66 void h8_set_audio_mute(int mute)
74 void h8_enable_event(int event)
76 if (event < 0 || event > 127)
79 ec_set_bit(0x10 + (event >> 3), event & 7);
82 void h8_disable_event(int event)
84 if (event < 0 || event > 127)
87 ec_clr_bit(0x10 + (event >> 3), event & 7);
91 void h8_usb_power_enable(int onoff)
99 int h8_ultrabay_device_present(void)
101 return ec_read(H8_STATUS1) & 0x5 ? 0 : 1;
104 static void h8_enable(device_t dev)
106 struct ec_lenovo_h8_config *conf = dev->chip_info;
111 ec_write(H8_CONFIG0, conf->config0);
112 ec_write(H8_CONFIG1, conf->config1);
113 ec_write(H8_CONFIG2, conf->config2);
114 ec_write(H8_CONFIG3, conf->config3);
116 ec_write(H8_SOUND_ENABLE0, conf->beepmask0);
117 ec_write(H8_SOUND_ENABLE1, conf->beepmask1);
118 ec_write(H8_SOUND_REPEAT, 0x00);
120 ec_write(0x10, conf->event0_enable);
121 ec_write(0x11, conf->event1_enable);
122 ec_write(0x12, conf->event2_enable);
123 ec_write(0x13, conf->event3_enable);
124 ec_write(0x14, conf->event4_enable);
125 ec_write(0x15, conf->event5_enable);
126 ec_write(0x16, conf->event6_enable);
127 ec_write(0x17, conf->event7_enable);
128 ec_write(0x18, conf->event8_enable);
129 ec_write(0x19, conf->event9_enable);
130 ec_write(0x1a, conf->eventa_enable);
131 ec_write(0x1b, conf->eventb_enable);
132 ec_write(0x1c, conf->eventc_enable);
133 ec_write(0x1d, conf->eventd_enable);
134 ec_write(0x1e, conf->evente_enable);
135 ec_write(0x1f, conf->eventf_enable);
137 ec_write(H8_FAN_CONTROL, H8_FAN_CONTROL_AUTO);
138 h8_wlan_enable(conf->wlan_enable);
139 h8_trackpoint_enable(conf->trackpoint_enable);
140 h8_usb_power_enable(1);
142 if (!get_option(&val, "volume"))
143 ec_write(H8_VOLUME_CONTROL, val);
146 if (!get_option(&val, "first_battery")) {
147 tmp = ec_read(H8_CONFIG3);
149 tmp |= (val & 1)<< 4;
150 ec_write(H8_CONFIG3, tmp);
152 h8_set_audio_mute(0);
155 struct chip_operations ec_lenovo_h8_ops = {
156 CHIP_NAME("Lenovo H8 EC")
157 .enable_dev = h8_enable