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