summaryrefslogtreecommitdiff
path: root/driver/usb_mux/it5205.c
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2020-09-09 19:16:40 +0800
committerCommit Bot <commit-bot@chromium.org>2020-09-15 08:26:53 +0000
commita4fcebc675bea0f5d3911f03947ab940eb70020d (patch)
tree592014ce8dbb55440d56afa416133fb7dad58946 /driver/usb_mux/it5205.c
parent64013cb81d3f27908cfbca0d814008f32f7dae54 (diff)
downloadchrome-ec-a4fcebc675bea0f5d3911f03947ab940eb70020d.tar.gz
usb_mux/it5205h: implement SBU control
BUG=b:167499422 TEST=able to trigger sbu interrupt on reworked asurada BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I457596ee938790736ebdd5bfbd22e13831d715b4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2402598 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'driver/usb_mux/it5205.c')
-rw-r--r--driver/usb_mux/it5205.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/driver/usb_mux/it5205.c b/driver/usb_mux/it5205.c
index 95416547cd..f275568313 100644
--- a/driver/usb_mux/it5205.c
+++ b/driver/usb_mux/it5205.c
@@ -6,10 +6,8 @@
*/
#include "common.h"
-#include "console.h"
#include "i2c.h"
#include "it5205.h"
-#include "usb_mux.h"
#include "util.h"
#define MUX_STATE_DP_USB_MASK (USB_PD_MUX_USB_ENABLED | USB_PD_MUX_DP_ENABLED)
@@ -24,6 +22,20 @@ static int it5205_write(const struct usb_mux *me, uint8_t reg, uint8_t val)
return i2c_write8(me->i2c_port, me->i2c_addr_flags, reg, val);
}
+static int it5205h_sbu_update(const struct usb_mux *me, uint8_t reg,
+ uint8_t mask, enum mask_update_action action)
+{
+ return i2c_update8(me->i2c_port, IT5205H_SBU_I2C_ADDR_FLAGS,
+ reg, mask, action);
+}
+
+static int it5205h_sbu_field_update(const struct usb_mux *me, uint8_t reg,
+ uint8_t field_mask, uint8_t set_value)
+{
+ return i2c_field_update8(me->i2c_port, IT5205H_SBU_I2C_ADDR_FLAGS,
+ reg, field_mask, set_value);
+}
+
struct mux_chip_id_t {
uint8_t chip_id;
uint8_t reg;
@@ -54,9 +66,30 @@ static int it5205_init(const struct usb_mux *me)
return EC_ERROR_UNKNOWN;
}
+ if (IS_ENABLED(CONFIG_USB_MUX_IT5205H_SBU_OVP)) {
+ RETURN_ERROR(it5205h_sbu_field_update(me, IT5205H_REG_VSR,
+ IT5205H_VREF_SELECT_MASK,
+ IT5205H_VREF_SELECT_3_3V));
+
+ RETURN_ERROR(it5205h_sbu_field_update(me, IT5205H_REG_CSBUOVPSR,
+ IT5205H_OVP_SELECT_MASK,
+ IT5205H_OVP_3_68V));
+
+ RETURN_ERROR(it5205h_sbu_update(me, IT5205H_REG_ISR,
+ IT5205H_ISR_CSBU_MASK, MASK_CLR));
+
+ RETURN_ERROR(it5205h_enable_csbu_switch(me, true));
+ }
+
return EC_SUCCESS;
}
+enum ec_error_list it5205h_enable_csbu_switch(const struct usb_mux *me, bool en)
+{
+ return it5205h_sbu_update(me, IT5205H_REG_CSBUSR,
+ IT5205H_CSBUSR_SWITCH, en ? MASK_SET : MASK_CLR);
+}
+
/* Writes control register to set switch mode */
static int it5205_set_mux(const struct usb_mux *me, mux_state_t mux_state)
{