aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Zyngier <maz@kernel.org>2023-06-24 14:37:07 +0100
committerMarc Zyngier <maz@kernel.org>2023-06-24 14:37:07 +0100
commit02a0ee415d3e2f430dff2d351afb9c3f32cd6dd6 (patch)
treec5768c1372596f6de6d40d24e790aece04c0b10c
parent1398a1a011c59edcc27201189e052aff187b7de9 (diff)
downloadcs-sw-02a0ee415d3e2f430dff2d351afb9c3f32cd6dd6.tar.gz
Add support for USB2.0 routing
CSv3 has a switch allowing the routing of the USB2.0 pins to either the external USB (as for all th eprevious versions) or the serial lines (to support dumb cables). The switch is controlled by a GPIO, which needs to be set to the right level when claming the serial port. Signed-off-by: Marc Zyngier <maz@kernel.org>
-rw-r--r--m1-pd-bmc.h1
-rw-r--r--start.c10
-rw-r--r--vdmtool.c9
3 files changed, 18 insertions, 2 deletions
diff --git a/m1-pd-bmc.h b/m1-pd-bmc.h
index 6c08739..533ad34 100644
--- a/m1-pd-bmc.h
+++ b/m1-pd-bmc.h
@@ -26,6 +26,7 @@ enum m1_pd_bmc_pins {
UART_TX,
UART_RX,
SBU_SWAP,
+ SEL_USB,
};
struct hw_context {
diff --git a/start.c b/start.c
index 633e14b..de1335c 100644
--- a/start.c
+++ b/start.c
@@ -44,6 +44,11 @@ static const struct gpio_pin_config m1_pd_bmc_pin_config0[] = {
.mode = GPIO_FUNC_SIO,
.dir = GPIO_OUT,
},
+ [SEL_USB] = {
+ .pin = 7,
+ .mode = GPIO_FUNC_SIO,
+ .dir = GPIO_OUT,
+ },
};
static const struct gpio_pin_config m1_pd_bmc_pin_config1[] = {
@@ -84,6 +89,11 @@ static const struct gpio_pin_config m1_pd_bmc_pin_config1[] = {
.mode = GPIO_FUNC_SIO,
.dir = GPIO_OUT,
},
+ [SEL_USB] = {
+ .pin = 6,
+ .mode = GPIO_FUNC_SIO,
+ .dir = GPIO_OUT,
+ },
};
static void __not_in_flash_func(uart_irq_fn)(int port,
diff --git a/vdmtool.c b/vdmtool.c
index 4c5117b..251b4f4 100644
--- a/vdmtool.c
+++ b/vdmtool.c
@@ -425,7 +425,7 @@ static void vdm_claim_serial(struct vdm_context *cxt)
static const char *pinsets[] = {
"AltUSB", "PrimUSB", "SBU1/2",
};
- bool sbu_swap;
+ bool usb_serial, sbu_swap;
//uint32_t vdm[] = { 0x5ac8010 }; // Get Action List
//uint32_t vdm[] = { 0x5ac8012, 0x0105, 0x8002<<16 }; // PMU Reset + DFU Hold
@@ -442,9 +442,11 @@ static void vdm_claim_serial(struct vdm_context *cxt)
/* If using the SBU pins, swap the pins if using CC2. */
sbu_swap = (cxt->serial_pin_set == 2) ? cxt->cc_line : LOW;
+ usb_serial = (cxt->serial_pin_set == 1);
gpio_put(PIN(cxt, SBU_SWAP), sbu_swap);
- dprintf(cxt, "SBU_SWAP = %d\n", sbu_swap);
+ gpio_put(PIN(cxt, SEL_USB), usb_serial);
+ dprintf(cxt, "SBU_SWAP = %d, SEL_USB = %d\n", sbu_swap, usb_serial);
}
void vdm_send_reboot(struct vdm_context *cxt)
@@ -663,7 +665,10 @@ void m1_pd_bmc_fusb_setup(unsigned int port,
}
gpio_put(PIN(cxt, LED_G), HIGH);
+ /* No swapping */
gpio_put(PIN(cxt, SBU_SWAP), LOW);
+ /* USB2.0 pins routed to USB */
+ gpio_put(PIN(cxt, SEL_USB), LOW);
vbus_off(cxt);
tcpc_read(PORT(cxt), TCPC_REG_DEVICE_ID, &reg);