diff --git a/src/ec/lenovo/h8/Makefile.inc b/src/ec/lenovo/h8/Makefile.inc index 4829e7b624..da9cee1d9f 100644 --- a/src/ec/lenovo/h8/Makefile.inc +++ b/src/ec/lenovo/h8/Makefile.inc @@ -1,5 +1,6 @@ ifeq ($(CONFIG_EC_LENOVO_H8),y) ramstage-y += h8.c +smm-y += smm.c endif diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c index b7b9db75c9..cfc3938e3d 100644 --- a/src/ec/lenovo/h8/h8.c +++ b/src/ec/lenovo/h8/h8.c @@ -268,6 +268,8 @@ static void h8_enable(struct device *dev) ec_write(0x1f, conf->eventf_enable); ec_write(H8_FAN_CONTROL, H8_FAN_CONTROL_AUTO); + ec_write(H8_USB_ALWAYS_ON, ec_read(H8_USB_ALWAYS_ON) & + ~H8_USB_ALWAYS_ON_ENABLE); if (get_option(&val, "wlan") != CB_SUCCESS) val = 1; diff --git a/src/ec/lenovo/h8/h8.h b/src/ec/lenovo/h8/h8.h index d3803c0700..290db918ec 100644 --- a/src/ec/lenovo/h8/h8.h +++ b/src/ec/lenovo/h8/h8.h @@ -26,6 +26,7 @@ void h8_enable_event(int event); void h8_disable_event(int event); int h8_ultrabay_device_present(void); u8 h8_build_id_and_function_spec_version(char *buf, u8 buf_len); +void h8_usb_always_on(void); #if !IS_ENABLED (CONFIG_H8_DOCK_EARLY_INIT) void h8_mainboard_init_dock (void); @@ -64,6 +65,10 @@ void h8_mainboard_init_dock (void); #define H8_LED_CONTROL_ON 0x80 #define H8_LED_CONTROL_BLINK 0xc0 +#define H8_USB_ALWAYS_ON 0x0d +#define H8_USB_ALWAYS_ON_ENABLE 0x01 +#define H8_USB_ALWAYS_ON_AC_ONLY 0x0c + #define H8_LED_CONTROL_POWER_LED 0x00 #define H8_LED_CONTROL_BAT0_LED 0x01 #define H8_LED_CONTROL_BAT1_LED 0x02 diff --git a/src/ec/lenovo/h8/smm.c b/src/ec/lenovo/h8/smm.c new file mode 100644 index 0000000000..31009a6926 --- /dev/null +++ b/src/ec/lenovo/h8/smm.c @@ -0,0 +1,35 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2016 Nicola Corna + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include + +#include "h8.h" + +void h8_usb_always_on(void) +{ + u8 val; + u8 reg; + + if (get_option(&val, "usb_always_on") != CB_SUCCESS) + val = 0; + + if (val) { + reg = ec_read(H8_USB_ALWAYS_ON); + reg &= ~H8_USB_ALWAYS_ON_AC_ONLY; + reg |= H8_USB_ALWAYS_ON_ENABLE; + ec_write(H8_USB_ALWAYS_ON, reg); + } +} diff --git a/src/mainboard/lenovo/x201/cmos.default b/src/mainboard/lenovo/x201/cmos.default index 50d17aefd2..9f1e31ded2 100644 --- a/src/mainboard/lenovo/x201/cmos.default +++ b/src/mainboard/lenovo/x201/cmos.default @@ -15,3 +15,4 @@ sticky_fn=Disable power_management_beeps=Enable low_battery_beep=Enable sata_mode=AHCI +usb_always_on=Disable diff --git a/src/mainboard/lenovo/x201/cmos.layout b/src/mainboard/lenovo/x201/cmos.layout index 2a91eb71bb..72702328fb 100644 --- a/src/mainboard/lenovo/x201/cmos.layout +++ b/src/mainboard/lenovo/x201/cmos.layout @@ -70,8 +70,8 @@ entries 419 1 e 1 power_management_beeps 420 1 e 1 low_battery_beep 421 1 e 9 sata_mode - -#422 2 r 0 unused +422 1 e 11 usb_always_on +#423 1 r 1 unused # coreboot config options: northbridge 424 3 e 10 gfx_uma_size @@ -123,6 +123,8 @@ enumerations 10 3 128M 10 5 96M 10 6 160M +11 0 Disable +11 1 AC and battery # ----------------------------------------------------------------- checksums diff --git a/src/mainboard/lenovo/x201/smihandler.c b/src/mainboard/lenovo/x201/smihandler.c index 591a52112e..f00ae0dcdc 100644 --- a/src/mainboard/lenovo/x201/smihandler.c +++ b/src/mainboard/lenovo/x201/smihandler.c @@ -178,6 +178,8 @@ int mainboard_smi_apmc(u8 data) void mainboard_smi_sleep(u8 slp_typ) { + h8_usb_always_on(); + if (slp_typ == 3) { u8 ec_wake = ec_read(0x32); /* If EC wake events are enabled, enable wake on EC WAKE GPE. */ diff --git a/src/mainboard/lenovo/x220/cmos.default b/src/mainboard/lenovo/x220/cmos.default index 1b8e212894..91331ab22e 100644 --- a/src/mainboard/lenovo/x220/cmos.default +++ b/src/mainboard/lenovo/x220/cmos.default @@ -10,6 +10,7 @@ wwan=Enable wlan=Enable touchpad=Enable sata_mode=AHCI +usb_always_on=Disable fn_ctrl_swap=Disable sticky_fn=Disable trackpoint=Enable diff --git a/src/mainboard/lenovo/x220/cmos.layout b/src/mainboard/lenovo/x220/cmos.layout index 143ee807cd..0f57058ca2 100644 --- a/src/mainboard/lenovo/x220/cmos.layout +++ b/src/mainboard/lenovo/x220/cmos.layout @@ -69,7 +69,8 @@ entries 418 1 e 1 sticky_fn 419 1 e 1 power_management_beeps 421 1 e 9 sata_mode -#422 2 r 1 unused +422 1 e 12 usb_always_on +#423 1 r 1 unused # coreboot config options: cpu 424 1 e 2 hyper_threading @@ -134,6 +135,8 @@ enumerations 11 4 160M 11 5 192M 11 6 224M +12 0 Disable +12 1 AC and battery # ----------------------------------------------------------------- checksums diff --git a/src/mainboard/lenovo/x220/smihandler.c b/src/mainboard/lenovo/x220/smihandler.c index 08554c93ec..e1bb37698f 100644 --- a/src/mainboard/lenovo/x220/smihandler.c +++ b/src/mainboard/lenovo/x220/smihandler.c @@ -133,6 +133,8 @@ int mainboard_smi_apmc(u8 data) void mainboard_smi_sleep(u8 slp_typ) { + h8_usb_always_on(); + if (slp_typ == 3) { u8 ec_wake = ec_read(0x32); /* If EC wake events are enabled, enable wake on EC WAKE GPE. */