4 * (c) Copyright 1999 Red Hat Software
5 * Portions (c) Copyright 1999 The Puffin Group Inc.
6 * Portions (c) Copyright 1999 Hewlett-Packard
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * by Alan Cox <alan@redhat.com> and
14 * Alex deVries <alex@onefishtwo.ca>
17 #include <linux/errno.h>
18 #include <linux/init.h>
19 #include <linux/irq.h>
20 #include <linux/slab.h>
21 #include <linux/module.h>
23 #include <linux/slab.h>
24 #include <linux/types.h>
27 #include <asm/hardware.h>
33 #define LASI_VER 0xC008 /* LASI Version */
35 #define LASI_IO_CONF 0x7FFFE /* LASI primary configuration register */
36 #define LASI_IO_CONF2 0x7FFFF /* LASI secondary configuration register */
38 static int lasi_choose_irq(struct parisc_device
*dev
)
43 ** "irq" bits below are numbered relative to most significant bit.
45 switch (dev
->id
.sversion
) {
46 case 0x74: irq
= 24; break; /* Centronics */
47 case 0x7B: irq
= 18; break; /* Audio */
48 case 0x81: irq
= 17; break; /* Lasi itself */
49 case 0x82: irq
= 22; break; /* SCSI */
50 case 0x83: irq
= 11; break; /* Floppy */
51 case 0x84: irq
= 5; break; /* PS/2 Keyboard */
52 case 0x87: irq
= 13; break; /* ISDN */
53 case 0x8A: irq
= 23; break; /* LAN */
54 case 0x8C: irq
= 26; break; /* RS232 */
55 case 0x8D: irq
= (dev
->hw_path
== 13) ? 15 : 14;
56 break; /* Telephone */
57 default: irq
= -1; break; /* unknown */
64 lasi_init_irq(struct busdevice
*this_lasi
)
66 unsigned long lasi_base
= this_lasi
->hpa
;
68 /* Stop LASI barking for a bit */
69 gsc_writel(0x00000000, lasi_base
+OFFSET_IMR
);
71 /* clear pending interrupts */
72 gsc_readl(lasi_base
+OFFSET_IRR
);
74 /* We're not really convinced we want to reset the onboard
75 * devices. Firmware does it for us...
79 /* gsc_writel(0xFFFFFFFF, lasi_base+0x2000);*/ /* Parallel */
80 if(pdc_add_valid(lasi_base
+0x4004) == PDC_OK
)
81 gsc_writel(0xFFFFFFFF, lasi_base
+0x4004); /* Audio */
82 /* gsc_writel(0xFFFFFFFF, lasi_base+0x5000);*/ /* Serial */
83 /* gsc_writel(0xFFFFFFFF, lasi_base+0x6000);*/ /* SCSI */
84 gsc_writel(0xFFFFFFFF, lasi_base
+0x7000); /* LAN */
85 gsc_writel(0xFFFFFFFF, lasi_base
+0x8000); /* Keyboard */
86 gsc_writel(0xFFFFFFFF, lasi_base
+0xA000); /* FDC */
88 /* Ok we hit it on the head with a hammer, our Dog is now
89 ** comatose and muzzled. Devices will now unmask LASI
90 ** interrupts as they are registered as irq's in the LASI range.
92 /* XXX: I thought it was `awks that got `it on the `ead with an
101 ** lasi_led_init() initializes the LED controller on the LASI.
103 ** Since Mirage and Electra machines use a different LED
104 ** address register, we need to check for these machines
108 #ifndef CONFIG_CHASSIS_LCD_LED
110 #define lasi_led_init(x) /* nothing */
114 void __init
lasi_led_init(unsigned long lasi_hpa
)
116 unsigned long datareg
;
118 switch (CPU_HVERSION
) {
119 /* Gecko machines have only one single LED, which can be permanently
120 turned on by writing a zero into the power control register. */
121 case 0x600: /* Gecko (712/60) */
122 case 0x601: /* Gecko (712/80) */
123 case 0x602: /* Gecko (712/100) */
124 case 0x603: /* Anole 64 (743/64) */
125 case 0x604: /* Anole 100 (743/100) */
126 case 0x605: /* Gecko (712/120) */
127 datareg
= lasi_hpa
+ 0x0000C000;
128 gsc_writeb(0, datareg
);
129 return; /* no need to register the LED interrupt-function */
131 /* Mirage and Electra machines need special offsets */
132 case 0x60A: /* Mirage Jr (715/64) */
133 case 0x60B: /* Mirage 100 */
134 case 0x60C: /* Mirage 100+ */
135 case 0x60D: /* Electra 100 */
136 case 0x60E: /* Electra 120 */
137 datareg
= lasi_hpa
- 0x00020000;
141 datareg
= lasi_hpa
+ 0x0000C000;
145 register_led_driver(DISPLAY_MODEL_LASI
, LED_CMD_REG_NONE
, (char *)datareg
);
152 * Function for lasi to turn off the power. This is accomplished by setting a
153 * 1 to PWR_ON_L in the Power Control Register
157 static unsigned long lasi_power_off_hpa
;
159 static void lasi_power_off(void)
161 unsigned long datareg
;
163 /* calculate addr of the Power Control Register */
164 datareg
= lasi_power_off_hpa
+ 0x0000C000;
166 /* Power down the machine */
167 gsc_writel(0x02, datareg
);
171 lasi_init_chip(struct parisc_device
*dev
)
173 struct busdevice
*lasi
;
174 struct gsc_irq gsc_irq
;
177 lasi
= kmalloc(sizeof(struct busdevice
), GFP_KERNEL
);
182 lasi
->hpa
= dev
->hpa
;
184 /* Check the 4-bit (yes, only 4) version register */
185 lasi
->version
= gsc_readl(lasi
->hpa
+ LASI_VER
) & 0xf;
186 printk(KERN_INFO
"%s version %d at 0x%lx found.\n",
187 lasi
->name
, lasi
->version
, lasi
->hpa
);
189 /* initialize the chassis LEDs really early */
190 lasi_led_init(lasi
->hpa
);
192 /* Stop LASI barking for a bit */
195 /* the IRQ lasi should use */
196 irq
= gsc_alloc_irq(&gsc_irq
);
198 printk(KERN_ERR
"%s(): cannot get GSC irq\n",
204 ret
= request_irq(gsc_irq
.irq
, busdev_barked
, 0, "lasi", lasi
);
210 /* Save this for debugging later */
211 lasi
->parent_irq
= gsc_irq
.irq
;
212 lasi
->eim
= ((u32
) gsc_irq
.txn_addr
) | gsc_irq
.txn_data
;
214 /* enable IRQ's for devices below LASI */
215 gsc_writel(lasi
->eim
, lasi
->hpa
+ OFFSET_IAR
);
217 /* Done init'ing, register this driver */
218 ret
= gsc_common_irqsetup(dev
, lasi
);
224 fixup_child_irqs(dev
, lasi
->busdev_region
->data
.irqbase
,
227 /* initialize the power off function */
228 /* FIXME: Record the LASI HPA for the power off function. This should
229 * ensure that only the first LASI (the one controlling the power off)
230 * should set the HPA here */
231 lasi_power_off_hpa
= lasi
->hpa
;
232 pm_power_off
= lasi_power_off
;
237 static struct parisc_device_id lasi_tbl
[] = {
238 { HPHW_BA
, HVERSION_REV_ANY_ID
, HVERSION_ANY_ID
, 0x00081 },
242 struct parisc_driver lasi_driver
= {
244 .id_table
= lasi_tbl
,
245 .probe
= lasi_init_chip
,