From 3af1c6fcffa061b156a63426b9b9937a412e3b54 Mon Sep 17 00:00:00 2001 From: Jason Yuan Date: Tue, 7 Mar 2023 13:13:18 -0800 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4316739 Auto-Submit: zhi cheng yuan Tested-by: zhi cheng yuan Reviewed-by: Keith Short Commit-Queue: zhi cheng yuan --- zephyr/program/rex/rex.dtsi | 15 +++++++++++++++ zephyr/program/rex/src/usbc_config.c | 11 ++++------- 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; } -- cgit v1.2.1