1 /*
2 * ASP 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/irq.h>
17 #include <linux/module.h>
18 #include <linux/slab.h>
19 #include <linux/types.h>
20 #include <asm/gsc.h>
21 #include <asm/led.h>
22
23 #include "busdevice.h"
24
25 #define ASP_GSC_IRQ 3 /* hardcoded interrupt for GSC */
26
27 #define ASP_VER_OFFSET 0x20 /* offset of ASP version */
28
29 #define ASP_LED_ADDR 0xf0800020
30
31 #define VIPER_INT_WORD 0xFFFBF088 /* addr of viper interrupt word */
32
asp_choose_irq(struct parisc_device * dev)33 static int asp_choose_irq(struct parisc_device *dev)
34 {
35 int irq = -1;
36
37 switch (dev->id.sversion) {
38 case 0x71: irq = 22; break; /* SCSI */
39 case 0x72: irq = 23; break; /* LAN */
40 case 0x73: irq = 30; break; /* HIL */
41 case 0x74: irq = 24; break; /* Centronics */
42 case 0x75: irq = (dev->hw_path == 4) ? 26 : 25; break; /* RS232 */
43 case 0x76: irq = 21; break; /* EISA BA */
44 case 0x77: irq = 20; break; /* Graphics1 */
45 case 0x7a: irq = 18; break; /* Audio (Bushmaster) */
46 case 0x7b: irq = 18; break; /* Audio (Scorpio) */
47 case 0x7c: irq = 28; break; /* FW SCSI */
48 case 0x7d: irq = 27; break; /* FDDI */
49 case 0x7f: irq = 18; break; /* Audio (Outfield) */
50 }
51 return irq;
52 }
53
54 /* There are two register ranges we're interested in. Interrupt /
55 * Status / LED are at 0xf080xxxx and Asp special registers are at
56 * 0xf082fxxx. PDC only tells us that Asp is at 0xf082f000, so for
57 * the purposes of interrupt handling, we have to tell other bits of
58 * the kernel to look at the other registers.
59 */
60 #define ASP_INTERRUPT_ADDR 0xf0800000
61
62 int __init
asp_init_chip(struct parisc_device * dev)63 asp_init_chip(struct parisc_device *dev)
64 {
65 struct busdevice *asp;
66 struct gsc_irq gsc_irq;
67 int irq, ret;
68
69 asp = kmalloc(sizeof(struct busdevice), GFP_KERNEL);
70 if(!asp)
71 return -ENOMEM;
72
73 asp->version = gsc_readb(dev->hpa + ASP_VER_OFFSET) & 0xf;
74 asp->name = (asp->version == 1) ? "Asp" : "Cutoff";
75 asp->hpa = ASP_INTERRUPT_ADDR;
76
77 printk(KERN_INFO "%s version %d at 0x%lx found.\n",
78 asp->name, asp->version, dev->hpa);
79
80 /* the IRQ ASP should use */
81 ret = -EBUSY;
82 irq = gsc_claim_irq(&gsc_irq, ASP_GSC_IRQ);
83 if (irq < 0) {
84 printk(KERN_ERR "%s(): cannot get GSC irq\n", __FUNCTION__);
85 goto out;
86 }
87
88 ret = request_irq(gsc_irq.irq, busdev_barked, 0, "asp", asp);
89 if (ret < 0)
90 goto out;
91
92 /* Save this for debugging later */
93 asp->parent_irq = gsc_irq.irq;
94 asp->eim = ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data;
95
96 /* Program VIPER to interrupt on the ASP irq */
97 gsc_writel((1 << (31 - ASP_GSC_IRQ)),VIPER_INT_WORD);
98
99 /* Done init'ing, register this driver */
100 ret = gsc_common_irqsetup(dev, asp);
101 if (ret)
102 goto out;
103
104 fixup_child_irqs(dev, asp->busdev_region->data.irqbase, asp_choose_irq);
105 /* Mongoose is a sibling of Asp, not a child... */
106 fixup_child_irqs(dev->parent, asp->busdev_region->data.irqbase,
107 asp_choose_irq);
108
109 /* initialize the chassis LEDs */
110 #ifdef CONFIG_CHASSIS_LCD_LED
111 register_led_driver(DISPLAY_MODEL_OLD_ASP, LED_CMD_REG_NONE,
112 (char *)ASP_LED_ADDR);
113 #endif
114
115 return 0;
116
117 out:
118 kfree(asp);
119 return ret;
120 }
121
122 static struct parisc_device_id asp_tbl[] = {
123 { HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00070 },
124 { 0, }
125 };
126
127 struct parisc_driver asp_driver = {
128 name: "Asp",
129 id_table: asp_tbl,
130 probe: asp_init_chip,
131 };
132