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