setup.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * linux/arch/sh/kernel/setup_7751se.c
  3. *
  4. * Copyright (C) 2000 Kazumoto Kojima
  5. *
  6. * Hitachi SolutionEngine Support.
  7. *
  8. * Modified for 7751 Solution Engine by
  9. * Ian da Silva and Jeremy Siegel, 2001.
  10. */
  11. #include <linux/init.h>
  12. #include <asm/machvec.h>
  13. #include <asm/se7751.h>
  14. #include <asm/io.h>
  15. void heartbeat_7751se(void);
  16. void init_7751se_IRQ(void);
  17. #ifdef CONFIG_SH_KGDB
  18. #include <asm/kgdb.h>
  19. static int kgdb_uart_setup(void);
  20. static struct kgdb_sermap kgdb_uart_sermap =
  21. { "ttyS", 0, kgdb_uart_setup, NULL };
  22. #endif
  23. /*
  24. * Initialize the board
  25. */
  26. static void __init sh7751se_setup(char **cmdline_p)
  27. {
  28. /* Call init_smsc() replacement to set up SuperIO. */
  29. /* XXX: RTC setting comes here */
  30. #ifdef CONFIG_SH_KGDB
  31. kgdb_register_sermap(&kgdb_uart_sermap);
  32. #endif
  33. }
  34. /*********************************************************************
  35. * Currently a hack (e.g. does not interact well w/serial.c, lots of *
  36. * hardcoded stuff) but may be useful if SCI/F needs debugging. *
  37. * Mostly copied from x86 code (see files asm-i386/kgdb_local.h and *
  38. * arch/i386/lib/kgdb_serial.c). *
  39. *********************************************************************/
  40. #ifdef CONFIG_SH_KGDB
  41. #include <linux/types.h>
  42. #include <linux/serial.h>
  43. #include <linux/serialP.h>
  44. #include <linux/serial_reg.h>
  45. #define COM1_PORT 0x3f8 /* Base I/O address */
  46. #define COM1_IRQ 4 /* IRQ not used yet */
  47. #define COM2_PORT 0x2f8 /* Base I/O address */
  48. #define COM2_IRQ 3 /* IRQ not used yet */
  49. #define SB_CLOCK 1843200 /* Serial baud clock */
  50. #define SB_BASE (SB_CLOCK/16)
  51. #define SB_MCR UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS
  52. struct uart_port {
  53. int base;
  54. };
  55. #define UART_NPORTS 2
  56. struct uart_port uart_ports[] = {
  57. { COM1_PORT },
  58. { COM2_PORT },
  59. };
  60. struct uart_port *kgdb_uart_port;
  61. #define UART_IN(reg) inb_p(kgdb_uart_port->base + reg)
  62. #define UART_OUT(reg,v) outb_p((v), kgdb_uart_port->base + reg)
  63. /* Basic read/write functions for the UART */
  64. #define UART_LSR_RXCERR (UART_LSR_BI | UART_LSR_FE | UART_LSR_PE)
  65. static int kgdb_uart_getchar(void)
  66. {
  67. int lsr;
  68. int c = -1;
  69. while (c == -1) {
  70. lsr = UART_IN(UART_LSR);
  71. if (lsr & UART_LSR_DR)
  72. c = UART_IN(UART_RX);
  73. if ((lsr & UART_LSR_RXCERR))
  74. c = -1;
  75. }
  76. return c;
  77. }
  78. static void kgdb_uart_putchar(int c)
  79. {
  80. while ((UART_IN(UART_LSR) & UART_LSR_THRE) == 0)
  81. ;
  82. UART_OUT(UART_TX, c);
  83. }
  84. /*
  85. * Initialize UART to configured/requested values.
  86. * (But we don't interrupts yet, or interact w/serial.c)
  87. */
  88. static int kgdb_uart_setup(void)
  89. {
  90. int port;
  91. int lcr = 0;
  92. int bdiv = 0;
  93. if (kgdb_portnum >= UART_NPORTS) {
  94. KGDB_PRINTK("uart port %d invalid.\n", kgdb_portnum);
  95. return -1;
  96. }
  97. kgdb_uart_port = &uart_ports[kgdb_portnum];
  98. /* Init sequence from gdb_hook_interrupt */
  99. UART_IN(UART_RX);
  100. UART_OUT(UART_IER, 0);
  101. UART_IN(UART_RX); /* Serial driver comments say */
  102. UART_IN(UART_IIR); /* this clears interrupt regs */
  103. UART_IN(UART_MSR);
  104. /* Figure basic LCR values */
  105. switch (kgdb_bits) {
  106. case '7':
  107. lcr |= UART_LCR_WLEN7;
  108. break;
  109. default: case '8':
  110. lcr |= UART_LCR_WLEN8;
  111. break;
  112. }
  113. switch (kgdb_parity) {
  114. case 'O':
  115. lcr |= UART_LCR_PARITY;
  116. break;
  117. case 'E':
  118. lcr |= (UART_LCR_PARITY | UART_LCR_EPAR);
  119. break;
  120. default: break;
  121. }
  122. /* Figure the baud rate divisor */
  123. bdiv = (SB_BASE/kgdb_baud);
  124. /* Set the baud rate and LCR values */
  125. UART_OUT(UART_LCR, (lcr | UART_LCR_DLAB));
  126. UART_OUT(UART_DLL, (bdiv & 0xff));
  127. UART_OUT(UART_DLM, ((bdiv >> 8) & 0xff));
  128. UART_OUT(UART_LCR, lcr);
  129. /* Set the MCR */
  130. UART_OUT(UART_MCR, SB_MCR);
  131. /* Turn off FIFOs for now */
  132. UART_OUT(UART_FCR, 0);
  133. /* Setup complete: initialize function pointers */
  134. kgdb_getchar = kgdb_uart_getchar;
  135. kgdb_putchar = kgdb_uart_putchar;
  136. return 0;
  137. }
  138. #endif /* CONFIG_SH_KGDB */
  139. /*
  140. * The Machine Vector
  141. */
  142. struct sh_machine_vector mv_7751se __initmv = {
  143. .mv_name = "7751 SolutionEngine",
  144. .mv_setup = sh7751se_setup,
  145. .mv_nr_irqs = 72,
  146. .mv_inb = sh7751se_inb,
  147. .mv_inw = sh7751se_inw,
  148. .mv_inl = sh7751se_inl,
  149. .mv_outb = sh7751se_outb,
  150. .mv_outw = sh7751se_outw,
  151. .mv_outl = sh7751se_outl,
  152. .mv_inb_p = sh7751se_inb_p,
  153. .mv_inw_p = sh7751se_inw,
  154. .mv_inl_p = sh7751se_inl,
  155. .mv_outb_p = sh7751se_outb_p,
  156. .mv_outw_p = sh7751se_outw,
  157. .mv_outl_p = sh7751se_outl,
  158. .mv_insl = sh7751se_insl,
  159. .mv_outsl = sh7751se_outsl,
  160. .mv_init_irq = init_7751se_IRQ,
  161. #ifdef CONFIG_HEARTBEAT
  162. .mv_heartbeat = heartbeat_7751se,
  163. #endif
  164. };
  165. ALIAS_MV(7751se)