summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2020-02-14 15:21:50 -0700
committerCommit Bot <commit-bot@chromium.org>2020-02-27 20:50:08 +0000
commitc2f751f107d88d910f4631eeb8c6f4f9a99b9d81 (patch)
treeea4742de3a983c9b98fb452cf7f79c5fbbf849a1
parent6c0c6ec6b08a14ea0c1e612d585cdb825bb2f1cf (diff)
downloadchrome-ec-c2f751f107d88d910f4631eeb8c6f4f9a99b9d81.tar.gz
volteer: Configure EC_VOLUP_BTN_ODL for next build
Update the GPIO assignment for the EC_VOLUP_BTN_ODL signal for the next board build. BUG=b:144933528 BRANCH=none TEST=make buildall TEST=Verify volume buttons with board ID=0 Change-Id: I28e53573b6a6a9ba7e5df0458ded8b988c25ac04 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2065489 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--baseboard/volteer/baseboard.c7
-rw-r--r--baseboard/volteer/baseboard.h1
-rw-r--r--board/volteer/gpio.inc12
-rw-r--r--common/button.c37
-rw-r--r--include/button.h15
-rw-r--r--include/config.h5
6 files changed, 69 insertions, 8 deletions
diff --git a/baseboard/volteer/baseboard.c b/baseboard/volteer/baseboard.c
index 207a6c0491..53b3a0d146 100644
--- a/baseboard/volteer/baseboard.c
+++ b/baseboard/volteer/baseboard.c
@@ -6,6 +6,7 @@
/* Volteer family-specific configuration */
#include "adc_chip.h"
#include "bb_retimer.h"
+#include "button.h"
#include "charge_manager.h"
#include "charge_state.h"
#include "cros_board_info.h"
@@ -670,10 +671,16 @@ static void config_volteer_gpios(void)
{
/* Legacy support for the first board build */
if (get_board_id() == 0) {
+ CPRINTS("Configuring GPIOs for board ID 0");
+
/* Reassign USB_C1_RT_RST_ODL */
bb_controls[USBC_PORT_C1].retimer_rst_gpio =
GPIO_USB_C1_RT_RST_ODL_BOARDID_0;
ps8xxx_rst_odl = GPIO_USB_C1_RT_RST_ODL_BOARDID_0;
+
+ /* Reassign EC_VOLUP_BTN_ODL */
+ button_reassign_gpio(BUTTON_VOLUME_UP,
+ GPIO_EC_VOLUP_BTN_ODL_BOARDID_0);
}
}
diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h
index 9be9e208fb..0f53a0eb65 100644
--- a/baseboard/volteer/baseboard.h
+++ b/baseboard/volteer/baseboard.h
@@ -32,6 +32,7 @@
#define CONFIG_VSTORE
#define CONFIG_VSTORE_SLOT_COUNT 1
#define CONFIG_VOLUME_BUTTONS
+#define CONFIG_BUTTONS_RUNTIME_CONFIG
#define CONFIG_LOW_POWER_IDLE
/* Host communication */
diff --git a/board/volteer/gpio.inc b/board/volteer/gpio.inc
index 02a63c98f0..c9e6183f10 100644
--- a/board/volteer/gpio.inc
+++ b/board/volteer/gpio.inc
@@ -47,8 +47,15 @@ GPIO_INT(USB_C1_MIX_INT_ODL, PIN(0, 3), GPIO_INT_BOTH, bc12_interrupt)
/* HDMI interrupts */
/* Volume button interrupts */
-GPIO_INT(EC_VOLDN_BTN_ODL, PIN(9, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
-GPIO_INT(EC_VOLUP_BTN_ODL, PIN(7, 5), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
+GPIO_INT(EC_VOLDN_BTN_ODL, PIN(9, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
+/*
+ * EC_VOLUP_BTN_ODL moved from GPIO75 to GPIO97 on boards with board ID >=1.
+ * GPIO97/EN_PP1050_BYPASS is DNS on board ID 0, and GPIO75 will be used once
+ * EFS support is added.
+ * TODO (b/149858568): remove board ID=0 support.
+ */
+GPIO_INT(EC_VOLUP_BTN_ODL_BOARDID_0, PIN(7, 5), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
+GPIO_INT(EC_VOLUP_BTN_ODL, PIN(9, 7), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
/* Power Sequencing Signals */
GPIO(EN_PP3300_A, PIN(A, 3), GPIO_OUT_LOW)
@@ -64,7 +71,6 @@ GPIO(EN_PP5000_USB_AG, PIN(A, 7), GPIO_OUT_LOW)
GPIO(EN_PPVAR_VCCIN_AUX, PIN(8, 1), GPIO_OUT_LOW)
GPIO(EN_PP1050_ST_S0, PIN(3, 4), GPIO_OUT_LOW)
GPIO(EN_VNN_BYPASS, PIN(B, 0), GPIO_OUT_LOW)
-GPIO(EN_PP1050_BYPASS, PIN(9, 7), GPIO_OUT_LOW)
GPIO(EN_DRAM_VDD1, PIN(9, 6), GPIO_OUT_LOW)
#endif
diff --git a/common/button.c b/common/button.c
index 7eee2e41e1..9c4e1a2446 100644
--- a/common/button.c
+++ b/common/button.c
@@ -186,6 +186,14 @@ static int is_recovery_boot(void)
}
#endif /* CONFIG_BUTTON_TRIGGERED_RECOVERY */
+static void button_reset(enum button button_type,
+ const struct button_config *button)
+{
+ state[button_type].debounced_pressed = raw_button_pressed(button);
+ state[button_type].debounce_time = 0;
+ gpio_enable_interrupt(button->gpio);
+}
+
/*
* Button initialization.
*/
@@ -195,11 +203,8 @@ void button_init(void)
CPRINTS("init buttons");
next_deferred_time = 0;
- for (i = 0; i < BUTTON_COUNT; i++) {
- state[i].debounced_pressed = raw_button_pressed(&buttons[i]);
- state[i].debounce_time = 0;
- gpio_enable_interrupt(buttons[i].gpio);
- }
+ for (i = 0; i < BUTTON_COUNT; i++)
+ button_reset(i, &buttons[i]);
#ifdef CONFIG_BUTTON_TRIGGERED_RECOVERY
if (is_recovery_boot()) {
@@ -210,6 +215,24 @@ void button_init(void)
#endif /* defined(CONFIG_BUTTON_TRIGGERED_RECOVERY) */
}
+#ifdef CONFIG_BUTTONS_RUNTIME_CONFIG
+int button_reassign_gpio(enum button button_type, enum gpio_signal gpio)
+{
+ if (button_type >= BUTTON_COUNT)
+ return EC_ERROR_INVAL;
+
+ /* Disable currently assigned interrupt */
+ gpio_disable_interrupt(buttons[button_type].gpio);
+
+ /* Reconfigure GPIO and enable the new interrupt */
+ buttons[button_type].gpio = gpio;
+ button_reset(button_type, &buttons[button_type]);
+
+ return EC_SUCCESS;
+}
+#endif
+
+
/*
* Handle debounced button changing state.
*/
@@ -723,7 +746,11 @@ DECLARE_HOOK(HOOK_TICK, debug_led_tick, HOOK_PRIO_DEFAULT);
#error "A dedicated recovery button is not needed if you have volume buttons."
#endif /* defined(CONFIG_VOLUME_BUTTONS && CONFIG_DEDICATED_RECOVERY_BUTTON) */
+#ifndef CONFIG_BUTTONS_RUNTIME_CONFIG
const struct button_config buttons[BUTTON_COUNT] = {
+#else
+struct button_config buttons[BUTTON_COUNT] = {
+#endif
#ifdef CONFIG_VOLUME_BUTTONS
[BUTTON_VOLUME_UP] = {
.name = "Volume Up",
diff --git a/include/button.h b/include/button.h
index 3c6a350b3b..2961625bea 100644
--- a/include/button.h
+++ b/include/button.h
@@ -51,7 +51,11 @@ enum button {
};
/* Table of buttons for the board. */
+#ifndef CONFIG_BUTTONS_RUNTIME_CONFIG
extern const struct button_config buttons[];
+#else
+extern struct button_config buttons[];
+#endif
/*
* Buttons used to decide whether recovery is requested or not
@@ -65,6 +69,17 @@ extern const int recovery_buttons_count;
void button_init(void);
/*
+ * Reassign a button GPIO signal at runtime.
+ *
+ * @param button_type Button type to reassign
+ * @param gpio GPIO to assign to the button
+ *
+ * Returns EC_SUCCESS if button change is accepted and made active,
+ * EC_ERROR_* otherwise.
+ */
+int button_reassign_gpio(enum button button_type, enum gpio_signal gpio);
+
+/*
* Interrupt handler for button.
*
* @param signal Signal which triggered the interrupt.
diff --git a/include/config.h b/include/config.h
index 59828ca716..1e59237b5e 100644
--- a/include/config.h
+++ b/include/config.h
@@ -727,6 +727,11 @@
*/
#undef CONFIG_VOLUME_BUTTONS
+/*
+ * Allow runtime configuration of the buttons[] array
+ */
+#undef CONFIG_BUTTONS_RUNTIME_CONFIG
+
/* Support V1 CCD configuration */
#undef CONFIG_CASE_CLOSED_DEBUG_V1
/* Allow unsafe debugging functionality in V1 configuration */