Auto merge with /home/aegl/GIT/ia64-test
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / firmware / pcdp.c
CommitLineData
1da177e4
LT
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
97d3a00f 14#include <linux/config.h>
1da177e4
LT
15#include <linux/acpi.h>
16#include <linux/console.h>
17#include <linux/efi.h>
18#include <linux/serial.h>
19#include "pcdp.h"
20
21static int __init
22setup_serial_console(struct pcdp_uart *uart)
23{
24#ifdef CONFIG_SERIAL_8250_CONSOLE
25 int mmio;
280dedb8 26 static char options[64], *p = options;
1da177e4
LT
27
28 mmio = (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY);
280dedb8
BH
29 p += sprintf(p, "console=uart,%s,0x%lx",
30 mmio ? "mmio" : "io", uart->addr.address);
31 if (uart->baud)
32 p += sprintf(p, ",%lu", uart->baud);
33 if (uart->bits)
34 p += sprintf(p, "n%d", uart->bits);
1da177e4
LT
35
36 return early_serial_console_init(options);
37#else
38 return -ENODEV;
39#endif
40}
41
42static int __init
43setup_vga_console(struct pcdp_vga *vga)
44{
45#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
46 if (efi_mem_type(0xA0000) == EFI_CONVENTIONAL_MEMORY) {
47 printk(KERN_ERR "PCDP: VGA selected, but frame buffer is not MMIO!\n");
48 return -ENODEV;
49 }
50
51 conswitchp = &vga_con;
52 printk(KERN_INFO "PCDP: VGA console\n");
53 return 0;
54#else
55 return -ENODEV;
56#endif
57}
58
59int __init
60efi_setup_pcdp_console(char *cmdline)
61{
62 struct pcdp *pcdp;
63 struct pcdp_uart *uart;
64 struct pcdp_device *dev, *end;
65 int i, serial = 0;
66
67 pcdp = efi.hcdp;
68 if (!pcdp)
69 return -ENODEV;
70
71 printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, __pa(pcdp));
72
73 if (strstr(cmdline, "console=hcdp")) {
74 if (pcdp->rev < 3)
75 serial = 1;
76 } else if (strstr(cmdline, "console=")) {
77 printk(KERN_INFO "Explicit \"console=\"; ignoring PCDP\n");
78 return -ENODEV;
79 }
80
81 if (pcdp->rev < 3 && efi_uart_console_only())
82 serial = 1;
83
84 for (i = 0, uart = pcdp->uart; i < pcdp->num_uarts; i++, uart++) {
85 if (uart->flags & PCDP_UART_PRIMARY_CONSOLE || serial) {
86 if (uart->type == PCDP_CONSOLE_UART) {
87 return setup_serial_console(uart);
88 }
89 }
90 }
91
92 end = (struct pcdp_device *) ((u8 *) pcdp + pcdp->length);
93 for (dev = (struct pcdp_device *) (pcdp->uart + pcdp->num_uarts);
94 dev < end;
95 dev = (struct pcdp_device *) ((u8 *) dev + dev->length)) {
96 if (dev->flags & PCDP_PRIMARY_CONSOLE) {
97 if (dev->type == PCDP_CONSOLE_VGA) {
98 return setup_vga_console((struct pcdp_vga *) dev);
99 }
100 }
101 }
102
103 return -ENODEV;
104}