summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/glados/board.c5
-rw-r--r--board/honeybuns/usb_mux.c5
-rw-r--r--board/kunimitsu/board.c5
-rw-r--r--board/oak/board.c26
-rw-r--r--board/ryu/board.c17
-rw-r--r--board/samus_pd/board.c20
-rw-r--r--board/strago/board.c5
-rw-r--r--common/usb_charger.c22
-rw-r--r--driver/usb_mux.c4
-rw-r--r--include/usb_charge.h15
-rw-r--r--include/usb_mux.h1
-rw-r--r--include/usb_pd.h14
12 files changed, 40 insertions, 99 deletions
diff --git a/board/glados/board.c b/board/glados/board.c
index c90c307364..fe7773d085 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -176,11 +176,6 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
}
};
-void board_set_usb_switches(int port, enum usb_switch setting)
-{
- /* TODO: Set open / close USB switches based on param */
-}
-
/**
* Reset PD MCU
*/
diff --git a/board/honeybuns/usb_mux.c b/board/honeybuns/usb_mux.c
index ea8a56910f..4b4938e9ef 100644
--- a/board/honeybuns/usb_mux.c
+++ b/board/honeybuns/usb_mux.c
@@ -10,11 +10,6 @@
#include "usb_mux.h"
#include "util.h"
-void board_set_usb_switches(int port, enum usb_switch setting)
-{
- /* Not implemented */
-}
-
static int board_init_usb_mux(int port)
{
return EC_SUCCESS;
diff --git a/board/kunimitsu/board.c b/board/kunimitsu/board.c
index 39b385422b..e9cade936f 100644
--- a/board/kunimitsu/board.c
+++ b/board/kunimitsu/board.c
@@ -171,11 +171,6 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
}
};
-void board_set_usb_switches(int port, enum usb_switch setting)
-{
- /* TODO: Set open / close USB switches based on param */
-}
-
/**
* Reset PD MCU
*/
diff --git a/board/oak/board.c b/board/oak/board.c
index 8893ed17fc..5468ae61a3 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -161,13 +161,6 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
};
/**
- * Store the state of our USB data switches so that they can be restored
- * after pericom reset.
- */
-static int usb_switch_state[CONFIG_USB_PD_PORT_COUNT];
-static struct mutex usb_switch_lock[CONFIG_USB_PD_PORT_COUNT];
-
-/**
* Store the current DP hardware route.
*/
static int dp_hw_port = PD_PORT_NONE;
@@ -301,25 +294,6 @@ void board_set_charge_limit(int charge_ma)
CONFIG_CHARGER_INPUT_CURRENT));
}
-/**
- * Set type-C port USB2.0 switch state.
- *
- * @param port the type-C port to change
- * @param setting enum usb_switch
- */
-void board_set_usb_switches(int port, enum usb_switch setting)
-{
- /* If switch is not charging, then return */
- if (setting == usb_switch_state[port])
- return;
-
- mutex_lock(&usb_switch_lock[port]);
- if (setting != USB_SWITCH_RESTORE)
- usb_switch_state[port] = setting;
- pi3usb9281_set_switches(port, usb_switch_state[port]);
- mutex_unlock(&usb_switch_lock[port]);
-}
-
static void hpd_irq_deferred(void)
{
gpio_set_level(GPIO_USB_DP_HPD, 1);
diff --git a/board/ryu/board.c b/board/ryu/board.c
index d92e89d9b2..ad1f5788b6 100644
--- a/board/ryu/board.c
+++ b/board/ryu/board.c
@@ -58,12 +58,6 @@ static int charge_current_limit;
*/
static struct ec_response_host_event_status host_event_status __aligned(4);
-/*
- * Store the state of our USB data switches so that they can be restored
- * after pericom reset.
- */
-static int usb_switch_state;
-
static void vbus_log(void)
{
CPRINTS("VBUS %d", gpio_get_level(GPIO_CHGR_ACOK));
@@ -373,17 +367,6 @@ struct motion_sensor_t motion_sensors[] = {
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
-void board_set_usb_switches(int port, enum usb_switch setting)
-{
- /* If switch is not changing, then return */
- if (setting == usb_switch_state)
- return;
-
- if (setting != USB_SWITCH_RESTORE)
- usb_switch_state = setting;
- pi3usb9281_set_switches(port, usb_switch_state);
-}
-
int extpower_is_present(void)
{
return gpio_get_level(GPIO_CHGR_ACOK);
diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c
index e1941cabbe..eb2273121b 100644
--- a/board/samus_pd/board.c
+++ b/board/samus_pd/board.c
@@ -62,13 +62,6 @@ static struct ec_response_host_event_status host_event_status __aligned(4);
/* Desired input current limit */
static int desired_charge_rate_ma = -1;
-/*
- * Store the state of our USB data switches so that they can be restored
- * after pericom reset.
- */
-static int usb_switch_state[CONFIG_USB_PD_PORT_COUNT];
-static struct mutex usb_switch_lock[CONFIG_USB_PD_PORT_COUNT];
-
/* PWM channels. Must be in the exact same order as in enum pwm_channel. */
const struct pwm_t pwm_channels[] = {
{STM32_TIM(15), STM32_TIM_CH(2), 0, GPIO_ILIM_ADJ_PWM, GPIO_ALT_F1},
@@ -391,19 +384,6 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-void board_set_usb_switches(int port, enum usb_switch setting)
-{
- /* If switch is not changing then return */
- if (setting == usb_switch_state[port])
- return;
-
- mutex_lock(&usb_switch_lock[port]);
- if (setting != USB_SWITCH_RESTORE)
- usb_switch_state[port] = setting;
- pi3usb9281_set_switches(port, usb_switch_state[port]);
- mutex_unlock(&usb_switch_lock[port]);
-}
-
int board_get_battery_soc(void)
{
return batt_soc;
diff --git a/board/strago/board.c b/board/strago/board.c
index 63bd12b66b..a2c5b75992 100644
--- a/board/strago/board.c
+++ b/board/strago/board.c
@@ -198,11 +198,6 @@ const struct button_config buttons[] = {
};
BUILD_ASSERT(ARRAY_SIZE(buttons) == CONFIG_BUTTON_COUNT);
-void board_set_usb_switches(int port, enum usb_switch setting)
-{
- /* TODO: Set open / close USB switches based on param */
-}
-
/**
* Reset PD MCU
*/
diff --git a/common/usb_charger.c b/common/usb_charger.c
index 468d2c97af..de81ad0497 100644
--- a/common/usb_charger.c
+++ b/common/usb_charger.c
@@ -27,6 +27,13 @@
*/
#define USB_CHG_RESET_DELAY_MS 100
+/*
+ * Store the state of our USB data switches so that they can be restored
+ * after pericom reset.
+ */
+static int usb_switch_state[CONFIG_USB_PD_PORT_COUNT];
+static struct mutex usb_switch_lock[CONFIG_USB_PD_PORT_COUNT];
+
int usb_charger_port_is_sourcing_vbus(int port)
{
if (port == 0)
@@ -39,6 +46,19 @@ int usb_charger_port_is_sourcing_vbus(int port)
return 0;
}
+void usb_charger_set_switches(int port, enum usb_switch setting)
+{
+ /* If switch is not changing then return */
+ if (setting == usb_switch_state[port])
+ return;
+
+ mutex_lock(&usb_switch_lock[port]);
+ if (setting != USB_SWITCH_RESTORE)
+ usb_switch_state[port] = setting;
+ pi3usb9281_set_switches(port, usb_switch_state[port]);
+ mutex_unlock(&usb_switch_lock[port]);
+}
+
void usb_charger_task(void)
{
int port = (task_get_current() == TASK_ID_USB_CHG_P0 ? 0 : 1);
@@ -89,7 +109,7 @@ void usb_charger_task(void)
* Restore data switch settings - switches return to
* closed on reset until restored.
*/
- board_set_usb_switches(port, USB_SWITCH_RESTORE);
+ usb_charger_set_switches(port, USB_SWITCH_RESTORE);
/* Clear possible disconnect interrupt */
pi3usb9281_get_interrupts(port);
/* Mask attach interrupt */
diff --git a/driver/usb_mux.c b/driver/usb_mux.c
index 04427f7615..a067fc1c25 100644
--- a/driver/usb_mux.c
+++ b/driver/usb_mux.c
@@ -37,8 +37,10 @@ void usb_mux_set(int port, enum typec_mux mux_mode,
int res;
mux_state_t mux_state;
+#ifdef CONFIG_USB_CHARGER
/* Configure USB2.0 */
- board_set_usb_switches(port, usb_mode);
+ usb_charger_set_switches(port, usb_mode);
+#endif
/* Configure superspeed lanes */
mux_state = polarity ? mux_mode | MUX_POLARITY_INVERTED : mux_mode;
diff --git a/include/usb_charge.h b/include/usb_charge.h
index c10ae8d5b4..60f2c9742c 100644
--- a/include/usb_charge.h
+++ b/include/usb_charge.h
@@ -55,4 +55,19 @@ int usb_charge_ports_enabled(void);
*/
int usb_charger_port_is_sourcing_vbus(int port);
+enum usb_switch {
+ USB_SWITCH_CONNECT,
+ USB_SWITCH_DISCONNECT,
+ USB_SWITCH_RESTORE,
+};
+
+/**
+ * Configure USB data switches on type-C port.
+ *
+ * @param port port number.
+ * @param setting new switch setting to configure.
+ */
+void usb_charger_set_switches(int port, enum usb_switch setting);
+
+
#endif /* __CROS_EC_USB_CHARGE_H */
diff --git a/include/usb_mux.h b/include/usb_mux.h
index d94c0c4606..3cb5c4e49d 100644
--- a/include/usb_mux.h
+++ b/include/usb_mux.h
@@ -8,6 +8,7 @@
#ifndef __CROS_EC_USB_MUX_H
#define __CROS_EC_USB_MUX_H
+#include "usb_charge.h"
#include "usb_pd.h"
/* USB-C mux state */
diff --git a/include/usb_pd.h b/include/usb_pd.h
index b25eca3ebc..5b42b687e0 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -1191,20 +1191,6 @@ extern const int pd_snk_pdo_cnt;
*/
int pd_get_source_pdo(const uint32_t **src_pdo);
-enum usb_switch {
- USB_SWITCH_CONNECT,
- USB_SWITCH_DISCONNECT,
- USB_SWITCH_RESTORE,
-};
-
-/**
- * Configure USB data switches on type-C port.
- *
- * @param port port number.
- * @param setting new switch setting to configure.
- */
-void board_set_usb_switches(int port, enum usb_switch setting);
-
/**
* Request that a host event be sent to notify the AP of a PD power event.
*