setup.c 4.4 KB

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