vserver 1.9.5.x5
[linux-2.6.git] / drivers / parisc / wax.c
1 /*
2  *      WAX Device Driver
3  *
4  *      (c) Copyright 2000 The Puffin Group Inc.
5  *
6  *      This program is free software; you can redistribute it and/or modify
7  *      it under the terms of the GNU General Public License as published by
8  *      the Free Software Foundation; either version 2 of the License, or
9  *      (at your option) any later version.
10  *
11  *      by Helge Deller <deller@gmx.de>
12  */
13
14 #include <linux/errno.h>
15 #include <linux/init.h>
16 #include <linux/interrupt.h>
17 #include <linux/ioport.h>
18 #include <linux/slab.h>
19 #include <linux/module.h>
20 #include <linux/types.h>
21
22 #include <asm/io.h>
23 #include <asm/hardware.h>
24
25 #include "gsc.h"
26
27 #define WAX_GSC_IRQ     7       /* Hardcoded Interrupt for GSC */
28 #define WAX_GSC_NMI_IRQ 29
29
30 static void wax_choose_irq(struct parisc_device *dev, void *ctrl)
31 {
32         int irq;
33
34         switch (dev->id.sversion) {
35                 case 0x73:      irq =  1; break; /* HIL */
36                 case 0x8c:      irq =  6; break; /* RS232 */
37                 case 0x90:      irq = 10; break; /* WAX EISA BA */
38                 default:        return;          /* Unknown */
39         }
40
41         gsc_asic_assign_irq(ctrl, irq, &dev->irq);
42 }
43
44 static void __init
45 wax_init_irq(struct gsc_asic *wax)
46 {
47         unsigned long base = wax->hpa;
48
49         /* Stop WAX barking for a bit */
50         gsc_writel(0x00000000, base+OFFSET_IMR);
51
52         /* clear pending interrupts */
53         gsc_readl(base+OFFSET_IRR);
54
55         /* We're not really convinced we want to reset the onboard
56          * devices. Firmware does it for us...
57          */
58
59         /* Resets */
60 //      gsc_writel(0xFFFFFFFF, base+0x1000); /* HIL */
61 //      gsc_writel(0xFFFFFFFF, base+0x2000); /* RS232-B on Wax */
62         
63         /* Ok we hit it on the head with a hammer, our Dog is now
64         ** comatose and muzzled.  Devices will now unmask WAX
65         ** interrupts as they are registered as irq's in the WAX range.
66         */
67 }
68
69 int __init
70 wax_init_chip(struct parisc_device *dev)
71 {
72         struct gsc_asic *wax;
73         struct parisc_device *parent;
74         struct gsc_irq gsc_irq;
75         int ret;
76
77         wax = kmalloc(sizeof(*wax), GFP_KERNEL);
78         if (!wax)
79                 return -ENOMEM;
80
81         wax->name = "Wax";
82         wax->hpa = dev->hpa;
83
84         wax->version = 0;   /* gsc_readb(wax->hpa+WAX_VER); */
85         printk(KERN_INFO "%s at 0x%lx found.\n", wax->name, wax->hpa);
86
87         /* Stop wax hissing for a bit */
88         wax_init_irq(wax);
89
90         /* the IRQ wax should use */
91         dev->irq = gsc_claim_irq(&gsc_irq, WAX_GSC_IRQ);
92         if (dev->irq < 0) {
93                 printk(KERN_ERR "%s(): cannot get GSC irq\n",
94                                 __FUNCTION__);
95                 kfree(wax);
96                 return -EBUSY;
97         }
98
99         wax->eim = ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data;
100
101         ret = request_irq(gsc_irq.irq, gsc_asic_intr, 0, "wax", wax);
102         if (ret < 0) {
103                 kfree(wax);
104                 return ret;
105         }
106
107         /* enable IRQ's for devices below WAX */
108         gsc_writel(wax->eim, wax->hpa + OFFSET_IAR);
109
110         /* Done init'ing, register this driver */
111         ret = gsc_common_setup(dev, wax);
112         if (ret) {
113                 kfree(wax);
114                 return ret;
115         }
116
117         gsc_fixup_irqs(dev, wax, wax_choose_irq);
118         /* On 715-class machines, Wax EISA is a sibling of Wax, not a child. */
119         parent = parisc_parent(dev);
120         if (parent->id.hw_type != HPHW_IOA) {
121                 gsc_fixup_irqs(parent, wax, wax_choose_irq);
122         }
123
124         return ret;
125 }
126
127 static struct parisc_device_id wax_tbl[] = {
128         { HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008e },
129         { 0, }
130 };
131
132 MODULE_DEVICE_TABLE(parisc, wax_tbl);
133
134 struct parisc_driver wax_driver = {
135         .name =         "Wax",
136         .id_table =     wax_tbl,
137         .probe =        wax_init_chip,
138 };