lenovo/h8,thinkpads: Re-do USB Always On
Re-write the UAO handling code as it had stopped working (#171) (the flag was not getting read from the RTC properly in SMM) Remove the SMM code as it's not needed (but EC flag won't be set upon entering S3 now) Set the EC flags on boot the same way other flags are set Document bitwise operators for clarity Propagate changes to other Thinkpads (updated X201 to have 2 bits for the flag as it only had 1) Per Nicola Corna's previous commits, 0x0d is set for "AC only" "AC only" does exhibit different behaviour - the USB port is turned on a few seconds after entering S3, rather than < 1 sec, regardless of AC status Tested on X220 Change-Id: If812cd1ef8fb1a24d7fadbe834f574b40cbcd56a Signed-off-by: Nathaniel Roach <nroach44@gmail.com> Reviewed-on: https://review.coreboot.org/c/29565 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
This commit is contained in:
parent
d88cf5f037
commit
4f4322dd68
|
@ -9,6 +9,5 @@ ramstage-y += h8.c
|
|||
ramstage-y += bluetooth.c
|
||||
ramstage-y += wwan.c
|
||||
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += ssdt.c
|
||||
smm-y += smm.c
|
||||
|
||||
endif
|
||||
|
|
|
@ -128,6 +128,34 @@ void h8_disable_event(int event)
|
|||
|
||||
}
|
||||
|
||||
void h8_usb_always_on_enable(enum usb_always_on on)
|
||||
{
|
||||
u8 val;
|
||||
|
||||
switch (on) {
|
||||
case UAO_OFF:
|
||||
val = ec_read(H8_USB_ALWAYS_ON);
|
||||
// Clear bits 0,2,3
|
||||
val &= ~(H8_USB_ALWAYS_ON_ENABLE | H8_USB_ALWAYS_ON_AC_ONLY);
|
||||
ec_write(H8_USB_ALWAYS_ON, val);
|
||||
break;
|
||||
|
||||
case UAO_AC_AND_BATTERY:
|
||||
val = ec_read(H8_USB_ALWAYS_ON);
|
||||
val |= H8_USB_ALWAYS_ON_ENABLE; // Set bit 0
|
||||
val &= ~H8_USB_ALWAYS_ON_AC_ONLY; // Clear bits 2 and 3
|
||||
ec_write(H8_USB_ALWAYS_ON, val);
|
||||
break;
|
||||
|
||||
case UAO_AC_ONLY:
|
||||
val = ec_read(H8_USB_ALWAYS_ON);
|
||||
// Set bits 0,2,3
|
||||
val |= (H8_USB_ALWAYS_ON_ENABLE | H8_USB_ALWAYS_ON_AC_ONLY);
|
||||
ec_write(H8_USB_ALWAYS_ON, val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void h8_usb_power_enable(int onoff)
|
||||
{
|
||||
if (onoff)
|
||||
|
@ -270,8 +298,10 @@ 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, "usb_always_on") != CB_SUCCESS)
|
||||
val = 0;
|
||||
h8_usb_always_on_enable(val);
|
||||
|
||||
if (get_option(&val, "wlan") != CB_SUCCESS)
|
||||
val = 1;
|
||||
|
|
|
@ -19,9 +19,16 @@
|
|||
#include <stdint.h>
|
||||
#include <device/device.h>
|
||||
|
||||
enum usb_always_on {
|
||||
UAO_OFF = 0,
|
||||
UAO_AC_AND_BATTERY = 1,
|
||||
UAO_AC_ONLY = 2
|
||||
};
|
||||
|
||||
void h8_trackpoint_enable(int on);
|
||||
void h8_wlan_enable(int on);
|
||||
void h8_set_audio_mute(int on);
|
||||
void h8_usb_always_on_enable(enum usb_always_on on);
|
||||
void h8_usb_power_enable(int on);
|
||||
void h8_enable_event(int event);
|
||||
void h8_disable_event(int event);
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* This file is part of the coreboot project.
|
||||
*
|
||||
* Copyright (C) 2016 Nicola Corna <nicola@corna.info>
|
||||
*
|
||||
* 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 <ec/acpi/ec.h>
|
||||
#include <pc80/mc146818rtc.h>
|
||||
|
||||
#include "h8.h"
|
||||
|
||||
enum usb_always_on {
|
||||
UAO_OFF = 0,
|
||||
UAO_AC_AND_BATTERY,
|
||||
UAO_AC_ONLY
|
||||
};
|
||||
|
||||
void h8_usb_always_on(void)
|
||||
{
|
||||
enum usb_always_on val;
|
||||
u8 reg;
|
||||
|
||||
if (get_option(&val, "usb_always_on") != CB_SUCCESS)
|
||||
val = UAO_OFF;
|
||||
|
||||
if (val == UAO_AC_AND_BATTERY) {
|
||||
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);
|
||||
} else if (val == UAO_AC_ONLY) {
|
||||
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);
|
||||
ec_set_bit(0x2, 3);
|
||||
}
|
||||
}
|
|
@ -73,8 +73,6 @@ 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. */
|
||||
|
|
|
@ -72,8 +72,6 @@ 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. */
|
||||
|
|
|
@ -102,8 +102,6 @@ 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. */
|
||||
|
|
|
@ -72,8 +72,6 @@ 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. */
|
||||
|
|
|
@ -102,8 +102,6 @@ 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. */
|
||||
|
|
|
@ -102,8 +102,6 @@ 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. */
|
||||
|
|
|
@ -102,8 +102,6 @@ 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. */
|
||||
|
|
|
@ -70,7 +70,7 @@ entries
|
|||
419 1 e 1 power_management_beeps
|
||||
420 1 e 1 low_battery_beep
|
||||
421 1 e 9 sata_mode
|
||||
422 1 e 11 usb_always_on
|
||||
422 2 e 11 usb_always_on
|
||||
#423 1 r 1 unused
|
||||
|
||||
# coreboot config options: northbridge
|
||||
|
|
|
@ -178,8 +178,6 @@ 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. */
|
||||
|
|
|
@ -69,7 +69,7 @@ entries
|
|||
418 1 e 1 sticky_fn
|
||||
419 1 e 1 power_management_beeps
|
||||
421 1 e 9 sata_mode
|
||||
422 1 e 12 usb_always_on
|
||||
422 2 e 12 usb_always_on
|
||||
#423 1 r 1 unused
|
||||
|
||||
# coreboot config options: cpu
|
||||
|
|
|
@ -102,8 +102,6 @@ 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. */
|
||||
|
|
|
@ -72,8 +72,6 @@ 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. */
|
||||
|
|
Loading…
Reference in New Issue