1 | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | /* |
3 | * ASP Device Driver |
4 | * |
5 | * (c) Copyright 2000 The Puffin Group Inc. |
6 | * |
7 | * (c) 2000-2023 by Helge Deller <deller@gmx.de> |
8 | */ |
9 | |
10 | #include <linux/errno.h> |
11 | #include <linux/init.h> |
12 | #include <linux/interrupt.h> |
13 | #include <linux/module.h> |
14 | #include <linux/types.h> |
15 | #include <asm/io.h> |
16 | #include <asm/led.h> |
17 | |
18 | #include "gsc.h" |
19 | |
20 | #define ASP_GSC_IRQ 3 /* hardcoded interrupt for GSC */ |
21 | |
22 | #define ASP_VER_OFFSET 0x20 /* offset of ASP version */ |
23 | |
24 | #define ASP_LED_ADDR 0xf0800020 |
25 | |
26 | #define VIPER_INT_WORD 0xFFFBF088 /* addr of viper interrupt word */ |
27 | |
28 | static struct gsc_asic asp; |
29 | |
30 | static void asp_choose_irq(struct parisc_device *dev, void *ctrl) |
31 | { |
32 | int irq; |
33 | |
34 | switch (dev->id.sversion) { |
35 | case 0x71: irq = 9; break; /* SCSI */ |
36 | case 0x72: irq = 8; break; /* LAN */ |
37 | case 0x73: irq = 1; break; /* HIL */ |
38 | case 0x74: irq = 7; break; /* Centronics */ |
39 | case 0x75: irq = (dev->hw_path == 4) ? 5 : 6; break; /* RS232 */ |
40 | case 0x76: irq = 10; break; /* EISA BA */ |
41 | case 0x77: irq = 11; break; /* Graphics1 */ |
42 | case 0x7a: irq = 13; break; /* Audio (Bushmaster) */ |
43 | case 0x7b: irq = 13; break; /* Audio (Scorpio) */ |
44 | case 0x7c: irq = 3; break; /* FW SCSI */ |
45 | case 0x7d: irq = 4; break; /* FDDI */ |
46 | case 0x7f: irq = 13; break; /* Audio (Outfield) */ |
47 | default: return; /* Unknown */ |
48 | } |
49 | |
50 | gsc_asic_assign_irq(asic: ctrl, local_irq: irq, irqp: &dev->irq); |
51 | |
52 | switch (dev->id.sversion) { |
53 | case 0x73: irq = 2; break; /* i8042 High-priority */ |
54 | case 0x76: irq = 0; break; /* EISA BA */ |
55 | default: return; /* Other */ |
56 | } |
57 | |
58 | gsc_asic_assign_irq(asic: ctrl, local_irq: irq, irqp: &dev->aux_irq); |
59 | } |
60 | |
61 | /* There are two register ranges we're interested in. Interrupt / |
62 | * Status / LED are at 0xf080xxxx and Asp special registers are at |
63 | * 0xf082fxxx. PDC only tells us that Asp is at 0xf082f000, so for |
64 | * the purposes of interrupt handling, we have to tell other bits of |
65 | * the kernel to look at the other registers. |
66 | */ |
67 | #define ASP_INTERRUPT_ADDR 0xf0800000 |
68 | |
69 | static int __init asp_init_chip(struct parisc_device *dev) |
70 | { |
71 | struct gsc_irq gsc_irq; |
72 | int ret; |
73 | |
74 | asp.version = gsc_readb(dev->hpa.start + ASP_VER_OFFSET) & 0xf; |
75 | asp.name = (asp.version == 1) ? "Asp" : "Cutoff" ; |
76 | asp.hpa = ASP_INTERRUPT_ADDR; |
77 | |
78 | printk(KERN_INFO "%s version %d at 0x%lx found.\n" , |
79 | asp.name, asp.version, (unsigned long)dev->hpa.start); |
80 | |
81 | /* the IRQ ASP should use */ |
82 | ret = -EBUSY; |
83 | dev->irq = gsc_claim_irq(dev: &gsc_irq, ASP_GSC_IRQ); |
84 | if (dev->irq < 0) { |
85 | printk(KERN_ERR "%s(): cannot get GSC irq\n" , __func__); |
86 | goto out; |
87 | } |
88 | |
89 | asp.eim = ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data; |
90 | |
91 | ret = request_irq(irq: gsc_irq.irq, handler: gsc_asic_intr, flags: 0, name: "asp" , dev: &asp); |
92 | if (ret < 0) |
93 | goto out; |
94 | |
95 | /* Program VIPER to interrupt on the ASP irq */ |
96 | gsc_writel((1 << (31 - ASP_GSC_IRQ)),VIPER_INT_WORD); |
97 | |
98 | /* Done init'ing, register this driver */ |
99 | ret = gsc_common_setup(parent: dev, gsc_asic: &asp); |
100 | if (ret) |
101 | goto out; |
102 | |
103 | gsc_fixup_irqs(parent: dev, ctrl: &asp, choose: asp_choose_irq); |
104 | /* Mongoose is a sibling of Asp, not a child... */ |
105 | gsc_fixup_irqs(parent: parisc_parent(dev), ctrl: &asp, choose: asp_choose_irq); |
106 | |
107 | /* initialize the chassis LEDs */ |
108 | #ifdef CONFIG_CHASSIS_LCD_LED |
109 | register_led_driver(DISPLAY_MODEL_OLD_ASP, LED_CMD_REG_NONE, |
110 | ASP_LED_ADDR); |
111 | #endif |
112 | |
113 | out: |
114 | return ret; |
115 | } |
116 | |
117 | static const struct parisc_device_id asp_tbl[] __initconst = { |
118 | { HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00070 }, |
119 | { 0, } |
120 | }; |
121 | MODULE_DEVICE_TABLE(parisc, asp_tbl); |
122 | |
123 | static struct parisc_driver asp_driver __refdata = { |
124 | .name = "asp" , |
125 | .id_table = asp_tbl, |
126 | .probe = asp_init_chip, |
127 | }; |
128 | |
129 | static int __init asp_init(void) |
130 | { |
131 | return register_parisc_driver(&asp_driver); |
132 | } |
133 | arch_initcall(asp_init); |
134 | |