serial.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 (wuzhangjin@gmail.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, 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[][2] = {
  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_LEMOTE_A1004] {PORT_M(2, 33177600), {} },
  45. [MACH_LEMOTE_A1101] {PORT_M(2, 25000000), {} },
  46. [MACH_LEMOTE_A1201] {PORT_M(2, 25000000), {} },
  47. [MACH_LEMOTE_A1205] {PORT_M(2, 25000000), {} },
  48. [MACH_LOONGSON_END] {},
  49. };
  50. static struct platform_device uart8250_device = {
  51. .name = "serial8250",
  52. .id = PLAT8250_DEV_PLATFORM,
  53. };
  54. static int __init serial_init(void)
  55. {
  56. unsigned char iotype;
  57. iotype = uart8250_data[mips_machtype][0].iotype;
  58. if (UPIO_MEM == iotype)
  59. uart8250_data[mips_machtype][0].membase =
  60. (void __iomem *)_loongson_uart_base;
  61. else if (UPIO_PORT == iotype)
  62. uart8250_data[mips_machtype][0].iobase =
  63. loongson_uart_base - LOONGSON_PCIIO_BASE;
  64. uart8250_device.dev.platform_data = uart8250_data[mips_machtype];
  65. return platform_device_register(&uart8250_device);
  66. }
  67. device_initcall(serial_init);