summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-08-14 15:05:26 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-30 20:33:28 +0000
commitfe3a60e79265658a8e5336c0eaada4977e083cd3 (patch)
tree09db3f89c5eb663daca1e5a1ed2b20708f37ab5c /driver
parentd32885333e9bba9915d5388b08e888e06dfad511 (diff)
downloadchrome-ec-fe3a60e79265658a8e5336c0eaada4977e083cd3.tar.gz
USB MUX: Convert usb_mux HPD functions to use mux_state_t
Since we have definitions for HPD IRQ and level in the mux flags, extend this to the HPD update function in the usb_mux structure as well. BRANCH=None BUG=b:172222942 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I19c3a65fc821a341338d73fabd7876339b37fe7d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3095437 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/tcpm/anx7447.c4
-rw-r--r--driver/tcpm/anx7447.h2
-rw-r--r--driver/tcpm/anx74xx.c4
-rw-r--r--driver/tcpm/anx74xx.h2
-rw-r--r--driver/tcpm/ps8xxx.c4
-rw-r--r--driver/usb_mux/usb_mux.c11
-rw-r--r--driver/usb_mux/virtual.c5
7 files changed, 15 insertions, 17 deletions
diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c
index 0367d4a78c..9a9a3c7971 100644
--- a/driver/tcpm/anx7447.c
+++ b/driver/tcpm/anx7447.c
@@ -455,10 +455,12 @@ static void anx7447_tcpc_alert(int port)
static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT];
void anx7447_tcpc_update_hpd_status(const struct usb_mux *me,
- int hpd_lvl, int hpd_irq)
+ mux_state_t mux_state)
{
int reg = 0;
int port = me->usb_port;
+ int hpd_lvl = (mux_state & USB_PD_MUX_HPD_LVL) ? 1 : 0;
+ int hpd_irq = (mux_state & USB_PD_MUX_HPD_IRQ) ? 1 : 0;
/*
* All calls within this method need to update to a mux_read/write calls
diff --git a/driver/tcpm/anx7447.h b/driver/tcpm/anx7447.h
index 8323282040..75982e6b91 100644
--- a/driver/tcpm/anx7447.h
+++ b/driver/tcpm/anx7447.h
@@ -143,7 +143,7 @@ extern const struct tcpm_drv anx7447_tcpm_drv;
extern const struct usb_mux_driver anx7447_usb_mux_driver;
void anx7447_tcpc_clear_hpd_status(int port);
void anx7447_tcpc_update_hpd_status(const struct usb_mux *me,
- int hpd_lvl, int hpd_irq);
+ mux_state_t mux_state);
/**
* Erase OCM flash if it's not empty
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c
index 34e7800daf..90834bff2e 100644
--- a/driver/tcpm/anx74xx.c
+++ b/driver/tcpm/anx74xx.c
@@ -233,10 +233,12 @@ static void anx74xx_tcpc_discharge_vbus(int port, int enable)
static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT];
void anx74xx_tcpc_update_hpd_status(const struct usb_mux *me,
- int hpd_lvl, int hpd_irq)
+ mux_state_t mux_state)
{
int reg;
int port = me->usb_port;
+ int hpd_lvl = (mux_state & USB_PD_MUX_HPD_LVL) ? 1 : 0;
+ int hpd_irq = (mux_state & USB_PD_MUX_HPD_IRQ) ? 1 : 0;
mux_read(me, ANX74XX_REG_HPD_CTRL_0, &reg);
if (hpd_lvl)
diff --git a/driver/tcpm/anx74xx.h b/driver/tcpm/anx74xx.h
index d7ba62bda3..8d700d4d86 100644
--- a/driver/tcpm/anx74xx.h
+++ b/driver/tcpm/anx74xx.h
@@ -220,7 +220,7 @@ extern const struct usb_mux_driver anx74xx_tcpm_usb_mux_driver;
void anx74xx_tcpc_set_vbus(int port, int enable);
void anx74xx_tcpc_clear_hpd_status(int port);
void anx74xx_tcpc_update_hpd_status(const struct usb_mux *me,
- int hpd_lvl, int hpd_irq);
+ mux_state_t mux_state);
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
extern struct i2c_stress_test_dev anx74xx_i2c_stress_test_dev;
diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c
index 37bfb30cc0..ade607ac09 100644
--- a/driver/tcpm/ps8xxx.c
+++ b/driver/tcpm/ps8xxx.c
@@ -383,9 +383,11 @@ bool check_ps8755_chip(int port)
}
void ps8xxx_tcpc_update_hpd_status(const struct usb_mux *me,
- int hpd_lvl, int hpd_irq)
+ mux_state_t mux_state)
{
int port = me->usb_port;
+ int hpd_lvl = (mux_state & USB_PD_MUX_HPD_LVL) ? 1 : 0;
+ int hpd_irq = (mux_state & USB_PD_MUX_HPD_IRQ) ? 1 : 0;
if (IS_ENABLED(CONFIG_USB_PD_TCPM_PS8751_CUSTOM_MUX_DRIVER) &&
product_id[me->usb_port] == PS8751_PRODUCT_ID &&
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c
index 5ae2b83848..56eb104b5d 100644
--- a/driver/usb_mux/usb_mux.c
+++ b/driver/usb_mux/usb_mux.c
@@ -138,15 +138,8 @@ static int configure_mux(int port,
break;
case USB_MUX_HPD_UPDATE:
- lcl_state = *mux_state;
-
- if (mux_ptr->hpd_update) {
- int hpd_lvl = (lcl_state & USB_PD_MUX_HPD_LVL) ?
- 1 : 0;
- int hpd_irq = (lcl_state & USB_PD_MUX_HPD_IRQ) ?
- 1 : 0;
- mux_ptr->hpd_update(mux_ptr, hpd_lvl, hpd_irq);
- }
+ if (mux_ptr->hpd_update)
+ mux_ptr->hpd_update(mux_ptr, *mux_state);
}
diff --git a/driver/usb_mux/virtual.c b/driver/usb_mux/virtual.c
index 72020dda03..dbece4faf9 100644
--- a/driver/usb_mux/virtual.c
+++ b/driver/usb_mux/virtual.c
@@ -105,14 +105,13 @@ static int virtual_get_mux(const struct usb_mux *me, mux_state_t *mux_state)
return EC_SUCCESS;
}
-void virtual_hpd_update(const struct usb_mux *me, int hpd_lvl, int hpd_irq)
+void virtual_hpd_update(const struct usb_mux *me, mux_state_t mux_state)
{
int port = me->usb_port;
bool unused;
/* Current HPD related mux status + existing USB & DP mux status */
- mux_state_t new_mux_state = (hpd_lvl ? USB_PD_MUX_HPD_LVL : 0) |
- (hpd_irq ? USB_PD_MUX_HPD_IRQ : 0) |
+ mux_state_t new_mux_state = mux_state |
(virtual_mux_state[port] & USB_PD_MUX_USB_DP_STATE);
/* HPD ACK isn't required for the EC to continue with its tasks */