Merge master.kernel.org:/pub/scm/linux/kernel/git/kyle/parisc-2.6
[deliverable/linux.git] / arch / sh / boards / se / 7751 / setup.c
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/platform_device.h>
13 #include <asm/machvec.h>
14 #include <asm/se7751.h>
15 #include <asm/io.h>
16
17 void init_7751se_IRQ(void);
18
19 #ifdef CONFIG_SH_KGDB
20 #include <asm/kgdb.h>
21 static int kgdb_uart_setup(void);
22 static struct kgdb_sermap kgdb_uart_sermap =
23 { "ttyS", 0, kgdb_uart_setup, NULL };
24 #endif
25
26 /*
27 * Initialize the board
28 */
29 static void __init sh7751se_setup(char **cmdline_p)
30 {
31 /* Call init_smsc() replacement to set up SuperIO. */
32 /* XXX: RTC setting comes here */
33 #ifdef CONFIG_SH_KGDB
34 kgdb_register_sermap(&kgdb_uart_sermap);
35 #endif
36 }
37
38 /*********************************************************************
39 * Currently a hack (e.g. does not interact well w/serial.c, lots of *
40 * hardcoded stuff) but may be useful if SCI/F needs debugging. *
41 * Mostly copied from x86 code (see files asm-i386/kgdb_local.h and *
42 * arch/i386/lib/kgdb_serial.c). *
43 *********************************************************************/
44
45 #ifdef CONFIG_SH_KGDB
46 #include <linux/types.h>
47 #include <linux/serial.h>
48 #include <linux/serialP.h>
49 #include <linux/serial_reg.h>
50
51 #define COM1_PORT 0x3f8 /* Base I/O address */
52 #define COM1_IRQ 4 /* IRQ not used yet */
53 #define COM2_PORT 0x2f8 /* Base I/O address */
54 #define COM2_IRQ 3 /* IRQ not used yet */
55
56 #define SB_CLOCK 1843200 /* Serial baud clock */
57 #define SB_BASE (SB_CLOCK/16)
58 #define SB_MCR UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS
59
60 struct uart_port {
61 int base;
62 };
63 #define UART_NPORTS 2
64 struct uart_port uart_ports[] = {
65 { COM1_PORT },
66 { COM2_PORT },
67 };
68 struct uart_port *kgdb_uart_port;
69
70 #define UART_IN(reg) inb_p(kgdb_uart_port->base + reg)
71 #define UART_OUT(reg,v) outb_p((v), kgdb_uart_port->base + reg)
72
73 /* Basic read/write functions for the UART */
74 #define UART_LSR_RXCERR (UART_LSR_BI | UART_LSR_FE | UART_LSR_PE)
75 static int kgdb_uart_getchar(void)
76 {
77 int lsr;
78 int c = -1;
79
80 while (c == -1) {
81 lsr = UART_IN(UART_LSR);
82 if (lsr & UART_LSR_DR)
83 c = UART_IN(UART_RX);
84 if ((lsr & UART_LSR_RXCERR))
85 c = -1;
86 }
87 return c;
88 }
89
90 static void kgdb_uart_putchar(int c)
91 {
92 while ((UART_IN(UART_LSR) & UART_LSR_THRE) == 0)
93 ;
94 UART_OUT(UART_TX, c);
95 }
96
97 /*
98 * Initialize UART to configured/requested values.
99 * (But we don't interrupts yet, or interact w/serial.c)
100 */
101 static int kgdb_uart_setup(void)
102 {
103 int port;
104 int lcr = 0;
105 int bdiv = 0;
106
107 if (kgdb_portnum >= UART_NPORTS) {
108 KGDB_PRINTK("uart port %d invalid.\n", kgdb_portnum);
109 return -1;
110 }
111
112 kgdb_uart_port = &uart_ports[kgdb_portnum];
113
114 /* Init sequence from gdb_hook_interrupt */
115 UART_IN(UART_RX);
116 UART_OUT(UART_IER, 0);
117
118 UART_IN(UART_RX); /* Serial driver comments say */
119 UART_IN(UART_IIR); /* this clears interrupt regs */
120 UART_IN(UART_MSR);
121
122 /* Figure basic LCR values */
123 switch (kgdb_bits) {
124 case '7':
125 lcr |= UART_LCR_WLEN7;
126 break;
127 default: case '8':
128 lcr |= UART_LCR_WLEN8;
129 break;
130 }
131 switch (kgdb_parity) {
132 case 'O':
133 lcr |= UART_LCR_PARITY;
134 break;
135 case 'E':
136 lcr |= (UART_LCR_PARITY | UART_LCR_EPAR);
137 break;
138 default: break;
139 }
140
141 /* Figure the baud rate divisor */
142 bdiv = (SB_BASE/kgdb_baud);
143
144 /* Set the baud rate and LCR values */
145 UART_OUT(UART_LCR, (lcr | UART_LCR_DLAB));
146 UART_OUT(UART_DLL, (bdiv & 0xff));
147 UART_OUT(UART_DLM, ((bdiv >> 8) & 0xff));
148 UART_OUT(UART_LCR, lcr);
149
150 /* Set the MCR */
151 UART_OUT(UART_MCR, SB_MCR);
152
153 /* Turn off FIFOs for now */
154 UART_OUT(UART_FCR, 0);
155
156 /* Setup complete: initialize function pointers */
157 kgdb_getchar = kgdb_uart_getchar;
158 kgdb_putchar = kgdb_uart_putchar;
159
160 return 0;
161 }
162 #endif /* CONFIG_SH_KGDB */
163
164 static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 };
165
166 static struct resource heartbeat_resources[] = {
167 [0] = {
168 .start = PA_LED,
169 .end = PA_LED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
170 .flags = IORESOURCE_MEM,
171 },
172 };
173
174 static struct platform_device heartbeat_device = {
175 .name = "heartbeat",
176 .id = -1,
177 .dev = {
178 .platform_data = heartbeat_bit_pos,
179 },
180 .num_resources = ARRAY_SIZE(heartbeat_resources),
181 .resource = heartbeat_resources,
182 };
183
184 static struct platform_device *se7751_devices[] __initdata = {
185 &smc91x_device,
186 &heartbeat_device,
187 };
188
189 static int __init se7751_devices_setup(void)
190 {
191 return platform_add_devices(se7751_devices, ARRAY_SIZE(se7751_devices));
192 }
193 __initcall(se7751_devices_setup);
194
195 /*
196 * The Machine Vector
197 */
198 struct sh_machine_vector mv_7751se __initmv = {
199 .mv_name = "7751 SolutionEngine",
200 .mv_setup = sh7751se_setup,
201 .mv_nr_irqs = 72,
202
203 .mv_inb = sh7751se_inb,
204 .mv_inw = sh7751se_inw,
205 .mv_inl = sh7751se_inl,
206 .mv_outb = sh7751se_outb,
207 .mv_outw = sh7751se_outw,
208 .mv_outl = sh7751se_outl,
209
210 .mv_inb_p = sh7751se_inb_p,
211 .mv_inw_p = sh7751se_inw,
212 .mv_inl_p = sh7751se_inl,
213 .mv_outb_p = sh7751se_outb_p,
214 .mv_outw_p = sh7751se_outw,
215 .mv_outl_p = sh7751se_outl,
216
217 .mv_insl = sh7751se_insl,
218 .mv_outsl = sh7751se_outsl,
219
220 .mv_init_irq = init_7751se_IRQ,
221 };
222 ALIAS_MV(7751se)
This page took 0.069145 seconds and 6 git commands to generate.