Allow selection of Primary USB as the serial pin set

Signed-off-by: Marc Zyngier <maz@kernel.org>
diff --git a/README.txt b/README.txt
index a7ac2c3..9e28cd0 100644
--- a/README.txt
+++ b/README.txt
@@ -88,6 +88,14 @@
 good results with cables designed to carry video signals, and USB3.1
 cables seem to do the trick.
 
+If you are stuck with a USB2.0 cable that doesn't have the SBU1/2
+signals, there is still a way to get a serial console by using the
+USB2.0 lines and connecting the SBU1 to USB_TX and SBU2 to USB_RX. On
+revision v2 of the board, this is only a matter of linking two sets of
+pins next to the micro-USB connector. In such a configuration, *DO NOT
+USE* the micro-USB connector *AT ALL* (put some tape or glue on it).
+If you don't know how to perform this change, please don't try.
+
 Because I'm lazy, the hardware only connects a single CC line to the
 board's PD controller, and there is no provision to swap TX and RX.
 Which means that on the board side, there is only a single valid
@@ -109,7 +117,8 @@
 
 Optionally, you can make use of the micro-USB connector that is on
 the other side of the board. It's main use it to allow interacting
-with the Asahi m1n1 firmware, such as tethered booting.
+with the Asahi m1n1 firmware, such as tethered booting. Do not connect
+it to anything if you use the USB2.0 lines as the serial console.
 
 ** Use it
 
diff --git a/m1-pd-bmc.h b/m1-pd-bmc.h
index d350c80..d93430a 100644
--- a/m1-pd-bmc.h
+++ b/m1-pd-bmc.h
@@ -46,7 +46,7 @@
 void usb_tx_str(int32_t port, char *ptr);
 int32_t usb_rx_byte(int32_t port);
 
-#define PRINTF_SIZE	256
+#define PRINTF_SIZE	512
 
 #define __printf(__p, __f, ...)	do {					\
 		char __str[PRINTF_SIZE];				\
diff --git a/vdmtool.c b/vdmtool.c
index 48926c4..1376ed8 100644
--- a/vdmtool.c
+++ b/vdmtool.c
@@ -405,6 +405,13 @@
 	fusb302_tcpm_transmit(PORT(cxt), TCPC_TX_SOP_DEBUG_PRIME_PRIME, hdr, vdm);
 }
 
+static void vdm_pd_reset(struct vdm_context *cxt)
+{
+	uint32_t vdm[] = { 0x5ac8012, 0x0103, 0x8000<<16 };
+	vdm_send_msg(cxt, vdm, ARRAY_SIZE(vdm));
+	cprintf(cxt, ">VDM SET ACTION PD reset\n");
+}
+
 static void vdm_claim_serial(struct vdm_context *cxt)
 {
 	static const char *pinsets[] = {
@@ -448,6 +455,8 @@
 		"^_ ^^ Central Scrutinizer reset to programming mode\n"
 		"^_ ^D Toggle debug\n"
 		"^_ ^M Send empty debug VDM\n"
+		"^_ 1  Serial on Primary USB pins\n"
+		"^_ 2  Serial on SBU pins\n"
 		"^_ ?  This message\n");
 	for (int i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++)
 		cprintf(cxt, "Port %d: %s\n",
@@ -497,6 +506,10 @@
 		case '\r':			/* Enter */
 			debug_poke(cxt);
 			break;
+		case '1' ... '2':
+			cxt->serial_pin_set = c - '0';
+			vdm_pd_reset(cxt);
+			break;
 		case '?':
 			help(cxt);
 			break;