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 <adevries@thepuffingroup.com>
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>
30 #include "busdevice.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 */
81 if(pdc_add_valid(lasi_base+0x4004) == PDC_OK)
82 gsc_writel(0xFFFFFFFF, lasi_base+0x4004); /* Audio */
84 /* gsc_writel(0xFFFFFFFF, lasi_base+0x5000);*/ /* Serial */
85 /* gsc_writel(0xFFFFFFFF, lasi_base+0x6000);*/ /* SCSI */
86 gsc_writel(0xFFFFFFFF, lasi_base+0x7000); /* LAN */
87 gsc_writel(0xFFFFFFFF, lasi_base+0x8000); /* Keyboard */
88 gsc_writel(0xFFFFFFFF, lasi_base+0xA000); /* FDC */
90 /* Ok we hit it on the head with a hammer, our Dog is now
91 ** comatose and muzzled. Devices will now unmask LASI
92 ** interrupts as they are registered as irq's in the LASI range.
94 /* XXX: I thought it was `awks that got `it on the `ead with an
103 ** lasi_led_init() initializes the LED controller on the LASI.
105 ** Since Mirage and Electra machines use a different LED
106 ** address register, we need to check for these machines
110 #ifndef CONFIG_CHASSIS_LCD_LED
112 #define lasi_led_init(x) /* nothing */
116 void __init lasi_led_init(unsigned long lasi_hpa)
118 unsigned long datareg;
120 switch (CPU_HVERSION) {
121 /* Gecko machines have only one single LED, which can be permanently
122 turned on by writing a zero into the power control register. */
123 case 0x600: /* Gecko (712/60) */
124 case 0x601: /* Gecko (712/80) */
125 case 0x602: /* Gecko (712/100) */
126 case 0x603: /* Anole 64 (743/64) */
127 case 0x604: /* Anole 100 (743/100) */
128 case 0x605: /* Gecko (712/120) */
129 datareg = lasi_hpa + 0x0000C000;
130 gsc_writeb(0, datareg);
131 return; /* no need to register the LED interrupt-function */
133 /* Mirage and Electra machines need special offsets */
134 case 0x60A: /* Mirage Jr (715/64) */
135 case 0x60B: /* Mirage 100 */
136 case 0x60C: /* Mirage 100+ */
137 case 0x60D: /* Electra 100 */
138 case 0x60E: /* Electra 120 */
139 datareg = lasi_hpa - 0x00020000;
143 datareg = lasi_hpa + 0x0000C000;
147 register_led_driver(DISPLAY_MODEL_LASI, LED_CMD_REG_NONE, (char *)datareg);
154 * Function for lasi to turn off the power. This is accomplished by setting a
155 * 1 to PWR_ON_L in the Power Control Register
159 static unsigned long lasi_power_off_hpa;
161 static void lasi_power_off(void)
163 unsigned long datareg;
165 /* calculate addr of the Power Control Register */
166 datareg = lasi_power_off_hpa + 0x0000C000;
168 /* Power down the machine */
169 gsc_writel(0x02, datareg);
173 lasi_init_chip(struct parisc_device *dev)
175 struct busdevice *lasi;
176 struct gsc_irq gsc_irq;
179 lasi = kmalloc(sizeof(struct busdevice), GFP_KERNEL);
184 lasi->hpa = dev->hpa;
186 /* Check the 4-bit (yes, only 4) version register */
187 lasi->version = gsc_readl(lasi->hpa + LASI_VER) & 0xf;
188 printk(KERN_INFO "%s version %d at 0x%lx found.\n",
189 lasi->name, lasi->version, lasi->hpa);
191 /* initialize the chassis LEDs really early */
192 lasi_led_init(lasi->hpa);
194 /* Stop LASI barking for a bit */
197 /* the IRQ lasi should use */
198 irq = gsc_alloc_irq(&gsc_irq);
200 printk(KERN_ERR "%s(): cannot get GSC irq\n",
206 ret = request_irq(gsc_irq.irq, busdev_barked, 0, "lasi", lasi);
212 /* Save this for debugging later */
213 lasi->parent_irq = gsc_irq.irq;
214 lasi->eim = ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data;
216 /* enable IRQ's for devices below LASI */
217 gsc_writel(lasi->eim, lasi->hpa + OFFSET_IAR);
219 /* Done init'ing, register this driver */
220 ret = gsc_common_irqsetup(dev, lasi);
226 fixup_child_irqs(dev, lasi->busdev_region->data.irqbase,
229 /* initialize the power off function */
230 /* FIXME: Record the LASI HPA for the power off function. This should
231 * ensure that only the first LASI (the one controlling the power off)
232 * should set the HPA here */
233 lasi_power_off_hpa = lasi->hpa;
234 pm_power_off = lasi_power_off;
239 static struct parisc_device_id lasi_tbl[] = {
240 { HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00081 },
244 struct parisc_driver lasi_driver = {
247 probe: lasi_init_chip,