blob: c48194c3073b95a2ccdcee6b1b0947913d996587 [file] [log] [blame]
Thomas Bogendoerferc066a322006-12-28 18:22:32 +01001/*
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>
David Howellsca4d3e672010-10-07 14:08:54 +010013#include <linux/irq.h>
Thomas Bogendoerferc066a322006-12-28 18:22:32 +010014#include <linux/platform_device.h>
15#include <linux/serial_8250.h>
16
17#include <asm/sni.h>
18#include <asm/time.h>
Thomas Bogendoerferc066a322006-12-28 18:22:32 +010019
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
Thomas Bogendoerfer06cf5582007-06-20 23:36:47 +020043static 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
Thomas Bogendoerferc066a322006-12-28 18:22:32 +010057static struct resource snirm_82596_rsrc[] = {
58 {
Thomas Bogendoerfer06cf5582007-06-20 23:36:47 +020059 .start = 0x18000000,
60 .end = 0x18000004,
Thomas Bogendoerferc066a322006-12-28 18:22:32 +010061 .flags = IORESOURCE_MEM
62 },
63 {
Thomas Bogendoerfer06cf5582007-06-20 23:36:47 +020064 .start = 0x18010000,
65 .end = 0x18010004,
Thomas Bogendoerferc066a322006-12-28 18:22:32 +010066 .flags = IORESOURCE_MEM
67 },
68 {
Thomas Bogendoerfer06cf5582007-06-20 23:36:47 +020069 .start = 0x1ff00000,
70 .end = 0x1ff00020,
Thomas Bogendoerferc066a322006-12-28 18:22:32 +010071 .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 {
Thomas Bogendoerfer98157782007-07-11 19:10:39 +020091 .start = 0x19000000,
92 .end = 0x190fffff,
Thomas Bogendoerferc066a322006-12-28 18:22:32 +010093 .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 {
Thomas Bogendoerfer98157782007-07-11 19:10:39 +0200110 .start = 0x1c070000,
111 .end = 0x1c0700ff,
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100112 .flags = IORESOURCE_MEM
113 },
114 {
115 .start = 20,
116 .end = 20,
117 .flags = IORESOURCE_IRQ
118 }
119};
120
Thomas Bogendoerfer231a35d2008-01-04 23:31:07 +0100121static 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
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100127static struct platform_device sc26xx_pdev = {
128 .name = "SC26xx",
129 .num_resources = ARRAY_SIZE(sc26xx_rsrc),
Thomas Bogendoerfer231a35d2008-01-04 23:31:07 +0100130 .resource = sc26xx_rsrc,
131 .dev = {
132 .platform_data = sc26xx_data,
133 }
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100134};
135
136static u32 a20r_ack_hwint(void)
137{
138 u32 status = read_c0_status();
139
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100140 write_c0_status(status | 0x00010000);
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100141 asm volatile(
142 " .set push \n"
143 " .set noat \n"
144 " .set noreorder \n"
145 " lw $1, 0(%0) \n"
146 " sb $0, 0(%1) \n"
147 " sync \n"
148 " lb %1, 0(%1) \n"
149 " b 1f \n"
150 " ori %1, $1, 2 \n"
151 " .align 8 \n"
152 "1: \n"
153 " nop \n"
154 " sw %1, 0(%0) \n"
155 " sync \n"
156 " li %1, 0x20 \n"
157 "2: \n"
158 " nop \n"
159 " bnez %1,2b \n"
160 " addiu %1, -1 \n"
161 " sw $1, 0(%0) \n"
162 " sync \n"
163 ".set pop \n"
164 :
165 : "Jr" (PCIMT_UCONF), "Jr" (0xbc000000));
166 write_c0_status(status);
167
168 return status;
169}
170
Thomas Gleixner0b888c72011-03-23 21:09:15 +0000171static inline void unmask_a20r_irq(struct irq_data *d)
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100172{
Thomas Gleixner0b888c72011-03-23 21:09:15 +0000173 set_c0_status(0x100 << (d->irq - SNI_A20R_IRQ_BASE));
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100174 irq_enable_hazard();
175}
176
Thomas Gleixner0b888c72011-03-23 21:09:15 +0000177static inline void mask_a20r_irq(struct irq_data *d)
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100178{
Thomas Gleixner0b888c72011-03-23 21:09:15 +0000179 clear_c0_status(0x100 << (d->irq - SNI_A20R_IRQ_BASE));
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100180 irq_disable_hazard();
181}
182
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100183static struct irq_chip a20r_irq_type = {
Thomas Gleixner8922f792009-11-17 22:51:03 +0000184 .name = "A20R",
Thomas Gleixner0b888c72011-03-23 21:09:15 +0000185 .irq_mask = mask_a20r_irq,
186 .irq_unmask = unmask_a20r_irq,
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100187};
188
189/*
190 * hwint 0 receive all interrupts
191 */
192static void a20r_hwint(void)
193{
194 u32 cause, status;
195 int irq;
196
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100197 clear_c0_status(IE_IRQ0);
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100198 status = a20r_ack_hwint();
199 cause = read_c0_cause();
200
201 irq = ffs(((cause & status) >> 8) & 0xf8);
202 if (likely(irq > 0))
203 do_IRQ(SNI_A20R_IRQ_BASE + irq - 1);
204 set_c0_status(IE_IRQ0);
205}
206
207void __init sni_a20r_irq_init(void)
208{
209 int i;
210
211 for (i = SNI_A20R_IRQ_BASE + 2 ; i < SNI_A20R_IRQ_BASE + 8; i++)
Thomas Gleixnere4ec7982011-03-27 15:19:28 +0200212 irq_set_chip_and_handler(i, &a20r_irq_type, handle_level_irq);
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100213 sni_hwint = a20r_hwint;
214 change_c0_status(ST0_IM, IE_IRQ0);
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100215 setup_irq(SNI_A20R_IRQ_BASE + 3, &sni_isa_irq);
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100216}
217
218void sni_a20r_init(void)
219{
Thomas Bogendoerfer06cf5582007-06-20 23:36:47 +0200220 /* FIXME, remove if not needed */
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100221}
222
223static int __init snirm_a20r_setup_devinit(void)
224{
225 switch (sni_brd_type) {
226 case SNI_BRD_TOWER_OASIC:
227 case SNI_BRD_MINITOWER:
228 platform_device_register(&snirm_82596_pdev);
229 platform_device_register(&snirm_53c710_pdev);
230 platform_device_register(&sc26xx_pdev);
231 platform_device_register(&a20r_serial8250_device);
Thomas Bogendoerfer06cf5582007-06-20 23:36:47 +0200232 platform_device_register(&a20r_ds1216_device);
Thomas Bogendoerfer231a35d2008-01-04 23:31:07 +0100233 sni_eisa_root_init();
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100234 break;
235 }
Thomas Bogendoerferc066a322006-12-28 18:22:32 +0100236 return 0;
237}
238
239device_initcall(snirm_a20r_setup_devinit);