diff options
author | Furquan Shaikh <furquan@chromium.org> | 2016-11-15 20:33:29 -0800 |
---|---|---|
committer | Furquan Shaikh <furquan@google.com> | 2016-11-18 04:01:59 +0100 |
commit | cd2afc0df034670a83479aded514b22b99124cf5 (patch) | |
tree | 185aa9e1d8dd811a93b90682e250b95bf4ae8cee /src | |
parent | f8a274acf53217129460b5a487396761c174bd54 (diff) | |
download | coreboot-cd2afc0df034670a83479aded514b22b99124cf5.tar.gz coreboot-cd2afc0df034670a83479aded514b22b99124cf5.tar.bz2 coreboot-cd2afc0df034670a83479aded514b22b99124cf5.zip |
google/chromeec: Add common infrastructure for boot-mode switches
Instead of defining the same functions for reading/clearing boot-mode
switches from EC in every mainboard, add a common infrastructure to
enable common functions for handling boot-mode switches if
GOOGLE_CHROMEEC is being used.
Only boards that were not moved to this new infrastructure are those
that do not use GOOGLE_CHROMEEC or which rely on some mainboard specific
mechanism for reading boot-mode switches.
BUG=None
BRANCH=None
TEST=abuild compiles all boards successfully with and without ChromeOS
option.
Change-Id: I267aadea9e616464563df04b51a668b877f0d578
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://review.coreboot.org/17449
Tested-by: build bot (Jenkins)
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src')
50 files changed, 106 insertions, 875 deletions
diff --git a/src/ec/google/chromeec/Kconfig b/src/ec/google/chromeec/Kconfig index f8090030eff3..76eef05dbe49 100644 --- a/src/ec/google/chromeec/Kconfig +++ b/src/ec/google/chromeec/Kconfig @@ -158,3 +158,10 @@ config EC_GOOGLE_CHROMEEC_PD_FIRMWARE_FILE depends on EC_GOOGLE_CHROMEEC_PD_FIRMWARE_EXTERNAL help The path and filename of the PD firmware file to use. + +config EC_GOOGLE_CHROMEEC_SWITCHES + depends on EC_GOOGLE_CHROMEEC && CHROMEOS + bool + help + Enable support for Chrome OS mode switches provided by the Chrome OS + EC. diff --git a/src/ec/google/chromeec/Makefile.inc b/src/ec/google/chromeec/Makefile.inc index b38d5b72ffb5..2fe6994884f3 100644 --- a/src/ec/google/chromeec/Makefile.inc +++ b/src/ec/google/chromeec/Makefile.inc @@ -29,6 +29,10 @@ smm-$(CONFIG_VBOOT) += vboot_storage.c romstage-$(CONFIG_VBOOT) += vboot_storage.c verstage-$(CONFIG_VBOOT) += vboot_storage.c +verstage-$(CONFIG_EC_GOOGLE_CHROMEEC_SWITCHES) += switches.c +romstage-$(CONFIG_EC_GOOGLE_CHROMEEC_SWITCHES) += switches.c +ramstage-$(CONFIG_EC_GOOGLE_CHROMEEC_SWITCHES) += switches.c + CHROMEEC_SOURCE ?= $(top)/3rdparty/chromeec # These are Chrome EC firmware images that a payload (such as depthcharge) can diff --git a/src/ec/google/chromeec/switches.c b/src/ec/google/chromeec/switches.c new file mode 100644 index 000000000000..74f72105d055 --- /dev/null +++ b/src/ec/google/chromeec/switches.c @@ -0,0 +1,59 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2016 Google Inc. + * + * 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 <bootmode.h> +#include <ec/google/chromeec/ec.h> + +#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_LPC) +int get_lid_switch(void) +{ + if (!IS_ENABLED(CONFIG_LID_SWITCH)) + return -1; + + return !!(google_chromeec_get_switches() & EC_SWITCH_LID_OPEN); +} +#endif + +int get_recovery_mode_switch(void) +{ + /* Check for dedicated recovery switch first. */ + if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_LPC) && + (google_chromeec_get_switches() & EC_SWITCH_DEDICATED_RECOVERY)) + return 1; + + /* Check if the EC has posted the keyboard recovery/fastboot event. */ + return !!(google_chromeec_get_events_b() & + (EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY) | + EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_FASTBOOT))); +} + +int get_recovery_mode_retrain_switch(void) +{ + /* + * Check if the EC has posted the keyboard recovery event with memory + * retrain. + */ + return !!(google_chromeec_get_events_b() & + EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT)); +} + +int clear_recovery_mode_switch(void) +{ + /* Clear all host event bits requesting recovery mode. */ + return google_chromeec_clear_events_b( + EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY) | + EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT) | + EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_FASTBOOT)); +} diff --git a/src/mainboard/google/auron/Kconfig b/src/mainboard/google/auron/Kconfig index f1b1719d683b..a6fd09cdac50 100644 --- a/src/mainboard/google/auron/Kconfig +++ b/src/mainboard/google/auron/Kconfig @@ -16,6 +16,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy config CHROMEOS select CHROMEOS_RAMOOPS_DYNAMIC + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select LID_SWITCH select VBOOT_VBNV_CMOS diff --git a/src/mainboard/google/auron/chromeos.c b/src/mainboard/google/auron/chromeos.c index 20685c67d111..61b3e4ef1e3d 100644 --- a/src/mainboard/google/auron/chromeos.c +++ b/src/mainboard/google/auron/chromeos.c @@ -14,14 +14,8 @@ */ #include <string.h> -#include <arch/io.h> -#include <device/device.h> -#include <device/pci.h> -#include <console/console.h> #include <vendorcode/google/chromeos/chromeos.h> -#include <ec/google/chromeec/ec.h> #include <soc/gpio.h> -#include "ec.h" /* SPI Write protect is GPIO 16 */ #define CROS_WP_GPIO 58 @@ -43,41 +37,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif -int get_lid_switch(void) -{ - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - - return !!(ec_switches & EC_SWITCH_LID_OPEN); -} - -/* The dev-switch is virtual */ -int get_developer_mode_switch(void) -{ - return 0; -} - -/* There are actually two recovery switches. One is the magic keyboard chord, - * the other is driven by Servo. */ -int get_recovery_mode_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - u32 ec_events; - - /* If a switch is set, we don't need to look at events. */ - if (ec_switches & (EC_SWITCH_DEDICATED_RECOVERY)) - return 1; - - /* Else check if the EC has posted the keyboard recovery event. */ - ec_events = google_chromeec_get_events_b(); - - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -#else - return 0; -#endif -} - int get_write_protect_state(void) { return get_gpio(CROS_WP_GPIO); diff --git a/src/mainboard/google/auron_paine/Kconfig b/src/mainboard/google/auron_paine/Kconfig index 533c3dad1bcd..774c79355f6f 100644 --- a/src/mainboard/google/auron_paine/Kconfig +++ b/src/mainboard/google/auron_paine/Kconfig @@ -15,6 +15,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select INTEL_INT15 config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select CHROMEOS_RAMOOPS_DYNAMIC select LID_SWITCH diff --git a/src/mainboard/google/auron_paine/chromeos.c b/src/mainboard/google/auron_paine/chromeos.c index 20685c67d111..61b3e4ef1e3d 100644 --- a/src/mainboard/google/auron_paine/chromeos.c +++ b/src/mainboard/google/auron_paine/chromeos.c @@ -14,14 +14,8 @@ */ #include <string.h> -#include <arch/io.h> -#include <device/device.h> -#include <device/pci.h> -#include <console/console.h> #include <vendorcode/google/chromeos/chromeos.h> -#include <ec/google/chromeec/ec.h> #include <soc/gpio.h> -#include "ec.h" /* SPI Write protect is GPIO 16 */ #define CROS_WP_GPIO 58 @@ -43,41 +37,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif -int get_lid_switch(void) -{ - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - - return !!(ec_switches & EC_SWITCH_LID_OPEN); -} - -/* The dev-switch is virtual */ -int get_developer_mode_switch(void) -{ - return 0; -} - -/* There are actually two recovery switches. One is the magic keyboard chord, - * the other is driven by Servo. */ -int get_recovery_mode_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - u32 ec_events; - - /* If a switch is set, we don't need to look at events. */ - if (ec_switches & (EC_SWITCH_DEDICATED_RECOVERY)) - return 1; - - /* Else check if the EC has posted the keyboard recovery event. */ - ec_events = google_chromeec_get_events_b(); - - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -#else - return 0; -#endif -} - int get_write_protect_state(void) { return get_gpio(CROS_WP_GPIO); diff --git a/src/mainboard/google/chell/Kconfig b/src/mainboard/google/chell/Kconfig index 38db37303138..e563ff175087 100644 --- a/src/mainboard/google/chell/Kconfig +++ b/src/mainboard/google/chell/Kconfig @@ -20,6 +20,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select SOC_INTEL_SKYLAKE config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select LID_SWITCH config DRIVERS_I2C_GENERIC diff --git a/src/mainboard/google/chell/chromeos.c b/src/mainboard/google/chell/chromeos.c index 3ca1872f04c0..fdd148611e3c 100644 --- a/src/mainboard/google/chell/chromeos.c +++ b/src/mainboard/google/chell/chromeos.c @@ -14,19 +14,13 @@ * GNU General Public License for more details. */ -#include <arch/io.h> -#include <console/console.h> -#include <device/device.h> -#include <device/pci.h> #include <rules.h> #include <gpio.h> #include <soc/gpio.h> #include <string.h> -#include <ec/google/chromeec/ec.h> #include <vendorcode/google/chromeos/chromeos.h> #include "gpio.h" -#include "ec.h" #if ENV_RAMSTAGE #include <boot/coreboot_tables.h> @@ -47,36 +41,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif /* ENV_RAMSTAGE */ -int get_lid_switch(void) -{ - /* Read lid switch state from the EC. */ - return !!(google_chromeec_get_switches() & EC_SWITCH_LID_OPEN); -} - -int get_developer_mode_switch(void) -{ - /* No physical developer mode switch. */ - return 0; -} - -int get_recovery_mode_switch(void) -{ - /* Check for dedicated recovery switch first. */ - if (google_chromeec_get_switches() & EC_SWITCH_DEDICATED_RECOVERY) - return 1; - - /* Otherwise check if the EC has posted the keyboard recovery event. */ - return !!(google_chromeec_get_events_b() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - -int clear_recovery_mode_switch(void) -{ - /* Clear keyboard recovery event. */ - return google_chromeec_clear_events_b( - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - int get_write_protect_state(void) { /* Read PCH_WP GPIO. */ diff --git a/src/mainboard/google/cyan/Kconfig b/src/mainboard/google/cyan/Kconfig index 782a460e4b1f..d236aa0a593b 100644 --- a/src/mainboard/google/cyan/Kconfig +++ b/src/mainboard/google/cyan/Kconfig @@ -16,6 +16,7 @@ config BOARD_SPECIFIC_OPTIONS select PCIEXP_L1_SUB_STATE config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select LID_SWITCH select VBOOT_DYNAMIC_WORK_BUFFER diff --git a/src/mainboard/google/cyan/chromeos.c b/src/mainboard/google/cyan/chromeos.c index f606d09c7dab..672bc9708da3 100644 --- a/src/mainboard/google/cyan/chromeos.c +++ b/src/mainboard/google/cyan/chromeos.c @@ -15,12 +15,6 @@ */ #include <arch/io.h> -#include <device/device.h> -#include <device/pci.h> -#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC) -#include "ec.h" -#include <ec/google/chromeec/ec.h> -#endif #include <rules.h> #include <soc/gpio.h> #include <string.h> @@ -50,60 +44,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif /* ENV_RAMSTAGE */ -int get_lid_switch(void) -{ -#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC) - u8 ec_switches; - - mec_io_bytes(0, EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES, 1, - &ec_switches, NULL); - return !!(ec_switches & EC_SWITCH_LID_OPEN); -#else - /* Default to force open. */ - return 1; -#endif -} - -int get_developer_mode_switch(void) -{ - return 0; -} - -int get_recovery_mode_switch(void) -{ -#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC) - u8 ec_switches; - u32 ec_events; - - mec_io_bytes(0, EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES, 1, - &ec_switches, NULL); - - /* If a switch is set, we don't need to look at events. */ - if (ec_switches & (EC_SWITCH_DEDICATED_RECOVERY)) - return 1; - - /* Else check if the EC has posted the keyboard recovery event. */ - ec_events = google_chromeec_get_events_b(); - - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -#else - return 0; -#endif -} - -int clear_recovery_mode_switch(void) -{ -#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC) - const uint32_t kb_rec_mask = - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY); - /* Unconditionally clear the EC recovery request. */ - return google_chromeec_clear_events_b(kb_rec_mask); -#else - return 0; -#endif -} - int get_write_protect_state(void) { /* diff --git a/src/mainboard/google/enguarde/Kconfig b/src/mainboard/google/enguarde/Kconfig index ec528a69a090..c2842bb334ff 100644 --- a/src/mainboard/google/enguarde/Kconfig +++ b/src/mainboard/google/enguarde/Kconfig @@ -15,6 +15,7 @@ config BOARD_SPECIFIC_OPTIONS config CHROMEOS select VBOOT_VBNV_CMOS select LID_SWITCH + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select VIRTUAL_DEV_SWITCH diff --git a/src/mainboard/google/enguarde/chromeos.c b/src/mainboard/google/enguarde/chromeos.c index e4f2d28689c3..68fb0a7bc7e4 100644 --- a/src/mainboard/google/enguarde/chromeos.c +++ b/src/mainboard/google/enguarde/chromeos.c @@ -15,17 +15,9 @@ #include <string.h> #include <bootmode.h> -#include <arch/io.h> -#include <device/device.h> -#include <device/pci.h> #include <soc/gpio.h> #include <vendorcode/google/chromeos/chromeos.h> -#if CONFIG_EC_GOOGLE_CHROMEEC -#include "ec.h" -#include <ec/google/chromeec/ec.h> -#endif - /* The WP status pin lives on GPIO_SSUS_6 which is pad 36 in the SUS well. */ #define WP_STATUS_PAD 36 @@ -46,55 +38,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif -int get_lid_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - - return !!(ec_switches & EC_SWITCH_LID_OPEN); -#else - /* Default to force open. */ - return 1; -#endif -} - -int get_developer_mode_switch(void) -{ - return 0; -} - -int get_recovery_mode_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - u32 ec_events; - - /* If a switch is set, we don't need to look at events. */ - if (ec_switches & (EC_SWITCH_DEDICATED_RECOVERY)) - return 1; - - /* Else check if the EC has posted the keyboard recovery event. */ - ec_events = google_chromeec_get_events_b(); - - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -#else - return 0; -#endif -} - -int clear_recovery_mode_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - const uint32_t kb_rec_mask = - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY); - /* Unconditionally clear the EC recovery request. */ - return google_chromeec_clear_events_b(kb_rec_mask); -#else - return 0; -#endif -} - int get_write_protect_state(void) { /* diff --git a/src/mainboard/google/eve/Kconfig b/src/mainboard/google/eve/Kconfig index c21d22abf34a..0e1bc52ccab9 100644 --- a/src/mainboard/google/eve/Kconfig +++ b/src/mainboard/google/eve/Kconfig @@ -18,6 +18,7 @@ config BOARD_SPECIFIC_OPTIONS select TPM2 config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select LID_SWITCH config DRIVERS_I2C_GENERIC diff --git a/src/mainboard/google/eve/chromeos.c b/src/mainboard/google/eve/chromeos.c index 63615b3a3e75..de83eaa637d5 100644 --- a/src/mainboard/google/eve/chromeos.c +++ b/src/mainboard/google/eve/chromeos.c @@ -14,15 +14,12 @@ * GNU General Public License for more details. */ -#include <arch/io.h> #include <rules.h> #include <gpio.h> #include <soc/gpio.h> -#include <ec/google/chromeec/ec.h> #include <vendorcode/google/chromeos/chromeos.h> #include "gpio.h" -#include "ec.h" #if ENV_RAMSTAGE #include <boot/coreboot_tables.h> @@ -43,32 +40,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif /* ENV_RAMSTAGE */ -int get_lid_switch(void) -{ - /* Read lid switch state from the EC. */ - return !!(google_chromeec_get_switches() & EC_SWITCH_LID_OPEN); -} - -int get_developer_mode_switch(void) -{ - /* No physical developer mode switch. */ - return 0; -} - -int get_recovery_mode_switch(void) -{ - /* Check if the EC has posted the keyboard recovery event. */ - return !!(google_chromeec_get_events_b() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - -int clear_recovery_mode_switch(void) -{ - /* Clear keyboard recovery event. */ - return google_chromeec_clear_events_b( - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - int get_write_protect_state(void) { /* Read PCH_WP GPIO. */ diff --git a/src/mainboard/google/falco/Kconfig b/src/mainboard/google/falco/Kconfig index d0b911a5128b..182a76464474 100644 --- a/src/mainboard/google/falco/Kconfig +++ b/src/mainboard/google/falco/Kconfig @@ -21,6 +21,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select INTEL_INT15 config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select LID_SWITCH select VBOOT_VBNV_CMOS diff --git a/src/mainboard/google/falco/chromeos.c b/src/mainboard/google/falco/chromeos.c index a8cef3279b41..22ec0742e2ce 100644 --- a/src/mainboard/google/falco/chromeos.c +++ b/src/mainboard/google/falco/chromeos.c @@ -15,18 +15,10 @@ #include <string.h> #include <bootmode.h> -#include <arch/io.h> -#include <device/device.h> -#include <device/pci.h> #include <southbridge/intel/lynxpoint/pch.h> #include <southbridge/intel/common/gpio.h> #include <vendorcode/google/chromeos/chromeos.h> -#if CONFIG_EC_GOOGLE_CHROMEEC -#include "ec.h" -#include <ec/google/chromeec/ec.h> -#endif - #ifndef __PRE_RAM__ #include <boot/coreboot_tables.h> @@ -44,45 +36,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif -int get_lid_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - - return !!(ec_switches & EC_SWITCH_LID_OPEN); -#else - return 0; -#endif -} - -/* The dev-switch is virtual */ -int get_developer_mode_switch(void) -{ - return 0; -} - -/* There are actually two recovery switches. One is the magic keyboard chord, - * the other is driven by Servo. */ -int get_recovery_mode_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - u32 ec_events; - - /* If a switch is set, we don't need to look at events. */ - if (ec_switches & (EC_SWITCH_DEDICATED_RECOVERY)) - return 1; - - /* Else check if the EC has posted the keyboard recovery event. */ - ec_events = google_chromeec_get_events_b(); - - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -#else - return 0; -#endif -} - int get_write_protect_state(void) { return get_gpio(58); diff --git a/src/mainboard/google/glados/Kconfig b/src/mainboard/google/glados/Kconfig index e70094fb8b77..a315b1cf246e 100644 --- a/src/mainboard/google/glados/Kconfig +++ b/src/mainboard/google/glados/Kconfig @@ -20,6 +20,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select SOC_INTEL_SKYLAKE config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select LID_SWITCH config DRIVERS_I2C_GENERIC diff --git a/src/mainboard/google/glados/chromeos.c b/src/mainboard/google/glados/chromeos.c index 3ca1872f04c0..9ee6e6f564ce 100644 --- a/src/mainboard/google/glados/chromeos.c +++ b/src/mainboard/google/glados/chromeos.c @@ -14,19 +14,14 @@ * GNU General Public License for more details. */ -#include <arch/io.h> -#include <console/console.h> -#include <device/device.h> -#include <device/pci.h> +#include <bootmode.h> #include <rules.h> #include <gpio.h> #include <soc/gpio.h> #include <string.h> -#include <ec/google/chromeec/ec.h> #include <vendorcode/google/chromeos/chromeos.h> #include "gpio.h" -#include "ec.h" #if ENV_RAMSTAGE #include <boot/coreboot_tables.h> @@ -47,36 +42,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif /* ENV_RAMSTAGE */ -int get_lid_switch(void) -{ - /* Read lid switch state from the EC. */ - return !!(google_chromeec_get_switches() & EC_SWITCH_LID_OPEN); -} - -int get_developer_mode_switch(void) -{ - /* No physical developer mode switch. */ - return 0; -} - -int get_recovery_mode_switch(void) -{ - /* Check for dedicated recovery switch first. */ - if (google_chromeec_get_switches() & EC_SWITCH_DEDICATED_RECOVERY) - return 1; - - /* Otherwise check if the EC has posted the keyboard recovery event. */ - return !!(google_chromeec_get_events_b() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - -int clear_recovery_mode_switch(void) -{ - /* Clear keyboard recovery event. */ - return google_chromeec_clear_events_b( - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - int get_write_protect_state(void) { /* Read PCH_WP GPIO. */ diff --git a/src/mainboard/google/gru/Kconfig b/src/mainboard/google/gru/Kconfig index 41e8105595a0..57b1762578cb 100644 --- a/src/mainboard/google/gru/Kconfig +++ b/src/mainboard/google/gru/Kconfig @@ -46,6 +46,7 @@ config BOARD_SPECIFIC_OPTIONS select SPI_FLASH_WINBOND config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select SPI_TPM if GRU_HAS_TPM2 select VBOOT_VBNV_FLASH diff --git a/src/mainboard/google/gru/chromeos.c b/src/mainboard/google/gru/chromeos.c index cc2b3b660483..d9e5e28f0045 100644 --- a/src/mainboard/google/gru/chromeos.c +++ b/src/mainboard/google/gru/chromeos.c @@ -14,11 +14,9 @@ * */ +#include <bootmode.h> #include <boot/coreboot_tables.h> -#include <ec/google/chromeec/ec.h> -#include <ec/google/chromeec/ec_commands.h> #include <gpio.h> -#include <vendorcode/google/chromeos/chromeos.h> #include "board.h" @@ -42,20 +40,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } -int get_developer_mode_switch(void) -{ - return 0; -} - -int get_recovery_mode_switch(void) -{ - uint32_t ec_events; - - ec_events = google_chromeec_get_events_b(); - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - void setup_chromeos_gpios(void) { gpio_input_pullup(GPIO_WP); diff --git a/src/mainboard/google/lars/Kconfig b/src/mainboard/google/lars/Kconfig index 2a4973eb45ca..49dcf1be4a96 100644 --- a/src/mainboard/google/lars/Kconfig +++ b/src/mainboard/google/lars/Kconfig @@ -21,6 +21,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select SOC_INTEL_SKYLAKE config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select LID_SWITCH config DRIVERS_GENERIC_MAX98357A diff --git a/src/mainboard/google/lars/chromeos.c b/src/mainboard/google/lars/chromeos.c index daa85c69e065..42763a7d3407 100644 --- a/src/mainboard/google/lars/chromeos.c +++ b/src/mainboard/google/lars/chromeos.c @@ -14,19 +14,13 @@ * GNU General Public License for more details. */ -#include <arch/io.h> -#include <console/console.h> -#include <device/device.h> -#include <device/pci.h> #include <rules.h> #include <gpio.h> #include <soc/gpio.h> #include <string.h> -#include <ec/google/chromeec/ec.h> #include <vendorcode/google/chromeos/chromeos.h> #include "gpio.h" -#include "ec.h" #if ENV_RAMSTAGE #include <boot/coreboot_tables.h> @@ -47,36 +41,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif /* ENV_RAMSTAGE */ -int get_lid_switch(void) -{ - /* Read lid switch state from the EC. */ - return !!(google_chromeec_get_switches() & EC_SWITCH_LID_OPEN); -} - -int get_developer_mode_switch(void) -{ - /* No physical developer mode switch. */ - return 0; -} - -int get_recovery_mode_switch(void) -{ - /* Check for dedicated recovery switch first. */ - if (google_chromeec_get_switches() & EC_SWITCH_DEDICATED_RECOVERY) - return 1; - - /* Otherwise check if the EC has posted the keyboard recovery event. */ - return !!(google_chromeec_get_events_b() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - -int clear_recovery_mode_switch(void) -{ - /* Clear keyboard recovery event. */ - return google_chromeec_clear_events_b( - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - int get_write_protect_state(void) { /* Read PCH_WP GPIO. */ diff --git a/src/mainboard/google/link/Kconfig b/src/mainboard/google/link/Kconfig index d1e114077346..b521f9c238ac 100644 --- a/src/mainboard/google/link/Kconfig +++ b/src/mainboard/google/link/Kconfig @@ -17,6 +17,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select MAINBOARD_HAS_NATIVE_VGA_INIT config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select LID_SWITCH select VBOOT_VBNV_CMOS diff --git a/src/mainboard/google/link/chromeos.c b/src/mainboard/google/link/chromeos.c index 4be31d9fa472..0469d65c7cf7 100644 --- a/src/mainboard/google/link/chromeos.c +++ b/src/mainboard/google/link/chromeos.c @@ -15,13 +15,8 @@ #include <string.h> #include <bootmode.h> -#include <arch/io.h> -#include <device/device.h> -#include <device/pci.h> #include <southbridge/intel/bd82x6x/pch.h> #include <southbridge/intel/common/gpio.h> -#include "ec.h" -#include <ec/google/chromeec/ec.h> #include <vendorcode/google/chromeos/chromeos.h> #ifndef __PRE_RAM__ @@ -78,37 +73,6 @@ int get_write_protect_state(void) return get_gpio(57); } -int get_lid_switch(void) -{ - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - - return !!(ec_switches & EC_SWITCH_LID_OPEN); -} - -/* The dev-switch is virtual on Link (and so handled elsewhere). */ -int get_developer_mode_switch(void) -{ - return 0; -} - -/* There are actually two recovery switches. One is the magic keyboard chord, - * the other is driven by Servo. */ -int get_recovery_mode_switch(void) -{ - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - u32 ec_events; - - /* If a switch is set, we don't need to look at events. */ - if (ec_switches & (EC_SWITCH_DEDICATED_RECOVERY)) - return 1; - - /* Else check if the EC has posted the keyboard recovery event. */ - ec_events = google_chromeec_get_events_b(); - - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - static const struct cros_gpio cros_gpios[] = { CROS_GPIO_REC_AL(9, CROS_GPIO_DEVICE_NAME), CROS_GPIO_WP_AH(57, CROS_GPIO_DEVICE_NAME), diff --git a/src/mainboard/google/ninja/Kconfig b/src/mainboard/google/ninja/Kconfig index ce32d3dac813..4c28e1a23b35 100644 --- a/src/mainboard/google/ninja/Kconfig +++ b/src/mainboard/google/ninja/Kconfig @@ -14,6 +14,7 @@ config BOARD_SPECIFIC_OPTIONS select MAINBOARD_HAS_LPC_TPM config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select LID_SWITCH select VBOOT_VBNV_CMOS diff --git a/src/mainboard/google/ninja/chromeos.c b/src/mainboard/google/ninja/chromeos.c index 1213266d3fdb..fa4c66f98f7e 100644 --- a/src/mainboard/google/ninja/chromeos.c +++ b/src/mainboard/google/ninja/chromeos.c @@ -15,16 +15,8 @@ #include <string.h> #include <vendorcode/google/chromeos/chromeos.h> -#include <arch/io.h> -#include <device/device.h> -#include <device/pci.h> #include <soc/gpio.h> -#if CONFIG_EC_GOOGLE_CHROMEEC -#include "ec.h" -#include <ec/google/chromeec/ec.h> -#endif - /* The WP status pin lives on GPIO_SSUS_6 which is pad 36 in the SUS well. */ #define WP_STATUS_PAD 36 @@ -34,18 +26,6 @@ #define ACTIVE_LOW 0 #define ACTIVE_HIGH 1 -int get_lid_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - - return !!(ec_switches & EC_SWITCH_LID_OPEN); -#else - /* Default to force open. */ - return 1; -#endif -} - void fill_lb_gpios(struct lb_gpios *gpios) { struct lb_gpio chromeos_gpios[] = { @@ -60,31 +40,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif -int get_developer_mode_switch(void) -{ - return 0; -} - -int get_recovery_mode_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - u32 ec_events; - - /* If a switch is set, we don't need to look at events. */ - if (ec_switches & (EC_SWITCH_DEDICATED_RECOVERY)) - return 1; - - /* Else check if the EC has posted the keyboard recovery event. */ - ec_events = google_chromeec_get_events_b(); - - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -#else - return 0; -#endif -} - int get_write_protect_state(void) { /* diff --git a/src/mainboard/google/nyan/Kconfig b/src/mainboard/google/nyan/Kconfig index 9b25d5c9b254..515d16bd78a2 100644 --- a/src/mainboard/google/nyan/Kconfig +++ b/src/mainboard/google/nyan/Kconfig @@ -32,6 +32,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select SPI_FLASH_FAST_READ_DUAL_OUTPUT_3B config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select VBOOT_VBNV_EC select VIRTUAL_DEV_SWITCH diff --git a/src/mainboard/google/nyan/chromeos.c b/src/mainboard/google/nyan/chromeos.c index 9d5d6b248e3a..aa7c9c69f63d 100644 --- a/src/mainboard/google/nyan/chromeos.c +++ b/src/mainboard/google/nyan/chromeos.c @@ -15,12 +15,8 @@ #include <boot/coreboot_tables.h> #include <bootmode.h> -#include <console/console.h> -#include <ec/google/chromeec/ec.h> -#include <ec/google/chromeec/ec_commands.h> #include <gpio.h> #include <string.h> -#include <vendorcode/google/chromeos/chromeos.h> void fill_lb_gpios(struct lb_gpios *gpios) { @@ -36,20 +32,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } -int get_developer_mode_switch(void) -{ - return 0; -} - -int get_recovery_mode_switch(void) -{ - uint32_t ec_events; - - ec_events = google_chromeec_get_events_b(); - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - int get_write_protect_state(void) { return !gpio_get(GPIO(R1)); diff --git a/src/mainboard/google/nyan_big/Kconfig b/src/mainboard/google/nyan_big/Kconfig index bcf8f5d61969..c8411bf43537 100644 --- a/src/mainboard/google/nyan_big/Kconfig +++ b/src/mainboard/google/nyan_big/Kconfig @@ -33,6 +33,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select SPI_FLASH_FAST_READ_DUAL_OUTPUT_3B config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select VBOOT_VBNV_EC select VIRTUAL_DEV_SWITCH diff --git a/src/mainboard/google/nyan_big/chromeos.c b/src/mainboard/google/nyan_big/chromeos.c index e9df4e3bda00..2c9ba28e5fee 100644 --- a/src/mainboard/google/nyan_big/chromeos.c +++ b/src/mainboard/google/nyan_big/chromeos.c @@ -15,12 +15,8 @@ #include <boot/coreboot_tables.h> #include <bootmode.h> -#include <console/console.h> -#include <ec/google/chromeec/ec.h> -#include <ec/google/chromeec/ec_commands.h> #include <gpio.h> #include <string.h> -#include <vendorcode/google/chromeos/chromeos.h> void fill_lb_gpios(struct lb_gpios *gpios) { @@ -36,20 +32,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } -int get_developer_mode_switch(void) -{ - return 0; -} - -int get_recovery_mode_switch(void) -{ - uint32_t ec_events; - - ec_events = google_chromeec_get_events_b(); - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - int get_write_protect_state(void) { return !gpio_get(GPIO(R1)); diff --git a/src/mainboard/google/nyan_blaze/Kconfig b/src/mainboard/google/nyan_blaze/Kconfig index 0782cc0fd671..530397c4258a 100644 --- a/src/mainboard/google/nyan_blaze/Kconfig +++ b/src/mainboard/google/nyan_blaze/Kconfig @@ -34,6 +34,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select SPI_FLASH_FAST_READ_DUAL_OUTPUT_3B config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select VBOOT_VBNV_EC select VIRTUAL_DEV_SWITCH diff --git a/src/mainboard/google/nyan_blaze/chromeos.c b/src/mainboard/google/nyan_blaze/chromeos.c index eddf15005be1..2c9ba28e5fee 100644 --- a/src/mainboard/google/nyan_blaze/chromeos.c +++ b/src/mainboard/google/nyan_blaze/chromeos.c @@ -14,17 +14,9 @@ */ #include <boot/coreboot_tables.h> -#include <console/console.h> -#include <ec/google/chromeec/ec.h> -#include <ec/google/chromeec/ec_commands.h> +#include <bootmode.h> #include <gpio.h> #include <string.h> -#include <vendorcode/google/chromeos/chromeos.h> - -//enum { -// ACTIVE_LOW = 0, -// ACTIVE_HIGH = 1 -//}; void fill_lb_gpios(struct lb_gpios *gpios) { @@ -40,20 +32,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } -int get_developer_mode_switch(void) -{ - return 0; -} - -int get_recovery_mode_switch(void) -{ - uint32_t ec_events; - - ec_events = google_chromeec_get_events_b(); - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - int get_write_protect_state(void) { return !gpio_get(GPIO(R1)); diff --git a/src/mainboard/google/oak/Kconfig b/src/mainboard/google/oak/Kconfig index acb27de55ff9..01bd0bcffb54 100644 --- a/src/mainboard/google/oak/Kconfig +++ b/src/mainboard/google/oak/Kconfig @@ -34,6 +34,7 @@ config BOARD_SPECIFIC_OPTIONS select SPI_FLASH config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select VBOOT_EC_SLOW_UPDATE select VBOOT_OPROM_MATTERS diff --git a/src/mainboard/google/oak/chromeos.c b/src/mainboard/google/oak/chromeos.c index 0265c7a3c46c..60c24e76ae87 100644 --- a/src/mainboard/google/oak/chromeos.c +++ b/src/mainboard/google/oak/chromeos.c @@ -14,13 +14,10 @@ */ #include <boardid.h> +#include <bootmode.h> #include <boot/coreboot_tables.h> -#include <console/console.h> -#include <ec/google/chromeec/ec.h> -#include <ec/google/chromeec/ec_commands.h> #include <gpio.h> #include <string.h> -#include <vendorcode/google/chromeos/chromeos.h> #include "gpio.h" @@ -50,20 +47,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } -int get_developer_mode_switch(void) -{ - return 0; -} - -int get_recovery_mode_switch(void) -{ - uint32_t ec_events; - - ec_events = google_chromeec_get_events_b(); - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - int get_write_protect_state(void) { return !gpio_get(WRITE_PROTECT); diff --git a/src/mainboard/google/peppy/Kconfig b/src/mainboard/google/peppy/Kconfig index 8829371bcd4b..b35cc58d1985 100644 --- a/src/mainboard/google/peppy/Kconfig +++ b/src/mainboard/google/peppy/Kconfig @@ -22,6 +22,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select INTEL_INT15 config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select LID_SWITCH select MAINBOARD_DO_NATIVE_VGA_INIT diff --git a/src/mainboard/google/peppy/chromeos.c b/src/mainboard/google/peppy/chromeos.c index a8cef3279b41..22ec0742e2ce 100644 --- a/src/mainboard/google/peppy/chromeos.c +++ b/src/mainboard/google/peppy/chromeos.c @@ -15,18 +15,10 @@ #include <string.h> #include <bootmode.h> -#include <arch/io.h> -#include <device/device.h> -#include <device/pci.h> #include <southbridge/intel/lynxpoint/pch.h> #include <southbridge/intel/common/gpio.h> #include <vendorcode/google/chromeos/chromeos.h> -#if CONFIG_EC_GOOGLE_CHROMEEC -#include "ec.h" -#include <ec/google/chromeec/ec.h> -#endif - #ifndef __PRE_RAM__ #include <boot/coreboot_tables.h> @@ -44,45 +36,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif -int get_lid_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - - return !!(ec_switches & EC_SWITCH_LID_OPEN); -#else - return 0; -#endif -} - -/* The dev-switch is virtual */ -int get_developer_mode_switch(void) -{ - return 0; -} - -/* There are actually two recovery switches. One is the magic keyboard chord, - * the other is driven by Servo. */ -int get_recovery_mode_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - u32 ec_events; - - /* If a switch is set, we don't need to look at events. */ - if (ec_switches & (EC_SWITCH_DEDICATED_RECOVERY)) - return 1; - - /* Else check if the EC has posted the keyboard recovery event. */ - ec_events = google_chromeec_get_events_b(); - - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -#else - return 0; -#endif -} - int get_write_protect_state(void) { return get_gpio(58); diff --git a/src/mainboard/google/rambi/Kconfig b/src/mainboard/google/rambi/Kconfig index 48af3b396fd6..94354c9c92de 100644 --- a/src/mainboard/google/rambi/Kconfig +++ b/src/mainboard/google/rambi/Kconfig @@ -13,6 +13,7 @@ config BOARD_SPECIFIC_OPTIONS select MAINBOARD_HAS_LPC_TPM config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select LID_SWITCH select VBOOT_VBNV_CMOS diff --git a/src/mainboard/google/rambi/chromeos.c b/src/mainboard/google/rambi/chromeos.c index 4304179d4b8e..10e076209d78 100644 --- a/src/mainboard/google/rambi/chromeos.c +++ b/src/mainboard/google/rambi/chromeos.c @@ -14,19 +14,10 @@ */ #include <string.h> -#include <arch/io.h> #include <bootmode.h> -#include <device/device.h> -#include <device/pci.h> #include <soc/gpio.h> -#include <vboot/vboot_common.h> #include <vendorcode/google/chromeos/chromeos.h> -#if CONFIG_EC_GOOGLE_CHROMEEC -#include "ec.h" -#include <ec/google/chromeec/ec.h> -#endif - /* The WP status pin lives on GPIO_SSUS_6 which is pad 36 in the SUS well. */ #define WP_STATUS_PAD 36 @@ -47,55 +38,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif -int get_lid_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - - return !!(ec_switches & EC_SWITCH_LID_OPEN); -#else - /* Default to force open. */ - return 1; -#endif -} - -int get_developer_mode_switch(void) -{ - return 0; -} - -int get_recovery_mode_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - u32 ec_events; - - /* If a switch is set, we don't need to look at events. */ - if (ec_switches & (EC_SWITCH_DEDICATED_RECOVERY)) - return 1; - - /* Else check if the EC has posted the keyboard recovery event. */ - ec_events = google_chromeec_get_events_b(); - - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -#else - return 0; -#endif -} - -int clear_recovery_mode_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - const uint32_t kb_rec_mask = - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY); - /* Unconditionally clear the EC recovery request. */ - return google_chromeec_clear_events_b(kb_rec_mask); -#else - return 0; -#endif -} - int get_write_protect_state(void) { /* diff --git a/src/mainboard/google/reef/Kconfig b/src/mainboard/google/reef/Kconfig index 4d76f3838b33..2cc391eecadf 100644 --- a/src/mainboard/google/reef/Kconfig +++ b/src/mainboard/google/reef/Kconfig @@ -33,8 +33,9 @@ config DRIVER_TPM_I2C_IRQ default 60 # GPE0_DW1_28 config CHROMEOS - select LID_SWITCH if BASEBOARD_REEF_LAPTOP + select EC_GOOGLE_CHROMEEC_SWITCHES select HAS_RECOVERY_MRC_CACHE + select LID_SWITCH if BASEBOARD_REEF_LAPTOP config DRIVERS_I2C_DA7219 default y diff --git a/src/mainboard/google/reef/chromeos.c b/src/mainboard/google/reef/chromeos.c index 506f9de94ba7..256db1654866 100644 --- a/src/mainboard/google/reef/chromeos.c +++ b/src/mainboard/google/reef/chromeos.c @@ -15,7 +15,6 @@ #include <baseboard/variants.h> #include <boot/coreboot_tables.h> -#include <ec/google/chromeec/ec.h> #include <gpio.h> #include <vendorcode/google/chromeos/chromeos.h> #include <soc/gpio.h> @@ -36,43 +35,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } -int get_lid_switch(void) -{ - /* Read lid switch state from the EC. */ - return !!(google_chromeec_get_switches() & EC_SWITCH_LID_OPEN); -} - -int get_developer_mode_switch(void) -{ - /* No physical developer mode switch. It's virtual. */ - return 0; -} - -int get_recovery_mode_switch(void) -{ - /* Check if the EC has posted the keyboard recovery event. */ - return !!(google_chromeec_get_events_b() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - -int get_recovery_mode_retrain_switch(void) -{ - /* - * Check if the EC has posted the keyboard recovery event with memory - * retrain. - */ - return !!(google_chromeec_get_events_b() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT)); -} - -int clear_recovery_mode_switch(void) -{ - /* Clear all host event bits requesting recovery mode. */ - return google_chromeec_clear_events_b( - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY) | - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT)); -} - int get_write_protect_state(void) { /* Read PCH_WP GPIO. */ diff --git a/src/mainboard/google/samus/Kconfig b/src/mainboard/google/samus/Kconfig index 0275189f51da..46fc7a3f4348 100644 --- a/src/mainboard/google/samus/Kconfig +++ b/src/mainboard/google/samus/Kconfig @@ -17,6 +17,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy config CHROMEOS select CHROMEOS_RAMOOPS_DYNAMIC + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select LID_SWITCH select VBOOT_EC_SLOW_UPDATE diff --git a/src/mainboard/google/samus/chromeos.c b/src/mainboard/google/samus/chromeos.c index 7010ac9b6da8..ea099f55b45b 100644 --- a/src/mainboard/google/samus/chromeos.c +++ b/src/mainboard/google/samus/chromeos.c @@ -15,16 +15,9 @@ #include <string.h> #include <bootmode.h> -#include <arch/io.h> -#include <device/device.h> -#include <device/pci.h> -#include <console/console.h> #include <vendorcode/google/chromeos/chromeos.h> -#include <ec/google/chromeec/ec.h> -#include <ec/google/chromeec/ec_commands.h> #include <soc/gpio.h> - /* SPI Write protect is GPIO 16 */ #define CROS_WP_GPIO 16 @@ -45,50 +38,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif -int get_lid_switch(void) -{ - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - - return !!(ec_switches & EC_SWITCH_LID_OPEN); -} - -/* The dev-switch is virtual */ -int get_developer_mode_switch(void) -{ - return 0; -} - -/* There are actually two recovery switches. One is the magic keyboard chord, - * the other is driven by Servo. */ -int get_recovery_mode_switch(void) -{ -#if CONFIG_EC_GOOGLE_CHROMEEC - u8 ec_switches = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES); - u32 ec_events; - - /* If a switch is set, we don't need to look at events. */ - if (ec_switches & (EC_SWITCH_DEDICATED_RECOVERY)) - return 1; - - /* Else check if the EC has posted the keyboard recovery event. */ - ec_events = google_chromeec_get_events_b(); - - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -#else - return 0; -#endif -} - -int clear_recovery_mode_switch(void) -{ - const uint32_t kb_rec_mask = - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY); - - /* Unconditionally clear the EC recovery request. */ - return google_chromeec_clear_events_b(kb_rec_mask); -} - int get_write_protect_state(void) { return get_gpio(CROS_WP_GPIO); diff --git a/src/mainboard/google/smaug/Kconfig b/src/mainboard/google/smaug/Kconfig index 665545325b60..ba6252b8301e 100644 --- a/src/mainboard/google/smaug/Kconfig +++ b/src/mainboard/google/smaug/Kconfig @@ -33,6 +33,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select RAM_CODE_SUPPORT config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select VBOOT_VBNV_FLASH select VIRTUAL_DEV_SWITCH diff --git a/src/mainboard/google/smaug/chromeos.c b/src/mainboard/google/smaug/chromeos.c index 8688937fd698..0372584ae048 100644 --- a/src/mainboard/google/smaug/chromeos.c +++ b/src/mainboard/google/smaug/chromeos.c @@ -13,13 +13,9 @@ * GNU General Public License for more details. */ -#include <boardid.h> +#include <bootmode.h> #include <boot/coreboot_tables.h> -#include <console/console.h> -#include <ec/google/chromeec/ec.h> -#include <ec/google/chromeec/ec_commands.h> #include <string.h> -#include <vendorcode/google/chromeos/chromeos.h> #include "gpio.h" @@ -37,24 +33,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); } -int get_developer_mode_switch(void) -{ - return 0; -} - -int get_recovery_mode_switch(void) -{ - uint32_t ec_events; - - ec_events = google_chromeec_get_events_b(); - - /* Enter recovery mode either on keyboard recovery / fastboot event. */ - return !!((ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)) || - (ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_FASTBOOT))); -} - int get_write_protect_state(void) { return !gpio_get(WRITE_PROTECT_L); diff --git a/src/mainboard/intel/kunimitsu/Kconfig b/src/mainboard/intel/kunimitsu/Kconfig index 9bc607e3dad2..6848c111088b 100644 --- a/src/mainboard/intel/kunimitsu/Kconfig +++ b/src/mainboard/intel/kunimitsu/Kconfig @@ -33,6 +33,7 @@ config KUNIMITSU_USES_FSP2_0 endchoice config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select LID_SWITCH config DRIVERS_GENERIC_MAX98357A diff --git a/src/mainboard/intel/kunimitsu/chromeos.c b/src/mainboard/intel/kunimitsu/chromeos.c index daa85c69e065..42763a7d3407 100644 --- a/src/mainboard/intel/kunimitsu/chromeos.c +++ b/src/mainboard/intel/kunimitsu/chromeos.c @@ -14,19 +14,13 @@ * GNU General Public License for more details. */ -#include <arch/io.h> -#include <console/console.h> -#include <device/device.h> -#include <device/pci.h> #include <rules.h> #include <gpio.h> #include <soc/gpio.h> #include <string.h> -#include <ec/google/chromeec/ec.h> #include <vendorcode/google/chromeos/chromeos.h> #include "gpio.h" -#include "ec.h" #if ENV_RAMSTAGE #include <boot/coreboot_tables.h> @@ -47,36 +41,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif /* ENV_RAMSTAGE */ -int get_lid_switch(void) -{ - /* Read lid switch state from the EC. */ - return !!(google_chromeec_get_switches() & EC_SWITCH_LID_OPEN); -} - -int get_developer_mode_switch(void) -{ - /* No physical developer mode switch. */ - return 0; -} - -int get_recovery_mode_switch(void) -{ - /* Check for dedicated recovery switch first. */ - if (google_chromeec_get_switches() & EC_SWITCH_DEDICATED_RECOVERY) - return 1; - - /* Otherwise check if the EC has posted the keyboard recovery event. */ - return !!(google_chromeec_get_events_b() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - -int clear_recovery_mode_switch(void) -{ - /* Clear keyboard recovery event. */ - return google_chromeec_clear_events_b( - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -} - int get_write_protect_state(void) { /* Read PCH_WP GPIO. */ diff --git a/src/mainboard/intel/strago/Kconfig b/src/mainboard/intel/strago/Kconfig index 42118f93e699..0d59371d43fb 100644 --- a/src/mainboard/intel/strago/Kconfig +++ b/src/mainboard/intel/strago/Kconfig @@ -16,6 +16,7 @@ config BOARD_SPECIFIC_OPTIONS select PCIEXP_L1_SUB_STATE config CHROMEOS + select EC_GOOGLE_CHROMEEC_SWITCHES select EC_SOFTWARE_SYNC select LID_SWITCH select VBOOT_DYNAMIC_WORK_BUFFER diff --git a/src/mainboard/intel/strago/chromeos.c b/src/mainboard/intel/strago/chromeos.c index 0fb98111a86e..6d00d72dee7c 100644 --- a/src/mainboard/intel/strago/chromeos.c +++ b/src/mainboard/intel/strago/chromeos.c @@ -14,14 +14,6 @@ * GNU General Public License for more details. */ -#include <arch/io.h> -#include <device/device.h> -#include <device/pci.h> - -#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC) -#include "ec.h" -#include <ec/google/chromeec/ec.h> -#endif #include <rules.h> #include <gpio.h> #include <string.h> @@ -49,60 +41,6 @@ void fill_lb_gpios(struct lb_gpios *gpios) } #endif /* ENV_RAMSTAGE */ -int get_lid_switch(void) -{ -#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC) - u8 ec_switches; - - mec_io_bytes(0, EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES, 1, - &ec_switches, NULL); - - return !!(ec_switches & EC_SWITCH_LID_OPEN); -#else - /* Default to force open. */ - return 1; -#endif -} - -int get_developer_mode_switch(void) -{ - return 0; -} - -int get_recovery_mode_switch(void) -{ -#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC) - u8 ec_switches; - u32 ec_events; - mec_io_bytes(0, EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SWITCHES, 1, - &ec_switches, NULL); - - /* If a switch is set, we don't need to look at events. */ - if (ec_switches & (EC_SWITCH_DEDICATED_RECOVERY)) - return 1; - - /* Else check if the EC has posted the keyboard recovery event. */ - ec_events = google_chromeec_get_events_b(); - - return !!(ec_events & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); -#else - return 0; -#endif -} - -int clear_recovery_mode_switch(void) -{ -#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC) - const uint32_t kb_rec_mask = - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY); - /* Unconditionally clear the EC recovery request. */ - return google_chromeec_clear_events_b(kb_rec_mask); -#else - return 0; -#endif -} - int get_write_protect_state(void) { /* diff --git a/src/vendorcode/google/chromeos/chromeos.c b/src/vendorcode/google/chromeos/chromeos.c index b7d1e45829c2..dddce63f0fb2 100644 --- a/src/vendorcode/google/chromeos/chromeos.c +++ b/src/vendorcode/google/chromeos/chromeos.c @@ -17,9 +17,15 @@ #include <string.h> #include "chromeos.h" +int __attribute__((weak)) get_developer_mode_switch(void) +{ + // Weak implementation. No physical developer switch. + return 0; +} + int __attribute__((weak)) clear_recovery_mode_switch(void) { - // Can be implemented by a mainboard + // Weak implementation. Nothing to do. return 0; } |