[coreboot-gerrit] Patch set updated for coreboot: google/chromeec: Add common infrastructure for boot-mode switches
Furquan Shaikh (furquan@google.com)
gerrit at coreboot.org
Thu Nov 17 21:30:30 CET 2016
Furquan Shaikh (furquan at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17449
-gerrit
commit 8fadd10c17ee66e18cd8f3f17c4fbe0e7df780f7
Author: Furquan Shaikh <furquan at chromium.org>
Date: Tue Nov 15 20:33:29 2016 -0800
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 at chromium.org>
---
src/ec/google/chromeec/Kconfig | 7 ++++
src/ec/google/chromeec/Makefile.inc | 4 ++
src/ec/google/chromeec/switches.c | 59 +++++++++++++++++++++++++++
src/mainboard/google/auron/Kconfig | 1 +
src/mainboard/google/auron/chromeos.c | 41 -------------------
src/mainboard/google/auron_paine/Kconfig | 1 +
src/mainboard/google/auron_paine/chromeos.c | 41 -------------------
src/mainboard/google/chell/Kconfig | 1 +
src/mainboard/google/chell/chromeos.c | 36 -----------------
src/mainboard/google/cyan/Kconfig | 1 +
src/mainboard/google/cyan/chromeos.c | 60 ----------------------------
src/mainboard/google/enguarde/Kconfig | 1 +
src/mainboard/google/enguarde/chromeos.c | 57 --------------------------
src/mainboard/google/eve/Kconfig | 1 +
src/mainboard/google/eve/chromeos.c | 29 --------------
src/mainboard/google/falco/Kconfig | 1 +
src/mainboard/google/falco/chromeos.c | 47 ----------------------
src/mainboard/google/glados/Kconfig | 1 +
src/mainboard/google/glados/chromeos.c | 37 +----------------
src/mainboard/google/gru/Kconfig | 1 +
src/mainboard/google/gru/chromeos.c | 18 +--------
src/mainboard/google/lars/Kconfig | 1 +
src/mainboard/google/lars/chromeos.c | 36 -----------------
src/mainboard/google/link/Kconfig | 1 +
src/mainboard/google/link/chromeos.c | 36 -----------------
src/mainboard/google/ninja/Kconfig | 1 +
src/mainboard/google/ninja/chromeos.c | 45 ---------------------
src/mainboard/google/nyan/Kconfig | 1 +
src/mainboard/google/nyan/chromeos.c | 18 ---------
src/mainboard/google/nyan_big/Kconfig | 1 +
src/mainboard/google/nyan_big/chromeos.c | 18 ---------
src/mainboard/google/nyan_blaze/Kconfig | 1 +
src/mainboard/google/nyan_blaze/chromeos.c | 24 +----------
src/mainboard/google/oak/Kconfig | 1 +
src/mainboard/google/oak/chromeos.c | 19 +--------
src/mainboard/google/peppy/Kconfig | 1 +
src/mainboard/google/peppy/chromeos.c | 47 ----------------------
src/mainboard/google/rambi/Kconfig | 1 +
src/mainboard/google/rambi/chromeos.c | 58 ---------------------------
src/mainboard/google/reef/Kconfig | 3 +-
src/mainboard/google/reef/chromeos.c | 38 ------------------
src/mainboard/google/samus/Kconfig | 1 +
src/mainboard/google/samus/chromeos.c | 51 ------------------------
src/mainboard/google/smaug/Kconfig | 1 +
src/mainboard/google/smaug/chromeos.c | 24 +----------
src/mainboard/intel/kunimitsu/Kconfig | 1 +
src/mainboard/intel/kunimitsu/chromeos.c | 36 -----------------
src/mainboard/intel/strago/Kconfig | 1 +
src/mainboard/intel/strago/chromeos.c | 62 -----------------------------
src/vendorcode/google/chromeos/chromeos.c | 8 +++-
50 files changed, 106 insertions(+), 875 deletions(-)
diff --git a/src/ec/google/chromeec/Kconfig b/src/ec/google/chromeec/Kconfig
index f809003..76eef05 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 b38d5b7..2fe6994 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 0000000..74f7210
--- /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 f1b1719..a6fd09c 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 20685c6..61b3e4e 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 533c3da..774c793 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 20685c6..61b3e4e 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 38db373..e563ff1 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 3ca1872..fdd1486 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 782a460..d236aa0 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 f606d09..672bc97 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 ec528a6..c2842bb 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 e4f2d28..68fb0a7 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 c21d22a..0e1bc52 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 63615b3..de83eaa 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 d0b911a..182a764 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 a8cef32..22ec074 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 e70094f..a315b1c 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 3ca1872..9ee6e6f 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 41e8105..57b1762 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 cc2b3b6..d9e5e28 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 2a4973e..49dcf1b 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 daa85c6..42763a7 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 d1e1140..b521f9c 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 4be31d9..0469d65 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 ce32d3d..4c28e1a 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 1213266..fa4c66f 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 9b25d5c..515d16b 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 9d5d6b2..aa7c9c6 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 bcf8f5d..c8411bf 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 e9df4e3..2c9ba28 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 0782cc0..530397c 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 eddf150..2c9ba28 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 acb27de..01bd0bc 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 0265c7a..60c24e7 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 8829371..b35cc58 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 a8cef32..22ec074 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 48af3b3..94354c9 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 4304179..10e0762 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 4d76f38..2cc391e 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 506f9de..256db16 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 0275189..46fc7a3 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 7010ac9..ea099f5 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 6655453..ba6252b 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 8688937..0372584 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 9bc607e..6848c11 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 daa85c6..42763a7 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 42118f9..0d59371 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 0fb9811..6d00d72 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 b7d1e45..dddce63 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;
}
More information about the coreboot-gerrit
mailing list