Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 1 | #include <linux/kernel.h> |
| 2 | #include <linux/serial.h> |
| 3 | #include <linux/serial_8250.h> |
| 4 | #include <linux/serial_core.h> |
| 5 | #include <linux/console.h> |
| 6 | #include <linux/pci.h> |
Grant Likely | 22ae782 | 2010-07-29 11:49:01 -0600 | [diff] [blame] | 7 | #include <linux/of_address.h> |
Paul Gortmaker | 1a7507c | 2008-01-24 11:59:12 -0500 | [diff] [blame] | 8 | #include <linux/of_device.h> |
Arnd Bergmann | 7df5659 | 2011-06-27 11:45:16 +0000 | [diff] [blame] | 9 | #include <linux/serial_reg.h> |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 10 | #include <asm/io.h> |
| 11 | #include <asm/mmu.h> |
| 12 | #include <asm/prom.h> |
| 13 | #include <asm/serial.h> |
| 14 | #include <asm/udbg.h> |
| 15 | #include <asm/pci-bridge.h> |
| 16 | #include <asm/ppc-pci.h> |
| 17 | |
| 18 | #undef DEBUG |
| 19 | |
| 20 | #ifdef DEBUG |
| 21 | #define DBG(fmt...) do { printk(fmt); } while(0) |
| 22 | #else |
| 23 | #define DBG(fmt...) do { } while(0) |
| 24 | #endif |
| 25 | |
| 26 | #define MAX_LEGACY_SERIAL_PORTS 8 |
| 27 | |
| 28 | static struct plat_serial8250_port |
| 29 | legacy_serial_ports[MAX_LEGACY_SERIAL_PORTS+1]; |
| 30 | static struct legacy_serial_info { |
| 31 | struct device_node *np; |
| 32 | unsigned int speed; |
| 33 | unsigned int clock; |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 34 | int irq_check_parent; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 35 | phys_addr_t taddr; |
| 36 | } legacy_serial_infos[MAX_LEGACY_SERIAL_PORTS]; |
Paul Gortmaker | 1a7507c | 2008-01-24 11:59:12 -0500 | [diff] [blame] | 37 | |
Benjamin Herrenschmidt | 3bc5ab9 | 2008-07-07 16:39:50 +1000 | [diff] [blame] | 38 | static struct __initdata of_device_id legacy_serial_parents[] = { |
Paul Gortmaker | 1a7507c | 2008-01-24 11:59:12 -0500 | [diff] [blame] | 39 | {.type = "soc",}, |
| 40 | {.type = "tsi-bridge",}, |
Michael Ellerman | f5903ed | 2008-02-05 23:01:50 +1100 | [diff] [blame] | 41 | {.type = "opb", }, |
| 42 | {.compatible = "ibm,opb",}, |
Paul Gortmaker | 1a7507c | 2008-01-24 11:59:12 -0500 | [diff] [blame] | 43 | {.compatible = "simple-bus",}, |
| 44 | {.compatible = "wrs,epld-localbus",}, |
Benjamin Herrenschmidt | 3bc5ab9 | 2008-07-07 16:39:50 +1000 | [diff] [blame] | 45 | {}, |
Paul Gortmaker | 1a7507c | 2008-01-24 11:59:12 -0500 | [diff] [blame] | 46 | }; |
| 47 | |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 48 | static unsigned int legacy_serial_count; |
| 49 | static int legacy_serial_console = -1; |
| 50 | |
Arnd Bergmann | 7df5659 | 2011-06-27 11:45:16 +0000 | [diff] [blame] | 51 | static unsigned int tsi_serial_in(struct uart_port *p, int offset) |
| 52 | { |
| 53 | unsigned int tmp; |
| 54 | offset = offset << p->regshift; |
| 55 | if (offset == UART_IIR) { |
| 56 | tmp = readl(p->membase + (UART_IIR & ~3)); |
| 57 | return (tmp >> 16) & 0xff; /* UART_IIR % 4 == 2 */ |
| 58 | } else |
| 59 | return readb(p->membase + offset); |
| 60 | } |
| 61 | |
| 62 | static void tsi_serial_out(struct uart_port *p, int offset, int value) |
| 63 | { |
| 64 | offset = offset << p->regshift; |
| 65 | if (!((offset == UART_IER) && (value & UART_IER_UUE))) |
| 66 | writeb(value, p->membase + offset); |
| 67 | } |
| 68 | |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 69 | static int __init add_legacy_port(struct device_node *np, int want_index, |
| 70 | int iotype, phys_addr_t base, |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 71 | phys_addr_t taddr, unsigned long irq, |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 72 | upf_t flags, int irq_check_parent) |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 73 | { |
Ian Munsie | f14362d | 2010-10-01 17:06:07 +1000 | [diff] [blame] | 74 | const __be32 *clk, *spd; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 75 | u32 clock = BASE_BAUD * 16; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 76 | int index; |
| 77 | |
| 78 | /* get clock freq. if present */ |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 79 | clk = of_get_property(np, "clock-frequency", NULL); |
David Woodhouse | 31df167 | 2005-11-24 17:08:56 +0000 | [diff] [blame] | 80 | if (clk && *clk) |
Ian Munsie | f14362d | 2010-10-01 17:06:07 +1000 | [diff] [blame] | 81 | clock = be32_to_cpup(clk); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 82 | |
| 83 | /* get default speed if present */ |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 84 | spd = of_get_property(np, "current-speed", NULL); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 85 | |
| 86 | /* If we have a location index, then try to use it */ |
| 87 | if (want_index >= 0 && want_index < MAX_LEGACY_SERIAL_PORTS) |
| 88 | index = want_index; |
| 89 | else |
| 90 | index = legacy_serial_count; |
| 91 | |
| 92 | /* if our index is still out of range, that mean that |
| 93 | * array is full, we could scan for a free slot but that |
| 94 | * make little sense to bother, just skip the port |
| 95 | */ |
| 96 | if (index >= MAX_LEGACY_SERIAL_PORTS) |
| 97 | return -1; |
| 98 | if (index >= legacy_serial_count) |
| 99 | legacy_serial_count = index + 1; |
| 100 | |
| 101 | /* Check if there is a port who already claimed our slot */ |
| 102 | if (legacy_serial_infos[index].np != 0) { |
| 103 | /* if we still have some room, move it, else override */ |
| 104 | if (legacy_serial_count < MAX_LEGACY_SERIAL_PORTS) { |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 105 | printk(KERN_DEBUG "Moved legacy port %d -> %d\n", |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 106 | index, legacy_serial_count); |
| 107 | legacy_serial_ports[legacy_serial_count] = |
| 108 | legacy_serial_ports[index]; |
| 109 | legacy_serial_infos[legacy_serial_count] = |
| 110 | legacy_serial_infos[index]; |
| 111 | legacy_serial_count++; |
| 112 | } else { |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 113 | printk(KERN_DEBUG "Replacing legacy port %d\n", index); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 114 | } |
| 115 | } |
| 116 | |
| 117 | /* Now fill the entry */ |
| 118 | memset(&legacy_serial_ports[index], 0, |
| 119 | sizeof(struct plat_serial8250_port)); |
| 120 | if (iotype == UPIO_PORT) |
| 121 | legacy_serial_ports[index].iobase = base; |
| 122 | else |
Benjamin Herrenschmidt | 8dacaed | 2005-11-29 11:21:59 +1100 | [diff] [blame] | 123 | legacy_serial_ports[index].mapbase = base; |
Arnd Bergmann | 7df5659 | 2011-06-27 11:45:16 +0000 | [diff] [blame] | 124 | |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 125 | legacy_serial_ports[index].iotype = iotype; |
| 126 | legacy_serial_ports[index].uartclk = clock; |
| 127 | legacy_serial_ports[index].irq = irq; |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 128 | legacy_serial_ports[index].flags = flags; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 129 | legacy_serial_infos[index].taddr = taddr; |
| 130 | legacy_serial_infos[index].np = of_node_get(np); |
| 131 | legacy_serial_infos[index].clock = clock; |
Ian Munsie | f14362d | 2010-10-01 17:06:07 +1000 | [diff] [blame] | 132 | legacy_serial_infos[index].speed = spd ? be32_to_cpup(spd) : 0; |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 133 | legacy_serial_infos[index].irq_check_parent = irq_check_parent; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 134 | |
Arnd Bergmann | 7df5659 | 2011-06-27 11:45:16 +0000 | [diff] [blame] | 135 | if (iotype == UPIO_TSI) { |
| 136 | legacy_serial_ports[index].serial_in = tsi_serial_in; |
| 137 | legacy_serial_ports[index].serial_out = tsi_serial_out; |
| 138 | } |
| 139 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 140 | printk(KERN_DEBUG "Found legacy serial port %d for %s\n", |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 141 | index, np->full_name); |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 142 | printk(KERN_DEBUG " %s=%llx, taddr=%llx, irq=%lx, clk=%d, speed=%d\n", |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 143 | (iotype == UPIO_PORT) ? "port" : "mem", |
| 144 | (unsigned long long)base, (unsigned long long)taddr, irq, |
| 145 | legacy_serial_ports[index].uartclk, |
| 146 | legacy_serial_infos[index].speed); |
| 147 | |
| 148 | return index; |
| 149 | } |
| 150 | |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 151 | static int __init add_legacy_soc_port(struct device_node *np, |
| 152 | struct device_node *soc_dev) |
| 153 | { |
Benjamin Herrenschmidt | f704b8d | 2006-07-04 14:14:07 +1000 | [diff] [blame] | 154 | u64 addr; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 155 | const u32 *addrp; |
David Gibson | abb4a23 | 2007-05-06 14:48:49 -0700 | [diff] [blame] | 156 | upf_t flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ |
| 157 | | UPF_FIXED_PORT; |
Zang Roy-r61911 | be9633e | 2006-08-23 10:20:27 +0800 | [diff] [blame] | 158 | struct device_node *tsi = of_get_parent(np); |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 159 | |
| 160 | /* We only support ports that have a clock frequency properly |
| 161 | * encoded in the device-tree. |
| 162 | */ |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 163 | if (of_get_property(np, "clock-frequency", NULL) == NULL) |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 164 | return -1; |
| 165 | |
John Linn | 1e6d1f2 | 2008-07-01 10:52:41 -0700 | [diff] [blame] | 166 | /* if reg-shift or offset, don't try to use it */ |
| 167 | if ((of_get_property(np, "reg-shift", NULL) != NULL) || |
| 168 | (of_get_property(np, "reg-offset", NULL) != NULL)) |
| 169 | return -1; |
| 170 | |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 171 | /* if rtas uses this device, don't try to use it as well */ |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 172 | if (of_get_property(np, "used-by-rtas", NULL) != NULL) |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 173 | return -1; |
| 174 | |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 175 | /* Get the address */ |
| 176 | addrp = of_get_address(soc_dev, 0, NULL, NULL); |
| 177 | if (addrp == NULL) |
| 178 | return -1; |
| 179 | |
| 180 | addr = of_translate_address(soc_dev, addrp); |
Benjamin Herrenschmidt | 7c6efda | 2006-07-03 17:24:15 +1000 | [diff] [blame] | 181 | if (addr == OF_BAD_ADDR) |
| 182 | return -1; |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 183 | |
| 184 | /* Add port, irq will be dealt with later. We passed a translated |
| 185 | * IO port value. It will be fixed up later along with the irq |
| 186 | */ |
Zang Roy-r61911 | be9633e | 2006-08-23 10:20:27 +0800 | [diff] [blame] | 187 | if (tsi && !strcmp(tsi->type, "tsi-bridge")) |
| 188 | return add_legacy_port(np, -1, UPIO_TSI, addr, addr, NO_IRQ, flags, 0); |
| 189 | else |
| 190 | return add_legacy_port(np, -1, UPIO_MEM, addr, addr, NO_IRQ, flags, 0); |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 191 | } |
| 192 | |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 193 | static int __init add_legacy_isa_port(struct device_node *np, |
Kumar Gala | 017e0fa | 2006-01-03 16:15:21 -0600 | [diff] [blame] | 194 | struct device_node *isa_brg) |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 195 | { |
Ian Munsie | f14362d | 2010-10-01 17:06:07 +1000 | [diff] [blame] | 196 | const __be32 *reg; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 197 | const char *typep; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 198 | int index = -1; |
Benjamin Herrenschmidt | f704b8d | 2006-07-04 14:14:07 +1000 | [diff] [blame] | 199 | u64 taddr; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 200 | |
Benjamin Herrenschmidt | 7c6efda | 2006-07-03 17:24:15 +1000 | [diff] [blame] | 201 | DBG(" -> add_legacy_isa_port(%s)\n", np->full_name); |
| 202 | |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 203 | /* Get the ISA port number */ |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 204 | reg = of_get_property(np, "reg", NULL); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 205 | if (reg == NULL) |
| 206 | return -1; |
| 207 | |
| 208 | /* Verify it's an IO port, we don't support anything else */ |
Ian Munsie | f14362d | 2010-10-01 17:06:07 +1000 | [diff] [blame] | 209 | if (!(be32_to_cpu(reg[0]) & 0x00000001)) |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 210 | return -1; |
| 211 | |
| 212 | /* Now look for an "ibm,aix-loc" property that gives us ordering |
| 213 | * if any... |
| 214 | */ |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 215 | typep = of_get_property(np, "ibm,aix-loc", NULL); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 216 | |
| 217 | /* If we have a location index, then use it */ |
| 218 | if (typep && *typep == 'S') |
| 219 | index = simple_strtol(typep+1, NULL, 0) - 1; |
| 220 | |
Benjamin Herrenschmidt | f704b8d | 2006-07-04 14:14:07 +1000 | [diff] [blame] | 221 | /* Translate ISA address. If it fails, we still register the port |
| 222 | * with no translated address so that it can be picked up as an IO |
| 223 | * port later by the serial driver |
| 224 | */ |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 225 | taddr = of_translate_address(np, reg); |
Benjamin Herrenschmidt | 7c6efda | 2006-07-03 17:24:15 +1000 | [diff] [blame] | 226 | if (taddr == OF_BAD_ADDR) |
Benjamin Herrenschmidt | f704b8d | 2006-07-04 14:14:07 +1000 | [diff] [blame] | 227 | taddr = 0; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 228 | |
| 229 | /* Add port, irq will be dealt with later */ |
Ian Munsie | f14362d | 2010-10-01 17:06:07 +1000 | [diff] [blame] | 230 | return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]), taddr, |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 231 | NO_IRQ, UPF_BOOT_AUTOCONF, 0); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 232 | |
| 233 | } |
| 234 | |
Kumar Gala | 017e0fa | 2006-01-03 16:15:21 -0600 | [diff] [blame] | 235 | #ifdef CONFIG_PCI |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 236 | static int __init add_legacy_pci_port(struct device_node *np, |
| 237 | struct device_node *pci_dev) |
| 238 | { |
Benjamin Herrenschmidt | f704b8d | 2006-07-04 14:14:07 +1000 | [diff] [blame] | 239 | u64 addr, base; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 240 | const u32 *addrp; |
Benjamin Herrenschmidt | d2dd482 | 2005-11-30 16:57:28 +1100 | [diff] [blame] | 241 | unsigned int flags; |
Benjamin Herrenschmidt | 8dacaed | 2005-11-29 11:21:59 +1100 | [diff] [blame] | 242 | int iotype, index = -1, lindex = 0; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 243 | |
Benjamin Herrenschmidt | 7c6efda | 2006-07-03 17:24:15 +1000 | [diff] [blame] | 244 | DBG(" -> add_legacy_pci_port(%s)\n", np->full_name); |
| 245 | |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 246 | /* We only support ports that have a clock frequency properly |
| 247 | * encoded in the device-tree (that is have an fcode). Anything |
| 248 | * else can't be used that early and will be normally probed by |
Benjamin Herrenschmidt | 8dacaed | 2005-11-29 11:21:59 +1100 | [diff] [blame] | 249 | * the generic 8250_pci driver later on. The reason is that 8250 |
| 250 | * compatible UARTs on PCI need all sort of quirks (port offsets |
| 251 | * etc...) that this code doesn't know about |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 252 | */ |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 253 | if (of_get_property(np, "clock-frequency", NULL) == NULL) |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 254 | return -1; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 255 | |
| 256 | /* Get the PCI address. Assume BAR 0 */ |
Benjamin Herrenschmidt | d2dd482 | 2005-11-30 16:57:28 +1100 | [diff] [blame] | 257 | addrp = of_get_pci_address(pci_dev, 0, NULL, &flags); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 258 | if (addrp == NULL) |
| 259 | return -1; |
| 260 | |
| 261 | /* We only support BAR 0 for now */ |
Benjamin Herrenschmidt | d2dd482 | 2005-11-30 16:57:28 +1100 | [diff] [blame] | 262 | iotype = (flags & IORESOURCE_MEM) ? UPIO_MEM : UPIO_PORT; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 263 | addr = of_translate_address(pci_dev, addrp); |
Benjamin Herrenschmidt | 7c6efda | 2006-07-03 17:24:15 +1000 | [diff] [blame] | 264 | if (addr == OF_BAD_ADDR) |
| 265 | return -1; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 266 | |
| 267 | /* Set the IO base to the same as the translated address for MMIO, |
| 268 | * or to the domain local IO base for PIO (it will be fixed up later) |
| 269 | */ |
| 270 | if (iotype == UPIO_MEM) |
| 271 | base = addr; |
| 272 | else |
| 273 | base = addrp[2]; |
| 274 | |
| 275 | /* Try to guess an index... If we have subdevices of the pci dev, |
| 276 | * we get to their "reg" property |
| 277 | */ |
| 278 | if (np != pci_dev) { |
Ian Munsie | f14362d | 2010-10-01 17:06:07 +1000 | [diff] [blame] | 279 | const __be32 *reg = of_get_property(np, "reg", NULL); |
| 280 | if (reg && (be32_to_cpup(reg) < 4)) |
| 281 | index = lindex = be32_to_cpup(reg); |
Benjamin Herrenschmidt | 8dacaed | 2005-11-29 11:21:59 +1100 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | /* Local index means it's the Nth port in the PCI chip. Unfortunately |
| 285 | * the offset to add here is device specific. We know about those |
| 286 | * EXAR ports and we default to the most common case. If your UART |
| 287 | * doesn't work for these settings, you'll have to add your own special |
| 288 | * cases here |
| 289 | */ |
Stephen Rothwell | 55b61fe | 2007-05-03 17:26:52 +1000 | [diff] [blame] | 290 | if (of_device_is_compatible(pci_dev, "pci13a8,152") || |
| 291 | of_device_is_compatible(pci_dev, "pci13a8,154") || |
| 292 | of_device_is_compatible(pci_dev, "pci13a8,158")) { |
Benjamin Herrenschmidt | 8dacaed | 2005-11-29 11:21:59 +1100 | [diff] [blame] | 293 | addr += 0x200 * lindex; |
| 294 | base += 0x200 * lindex; |
| 295 | } else { |
| 296 | addr += 8 * lindex; |
| 297 | base += 8 * lindex; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | /* Add port, irq will be dealt with later. We passed a translated |
| 301 | * IO port value. It will be fixed up later along with the irq |
| 302 | */ |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 303 | return add_legacy_port(np, index, iotype, base, addr, NO_IRQ, |
| 304 | UPF_BOOT_AUTOCONF, np != pci_dev); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 305 | } |
Kumar Gala | 017e0fa | 2006-01-03 16:15:21 -0600 | [diff] [blame] | 306 | #endif |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 307 | |
Michael Neuling | 37a801c | 2006-03-26 10:07:35 +1000 | [diff] [blame] | 308 | static void __init setup_legacy_serial_console(int console) |
| 309 | { |
| 310 | struct legacy_serial_info *info = |
| 311 | &legacy_serial_infos[console]; |
| 312 | void __iomem *addr; |
| 313 | |
| 314 | if (info->taddr == 0) |
| 315 | return; |
| 316 | addr = ioremap(info->taddr, 0x1000); |
| 317 | if (addr == NULL) |
| 318 | return; |
| 319 | if (info->speed == 0) |
| 320 | info->speed = udbg_probe_uart_speed(addr, info->clock); |
| 321 | DBG("default console speed = %d\n", info->speed); |
| 322 | udbg_init_uart(addr, info->speed, info->clock); |
| 323 | } |
| 324 | |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 325 | /* |
| 326 | * This is called very early, as part of setup_system() or eventually |
| 327 | * setup_arch(), basically before anything else in this file. This function |
| 328 | * will try to build a list of all the available 8250-compatible serial ports |
| 329 | * in the machine using the Open Firmware device-tree. It currently only deals |
| 330 | * with ISA and PCI busses but could be extended. It allows a very early boot |
| 331 | * console to be initialized, that list is also used later to provide 8250 with |
| 332 | * the machine non-PCI ports and to properly pick the default console port |
| 333 | */ |
| 334 | void __init find_legacy_serial_ports(void) |
| 335 | { |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 336 | struct device_node *np, *stdout = NULL; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 337 | const char *path; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 338 | int index; |
| 339 | |
| 340 | DBG(" -> find_legacy_serial_port()\n"); |
| 341 | |
| 342 | /* Now find out if one of these is out firmware console */ |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 343 | path = of_get_property(of_chosen, "linux,stdout-path", NULL); |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 344 | if (path != NULL) { |
| 345 | stdout = of_find_node_by_path(path); |
| 346 | if (stdout) |
| 347 | DBG("stdout is %s\n", stdout->full_name); |
| 348 | } else { |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 349 | DBG(" no linux,stdout-path !\n"); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 350 | } |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 351 | |
Paul Gortmaker | 1a7507c | 2008-01-24 11:59:12 -0500 | [diff] [blame] | 352 | /* Iterate over all the 16550 ports, looking for known parents */ |
Cyrill Gorcunov | 3329c0d | 2007-11-30 06:45:47 +1100 | [diff] [blame] | 353 | for_each_compatible_node(np, "serial", "ns16550") { |
Paul Gortmaker | 1a7507c | 2008-01-24 11:59:12 -0500 | [diff] [blame] | 354 | struct device_node *parent = of_get_parent(np); |
| 355 | if (!parent) |
| 356 | continue; |
Benjamin Herrenschmidt | 3bc5ab9 | 2008-07-07 16:39:50 +1000 | [diff] [blame] | 357 | if (of_match_node(legacy_serial_parents, parent) != NULL) { |
Prabhakar Kushwaha | 07d9fce | 2011-04-06 12:56:29 +0530 | [diff] [blame] | 358 | if (of_device_is_available(np)) { |
| 359 | index = add_legacy_soc_port(np, np); |
| 360 | if (index >= 0 && np == stdout) |
| 361 | legacy_serial_console = index; |
| 362 | } |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 363 | } |
Paul Gortmaker | 1a7507c | 2008-01-24 11:59:12 -0500 | [diff] [blame] | 364 | of_node_put(parent); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 365 | } |
| 366 | |
Paul Gortmaker | 1a7507c | 2008-01-24 11:59:12 -0500 | [diff] [blame] | 367 | /* Next, fill our array with ISA ports */ |
Cyrill Gorcunov | 3329c0d | 2007-11-30 06:45:47 +1100 | [diff] [blame] | 368 | for_each_node_by_type(np, "serial") { |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 369 | struct device_node *isa = of_get_parent(np); |
| 370 | if (isa && !strcmp(isa->name, "isa")) { |
| 371 | index = add_legacy_isa_port(np, isa); |
| 372 | if (index >= 0 && np == stdout) |
| 373 | legacy_serial_console = index; |
| 374 | } |
| 375 | of_node_put(isa); |
| 376 | } |
| 377 | |
Kumar Gala | 017e0fa | 2006-01-03 16:15:21 -0600 | [diff] [blame] | 378 | #ifdef CONFIG_PCI |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 379 | /* Next, try to locate PCI ports */ |
| 380 | for (np = NULL; (np = of_find_all_nodes(np));) { |
| 381 | struct device_node *pci, *parent = of_get_parent(np); |
| 382 | if (parent && !strcmp(parent->name, "isa")) { |
| 383 | of_node_put(parent); |
| 384 | continue; |
| 385 | } |
| 386 | if (strcmp(np->name, "serial") && strcmp(np->type, "serial")) { |
| 387 | of_node_put(parent); |
| 388 | continue; |
| 389 | } |
| 390 | /* Check for known pciclass, and also check wether we have |
| 391 | * a device with child nodes for ports or not |
| 392 | */ |
Stephen Rothwell | 55b61fe | 2007-05-03 17:26:52 +1000 | [diff] [blame] | 393 | if (of_device_is_compatible(np, "pciclass,0700") || |
| 394 | of_device_is_compatible(np, "pciclass,070002")) |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 395 | pci = np; |
Stephen Rothwell | 55b61fe | 2007-05-03 17:26:52 +1000 | [diff] [blame] | 396 | else if (of_device_is_compatible(parent, "pciclass,0700") || |
| 397 | of_device_is_compatible(parent, "pciclass,070002")) |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 398 | pci = parent; |
| 399 | else { |
| 400 | of_node_put(parent); |
| 401 | continue; |
| 402 | } |
| 403 | index = add_legacy_pci_port(np, pci); |
| 404 | if (index >= 0 && np == stdout) |
| 405 | legacy_serial_console = index; |
| 406 | of_node_put(parent); |
| 407 | } |
Kumar Gala | 017e0fa | 2006-01-03 16:15:21 -0600 | [diff] [blame] | 408 | #endif |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 409 | |
| 410 | DBG("legacy_serial_console = %d\n", legacy_serial_console); |
Michael Neuling | 37a801c | 2006-03-26 10:07:35 +1000 | [diff] [blame] | 411 | if (legacy_serial_console >= 0) |
| 412 | setup_legacy_serial_console(legacy_serial_console); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 413 | DBG(" <- find_legacy_serial_port()\n"); |
| 414 | } |
| 415 | |
| 416 | static struct platform_device serial_device = { |
| 417 | .name = "serial8250", |
| 418 | .id = PLAT8250_DEV_PLATFORM, |
| 419 | .dev = { |
| 420 | .platform_data = legacy_serial_ports, |
| 421 | }, |
| 422 | }; |
| 423 | |
| 424 | static void __init fixup_port_irq(int index, |
| 425 | struct device_node *np, |
| 426 | struct plat_serial8250_port *port) |
| 427 | { |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 428 | unsigned int virq; |
| 429 | |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 430 | DBG("fixup_port_irq(%d)\n", index); |
| 431 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 432 | virq = irq_of_parse_and_map(np, 0); |
| 433 | if (virq == NO_IRQ && legacy_serial_infos[index].irq_check_parent) { |
| 434 | np = of_get_parent(np); |
| 435 | if (np == NULL) |
| 436 | return; |
| 437 | virq = irq_of_parse_and_map(np, 0); |
| 438 | of_node_put(np); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 439 | } |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 440 | if (virq == NO_IRQ) |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 441 | return; |
| 442 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 443 | port->irq = virq; |
Paul Gortmaker | 9deaa53 | 2011-12-04 18:42:23 -0500 | [diff] [blame] | 444 | |
Benjamin Herrenschmidt | 3493c85 | 2012-01-25 13:33:22 +1100 | [diff] [blame] | 445 | #ifdef CONFIG_SERIAL_8250_FSL |
Paul Gortmaker | 9deaa53 | 2011-12-04 18:42:23 -0500 | [diff] [blame] | 446 | if (of_device_is_compatible(np, "fsl,ns16550")) |
| 447 | port->handle_irq = fsl8250_handle_irq; |
Benjamin Herrenschmidt | 3493c85 | 2012-01-25 13:33:22 +1100 | [diff] [blame] | 448 | #endif |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | static void __init fixup_port_pio(int index, |
| 452 | struct device_node *np, |
| 453 | struct plat_serial8250_port *port) |
| 454 | { |
Kumar Gala | 017e0fa | 2006-01-03 16:15:21 -0600 | [diff] [blame] | 455 | #ifdef CONFIG_PCI |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 456 | struct pci_controller *hose; |
| 457 | |
| 458 | DBG("fixup_port_pio(%d)\n", index); |
| 459 | |
| 460 | hose = pci_find_hose_for_OF_device(np); |
| 461 | if (hose) { |
| 462 | unsigned long offset = (unsigned long)hose->io_base_virt - |
| 463 | #ifdef CONFIG_PPC64 |
| 464 | pci_io_base; |
| 465 | #else |
| 466 | isa_io_base; |
| 467 | #endif |
| 468 | DBG("port %d, IO %lx -> %lx\n", |
| 469 | index, port->iobase, port->iobase + offset); |
| 470 | port->iobase += offset; |
| 471 | } |
Kumar Gala | 017e0fa | 2006-01-03 16:15:21 -0600 | [diff] [blame] | 472 | #endif |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 473 | } |
| 474 | |
Benjamin Herrenschmidt | 8dacaed | 2005-11-29 11:21:59 +1100 | [diff] [blame] | 475 | static void __init fixup_port_mmio(int index, |
| 476 | struct device_node *np, |
| 477 | struct plat_serial8250_port *port) |
| 478 | { |
| 479 | DBG("fixup_port_mmio(%d)\n", index); |
| 480 | |
| 481 | port->membase = ioremap(port->mapbase, 0x100); |
| 482 | } |
| 483 | |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 484 | /* |
| 485 | * This is called as an arch initcall, hopefully before the PCI bus is |
| 486 | * probed and/or the 8250 driver loaded since we need to register our |
| 487 | * platform devices before 8250 PCI ones are detected as some of them |
| 488 | * must properly "override" the platform ones. |
| 489 | * |
| 490 | * This function fixes up the interrupt value for platform ports as it |
| 491 | * couldn't be done earlier before interrupt maps have been parsed. It |
| 492 | * also "corrects" the IO address for PIO ports for the same reason, |
| 493 | * since earlier, the PHBs virtual IO space wasn't assigned yet. It then |
| 494 | * registers all those platform ports for use by the 8250 driver when it |
| 495 | * finally loads. |
| 496 | */ |
| 497 | static int __init serial_dev_init(void) |
| 498 | { |
| 499 | int i; |
| 500 | |
| 501 | if (legacy_serial_count == 0) |
| 502 | return -ENODEV; |
| 503 | |
| 504 | /* |
Stefan Weil | 947af29 | 2010-01-07 00:03:52 +0100 | [diff] [blame] | 505 | * Before we register the platform serial devices, we need |
joe@perches.com | 00d7041 | 2007-12-18 06:30:12 +1100 | [diff] [blame] | 506 | * to fixup their interrupts and their IO ports. |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 507 | */ |
| 508 | DBG("Fixing serial ports interrupts and IO ports ...\n"); |
| 509 | |
| 510 | for (i = 0; i < legacy_serial_count; i++) { |
| 511 | struct plat_serial8250_port *port = &legacy_serial_ports[i]; |
| 512 | struct device_node *np = legacy_serial_infos[i].np; |
| 513 | |
| 514 | if (port->irq == NO_IRQ) |
| 515 | fixup_port_irq(i, np, port); |
| 516 | if (port->iotype == UPIO_PORT) |
| 517 | fixup_port_pio(i, np, port); |
Zang Roy-r61911 | be9633e | 2006-08-23 10:20:27 +0800 | [diff] [blame] | 518 | if ((port->iotype == UPIO_MEM) || (port->iotype == UPIO_TSI)) |
Benjamin Herrenschmidt | 8dacaed | 2005-11-29 11:21:59 +1100 | [diff] [blame] | 519 | fixup_port_mmio(i, np, port); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | DBG("Registering platform serial ports\n"); |
| 523 | |
| 524 | return platform_device_register(&serial_device); |
| 525 | } |
Olof Johansson | ee56c47 | 2007-08-22 19:26:37 -0500 | [diff] [blame] | 526 | device_initcall(serial_dev_init); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 527 | |
| 528 | |
Benjamin Herrenschmidt | 025d791 | 2008-07-28 13:49:15 +1000 | [diff] [blame] | 529 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 530 | /* |
| 531 | * This is called very early, as part of console_init() (typically just after |
| 532 | * time_init()). This function is respondible for trying to find a good |
| 533 | * default console on serial ports. It tries to match the open firmware |
Benjamin Herrenschmidt | 025d791 | 2008-07-28 13:49:15 +1000 | [diff] [blame] | 534 | * default output with one of the available serial console drivers that have |
| 535 | * been probed earlier by find_legacy_serial_ports() |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 536 | */ |
| 537 | static int __init check_legacy_serial_console(void) |
| 538 | { |
| 539 | struct device_node *prom_stdout = NULL; |
Benjamin Herrenschmidt | 025d791 | 2008-07-28 13:49:15 +1000 | [diff] [blame] | 540 | int i, speed = 0, offset = 0; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 541 | const char *name; |
Ian Munsie | f14362d | 2010-10-01 17:06:07 +1000 | [diff] [blame] | 542 | const __be32 *spd; |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 543 | |
| 544 | DBG(" -> check_legacy_serial_console()\n"); |
| 545 | |
| 546 | /* The user has requested a console so this is already set up. */ |
Alon Bar-Lev | b8757b2 | 2007-02-12 00:54:17 -0800 | [diff] [blame] | 547 | if (strstr(boot_command_line, "console=")) { |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 548 | DBG(" console was specified !\n"); |
| 549 | return -EBUSY; |
| 550 | } |
| 551 | |
| 552 | if (!of_chosen) { |
| 553 | DBG(" of_chosen is NULL !\n"); |
| 554 | return -ENODEV; |
| 555 | } |
Kumar Gala | b580d46 | 2005-12-20 16:16:52 -0600 | [diff] [blame] | 556 | |
| 557 | if (legacy_serial_console < 0) { |
| 558 | DBG(" legacy_serial_console not found !\n"); |
| 559 | return -ENODEV; |
| 560 | } |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 561 | /* We are getting a weird phandle from OF ... */ |
| 562 | /* ... So use the full path instead */ |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 563 | name = of_get_property(of_chosen, "linux,stdout-path", NULL); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 564 | if (name == NULL) { |
| 565 | DBG(" no linux,stdout-path !\n"); |
| 566 | return -ENODEV; |
| 567 | } |
| 568 | prom_stdout = of_find_node_by_path(name); |
| 569 | if (!prom_stdout) { |
| 570 | DBG(" can't find stdout package %s !\n", name); |
| 571 | return -ENODEV; |
| 572 | } |
| 573 | DBG("stdout is %s\n", prom_stdout->full_name); |
| 574 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 575 | name = of_get_property(prom_stdout, "name", NULL); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 576 | if (!name) { |
| 577 | DBG(" stdout package has no name !\n"); |
| 578 | goto not_found; |
| 579 | } |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 580 | spd = of_get_property(prom_stdout, "current-speed", NULL); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 581 | if (spd) |
Ian Munsie | f14362d | 2010-10-01 17:06:07 +1000 | [diff] [blame] | 582 | speed = be32_to_cpup(spd); |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 583 | |
Benjamin Herrenschmidt | 025d791 | 2008-07-28 13:49:15 +1000 | [diff] [blame] | 584 | if (strcmp(name, "serial") != 0) |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 585 | goto not_found; |
Benjamin Herrenschmidt | 025d791 | 2008-07-28 13:49:15 +1000 | [diff] [blame] | 586 | |
| 587 | /* Look for it in probed array */ |
| 588 | for (i = 0; i < legacy_serial_count; i++) { |
| 589 | if (prom_stdout != legacy_serial_infos[i].np) |
| 590 | continue; |
| 591 | offset = i; |
| 592 | speed = legacy_serial_infos[i].speed; |
| 593 | break; |
| 594 | } |
| 595 | if (i >= legacy_serial_count) |
| 596 | goto not_found; |
| 597 | |
Benjamin Herrenschmidt | 463ce0e | 2005-11-23 17:56:06 +1100 | [diff] [blame] | 598 | of_node_put(prom_stdout); |
| 599 | |
| 600 | DBG("Found serial console at ttyS%d\n", offset); |
| 601 | |
| 602 | if (speed) { |
| 603 | static char __initdata opt[16]; |
| 604 | sprintf(opt, "%d", speed); |
| 605 | return add_preferred_console("ttyS", offset, opt); |
| 606 | } else |
| 607 | return add_preferred_console("ttyS", offset, NULL); |
| 608 | |
| 609 | not_found: |
| 610 | DBG("No preferred console found !\n"); |
| 611 | of_node_put(prom_stdout); |
| 612 | return -ENODEV; |
| 613 | } |
| 614 | console_initcall(check_legacy_serial_console); |
| 615 | |
Benjamin Herrenschmidt | 025d791 | 2008-07-28 13:49:15 +1000 | [diff] [blame] | 616 | #endif /* CONFIG_SERIAL_8250_CONSOLE */ |