legacy_serial.c 18 KB

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