1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <linux/errno.h>
18#include <linux/init.h>
19#include <linux/interrupt.h>
20#include <linux/slab.h>
21#include <linux/module.h>
22#include <linux/pm.h>
23#include <linux/types.h>
24
25#include <asm/io.h>
26#include <asm/hardware.h>
27#include <asm/led.h>
28
29#include "gsc.h"
30
31
32#define LASI_VER 0xC008
33
34#define LASI_IO_CONF 0x7FFFE
35#define LASI_IO_CONF2 0x7FFFF
36
37static void lasi_choose_irq(struct parisc_device *dev, void *ctrl)
38{
39 int irq;
40
41 switch (dev->id.sversion) {
42 case 0x74: irq = 7; break;
43 case 0x7B: irq = 13; break;
44 case 0x81: irq = 14; break;
45 case 0x82: irq = 9; break;
46 case 0x83: irq = 20; break;
47 case 0x84: irq = 26; break;
48 case 0x87: irq = 18; break;
49 case 0x8A: irq = 8; break;
50 case 0x8C: irq = 5; break;
51 case 0x8D: irq = (dev->hw_path == 13) ? 16 : 17; break;
52
53 default: return;
54 }
55
56 gsc_asic_assign_irq(ctrl, irq, &dev->irq);
57}
58
59static void __init
60lasi_init_irq(struct gsc_asic *this_lasi)
61{
62 unsigned long lasi_base = this_lasi->hpa;
63
64
65 gsc_writel(0x00000000, lasi_base+OFFSET_IMR);
66
67
68 gsc_readl(lasi_base+OFFSET_IRR);
69
70
71
72
73
74
75
76 if(pdc_add_valid(lasi_base+0x4004) == PDC_OK)
77 gsc_writel(0xFFFFFFFF, lasi_base+0x4004);
78
79
80 gsc_writel(0xFFFFFFFF, lasi_base+0x7000);
81 gsc_writel(0xFFFFFFFF, lasi_base+0x8000);
82 gsc_writel(0xFFFFFFFF, lasi_base+0xA000);
83
84
85
86
87
88
89
90
91}
92
93
94
95
96
97
98
99
100
101
102
103
104#ifndef CONFIG_CHASSIS_LCD_LED
105
106#define lasi_led_init(x)
107
108#else
109
110static void __init lasi_led_init(unsigned long lasi_hpa)
111{
112 unsigned long datareg;
113
114 switch (CPU_HVERSION) {
115
116
117 case 0x600:
118 case 0x601:
119 case 0x602:
120 case 0x603:
121 case 0x604:
122 case 0x605:
123 datareg = lasi_hpa + 0x0000C000;
124 gsc_writeb(0, datareg);
125 return;
126
127
128 case 0x60A:
129 case 0x60B:
130 case 0x60C:
131 case 0x60D:
132 case 0x60E:
133 datareg = lasi_hpa - 0x00020000;
134 break;
135
136 default:
137 datareg = lasi_hpa + 0x0000C000;
138 break;
139 }
140
141 register_led_driver(DISPLAY_MODEL_LASI, LED_CMD_REG_NONE, datareg);
142}
143#endif
144
145
146
147
148
149
150
151
152
153static unsigned long lasi_power_off_hpa __read_mostly;
154
155static void lasi_power_off(void)
156{
157 unsigned long datareg;
158
159
160 datareg = lasi_power_off_hpa + 0x0000C000;
161
162
163 gsc_writel(0x02, datareg);
164}
165
166static int __init lasi_init_chip(struct parisc_device *dev)
167{
168 extern void (*chassis_power_off)(void);
169 struct gsc_asic *lasi;
170 struct gsc_irq gsc_irq;
171 int ret;
172
173 lasi = kzalloc(sizeof(*lasi), GFP_KERNEL);
174 if (!lasi)
175 return -ENOMEM;
176
177 lasi->name = "Lasi";
178 lasi->hpa = dev->hpa.start;
179
180
181 lasi->version = gsc_readl(lasi->hpa + LASI_VER) & 0xf;
182 printk(KERN_INFO "%s version %d at 0x%lx found.\n",
183 lasi->name, lasi->version, lasi->hpa);
184
185
186 lasi_led_init(lasi->hpa);
187
188
189 lasi_init_irq(lasi);
190
191
192 dev->irq = gsc_alloc_irq(&gsc_irq);
193 if (dev->irq < 0) {
194 printk(KERN_ERR "%s(): cannot get GSC irq\n",
195 __func__);
196 kfree(lasi);
197 return -EBUSY;
198 }
199
200 lasi->eim = ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data;
201
202 ret = request_irq(gsc_irq.irq, gsc_asic_intr, 0, "lasi", lasi);
203 if (ret < 0) {
204 kfree(lasi);
205 return ret;
206 }
207
208
209 gsc_writel(lasi->eim, lasi->hpa + OFFSET_IAR);
210
211
212 ret = gsc_common_setup(dev, lasi);
213 if (ret) {
214 kfree(lasi);
215 return ret;
216 }
217
218 gsc_fixup_irqs(dev, lasi, lasi_choose_irq);
219
220
221
222
223
224 lasi_power_off_hpa = lasi->hpa;
225 chassis_power_off = lasi_power_off;
226
227 return ret;
228}
229
230static struct parisc_device_id lasi_tbl[] = {
231 { HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00081 },
232 { 0, }
233};
234
235struct parisc_driver lasi_driver = {
236 .name = "lasi",
237 .id_table = lasi_tbl,
238 .probe = lasi_init_chip,
239};
240