serial.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 (ralf@linux-mips.org)
  7. *
  8. * Copyright (C) 2009 Lemote, Inc.
  9. * Author: Yan hua (yanhua@lemote.com)
  10. * Author: Wu Zhangjin (wuzj@lemote.com)
  11. */
  12. #include <linux/io.h>
  13. #include <linux/init.h>
  14. #include <linux/serial_8250.h>
  15. #include <asm/bootinfo.h>
  16. #include <loongson.h>
  17. #include <machine.h>
  18. #define PORT(int) \
  19. { \
  20. .irq = int, \
  21. .uartclk = 1843200, \
  22. .iotype = UPIO_PORT, \
  23. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, \
  24. .regshift = 0, \
  25. }
  26. #define PORT_M(int) \
  27. { \
  28. .irq = MIPS_CPU_IRQ_BASE + (int), \
  29. .uartclk = 3686400, \
  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[][2] = {
  36. [MACH_LOONGSON_UNKNOWN] {},
  37. [MACH_LEMOTE_FL2E] {PORT(4), {} },
  38. [MACH_LEMOTE_FL2F] {PORT(3), {} },
  39. [MACH_LEMOTE_ML2F7] {PORT_M(3), {} },
  40. [MACH_LEMOTE_YL2F89] {PORT_M(3), {} },
  41. [MACH_DEXXON_GDIUM2F10] {PORT_M(3), {} },
  42. [MACH_LEMOTE_NAS] {PORT_M(3), {} },
  43. [MACH_LEMOTE_LL2F] {PORT(3), {} },
  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][0].iotype;
  54. if (UPIO_MEM == iotype)
  55. uart8250_data[mips_machtype][0].membase =
  56. (void __iomem *)_loongson_uart_base;
  57. else if (UPIO_PORT == iotype)
  58. uart8250_data[mips_machtype][0].iobase =
  59. loongson_uart_base - LOONGSON_PCIIO_BASE;
  60. uart8250_device.dev.platform_data = uart8250_data[mips_machtype];
  61. return platform_device_register(&uart8250_device);
  62. }
  63. device_initcall(serial_init);