aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware/pcdp.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/firmware/pcdp.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/firmware/pcdp.c')
-rw-r--r--drivers/firmware/pcdp.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/drivers/firmware/pcdp.c b/drivers/firmware/pcdp.c
new file mode 100644
index 000000000000..6d5df6c2efa2
--- /dev/null
+++ b/drivers/firmware/pcdp.c
@@ -0,0 +1,100 @@
1/*
2 * Parse the EFI PCDP table to locate the console device.
3 *
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>
8 *
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.
12 */
13
14#include <linux/acpi.h>
15#include <linux/console.h>
16#include <linux/efi.h>
17#include <linux/serial.h>
18#include "pcdp.h"
19
20static int __init
21setup_serial_console(struct pcdp_uart *uart)
22{
23#ifdef CONFIG_SERIAL_8250_CONSOLE
24 int mmio;
25 static char options[64];
26
27 mmio = (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY);
28 snprintf(options, sizeof(options), "console=uart,%s,0x%lx,%lun%d",
29 mmio ? "mmio" : "io", uart->addr.address, uart->baud,
30 uart->bits ? uart->bits : 8);
31
32 return early_serial_console_init(options);
33#else
34 return -ENODEV;
35#endif
36}
37
38static int __init
39setup_vga_console(struct pcdp_vga *vga)
40{
41#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
42 if (efi_mem_type(0xA0000) == EFI_CONVENTIONAL_MEMORY) {
43 printk(KERN_ERR "PCDP: VGA selected, but frame buffer is not MMIO!\n");
44 return -ENODEV;
45 }
46
47 conswitchp = &vga_con;
48 printk(KERN_INFO "PCDP: VGA console\n");
49 return 0;
50#else
51 return -ENODEV;
52#endif
53}
54
55int __init
56efi_setup_pcdp_console(char *cmdline)
57{
58 struct pcdp *pcdp;
59 struct pcdp_uart *uart;
60 struct pcdp_device *dev, *end;
61 int i, serial = 0;
62
63 pcdp = efi.hcdp;
64 if (!pcdp)
65 return -ENODEV;
66
67 printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, __pa(pcdp));
68
69 if (strstr(cmdline, "console=hcdp")) {
70 if (pcdp->rev < 3)
71 serial = 1;
72 } else if (strstr(cmdline, "console=")) {
73 printk(KERN_INFO "Explicit \"console=\"; ignoring PCDP\n");
74 return -ENODEV;
75 }
76
77 if (pcdp->rev < 3 && efi_uart_console_only())
78 serial = 1;
79
80 for (i = 0, uart = pcdp->uart; i < pcdp->num_uarts; i++, uart++) {
81 if (uart->flags & PCDP_UART_PRIMARY_CONSOLE || serial) {
82 if (uart->type == PCDP_CONSOLE_UART) {
83 return setup_serial_console(uart);
84 }
85 }
86 }
87
88 end = (struct pcdp_device *) ((u8 *) pcdp + pcdp->length);
89 for (dev = (struct pcdp_device *) (pcdp->uart + pcdp->num_uarts);
90 dev < end;
91 dev = (struct pcdp_device *) ((u8 *) dev + dev->length)) {
92 if (dev->flags & PCDP_PRIMARY_CONSOLE) {
93 if (dev->type == PCDP_CONSOLE_VGA) {
94 return setup_vga_console((struct pcdp_vga *) dev);
95 }
96 }
97 }
98
99 return -ENODEV;
100}