diff options
author | Marc Zyngier <maz@kernel.org> | 2023-05-13 15:44:32 +0100 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2023-05-13 15:44:32 +0100 |
commit | ddea7a17b7609fe26ebf168fa60c83ca87f7b125 (patch) | |
tree | 5d2085c7c49063fea28667d0994d0079d2264251 | |
parent | a4fbd8f665d26c8744588e408bd2da4ba290d8c5 (diff) | |
download | cs-sw-ddea7a17b7609fe26ebf168fa60c83ca87f7b125.tar.gz |
Restore fusb302_tcpm_set_vconn()
fusb302_tcpm_set_vconn() seems to exist in the upstream project,
but never made it into this parent, nor the Asahi one.
I can sort of understand why given the previous issues with it,
but we can now bring it back fron the dead.
Signed-off-by: Marc Zyngier <maz@kernel.org>
-rw-r--r-- | FUSB302.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -954,6 +954,38 @@ void fusb302_get_irq(int16_t port, int16_t *interrupt, int16_t *interrupta, int1 #endif } +int16_t fusb302_tcpm_set_vconn(int16_t port, int16_t enable) +{ + /* + * FUSB302 does not have dedicated VCONN Enable switch. + * We'll get through this by disabling both of the + * VCONN - CC* switches to disable, and enabling the + * saved polarity when enabling. + * Therefore at startup, set_polarity should be called first, + * or else live with the default put into init. + */ + int16_t reg; + + /* save enable state for later use */ + state[port].vconn_enabled = enable; + + if (enable) { + /* set to saved polarity */ + fusb302_tcpm_set_polarity(port, state[port].cc_polarity); + } else { + + tcpc_read(port, TCPC_REG_SWITCHES0, ®); + + /* clear VCONN switch bits */ + reg &= ~TCPC_REG_SWITCHES0_VCONN_CC1; + reg &= ~TCPC_REG_SWITCHES0_VCONN_CC2; + + tcpc_write(port, TCPC_REG_SWITCHES0, reg); + } + + return 0; +} + #if 0 /* For BIST receiving */ void tcpm_set_bist_test_data(int16_t port) |