2 * Parse the EFI PCDP table to locate the console device.
4 * (c) Copyright 2002, 2003, 2004 Hewlett-Packard Development Company, L.P.
5 * Khalid Aziz <khalid.aziz@hp.com>
6 * Alex Williamson <alex.williamson@hp.com>
7 * Bjorn Helgaas <bjorn.helgaas@hp.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/acpi.h>
15 #include <linux/console.h>
16 #include <linux/efi.h>
17 #include <linux/serial.h>
18 #include <linux/serial_8250.h>
23 setup_serial_console(struct pcdp_uart
*uart
)
25 #ifdef CONFIG_SERIAL_8250_CONSOLE
27 static char options
[64], *p
= options
;
30 mmio
= (uart
->addr
.space_id
== ACPI_ADR_SPACE_SYSTEM_MEMORY
);
31 p
+= sprintf(p
, "uart8250,%s,0x%llx",
32 mmio
? "mmio" : "io", uart
->addr
.address
);
34 p
+= sprintf(p
, ",%llu", uart
->baud
);
36 switch (uart
->parity
) {
37 case 0x2: parity
= 'e'; break;
38 case 0x3: parity
= 'o'; break;
39 default: parity
= 'n';
41 p
+= sprintf(p
, "%c%d", parity
, uart
->bits
);
45 add_preferred_console("uart", 8250, &options
[9]);
46 return setup_early_serial8250_console(options
);
53 setup_vga_console(struct pcdp_device
*dev
)
55 #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
58 if_ptr
= ((u8
*)dev
+ sizeof(struct pcdp_device
));
59 if (if_ptr
[0] == PCDP_IF_PCI
) {
60 struct pcdp_if_pci if_pci
;
62 /* struct copy since ifptr might not be correctly aligned */
64 memcpy(&if_pci
, if_ptr
, sizeof(if_pci
));
66 if (if_pci
.trans
& PCDP_PCI_TRANS_IOPORT
)
67 vga_console_iobase
= if_pci
.ioport_tra
;
69 if (if_pci
.trans
& PCDP_PCI_TRANS_MMIO
)
70 vga_console_membase
= if_pci
.mmio_tra
;
73 if (efi_mem_type(vga_console_membase
+ 0xA0000) == EFI_CONVENTIONAL_MEMORY
) {
74 printk(KERN_ERR
"PCDP: VGA selected, but frame buffer is not MMIO!\n");
78 conswitchp
= &vga_con
;
79 printk(KERN_INFO
"PCDP: VGA console\n");
87 efi_setup_pcdp_console(char *cmdline
)
90 struct pcdp_uart
*uart
;
91 struct pcdp_device
*dev
, *end
;
95 if (efi
.hcdp
== EFI_INVALID_TABLE_ADDR
)
98 pcdp
= ioremap(efi
.hcdp
, 4096);
99 printk(KERN_INFO
"PCDP: v%d at 0x%lx\n", pcdp
->rev
, efi
.hcdp
);
101 if (strstr(cmdline
, "console=hcdp")) {
104 } else if (strstr(cmdline
, "console=")) {
105 printk(KERN_INFO
"Explicit \"console=\"; ignoring PCDP\n");
109 if (pcdp
->rev
< 3 && efi_uart_console_only())
112 for (i
= 0, uart
= pcdp
->uart
; i
< pcdp
->num_uarts
; i
++, uart
++) {
113 if (uart
->flags
& PCDP_UART_PRIMARY_CONSOLE
|| serial
) {
114 if (uart
->type
== PCDP_CONSOLE_UART
) {
115 rc
= setup_serial_console(uart
);
121 end
= (struct pcdp_device
*) ((u8
*) pcdp
+ pcdp
->length
);
122 for (dev
= (struct pcdp_device
*) (pcdp
->uart
+ pcdp
->num_uarts
);
124 dev
= (struct pcdp_device
*) ((u8
*) dev
+ dev
->length
)) {
125 if (dev
->flags
& PCDP_PRIMARY_CONSOLE
) {
126 if (dev
->type
== PCDP_CONSOLE_VGA
) {
127 rc
= setup_vga_console(dev
);