Angel Pons | 210a008 | 2020-04-02 23:48:24 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 4 | #include <console/console.h> |
| 5 | #include <device/device.h> |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 6 | #include <device/pnp.h> |
Edward O'Callaghan | b57fef9 | 2014-06-17 20:13:08 +1000 | [diff] [blame] | 7 | #include <ec/acpi/ec.h> |
Elyes Haouas | bdd03c2 | 2024-05-27 11:20:07 +0200 | [diff] [blame^] | 8 | #include <stdio.h> |
Edward O'Callaghan | b57fef9 | 2014-06-17 20:13:08 +1000 | [diff] [blame] | 9 | #include <string.h> |
Vladimir Serbinenko | 6abb33c | 2014-08-27 23:42:45 +0200 | [diff] [blame] | 10 | #include <smbios.h> |
Kyösti Mälkki | cbf9571 | 2020-01-05 08:05:45 +0200 | [diff] [blame] | 11 | #include <option.h> |
Vladimir Serbinenko | 852014c | 2015-05-27 08:30:47 +0200 | [diff] [blame] | 12 | #include <pc80/keyboard.h> |
Elyes HAOUAS | 5fd93e0 | 2019-05-15 21:07:30 +0200 | [diff] [blame] | 13 | #include <types.h> |
Edward O'Callaghan | b57fef9 | 2014-06-17 20:13:08 +1000 | [diff] [blame] | 14 | |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 15 | #include "h8.h" |
| 16 | #include "chip.h" |
Vladimir Serbinenko | e2b6795 | 2013-11-14 19:09:42 +0100 | [diff] [blame] | 17 | |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 18 | void h8_trackpoint_enable(int on) |
| 19 | { |
Peter Stuge | d0b0400 | 2013-07-06 20:20:45 +0200 | [diff] [blame] | 20 | ec_write(H8_TRACKPOINT_CTRL, |
| 21 | on ? H8_TRACKPOINT_ON : H8_TRACKPOINT_OFF); |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 22 | } |
| 23 | |
Vladimir Serbinenko | f422a44 | 2013-11-13 21:53:23 +0100 | [diff] [blame] | 24 | /* Controls radio-off pin in WLAN MiniPCIe slot. */ |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 25 | void h8_wlan_enable(int on) |
| 26 | { |
| 27 | if (on) |
| 28 | ec_set_bit(0x3a, 5); |
| 29 | else |
| 30 | ec_clr_bit(0x3a, 5); |
| 31 | } |
| 32 | |
Vladimir Serbinenko | 883e7ac | 2014-08-13 01:22:13 +0200 | [diff] [blame] | 33 | /* Controls radio-off pin in UWB MiniPCIe slot. */ |
| 34 | static void h8_uwb_enable(int on) |
| 35 | { |
| 36 | if (on) |
| 37 | ec_set_bit(0x31, 2); |
| 38 | else |
| 39 | ec_clr_bit(0x31, 2); |
| 40 | } |
| 41 | |
Vladimir Serbinenko | fc7090b | 2014-01-11 10:29:14 +0100 | [diff] [blame] | 42 | static void h8_fn_ctrl_swap(int on) |
| 43 | { |
| 44 | if (on) |
| 45 | ec_set_bit(0xce, 4); |
| 46 | else |
| 47 | ec_clr_bit(0xce, 4); |
| 48 | } |
| 49 | |
Alexander Couzens | c5a6fb8 | 2016-10-16 06:55:19 +0200 | [diff] [blame] | 50 | enum battery { |
| 51 | SECONDARY_BATTERY = 0, |
| 52 | PRIMARY_BATTERY = 1, |
| 53 | }; |
| 54 | |
| 55 | /* h8 charge priority. Defines if primary or secondary |
| 56 | * battery is charged first. |
Martin Roth | 3e25f85 | 2023-09-04 15:37:07 -0600 | [diff] [blame] | 57 | * Because NVRAM is complete the other way around as this register, |
Alexander Couzens | c5a6fb8 | 2016-10-16 06:55:19 +0200 | [diff] [blame] | 58 | * it's inverted by if |
| 59 | */ |
| 60 | static void h8_charge_priority(enum battery battery) |
| 61 | { |
| 62 | if (battery == PRIMARY_BATTERY) |
| 63 | ec_clr_bit(0x0, 4); |
| 64 | else |
| 65 | ec_set_bit(0x0, 4); |
| 66 | } |
| 67 | |
Vladimir Serbinenko | 11a7c84 | 2014-01-11 10:55:31 +0100 | [diff] [blame] | 68 | static void h8_sticky_fn(int on) |
| 69 | { |
| 70 | if (on) |
| 71 | ec_set_bit(0x0, 3); |
| 72 | else |
| 73 | ec_clr_bit(0x0, 3); |
| 74 | } |
| 75 | |
Iru Cai | 7e8eb6b | 2019-07-31 21:01:52 +0800 | [diff] [blame] | 76 | static void f1_to_f12_as_primary(int on) |
| 77 | { |
| 78 | if (on) |
| 79 | ec_set_bit(0x3b, 3); |
| 80 | else |
| 81 | ec_clr_bit(0x3b, 3); |
| 82 | } |
| 83 | |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 84 | static void h8_log_ec_version(void) |
| 85 | { |
Peter Stuge | 77a5abe | 2013-07-06 19:44:47 +0200 | [diff] [blame] | 86 | char ecfw[17]; |
| 87 | u8 len; |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 88 | u16 fwvh, fwvl; |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 89 | |
Elyes Haouas | ad0b3fa | 2023-08-13 12:43:38 +0200 | [diff] [blame] | 90 | len = h8_build_id_and_function_spec_version(ecfw, sizeof(ecfw) - 1); |
Peter Stuge | 77a5abe | 2013-07-06 19:44:47 +0200 | [diff] [blame] | 91 | ecfw[len] = 0; |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 92 | |
| 93 | fwvh = ec_read(0xe9); |
| 94 | fwvl = ec_read(0xe8); |
| 95 | |
Paul Menzel | 58ecefb | 2020-01-09 22:35:50 +0100 | [diff] [blame] | 96 | printk(BIOS_INFO, "H8: EC Firmware ID %s, Version %d.%d%d%c\n", ecfw, |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 97 | fwvh >> 4, fwvh & 0x0f, fwvl >> 4, 0x41 + (fwvl & 0xf)); |
| 98 | } |
| 99 | |
Sven Schnelle | d0ea678 | 2011-10-25 15:29:47 +0200 | [diff] [blame] | 100 | void h8_set_audio_mute(int mute) |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 101 | { |
Sven Schnelle | d0ea678 | 2011-10-25 15:29:47 +0200 | [diff] [blame] | 102 | if (mute) |
| 103 | ec_set_bit(0x3a, 0); |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 104 | else |
Sven Schnelle | d0ea678 | 2011-10-25 15:29:47 +0200 | [diff] [blame] | 105 | ec_clr_bit(0x3a, 0); |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | void h8_enable_event(int event) |
| 109 | { |
| 110 | if (event < 0 || event > 127) |
| 111 | return; |
| 112 | |
| 113 | ec_set_bit(0x10 + (event >> 3), event & 7); |
| 114 | } |
| 115 | |
| 116 | void h8_disable_event(int event) |
| 117 | { |
| 118 | if (event < 0 || event > 127) |
| 119 | return; |
| 120 | |
| 121 | ec_clr_bit(0x10 + (event >> 3), event & 7); |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Nathaniel Roach | 4f4322d | 2018-11-10 08:34:44 +0800 | [diff] [blame] | 124 | void h8_usb_always_on_enable(enum usb_always_on on) |
| 125 | { |
| 126 | u8 val; |
| 127 | |
| 128 | switch (on) { |
| 129 | case UAO_OFF: |
| 130 | val = ec_read(H8_USB_ALWAYS_ON); |
| 131 | // Clear bits 0,2,3 |
| 132 | val &= ~(H8_USB_ALWAYS_ON_ENABLE | H8_USB_ALWAYS_ON_AC_ONLY); |
| 133 | ec_write(H8_USB_ALWAYS_ON, val); |
| 134 | break; |
| 135 | |
| 136 | case UAO_AC_AND_BATTERY: |
| 137 | val = ec_read(H8_USB_ALWAYS_ON); |
| 138 | val |= H8_USB_ALWAYS_ON_ENABLE; // Set bit 0 |
| 139 | val &= ~H8_USB_ALWAYS_ON_AC_ONLY; // Clear bits 2 and 3 |
| 140 | ec_write(H8_USB_ALWAYS_ON, val); |
| 141 | break; |
| 142 | |
| 143 | case UAO_AC_ONLY: |
| 144 | val = ec_read(H8_USB_ALWAYS_ON); |
| 145 | // Set bits 0,2,3 |
| 146 | val |= (H8_USB_ALWAYS_ON_ENABLE | H8_USB_ALWAYS_ON_AC_ONLY); |
| 147 | ec_write(H8_USB_ALWAYS_ON, val); |
| 148 | break; |
| 149 | } |
| 150 | } |
| 151 | |
Sven Schnelle | 86e1aea | 2011-06-16 16:43:04 +0200 | [diff] [blame] | 152 | void h8_usb_power_enable(int onoff) |
| 153 | { |
| 154 | if (onoff) |
| 155 | ec_set_bit(0x3b, 4); |
| 156 | else |
| 157 | ec_clr_bit(0x3b, 4); |
| 158 | } |
| 159 | |
Sven Schnelle | cf7dffe | 2011-04-27 19:47:28 +0000 | [diff] [blame] | 160 | int h8_ultrabay_device_present(void) |
| 161 | { |
| 162 | return ec_read(H8_STATUS1) & 0x5 ? 0 : 1; |
| 163 | } |
| 164 | |
Peter Stuge | 77a5abe | 2013-07-06 19:44:47 +0200 | [diff] [blame] | 165 | u8 h8_build_id_and_function_spec_version(char *buf, u8 buf_len) |
| 166 | { |
| 167 | u8 i, c; |
| 168 | char str[16 + 1]; /* 16 ASCII chars + \0 */ |
| 169 | |
| 170 | /* Build ID */ |
| 171 | for (i = 0; i < 8; i++) { |
| 172 | c = ec_read(0xf0 + i); |
| 173 | if (c < 0x20 || c > 0x7f) { |
Elyes HAOUAS | af56a77 | 2020-07-22 20:36:20 +0200 | [diff] [blame] | 174 | i = snprintf(str, sizeof(str), "*INVALID"); |
Peter Stuge | 77a5abe | 2013-07-06 19:44:47 +0200 | [diff] [blame] | 175 | break; |
| 176 | } |
| 177 | str[i] = c; |
| 178 | } |
| 179 | |
| 180 | /* EC firmware function specification version */ |
Elyes HAOUAS | af56a77 | 2020-07-22 20:36:20 +0200 | [diff] [blame] | 181 | i += snprintf(str + i, sizeof(str) - i, "-%u.%u", ec_read(0xef), ec_read(0xeb)); |
Peter Stuge | 77a5abe | 2013-07-06 19:44:47 +0200 | [diff] [blame] | 182 | |
| 183 | i = MIN(buf_len, i); |
| 184 | memcpy(buf, str, i); |
| 185 | |
| 186 | return i; |
| 187 | } |
| 188 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 189 | #if CONFIG(GENERATE_SMBIOS_TABLES) |
Edward O'Callaghan | 2c9d2cf | 2014-10-27 23:29:29 +1100 | [diff] [blame] | 190 | static void h8_smbios_strings(struct device *dev, struct smbios_type11 *t) |
Vladimir Serbinenko | 6abb33c | 2014-08-27 23:42:45 +0200 | [diff] [blame] | 191 | { |
| 192 | char tpec[] = "IBM ThinkPad Embedded Controller -[ ]-"; |
| 193 | |
| 194 | h8_build_id_and_function_spec_version(tpec + 35, 17); |
| 195 | |
| 196 | t->count = smbios_add_string(t->eos, tpec); |
| 197 | } |
Paul Menzel | 2a4a452 | 2016-12-08 00:03:38 +0100 | [diff] [blame] | 198 | #endif |
Vladimir Serbinenko | 6abb33c | 2014-08-27 23:42:45 +0200 | [diff] [blame] | 199 | |
Elyes HAOUAS | 6572bdd | 2018-05-04 18:32:11 +0200 | [diff] [blame] | 200 | static void h8_init(struct device *dev) |
Vladimir Serbinenko | 852014c | 2015-05-27 08:30:47 +0200 | [diff] [blame] | 201 | { |
Timothy Pearson | 448e386 | 2015-11-24 14:12:01 -0600 | [diff] [blame] | 202 | pc_keyboard_init(NO_AUX_DEVICE); |
Vladimir Serbinenko | 852014c | 2015-05-27 08:30:47 +0200 | [diff] [blame] | 203 | } |
| 204 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 205 | #if CONFIG(HAVE_ACPI_TABLES) |
Patrick Rudolph | f1114d8 | 2017-11-14 19:00:20 +0100 | [diff] [blame] | 206 | static const char *h8_acpi_name(const struct device *dev) |
| 207 | { |
| 208 | return "EC"; |
| 209 | } |
| 210 | #endif |
| 211 | |
Vladimir Serbinenko | 6abb33c | 2014-08-27 23:42:45 +0200 | [diff] [blame] | 212 | struct device_operations h8_dev_ops = { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 213 | #if CONFIG(GENERATE_SMBIOS_TABLES) |
Vladimir Serbinenko | 852014c | 2015-05-27 08:30:47 +0200 | [diff] [blame] | 214 | .get_smbios_strings = h8_smbios_strings, |
Paul Menzel | 2a4a452 | 2016-12-08 00:03:38 +0100 | [diff] [blame] | 215 | #endif |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 216 | #if CONFIG(HAVE_ACPI_TABLES) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 217 | .acpi_fill_ssdt = h8_ssdt_generator, |
Patrick Rudolph | f1114d8 | 2017-11-14 19:00:20 +0100 | [diff] [blame] | 218 | .acpi_name = h8_acpi_name, |
| 219 | #endif |
Vladimir Serbinenko | 852014c | 2015-05-27 08:30:47 +0200 | [diff] [blame] | 220 | .init = h8_init, |
Vladimir Serbinenko | 6abb33c | 2014-08-27 23:42:45 +0200 | [diff] [blame] | 221 | }; |
| 222 | |
Bill XIE | 4611ad8 | 2020-03-21 02:07:41 +0800 | [diff] [blame] | 223 | void __weak h8_mb_init(void){ /* NOOP */ } |
| 224 | |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 225 | static void h8_enable(struct device *dev) |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 226 | { |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 227 | struct ec_lenovo_h8_config *conf = dev->chip_info; |
Alexander Couzens | c5a6fb8 | 2016-10-16 06:55:19 +0200 | [diff] [blame] | 228 | u8 val; |
Patrick Rudolph | a959a14 | 2017-05-24 18:14:43 +0200 | [diff] [blame] | 229 | u8 beepmask0, beepmask1, reg8; |
Sven Schnelle | 1b8068e | 2011-06-05 20:47:49 +0200 | [diff] [blame] | 230 | |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 231 | dev->ops = &h8_dev_ops; |
Vladimir Serbinenko | 6abb33c | 2014-08-27 23:42:45 +0200 | [diff] [blame] | 232 | |
Bill XIE | 54f45c6 | 2017-10-26 11:55:34 +0800 | [diff] [blame] | 233 | ec_clear_out_queue(); |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 234 | h8_log_ec_version(); |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 235 | |
Patrick Rudolph | a959a14 | 2017-05-24 18:14:43 +0200 | [diff] [blame] | 236 | /* Always enable I/O range 0x1600-0x160f and thermal management */ |
| 237 | reg8 = conf->config0; |
| 238 | reg8 |= H8_CONFIG0_SMM_H8_ENABLE; |
| 239 | reg8 |= H8_CONFIG0_TC_ENABLE; |
| 240 | ec_write(H8_CONFIG0, reg8); |
Vladimir Serbinenko | f3c3dae | 2014-01-12 15:19:50 +0100 | [diff] [blame] | 241 | |
Patrick Rudolph | a959a14 | 2017-05-24 18:14:43 +0200 | [diff] [blame] | 242 | reg8 = conf->config1; |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 243 | if (conf->has_keyboard_backlight) { |
Angel Pons | 9dc1c51 | 2020-11-02 20:59:32 +0100 | [diff] [blame] | 244 | /* Default to both backlights */ |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 245 | reg8 = (reg8 & 0xf3) | ((get_uint_option("backlight", 0) & 0x3) << 2); |
Vladimir Serbinenko | f3c3dae | 2014-01-12 15:19:50 +0100 | [diff] [blame] | 246 | } |
Patrick Rudolph | a959a14 | 2017-05-24 18:14:43 +0200 | [diff] [blame] | 247 | ec_write(H8_CONFIG1, reg8); |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 248 | ec_write(H8_CONFIG2, conf->config2); |
| 249 | ec_write(H8_CONFIG3, conf->config3); |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 250 | |
Vladimir Serbinenko | 9a3b9c4 | 2014-01-11 20:56:47 +0100 | [diff] [blame] | 251 | beepmask0 = conf->beepmask0; |
| 252 | beepmask1 = conf->beepmask1; |
| 253 | |
Angel Pons | 9dc1c51 | 2020-11-02 20:59:32 +0100 | [diff] [blame] | 254 | if (conf->has_power_management_beeps) { |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 255 | if (get_uint_option("power_management_beeps", 1) == 0) { |
Angel Pons | 9dc1c51 | 2020-11-02 20:59:32 +0100 | [diff] [blame] | 256 | beepmask0 = 0x00; |
| 257 | beepmask1 = 0x00; |
| 258 | } |
Vladimir Serbinenko | 9a3b9c4 | 2014-01-11 20:56:47 +0100 | [diff] [blame] | 259 | } |
Vladimir Serbinenko | add3f7f | 2014-01-11 20:58:20 +0100 | [diff] [blame] | 260 | |
| 261 | if (conf->has_power_management_beeps) { |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 262 | if (get_uint_option("low_battery_beep", 1)) |
Vladimir Serbinenko | add3f7f | 2014-01-11 20:58:20 +0100 | [diff] [blame] | 263 | beepmask0 |= 2; |
| 264 | else |
| 265 | beepmask0 &= ~2; |
| 266 | } |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 267 | |
Vladimir Serbinenko | 9a3b9c4 | 2014-01-11 20:56:47 +0100 | [diff] [blame] | 268 | ec_write(H8_SOUND_ENABLE0, beepmask0); |
| 269 | ec_write(H8_SOUND_ENABLE1, beepmask1); |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 270 | |
Alexander Couzens | f6dde95 | 2015-05-24 03:17:42 +0200 | [diff] [blame] | 271 | /* silence sounds in queue */ |
Alexander Couzens | 318ed6f | 2016-10-16 07:44:26 +0200 | [diff] [blame] | 272 | ec_write(H8_SOUND_REPEAT, 0x00); |
Alexander Couzens | f6dde95 | 2015-05-24 03:17:42 +0200 | [diff] [blame] | 273 | ec_write(H8_SOUND_REG, 0x00); |
| 274 | |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 275 | ec_write(0x10, conf->event0_enable); |
| 276 | ec_write(0x11, conf->event1_enable); |
| 277 | ec_write(0x12, conf->event2_enable); |
| 278 | ec_write(0x13, conf->event3_enable); |
| 279 | ec_write(0x14, conf->event4_enable); |
| 280 | ec_write(0x15, conf->event5_enable); |
| 281 | ec_write(0x16, conf->event6_enable); |
| 282 | ec_write(0x17, conf->event7_enable); |
| 283 | ec_write(0x18, conf->event8_enable); |
| 284 | ec_write(0x19, conf->event9_enable); |
| 285 | ec_write(0x1a, conf->eventa_enable); |
| 286 | ec_write(0x1b, conf->eventb_enable); |
| 287 | ec_write(0x1c, conf->eventc_enable); |
| 288 | ec_write(0x1d, conf->eventd_enable); |
| 289 | ec_write(0x1e, conf->evente_enable); |
| 290 | ec_write(0x1f, conf->eventf_enable); |
| 291 | |
Sven Schnelle | 3e2f679 | 2011-04-12 18:18:24 +0000 | [diff] [blame] | 292 | ec_write(H8_FAN_CONTROL, H8_FAN_CONTROL_AUTO); |
Nathaniel Roach | 4f4322d | 2018-11-10 08:34:44 +0800 | [diff] [blame] | 293 | |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 294 | h8_usb_always_on_enable(get_uint_option("usb_always_on", 0)); |
Vladimir Serbinenko | 8e7e525 | 2014-01-11 03:45:53 +0100 | [diff] [blame] | 295 | |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 296 | h8_wlan_enable(get_uint_option("wlan", 1)); |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 297 | |
Vladimir Serbinenko | 1eda31c | 2014-01-11 04:18:52 +0100 | [diff] [blame] | 298 | h8_trackpoint_enable(1); |
Sven Schnelle | 86e1aea | 2011-06-16 16:43:04 +0200 | [diff] [blame] | 299 | h8_usb_power_enable(1); |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 300 | |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 301 | unsigned int volume = get_uint_option("volume", ~0); |
Angel Pons | 9157ccb | 2021-04-26 18:05:42 +0200 | [diff] [blame] | 302 | if (volume <= 0xff && !acpi_is_wakeup_s3()) |
Angel Pons | 9dc1c51 | 2020-11-02 20:59:32 +0100 | [diff] [blame] | 303 | ec_write(H8_VOLUME_CONTROL, volume); |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 304 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 305 | val = (CONFIG(H8_SUPPORT_BT_ON_WIFI) || h8_has_bdc(dev)) && |
Patrick Rudolph | 7c2a6f9 | 2017-09-17 12:17:13 +0200 | [diff] [blame] | 306 | h8_bluetooth_nv_enable(); |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 307 | h8_bluetooth_enable(val); |
| 308 | |
Patrick Rudolph | b8e325a | 2017-08-13 12:09:54 +0200 | [diff] [blame] | 309 | val = h8_has_wwan(dev) && h8_wwan_nv_enable(); |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 310 | h8_wwan_enable(val); |
| 311 | |
Angel Pons | 9dc1c51 | 2020-11-02 20:59:32 +0100 | [diff] [blame] | 312 | if (conf->has_uwb) |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 313 | h8_uwb_enable(get_uint_option("uwb", 1)); |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 314 | |
Angel Pons | c6df44b | 2022-09-26 16:26:30 +0200 | [diff] [blame] | 315 | h8_fn_ctrl_swap(get_uint_option("fn_ctrl_swap", CONFIG(H8_FN_CTRL_SWAP))); |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 316 | |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 317 | h8_sticky_fn(get_uint_option("sticky_fn", 0)); |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 318 | |
Angel Pons | 9dc1c51 | 2020-11-02 20:59:32 +0100 | [diff] [blame] | 319 | if (CONFIG(H8_HAS_PRIMARY_FN_KEYS)) |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 320 | f1_to_f12_as_primary(get_uint_option("f1_to_f12_as_primary", 1)); |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 321 | |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 322 | h8_charge_priority(get_uint_option("first_battery", PRIMARY_BATTERY)); |
Nico Huber | 6444b52 | 2016-11-14 00:49:29 +0200 | [diff] [blame] | 323 | |
| 324 | h8_set_audio_mute(0); |
Bill XIE | 4611ad8 | 2020-03-21 02:07:41 +0800 | [diff] [blame] | 325 | h8_mb_init(); |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | struct chip_operations ec_lenovo_h8_ops = { |
Nicholas Sudsgaard | bfb11be | 2024-01-30 09:53:46 +0900 | [diff] [blame] | 329 | .name = "Lenovo H8 EC", |
Vladimir Serbinenko | 6abb33c | 2014-08-27 23:42:45 +0200 | [diff] [blame] | 330 | .enable_dev = h8_enable, |
Sven Schnelle | ffcd143 | 2011-04-11 19:43:32 +0000 | [diff] [blame] | 331 | }; |