From 3f09060dc73714ca26b1ee5e9fdbe9c4c66c2b7b Mon Sep 17 00:00:00 2001 From: Stewart Hildebrand Date: Thu, 11 Mar 2021 12:14:30 -0500 Subject: [PATCH] Cadence: initialize from device tree Add runtime map for Cadence UART Signed-off-by: Stewart Hildebrand Message-Id: <20210311171431.31417-4-stewart.hildebrand@dornerworks.com> --- arch/aarch64/arch-setup.cc | 17 +++++++++++++++++ arch/aarch64/early-console.hh | 2 ++ 2 files changed, 19 insertions(+) diff --git a/arch/aarch64/arch-setup.cc b/arch/aarch64/arch-setup.cc index e22b4ea49c..fd2103b788 100644 --- a/arch/aarch64/arch-setup.cc +++ b/arch/aarch64/arch-setup.cc @@ -100,6 +100,13 @@ void arch_setup_free_memory() mmu::mattr::dev); } + if (console::Cadence_Console::active) { + // linear_map [TTBR0 - UART] + addr = (mmu::phys)console::aarch64_console.cadence.get_base_addr(); + mmu::linear_map((void *)addr, addr, 0x1000, mmu::page_size, + mmu::mattr::dev); + } + /* linear_map [TTBR0 - GIC DIST and GIC CPU] */ u64 dist, cpu; size_t dist_len, cpu_len; @@ -211,6 +218,16 @@ void arch_init_early_console() return; } + mmio_serial_address = dtb_get_cadence_uart(&irqid); + if (mmio_serial_address) { + new (&console::aarch64_console.cadence) console::Cadence_Console(); + console::arch_early_console = console::aarch64_console.cadence; + console::aarch64_console.cadence.set_base_addr(mmio_serial_address); + console::aarch64_console.cadence.set_irqid(irqid); + console::Cadence_Console::active = true; + return; + } + new (&console::aarch64_console.pl011) console::PL011_Console(); console::arch_early_console = console::aarch64_console.pl011; console::PL011_Console::active = true; diff --git a/arch/aarch64/early-console.hh b/arch/aarch64/early-console.hh index 6ecedc0e9a..74cf36a709 100644 --- a/arch/aarch64/early-console.hh +++ b/arch/aarch64/early-console.hh @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -18,6 +19,7 @@ namespace console { union AARCH64_Console { PL011_Console pl011; + Cadence_Console cadence; XEN_Console xen; mmio_isa_serial_console isa_serial;