2 * linux/arch/sh/kernel/setup_7751se.c
4 * Copyright (C) 2000 Kazumoto Kojima
6 * Hitachi SolutionEngine Support.
8 * Modified for 7751 Solution Engine by
9 * Ian da Silva and Jeremy Siegel, 2001.
12 #include <linux/init.h>
13 #include <linux/irq.h>
14 #include <linux/ide.h>
16 #include <asm/se7751.h>
18 void heartbeat_7751se(void);
19 void init_7751se_IRQ(void);
23 static int kgdb_uart_setup(void);
24 static struct kgdb_sermap kgdb_uart_sermap =
25 { "ttyS", 0, kgdb_uart_setup, NULL };
29 * Initialize the board
31 static void __init sh7751se_setup(char **cmdline_p)
33 /* Call init_smsc() replacement to set up SuperIO. */
34 /* XXX: RTC setting comes here */
36 kgdb_register_sermap(&kgdb_uart_sermap);
40 /*********************************************************************
41 * Currently a hack (e.g. does not interact well w/serial.c, lots of *
42 * hardcoded stuff) but may be useful if SCI/F needs debugging. *
43 * Mostly copied from x86 code (see files asm-i386/kgdb_local.h and *
44 * arch/i386/lib/kgdb_serial.c). *
45 *********************************************************************/
48 #include <linux/types.h>
49 #include <linux/serial.h>
50 #include <linux/serialP.h>
51 #include <linux/serial_reg.h>
53 #define COM1_PORT 0x3f8 /* Base I/O address */
54 #define COM1_IRQ 4 /* IRQ not used yet */
55 #define COM2_PORT 0x2f8 /* Base I/O address */
56 #define COM2_IRQ 3 /* IRQ not used yet */
58 #define SB_CLOCK 1843200 /* Serial baud clock */
59 #define SB_BASE (SB_CLOCK/16)
60 #define SB_MCR UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS
66 struct uart_port uart_ports[] = {
70 struct uart_port *kgdb_uart_port;
72 #define UART_IN(reg) inb_p(kgdb_uart_port->base + reg)
73 #define UART_OUT(reg,v) outb_p((v), kgdb_uart_port->base + reg)
75 /* Basic read/write functions for the UART */
76 #define UART_LSR_RXCERR (UART_LSR_BI | UART_LSR_FE | UART_LSR_PE)
77 static int kgdb_uart_getchar(void)
83 lsr = UART_IN(UART_LSR);
84 if (lsr & UART_LSR_DR)
86 if ((lsr & UART_LSR_RXCERR))
92 static void kgdb_uart_putchar(int c)
94 while ((UART_IN(UART_LSR) & UART_LSR_THRE) == 0)
100 * Initialize UART to configured/requested values.
101 * (But we don't interrupts yet, or interact w/serial.c)
103 static int kgdb_uart_setup(void)
109 if (kgdb_portnum >= UART_NPORTS) {
110 KGDB_PRINTK("uart port %d invalid.\n", kgdb_portnum);
114 kgdb_uart_port = &uart_ports[kgdb_portnum];
116 /* Init sequence from gdb_hook_interrupt */
118 UART_OUT(UART_IER, 0);
120 UART_IN(UART_RX); /* Serial driver comments say */
121 UART_IN(UART_IIR); /* this clears interrupt regs */
124 /* Figure basic LCR values */
127 lcr |= UART_LCR_WLEN7;
130 lcr |= UART_LCR_WLEN8;
133 switch (kgdb_parity) {
135 lcr |= UART_LCR_PARITY;
138 lcr |= (UART_LCR_PARITY | UART_LCR_EPAR);
143 /* Figure the baud rate divisor */
144 bdiv = (SB_BASE/kgdb_baud);
146 /* Set the baud rate and LCR values */
147 UART_OUT(UART_LCR, (lcr | UART_LCR_DLAB));
148 UART_OUT(UART_DLL, (bdiv & 0xff));
149 UART_OUT(UART_DLM, ((bdiv >> 8) & 0xff));
150 UART_OUT(UART_LCR, lcr);
153 UART_OUT(UART_MCR, SB_MCR);
155 /* Turn off FIFOs for now */
156 UART_OUT(UART_FCR, 0);
158 /* Setup complete: initialize function pointers */
159 kgdb_getchar = kgdb_uart_getchar;
160 kgdb_putchar = kgdb_uart_putchar;
164 #endif /* CONFIG_SH_KGDB */
171 struct sh_machine_vector mv_7751se __initmv = {
172 .mv_name = "7751 SolutionEngine",
173 .mv_setup = sh7751se_setup,
176 .mv_inb = sh7751se_inb,
177 .mv_inw = sh7751se_inw,
178 .mv_inl = sh7751se_inl,
179 .mv_outb = sh7751se_outb,
180 .mv_outw = sh7751se_outw,
181 .mv_outl = sh7751se_outl,
183 .mv_inb_p = sh7751se_inb_p,
184 .mv_inw_p = sh7751se_inw,
185 .mv_inl_p = sh7751se_inl,
186 .mv_outb_p = sh7751se_outb_p,
187 .mv_outw_p = sh7751se_outw,
188 .mv_outl_p = sh7751se_outl,
190 .mv_insl = sh7751se_insl,
191 .mv_outsl = sh7751se_outsl,
193 .mv_init_irq = init_7751se_IRQ,
194 #ifdef CONFIG_HEARTBEAT
195 .mv_heartbeat = heartbeat_7751se,