summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2021-05-03 09:15:28 -0700
committerCommit Bot <commit-bot@chromium.org>2021-05-14 16:22:03 +0000
commit81bf98de282dcd11287fc8f5a95cc999437e7597 (patch)
tree84741f3242937acc2ac37e0500675054ef39e072
parentbcc11b209a014da1436e9abb9a6cd2c2918869f5 (diff)
downloadchrome-ec-81bf98de282dcd11287fc8f5a95cc999437e7597.tar.gz
honeybuns: Board specific power button and LEDs
This CL modifies both power button press/release polairty and power button LED control signals to be board specific instead of platform specific. Previously there were platform specific macros for BUTTON_PRESSED_LEVEL and BUTTON_RELEASED_LEVEL. But, these levels will depend on how the power button circuit is designed. This CL moves these macros to board.h. In addition, macros are added to for the GPIO signals used for green/red LED control. This allows for boards that don't support the power button LED at all. BUG=b:164157329 BRANCH=quiche TEST=Verfied power button works on both quiche and gingerbread. Previously, this was only working on quiche because gingerbread has opposite polarity for the power button signal. Also, verfied that power button/status LED turns off when dock is off. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: Iee838ee158d23252e8b429f51a1dd1a71d8e94a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2868225 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--baseboard/honeybuns/baseboard.c43
-rw-r--r--board/baklava/board.h3
-rw-r--r--board/gingerbread/board.c4
-rw-r--r--board/gingerbread/board.h9
-rw-r--r--board/quiche/board.h5
5 files changed, 44 insertions, 20 deletions
diff --git a/baseboard/honeybuns/baseboard.c b/baseboard/honeybuns/baseboard.c
index e61f447240..f32e6bed02 100644
--- a/baseboard/honeybuns/baseboard.c
+++ b/baseboard/honeybuns/baseboard.c
@@ -25,9 +25,6 @@
#define POWER_BUTTON_LONG_USEC (5000 * MSEC)
#define POWER_BUTTON_DEBOUNCE_USEC (30)
-#define BUTTON_PRESSED_LEVEL 1
-#define BUTTON_RELEASED_LEVEL 0
-
#define BUTTON_EVT_CHANGE BIT(0)
#define BUTTON_EVT_INFO BIT(1)
@@ -110,16 +107,16 @@ static void baseboard_set_led(enum led_color color)
CPRINTS("led: color = %d", color);
/* Not all boards may have LEDs under EC control */
-#if defined(GPIO_EC_STATUS_LED1) && defined(GPIO_EC_STATUS_LED2)
+#if defined(GPIO_PWR_BUTTON_RED) && defined(GPIO_PWR_BUTTON_GREEN)
if (color == OFF) {
- gpio_set_level(GPIO_EC_STATUS_LED1, 1);
- gpio_set_level(GPIO_EC_STATUS_LED2, 1);
+ gpio_set_level(GPIO_PWR_BUTTON_RED, 1);
+ gpio_set_level(GPIO_PWR_BUTTON_GREEN, 1);
} else if (color == GREEN) {
- gpio_set_level(GPIO_EC_STATUS_LED1, 1);
- gpio_set_level(GPIO_EC_STATUS_LED2, 0);
+ gpio_set_level(GPIO_PWR_BUTTON_RED, 1);
+ gpio_set_level(GPIO_PWR_BUTTON_GREEN, 0);
} else if (color == YELLOW) {
- gpio_set_level(GPIO_EC_STATUS_LED1, 0);
- gpio_set_level(GPIO_EC_STATUS_LED2, 0);
+ gpio_set_level(GPIO_PWR_BUTTON_RED, 0);
+ gpio_set_level(GPIO_PWR_BUTTON_GREEN, 0);
}
#endif
}
@@ -180,9 +177,14 @@ void baseboard_set_mst_lane_control(int mf)
static void baseboard_enable_mp4245(void)
{
+ int mv;
+ int ma;
+
mp4245_set_voltage_out(5000);
mp4245_votlage_out_enable(1);
msleep(MP4245_VOUT_5V_DELAY_MS);
+ mp3245_get_vbus(&mv, &ma);
+ CPRINTS("mp4245: vout @ %d mV enabled", mv);
}
#endif /* SECTION_IS_RW */
@@ -245,11 +247,16 @@ static void baseboard_power_on(void)
int port_max = board_get_usb_pd_port_count();
int port;
+ CPRINTS("pwrbtn: power on: mf = %d", dock_mf);
/* Adjust system flags to full PPC init occurs */
system_clear_reset_flags(EC_RESET_FLAG_POWER_ON);
system_set_reset_flags(EC_RESET_FLAG_EFS);
/* Enable power rails and release reset signals */
board_power_sequence(1);
+ /* Set VBUS to 5V and enable output from mp4245 */
+ baseboard_enable_mp4245();
+ /* Set dock mf preference LED */
+ baseboard_set_led(dock_mf);
/*
* Lane control (realtek MST) must be set prior to releasing MST
* reset.
@@ -268,8 +275,6 @@ static void baseboard_power_on(void)
/* Inform TC state machine that it can resume */
pd_set_suspend(port, 0);
}
- /* Set VBUS to 5V and enable output from mp4245 */
- baseboard_enable_mp4245();
/* Enable usbc interrupts */
board_enable_usbc_interrupts();
@@ -283,6 +288,7 @@ static void baseboard_power_off(void)
int port_max = board_get_usb_pd_port_count();
int port;
+ CPRINTS("pwrbtn: power off");
/* Put ports in TC suspend state */
for (port = 0; port < port_max; port++)
pd_set_suspend(port, 1);
@@ -296,6 +302,8 @@ static void baseboard_power_off(void)
/* Disable PPC interrupts for PS8803 managed port */
baseboard_usbc_usb3_enable_interrupts(0);
#endif
+ /* Set dock power button/MF preference LED */
+ baseboard_set_led(OFF);
/* Go into power off state */
board_power_sequence(0);
}
@@ -312,9 +320,14 @@ static void baseboard_toggle_mf(void)
dock_mf = CBI_FW_MF_PREFERENCE(fw_config);
/* Flash led for visual indication of user MF change */
baseboard_change_mf_led();
- /* Power the dock off, then on, to apply user preference */
- baseboard_power_off();
- baseboard_power_on();
+
+ /*
+ * Suspend, then release host port to force new MF setting to
+ * take effect.
+ */
+ pd_set_suspend(USB_PD_PORT_HOST, 1);
+ msleep(250);
+ pd_set_suspend(USB_PD_PORT_HOST, 0);
}
}
diff --git a/board/baklava/board.h b/board/baklava/board.h
index 48e8c17866..c5737f8a40 100644
--- a/board/baklava/board.h
+++ b/board/baklava/board.h
@@ -53,6 +53,9 @@
#define GPIO_USB_HUB_OCP_NOTIFY GPIO_USBC_DATA_OCP_NOTIFY
#define GPIO_UFP_PLUG_DET GPIO_MST_UFP_PLUG_DET
+#define BUTTON_PRESSED_LEVEL 1
+#define BUTTON_RELEASED_LEVEL 0
+
#define GPIO_TRIGGER_1 GPIO_USB3_A5_CDP_EN
#define GPIO_TRIGGER_2 GPIO_USB3_A6_CDP_EN
diff --git a/board/gingerbread/board.c b/board/gingerbread/board.c
index 4672ba0886..c23ace51b0 100644
--- a/board/gingerbread/board.c
+++ b/board/gingerbread/board.c
@@ -96,8 +96,7 @@ static void board_pwr_btn_interrupt(enum gpio_signal signal)
const struct power_seq board_power_seq[] = {
{GPIO_EN_AC_JACK, 1, 20},
{GPIO_EN_PP5000_A, 1, 31},
- {GPIO_EN_PP3300_A, 1, 35},
- {GPIO_EC_STATUS_LED1, 0, 100},
+ {GPIO_EN_PP3300_A, 1, 135},
{GPIO_EN_BB, 1, 30},
{GPIO_EN_PP1100_A, 1, 30},
{GPIO_EN_PP1000_A, 1, 20},
@@ -116,7 +115,6 @@ const struct power_seq board_power_seq[] = {
{GPIO_DEMUX_DP_HDMI_PD_N, 1, 10},
{GPIO_DEMUX_DUAL_DP_MODE, 1, 10},
{GPIO_DEMUX_DP_HDMI_MODE, 1, 1},
- {GPIO_EC_STATUS_LED2, 0, 100},
};
const size_t board_power_seq_count = ARRAY_SIZE(board_power_seq);
diff --git a/board/gingerbread/board.h b/board/gingerbread/board.h
index cee6cb45d9..af962f4273 100644
--- a/board/gingerbread/board.h
+++ b/board/gingerbread/board.h
@@ -60,9 +60,14 @@
#define GPIO_DP_HPD GPIO_DDI_MST_IN_HPD
#define GPIO_BPWR_DET GPIO_TP71
+#define GPIO_PWR_BUTTON_RED GPIO_EC_STATUS_LED1
+#define GPIO_PWR_BUTTON_GREEN GPIO_EC_STATUS_LED2
-#define GPIO_TRIGGER_1 GPIO_EC_HUB1_RESET_L
-#define GPIO_TRIGGER_2 GPIO_EC_HUB2_RESET_L
+#define BUTTON_PRESSED_LEVEL 0
+#define BUTTON_RELEASED_LEVEL 1
+
+#define GPIO_TRIGGER_1 GPIO_USB3_A1_CDP_EN
+#define GPIO_TRIGGER_2 GPIO_USB3_A2_CDP_EN
enum debug_gpio {
TRIGGER_1 = 0,
diff --git a/board/quiche/board.h b/board/quiche/board.h
index 336b6fcd7e..15faabc1ed 100644
--- a/board/quiche/board.h
+++ b/board/quiche/board.h
@@ -52,6 +52,11 @@
#define GPIO_BPWR_DET GPIO_TP73
#define GPIO_USB_HUB_OCP_NOTIFY GPIO_USBC_DATA_OCP_NOTIFY
#define GPIO_UFP_PLUG_DET GPIO_MST_UFP_PLUG_DET
+#define GPIO_PWR_BUTTON_RED GPIO_EC_STATUS_LED1
+#define GPIO_PWR_BUTTON_GREEN GPIO_EC_STATUS_LED2
+
+#define BUTTON_PRESSED_LEVEL 1
+#define BUTTON_RELEASED_LEVEL 0
#define GPIO_TRIGGER_1 GPIO_EC_STATUS_LED1
#define GPIO_TRIGGER_2 GPIO_EC_STATUS_LED2