2 * Copyright (c) 2012, Intel Corporation
3 * Copyright (c) 2015, Red Hat, Inc.
4 * Copyright (c) 2015, 2016 Linaro Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
12 #define pr_fmt(fmt) "ACPI: SPCR: " fmt
14 #include <linux/acpi.h>
15 #include <linux/console.h>
16 #include <linux/kernel.h>
17 #include <linux/serial_core.h>
20 * parse_spcr() - parse ACPI SPCR table and add preferred console
22 * @earlycon: set up earlycon for the console specified by the table
24 * For the architectures with support for ACPI, CONFIG_ACPI_SPCR_TABLE may be
25 * defined to parse ACPI SPCR table. As a result of the parsing preferred
26 * console is registered and if @earlycon is true, earlycon is set up.
28 * When CONFIG_ACPI_SPCR_TABLE is defined, this function should be called
29 * from arch inintialization code as soon as the DT/ACPI decision is made.
32 int __init
parse_spcr(bool earlycon
)
35 struct acpi_table_spcr
*table
;
46 status
= acpi_get_table_with_size(ACPI_SIG_SPCR
, 0,
47 (struct acpi_table_header
**)&table
,
50 if (ACPI_FAILURE(status
))
53 if (table
->header
.revision
< 2) {
55 pr_err("wrong table version\n");
59 iotype
= table
->serial_port
.space_id
== ACPI_ADR_SPACE_SYSTEM_MEMORY
?
62 switch (table
->interface_type
) {
63 case ACPI_DBG2_ARM_SBSA_32BIT
:
66 case ACPI_DBG2_ARM_PL011
:
67 case ACPI_DBG2_ARM_SBSA_GENERIC
:
68 case ACPI_DBG2_BCM2835
:
71 case ACPI_DBG2_16550_COMPATIBLE
:
72 case ACPI_DBG2_16550_SUBSET
:
80 switch (table
->baud_rate
) {
98 snprintf(opts
, sizeof(opts
), "%s,%s,0x%llx,%d", uart
, iotype
,
99 table
->serial_port
.address
, baud_rate
);
101 pr_info("console: %s\n", opts
);
104 setup_earlycon(opts
);
106 err
= add_preferred_console(uart
, 0, opts
+ strlen(uart
) + 1);
109 early_acpi_os_unmap_memory((void __iomem
*)table
, table_size
);