Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / parisc / wax.c
blob5b6df1516235470167198138e0cdbcfdd5feef95
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * WAX Device Driver
5 * (c) Copyright 2000 The Puffin Group Inc.
7 * by Helge Deller <deller@gmx.de>
8 */
10 #include <linux/errno.h>
11 #include <linux/init.h>
12 #include <linux/interrupt.h>
13 #include <linux/ioport.h>
14 #include <linux/slab.h>
15 #include <linux/module.h>
16 #include <linux/types.h>
18 #include <asm/io.h>
19 #include <asm/hardware.h>
21 #include "gsc.h"
23 #define WAX_GSC_IRQ 7 /* Hardcoded Interrupt for GSC */
25 static void wax_choose_irq(struct parisc_device *dev, void *ctrl)
27 int irq;
29 switch (dev->id.sversion) {
30 case 0x73: irq = 1; break; /* i8042 General */
31 case 0x8c: irq = 6; break; /* Serial */
32 case 0x90: irq = 10; break; /* EISA */
33 default: return; /* Unknown */
36 gsc_asic_assign_irq(ctrl, irq, &dev->irq);
38 switch (dev->id.sversion) {
39 case 0x73: irq = 2; break; /* i8042 High-priority */
40 case 0x90: irq = 0; break; /* EISA NMI */
41 default: return; /* No secondary IRQ */
44 gsc_asic_assign_irq(ctrl, irq, &dev->aux_irq);
47 static void __init
48 wax_init_irq(struct gsc_asic *wax)
50 unsigned long base = wax->hpa;
52 /* Wax-off */
53 gsc_writel(0x00000000, base+OFFSET_IMR);
55 /* clear pending interrupts */
56 gsc_readl(base+OFFSET_IRR);
58 /* We're not really convinced we want to reset the onboard
59 * devices. Firmware does it for us...
62 /* Resets */
63 // gsc_writel(0xFFFFFFFF, base+0x1000); /* HIL */
64 // gsc_writel(0xFFFFFFFF, base+0x2000); /* RS232-B on Wax */
67 static int __init wax_init_chip(struct parisc_device *dev)
69 struct gsc_asic *wax;
70 struct parisc_device *parent;
71 struct gsc_irq gsc_irq;
72 int ret;
74 wax = kzalloc(sizeof(*wax), GFP_KERNEL);
75 if (!wax)
76 return -ENOMEM;
78 wax->name = "wax";
79 wax->hpa = dev->hpa.start;
81 wax->version = 0; /* gsc_readb(wax->hpa+WAX_VER); */
82 printk(KERN_INFO "%s at 0x%lx found.\n", wax->name, wax->hpa);
84 /* Stop wax hissing for a bit */
85 wax_init_irq(wax);
87 /* the IRQ wax should use */
88 dev->irq = gsc_claim_irq(&gsc_irq, WAX_GSC_IRQ);
89 if (dev->irq < 0) {
90 printk(KERN_ERR "%s(): cannot get GSC irq\n",
91 __func__);
92 kfree(wax);
93 return -EBUSY;
96 wax->eim = ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data;
98 ret = request_irq(gsc_irq.irq, gsc_asic_intr, 0, "wax", wax);
99 if (ret < 0) {
100 kfree(wax);
101 return ret;
104 /* enable IRQ's for devices below WAX */
105 gsc_writel(wax->eim, wax->hpa + OFFSET_IAR);
107 /* Done init'ing, register this driver */
108 ret = gsc_common_setup(dev, wax);
109 if (ret) {
110 kfree(wax);
111 return ret;
114 gsc_fixup_irqs(dev, wax, wax_choose_irq);
115 /* On 715-class machines, Wax EISA is a sibling of Wax, not a child. */
116 parent = parisc_parent(dev);
117 if (parent->id.hw_type != HPHW_IOA) {
118 gsc_fixup_irqs(parent, wax, wax_choose_irq);
121 return ret;
124 static const struct parisc_device_id wax_tbl[] __initconst = {
125 { HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008e },
126 { 0, }
129 MODULE_DEVICE_TABLE(parisc, wax_tbl);
131 struct parisc_driver wax_driver __refdata = {
132 .name = "wax",
133 .id_table = wax_tbl,
134 .probe = wax_init_chip,