legacy_serial.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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. 0, legacy_port_flags, 0);
  169. else
  170. return add_legacy_port(np, -1, UPIO_MEM, addr, addr,
  171. 0, 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. of_get_property(isa_brg, "ranges", NULL)) {
  203. taddr = of_translate_address(np, reg);
  204. if (taddr == OF_BAD_ADDR)
  205. taddr = 0;
  206. } else
  207. taddr = 0;
  208. /* Add port, irq will be dealt with later */
  209. return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]),
  210. taddr, 0, legacy_port_flags, 0);
  211. }
  212. #ifdef CONFIG_PCI
  213. static int __init add_legacy_pci_port(struct device_node *np,
  214. struct device_node *pci_dev)
  215. {
  216. u64 addr, base;
  217. const __be32 *addrp;
  218. unsigned int flags;
  219. int iotype, index = -1, lindex = 0;
  220. DBG(" -> add_legacy_pci_port(%s)\n", np->full_name);
  221. /* We only support ports that have a clock frequency properly
  222. * encoded in the device-tree (that is have an fcode). Anything
  223. * else can't be used that early and will be normally probed by
  224. * the generic 8250_pci driver later on. The reason is that 8250
  225. * compatible UARTs on PCI need all sort of quirks (port offsets
  226. * etc...) that this code doesn't know about
  227. */
  228. if (of_get_property(np, "clock-frequency", NULL) == NULL)
  229. return -1;
  230. /* Get the PCI address. Assume BAR 0 */
  231. addrp = of_get_pci_address(pci_dev, 0, NULL, &flags);
  232. if (addrp == NULL)
  233. return -1;
  234. /* We only support BAR 0 for now */
  235. iotype = (flags & IORESOURCE_MEM) ? UPIO_MEM : UPIO_PORT;
  236. addr = of_translate_address(pci_dev, addrp);
  237. if (addr == OF_BAD_ADDR)
  238. return -1;
  239. /* Set the IO base to the same as the translated address for MMIO,
  240. * or to the domain local IO base for PIO (it will be fixed up later)
  241. */
  242. if (iotype == UPIO_MEM)
  243. base = addr;
  244. else
  245. base = of_read_number(&addrp[2], 1);
  246. /* Try to guess an index... If we have subdevices of the pci dev,
  247. * we get to their "reg" property
  248. */
  249. if (np != pci_dev) {
  250. const __be32 *reg = of_get_property(np, "reg", NULL);
  251. if (reg && (be32_to_cpup(reg) < 4))
  252. index = lindex = be32_to_cpup(reg);
  253. }
  254. /* Local index means it's the Nth port in the PCI chip. Unfortunately
  255. * the offset to add here is device specific. We know about those
  256. * EXAR ports and we default to the most common case. If your UART
  257. * doesn't work for these settings, you'll have to add your own special
  258. * cases here
  259. */
  260. if (of_device_is_compatible(pci_dev, "pci13a8,152") ||
  261. of_device_is_compatible(pci_dev, "pci13a8,154") ||
  262. of_device_is_compatible(pci_dev, "pci13a8,158")) {
  263. addr += 0x200 * lindex;
  264. base += 0x200 * lindex;
  265. } else {
  266. addr += 8 * lindex;
  267. base += 8 * lindex;
  268. }
  269. /* Add port, irq will be dealt with later. We passed a translated
  270. * IO port value. It will be fixed up later along with the irq
  271. */
  272. return add_legacy_port(np, index, iotype, base, addr, 0,
  273. legacy_port_flags, np != pci_dev);
  274. }
  275. #endif
  276. static void __init setup_legacy_serial_console(int console)
  277. {
  278. struct legacy_serial_info *info = &legacy_serial_infos[console];
  279. struct plat_serial8250_port *port = &legacy_serial_ports[console];
  280. void __iomem *addr;
  281. unsigned int stride;
  282. stride = 1 << port->regshift;
  283. /* Check if a translated MMIO address has been found */
  284. if (info->taddr) {
  285. addr = ioremap(info->taddr, 0x1000);
  286. if (addr == NULL)
  287. return;
  288. udbg_uart_init_mmio(addr, stride);
  289. } else {
  290. /* Check if it's PIO and we support untranslated PIO */
  291. if (port->iotype == UPIO_PORT && isa_io_special)
  292. udbg_uart_init_pio(port->iobase, stride);
  293. else
  294. return;
  295. }
  296. /* Try to query the current speed */
  297. if (info->speed == 0)
  298. info->speed = udbg_probe_uart_speed(info->clock);
  299. /* Set it up */
  300. DBG("default console speed = %d\n", info->speed);
  301. udbg_uart_setup(info->speed, info->clock);
  302. }
  303. /*
  304. * This is called very early, as part of setup_system() or eventually
  305. * setup_arch(), basically before anything else in this file. This function
  306. * will try to build a list of all the available 8250-compatible serial ports
  307. * in the machine using the Open Firmware device-tree. It currently only deals
  308. * with ISA and PCI busses but could be extended. It allows a very early boot
  309. * console to be initialized, that list is also used later to provide 8250 with
  310. * the machine non-PCI ports and to properly pick the default console port
  311. */
  312. void __init find_legacy_serial_ports(void)
  313. {
  314. struct device_node *np, *stdout = NULL;
  315. const char *path;
  316. int index;
  317. DBG(" -> find_legacy_serial_port()\n");
  318. /* Now find out if one of these is out firmware console */
  319. path = of_get_property(of_chosen, "linux,stdout-path", NULL);
  320. if (path != NULL) {
  321. stdout = of_find_node_by_path(path);
  322. if (stdout)
  323. DBG("stdout is %s\n", stdout->full_name);
  324. } else {
  325. DBG(" no linux,stdout-path !\n");
  326. }
  327. /* Iterate over all the 16550 ports, looking for known parents */
  328. for_each_compatible_node(np, "serial", "ns16550") {
  329. struct device_node *parent = of_get_parent(np);
  330. if (!parent)
  331. continue;
  332. if (of_match_node(legacy_serial_parents, parent) != NULL) {
  333. if (of_device_is_available(np)) {
  334. index = add_legacy_soc_port(np, np);
  335. if (index >= 0 && np == stdout)
  336. legacy_serial_console = index;
  337. }
  338. }
  339. of_node_put(parent);
  340. }
  341. /* Next, fill our array with ISA ports */
  342. for_each_node_by_type(np, "serial") {
  343. struct device_node *isa = of_get_parent(np);
  344. if (isa && (!strcmp(isa->name, "isa") ||
  345. !strcmp(isa->name, "lpc"))) {
  346. if (of_device_is_available(np)) {
  347. index = add_legacy_isa_port(np, isa);
  348. if (index >= 0 && np == stdout)
  349. legacy_serial_console = index;
  350. }
  351. }
  352. of_node_put(isa);
  353. }
  354. #ifdef CONFIG_PCI
  355. /* Next, try to locate PCI ports */
  356. for (np = NULL; (np = of_find_all_nodes(np));) {
  357. struct device_node *pci, *parent = of_get_parent(np);
  358. if (parent && !strcmp(parent->name, "isa")) {
  359. of_node_put(parent);
  360. continue;
  361. }
  362. if (strcmp(np->name, "serial") && strcmp(np->type, "serial")) {
  363. of_node_put(parent);
  364. continue;
  365. }
  366. /* Check for known pciclass, and also check whether we have
  367. * a device with child nodes for ports or not
  368. */
  369. if (of_device_is_compatible(np, "pciclass,0700") ||
  370. of_device_is_compatible(np, "pciclass,070002"))
  371. pci = np;
  372. else if (of_device_is_compatible(parent, "pciclass,0700") ||
  373. of_device_is_compatible(parent, "pciclass,070002"))
  374. pci = parent;
  375. else {
  376. of_node_put(parent);
  377. continue;
  378. }
  379. index = add_legacy_pci_port(np, pci);
  380. if (index >= 0 && np == stdout)
  381. legacy_serial_console = index;
  382. of_node_put(parent);
  383. }
  384. #endif
  385. DBG("legacy_serial_console = %d\n", legacy_serial_console);
  386. if (legacy_serial_console >= 0)
  387. setup_legacy_serial_console(legacy_serial_console);
  388. DBG(" <- find_legacy_serial_port()\n");
  389. }
  390. static struct platform_device serial_device = {
  391. .name = "serial8250",
  392. .id = PLAT8250_DEV_PLATFORM,
  393. .dev = {
  394. .platform_data = legacy_serial_ports,
  395. },
  396. };
  397. static void __init fixup_port_irq(int index,
  398. struct device_node *np,
  399. struct plat_serial8250_port *port)
  400. {
  401. unsigned int virq;
  402. DBG("fixup_port_irq(%d)\n", index);
  403. virq = irq_of_parse_and_map(np, 0);
  404. if (!virq && legacy_serial_infos[index].irq_check_parent) {
  405. np = of_get_parent(np);
  406. if (np == NULL)
  407. return;
  408. virq = irq_of_parse_and_map(np, 0);
  409. of_node_put(np);
  410. }
  411. if (!virq)
  412. return;
  413. port->irq = virq;
  414. #ifdef CONFIG_SERIAL_8250_FSL
  415. if (of_device_is_compatible(np, "fsl,ns16550"))
  416. port->handle_irq = fsl8250_handle_irq;
  417. #endif
  418. }
  419. static void __init fixup_port_pio(int index,
  420. struct device_node *np,
  421. struct plat_serial8250_port *port)
  422. {
  423. #ifdef CONFIG_PCI
  424. struct pci_controller *hose;
  425. DBG("fixup_port_pio(%d)\n", index);
  426. hose = pci_find_hose_for_OF_device(np);
  427. if (hose) {
  428. unsigned long offset = (unsigned long)hose->io_base_virt -
  429. #ifdef CONFIG_PPC64
  430. pci_io_base;
  431. #else
  432. isa_io_base;
  433. #endif
  434. DBG("port %d, IO %lx -> %lx\n",
  435. index, port->iobase, port->iobase + offset);
  436. port->iobase += offset;
  437. }
  438. #endif
  439. }
  440. static void __init fixup_port_mmio(int index,
  441. struct device_node *np,
  442. struct plat_serial8250_port *port)
  443. {
  444. DBG("fixup_port_mmio(%d)\n", index);
  445. port->membase = ioremap(port->mapbase, 0x100);
  446. }
  447. /*
  448. * This is called as an arch initcall, hopefully before the PCI bus is
  449. * probed and/or the 8250 driver loaded since we need to register our
  450. * platform devices before 8250 PCI ones are detected as some of them
  451. * must properly "override" the platform ones.
  452. *
  453. * This function fixes up the interrupt value for platform ports as it
  454. * couldn't be done earlier before interrupt maps have been parsed. It
  455. * also "corrects" the IO address for PIO ports for the same reason,
  456. * since earlier, the PHBs virtual IO space wasn't assigned yet. It then
  457. * registers all those platform ports for use by the 8250 driver when it
  458. * finally loads.
  459. */
  460. static int __init serial_dev_init(void)
  461. {
  462. int i;
  463. if (legacy_serial_count == 0)
  464. return -ENODEV;
  465. /*
  466. * Before we register the platform serial devices, we need
  467. * to fixup their interrupts and their IO ports.
  468. */
  469. DBG("Fixing serial ports interrupts and IO ports ...\n");
  470. for (i = 0; i < legacy_serial_count; i++) {
  471. struct plat_serial8250_port *port = &legacy_serial_ports[i];
  472. struct device_node *np = legacy_serial_infos[i].np;
  473. if (!port->irq)
  474. fixup_port_irq(i, np, port);
  475. if (port->iotype == UPIO_PORT)
  476. fixup_port_pio(i, np, port);
  477. if ((port->iotype == UPIO_MEM) || (port->iotype == UPIO_TSI))
  478. fixup_port_mmio(i, np, port);
  479. }
  480. DBG("Registering platform serial ports\n");
  481. return platform_device_register(&serial_device);
  482. }
  483. device_initcall(serial_dev_init);
  484. #ifdef CONFIG_SERIAL_8250_CONSOLE
  485. /*
  486. * This is called very early, as part of console_init() (typically just after
  487. * time_init()). This function is respondible for trying to find a good
  488. * default console on serial ports. It tries to match the open firmware
  489. * default output with one of the available serial console drivers that have
  490. * been probed earlier by find_legacy_serial_ports()
  491. */
  492. static int __init check_legacy_serial_console(void)
  493. {
  494. struct device_node *prom_stdout = NULL;
  495. int i, speed = 0, offset = 0;
  496. const char *name;
  497. const __be32 *spd;
  498. DBG(" -> check_legacy_serial_console()\n");
  499. /* The user has requested a console so this is already set up. */
  500. if (strstr(boot_command_line, "console=")) {
  501. DBG(" console was specified !\n");
  502. return -EBUSY;
  503. }
  504. if (!of_chosen) {
  505. DBG(" of_chosen is NULL !\n");
  506. return -ENODEV;
  507. }
  508. if (legacy_serial_console < 0) {
  509. DBG(" legacy_serial_console not found !\n");
  510. return -ENODEV;
  511. }
  512. /* We are getting a weird phandle from OF ... */
  513. /* ... So use the full path instead */
  514. name = of_get_property(of_chosen, "linux,stdout-path", NULL);
  515. if (name == NULL) {
  516. DBG(" no linux,stdout-path !\n");
  517. return -ENODEV;
  518. }
  519. prom_stdout = of_find_node_by_path(name);
  520. if (!prom_stdout) {
  521. DBG(" can't find stdout package %s !\n", name);
  522. return -ENODEV;
  523. }
  524. DBG("stdout is %s\n", prom_stdout->full_name);
  525. name = of_get_property(prom_stdout, "name", NULL);
  526. if (!name) {
  527. DBG(" stdout package has no name !\n");
  528. goto not_found;
  529. }
  530. spd = of_get_property(prom_stdout, "current-speed", NULL);
  531. if (spd)
  532. speed = be32_to_cpup(spd);
  533. if (strcmp(name, "serial") != 0)
  534. goto not_found;
  535. /* Look for it in probed array */
  536. for (i = 0; i < legacy_serial_count; i++) {
  537. if (prom_stdout != legacy_serial_infos[i].np)
  538. continue;
  539. offset = i;
  540. speed = legacy_serial_infos[i].speed;
  541. break;
  542. }
  543. if (i >= legacy_serial_count)
  544. goto not_found;
  545. of_node_put(prom_stdout);
  546. DBG("Found serial console at ttyS%d\n", offset);
  547. if (speed) {
  548. static char __initdata opt[16];
  549. sprintf(opt, "%d", speed);
  550. return add_preferred_console("ttyS", offset, opt);
  551. } else
  552. return add_preferred_console("ttyS", offset, NULL);
  553. not_found:
  554. DBG("No preferred console found !\n");
  555. of_node_put(prom_stdout);
  556. return -ENODEV;
  557. }
  558. console_initcall(check_legacy_serial_console);
  559. #endif /* CONFIG_SERIAL_8250_CONSOLE */