Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  WAX Device Driver
0004  *
0005  *  (c) Copyright 2000 The Puffin Group Inc.
0006  *
0007  *  by Helge Deller <deller@gmx.de>
0008  */
0009 
0010 #include <linux/errno.h>
0011 #include <linux/init.h>
0012 #include <linux/interrupt.h>
0013 #include <linux/ioport.h>
0014 #include <linux/slab.h>
0015 #include <linux/module.h>
0016 #include <linux/types.h>
0017 
0018 #include <asm/io.h>
0019 #include <asm/hardware.h>
0020 
0021 #include "gsc.h"
0022 
0023 #define WAX_GSC_IRQ 7   /* Hardcoded Interrupt for GSC */
0024 
0025 static void wax_choose_irq(struct parisc_device *dev, void *ctrl)
0026 {
0027     int irq;
0028 
0029     switch (dev->id.sversion) {
0030         case 0x73:  irq =  1; break; /* i8042 General */
0031         case 0x8c:  irq =  6; break; /* Serial */
0032         case 0x90:  irq = 10; break; /* EISA */
0033         default:    return;      /* Unknown */
0034     }
0035 
0036     gsc_asic_assign_irq(ctrl, irq, &dev->irq);
0037 
0038     switch (dev->id.sversion) {
0039         case 0x73:  irq =  2; break; /* i8042 High-priority */
0040         case 0x90:  irq =  0; break; /* EISA NMI */
0041         default:    return;      /* No secondary IRQ */
0042     }
0043 
0044     gsc_asic_assign_irq(ctrl, irq, &dev->aux_irq);
0045 }
0046 
0047 static void __init
0048 wax_init_irq(struct gsc_asic *wax)
0049 {
0050     unsigned long base = wax->hpa;
0051 
0052     /* Wax-off */
0053     gsc_writel(0x00000000, base+OFFSET_IMR);
0054 
0055     /* clear pending interrupts */
0056     gsc_readl(base+OFFSET_IRR);
0057 
0058     /* We're not really convinced we want to reset the onboard
0059          * devices. Firmware does it for us...
0060      */
0061 
0062     /* Resets */
0063 //  gsc_writel(0xFFFFFFFF, base+0x1000); /* HIL */
0064 //  gsc_writel(0xFFFFFFFF, base+0x2000); /* RS232-B on Wax */
0065 }
0066 
0067 static int __init wax_init_chip(struct parisc_device *dev)
0068 {
0069     struct gsc_asic *wax;
0070     struct parisc_device *parent;
0071     int ret;
0072 
0073     wax = kzalloc(sizeof(*wax), GFP_KERNEL);
0074     if (!wax)
0075         return -ENOMEM;
0076 
0077     wax->name = "wax";
0078     wax->hpa = dev->hpa.start;
0079 
0080     wax->version = 0;   /* gsc_readb(wax->hpa+WAX_VER); */
0081     printk(KERN_INFO "%s at 0x%lx found.\n", wax->name, wax->hpa);
0082 
0083     /* Stop wax hissing for a bit */
0084     wax_init_irq(wax);
0085 
0086     /* the IRQ wax should use */
0087     dev->irq = gsc_claim_irq(&wax->gsc_irq, WAX_GSC_IRQ);
0088     if (dev->irq < 0) {
0089         printk(KERN_ERR "%s(): cannot get GSC irq\n",
0090                 __func__);
0091         kfree(wax);
0092         return -EBUSY;
0093     }
0094 
0095     wax->eim = ((u32) wax->gsc_irq.txn_addr) | wax->gsc_irq.txn_data;
0096 
0097     ret = request_irq(wax->gsc_irq.irq, gsc_asic_intr, 0, "wax", wax);
0098     if (ret < 0) {
0099         kfree(wax);
0100         return ret;
0101     }
0102 
0103     /* enable IRQ's for devices below WAX */
0104     gsc_writel(wax->eim, wax->hpa + OFFSET_IAR);
0105 
0106     /* Done init'ing, register this driver */
0107     ret = gsc_common_setup(dev, wax);
0108     if (ret) {
0109         kfree(wax);
0110         return ret;
0111     }
0112 
0113     gsc_fixup_irqs(dev, wax, wax_choose_irq);
0114     /* On 715-class machines, Wax EISA is a sibling of Wax, not a child. */
0115     parent = parisc_parent(dev);
0116     if (parent->id.hw_type != HPHW_IOA) {
0117         gsc_fixup_irqs(parent, wax, wax_choose_irq);
0118     }
0119 
0120     return ret;
0121 }
0122 
0123 static const struct parisc_device_id wax_tbl[] __initconst = {
0124     { HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008e },
0125     { 0, }
0126 };
0127 
0128 MODULE_DEVICE_TABLE(parisc, wax_tbl);
0129 
0130 struct parisc_driver wax_driver __refdata = {
0131     .name =     "wax",
0132     .id_table = wax_tbl,
0133     .probe =    wax_init_chip,
0134 };