ec/lenovo/h8/smm: Support USB always on AC only
[coreboot.git] / src / ec / lenovo / h8 / smm.c
blob6005c310332f10f70231cbd73ef8bb0b19f58785
1 /*
2 * This file is part of the coreboot project.
4 * Copyright (C) 2016 Nicola Corna <nicola@corna.info>
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.
16 #include <ec/acpi/ec.h>
17 #include <pc80/mc146818rtc.h>
19 #include "h8.h"
21 enum usb_always_on {
22 UAO_OFF = 0,
23 UAO_AC_AND_BATTERY,
24 UAO_AC_ONLY
27 void h8_usb_always_on(void)
29 enum usb_always_on val;
30 u8 reg;
32 if (get_option(&val, "usb_always_on") != CB_SUCCESS)
33 val = UAO_OFF;
35 if (val == UAO_AC_AND_BATTERY) {
36 reg = ec_read(H8_USB_ALWAYS_ON);
37 reg &= ~H8_USB_ALWAYS_ON_AC_ONLY;
38 reg |= H8_USB_ALWAYS_ON_ENABLE;
39 ec_write(H8_USB_ALWAYS_ON, reg);
40 } else if (val == UAO_AC_ONLY) {
41 reg = ec_read(H8_USB_ALWAYS_ON);
42 reg |= H8_USB_ALWAYS_ON_AC_ONLY;
43 reg |= H8_USB_ALWAYS_ON_ENABLE;
44 ec_write(H8_USB_ALWAYS_ON, reg);
45 ec_set_bit(0x2, 3);