summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hill <ecgh@chromium.org>2020-05-11 20:35:22 -0600
committerCommit Bot <commit-bot@chromium.org>2020-05-12 19:04:32 +0000
commit65aa151d0544051118259fc086093670eef26518 (patch)
tree65c32fa6ce2476bcca352470593a2ff901fa8e16
parent5c359b906557cd1a1fc80baa11a7043ca169a8b9 (diff)
downloadchrome-ec-65aa151d0544051118259fc086093670eef26518.tar.gz
Zork: Use FW_CONFIG for IOEX_MST_HPD_OUT.
Move mst_hpd_interrupt() out of variant_trembyle.c into individual boards. Use FW_CONFIG to only enable IOEX_MST_HPD_OUT interrupt when appropriate. BUG=b:156046102 BRANCH=none TEST=none Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I3f188088254208f01aea2094b7f2b57590b0d91b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2195186 Reviewed-by: David Huang <david.huang@quanta.corp-partner.google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
-rw-r--r--baseboard/zork/variant_trembyle.c32
-rw-r--r--board/berknip/board.c34
-rw-r--r--board/berknip/board.h9
-rw-r--r--board/ezkinil/gpio.inc1
-rw-r--r--board/morphius/board.c34
-rw-r--r--board/morphius/board.h9
-rw-r--r--board/trembyle/board.c34
-rw-r--r--board/trembyle/board.h9
8 files changed, 129 insertions, 33 deletions
diff --git a/baseboard/zork/variant_trembyle.c b/baseboard/zork/variant_trembyle.c
index eb26ac4199..6f5ba217ba 100644
--- a/baseboard/zork/variant_trembyle.c
+++ b/baseboard/zork/variant_trembyle.c
@@ -137,7 +137,6 @@ void baseboard_tcpc_init(void)
/* Enable HPD interrupts */
ioex_enable_interrupt(IOEX_HDMI_CONN_HPD_3V3_DB);
- ioex_enable_interrupt(IOEX_MST_HPD_OUT);
}
DECLARE_HOOK(HOOK_INIT, baseboard_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
@@ -161,37 +160,6 @@ BUILD_ASSERT(ARRAY_SIZE(ioex_config) == USBC_PORT_COUNT);
BUILD_ASSERT(CONFIG_IO_EXPANDER_PORT_COUNT == USBC_PORT_COUNT);
/*****************************************************************************
- * MST hub
- */
-
-static void mst_hpd_handler(void)
-{
- int hpd = 0;
-
- /*
- * Ensure level on GPIO_DP1_HPD matches IOEX_MST_HPD_OUT, in case
- * we got out of sync.
- */
- ioex_get_level(IOEX_MST_HPD_OUT, &hpd);
- gpio_set_level(GPIO_DP1_HPD, hpd);
- ccprints("MST HPD %d", hpd);
-}
-DECLARE_DEFERRED(mst_hpd_handler);
-
-void mst_hpd_interrupt(enum ioex_signal signal)
-{
- /*
- * Goal is to pass HPD through from DB OPT3 MST hub to AP's DP1.
- * Immediately invert GPIO_DP1_HPD, to pass through the edge on
- * IOEX_MST_HPD_OUT. Then check level after 2 msec debounce.
- */
- int hpd = !gpio_get_level(GPIO_DP1_HPD);
-
- gpio_set_level(GPIO_DP1_HPD, hpd);
- hook_call_deferred(&mst_hpd_handler_data, (2 * MSEC));
-}
-
-/*****************************************************************************
* USB-A Power
*/
diff --git a/board/berknip/board.c b/board/berknip/board.c
index ea6ad978d1..d61369f645 100644
--- a/board/berknip/board.c
+++ b/board/berknip/board.c
@@ -308,6 +308,9 @@ void setup_fw_config(void)
gpio_enable_interrupt(GPIO_6AXIS_INT_L);
setup_mux();
+
+ if (ec_config_has_mst_hub_rtd2141b())
+ ioex_enable_interrupt(IOEX_MST_HPD_OUT);
}
DECLARE_HOOK(HOOK_INIT, setup_fw_config, HOOK_PRIO_INIT_I2C + 2);
@@ -368,3 +371,34 @@ static void setup_fans(void)
thermal_params[TEMP_SENSOR_CPU] = thermal_cpu;
}
DECLARE_HOOK(HOOK_INIT, setup_fans, HOOK_PRIO_DEFAULT);
+
+/*****************************************************************************
+ * MST hub
+ */
+
+static void mst_hpd_handler(void)
+{
+ int hpd = 0;
+
+ /*
+ * Ensure level on GPIO_DP1_HPD matches IOEX_MST_HPD_OUT, in case
+ * we got out of sync.
+ */
+ ioex_get_level(IOEX_MST_HPD_OUT, &hpd);
+ gpio_set_level(GPIO_DP1_HPD, hpd);
+ ccprints("MST HPD %d", hpd);
+}
+DECLARE_DEFERRED(mst_hpd_handler);
+
+void mst_hpd_interrupt(enum ioex_signal signal)
+{
+ /*
+ * Goal is to pass HPD through from DB OPT3 MST hub to AP's DP1.
+ * Immediately invert GPIO_DP1_HPD, to pass through the edge on
+ * IOEX_MST_HPD_OUT. Then check level after 2 msec debounce.
+ */
+ int hpd = !gpio_get_level(GPIO_DP1_HPD);
+
+ gpio_set_level(GPIO_DP1_HPD, hpd);
+ hook_call_deferred(&mst_hpd_handler_data, (2 * MSEC));
+}
diff --git a/board/berknip/board.h b/board/berknip/board.h
index e9ab9e1a9e..8cd07fee84 100644
--- a/board/berknip/board.h
+++ b/board/berknip/board.h
@@ -172,6 +172,15 @@ static inline bool ec_config_has_hdmi_retimer_pi3hdx1204(void)
HAS_HDMI_RETIMER_PI3HDX1204);
}
+#define HAS_MST_HUB_RTD2141B \
+ (BIT(BERKNIP_DB_T_OPT3_USBAC_HDMI_MSTHUB))
+
+static inline bool ec_config_has_mst_hub_rtd2141b(void)
+{
+ return !!(BIT(ec_config_get_usb_db()) &
+ HAS_MST_HUB_RTD2141B);
+}
+
#define PORT_TO_HPD(port) ((port == 0) \
? GPIO_USB_C0_HPD \
: (ec_config_has_usbc1_retimer_ps8802()) \
diff --git a/board/ezkinil/gpio.inc b/board/ezkinil/gpio.inc
index 125484b819..9168a47116 100644
--- a/board/ezkinil/gpio.inc
+++ b/board/ezkinil/gpio.inc
@@ -56,7 +56,6 @@ GPIO(LED_FULL_L, PIN(6, 0), GPIO_OUT_HIGH)
GPIO(LED_CHRG_L, PIN(C, 0), GPIO_OUT_HIGH)
IOEX_INT(HDMI_CONN_HPD_3V3_DB, EXPIN(USBC_PORT_C1, 1, 0), GPIO_INT_BOTH, hdmi_hpd_interrupt)
-IOEX_INT(MST_HPD_OUT, EXPIN(USBC_PORT_C1, 0, 3), GPIO_INT_BOTH, mst_hpd_interrupt)
IOEX(USB_C0_FAULT_ODL, EXPIN(USBC_PORT_C0, 0, 3), GPIO_ODR_HIGH) /* C0 Fault to SOC */
IOEX(USB_C0_TCPC_FASTSW_CTL_EN, EXPIN(USBC_PORT_C0, 0, 4), GPIO_OUT_LOW) /* C0 FastSwitch Control */
diff --git a/board/morphius/board.c b/board/morphius/board.c
index a71e5dfacc..b80971994a 100644
--- a/board/morphius/board.c
+++ b/board/morphius/board.c
@@ -293,6 +293,9 @@ void setup_fw_config(void)
gpio_enable_interrupt(GPIO_EN_PWR_TOUCHPAD_PS2);
setup_mux();
+
+ if (ec_config_has_mst_hub_rtd2141b())
+ ioex_enable_interrupt(IOEX_MST_HPD_OUT);
}
DECLARE_HOOK(HOOK_INIT, setup_fw_config, HOOK_PRIO_INIT_I2C + 2);
@@ -451,3 +454,34 @@ static void board_chipset_suspend(void)
sb_smart_charge_mode(SB_SMART_CHARGE_ENABLE);
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
+
+/*****************************************************************************
+ * MST hub
+ */
+
+static void mst_hpd_handler(void)
+{
+ int hpd = 0;
+
+ /*
+ * Ensure level on GPIO_DP1_HPD matches IOEX_MST_HPD_OUT, in case
+ * we got out of sync.
+ */
+ ioex_get_level(IOEX_MST_HPD_OUT, &hpd);
+ gpio_set_level(GPIO_DP1_HPD, hpd);
+ ccprints("MST HPD %d", hpd);
+}
+DECLARE_DEFERRED(mst_hpd_handler);
+
+void mst_hpd_interrupt(enum ioex_signal signal)
+{
+ /*
+ * Goal is to pass HPD through from DB OPT3 MST hub to AP's DP1.
+ * Immediately invert GPIO_DP1_HPD, to pass through the edge on
+ * IOEX_MST_HPD_OUT. Then check level after 2 msec debounce.
+ */
+ int hpd = !gpio_get_level(GPIO_DP1_HPD);
+
+ gpio_set_level(GPIO_DP1_HPD, hpd);
+ hook_call_deferred(&mst_hpd_handler_data, (2 * MSEC));
+}
diff --git a/board/morphius/board.h b/board/morphius/board.h
index f62f4a64f3..41aca10514 100644
--- a/board/morphius/board.h
+++ b/board/morphius/board.h
@@ -173,6 +173,15 @@ static inline bool ec_config_has_hdmi_retimer_pi3hdx1204(void)
HAS_HDMI_RETIMER_PI3HDX1204);
}
+#define HAS_MST_HUB_RTD2141B \
+ (BIT(MORPHIUS_DB_T_OPT3_USBC_HDMI_MSTHUB))
+
+static inline bool ec_config_has_mst_hub_rtd2141b(void)
+{
+ return !!(BIT(ec_config_get_usb_db()) &
+ HAS_MST_HUB_RTD2141B);
+}
+
#define PORT_TO_HPD(port) ((port == 0) \
? GPIO_USB_C0_HPD \
: (ec_config_has_usbc1_retimer_ps8802()) \
diff --git a/board/trembyle/board.c b/board/trembyle/board.c
index 0add1454d3..8fa429f83a 100644
--- a/board/trembyle/board.c
+++ b/board/trembyle/board.c
@@ -308,6 +308,9 @@ void setup_fw_config(void)
gpio_enable_interrupt(GPIO_6AXIS_INT_L);
setup_mux();
+
+ if (ec_config_has_mst_hub_rtd2141b())
+ ioex_enable_interrupt(IOEX_MST_HPD_OUT);
}
DECLARE_HOOK(HOOK_INIT, setup_fw_config, HOOK_PRIO_INIT_I2C + 2);
@@ -368,3 +371,34 @@ static void setup_fans(void)
thermal_params[TEMP_SENSOR_CPU] = thermal_cpu;
}
DECLARE_HOOK(HOOK_INIT, setup_fans, HOOK_PRIO_DEFAULT);
+
+/*****************************************************************************
+ * MST hub
+ */
+
+static void mst_hpd_handler(void)
+{
+ int hpd = 0;
+
+ /*
+ * Ensure level on GPIO_DP1_HPD matches IOEX_MST_HPD_OUT, in case
+ * we got out of sync.
+ */
+ ioex_get_level(IOEX_MST_HPD_OUT, &hpd);
+ gpio_set_level(GPIO_DP1_HPD, hpd);
+ ccprints("MST HPD %d", hpd);
+}
+DECLARE_DEFERRED(mst_hpd_handler);
+
+void mst_hpd_interrupt(enum ioex_signal signal)
+{
+ /*
+ * Goal is to pass HPD through from DB OPT3 MST hub to AP's DP1.
+ * Immediately invert GPIO_DP1_HPD, to pass through the edge on
+ * IOEX_MST_HPD_OUT. Then check level after 2 msec debounce.
+ */
+ int hpd = !gpio_get_level(GPIO_DP1_HPD);
+
+ gpio_set_level(GPIO_DP1_HPD, hpd);
+ hook_call_deferred(&mst_hpd_handler_data, (2 * MSEC));
+}
diff --git a/board/trembyle/board.h b/board/trembyle/board.h
index 5af5ef98bb..b6facff8be 100644
--- a/board/trembyle/board.h
+++ b/board/trembyle/board.h
@@ -172,6 +172,15 @@ static inline bool ec_config_has_hdmi_retimer_pi3hdx1204(void)
HAS_HDMI_RETIMER_PI3HDX1204);
}
+#define HAS_MST_HUB_RTD2141B \
+ (BIT(TREMBYLE_DB_T_OPT3_USBAC_HDMI_MSTHUB))
+
+static inline bool ec_config_has_mst_hub_rtd2141b(void)
+{
+ return !!(BIT(ec_config_get_usb_db()) &
+ HAS_MST_HUB_RTD2141B);
+}
+
#define PORT_TO_HPD(port) ((port == 0) \
? GPIO_USB_C0_HPD \
: (ec_config_has_usbc1_retimer_ps8802()) \