serial.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2007 Ralf Baechle ([email protected])
  7. *
  8. * Copyright (C) 2009 Lemote, Inc.
  9. * Author: Yan hua ([email protected])
  10. * Author: Wu Zhangjin ([email protected])
  11. */
  12. #include <linux/io.h>
  13. #include <linux/module.h>
  14. #include <linux/serial_8250.h>
  15. #include <asm/bootinfo.h>
  16. #include <loongson.h>
  17. #include <machine.h>
  18. #define PORT(int, clk) \
  19. { \
  20. .irq = int, \
  21. .uartclk = clk, \
  22. .iotype = UPIO_PORT, \
  23. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, \
  24. .regshift = 0, \
  25. }
  26. #define PORT_M(int, clk) \
  27. { \
  28. .irq = MIPS_CPU_IRQ_BASE + (int), \
  29. .uartclk = clk, \
  30. .iotype = UPIO_MEM, \
  31. .membase = (void __iomem *)NULL, \
  32. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, \
  33. .regshift = 0, \
  34. }
  35. static struct plat_serial8250_port uart8250_data[MACH_LOONGSON_END + 1] = {
  36. [MACH_LOONGSON_UNKNOWN] = {},
  37. [MACH_LEMOTE_FL2E] = PORT(4, 1843200),
  38. [MACH_LEMOTE_FL2F] = PORT(3, 1843200),
  39. [MACH_LEMOTE_ML2F7] = PORT_M(3, 3686400),
  40. [MACH_LEMOTE_YL2F89] = PORT_M(3, 3686400),
  41. [MACH_DEXXON_GDIUM2F10] = PORT_M(3, 3686400),
  42. [MACH_LEMOTE_NAS] = PORT_M(3, 3686400),
  43. [MACH_LEMOTE_LL2F] = PORT(3, 1843200),
  44. [MACH_LOONGSON_END] = {},
  45. };
  46. static struct platform_device uart8250_device = {
  47. .name = "serial8250",
  48. .id = PLAT8250_DEV_PLATFORM,
  49. };
  50. static int __init serial_init(void)
  51. {
  52. unsigned char iotype;
  53. iotype = uart8250_data[mips_machtype].iotype;
  54. if (UPIO_MEM == iotype) {
  55. uart8250_data[mips_machtype].mapbase =
  56. loongson_uart_base;
  57. uart8250_data[mips_machtype].membase =
  58. (void __iomem *)_loongson_uart_base;
  59. }
  60. else if (UPIO_PORT == iotype)
  61. uart8250_data[mips_machtype].iobase =
  62. loongson_uart_base - LOONGSON_PCIIO_BASE;
  63. memset(&uart8250_data[mips_machtype + 1], 0,
  64. sizeof(struct plat_serial8250_port));
  65. uart8250_device.dev.platform_data = &uart8250_data[mips_machtype];
  66. return platform_device_register(&uart8250_device);
  67. }
  68. module_init(serial_init);
  69. static void __exit serial_exit(void)
  70. {
  71. platform_device_unregister(&uart8250_device);
  72. }
  73. module_exit(serial_exit);