Commit 56e45ea4 authored by Andre Przywara's avatar Andre Przywara Committed by Will Deacon
Browse files

arm: fdt: add stdout-path to /chosen node



The DT spec describes the stdout-path property in the /chosen node to
contain the DT path for a default device usable for outputting characters.
The Linux kernel uses this for earlycon (without further parameters),
other DT users might rely on this as well.

Add a stdout-path property pointing to the "serial0" alias, then add an
aliases node at the end of the FDT, containing the actual path. This
allows the FDT generation code in hw/serial.c to set this string.

Even when we use the virtio console, the serial console is still there
and works, so we can expose this unconditionally. Putting the virtio
console path in there will not work anyway.
Signed-off-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 04d604b6
...@@ -142,6 +142,7 @@ static int setup_fdt(struct kvm *kvm) ...@@ -142,6 +142,7 @@ static int setup_fdt(struct kvm *kvm)
kvm->cfg.real_cmdline)); kvm->cfg.real_cmdline));
_FDT(fdt_property_u64(fdt, "kaslr-seed", kvm->cfg.arch.kaslr_seed)); _FDT(fdt_property_u64(fdt, "kaslr-seed", kvm->cfg.arch.kaslr_seed));
_FDT(fdt_property_string(fdt, "stdout-path", "serial0"));
/* Initrd */ /* Initrd */
if (kvm->arch.initrd_size != 0) { if (kvm->arch.initrd_size != 0) {
...@@ -207,6 +208,15 @@ static int setup_fdt(struct kvm *kvm) ...@@ -207,6 +208,15 @@ static int setup_fdt(struct kvm *kvm)
_FDT(fdt_property_cell(fdt, "migrate", fns->migrate)); _FDT(fdt_property_cell(fdt, "migrate", fns->migrate));
_FDT(fdt_end_node(fdt)); _FDT(fdt_end_node(fdt));
if (fdt_stdout_path) {
_FDT(fdt_begin_node(fdt, "aliases"));
_FDT(fdt_property_string(fdt, "serial0", fdt_stdout_path));
_FDT(fdt_end_node(fdt));
free(fdt_stdout_path);
fdt_stdout_path = NULL;
}
/* Finalise. */ /* Finalise. */
_FDT(fdt_end_node(fdt)); _FDT(fdt_end_node(fdt));
_FDT(fdt_finish(fdt)); _FDT(fdt_finish(fdt));
......
...@@ -366,6 +366,9 @@ static bool serial8250_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, ...@@ -366,6 +366,9 @@ static bool serial8250_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port,
} }
#ifdef CONFIG_HAS_LIBFDT #ifdef CONFIG_HAS_LIBFDT
char *fdt_stdout_path = NULL;
#define DEVICE_NAME_MAX_LEN 32 #define DEVICE_NAME_MAX_LEN 32
static static
void serial8250_generate_fdt_node(struct ioport *ioport, void *fdt, void serial8250_generate_fdt_node(struct ioport *ioport, void *fdt,
...@@ -383,6 +386,12 @@ void serial8250_generate_fdt_node(struct ioport *ioport, void *fdt, ...@@ -383,6 +386,12 @@ void serial8250_generate_fdt_node(struct ioport *ioport, void *fdt,
snprintf(dev_name, DEVICE_NAME_MAX_LEN, "U6_16550A@%llx", addr); snprintf(dev_name, DEVICE_NAME_MAX_LEN, "U6_16550A@%llx", addr);
if (!fdt_stdout_path) {
fdt_stdout_path = malloc(strlen(dev_name) + 2);
/* Assumes that this node is a child of the root node. */
sprintf(fdt_stdout_path, "/%s", dev_name);
}
_FDT(fdt_begin_node(fdt, dev_name)); _FDT(fdt_begin_node(fdt, dev_name));
_FDT(fdt_property_string(fdt, "compatible", "ns16550a")); _FDT(fdt_property_string(fdt, "compatible", "ns16550a"));
_FDT(fdt_property(fdt, "reg", reg_prop, sizeof(reg_prop))); _FDT(fdt_property(fdt, "reg", reg_prop, sizeof(reg_prop)));
......
...@@ -25,6 +25,8 @@ enum irq_type { ...@@ -25,6 +25,8 @@ enum irq_type {
IRQ_TYPE_LEVEL_MASK = (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH), IRQ_TYPE_LEVEL_MASK = (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH),
}; };
extern char *fdt_stdout_path;
/* Helper for the various bits of code that generate FDT nodes */ /* Helper for the various bits of code that generate FDT nodes */
#define _FDT(exp) \ #define _FDT(exp) \
do { \ do { \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment