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 * parse_spcr() - parse ACPI SPCR table and add preferred console
42 * @earlycon: set up earlycon for the console specified by the table
44 * For the architectures with support for ACPI, CONFIG_ACPI_SPCR_TABLE may be
45 * defined to parse ACPI SPCR table. As a result of the parsing preferred
46 * console is registered and if @earlycon is true, earlycon is set up.
48 * When CONFIG_ACPI_SPCR_TABLE is defined, this function should be called
49 * from arch initialization code as soon as the DT/ACPI decision is made.
52 int __init
parse_spcr(bool earlycon
)
55 struct acpi_table_spcr
*table
;
65 status
= acpi_get_table(ACPI_SIG_SPCR
, 0,
66 (struct acpi_table_header
**)&table
);
68 if (ACPI_FAILURE(status
))
71 if (table
->header
.revision
< 2) {
73 pr_err("wrong table version\n");
77 iotype
= table
->serial_port
.space_id
== ACPI_ADR_SPACE_SYSTEM_MEMORY
?
80 switch (table
->interface_type
) {
81 case ACPI_DBG2_ARM_SBSA_32BIT
:
84 case ACPI_DBG2_ARM_PL011
:
85 case ACPI_DBG2_ARM_SBSA_GENERIC
:
86 case ACPI_DBG2_BCM2835
:
89 case ACPI_DBG2_16550_COMPATIBLE
:
90 case ACPI_DBG2_16550_SUBSET
:
98 switch (table
->baud_rate
) {
116 if (qdf2400_erratum_44_present(&table
->header
))
117 uart
= "qdf2400_e44";
119 snprintf(opts
, sizeof(opts
), "%s,%s,0x%llx,%d", uart
, iotype
,
120 table
->serial_port
.address
, baud_rate
);
122 pr_info("console: %s\n", opts
);
125 setup_earlycon(opts
);
127 err
= add_preferred_console(uart
, 0, opts
+ strlen(uart
) + 1);
130 acpi_put_table((struct acpi_table_header
*)table
);