Re: [kvm-unit-tests PATCH 1/7] lib: arm: Discover ns16550a UART

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 1/24/19 1:11 PM, Andrew Jones wrote:
On Thu, Jan 24, 2019 at 11:16:28AM +0000, Alexandru Elisei wrote:
Add support for discovering the ns16550a UART from the device tree. This
particular UART model is emulated by kvmtool.

Signed-off-by: Alexandru Elisei <alexandru.elisei@xxxxxxx>
---
  lib/arm/io.c | 18 +++++++++++-------
  1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/arm/io.c b/lib/arm/io.c
index d2c1a07c19ee..35fc05aeb4db 100644
--- a/lib/arm/io.c
+++ b/lib/arm/io.c
@@ -32,22 +32,26 @@ static volatile u8 *uart0_base = (u8 *)UART_EARLY_BASE;
static void uart0_init(void)
  {
-	const char *compatible = "arm,pl011";
+	const char *compatible[] = {"arm,pl011", "ns16550a"};
  	struct dt_pbus_reg base;
-	int ret;
+	int i, ret;
ret = dt_get_default_console_node();
  	assert(ret >= 0 || ret == -FDT_ERR_NOTFOUND);
if (ret == -FDT_ERR_NOTFOUND) { - ret = dt_pbus_get_base_compatible(compatible, &base);
-		assert(ret == 0 || ret == -FDT_ERR_NOTFOUND);
+		for (i = 0; i < ARRAY_SIZE(compatible); i++) {
+			ret = dt_pbus_get_base_compatible(compatible[i], &base);
+			assert(ret == 0 || ret == -FDT_ERR_NOTFOUND);
+
+			if (ret == 0)
+				break;
+		}
if (ret) {
-			printf("%s: %s not found in the device tree, "
-				"aborting...\n",
-				__func__, compatible);
+			printf("%s: Compatible UART not found in the device tree, "
+				"aborting...\n", __func__);
  			abort();
  		}
--
2.17.0

I agree with Andre that we should document this UART "driver" only ever
writes to the TX register. And that it assumes that TX register is at
the 0th offset.

Thanks,
drew
Sure, I'll write a comment documenting this behavior in the next version of the patches.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux