Control tests on RPi over UART

Select the 'ctrl_uart' hftest driver for Raspberry Pi 4. Implement
plat_console_get_char() to support reading the test arguments from
MiniUART.

Change-Id: I36901875a1f244638e9a6bad61f17d8977c9571b
diff --git a/BUILD.gn b/BUILD.gn
index 4a5acf0..f25e246 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -100,6 +100,7 @@
     gpio_base_address = "0xfe200000"
     aux_base_address = "0xfe215000"
     core_freq_mhz = 500
+    hftest_ctrl = "//test/hftest:ctrl_uart"
   }
 }
 
diff --git a/rpi/mini_uart.c b/rpi/mini_uart.c
index 79d5a60..cb23ce6 100644
--- a/rpi/mini_uart.c
+++ b/rpi/mini_uart.c
@@ -112,3 +112,13 @@
 	while ((io_read32(AUX_MU_LSR_REG) & AUX_MU_LSR_TX_IDLE) == 0) {
 	}
 }
+
+char plat_console_getchar(void)
+{
+	/* Wait for the transmitter to be ready to deliver a byte. */
+	while (!(io_read32(AUX_MU_LSR_REG) & 0x1)) {
+	}
+
+	/* Read data from transmitter FIFO. */
+	return (char)(io_read32(AUX_MU_IO_REG) & 0xff);
+}