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/mainboard | |
parent | f8a274acf53217129460b5a487396761c174bd54 (diff) |
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/mainboard')
46 files changed, 29 insertions, 874 deletions
diff --git a/src/mainboard/google/auron/Kconfig b/src/mainboard/google/auron/Kconfig index f1b1719d68..a6fd09cdac 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 20685c67d1..61b3e4ef1e 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 533c3dad1b..774c79355f 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 20685c67d1..61b3e4ef1e 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 38db373031..e563ff1750 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 3ca1872f04..fdd148611e 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 782a460e4b..d236aa0a59 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 f606d09c7d..672bc9708d 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 ec528a69a0..c2842bb334 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 e4f2d28689..68fb0a7bc7 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 c21d22abf3..0e1bc52cca 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 63615b3a3e..de83eaa637 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 d0b911a512..182a764644 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 a8cef3279b..22ec0742e2 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 e70094fb8b..a315b1cf24 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 3ca1872f04..9ee6e6f564 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 41e8105595..57b1762578 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 cc2b3b6604..d9e5e28f00 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 2a4973eb45..49dcf1be4a 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 daa85c69e0..42763a7d34 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 d1e1140773..b521f9c238 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 4be31d9fa4..0469d65c7c 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 ce32d3dac8..4c28e1a23b 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 1213266d3f..fa4c66f98f 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 9b25d5c9b2..515d16bd78 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 9d5d6b248e..aa7c9c69f6 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 bcf8f5d619..c8411bf435 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 e9df4e3bda..2c9ba28e5f 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 0782cc0fd6..530397c425 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 eddf15005b..2c9ba28e5f 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 acb27de55f..01bd0bcffb 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 0265c7a3c4..60c24e76ae 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 8829371bcd..b35cc58d19 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 a8cef3279b..22ec0742e2 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 48af3b396f..94354c9c92 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 4304179d4b..10e076209d 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 4d76f3838b..2cc391eeca 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 506f9de94b..256db16548 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 0275189f51..46fc7a3f43 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 7010ac9b6d..ea099f55b4 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 665545325b..ba6252b830 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 8688937fd6..0372584ae0 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 9bc607e3da..6848c11108 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 daa85c69e0..42763a7d34 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 42118f93e6..0d59371d43 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 0fb98111a8..6d00d72dee 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) { /* |