8250_parisc.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Serial Device Initialisation for Lasi/Asp/Wax/Dino
  4. *
  5. * (c) Copyright Matthew Wilcox <[email protected]> 2001-2002
  6. */
  7. #include <linux/errno.h>
  8. #include <linux/init.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/ioport.h>
  11. #include <linux/module.h>
  12. #include <linux/serial_core.h>
  13. #include <linux/signal.h>
  14. #include <linux/types.h>
  15. #include <asm/hardware.h>
  16. #include <asm/parisc-device.h>
  17. #include <asm/io.h>
  18. #include "8250.h"
  19. static int __init serial_init_chip(struct parisc_device *dev)
  20. {
  21. struct uart_8250_port uart;
  22. unsigned long address;
  23. int err;
  24. #if defined(CONFIG_64BIT) && defined(CONFIG_IOSAPIC)
  25. if (!dev->irq && (dev->id.sversion == 0xad))
  26. dev->irq = iosapic_serial_irq(dev);
  27. #endif
  28. if (!dev->irq) {
  29. /* We find some unattached serial ports by walking native
  30. * busses. These should be silently ignored. Otherwise,
  31. * what we have here is a missing parent device, so tell
  32. * the user what they're missing.
  33. */
  34. if (parisc_parent(dev)->id.hw_type != HPHW_IOA)
  35. dev_info(&dev->dev,
  36. "Serial: device 0x%llx not configured.\n"
  37. "Enable support for Wax, Lasi, Asp or Dino.\n",
  38. (unsigned long long)dev->hpa.start);
  39. return -ENODEV;
  40. }
  41. address = dev->hpa.start;
  42. if (dev->id.sversion != 0x8d)
  43. address += 0x800;
  44. memset(&uart, 0, sizeof(uart));
  45. uart.port.iotype = UPIO_MEM;
  46. /* 7.272727MHz on Lasi. Assumed the same for Dino, Wax and Timi. */
  47. uart.port.uartclk = (dev->id.sversion != 0xad) ?
  48. 7272727 : 1843200;
  49. uart.port.mapbase = address;
  50. uart.port.membase = ioremap(address, 16);
  51. if (!uart.port.membase) {
  52. dev_warn(&dev->dev, "Failed to map memory\n");
  53. return -ENOMEM;
  54. }
  55. uart.port.irq = dev->irq;
  56. uart.port.flags = UPF_BOOT_AUTOCONF;
  57. uart.port.dev = &dev->dev;
  58. err = serial8250_register_8250_port(&uart);
  59. if (err < 0) {
  60. dev_warn(&dev->dev,
  61. "serial8250_register_8250_port returned error %d\n",
  62. err);
  63. iounmap(uart.port.membase);
  64. return err;
  65. }
  66. return 0;
  67. }
  68. static const struct parisc_device_id serial_tbl[] __initconst = {
  69. { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 },
  70. { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c },
  71. { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d },
  72. { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x000ad },
  73. { 0 }
  74. };
  75. /* Hack. Some machines have SERIAL_0 attached to Lasi and SERIAL_1
  76. * attached to Dino. Unfortunately, Dino appears before Lasi in the device
  77. * tree. To ensure that ttyS0 == SERIAL_0, we register two drivers; one
  78. * which only knows about Lasi and then a second which will find all the
  79. * other serial ports. HPUX ignores this problem.
  80. */
  81. static const struct parisc_device_id lasi_tbl[] __initconst = {
  82. { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */
  83. { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C }, /* B132L */
  84. { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C }, /* B160L */
  85. { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C }, /* B132L+ */
  86. { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C }, /* B180L+ */
  87. { HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C }, /* Rocky2 120 */
  88. { HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */
  89. { HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */
  90. { HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */
  91. { 0 }
  92. };
  93. MODULE_DEVICE_TABLE(parisc, serial_tbl);
  94. static struct parisc_driver lasi_driver __refdata = {
  95. .name = "serial_1",
  96. .id_table = lasi_tbl,
  97. .probe = serial_init_chip,
  98. };
  99. static struct parisc_driver serial_driver __refdata = {
  100. .name = "serial",
  101. .id_table = serial_tbl,
  102. .probe = serial_init_chip,
  103. };
  104. static int __init probe_serial_gsc(void)
  105. {
  106. register_parisc_driver(&lasi_driver);
  107. register_parisc_driver(&serial_driver);
  108. return 0;
  109. }
  110. module_init(probe_serial_gsc);
  111. MODULE_LICENSE("GPL");