8250_gsc.c 3.8 KB

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