summaryrefslogtreecommitdiff
path: root/baseboard
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2021-08-03 17:17:56 -0700
committerCommit Bot <commit-bot@chromium.org>2021-08-05 00:13:33 +0000
commit2eb53a39662b905c65015bafb5f73ab2324d369c (patch)
tree6352433557cdb05c75b1eef449c9ecf844bfc3d0 /baseboard
parentfc016f2dce16d0555deee69e00ea5a626eb27f21 (diff)
downloadchrome-ec-2eb53a39662b905c65015bafb5f73ab2324d369c.tar.gz
lid_angle: Create a common callback for lid angle changes
Each board defines its own callback lid_angle_peripheral_enable(). The implementation is very similar. Create a common implementation and reduce the duplicated code. This CL removes the board callbacks which are identifical to the common callback. If it is slightly different, keep it and add the __override tag. The check of TEST_BUILD is unnecessary as the board callback is not linked in the test build. BRANCH=None BUG=b:194922043 TEST=Build all the images. Change-Id: I73d381730f35b80eff69399cdfc5fb54f839aee0 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3069175 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'baseboard')
-rw-r--r--baseboard/asurada/baseboard.c21
-rw-r--r--baseboard/cherry/baseboard.c21
-rw-r--r--baseboard/goroh/baseboard.c21
-rw-r--r--baseboard/grunt/baseboard.c4
-rw-r--r--baseboard/hatch/baseboard.c4
-rw-r--r--baseboard/kukui/baseboard.c4
-rw-r--r--baseboard/zork/baseboard.c4
7 files changed, 5 insertions, 74 deletions
diff --git a/baseboard/asurada/baseboard.c b/baseboard/asurada/baseboard.c
index 8780297939..c00a990483 100644
--- a/baseboard/asurada/baseboard.c
+++ b/baseboard/asurada/baseboard.c
@@ -123,24 +123,3 @@ const struct cc_para_t *board_get_cc_tuning_parameter(enum usbpd_port port)
return &cc_parameter[port];
}
-
-/* Lid */
-#ifndef TEST_BUILD
-/* This callback disables keyboard when convertibles are fully open */
-void lid_angle_peripheral_enable(int enable)
-{
- int chipset_in_s0 = chipset_in_state(CHIPSET_STATE_ON);
-
- if (enable) {
- keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_ANGLE);
- } else {
- /*
- * Ensure that the chipset is off before disabling the keyboard.
- * When the chipset is on, the EC keeps the keyboard enabled and
- * the AP decides whether to ignore input devices or not.
- */
- if (!chipset_in_s0)
- keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_ANGLE);
- }
-}
-#endif
diff --git a/baseboard/cherry/baseboard.c b/baseboard/cherry/baseboard.c
index 507febf712..e3201a96af 100644
--- a/baseboard/cherry/baseboard.c
+++ b/baseboard/cherry/baseboard.c
@@ -592,27 +592,6 @@ int board_regulator_get_voltage(uint32_t index, uint32_t *voltage_mv)
return mt6360_regulator_get_voltage(id, voltage_mv);
}
-/* Lid */
-#ifndef TEST_BUILD
-/* This callback disables keyboard when convertibles are fully open */
-void lid_angle_peripheral_enable(int enable)
-{
- int chipset_in_s0 = chipset_in_state(CHIPSET_STATE_ON);
-
- if (enable) {
- keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_ANGLE);
- } else {
- /*
- * Ensure that the chipset is off before disabling the keyboard.
- * When the chipset is on, the EC keeps the keyboard enabled and
- * the AP decides whether to ignore input devices or not.
- */
- if (!chipset_in_s0)
- keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_ANGLE);
- }
-}
-#endif
-
static void baseboard_init(void)
{
gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_ODL);
diff --git a/baseboard/goroh/baseboard.c b/baseboard/goroh/baseboard.c
index b14521f76d..c738033018 100644
--- a/baseboard/goroh/baseboard.c
+++ b/baseboard/goroh/baseboard.c
@@ -566,27 +566,6 @@ int board_regulator_get_voltage(uint32_t index, uint32_t *voltage_mv)
return mt6360_regulator_get_voltage(id, voltage_mv);
}
-/* Lid */
-#ifndef TEST_BUILD
-/* This callback disables keyboard when convertibles are fully open */
-void lid_angle_peripheral_enable(int enable)
-{
- int chipset_in_s0 = chipset_in_state(CHIPSET_STATE_ON);
-
- if (enable) {
- keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_ANGLE);
- } else {
- /*
- * Ensure that the chipset is off before disabling the keyboard.
- * When the chipset is on, the EC keeps the keyboard enabled and
- * the AP decides whether to ignore input devices or not.
- */
- if (!chipset_in_s0)
- keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_ANGLE);
- }
-}
-#endif
-
static void baseboard_init(void)
{
gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_ODL);
diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c
index 9d06fd4b78..70270f6927 100644
--- a/baseboard/grunt/baseboard.c
+++ b/baseboard/grunt/baseboard.c
@@ -645,13 +645,11 @@ unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
#endif /* HAS_TASK_MOTIONSENSE */
-#ifndef TEST_BUILD
-void lid_angle_peripheral_enable(int enable)
+__override void lid_angle_peripheral_enable(int enable)
{
if (board_is_convertible())
keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE);
}
-#endif
static const int sku_thresh_mv[] = {
/* Vin = 3.3V, Ideal voltage, R2 values listed below */
diff --git a/baseboard/hatch/baseboard.c b/baseboard/hatch/baseboard.c
index 834406dd93..dd93e581cf 100644
--- a/baseboard/hatch/baseboard.c
+++ b/baseboard/hatch/baseboard.c
@@ -336,8 +336,7 @@ void baseboard_mst_enable_control(enum mst_source src, int level)
#endif
/* Enable or disable input devices, based on chipset state */
-#ifndef TEST_BUILD
-void lid_angle_peripheral_enable(int enable)
+__override void lid_angle_peripheral_enable(int enable)
{
if (board_is_convertible()) {
if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
@@ -345,7 +344,6 @@ void lid_angle_peripheral_enable(int enable)
keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE);
}
}
-#endif
static uint8_t sku_id;
static uint8_t board_id;
diff --git a/baseboard/kukui/baseboard.c b/baseboard/kukui/baseboard.c
index 03023b1068..a779d57791 100644
--- a/baseboard/kukui/baseboard.c
+++ b/baseboard/kukui/baseboard.c
@@ -201,8 +201,8 @@ int board_allow_i2c_passthru(int port)
}
/* Enable or disable input devices, based on chipset state and tablet mode */
-#if !defined(TEST_BUILD) && defined(VARIANT_KUKUI_JACUZZI)
-void lid_angle_peripheral_enable(int enable)
+#ifdef VARIANT_KUKUI_JACUZZI
+__override void lid_angle_peripheral_enable(int enable)
{
int chipset_in_s0 = chipset_in_state(CHIPSET_STATE_ON);
diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c
index 41c859ad7b..00ccaf23c4 100644
--- a/baseboard/zork/baseboard.c
+++ b/baseboard/zork/baseboard.c
@@ -156,8 +156,7 @@ const struct thermistor_info thermistor_info = {
.data = thermistor_data,
};
-#ifndef TEST_BUILD
-void lid_angle_peripheral_enable(int enable)
+__override void lid_angle_peripheral_enable(int enable)
{
if (ec_config_has_lid_angle_tablet_mode()) {
int chipset_in_s0 = chipset_in_state(CHIPSET_STATE_ON);
@@ -177,7 +176,6 @@ void lid_angle_peripheral_enable(int enable)
}
}
}
-#endif
static void cbi_init(void)
{