summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Yuan <jasonyuan@google.com>2023-03-07 13:13:18 -0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-13 20:50:15 +0000
commit3af1c6fcffa061b156a63426b9b9937a412e3b54 (patch)
tree4a6aeae6cc37fd7bc2f0184b3d4f546fb7b5da5a
parent4b446daddd9815263d86d8112879fae3a3fc9856 (diff)
downloadchrome-ec-3af1c6fcffa061b156a63426b9b9937a412e3b54.tar.gz
rex: fix polarity on tcpc interrupts
the original tcpc interrupt pins was not configured to ACTIVE_LOW so all logic involving the tcpc interrupt pins were reversed. This patch seeks to move to Zephyr conventions for tcpc gpios. gpio.dtsi is not edited due to it being an auto-generated file. The pinmap untility does not currently supprot the ACTIVE_LOW flag so it is instead set in rex.dtsi. BUG=b:254148652 TEST=none BRANCH=none LOW_COVERAGE_REASON=Some untested code have been simplified, which does not actually reduce code coverage even though it is technically uncovered. Change-Id: I5a4133a75d4eb089645633fa9b69fdb1d2e347b4 Signed-off-by: Jason Yuan <jasonyuan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4316739 Auto-Submit: zhi cheng yuan <jasonyuan@chromium.org> Tested-by: zhi cheng yuan <jasonyuan@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: zhi cheng yuan <jasonyuan@chromium.org>
-rw-r--r--zephyr/program/rex/rex.dtsi15
-rw-r--r--zephyr/program/rex/src/usbc_config.c11
2 files changed, 19 insertions, 7 deletions
diff --git a/zephyr/program/rex/rex.dtsi b/zephyr/program/rex/rex.dtsi
index 640459f9a9..7985f5ab76 100644
--- a/zephyr/program/rex/rex.dtsi
+++ b/zephyr/program/rex/rex.dtsi
@@ -43,6 +43,21 @@
ec-i2c-c0-rt-sda {
gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
};
+
+ /*
+ * The pinmap utility does not currently support ACTIVE_LOW
+ * flag. So it is set here.
+ */
+ /delete-node/ usb_c0_tcpc_int_odl;
+ /delete-node/ usb_c1_tcpc_int_odl;
+ gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl {
+ gpios = <&gpioe 0 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ enum-name = "GPIO_USB_C0_TCPC_INT_ODL";
+ };
+ gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl {
+ gpios = <&gpio3 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ enum-name = "GPIO_USB_C1_TCPC_INT_ODL";
+ };
};
usba-port-enable-list {
diff --git a/zephyr/program/rex/src/usbc_config.c b/zephyr/program/rex/src/usbc_config.c
index fceb6e0197..e12991d820 100644
--- a/zephyr/program/rex/src/usbc_config.c
+++ b/zephyr/program/rex/src/usbc_config.c
@@ -123,25 +123,22 @@ uint16_t tcpc_get_alert_status(void)
{
uint16_t status = 0;
const struct gpio_dt_spec *tcpc_c0_rst_l;
- const struct gpio_dt_spec *tcpc_c0_int_l;
const struct gpio_dt_spec *tcpc_c1_rst_l;
- const struct gpio_dt_spec *tcpc_c1_int_l;
tcpc_c0_rst_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_odl);
- tcpc_c0_int_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl);
-
tcpc_c1_rst_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl);
- tcpc_c1_int_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl);
/*
* Check which port has the ALERT line set and ignore if that TCPC has
* its reset line active.
*/
- if (!gpio_pin_get_dt(tcpc_c0_int_l) && gpio_pin_get_dt(tcpc_c0_rst_l)) {
+ if (gpio_pin_get_dt(&tcpc_config[0].irq_gpio) &&
+ gpio_pin_get_dt(tcpc_c0_rst_l)) {
status |= PD_STATUS_TCPC_ALERT_0;
}
- if (!gpio_pin_get_dt(tcpc_c1_int_l) && gpio_pin_get_dt(tcpc_c1_rst_l)) {
+ if (gpio_pin_get_dt(&tcpc_config[1].irq_gpio) &&
+ gpio_pin_get_dt(tcpc_c1_rst_l)) {
status |= PD_STATUS_TCPC_ALERT_1;
}