MIPS: Remove unused empty_bad_pmd_table[] declaration.
[deliverable/linux.git] / arch / mips / sni / a20r.c
CommitLineData
c066a32a
TB
1/*
2 * A20R specific code
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
9 */
10
11#include <linux/init.h>
12#include <linux/interrupt.h>
ca4d3e67 13#include <linux/irq.h>
c066a32a
TB
14#include <linux/platform_device.h>
15#include <linux/serial_8250.h>
16
17#include <asm/sni.h>
18#include <asm/time.h>
c066a32a
TB
19
20#define PORT(_base,_irq) \
21 { \
22 .iobase = _base, \
23 .irq = _irq, \
24 .uartclk = 1843200, \
25 .iotype = UPIO_PORT, \
26 .flags = UPF_BOOT_AUTOCONF, \
27 }
28
29static struct plat_serial8250_port a20r_data[] = {
30 PORT(0x3f8, 4),
31 PORT(0x2f8, 3),
32 { },
33};
34
35static struct platform_device a20r_serial8250_device = {
36 .name = "serial8250",
37 .id = PLAT8250_DEV_PLATFORM,
38 .dev = {
39 .platform_data = a20r_data,
40 },
41};
42
06cf5583
TB
43static struct resource a20r_ds1216_rsrc[] = {
44 {
45 .start = 0x1c081ffc,
46 .end = 0x1c081fff,
47 .flags = IORESOURCE_MEM
48 }
49};
50
51static struct platform_device a20r_ds1216_device = {
52 .name = "rtc-ds1216",
53 .num_resources = ARRAY_SIZE(a20r_ds1216_rsrc),
54 .resource = a20r_ds1216_rsrc
55};
56
c066a32a
TB
57static struct resource snirm_82596_rsrc[] = {
58 {
06cf5583
TB
59 .start = 0x18000000,
60 .end = 0x18000004,
c066a32a
TB
61 .flags = IORESOURCE_MEM
62 },
63 {
06cf5583
TB
64 .start = 0x18010000,
65 .end = 0x18010004,
c066a32a
TB
66 .flags = IORESOURCE_MEM
67 },
68 {
06cf5583
TB
69 .start = 0x1ff00000,
70 .end = 0x1ff00020,
c066a32a
TB
71 .flags = IORESOURCE_MEM
72 },
73 {
74 .start = 22,
75 .end = 22,
76 .flags = IORESOURCE_IRQ
77 },
78 {
79 .flags = 0x01 /* 16bit mpu port access */
80 }
81};
82
83static struct platform_device snirm_82596_pdev = {
84 .name = "snirm_82596",
85 .num_resources = ARRAY_SIZE(snirm_82596_rsrc),
86 .resource = snirm_82596_rsrc
87};
88
89static struct resource snirm_53c710_rsrc[] = {
90 {
9815778a
TB
91 .start = 0x19000000,
92 .end = 0x190fffff,
c066a32a
TB
93 .flags = IORESOURCE_MEM
94 },
95 {
96 .start = 19,
97 .end = 19,
98 .flags = IORESOURCE_IRQ
99 }
100};
101
102static struct platform_device snirm_53c710_pdev = {
103 .name = "snirm_53c710",
104 .num_resources = ARRAY_SIZE(snirm_53c710_rsrc),
105 .resource = snirm_53c710_rsrc
106};
107
108static struct resource sc26xx_rsrc[] = {
109 {
9815778a
TB
110 .start = 0x1c070000,
111 .end = 0x1c0700ff,
c066a32a
TB
112 .flags = IORESOURCE_MEM
113 },
114 {
115 .start = 20,
116 .end = 20,
117 .flags = IORESOURCE_IRQ
118 }
119};
120
231a35d3
TB
121static unsigned int sc26xx_data[2] = {
122 /* DTR | RTS | DSR | CTS | DCD | RI */
123 (8 << 0) | (4 << 4) | (6 << 8) | (0 << 12) | (6 << 16) | (0 << 20),
124 (3 << 0) | (2 << 4) | (1 << 8) | (2 << 12) | (3 << 16) | (4 << 20)
125};
126
c066a32a
TB
127static struct platform_device sc26xx_pdev = {
128 .name = "SC26xx",
129 .num_resources = ARRAY_SIZE(sc26xx_rsrc),
231a35d3
TB
130 .resource = sc26xx_rsrc,
131 .dev = {
132 .platform_data = sc26xx_data,
133 }
c066a32a
TB
134};
135
be282059
AS
136#warning "Please try migrate to use new driver SCCNXP and report the status" \
137 "in the linux-serial mailing list."
138
139/* The code bellow is a replacement of SC26XX to SCCNXP */
140#if 0
141#include <linux/platform_data/sccnxp.h>
142
143static struct sccnxp_pdata sccnxp_data = {
144 .reg_shift = 2,
145 .frequency = 3686400,
146 .mctrl_cfg[0] = MCTRL_SIG(DTR_OP, LINE_OP7) |
147 MCTRL_SIG(RTS_OP, LINE_OP3) |
148 MCTRL_SIG(DSR_IP, LINE_IP5) |
149 MCTRL_SIG(DCD_IP, LINE_IP6),
150 .mctrl_cfg[1] = MCTRL_SIG(DTR_OP, LINE_OP2) |
151 MCTRL_SIG(RTS_OP, LINE_OP1) |
152 MCTRL_SIG(DSR_IP, LINE_IP0) |
153 MCTRL_SIG(CTS_IP, LINE_IP1) |
154 MCTRL_SIG(DCD_IP, LINE_IP2) |
155 MCTRL_SIG(RNG_IP, LINE_IP3),
156};
157
158static struct platform_device sc2681_pdev = {
159 .name = "sc2681",
160 .resource = sc2xxx_rsrc,
161 .num_resources = ARRAY_SIZE(sc2xxx_rsrc),
162 .dev = {
163 .platform_data = &sccnxp_data,
164 },
165};
166#endif
167
c066a32a
TB
168static u32 a20r_ack_hwint(void)
169{
170 u32 status = read_c0_status();
171
49a89efb 172 write_c0_status(status | 0x00010000);
c066a32a
TB
173 asm volatile(
174 " .set push \n"
175 " .set noat \n"
176 " .set noreorder \n"
177 " lw $1, 0(%0) \n"
178 " sb $0, 0(%1) \n"
179 " sync \n"
180 " lb %1, 0(%1) \n"
181 " b 1f \n"
182 " ori %1, $1, 2 \n"
183 " .align 8 \n"
184 "1: \n"
185 " nop \n"
186 " sw %1, 0(%0) \n"
187 " sync \n"
188 " li %1, 0x20 \n"
189 "2: \n"
190 " nop \n"
191 " bnez %1,2b \n"
192 " addiu %1, -1 \n"
193 " sw $1, 0(%0) \n"
194 " sync \n"
195 ".set pop \n"
196 :
197 : "Jr" (PCIMT_UCONF), "Jr" (0xbc000000));
198 write_c0_status(status);
199
200 return status;
201}
202
0b888c7f 203static inline void unmask_a20r_irq(struct irq_data *d)
c066a32a 204{
0b888c7f 205 set_c0_status(0x100 << (d->irq - SNI_A20R_IRQ_BASE));
c066a32a
TB
206 irq_enable_hazard();
207}
208
0b888c7f 209static inline void mask_a20r_irq(struct irq_data *d)
c066a32a 210{
0b888c7f 211 clear_c0_status(0x100 << (d->irq - SNI_A20R_IRQ_BASE));
c066a32a
TB
212 irq_disable_hazard();
213}
214
c066a32a 215static struct irq_chip a20r_irq_type = {
8922f79e 216 .name = "A20R",
0b888c7f
TG
217 .irq_mask = mask_a20r_irq,
218 .irq_unmask = unmask_a20r_irq,
c066a32a
TB
219};
220
221/*
222 * hwint 0 receive all interrupts
223 */
224static void a20r_hwint(void)
225{
226 u32 cause, status;
227 int irq;
228
49a89efb 229 clear_c0_status(IE_IRQ0);
c066a32a
TB
230 status = a20r_ack_hwint();
231 cause = read_c0_cause();
232
233 irq = ffs(((cause & status) >> 8) & 0xf8);
234 if (likely(irq > 0))
235 do_IRQ(SNI_A20R_IRQ_BASE + irq - 1);
236 set_c0_status(IE_IRQ0);
237}
238
239void __init sni_a20r_irq_init(void)
240{
241 int i;
242
243 for (i = SNI_A20R_IRQ_BASE + 2 ; i < SNI_A20R_IRQ_BASE + 8; i++)
e4ec7989 244 irq_set_chip_and_handler(i, &a20r_irq_type, handle_level_irq);
c066a32a
TB
245 sni_hwint = a20r_hwint;
246 change_c0_status(ST0_IM, IE_IRQ0);
49a89efb 247 setup_irq(SNI_A20R_IRQ_BASE + 3, &sni_isa_irq);
c066a32a
TB
248}
249
250void sni_a20r_init(void)
251{
06cf5583 252 /* FIXME, remove if not needed */
c066a32a
TB
253}
254
255static int __init snirm_a20r_setup_devinit(void)
256{
257 switch (sni_brd_type) {
258 case SNI_BRD_TOWER_OASIC:
259 case SNI_BRD_MINITOWER:
260 platform_device_register(&snirm_82596_pdev);
261 platform_device_register(&snirm_53c710_pdev);
262 platform_device_register(&sc26xx_pdev);
263 platform_device_register(&a20r_serial8250_device);
06cf5583 264 platform_device_register(&a20r_ds1216_device);
231a35d3 265 sni_eisa_root_init();
c066a32a
TB
266 break;
267 }
c066a32a
TB
268 return 0;
269}
270
271device_initcall(snirm_a20r_setup_devinit);
This page took 0.405914 seconds and 5 git commands to generate.