setup.c 5.3 KB

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