aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/vr41xx
diff options
context:
space:
mode:
authorYoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>2006-07-13 04:33:14 -0400
committerRalf Baechle <ralf@linux-mips.org>2006-07-13 16:26:19 -0400
commitefcb487a8e9a86874cf63c3fbf6c85bbf87e6d87 (patch)
tree621f0f33f95709303c9deea5f726ccfb4eb75e9a /arch/mips/vr41xx
parent66151bbd20c6c62dbe5b131484c885086e3a8d29 (diff)
[MIPS] vr41xx: Removed old v2.4 VRC4173 driver
Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/vr41xx')
-rw-r--r--arch/mips/vr41xx/Kconfig6
-rw-r--r--arch/mips/vr41xx/common/Makefile3
-rw-r--r--arch/mips/vr41xx/common/vrc4173.c582
3 files changed, 1 insertions, 590 deletions
diff --git a/arch/mips/vr41xx/Kconfig b/arch/mips/vr41xx/Kconfig
index 6046ef23b2bf..92f41f6f934a 100644
--- a/arch/mips/vr41xx/Kconfig
+++ b/arch/mips/vr41xx/Kconfig
@@ -86,9 +86,3 @@ config PCI_VR41XX
86 depends on MACH_VR41XX && HW_HAS_PCI 86 depends on MACH_VR41XX && HW_HAS_PCI
87 default y 87 default y
88 select PCI 88 select PCI
89
90config VRC4173
91 tristate "Add NEC VRC4173 companion chip support"
92 depends on MACH_VR41XX && PCI_VR41XX
93 help
94 The NEC VRC4173 is a companion chip for NEC VR4122/VR4131.
diff --git a/arch/mips/vr41xx/common/Makefile b/arch/mips/vr41xx/common/Makefile
index aa373974c80f..975d5caf9d1b 100644
--- a/arch/mips/vr41xx/common/Makefile
+++ b/arch/mips/vr41xx/common/Makefile
@@ -2,7 +2,6 @@
2# Makefile for common code of the NEC VR4100 series. 2# Makefile for common code of the NEC VR4100 series.
3# 3#
4 4
5obj-y += bcu.o cmu.o icu.o init.o irq.o pmu.o type.o 5obj-y += bcu.o cmu.o icu.o init.o irq.o pmu.o type.o
6obj-$(CONFIG_VRC4173) += vrc4173.o
7 6
8EXTRA_AFLAGS := $(CFLAGS) 7EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/vr41xx/common/vrc4173.c b/arch/mips/vr41xx/common/vrc4173.c
deleted file mode 100644
index 3f1ae9721e4e..000000000000
--- a/arch/mips/vr41xx/common/vrc4173.c
+++ /dev/null
@@ -1,582 +0,0 @@
1/*
2 * vrc4173.c, NEC VRC4173 base driver for NEC VR4122/VR4131.
3 *
4 * Copyright (C) 2001-2003 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com>
6 * Copyright (C) 2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
7 * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23#include <linux/init.h>
24#include <linux/module.h>
25#include <linux/interrupt.h>
26#include <linux/irq.h>
27#include <linux/pci.h>
28#include <linux/spinlock.h>
29#include <linux/types.h>
30
31#include <asm/vr41xx/irq.h>
32#include <asm/vr41xx/vr41xx.h>
33#include <asm/vr41xx/vrc4173.h>
34
35MODULE_DESCRIPTION("NEC VRC4173 base driver for NEC VR4122/4131");
36MODULE_AUTHOR("Yoichi Yuasa <yyuasa@mvista.com>");
37MODULE_LICENSE("GPL");
38
39#define VRC4173_CMUCLKMSK 0x040
40 #define MSKPIU 0x0001
41 #define MSKKIU 0x0002
42 #define MSKAIU 0x0004
43 #define MSKPS2CH1 0x0008
44 #define MSKPS2CH2 0x0010
45 #define MSKUSB 0x0020
46 #define MSKCARD1 0x0040
47 #define MSKCARD2 0x0080
48 #define MSKAC97 0x0100
49 #define MSK48MUSB 0x0400
50 #define MSK48MPIN 0x0800
51 #define MSK48MOSC 0x1000
52#define VRC4173_CMUSRST 0x042
53 #define USBRST 0x0001
54 #define CARD1RST 0x0002
55 #define CARD2RST 0x0004
56 #define AC97RST 0x0008
57
58#define VRC4173_SYSINT1REG 0x060
59#define VRC4173_MSYSINT1REG 0x06c
60#define VRC4173_MPIUINTREG 0x06e
61#define VRC4173_MAIUINTREG 0x070
62#define VRC4173_MKIUINTREG 0x072
63
64#define VRC4173_SELECTREG 0x09e
65 #define SEL3 0x0008
66 #define SEL2 0x0004
67 #define SEL1 0x0002
68 #define SEL0 0x0001
69
70static struct pci_device_id vrc4173_id_table[] __devinitdata = {
71 { .vendor = PCI_VENDOR_ID_NEC,
72 .device = PCI_DEVICE_ID_NEC_VRC4173,
73 .subvendor = PCI_ANY_ID,
74 .subdevice = PCI_ANY_ID, },
75 { .vendor = 0, },
76};
77
78unsigned long vrc4173_io_offset = 0;
79
80EXPORT_SYMBOL(vrc4173_io_offset);
81
82static int vrc4173_initialized;
83static uint16_t vrc4173_cmuclkmsk;
84static uint16_t vrc4173_selectreg;
85static DEFINE_SPINLOCK(vrc4173_cmu_lock);
86static DEFINE_SPINLOCK(vrc4173_giu_lock);
87
88static inline void set_cmusrst(uint16_t val)
89{
90 uint16_t cmusrst;
91
92 cmusrst = vrc4173_inw(VRC4173_CMUSRST);
93 cmusrst |= val;
94 vrc4173_outw(cmusrst, VRC4173_CMUSRST);
95}
96
97static inline void clear_cmusrst(uint16_t val)
98{
99 uint16_t cmusrst;
100
101 cmusrst = vrc4173_inw(VRC4173_CMUSRST);
102 cmusrst &= ~val;
103 vrc4173_outw(cmusrst, VRC4173_CMUSRST);
104}
105
106void vrc4173_supply_clock(vrc4173_clock_t clock)
107{
108 if (vrc4173_initialized) {
109 spin_lock_irq(&vrc4173_cmu_lock);
110
111 switch (clock) {
112 case VRC4173_PIU_CLOCK:
113 vrc4173_cmuclkmsk |= MSKPIU;
114 break;
115 case VRC4173_KIU_CLOCK:
116 vrc4173_cmuclkmsk |= MSKKIU;
117 break;
118 case VRC4173_AIU_CLOCK:
119 vrc4173_cmuclkmsk |= MSKAIU;
120 break;
121 case VRC4173_PS2_CH1_CLOCK:
122 vrc4173_cmuclkmsk |= MSKPS2CH1;
123 break;
124 case VRC4173_PS2_CH2_CLOCK:
125 vrc4173_cmuclkmsk |= MSKPS2CH2;
126 break;
127 case VRC4173_USBU_PCI_CLOCK:
128 set_cmusrst(USBRST);
129 vrc4173_cmuclkmsk |= MSKUSB;
130 break;
131 case VRC4173_CARDU1_PCI_CLOCK:
132 set_cmusrst(CARD1RST);
133 vrc4173_cmuclkmsk |= MSKCARD1;
134 break;
135 case VRC4173_CARDU2_PCI_CLOCK:
136 set_cmusrst(CARD2RST);
137 vrc4173_cmuclkmsk |= MSKCARD2;
138 break;
139 case VRC4173_AC97U_PCI_CLOCK:
140 set_cmusrst(AC97RST);
141 vrc4173_cmuclkmsk |= MSKAC97;
142 break;
143 case VRC4173_USBU_48MHz_CLOCK:
144 set_cmusrst(USBRST);
145 vrc4173_cmuclkmsk |= MSK48MUSB;
146 break;
147 case VRC4173_EXT_48MHz_CLOCK:
148 if (vrc4173_cmuclkmsk & MSK48MOSC)
149 vrc4173_cmuclkmsk |= MSK48MPIN;
150 else
151 printk(KERN_WARNING
152 "vrc4173_supply_clock: "
153 "Please supply VRC4173_48MHz_CLOCK first "
154 "rather than VRC4173_EXT_48MHz_CLOCK.\n");
155 break;
156 case VRC4173_48MHz_CLOCK:
157 vrc4173_cmuclkmsk |= MSK48MOSC;
158 break;
159 default:
160 printk(KERN_WARNING
161 "vrc4173_supply_clock: Invalid CLOCK value %u\n", clock);
162 break;
163 }
164
165 vrc4173_outw(vrc4173_cmuclkmsk, VRC4173_CMUCLKMSK);
166
167 switch (clock) {
168 case VRC4173_USBU_PCI_CLOCK:
169 case VRC4173_USBU_48MHz_CLOCK:
170 clear_cmusrst(USBRST);
171 break;
172 case VRC4173_CARDU1_PCI_CLOCK:
173 clear_cmusrst(CARD1RST);
174 break;
175 case VRC4173_CARDU2_PCI_CLOCK:
176 clear_cmusrst(CARD2RST);
177 break;
178 case VRC4173_AC97U_PCI_CLOCK:
179 clear_cmusrst(AC97RST);
180 break;
181 default:
182 break;
183 }
184
185 spin_unlock_irq(&vrc4173_cmu_lock);
186 }
187}
188
189EXPORT_SYMBOL(vrc4173_supply_clock);
190
191void vrc4173_mask_clock(vrc4173_clock_t clock)
192{
193 if (vrc4173_initialized) {
194 spin_lock_irq(&vrc4173_cmu_lock);
195
196 switch (clock) {
197 case VRC4173_PIU_CLOCK:
198 vrc4173_cmuclkmsk &= ~MSKPIU;
199 break;
200 case VRC4173_KIU_CLOCK:
201 vrc4173_cmuclkmsk &= ~MSKKIU;
202 break;
203 case VRC4173_AIU_CLOCK:
204 vrc4173_cmuclkmsk &= ~MSKAIU;
205 break;
206 case VRC4173_PS2_CH1_CLOCK:
207 vrc4173_cmuclkmsk &= ~MSKPS2CH1;
208 break;
209 case VRC4173_PS2_CH2_CLOCK:
210 vrc4173_cmuclkmsk &= ~MSKPS2CH2;
211 break;
212 case VRC4173_USBU_PCI_CLOCK:
213 set_cmusrst(USBRST);
214 vrc4173_cmuclkmsk &= ~MSKUSB;
215 break;
216 case VRC4173_CARDU1_PCI_CLOCK:
217 set_cmusrst(CARD1RST);
218 vrc4173_cmuclkmsk &= ~MSKCARD1;
219 break;
220 case VRC4173_CARDU2_PCI_CLOCK:
221 set_cmusrst(CARD2RST);
222 vrc4173_cmuclkmsk &= ~MSKCARD2;
223 break;
224 case VRC4173_AC97U_PCI_CLOCK:
225 set_cmusrst(AC97RST);
226 vrc4173_cmuclkmsk &= ~MSKAC97;
227 break;
228 case VRC4173_USBU_48MHz_CLOCK:
229 set_cmusrst(USBRST);
230 vrc4173_cmuclkmsk &= ~MSK48MUSB;
231 break;
232 case VRC4173_EXT_48MHz_CLOCK:
233 vrc4173_cmuclkmsk &= ~MSK48MPIN;
234 break;
235 case VRC4173_48MHz_CLOCK:
236 vrc4173_cmuclkmsk &= ~MSK48MOSC;
237 break;
238 default:
239 printk(KERN_WARNING "vrc4173_mask_clock: Invalid CLOCK value %u\n", clock);
240 break;
241 }
242
243 vrc4173_outw(vrc4173_cmuclkmsk, VRC4173_CMUCLKMSK);
244
245 switch (clock) {
246 case VRC4173_USBU_PCI_CLOCK:
247 case VRC4173_USBU_48MHz_CLOCK:
248 clear_cmusrst(USBRST);
249 break;
250 case VRC4173_CARDU1_PCI_CLOCK:
251 clear_cmusrst(CARD1RST);
252 break;
253 case VRC4173_CARDU2_PCI_CLOCK:
254 clear_cmusrst(CARD2RST);
255 break;
256 case VRC4173_AC97U_PCI_CLOCK:
257 clear_cmusrst(AC97RST);
258 break;
259 default:
260 break;
261 }
262
263 spin_unlock_irq(&vrc4173_cmu_lock);
264 }
265}
266
267EXPORT_SYMBOL(vrc4173_mask_clock);
268
269static inline void vrc4173_cmu_init(void)
270{
271 vrc4173_cmuclkmsk = vrc4173_inw(VRC4173_CMUCLKMSK);
272
273 spin_lock_init(&vrc4173_cmu_lock);
274}
275
276void vrc4173_select_function(vrc4173_function_t function)
277{
278 if (vrc4173_initialized) {
279 spin_lock_irq(&vrc4173_giu_lock);
280
281 switch(function) {
282 case PS2_CHANNEL1:
283 vrc4173_selectreg |= SEL2;
284 break;
285 case PS2_CHANNEL2:
286 vrc4173_selectreg |= SEL1;
287 break;
288 case TOUCHPANEL:
289 vrc4173_selectreg &= SEL2 | SEL1 | SEL0;
290 break;
291 case KEYBOARD_8SCANLINES:
292 vrc4173_selectreg &= SEL3 | SEL2 | SEL1;
293 break;
294 case KEYBOARD_10SCANLINES:
295 vrc4173_selectreg &= SEL3 | SEL2;
296 break;
297 case KEYBOARD_12SCANLINES:
298 vrc4173_selectreg &= SEL3;
299 break;
300 case GPIO_0_15PINS:
301 vrc4173_selectreg |= SEL0;
302 break;
303 case GPIO_16_20PINS:
304 vrc4173_selectreg |= SEL3;
305 break;
306 }
307
308 vrc4173_outw(vrc4173_selectreg, VRC4173_SELECTREG);
309
310 spin_unlock_irq(&vrc4173_giu_lock);
311 }
312}
313
314EXPORT_SYMBOL(vrc4173_select_function);
315
316static inline void vrc4173_giu_init(void)
317{
318 vrc4173_selectreg = vrc4173_inw(VRC4173_SELECTREG);
319
320 spin_lock_init(&vrc4173_giu_lock);
321}
322
323void vrc4173_enable_piuint(uint16_t mask)
324{
325 struct irq_desc *desc = irq_desc + VRC4173_PIU_IRQ;
326 unsigned long flags;
327 uint16_t val;
328
329 spin_lock_irqsave(&desc->lock, flags);
330 val = vrc4173_inw(VRC4173_MPIUINTREG);
331 val |= mask;
332 vrc4173_outw(val, VRC4173_MPIUINTREG);
333 spin_unlock_irqrestore(&desc->lock, flags);
334}
335
336EXPORT_SYMBOL(vrc4173_enable_piuint);
337
338void vrc4173_disable_piuint(uint16_t mask)
339{
340 struct irq_desc *desc = irq_desc + VRC4173_PIU_IRQ;
341 unsigned long flags;
342 uint16_t val;
343
344 spin_lock_irqsave(&desc->lock, flags);
345 val = vrc4173_inw(VRC4173_MPIUINTREG);
346 val &= ~mask;
347 vrc4173_outw(val, VRC4173_MPIUINTREG);
348 spin_unlock_irqrestore(&desc->lock, flags);
349}
350
351EXPORT_SYMBOL(vrc4173_disable_piuint);
352
353void vrc4173_enable_aiuint(uint16_t mask)
354{
355 struct irq_desc *desc = irq_desc + VRC4173_AIU_IRQ;
356 unsigned long flags;
357 uint16_t val;
358
359 spin_lock_irqsave(&desc->lock, flags);
360 val = vrc4173_inw(VRC4173_MAIUINTREG);
361 val |= mask;
362 vrc4173_outw(val, VRC4173_MAIUINTREG);
363 spin_unlock_irqrestore(&desc->lock, flags);
364}
365
366EXPORT_SYMBOL(vrc4173_enable_aiuint);
367
368void vrc4173_disable_aiuint(uint16_t mask)
369{
370 struct irq_desc *desc = irq_desc + VRC4173_AIU_IRQ;
371 unsigned long flags;
372 uint16_t val;
373
374 spin_lock_irqsave(&desc->lock, flags);
375 val = vrc4173_inw(VRC4173_MAIUINTREG);
376 val &= ~mask;
377 vrc4173_outw(val, VRC4173_MAIUINTREG);
378 spin_unlock_irqrestore(&desc->lock, flags);
379}
380
381EXPORT_SYMBOL(vrc4173_disable_aiuint);
382
383void vrc4173_enable_kiuint(uint16_t mask)
384{
385 struct irq_desc *desc = irq_desc + VRC4173_KIU_IRQ;
386 unsigned long flags;
387 uint16_t val;
388
389 spin_lock_irqsave(&desc->lock, flags);
390 val = vrc4173_inw(VRC4173_MKIUINTREG);
391 val |= mask;
392 vrc4173_outw(val, VRC4173_MKIUINTREG);
393 spin_unlock_irqrestore(&desc->lock, flags);
394}
395
396EXPORT_SYMBOL(vrc4173_enable_kiuint);
397
398void vrc4173_disable_kiuint(uint16_t mask)
399{
400 struct irq_desc *desc = irq_desc + VRC4173_KIU_IRQ;
401 unsigned long flags;
402 uint16_t val;
403
404 spin_lock_irqsave(&desc->lock, flags);
405 val = vrc4173_inw(VRC4173_MKIUINTREG);
406 val &= ~mask;
407 vrc4173_outw(val, VRC4173_MKIUINTREG);
408 spin_unlock_irqrestore(&desc->lock, flags);
409}
410
411EXPORT_SYMBOL(vrc4173_disable_kiuint);
412
413static void enable_vrc4173_irq(unsigned int irq)
414{
415 uint16_t val;
416
417 val = vrc4173_inw(VRC4173_MSYSINT1REG);
418 val |= (uint16_t)1 << (irq - VRC4173_IRQ_BASE);
419 vrc4173_outw(val, VRC4173_MSYSINT1REG);
420}
421
422static void disable_vrc4173_irq(unsigned int irq)
423{
424 uint16_t val;
425
426 val = vrc4173_inw(VRC4173_MSYSINT1REG);
427 val &= ~((uint16_t)1 << (irq - VRC4173_IRQ_BASE));
428 vrc4173_outw(val, VRC4173_MSYSINT1REG);
429}
430
431static unsigned int startup_vrc4173_irq(unsigned int irq)
432{
433 enable_vrc4173_irq(irq);
434 return 0; /* never anything pending */
435}
436
437#define shutdown_vrc4173_irq disable_vrc4173_irq
438#define ack_vrc4173_irq disable_vrc4173_irq
439
440static void end_vrc4173_irq(unsigned int irq)
441{
442 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
443 enable_vrc4173_irq(irq);
444}
445
446static struct irq_chip vrc4173_irq_type = {
447 .typename = "VRC4173",
448 .startup = startup_vrc4173_irq,
449 .shutdown = shutdown_vrc4173_irq,
450 .enable = enable_vrc4173_irq,
451 .disable = disable_vrc4173_irq,
452 .ack = ack_vrc4173_irq,
453 .end = end_vrc4173_irq,
454};
455
456static int vrc4173_get_irq_number(int irq)
457{
458 uint16_t status, mask;
459 int i;
460
461 status = vrc4173_inw(VRC4173_SYSINT1REG);
462 mask = vrc4173_inw(VRC4173_MSYSINT1REG);
463
464 status &= mask;
465 if (status) {
466 for (i = 0; i < 16; i++)
467 if (status & (0x0001 << i))
468 return VRC4173_IRQ(i);
469 }
470
471 return -EINVAL;
472}
473
474static inline int vrc4173_icu_init(int cascade_irq)
475{
476 int i;
477
478 if (cascade_irq < GIU_IRQ(0) || cascade_irq > GIU_IRQ(15))
479 return -EINVAL;
480
481 vrc4173_outw(0, VRC4173_MSYSINT1REG);
482
483 vr41xx_set_irq_trigger(GIU_IRQ_TO_PIN(cascade_irq), TRIGGER_LEVEL, SIGNAL_THROUGH);
484 vr41xx_set_irq_level(GIU_IRQ_TO_PIN(cascade_irq), LEVEL_LOW);
485
486 for (i = VRC4173_IRQ_BASE; i <= VRC4173_IRQ_LAST; i++)
487 irq_desc[i].chip = &vrc4173_irq_type;
488
489 return 0;
490}
491
492static int __devinit vrc4173_probe(struct pci_dev *dev,
493 const struct pci_device_id *id)
494{
495 unsigned long start, flags;
496 int err;
497
498 err = pci_enable_device(dev);
499 if (err < 0) {
500 printk(KERN_ERR "vrc4173: Failed to enable PCI device, aborting\n");
501 return err;
502 }
503
504 pci_set_master(dev);
505
506 start = pci_resource_start(dev, 0);
507 if (start == 0) {
508 printk(KERN_ERR "vrc4173:No such PCI I/O resource, aborting\n");
509 return -ENXIO;
510 }
511
512 flags = pci_resource_flags(dev, 0);
513 if ((flags & IORESOURCE_IO) == 0) {
514 printk(KERN_ERR "vrc4173: No such PCI I/O resource, aborting\n");
515 return -ENXIO;
516 }
517
518 err = pci_request_regions(dev, "NEC VRC4173");
519 if (err < 0) {
520 printk(KERN_ERR "vrc4173: PCI resources are busy, aborting\n");
521 return err;
522 }
523
524 set_vrc4173_io_offset(start);
525
526 vrc4173_cmu_init();
527 vrc4173_giu_init();
528
529 err = vrc4173_icu_init(dev->irq);
530 if (err < 0) {
531 printk(KERN_ERR "vrc4173: Invalid IRQ %d, aborting\n", dev->irq);
532 return err;
533 }
534
535 err = vr41xx_cascade_irq(dev->irq, vrc4173_get_irq_number);
536 if (err < 0) {
537 printk(KERN_ERR "vrc4173: IRQ resource %d is busy, aborting\n", dev->irq);
538 return err;
539 }
540
541 printk(KERN_INFO
542 "NEC VRC4173 at 0x%#08lx, IRQ is cascaded to %d\n", start, dev->irq);
543
544 return 0;
545}
546
547static void vrc4173_remove(struct pci_dev *dev)
548{
549 free_irq(dev->irq, NULL);
550
551 pci_release_regions(dev);
552}
553
554static struct pci_driver vrc4173_driver = {
555 .name = "NEC VRC4173",
556 .probe = vrc4173_probe,
557 .remove = vrc4173_remove,
558 .id_table = vrc4173_id_table,
559};
560
561static int __devinit vrc4173_init(void)
562{
563 int err;
564
565 err = pci_register_driver(&vrc4173_driver);
566 if (err < 0)
567 return err;
568
569 vrc4173_initialized = 1;
570
571 return 0;
572}
573
574static void __devexit vrc4173_exit(void)
575{
576 vrc4173_initialized = 0;
577
578 pci_unregister_driver(&vrc4173_driver);
579}
580
581module_init(vrc4173_init);
582module_exit(vrc4173_exit);