setup.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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 <linux/irq.h>
  13. #include <linux/hdreg.h>
  14. #include <linux/ide.h>
  15. #include <asm/io.h>
  16. #include <asm/se7751/se7751.h>
  17. #ifdef CONFIG_SH_KGDB
  18. #include <asm/kgdb.h>
  19. #endif
  20. /*
  21. * Configure the Super I/O chip
  22. */
  23. #if 0
  24. /* Leftover code from regular Solution Engine, for reference. */
  25. /* The SH7751 Solution Engine has a different SuperIO. */
  26. static void __init smsc_config(int index, int data)
  27. {
  28. outb_p(index, INDEX_PORT);
  29. outb_p(data, DATA_PORT);
  30. }
  31. static void __init init_smsc(void)
  32. {
  33. outb_p(CONFIG_ENTER, CONFIG_PORT);
  34. outb_p(CONFIG_ENTER, CONFIG_PORT);
  35. /* FDC */
  36. smsc_config(CURRENT_LDN_INDEX, LDN_FDC);
  37. smsc_config(ACTIVATE_INDEX, 0x01);
  38. smsc_config(IRQ_SELECT_INDEX, 6); /* IRQ6 */
  39. /* IDE1 */
  40. smsc_config(CURRENT_LDN_INDEX, LDN_IDE1);
  41. smsc_config(ACTIVATE_INDEX, 0x01);
  42. smsc_config(IRQ_SELECT_INDEX, 14); /* IRQ14 */
  43. /* AUXIO (GPIO): to use IDE1 */
  44. smsc_config(CURRENT_LDN_INDEX, LDN_AUXIO);
  45. smsc_config(GPIO46_INDEX, 0x00); /* nIOROP */
  46. smsc_config(GPIO47_INDEX, 0x00); /* nIOWOP */
  47. /* COM1 */
  48. smsc_config(CURRENT_LDN_INDEX, LDN_COM1);
  49. smsc_config(ACTIVATE_INDEX, 0x01);
  50. smsc_config(IO_BASE_HI_INDEX, 0x03);
  51. smsc_config(IO_BASE_LO_INDEX, 0xf8);
  52. smsc_config(IRQ_SELECT_INDEX, 4); /* IRQ4 */
  53. /* COM2 */
  54. smsc_config(CURRENT_LDN_INDEX, LDN_COM2);
  55. smsc_config(ACTIVATE_INDEX, 0x01);
  56. smsc_config(IO_BASE_HI_INDEX, 0x02);
  57. smsc_config(IO_BASE_LO_INDEX, 0xf8);
  58. smsc_config(IRQ_SELECT_INDEX, 3); /* IRQ3 */
  59. /* RTC */
  60. smsc_config(CURRENT_LDN_INDEX, LDN_RTC);
  61. smsc_config(ACTIVATE_INDEX, 0x01);
  62. smsc_config(IRQ_SELECT_INDEX, 8); /* IRQ8 */
  63. /* XXX: PARPORT, KBD, and MOUSE will come here... */
  64. outb_p(CONFIG_EXIT, CONFIG_PORT);
  65. }
  66. #endif
  67. const char *get_system_type(void)
  68. {
  69. return "7751 SolutionEngine";
  70. }
  71. #ifdef CONFIG_SH_KGDB
  72. static int kgdb_uart_setup(void);
  73. static struct kgdb_sermap kgdb_uart_sermap =
  74. { "ttyS", 0, kgdb_uart_setup, NULL };
  75. #endif
  76. /*
  77. * Initialize the board
  78. */
  79. void __init platform_setup(void)
  80. {
  81. /* Call init_smsc() replacement to set up SuperIO. */
  82. /* XXX: RTC setting comes here */
  83. #ifdef CONFIG_SH_KGDB
  84. kgdb_register_sermap(&kgdb_uart_sermap);
  85. #endif
  86. }
  87. /*********************************************************************
  88. * Currently a hack (e.g. does not interact well w/serial.c, lots of *
  89. * hardcoded stuff) but may be useful if SCI/F needs debugging. *
  90. * Mostly copied from x86 code (see files asm-i386/kgdb_local.h and *
  91. * arch/i386/lib/kgdb_serial.c). *
  92. *********************************************************************/
  93. #ifdef CONFIG_SH_KGDB
  94. #include <linux/types.h>
  95. #include <linux/serial.h>
  96. #include <linux/serialP.h>
  97. #include <linux/serial_reg.h>
  98. #define COM1_PORT 0x3f8 /* Base I/O address */
  99. #define COM1_IRQ 4 /* IRQ not used yet */
  100. #define COM2_PORT 0x2f8 /* Base I/O address */
  101. #define COM2_IRQ 3 /* IRQ not used yet */
  102. #define SB_CLOCK 1843200 /* Serial baud clock */
  103. #define SB_BASE (SB_CLOCK/16)
  104. #define SB_MCR UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS
  105. struct uart_port {
  106. int base;
  107. };
  108. #define UART_NPORTS 2
  109. struct uart_port uart_ports[] = {
  110. { COM1_PORT },
  111. { COM2_PORT },
  112. };
  113. struct uart_port *kgdb_uart_port;
  114. #define UART_IN(reg) inb_p(kgdb_uart_port->base + reg)
  115. #define UART_OUT(reg,v) outb_p((v), kgdb_uart_port->base + reg)
  116. /* Basic read/write functions for the UART */
  117. #define UART_LSR_RXCERR (UART_LSR_BI | UART_LSR_FE | UART_LSR_PE)
  118. static int kgdb_uart_getchar(void)
  119. {
  120. int lsr;
  121. int c = -1;
  122. while (c == -1) {
  123. lsr = UART_IN(UART_LSR);
  124. if (lsr & UART_LSR_DR)
  125. c = UART_IN(UART_RX);
  126. if ((lsr & UART_LSR_RXCERR))
  127. c = -1;
  128. }
  129. return c;
  130. }
  131. static void kgdb_uart_putchar(int c)
  132. {
  133. while ((UART_IN(UART_LSR) & UART_LSR_THRE) == 0)
  134. ;
  135. UART_OUT(UART_TX, c);
  136. }
  137. /*
  138. * Initialize UART to configured/requested values.
  139. * (But we don't interrupts yet, or interact w/serial.c)
  140. */
  141. static int kgdb_uart_setup(void)
  142. {
  143. int port;
  144. int lcr = 0;
  145. int bdiv = 0;
  146. if (kgdb_portnum >= UART_NPORTS) {
  147. KGDB_PRINTK("uart port %d invalid.\n", kgdb_portnum);
  148. return -1;
  149. }
  150. kgdb_uart_port = &uart_ports[kgdb_portnum];
  151. /* Init sequence from gdb_hook_interrupt */
  152. UART_IN(UART_RX);
  153. UART_OUT(UART_IER, 0);
  154. UART_IN(UART_RX); /* Serial driver comments say */
  155. UART_IN(UART_IIR); /* this clears interrupt regs */
  156. UART_IN(UART_MSR);
  157. /* Figure basic LCR values */
  158. switch (kgdb_bits) {
  159. case '7':
  160. lcr |= UART_LCR_WLEN7;
  161. break;
  162. default: case '8':
  163. lcr |= UART_LCR_WLEN8;
  164. break;
  165. }
  166. switch (kgdb_parity) {
  167. case 'O':
  168. lcr |= UART_LCR_PARITY;
  169. break;
  170. case 'E':
  171. lcr |= (UART_LCR_PARITY | UART_LCR_EPAR);
  172. break;
  173. default: break;
  174. }
  175. /* Figure the baud rate divisor */
  176. bdiv = (SB_BASE/kgdb_baud);
  177. /* Set the baud rate and LCR values */
  178. UART_OUT(UART_LCR, (lcr | UART_LCR_DLAB));
  179. UART_OUT(UART_DLL, (bdiv & 0xff));
  180. UART_OUT(UART_DLM, ((bdiv >> 8) & 0xff));
  181. UART_OUT(UART_LCR, lcr);
  182. /* Set the MCR */
  183. UART_OUT(UART_MCR, SB_MCR);
  184. /* Turn off FIFOs for now */
  185. UART_OUT(UART_FCR, 0);
  186. /* Setup complete: initialize function pointers */
  187. kgdb_getchar = kgdb_uart_getchar;
  188. kgdb_putchar = kgdb_uart_putchar;
  189. return 0;
  190. }
  191. #endif /* CONFIG_SH_KGDB */