11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * ASP Device Driver 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * (c) Copyright 2000 The Puffin Group Inc. 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 71da177e4SLinus Torvalds * it under the terms of the GNU General Public License as published by 81da177e4SLinus Torvalds * the Free Software Foundation; either version 2 of the License, or 91da177e4SLinus Torvalds * (at your option) any later version. 101da177e4SLinus Torvalds * 111da177e4SLinus Torvalds * by Helge Deller <deller@gmx.de> 121da177e4SLinus Torvalds */ 131da177e4SLinus Torvalds 141da177e4SLinus Torvalds #include <linux/errno.h> 151da177e4SLinus Torvalds #include <linux/init.h> 161da177e4SLinus Torvalds #include <linux/interrupt.h> 171da177e4SLinus Torvalds #include <linux/module.h> 181da177e4SLinus Torvalds #include <linux/slab.h> 191da177e4SLinus Torvalds #include <linux/types.h> 201da177e4SLinus Torvalds #include <asm/io.h> 211da177e4SLinus Torvalds #include <asm/led.h> 221da177e4SLinus Torvalds 231da177e4SLinus Torvalds #include "gsc.h" 241da177e4SLinus Torvalds 251da177e4SLinus Torvalds #define ASP_GSC_IRQ 3 /* hardcoded interrupt for GSC */ 261da177e4SLinus Torvalds 271da177e4SLinus Torvalds #define ASP_VER_OFFSET 0x20 /* offset of ASP version */ 281da177e4SLinus Torvalds 291da177e4SLinus Torvalds #define ASP_LED_ADDR 0xf0800020 301da177e4SLinus Torvalds 311da177e4SLinus Torvalds #define VIPER_INT_WORD 0xFFFBF088 /* addr of viper interrupt word */ 321da177e4SLinus Torvalds 331da177e4SLinus Torvalds static struct gsc_asic asp; 341da177e4SLinus Torvalds 351da177e4SLinus Torvalds static void asp_choose_irq(struct parisc_device *dev, void *ctrl) 361da177e4SLinus Torvalds { 371da177e4SLinus Torvalds int irq; 381da177e4SLinus Torvalds 391da177e4SLinus Torvalds switch (dev->id.sversion) { 401da177e4SLinus Torvalds case 0x71: irq = 9; break; /* SCSI */ 411da177e4SLinus Torvalds case 0x72: irq = 8; break; /* LAN */ 421da177e4SLinus Torvalds case 0x73: irq = 1; break; /* HIL */ 431da177e4SLinus Torvalds case 0x74: irq = 7; break; /* Centronics */ 441da177e4SLinus Torvalds case 0x75: irq = (dev->hw_path == 4) ? 5 : 6; break; /* RS232 */ 451da177e4SLinus Torvalds case 0x76: irq = 10; break; /* EISA BA */ 461da177e4SLinus Torvalds case 0x77: irq = 11; break; /* Graphics1 */ 471da177e4SLinus Torvalds case 0x7a: irq = 13; break; /* Audio (Bushmaster) */ 481da177e4SLinus Torvalds case 0x7b: irq = 13; break; /* Audio (Scorpio) */ 491da177e4SLinus Torvalds case 0x7c: irq = 3; break; /* FW SCSI */ 501da177e4SLinus Torvalds case 0x7d: irq = 4; break; /* FDDI */ 511da177e4SLinus Torvalds case 0x7f: irq = 13; break; /* Audio (Outfield) */ 521da177e4SLinus Torvalds default: return; /* Unknown */ 531da177e4SLinus Torvalds } 541da177e4SLinus Torvalds 551da177e4SLinus Torvalds gsc_asic_assign_irq(ctrl, irq, &dev->irq); 561da177e4SLinus Torvalds 571da177e4SLinus Torvalds switch (dev->id.sversion) { 581da177e4SLinus Torvalds case 0x73: irq = 2; break; /* i8042 High-priority */ 591da177e4SLinus Torvalds case 0x76: irq = 0; break; /* EISA BA */ 601da177e4SLinus Torvalds default: return; /* Other */ 611da177e4SLinus Torvalds } 621da177e4SLinus Torvalds 631da177e4SLinus Torvalds gsc_asic_assign_irq(ctrl, irq, &dev->aux_irq); 641da177e4SLinus Torvalds } 651da177e4SLinus Torvalds 661da177e4SLinus Torvalds /* There are two register ranges we're interested in. Interrupt / 671da177e4SLinus Torvalds * Status / LED are at 0xf080xxxx and Asp special registers are at 681da177e4SLinus Torvalds * 0xf082fxxx. PDC only tells us that Asp is at 0xf082f000, so for 691da177e4SLinus Torvalds * the purposes of interrupt handling, we have to tell other bits of 701da177e4SLinus Torvalds * the kernel to look at the other registers. 711da177e4SLinus Torvalds */ 721da177e4SLinus Torvalds #define ASP_INTERRUPT_ADDR 0xf0800000 731da177e4SLinus Torvalds 741da177e4SLinus Torvalds int __init 751da177e4SLinus Torvalds asp_init_chip(struct parisc_device *dev) 761da177e4SLinus Torvalds { 771da177e4SLinus Torvalds struct gsc_irq gsc_irq; 781da177e4SLinus Torvalds int ret; 791da177e4SLinus Torvalds 801da177e4SLinus Torvalds asp.version = gsc_readb(dev->hpa + ASP_VER_OFFSET) & 0xf; 811da177e4SLinus Torvalds asp.name = (asp.version == 1) ? "Asp" : "Cutoff"; 821da177e4SLinus Torvalds asp.hpa = ASP_INTERRUPT_ADDR; 831da177e4SLinus Torvalds 841da177e4SLinus Torvalds printk(KERN_INFO "%s version %d at 0x%lx found.\n", 851da177e4SLinus Torvalds asp.name, asp.version, dev->hpa); 861da177e4SLinus Torvalds 871da177e4SLinus Torvalds /* the IRQ ASP should use */ 881da177e4SLinus Torvalds ret = -EBUSY; 891da177e4SLinus Torvalds dev->irq = gsc_claim_irq(&gsc_irq, ASP_GSC_IRQ); 901da177e4SLinus Torvalds if (dev->irq < 0) { 911da177e4SLinus Torvalds printk(KERN_ERR "%s(): cannot get GSC irq\n", __FUNCTION__); 921da177e4SLinus Torvalds goto out; 931da177e4SLinus Torvalds } 941da177e4SLinus Torvalds 951da177e4SLinus Torvalds asp.eim = ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data; 961da177e4SLinus Torvalds 971da177e4SLinus Torvalds ret = request_irq(gsc_irq.irq, gsc_asic_intr, 0, "asp", &asp); 981da177e4SLinus Torvalds if (ret < 0) 991da177e4SLinus Torvalds goto out; 1001da177e4SLinus Torvalds 1011da177e4SLinus Torvalds /* Program VIPER to interrupt on the ASP irq */ 1021da177e4SLinus Torvalds gsc_writel((1 << (31 - ASP_GSC_IRQ)),VIPER_INT_WORD); 1031da177e4SLinus Torvalds 1041da177e4SLinus Torvalds /* Done init'ing, register this driver */ 1051da177e4SLinus Torvalds ret = gsc_common_setup(dev, &asp); 1061da177e4SLinus Torvalds if (ret) 1071da177e4SLinus Torvalds goto out; 1081da177e4SLinus Torvalds 1091da177e4SLinus Torvalds gsc_fixup_irqs(dev, &asp, asp_choose_irq); 1101da177e4SLinus Torvalds /* Mongoose is a sibling of Asp, not a child... */ 1111da177e4SLinus Torvalds gsc_fixup_irqs(parisc_parent(dev), &asp, asp_choose_irq); 1121da177e4SLinus Torvalds 1131da177e4SLinus Torvalds /* initialize the chassis LEDs */ 1141da177e4SLinus Torvalds #ifdef CONFIG_CHASSIS_LCD_LED 1151da177e4SLinus Torvalds register_led_driver(DISPLAY_MODEL_OLD_ASP, LED_CMD_REG_NONE, 1161da177e4SLinus Torvalds ASP_LED_ADDR); 1171da177e4SLinus Torvalds #endif 1181da177e4SLinus Torvalds 1191da177e4SLinus Torvalds out: 1201da177e4SLinus Torvalds return ret; 1211da177e4SLinus Torvalds } 1221da177e4SLinus Torvalds 1231da177e4SLinus Torvalds static struct parisc_device_id asp_tbl[] = { 1241da177e4SLinus Torvalds { HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00070 }, 1251da177e4SLinus Torvalds { 0, } 1261da177e4SLinus Torvalds }; 1271da177e4SLinus Torvalds 1281da177e4SLinus Torvalds struct parisc_driver asp_driver = { 1291da177e4SLinus Torvalds .name = "Asp", 1301da177e4SLinus Torvalds .id_table = asp_tbl, 1311da177e4SLinus Torvalds .probe = asp_init_chip, 1321da177e4SLinus Torvalds }; 133