• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/drivers/parisc/
1/*
2 *	LASI Device Driver
3 *
4 *	(c) Copyright 1999 Red Hat Software
5 *	Portions (c) Copyright 1999 The Puffin Group Inc.
6 *	Portions (c) Copyright 1999 Hewlett-Packard
7 *
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.
12 *
13 *	by Alan Cox <alan@redhat.com> and
14 * 	   Alex deVries <alex@onefishtwo.ca>
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	/* LASI Version */
33
34#define LASI_IO_CONF	0x7FFFE	/* LASI primary configuration register */
35#define LASI_IO_CONF2	0x7FFFF	/* LASI secondary configuration register */
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; /* Centronics */
43		case 0x7B:	irq = 13; break; /* Audio */
44		case 0x81:	irq = 14; break; /* Lasi itself */
45		case 0x82:	irq =  9; break; /* SCSI */
46		case 0x83:	irq = 20; break; /* Floppy */
47		case 0x84:	irq = 26; break; /* PS/2 Keyboard */
48		case 0x87:	irq = 18; break; /* ISDN */
49		case 0x8A:	irq =  8; break; /* LAN */
50		case 0x8C:	irq =  5; break; /* RS232 */
51		case 0x8D:	irq = (dev->hw_path == 13) ? 16 : 17; break;
52						 /* Telephone */
53		default: 	return;		 /* unknown */
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	/* Stop LASI barking for a bit */
65	gsc_writel(0x00000000, lasi_base+OFFSET_IMR);
66
67	/* clear pending interrupts */
68	gsc_readl(lasi_base+OFFSET_IRR);
69
70	/* We're not really convinced we want to reset the onboard
71         * devices. Firmware does it for us...
72	 */
73
74	/* Resets */
75	/* gsc_writel(0xFFFFFFFF, lasi_base+0x2000);*/	/* Parallel */
76	if(pdc_add_valid(lasi_base+0x4004) == PDC_OK)
77		gsc_writel(0xFFFFFFFF, lasi_base+0x4004);	/* Audio */
78	/* gsc_writel(0xFFFFFFFF, lasi_base+0x5000);*/	/* Serial */
79	/* gsc_writel(0xFFFFFFFF, lasi_base+0x6000);*/	/* SCSI */
80	gsc_writel(0xFFFFFFFF, lasi_base+0x7000);	/* LAN */
81	gsc_writel(0xFFFFFFFF, lasi_base+0x8000);	/* Keyboard */
82	gsc_writel(0xFFFFFFFF, lasi_base+0xA000);	/* FDC */
83
84	/* Ok we hit it on the head with a hammer, our Dog is now
85	** comatose and muzzled.  Devices will now unmask LASI
86	** interrupts as they are registered as irq's in the LASI range.
87	*/
88}
89
90
91/*
92   ** lasi_led_init()
93   **
94   ** lasi_led_init() initializes the LED controller on the LASI.
95   **
96   ** Since Mirage and Electra machines use a different LED
97   ** address register, we need to check for these machines
98   ** explicitly.
99 */
100
101#ifndef CONFIG_CHASSIS_LCD_LED
102
103#define lasi_led_init(x)	/* nothing */
104
105#else
106
107static void __init lasi_led_init(unsigned long lasi_hpa)
108{
109	unsigned long datareg;
110
111	switch (CPU_HVERSION) {
112	/* Gecko machines have only one single LED, which can be permanently
113	   turned on by writing a zero into the power control register. */
114	case 0x600:		/* Gecko (712/60) */
115	case 0x601:		/* Gecko (712/80) */
116	case 0x602:		/* Gecko (712/100) */
117	case 0x603:		/* Anole 64 (743/64) */
118	case 0x604:		/* Anole 100 (743/100) */
119	case 0x605:		/* Gecko (712/120) */
120		datareg = lasi_hpa + 0x0000C000;
121		gsc_writeb(0, datareg);
122		return; /* no need to register the LED interrupt-function */
123
124	/* Mirage and Electra machines need special offsets */
125	case 0x60A:		/* Mirage Jr (715/64) */
126	case 0x60B:		/* Mirage 100 */
127	case 0x60C:		/* Mirage 100+ */
128	case 0x60D:		/* Electra 100 */
129	case 0x60E:		/* Electra 120 */
130		datareg = lasi_hpa - 0x00020000;
131		break;
132
133	default:
134		datareg = lasi_hpa + 0x0000C000;
135		break;
136	}
137
138	register_led_driver(DISPLAY_MODEL_LASI, LED_CMD_REG_NONE, datareg);
139}
140#endif
141
142/*
143 * lasi_power_off
144 *
145 * Function for lasi to turn off the power.  This is accomplished by setting a
146 * 1 to PWR_ON_L in the Power Control Register
147 *
148 */
149
150static unsigned long lasi_power_off_hpa __read_mostly;
151
152static void lasi_power_off(void)
153{
154	unsigned long datareg;
155
156	/* calculate addr of the Power Control Register */
157	datareg = lasi_power_off_hpa + 0x0000C000;
158
159	/* Power down the machine */
160	gsc_writel(0x02, datareg);
161}
162
163static int __init lasi_init_chip(struct parisc_device *dev)
164{
165	extern void (*chassis_power_off)(void);
166	struct gsc_asic *lasi;
167	struct gsc_irq gsc_irq;
168	int ret;
169
170	lasi = kzalloc(sizeof(*lasi), GFP_KERNEL);
171	if (!lasi)
172		return -ENOMEM;
173
174	lasi->name = "Lasi";
175	lasi->hpa = dev->hpa.start;
176
177	/* Check the 4-bit (yes, only 4) version register */
178	lasi->version = gsc_readl(lasi->hpa + LASI_VER) & 0xf;
179	printk(KERN_INFO "%s version %d at 0x%lx found.\n",
180		lasi->name, lasi->version, lasi->hpa);
181
182	/* initialize the chassis LEDs really early */
183	lasi_led_init(lasi->hpa);
184
185	/* Stop LASI barking for a bit */
186	lasi_init_irq(lasi);
187
188	/* the IRQ lasi should use */
189	dev->irq = gsc_alloc_irq(&gsc_irq);
190	if (dev->irq < 0) {
191		printk(KERN_ERR "%s(): cannot get GSC irq\n",
192				__func__);
193		kfree(lasi);
194		return -EBUSY;
195	}
196
197	lasi->eim = ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data;
198
199	ret = request_irq(gsc_irq.irq, gsc_asic_intr, 0, "lasi", lasi);
200	if (ret < 0) {
201		kfree(lasi);
202		return ret;
203	}
204
205	/* enable IRQ's for devices below LASI */
206	gsc_writel(lasi->eim, lasi->hpa + OFFSET_IAR);
207
208	/* Done init'ing, register this driver */
209	ret = gsc_common_setup(dev, lasi);
210	if (ret) {
211		kfree(lasi);
212		return ret;
213	}
214
215	gsc_fixup_irqs(dev, lasi, lasi_choose_irq);
216
217	/* initialize the power off function */
218	lasi_power_off_hpa = lasi->hpa;
219	chassis_power_off = lasi_power_off;
220
221	return ret;
222}
223
224static struct parisc_device_id lasi_tbl[] = {
225	{ HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00081 },
226	{ 0, }
227};
228
229struct parisc_driver lasi_driver = {
230	.name =		"lasi",
231	.id_table =	lasi_tbl,
232	.probe =	lasi_init_chip,
233};
234