linux-old/drivers/gsc/wax.c
<<
>>
Prefs
   1/*
   2 *      WAX Device Driver
   3 *
   4 *      (c) Copyright 2000 The Puffin Group Inc.
   5 *
   6 *      This program is free software; you can redistribute it and/or modify
   7 *      it under the terms of the GNU General Public License as published by
   8 *      the Free Software Foundation; either version 2 of the License, or
   9 *      (at your option) any later version.
  10 *
  11 *      by Helge Deller <deller@gmx.de>
  12 */
  13
  14#include <linux/errno.h>
  15#include <linux/init.h>
  16#include <linux/interrupt.h>
  17#include <linux/ioport.h>
  18#include <linux/slab.h>
  19#include <linux/module.h>
  20#include <linux/slab.h>
  21#include <linux/types.h>
  22
  23#include <asm/io.h>
  24#include <asm/hardware.h>
  25#include <asm/gsc.h>
  26#include <asm/irq.h>
  27
  28#include "busdevice.h"
  29
  30#define WAX_GSC_IRQ     7       /* Hardcoded Interrupt for GSC */
  31#define WAX_GSC_NMI_IRQ 29
  32
  33static int wax_choose_irq(struct parisc_device *dev)
  34{
  35        int irq = -1;
  36
  37        switch (dev->id.sversion) {
  38                case 0x73:      irq = 30; break; /* HIL */
  39                case 0x8c:      irq = 25; break; /* RS232 */
  40                case 0x90:      irq = 21; break; /* WAX EISA BA */
  41        }
  42
  43        return irq;
  44}
  45
  46static void __init
  47wax_init_irq(struct busdevice *wax)
  48{
  49        unsigned long base = wax->hpa;
  50
  51        /* Stop WAX barking for a bit */
  52        gsc_writel(0x00000000, base+OFFSET_IMR);
  53
  54        /* clear pending interrupts */
  55        (volatile u32) gsc_readl(base+OFFSET_IRR);
  56
  57        /* We're not really convinced we want to reset the onboard
  58         * devices. Firmware does it for us...
  59         */
  60
  61        /* Resets */
  62//      gsc_writel(0xFFFFFFFF, base+0x1000); /* HIL */
  63//      gsc_writel(0xFFFFFFFF, base+0x2000); /* RS232-B on Wax */
  64        
  65        /* Ok we hit it on the head with a hammer, our Dog is now
  66        ** comatose and muzzled.  Devices will now unmask WAX
  67        ** interrupts as they are registered as irq's in the WAX range.
  68        */
  69}
  70
  71int __init
  72wax_init_chip(struct parisc_device *dev)
  73{
  74        struct busdevice *wax;
  75        struct gsc_irq gsc_irq;
  76        int irq, ret;
  77
  78        wax = kmalloc(sizeof(struct busdevice), GFP_KERNEL);
  79        if (!wax)
  80                return -ENOMEM;
  81
  82        wax->name = "Wax";
  83        wax->hpa = dev->hpa;
  84
  85        wax->version = 0;   /* gsc_readb(wax->hpa+WAX_VER); */
  86        printk(KERN_INFO "%s at 0x%lx found.\n", wax->name, wax->hpa);
  87
  88        /* Stop wax hissing for a bit */
  89        wax_init_irq(wax);
  90
  91        /* the IRQ wax should use */
  92        irq = gsc_claim_irq(&gsc_irq, WAX_GSC_IRQ);
  93        if (irq < 0) {
  94                printk(KERN_ERR "%s(): cannot get GSC irq\n",
  95                                __FUNCTION__);
  96                kfree(wax);
  97                return -EBUSY;
  98        }
  99
 100        ret = request_irq(gsc_irq.irq, busdev_barked, 0, "wax", wax);
 101        if (ret < 0) {
 102                kfree(wax);
 103                return ret;
 104        }
 105
 106        /* Save this for debugging later */
 107        wax->parent_irq = gsc_irq.irq;
 108        wax->eim = ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data;
 109
 110        /* enable IRQ's for devices below WAX */
 111        gsc_writel(wax->eim, wax->hpa + OFFSET_IAR);
 112
 113        /* Done init'ing, register this driver */
 114        ret = gsc_common_irqsetup(dev, wax);
 115        if (ret) {
 116                kfree(wax);
 117                return ret;
 118        }
 119
 120        fixup_child_irqs(dev, wax->busdev_region->data.irqbase,
 121                        wax_choose_irq);
 122        /* On 715-class machines, Wax EISA is a sibling of Wax, not a child. */
 123        if (dev->parent->id.hw_type != HPHW_IOA) {
 124                fixup_child_irqs(dev->parent, wax->busdev_region->data.irqbase,
 125                                wax_choose_irq);
 126        }
 127
 128        return ret;
 129}
 130
 131static struct parisc_device_id wax_tbl[] = {
 132        { HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008e },
 133        { 0, }
 134};
 135
 136MODULE_DEVICE_TABLE(parisc, wax_tbl);
 137
 138struct parisc_driver wax_driver = {
 139        name:           "Wax",
 140        id_table:       wax_tbl,
 141        probe:          wax_init_chip,
 142};
 143
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.