ja-console.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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) 2001, 2002, 2004 Ralf Baechle
  7. */
  8. #include <linux/init.h>
  9. #include <linux/console.h>
  10. #include <linux/kdev_t.h>
  11. #include <linux/major.h>
  12. #include <linux/termios.h>
  13. #include <linux/sched.h>
  14. #include <linux/tty.h>
  15. #include <linux/serial.h>
  16. #include <linux/serial_core.h>
  17. #include <asm/serial.h>
  18. /* SUPERIO uart register map */
  19. struct ja_uartregs {
  20. union {
  21. volatile u8 pad0[3];
  22. volatile u8 rbr; /* read only, DLAB == 0 */
  23. volatile u8 pad1[3];
  24. volatile u8 thr; /* write only, DLAB == 0 */
  25. volatile u8 pad2[3];
  26. volatile u8 dll; /* DLAB == 1 */
  27. } u1;
  28. union {
  29. volatile u8 pad0[3];
  30. volatile u8 ier; /* DLAB == 0 */
  31. volatile u8 pad1[3];
  32. volatile u8 dlm; /* DLAB == 1 */
  33. } u2;
  34. union {
  35. volatile u8 pad0[3];
  36. volatile u8 iir; /* read only */
  37. volatile u8 pad1[3];
  38. volatile u8 fcr; /* write only */
  39. } u3;
  40. volatile u8 pad0[3];
  41. volatile u8 iu_lcr;
  42. volatile u8 pad1[3];
  43. volatile u8 iu_mcr;
  44. volatile u8 pad2[3];
  45. volatile u8 iu_lsr;
  46. volatile u8 pad3[3];
  47. volatile u8 iu_msr;
  48. volatile u8 pad4[3];
  49. volatile u8 iu_scr;
  50. } ja_uregs_t;
  51. #define iu_rbr u1.rbr
  52. #define iu_thr u1.thr
  53. #define iu_dll u1.dll
  54. #define iu_ier u2.ier
  55. #define iu_dlm u2.dlm
  56. #define iu_iir u3.iir
  57. #define iu_fcr u3.fcr
  58. extern unsigned long uart_base;
  59. static inline struct ja_uartregs *console_uart(void)
  60. {
  61. return (struct ja_uartregs *) (uart_base + 0x23UL);
  62. }
  63. void prom_putchar(char c)
  64. {
  65. struct ja_uartregs *uart = console_uart();
  66. while ((uart->iu_lsr & 0x20) == 0);
  67. uart->iu_thr = c;
  68. }
  69. char __init prom_getchar(void)
  70. {
  71. return 0;
  72. }
  73. static void inline ja_console_probe(void)
  74. {
  75. struct uart_port up;
  76. /*
  77. * Register to interrupt zero because we share the interrupt with
  78. * the serial driver which we don't properly support yet.
  79. */
  80. memset(&up, 0, sizeof(up));
  81. up.membase = (unsigned char *) uart_base + 0x23UL;
  82. up.irq = JAGUAR_ATX_SERIAL1_IRQ;
  83. up.uartclk = JAGUAR_ATX_UART_CLK;
  84. up.regshift = 2;
  85. up.iotype = UPIO_MEM;
  86. up.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
  87. up.line = 0;
  88. if (early_serial_setup(&up))
  89. printk(KERN_ERR "Early serial init of port 0 failed\n");
  90. }
  91. __init void ja_setup_console(void)
  92. {
  93. ja_console_probe();
  94. }