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