diff options
-rw-r--r-- | board/servo_v4p1/board.c | 2 | ||||
-rw-r--r-- | board/servo_v4p1/build.mk | 1 | ||||
-rw-r--r-- | board/servo_v4p1/pathsel.c | 59 | ||||
-rw-r--r-- | board/servo_v4p1/pathsel.h | 44 |
4 files changed, 106 insertions, 0 deletions
diff --git a/board/servo_v4p1/board.c b/board/servo_v4p1/board.c index e9f0869a2e..cc6629547d 100644 --- a/board/servo_v4p1/board.c +++ b/board/servo_v4p1/board.c @@ -14,6 +14,7 @@ #include "hooks.h" #include "i2c.h" #include "ioexpanders.h" +#include "pathsel.h" #include "queue_policies.h" #include "registers.h" #include "spi.h" @@ -314,6 +315,7 @@ static void board_init(void) #ifdef SECTION_IS_RO init_uservo_port(); + init_pathsel(); /* Enable DUT USB2.0 pair. */ gpio_set_level(GPIO_FASTBOOT_DUTHUB_MUX_EN_L, 0); diff --git a/board/servo_v4p1/build.mk b/board/servo_v4p1/build.mk index 260e96f1f4..321c911871 100644 --- a/board/servo_v4p1/build.mk +++ b/board/servo_v4p1/build.mk @@ -19,5 +19,6 @@ board-y+=ioexpanders.o # These files are compiled into RO only board-ro+=ccd_measure_sbu.o +board-ro+=pathsel.o all_deps=$(patsubst ro,,$(def_all_deps)) diff --git a/board/servo_v4p1/pathsel.c b/board/servo_v4p1/pathsel.c new file mode 100644 index 0000000000..40100ce22a --- /dev/null +++ b/board/servo_v4p1/pathsel.c @@ -0,0 +1,59 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "gpio.h" +#include "ioexpanders.h" +#include "pathsel.h" + +void init_pathsel(void) +{ + /* Connect TypeA port to DUT hub */ + usb3_a0_to_dut(); + /* Connect data lines */ + usb3_a0_mux_en_l(0); + /* Enable power */ + usb3_a0_pwr_en(1); + + /* Connect TypeA port to DUT hub */ + usb3_a1_to_dut(); + /* Connect data lines */ + gpio_set_level(GPIO_USB3_A1_MUX_EN_L, 0); + /* Enable power */ + usb3_a1_pwr_en(1); +} + +void usb3_a0_to_dut(void) +{ + usb3_a0_mux_sel(1); + gpio_set_level(GPIO_FASTBOOT_DUTHUB_MUX_SEL, 1); +} + +void usb3_a1_to_dut(void) +{ + usb3_a1_mux_sel(1); + gpio_set_level(GPIO_FASTBOOT_DUTHUB_MUX_SEL, 1); +} + +void usb3_a0_to_host(void) +{ + usb3_a0_mux_sel(0); +} + +void usb3_a1_to_host(void) +{ + usb3_a1_mux_sel(0); +} + +void host_to_dut(void) +{ + gpio_set_level(GPIO_FASTBOOT_DUTHUB_MUX_SEL, 0); + uservo_fastboot_mux_sel(MUX_SEL_FASTBOOT); +} + +void uservo_to_host(void) +{ + gpio_set_level(GPIO_FASTBOOT_DUTHUB_MUX_SEL, 1); + uservo_fastboot_mux_sel(MUX_SEL_USERVO); +} diff --git a/board/servo_v4p1/pathsel.h b/board/servo_v4p1/pathsel.h new file mode 100644 index 0000000000..d2f71be024 --- /dev/null +++ b/board/servo_v4p1/pathsel.h @@ -0,0 +1,44 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __CROS_EC_PATHSEL_H +#define __CROS_EC_PATHSEL_H + +/** + * Both USB3_TypeA0 and USB3_TypeA1 are routed to the DUT by default. + */ +void init_pathsel(void); + +/** + * Routes USB3_TypeA0 port to DUT + */ +void usb3_a0_to_dut(void); + +/** + * Routes USB3_TypeA1 port to DUT + */ +void usb3_a1_to_dut(void); + +/** + * Routes USB3_TypeA0 port to HOST + */ +void usb3_a0_to_host(void); + +/** + * Routes USB3_TypeA1 port to HOST + */ +void usb3_a1_to_host(void); + +/** + * Routes the HOST to the DUT. Used for fastboot + */ +void host_to_dut(void); + +/** + * Routes the Micro Servo to the Host + */ +void uservo_to_host(void); + +#endif /* __CROS_EC_PATHSEL_H */ |