blob: 813c2c24ab1ef8a1273becb3dbfd2ecabcadaebf [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
29static void wax_choose_irq(struct parisc_device *dev, void *ctrl)
30{
31 int irq;
32
33 switch (dev->id.sversion) {
34 case 0x73: irq = 1; break; /* i8042 General */
35 case 0x8c: irq = 6; break; /* Serial */
36 case 0x90: irq = 10; break; /* EISA */
37 default: return; /* Unknown */
38 }
39
40 gsc_asic_assign_irq(ctrl, irq, &dev->irq);
41
42 switch (dev->id.sversion) {
43 case 0x73: irq = 2; break; /* i8042 High-priority */
44 case 0x90: irq = 0; break; /* EISA NMI */
45 default: return; /* No secondary IRQ */
46 }
47
48 gsc_asic_assign_irq(ctrl, irq, &dev->aux_irq);
49}
50
51static void __init
52wax_init_irq(struct gsc_asic *wax)
53{
54 unsigned long base = wax->hpa;
55
56 /* Wax-off */
57 gsc_writel(0x00000000, base+OFFSET_IMR);
58
59 /* clear pending interrupts */
60 gsc_readl(base+OFFSET_IRR);
61
62 /* We're not really convinced we want to reset the onboard
63 * devices. Firmware does it for us...
64 */
65
66 /* Resets */
67// gsc_writel(0xFFFFFFFF, base+0x1000); /* HIL */
68// gsc_writel(0xFFFFFFFF, base+0x2000); /* RS232-B on Wax */
69}
70
71int __init
72wax_init_chip(struct parisc_device *dev)
73{
74 struct gsc_asic *wax;
75 struct parisc_device *parent;
76 struct gsc_irq gsc_irq;
77 int ret;
78
Helge Dellercb6fc182006-01-17 12:40:40 -070079 wax = kzalloc(sizeof(*wax), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 if (!wax)
81 return -ENOMEM;
82
83 wax->name = "wax";
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040084 wax->hpa = dev->hpa.start;
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
86 wax->version = 0; /* gsc_readb(wax->hpa+WAX_VER); */
87 printk(KERN_INFO "%s at 0x%lx found.\n", wax->name, wax->hpa);
88
89 /* Stop wax hissing for a bit */
90 wax_init_irq(wax);
91
92 /* the IRQ wax should use */
93 dev->irq = gsc_claim_irq(&gsc_irq, WAX_GSC_IRQ);
94 if (dev->irq < 0) {
95 printk(KERN_ERR "%s(): cannot get GSC irq\n",
96 __FUNCTION__);
97 kfree(wax);
98 return -EBUSY;
99 }
100
101 wax->eim = ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data;
102
103 ret = request_irq(gsc_irq.irq, gsc_asic_intr, 0, "wax", wax);
104 if (ret < 0) {
105 kfree(wax);
106 return ret;
107 }
108
109 /* enable IRQ's for devices below WAX */
110 gsc_writel(wax->eim, wax->hpa + OFFSET_IAR);
111
112 /* Done init'ing, register this driver */
113 ret = gsc_common_setup(dev, wax);
114 if (ret) {
115 kfree(wax);
116 return ret;
117 }
118
119 gsc_fixup_irqs(dev, wax, wax_choose_irq);
120 /* On 715-class machines, Wax EISA is a sibling of Wax, not a child. */
121 parent = parisc_parent(dev);
122 if (parent->id.hw_type != HPHW_IOA) {
123 gsc_fixup_irqs(parent, wax, wax_choose_irq);
124 }
125
126 return ret;
127}
128
129static struct parisc_device_id wax_tbl[] = {
130 { HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008e },
131 { 0, }
132};
133
134MODULE_DEVICE_TABLE(parisc, wax_tbl);
135
136struct parisc_driver wax_driver = {
137 .name = "wax",
138 .id_table = wax_tbl,
139 .probe = wax_init_chip,
140};