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>
29 void h8_trackpoint_enable(int on)
31 ec_write(H8_TRACKPOINT_CTRL,
32 on ? H8_TRACKPOINT_ON : H8_TRACKPOINT_OFF);
36 void h8_wlan_enable(int on)
44 static void h8_log_ec_version(void)
46 unsigned char ecfw[9], c;
50 for(i = 0; i < 8; i++) {
51 c = ec_read(0xf0 + i);
52 if (c < 0x20 || c > 0x7f)
61 printk(BIOS_INFO, "EC Firmware ID %s, Version %d.%d%d%c\n", ecfw,
62 fwvh >> 4, fwvh & 0x0f, fwvl >> 4, 0x41 + (fwvl & 0xf));
65 void h8_set_audio_mute(int on)
73 void h8_enable_event(int event)
75 if (event < 0 || event > 127)
78 ec_set_bit(0x10 + (event >> 3), event & 7);
81 void h8_disable_event(int event)
83 if (event < 0 || event > 127)
86 ec_clr_bit(0x10 + (event >> 3), event & 7);
90 int h8_ultrabay_device_present(void)
92 return ec_read(H8_STATUS1) & 0x5 ? 0 : 1;
95 static void h8_enable(device_t dev)
97 struct ec_lenovo_h8_config *conf = dev->chip_info;
100 ec_write(H8_CONFIG0, conf->config0);
101 ec_write(H8_CONFIG1, conf->config1);
102 ec_write(H8_CONFIG2, conf->config2);
103 ec_write(H8_CONFIG3, conf->config3);
105 ec_write(H8_SOUND_ENABLE0, conf->beepmask0);
106 ec_write(H8_SOUND_ENABLE1, conf->beepmask1);
107 ec_write(H8_SOUND_REPEAT, 0x00);
109 ec_write(0x10, conf->event0_enable);
110 ec_write(0x11, conf->event1_enable);
111 ec_write(0x12, conf->event2_enable);
112 ec_write(0x13, conf->event3_enable);
113 ec_write(0x14, conf->event4_enable);
114 ec_write(0x15, conf->event5_enable);
115 ec_write(0x16, conf->event6_enable);
116 ec_write(0x17, conf->event7_enable);
117 ec_write(0x18, conf->event8_enable);
118 ec_write(0x19, conf->event9_enable);
119 ec_write(0x1a, conf->eventa_enable);
120 ec_write(0x1b, conf->eventb_enable);
121 ec_write(0x1c, conf->eventc_enable);
122 ec_write(0x1d, conf->eventd_enable);
123 ec_write(0x1e, conf->evente_enable);
124 ec_write(0x1f, conf->eventf_enable);
126 ec_write(H8_FAN_CONTROL, H8_FAN_CONTROL_AUTO);
127 h8_wlan_enable(conf->wlan_enable);
128 h8_trackpoint_enable(conf->trackpoint_enable);
132 struct chip_operations ec_lenovo_h8_ops = {
133 CHIP_NAME("Lenovo H8 EC")
134 .enable_dev = h8_enable