aboutsummaryrefslogtreecommitdiff
path: root/arch/mips/sni/a20r.c
blob: 9cb9d43a3a0e6341809f79825ce229423c7acf0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/*
 * A20R specific code
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
 */

#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/serial_8250.h>

#include <asm/sni.h>
#include <asm/time.h>

#define PORT(_base,_irq)				\
	{						\
		.iobase		= _base,		\
		.irq		= _irq,			\
		.uartclk	= 1843200,		\
		.iotype		= UPIO_PORT,		\
		.flags		= UPF_BOOT_AUTOCONF,	\
	}

static struct plat_serial8250_port a20r_data[] = {
	PORT(0x3f8, 4),
	PORT(0x2f8, 3),
	{ },
};

static struct platform_device a20r_serial8250_device = {
	.name			= "serial8250",
	.id			= PLAT8250_DEV_PLATFORM,
	.dev			= {
		.platform_data	= a20r_data,
	},
};

static struct resource a20r_ds1216_rsrc[] = {
        {
                .start = 0x1c081ffc,
                .end   = 0x1c081fff,
                .flags = IORESOURCE_MEM
        }
};

static struct platform_device a20r_ds1216_device = {
        .name           = "rtc-ds1216",
        .num_resources  = ARRAY_SIZE(a20r_ds1216_rsrc),
        .resource       = a20r_ds1216_rsrc
};

static struct resource snirm_82596_rsrc[] = {
	{
		.start = 0x18000000,
		.end   = 0x18000004,
		.flags = IORESOURCE_MEM
	},
	{
		.start = 0x18010000,
		.end   = 0x18010004,
		.flags = IORESOURCE_MEM
	},
	{
		.start = 0x1ff00000,
		.end   = 0x1ff00020,
		.flags = IORESOURCE_MEM
	},
	{
		.start = 22,
		.end   = 22,
		.flags = IORESOURCE_IRQ
	},
	{
		.flags = 0x01                /* 16bit mpu port access */
	}
};

static struct platform_device snirm_82596_pdev = {
	.name           = "snirm_82596",
	.num_resources  = ARRAY_SIZE(snirm_82596_rsrc),
	.resource       = snirm_82596_rsrc
};

static struct resource snirm_53c710_rsrc[] = {
	{
		.start = 0x19000000,
		.end   = 0x190fffff,
		.flags = IORESOURCE_MEM
	},
	{
		.start = 19,
		.end   = 19,
		.flags = IORESOURCE_IRQ
	}
};

static struct platform_device snirm_53c710_pdev = {
	.name           = "snirm_53c710",
	.num_resources  = ARRAY_SIZE(snirm_53c710_rsrc),
	.resource       = snirm_53c710_rsrc
};

static struct resource sc26xx_rsrc[] = {
	{
		.start = 0x1c070000,
		.end   = 0x1c0700ff,
		.flags = IORESOURCE_MEM
	},
	{
		.start = 20,
		.end   = 20,
		.flags = IORESOURCE_IRQ
	}
};

#include <linux/platform_data/sccnxp.h>

static struct sccnxp_pdata sccnxp_data = {
	.reg_shift	= 2,
	.frequency	= 3686400,
	.mctrl_cfg[0]	= MCTRL_SIG(DTR_OP, LINE_OP7) |
			  MCTRL_SIG(RTS_OP, LINE_OP3) |
			  MCTRL_SIG(DSR_IP, LINE_IP5) |
			  MCTRL_SIG(DCD_IP, LINE_IP6),
	.mctrl_cfg[1]	= MCTRL_SIG(DTR_OP, LINE_OP2) |
			  MCTRL_SIG(RTS_OP, LINE_OP1) |
			  MCTRL_SIG(DSR_IP, LINE_IP0) |
			  MCTRL_SIG(CTS_IP, LINE_IP1) |
			  MCTRL_SIG(DCD_IP, LINE_IP2) |
			  MCTRL_SIG(RNG_IP, LINE_IP3),
};

static struct platform_device sc26xx_pdev = {
	.name		= "sc2681",
	.resource	= sc26xx_rsrc,
	.num_resources	= ARRAY_SIZE(sc26xx_rsrc),
	.dev	= {
		.platform_data	= &sccnxp_data,
	},
};

static u32 a20r_ack_hwint(void)
{
	u32 status = read_c0_status();

	write_c0_status(status | 0x00010000);
	asm volatile(
	"	.set	push			\n"
	"	.set	noat			\n"
	"	.set	noreorder		\n"
	"	lw	$1, 0(%0)		\n"
	"	sb	$0, 0(%1)		\n"
	"	sync				\n"
	"	lb	%1, 0(%1)		\n"
	"	b	1f			\n"
	"	ori	%1, $1, 2		\n"
	"	.align	8			\n"
	"1:					\n"
	"	nop				\n"
	"	sw	%1, 0(%0)		\n"
	"	sync				\n"
	"	li	%1, 0x20		\n"
	"2:					\n"
	"	nop				\n"
	"	bnez	%1,2b			\n"
	"	addiu	%1, -1			\n"
	"	sw	$1, 0(%0)		\n"
	"	sync				\n"
		".set   pop			\n"
	:
	: "Jr" (PCIMT_UCONF), "Jr" (0xbc000000));
	write_c0_status(status);

	return status;
}

static inline void unmask_a20r_irq(struct irq_data *d)
{
	set_c0_status(0x100 << (d->irq - SNI_A20R_IRQ_BASE));
	irq_enable_hazard();
}

static inline void mask_a20r_irq(struct irq_data *d)
{
	clear_c0_status(0x100 << (d->irq - SNI_A20R_IRQ_BASE));
	irq_disable_hazard();
}

static struct irq_chip a20r_irq_type = {
	.name		= "A20R",
	.irq_mask	= mask_a20r_irq,
	.irq_unmask	= unmask_a20r_irq,
};

/*
 * hwint 0 receive all interrupts
 */
static void a20r_hwint(void)
{
	u32 cause, status;
	int irq;

	clear_c0_status(IE_IRQ0);
	status = a20r_ack_hwint();
	cause = read_c0_cause();

	irq = ffs(((cause & status) >> 8) & 0xf8);
	if (likely(irq > 0))
		do_IRQ(SNI_A20R_IRQ_BASE + irq - 1);
	set_c0_status(IE_IRQ0);
}

void __init sni_a20r_irq_init(void)
{
	int i;

	for (i = SNI_A20R_IRQ_BASE + 2 ; i < SNI_A20R_IRQ_BASE + 8; i++)
		irq_set_chip_and_handler(i, &a20r_irq_type, handle_level_irq);
	sni_hwint = a20r_hwint;
	change_c0_status(ST0_IM, IE_IRQ0);
	setup_irq(SNI_A20R_IRQ_BASE + 3, &sni_isa_irq);
}

void sni_a20r_init(void)
{
	/* FIXME, remove if not needed */
}

static int __init snirm_a20r_setup_devinit(void)
{
	switch (sni_brd_type) {
	case SNI_BRD_TOWER_OASIC:
	case SNI_BRD_MINITOWER:
	        platform_device_register(&snirm_82596_pdev);
	        platform_device_register(&snirm_53c710_pdev);
	        platform_device_register(&sc26xx_pdev);
	        platform_device_register(&a20r_serial8250_device);
	        platform_device_register(&a20r_ds1216_device);
		sni_eisa_root_init();
	        break;
	}
	return 0;
}

device_initcall(snirm_a20r_setup_devinit);