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 * Some Qualcomm Datacenter Technologies SoCs have a defective UART BUSY bit.
21 * Detect them by examining the OEM fields in the SPCR header, similiar to PCI
22 * quirk detection in pci_mcfg.c.
24 static bool qdf2400_erratum_44_present(struct acpi_table_header
*h
)
26 if (memcmp(h
->oem_id
, "QCOM ", ACPI_OEM_ID_SIZE
))
29 if (!memcmp(h
->oem_table_id
, "QDF2432 ", ACPI_OEM_TABLE_ID_SIZE
))
32 if (!memcmp(h
->oem_table_id
, "QDF2400 ", ACPI_OEM_TABLE_ID_SIZE
) &&
40 * APM X-Gene v1 and v2 UART hardware is an 16550 like device but has its
41 * register aligned to 32-bit. In addition, the BIOS also encoded the
42 * access width to be 8 bits. This function detects this errata condition.
44 static bool xgene_8250_erratum_present(struct acpi_table_spcr
*tb
)
46 if (tb
->interface_type
!= ACPI_DBG2_16550_COMPATIBLE
)
49 if (memcmp(tb
->header
.oem_id
, "APMC0D", ACPI_OEM_ID_SIZE
))
52 if (!memcmp(tb
->header
.oem_table_id
, "XGENESPC",
53 ACPI_OEM_TABLE_ID_SIZE
) && tb
->header
.oem_revision
== 0)
60 * parse_spcr() - parse ACPI SPCR table and add preferred console
62 * @earlycon: set up earlycon for the console specified by the table
64 * For the architectures with support for ACPI, CONFIG_ACPI_SPCR_TABLE may be
65 * defined to parse ACPI SPCR table. As a result of the parsing preferred
66 * console is registered and if @earlycon is true, earlycon is set up.
68 * When CONFIG_ACPI_SPCR_TABLE is defined, this function should be called
69 * from arch initialization code as soon as the DT/ACPI decision is made.
72 int __init
parse_spcr(bool earlycon
)
75 struct acpi_table_spcr
*table
;
85 status
= acpi_get_table(ACPI_SIG_SPCR
, 0,
86 (struct acpi_table_header
**)&table
);
88 if (ACPI_FAILURE(status
))
91 if (table
->header
.revision
< 2) {
93 pr_err("wrong table version\n");
97 if (table
->serial_port
.space_id
== ACPI_ADR_SPACE_SYSTEM_MEMORY
) {
98 switch (table
->serial_port
.access_width
) {
100 pr_err("Unexpected SPCR Access Width. Defaulting to byte size\n");
101 case ACPI_ACCESS_SIZE_BYTE
:
104 case ACPI_ACCESS_SIZE_WORD
:
107 case ACPI_ACCESS_SIZE_DWORD
:
114 switch (table
->interface_type
) {
115 case ACPI_DBG2_ARM_SBSA_32BIT
:
118 case ACPI_DBG2_ARM_PL011
:
119 case ACPI_DBG2_ARM_SBSA_GENERIC
:
120 case ACPI_DBG2_BCM2835
:
123 case ACPI_DBG2_16550_COMPATIBLE
:
124 case ACPI_DBG2_16550_SUBSET
:
132 switch (table
->baud_rate
) {
150 if (qdf2400_erratum_44_present(&table
->header
))
151 uart
= "qdf2400_e44";
152 if (xgene_8250_erratum_present(table
))
155 snprintf(opts
, sizeof(opts
), "%s,%s,0x%llx,%d", uart
, iotype
,
156 table
->serial_port
.address
, baud_rate
);
158 pr_info("console: %s\n", opts
);
161 setup_earlycon(opts
);
163 err
= add_preferred_console(uart
, 0, opts
+ strlen(uart
) + 1);
166 acpi_put_table((struct acpi_table_header
*)table
);