Commit a39cf72ceb406e152c4682c0b635a96f1439c5ed
1 parent
29a622dd2b
Exists in
master
and in
7 other branches
[PARISC] Make superio.c initialize before any driver needs it
Convert superio_init to use PCI_FIXUP_FINAL as ohci_pci being called before superio_probe really makes a mess. superio_init will then fail to register irq 20 (the "SuperIO" irq) and BUG() because ohci_pci has stolen it before superio_fixup_irq can be moved USB to irq 1. Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
Showing 1 changed file with 21 additions and 14 deletions Inline Diff
drivers/parisc/superio.c
1 | /* National Semiconductor NS87560UBD Super I/O controller used in | 1 | /* National Semiconductor NS87560UBD Super I/O controller used in |
2 | * HP [BCJ]x000 workstations. | 2 | * HP [BCJ]x000 workstations. |
3 | * | 3 | * |
4 | * This chip is a horrid piece of engineering, and National | 4 | * This chip is a horrid piece of engineering, and National |
5 | * denies any knowledge of its existence. Thus no datasheet is | 5 | * denies any knowledge of its existence. Thus no datasheet is |
6 | * available off www.national.com. | 6 | * available off www.national.com. |
7 | * | 7 | * |
8 | * (C) Copyright 2000 Linuxcare, Inc. | 8 | * (C) Copyright 2000 Linuxcare, Inc. |
9 | * (C) Copyright 2000 Linuxcare Canada, Inc. | 9 | * (C) Copyright 2000 Linuxcare Canada, Inc. |
10 | * (C) Copyright 2000 Martin K. Petersen <mkp@linuxcare.com> | 10 | * (C) Copyright 2000 Martin K. Petersen <mkp@linuxcare.com> |
11 | * (C) Copyright 2000 Alex deVries <alex@onefishtwo.ca> | 11 | * (C) Copyright 2000 Alex deVries <alex@onefishtwo.ca> |
12 | * (C) Copyright 2001 John Marvin <jsm fc hp com> | 12 | * (C) Copyright 2001 John Marvin <jsm fc hp com> |
13 | * (C) Copyright 2003 Grant Grundler <grundler parisc-linux org> | 13 | * (C) Copyright 2003 Grant Grundler <grundler parisc-linux org> |
14 | * (C) Copyright 2005 Kyle McMartin <kyle@parisc-linux.org> | 14 | * (C) Copyright 2005 Kyle McMartin <kyle@parisc-linux.org> |
15 | * | 15 | * |
16 | * This program is free software; you can redistribute it and/or | 16 | * This program is free software; you can redistribute it and/or |
17 | * modify it under the terms of the GNU General Public License as | 17 | * modify it under the terms of the GNU General Public License as |
18 | * published by the Free Software Foundation; either version 2 of | 18 | * published by the Free Software Foundation; either version 2 of |
19 | * the License, or (at your option) any later version. | 19 | * the License, or (at your option) any later version. |
20 | * | 20 | * |
21 | * The initial version of this is by Martin Peterson. Alex deVries | 21 | * The initial version of this is by Martin Peterson. Alex deVries |
22 | * has spent a bit of time trying to coax it into working. | 22 | * has spent a bit of time trying to coax it into working. |
23 | * | 23 | * |
24 | * Major changes to get basic interrupt infrastructure working to | 24 | * Major changes to get basic interrupt infrastructure working to |
25 | * hopefully be able to support all SuperIO devices. Currently | 25 | * hopefully be able to support all SuperIO devices. Currently |
26 | * works with serial. -- John Marvin <jsm@fc.hp.com> | 26 | * works with serial. -- John Marvin <jsm@fc.hp.com> |
27 | * | ||
28 | * Converted superio_init() to be a PCI_FIXUP_FINAL callee. | ||
29 | * -- Kyle McMartin <kyle@parisc-linux.org> | ||
27 | */ | 30 | */ |
28 | 31 | ||
29 | 32 | ||
30 | /* NOTES: | 33 | /* NOTES: |
31 | * | 34 | * |
32 | * Function 0 is an IDE controller. It is identical to a PC87415 IDE | 35 | * Function 0 is an IDE controller. It is identical to a PC87415 IDE |
33 | * controller (and identifies itself as such). | 36 | * controller (and identifies itself as such). |
34 | * | 37 | * |
35 | * Function 1 is a "Legacy I/O" controller. Under this function is a | 38 | * Function 1 is a "Legacy I/O" controller. Under this function is a |
36 | * whole mess of legacy I/O peripherals. Of course, HP hasn't enabled | 39 | * whole mess of legacy I/O peripherals. Of course, HP hasn't enabled |
37 | * all the functionality in hardware, but the following is available: | 40 | * all the functionality in hardware, but the following is available: |
38 | * | 41 | * |
39 | * Two 16550A compatible serial controllers | 42 | * Two 16550A compatible serial controllers |
40 | * An IEEE 1284 compatible parallel port | 43 | * An IEEE 1284 compatible parallel port |
41 | * A floppy disk controller | 44 | * A floppy disk controller |
42 | * | 45 | * |
43 | * Function 2 is a USB controller. | 46 | * Function 2 is a USB controller. |
44 | * | 47 | * |
45 | * We must be incredibly careful during initialization. Since all | 48 | * We must be incredibly careful during initialization. Since all |
46 | * interrupts are routed through function 1 (which is not allowed by | 49 | * interrupts are routed through function 1 (which is not allowed by |
47 | * the PCI spec), we need to program the PICs on the legacy I/O port | 50 | * the PCI spec), we need to program the PICs on the legacy I/O port |
48 | * *before* we attempt to set up IDE and USB. @#$!& | 51 | * *before* we attempt to set up IDE and USB. @#$!& |
49 | * | 52 | * |
50 | * According to HP, devices are only enabled by firmware if they have | 53 | * According to HP, devices are only enabled by firmware if they have |
51 | * a physical device connected. | 54 | * a physical device connected. |
52 | * | 55 | * |
53 | * Configuration register bits: | 56 | * Configuration register bits: |
54 | * 0x5A: FDC, SP1, IDE1, SP2, IDE2, PAR, Reserved, P92 | 57 | * 0x5A: FDC, SP1, IDE1, SP2, IDE2, PAR, Reserved, P92 |
55 | * 0x5B: RTC, 8259, 8254, DMA1, DMA2, KBC, P61, APM | 58 | * 0x5B: RTC, 8259, 8254, DMA1, DMA2, KBC, P61, APM |
56 | * | 59 | * |
57 | */ | 60 | */ |
58 | 61 | ||
59 | #include <linux/errno.h> | 62 | #include <linux/errno.h> |
60 | #include <linux/init.h> | 63 | #include <linux/init.h> |
61 | #include <linux/module.h> | 64 | #include <linux/module.h> |
62 | #include <linux/types.h> | 65 | #include <linux/types.h> |
63 | #include <linux/interrupt.h> | 66 | #include <linux/interrupt.h> |
64 | #include <linux/ioport.h> | 67 | #include <linux/ioport.h> |
65 | #include <linux/serial.h> | 68 | #include <linux/serial.h> |
66 | #include <linux/pci.h> | 69 | #include <linux/pci.h> |
67 | #include <linux/parport.h> | 70 | #include <linux/parport.h> |
68 | #include <linux/parport_pc.h> | 71 | #include <linux/parport_pc.h> |
69 | #include <linux/termios.h> | 72 | #include <linux/termios.h> |
70 | #include <linux/tty.h> | 73 | #include <linux/tty.h> |
71 | #include <linux/serial_core.h> | 74 | #include <linux/serial_core.h> |
72 | #include <linux/delay.h> | 75 | #include <linux/delay.h> |
73 | 76 | ||
74 | #include <asm/io.h> | 77 | #include <asm/io.h> |
75 | #include <asm/hardware.h> | 78 | #include <asm/hardware.h> |
76 | #include <asm/superio.h> | 79 | #include <asm/superio.h> |
77 | 80 | ||
78 | static struct superio_device sio_dev; | 81 | static struct superio_device sio_dev; |
79 | 82 | ||
80 | 83 | ||
81 | #undef DEBUG_SUPERIO_INIT | 84 | #undef DEBUG_SUPERIO_INIT |
82 | 85 | ||
83 | #ifdef DEBUG_SUPERIO_INIT | 86 | #ifdef DEBUG_SUPERIO_INIT |
84 | #define DBG_INIT(x...) printk(x) | 87 | #define DBG_INIT(x...) printk(x) |
85 | #else | 88 | #else |
86 | #define DBG_INIT(x...) | 89 | #define DBG_INIT(x...) |
87 | #endif | 90 | #endif |
88 | 91 | ||
89 | static irqreturn_t | 92 | static irqreturn_t |
90 | superio_interrupt(int parent_irq, void *devp, struct pt_regs *regs) | 93 | superio_interrupt(int parent_irq, void *devp, struct pt_regs *regs) |
91 | { | 94 | { |
92 | u8 results; | 95 | u8 results; |
93 | u8 local_irq; | 96 | u8 local_irq; |
94 | 97 | ||
95 | /* Poll the 8259 to see if there's an interrupt. */ | 98 | /* Poll the 8259 to see if there's an interrupt. */ |
96 | outb (OCW3_POLL,IC_PIC1+0); | 99 | outb (OCW3_POLL,IC_PIC1+0); |
97 | 100 | ||
98 | results = inb(IC_PIC1+0); | 101 | results = inb(IC_PIC1+0); |
99 | 102 | ||
100 | /* | 103 | /* |
101 | * Bit 7: 1 = active Interrupt; 0 = no Interrupt pending | 104 | * Bit 7: 1 = active Interrupt; 0 = no Interrupt pending |
102 | * Bits 6-3: zero | 105 | * Bits 6-3: zero |
103 | * Bits 2-0: highest priority, active requesting interrupt ID (0-7) | 106 | * Bits 2-0: highest priority, active requesting interrupt ID (0-7) |
104 | */ | 107 | */ |
105 | if ((results & 0x80) == 0) { | 108 | if ((results & 0x80) == 0) { |
106 | /* I suspect "spurious" interrupts are from unmasking an IRQ. | 109 | /* I suspect "spurious" interrupts are from unmasking an IRQ. |
107 | * We don't know if an interrupt was/is pending and thus | 110 | * We don't know if an interrupt was/is pending and thus |
108 | * just call the handler for that IRQ as if it were pending. | 111 | * just call the handler for that IRQ as if it were pending. |
109 | */ | 112 | */ |
110 | return IRQ_NONE; | 113 | return IRQ_NONE; |
111 | } | 114 | } |
112 | 115 | ||
113 | /* Check to see which device is interrupting */ | 116 | /* Check to see which device is interrupting */ |
114 | local_irq = results & 0x0f; | 117 | local_irq = results & 0x0f; |
115 | 118 | ||
116 | if (local_irq == 2 || local_irq > 7) { | 119 | if (local_irq == 2 || local_irq > 7) { |
117 | printk(KERN_ERR "SuperIO: slave interrupted!\n"); | 120 | printk(KERN_ERR "SuperIO: slave interrupted!\n"); |
118 | return IRQ_HANDLED; | 121 | return IRQ_HANDLED; |
119 | } | 122 | } |
120 | 123 | ||
121 | if (local_irq == 7) { | 124 | if (local_irq == 7) { |
122 | 125 | ||
123 | /* Could be spurious. Check in service bits */ | 126 | /* Could be spurious. Check in service bits */ |
124 | 127 | ||
125 | outb(OCW3_ISR,IC_PIC1+0); | 128 | outb(OCW3_ISR,IC_PIC1+0); |
126 | results = inb(IC_PIC1+0); | 129 | results = inb(IC_PIC1+0); |
127 | if ((results & 0x80) == 0) { /* if ISR7 not set: spurious */ | 130 | if ((results & 0x80) == 0) { /* if ISR7 not set: spurious */ |
128 | printk(KERN_WARNING "SuperIO: spurious interrupt!\n"); | 131 | printk(KERN_WARNING "SuperIO: spurious interrupt!\n"); |
129 | return IRQ_HANDLED; | 132 | return IRQ_HANDLED; |
130 | } | 133 | } |
131 | } | 134 | } |
132 | 135 | ||
133 | /* Call the appropriate device's interrupt */ | 136 | /* Call the appropriate device's interrupt */ |
134 | __do_IRQ(local_irq, regs); | 137 | __do_IRQ(local_irq, regs); |
135 | 138 | ||
136 | /* set EOI - forces a new interrupt if a lower priority device | 139 | /* set EOI - forces a new interrupt if a lower priority device |
137 | * still needs service. | 140 | * still needs service. |
138 | */ | 141 | */ |
139 | outb((OCW2_SEOI|local_irq),IC_PIC1 + 0); | 142 | outb((OCW2_SEOI|local_irq),IC_PIC1 + 0); |
140 | return IRQ_HANDLED; | 143 | return IRQ_HANDLED; |
141 | } | 144 | } |
142 | 145 | ||
143 | /* Initialize Super I/O device */ | 146 | /* Initialize Super I/O device */ |
144 | 147 | static void | |
145 | static void __devinit | 148 | superio_init(struct pci_dev *pcidev) |
146 | superio_init(struct superio_device *sio) | ||
147 | { | 149 | { |
150 | struct superio_device *sio = &sio_dev; | ||
148 | struct pci_dev *pdev = sio->lio_pdev; | 151 | struct pci_dev *pdev = sio->lio_pdev; |
149 | u16 word; | 152 | u16 word; |
150 | 153 | ||
151 | if (sio->suckyio_irq_enabled) | 154 | if (sio->suckyio_irq_enabled) |
152 | return; | 155 | return; |
153 | 156 | ||
154 | if (!pdev) BUG(); | 157 | if (!pdev) BUG(); |
155 | if (!sio->usb_pdev) BUG(); | 158 | if (!sio->usb_pdev) BUG(); |
156 | 159 | ||
157 | /* use the IRQ iosapic found for USB INT D... */ | 160 | /* use the IRQ iosapic found for USB INT D... */ |
158 | pdev->irq = sio->usb_pdev->irq; | 161 | pdev->irq = sio->usb_pdev->irq; |
159 | 162 | ||
160 | /* ...then properly fixup the USB to point at suckyio PIC */ | 163 | /* ...then properly fixup the USB to point at suckyio PIC */ |
161 | sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev); | 164 | sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev); |
162 | 165 | ||
163 | printk (KERN_INFO "SuperIO: Found NS87560 Legacy I/O device at %s (IRQ %i) \n", | 166 | printk(KERN_INFO "SuperIO: Found NS87560 Legacy I/O device at %s (IRQ %i) \n", |
164 | pci_name(pdev),pdev->irq); | 167 | pci_name(pdev), pdev->irq); |
165 | 168 | ||
166 | pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base); | 169 | pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base); |
167 | sio->sp1_base &= ~1; | 170 | sio->sp1_base &= ~1; |
168 | printk (KERN_INFO "SuperIO: Serial port 1 at 0x%x\n", sio->sp1_base); | 171 | printk (KERN_INFO "SuperIO: Serial port 1 at 0x%x\n", sio->sp1_base); |
169 | 172 | ||
170 | pci_read_config_dword (pdev, SIO_SP2BAR, &sio->sp2_base); | 173 | pci_read_config_dword (pdev, SIO_SP2BAR, &sio->sp2_base); |
171 | sio->sp2_base &= ~1; | 174 | sio->sp2_base &= ~1; |
172 | printk (KERN_INFO "SuperIO: Serial port 2 at 0x%x\n", sio->sp2_base); | 175 | printk (KERN_INFO "SuperIO: Serial port 2 at 0x%x\n", sio->sp2_base); |
173 | 176 | ||
174 | pci_read_config_dword (pdev, SIO_PPBAR, &sio->pp_base); | 177 | pci_read_config_dword (pdev, SIO_PPBAR, &sio->pp_base); |
175 | sio->pp_base &= ~1; | 178 | sio->pp_base &= ~1; |
176 | printk (KERN_INFO "SuperIO: Parallel port at 0x%x\n", sio->pp_base); | 179 | printk (KERN_INFO "SuperIO: Parallel port at 0x%x\n", sio->pp_base); |
177 | 180 | ||
178 | pci_read_config_dword (pdev, SIO_FDCBAR, &sio->fdc_base); | 181 | pci_read_config_dword (pdev, SIO_FDCBAR, &sio->fdc_base); |
179 | sio->fdc_base &= ~1; | 182 | sio->fdc_base &= ~1; |
180 | printk (KERN_INFO "SuperIO: Floppy controller at 0x%x\n", sio->fdc_base); | 183 | printk (KERN_INFO "SuperIO: Floppy controller at 0x%x\n", sio->fdc_base); |
181 | pci_read_config_dword (pdev, SIO_ACPIBAR, &sio->acpi_base); | 184 | pci_read_config_dword (pdev, SIO_ACPIBAR, &sio->acpi_base); |
182 | sio->acpi_base &= ~1; | 185 | sio->acpi_base &= ~1; |
183 | printk (KERN_INFO "SuperIO: ACPI at 0x%x\n", sio->acpi_base); | 186 | printk (KERN_INFO "SuperIO: ACPI at 0x%x\n", sio->acpi_base); |
184 | 187 | ||
185 | request_region (IC_PIC1, 0x1f, "pic1"); | 188 | request_region (IC_PIC1, 0x1f, "pic1"); |
186 | request_region (IC_PIC2, 0x1f, "pic2"); | 189 | request_region (IC_PIC2, 0x1f, "pic2"); |
187 | request_region (sio->acpi_base, 0x1f, "acpi"); | 190 | request_region (sio->acpi_base, 0x1f, "acpi"); |
188 | 191 | ||
189 | /* Enable the legacy I/O function */ | 192 | /* Enable the legacy I/O function */ |
190 | pci_read_config_word (pdev, PCI_COMMAND, &word); | 193 | pci_read_config_word (pdev, PCI_COMMAND, &word); |
191 | word |= PCI_COMMAND_SERR | PCI_COMMAND_PARITY | PCI_COMMAND_IO; | 194 | word |= PCI_COMMAND_SERR | PCI_COMMAND_PARITY | PCI_COMMAND_IO; |
192 | pci_write_config_word (pdev, PCI_COMMAND, word); | 195 | pci_write_config_word (pdev, PCI_COMMAND, word); |
193 | 196 | ||
194 | pci_set_master (pdev); | 197 | pci_set_master (pdev); |
195 | pci_enable_device(pdev); | 198 | pci_enable_device(pdev); |
196 | 199 | ||
197 | /* | 200 | /* |
198 | * Next project is programming the onboard interrupt controllers. | 201 | * Next project is programming the onboard interrupt controllers. |
199 | * PDC hasn't done this for us, since it's using polled I/O. | 202 | * PDC hasn't done this for us, since it's using polled I/O. |
200 | * | 203 | * |
201 | * XXX Use dword writes to avoid bugs in Elroy or Suckyio Config | 204 | * XXX Use dword writes to avoid bugs in Elroy or Suckyio Config |
202 | * space access. PCI is by nature a 32-bit bus and config | 205 | * space access. PCI is by nature a 32-bit bus and config |
203 | * space can be sensitive to that. | 206 | * space can be sensitive to that. |
204 | */ | 207 | */ |
205 | 208 | ||
206 | /* 0x64 - 0x67 : | 209 | /* 0x64 - 0x67 : |
207 | DMA Rtg 2 | 210 | DMA Rtg 2 |
208 | DMA Rtg 3 | 211 | DMA Rtg 3 |
209 | DMA Chan Ctl | 212 | DMA Chan Ctl |
210 | TRIGGER_1 == 0x82 USB & IDE level triggered, rest to edge | 213 | TRIGGER_1 == 0x82 USB & IDE level triggered, rest to edge |
211 | */ | 214 | */ |
212 | pci_write_config_dword (pdev, 0x64, 0x82000000U); | 215 | pci_write_config_dword (pdev, 0x64, 0x82000000U); |
213 | 216 | ||
214 | /* 0x68 - 0x6b : | 217 | /* 0x68 - 0x6b : |
215 | TRIGGER_2 == 0x00 all edge triggered (not used) | 218 | TRIGGER_2 == 0x00 all edge triggered (not used) |
216 | CFG_IR_SER == 0x43 SerPort1 = IRQ3, SerPort2 = IRQ4 | 219 | CFG_IR_SER == 0x43 SerPort1 = IRQ3, SerPort2 = IRQ4 |
217 | CFG_IR_PF == 0x65 ParPort = IRQ5, FloppyCtlr = IRQ6 | 220 | CFG_IR_PF == 0x65 ParPort = IRQ5, FloppyCtlr = IRQ6 |
218 | CFG_IR_IDE == 0x07 IDE1 = IRQ7, reserved | 221 | CFG_IR_IDE == 0x07 IDE1 = IRQ7, reserved |
219 | */ | 222 | */ |
220 | pci_write_config_dword (pdev, TRIGGER_2, 0x07654300U); | 223 | pci_write_config_dword (pdev, TRIGGER_2, 0x07654300U); |
221 | 224 | ||
222 | /* 0x6c - 0x6f : | 225 | /* 0x6c - 0x6f : |
223 | CFG_IR_INTAB == 0x00 | 226 | CFG_IR_INTAB == 0x00 |
224 | CFG_IR_INTCD == 0x10 USB = IRQ1 | 227 | CFG_IR_INTCD == 0x10 USB = IRQ1 |
225 | CFG_IR_PS2 == 0x00 | 228 | CFG_IR_PS2 == 0x00 |
226 | CFG_IR_FXBUS == 0x00 | 229 | CFG_IR_FXBUS == 0x00 |
227 | */ | 230 | */ |
228 | pci_write_config_dword (pdev, CFG_IR_INTAB, 0x00001000U); | 231 | pci_write_config_dword (pdev, CFG_IR_INTAB, 0x00001000U); |
229 | 232 | ||
230 | /* 0x70 - 0x73 : | 233 | /* 0x70 - 0x73 : |
231 | CFG_IR_USB == 0x00 not used. USB is connected to INTD. | 234 | CFG_IR_USB == 0x00 not used. USB is connected to INTD. |
232 | CFG_IR_ACPI == 0x00 not used. | 235 | CFG_IR_ACPI == 0x00 not used. |
233 | DMA Priority == 0x4c88 Power on default value. NFC. | 236 | DMA Priority == 0x4c88 Power on default value. NFC. |
234 | */ | 237 | */ |
235 | pci_write_config_dword (pdev, CFG_IR_USB, 0x4c880000U); | 238 | pci_write_config_dword (pdev, CFG_IR_USB, 0x4c880000U); |
236 | 239 | ||
237 | /* PIC1 Initialization Command Word register programming */ | 240 | /* PIC1 Initialization Command Word register programming */ |
238 | outb (0x11,IC_PIC1+0); /* ICW1: ICW4 write req | ICW1 */ | 241 | outb (0x11,IC_PIC1+0); /* ICW1: ICW4 write req | ICW1 */ |
239 | outb (0x00,IC_PIC1+1); /* ICW2: interrupt vector table - not used */ | 242 | outb (0x00,IC_PIC1+1); /* ICW2: interrupt vector table - not used */ |
240 | outb (0x04,IC_PIC1+1); /* ICW3: Cascade */ | 243 | outb (0x04,IC_PIC1+1); /* ICW3: Cascade */ |
241 | outb (0x01,IC_PIC1+1); /* ICW4: x86 mode */ | 244 | outb (0x01,IC_PIC1+1); /* ICW4: x86 mode */ |
242 | 245 | ||
243 | /* PIC1 Program Operational Control Words */ | 246 | /* PIC1 Program Operational Control Words */ |
244 | outb (0xff,IC_PIC1+1); /* OCW1: Mask all interrupts */ | 247 | outb (0xff,IC_PIC1+1); /* OCW1: Mask all interrupts */ |
245 | outb (0xc2,IC_PIC1+0); /* OCW2: priority (3-7,0-2) */ | 248 | outb (0xc2,IC_PIC1+0); /* OCW2: priority (3-7,0-2) */ |
246 | 249 | ||
247 | /* PIC2 Initialization Command Word register programming */ | 250 | /* PIC2 Initialization Command Word register programming */ |
248 | outb (0x11,IC_PIC2+0); /* ICW1: ICW4 write req | ICW1 */ | 251 | outb (0x11,IC_PIC2+0); /* ICW1: ICW4 write req | ICW1 */ |
249 | outb (0x00,IC_PIC2+1); /* ICW2: N/A */ | 252 | outb (0x00,IC_PIC2+1); /* ICW2: N/A */ |
250 | outb (0x02,IC_PIC2+1); /* ICW3: Slave ID code */ | 253 | outb (0x02,IC_PIC2+1); /* ICW3: Slave ID code */ |
251 | outb (0x01,IC_PIC2+1); /* ICW4: x86 mode */ | 254 | outb (0x01,IC_PIC2+1); /* ICW4: x86 mode */ |
252 | 255 | ||
253 | /* Program Operational Control Words */ | 256 | /* Program Operational Control Words */ |
254 | outb (0xff,IC_PIC1+1); /* OCW1: Mask all interrupts */ | 257 | outb (0xff,IC_PIC1+1); /* OCW1: Mask all interrupts */ |
255 | outb (0x68,IC_PIC1+0); /* OCW3: OCW3 select | ESMM | SMM */ | 258 | outb (0x68,IC_PIC1+0); /* OCW3: OCW3 select | ESMM | SMM */ |
256 | 259 | ||
257 | /* Write master mask reg */ | 260 | /* Write master mask reg */ |
258 | outb (0xff,IC_PIC1+1); | 261 | outb (0xff,IC_PIC1+1); |
259 | 262 | ||
260 | /* Setup USB power regulation */ | 263 | /* Setup USB power regulation */ |
261 | outb(1, sio->acpi_base + USB_REG_CR); | 264 | outb(1, sio->acpi_base + USB_REG_CR); |
262 | if (inb(sio->acpi_base + USB_REG_CR) & 1) | 265 | if (inb(sio->acpi_base + USB_REG_CR) & 1) |
263 | printk(KERN_INFO "SuperIO: USB regulator enabled\n"); | 266 | printk(KERN_INFO "SuperIO: USB regulator enabled\n"); |
264 | else | 267 | else |
265 | printk(KERN_ERR "USB regulator not initialized!\n"); | 268 | printk(KERN_ERR "USB regulator not initialized!\n"); |
266 | 269 | ||
267 | if (request_irq(pdev->irq, superio_interrupt, SA_INTERRUPT, | 270 | if (request_irq(pdev->irq, superio_interrupt, SA_INTERRUPT, |
268 | "SuperIO", (void *)sio)) { | 271 | "SuperIO", (void *)sio)) { |
269 | 272 | ||
270 | printk(KERN_ERR "SuperIO: could not get irq\n"); | 273 | printk(KERN_ERR "SuperIO: could not get irq\n"); |
271 | BUG(); | 274 | BUG(); |
272 | return; | 275 | return; |
273 | } | 276 | } |
274 | 277 | ||
275 | sio->suckyio_irq_enabled = 1; | 278 | sio->suckyio_irq_enabled = 1; |
276 | } | 279 | } |
280 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87560_LIO, superio_init); | ||
277 | 281 | ||
278 | |||
279 | static void superio_disable_irq(unsigned int irq) | 282 | static void superio_disable_irq(unsigned int irq) |
280 | { | 283 | { |
281 | u8 r8; | 284 | u8 r8; |
282 | 285 | ||
283 | if ((irq < 1) || (irq == 2) || (irq > 7)) { | 286 | if ((irq < 1) || (irq == 2) || (irq > 7)) { |
284 | printk(KERN_ERR "SuperIO: Illegal irq number.\n"); | 287 | printk(KERN_ERR "SuperIO: Illegal irq number.\n"); |
285 | BUG(); | 288 | BUG(); |
286 | return; | 289 | return; |
287 | } | 290 | } |
288 | 291 | ||
289 | /* Mask interrupt */ | 292 | /* Mask interrupt */ |
290 | 293 | ||
291 | r8 = inb(IC_PIC1+1); | 294 | r8 = inb(IC_PIC1+1); |
292 | r8 |= (1 << irq); | 295 | r8 |= (1 << irq); |
293 | outb (r8,IC_PIC1+1); | 296 | outb (r8,IC_PIC1+1); |
294 | } | 297 | } |
295 | 298 | ||
296 | static void superio_enable_irq(unsigned int irq) | 299 | static void superio_enable_irq(unsigned int irq) |
297 | { | 300 | { |
298 | u8 r8; | 301 | u8 r8; |
299 | 302 | ||
300 | if ((irq < 1) || (irq == 2) || (irq > 7)) { | 303 | if ((irq < 1) || (irq == 2) || (irq > 7)) { |
301 | printk(KERN_ERR "SuperIO: Illegal irq number (%d).\n", irq); | 304 | printk(KERN_ERR "SuperIO: Illegal irq number (%d).\n", irq); |
302 | BUG(); | 305 | BUG(); |
303 | return; | 306 | return; |
304 | } | 307 | } |
305 | 308 | ||
306 | /* Unmask interrupt */ | 309 | /* Unmask interrupt */ |
307 | r8 = inb(IC_PIC1+1); | 310 | r8 = inb(IC_PIC1+1); |
308 | r8 &= ~(1 << irq); | 311 | r8 &= ~(1 << irq); |
309 | outb (r8,IC_PIC1+1); | 312 | outb (r8,IC_PIC1+1); |
310 | } | 313 | } |
311 | 314 | ||
312 | static unsigned int superio_startup_irq(unsigned int irq) | 315 | static unsigned int superio_startup_irq(unsigned int irq) |
313 | { | 316 | { |
314 | superio_enable_irq(irq); | 317 | superio_enable_irq(irq); |
315 | return 0; | 318 | return 0; |
316 | } | 319 | } |
317 | 320 | ||
318 | static struct hw_interrupt_type superio_interrupt_type = { | 321 | static struct hw_interrupt_type superio_interrupt_type = { |
319 | .typename = "SuperIO", | 322 | .typename = "SuperIO", |
320 | .startup = superio_startup_irq, | 323 | .startup = superio_startup_irq, |
321 | .shutdown = superio_disable_irq, | 324 | .shutdown = superio_disable_irq, |
322 | .enable = superio_enable_irq, | 325 | .enable = superio_enable_irq, |
323 | .disable = superio_disable_irq, | 326 | .disable = superio_disable_irq, |
324 | .ack = no_ack_irq, | 327 | .ack = no_ack_irq, |
325 | .end = no_end_irq, | 328 | .end = no_end_irq, |
326 | }; | 329 | }; |
327 | 330 | ||
328 | #ifdef DEBUG_SUPERIO_INIT | 331 | #ifdef DEBUG_SUPERIO_INIT |
329 | static unsigned short expected_device[3] = { | 332 | static unsigned short expected_device[3] = { |
330 | PCI_DEVICE_ID_NS_87415, | 333 | PCI_DEVICE_ID_NS_87415, |
331 | PCI_DEVICE_ID_NS_87560_LIO, | 334 | PCI_DEVICE_ID_NS_87560_LIO, |
332 | PCI_DEVICE_ID_NS_87560_USB | 335 | PCI_DEVICE_ID_NS_87560_USB |
333 | }; | 336 | }; |
334 | #endif | 337 | #endif |
335 | 338 | ||
336 | int superio_fixup_irq(struct pci_dev *pcidev) | 339 | int superio_fixup_irq(struct pci_dev *pcidev) |
337 | { | 340 | { |
338 | int local_irq, i; | 341 | int local_irq, i; |
339 | 342 | ||
340 | #ifdef DEBUG_SUPERIO_INIT | 343 | #ifdef DEBUG_SUPERIO_INIT |
341 | int fn; | 344 | int fn; |
342 | fn = PCI_FUNC(pcidev->devfn); | 345 | fn = PCI_FUNC(pcidev->devfn); |
343 | 346 | ||
344 | /* Verify the function number matches the expected device id. */ | 347 | /* Verify the function number matches the expected device id. */ |
345 | if (expected_device[fn] != pcidev->device) { | 348 | if (expected_device[fn] != pcidev->device) { |
346 | BUG(); | 349 | BUG(); |
347 | return -1; | 350 | return -1; |
348 | } | 351 | } |
349 | printk("superio_fixup_irq(%s) ven 0x%x dev 0x%x from %p\n", | 352 | printk("superio_fixup_irq(%s) ven 0x%x dev 0x%x from %p\n", |
350 | pci_name(pcidev), | 353 | pci_name(pcidev), |
351 | pcidev->vendor, pcidev->device, | 354 | pcidev->vendor, pcidev->device, |
352 | __builtin_return_address(0)); | 355 | __builtin_return_address(0)); |
353 | #endif | 356 | #endif |
354 | 357 | ||
355 | for (i = 0; i < 16; i++) { | 358 | for (i = 0; i < 16; i++) { |
356 | irq_desc[i].handler = &superio_interrupt_type; | 359 | irq_desc[i].handler = &superio_interrupt_type; |
357 | } | 360 | } |
358 | 361 | ||
359 | /* | 362 | /* |
360 | * We don't allocate a SuperIO irq for the legacy IO function, | 363 | * We don't allocate a SuperIO irq for the legacy IO function, |
361 | * since it is a "bridge". Instead, we will allocate irq's for | 364 | * since it is a "bridge". Instead, we will allocate irq's for |
362 | * each legacy device as they are initialized. | 365 | * each legacy device as they are initialized. |
363 | */ | 366 | */ |
364 | 367 | ||
365 | switch(pcidev->device) { | 368 | switch(pcidev->device) { |
366 | case PCI_DEVICE_ID_NS_87415: /* Function 0 */ | 369 | case PCI_DEVICE_ID_NS_87415: /* Function 0 */ |
367 | local_irq = IDE_IRQ; | 370 | local_irq = IDE_IRQ; |
368 | break; | 371 | break; |
369 | case PCI_DEVICE_ID_NS_87560_LIO: /* Function 1 */ | 372 | case PCI_DEVICE_ID_NS_87560_LIO: /* Function 1 */ |
370 | sio_dev.lio_pdev = pcidev; /* save for superio_init() */ | 373 | sio_dev.lio_pdev = pcidev; /* save for superio_init() */ |
371 | return -1; | 374 | return -1; |
372 | case PCI_DEVICE_ID_NS_87560_USB: /* Function 2 */ | 375 | case PCI_DEVICE_ID_NS_87560_USB: /* Function 2 */ |
373 | sio_dev.usb_pdev = pcidev; /* save for superio_init() */ | 376 | sio_dev.usb_pdev = pcidev; /* save for superio_init() */ |
374 | local_irq = USB_IRQ; | 377 | local_irq = USB_IRQ; |
375 | break; | 378 | break; |
376 | default: | 379 | default: |
377 | local_irq = -1; | 380 | local_irq = -1; |
378 | BUG(); | 381 | BUG(); |
379 | break; | 382 | break; |
380 | } | 383 | } |
381 | 384 | ||
382 | return local_irq; | 385 | return local_irq; |
383 | } | 386 | } |
384 | 387 | ||
385 | static struct uart_port serial[] = { | 388 | static struct uart_port serial[] = { |
386 | { | 389 | { |
387 | .iotype = UPIO_PORT, | 390 | .iotype = UPIO_PORT, |
388 | .line = 0, | 391 | .line = 0, |
389 | .type = PORT_16550A, | 392 | .type = PORT_16550A, |
390 | .uartclk = 115200*16, | 393 | .uartclk = 115200*16, |
391 | .fifosize = 16, | 394 | .fifosize = 16, |
392 | }, | 395 | }, |
393 | { | 396 | { |
394 | .iotype = UPIO_PORT, | 397 | .iotype = UPIO_PORT, |
395 | .line = 1, | 398 | .line = 1, |
396 | .type = PORT_16550A, | 399 | .type = PORT_16550A, |
397 | .uartclk = 115200*16, | 400 | .uartclk = 115200*16, |
398 | .fifosize = 16, | 401 | .fifosize = 16, |
399 | } | 402 | } |
400 | }; | 403 | }; |
401 | 404 | ||
402 | static void __devinit superio_serial_init(void) | 405 | static void __devinit superio_serial_init(void) |
403 | { | 406 | { |
404 | #ifdef CONFIG_SERIAL_8250 | 407 | #ifdef CONFIG_SERIAL_8250 |
405 | int retval; | 408 | int retval; |
406 | 409 | ||
407 | serial[0].iobase = sio_dev.sp1_base; | 410 | serial[0].iobase = sio_dev.sp1_base; |
408 | serial[0].irq = SP1_IRQ; | 411 | serial[0].irq = SP1_IRQ; |
409 | spin_lock_init(&serial[0].lock); | 412 | spin_lock_init(&serial[0].lock); |
410 | 413 | ||
411 | retval = early_serial_setup(&serial[0]); | 414 | retval = early_serial_setup(&serial[0]); |
412 | if (retval < 0) { | 415 | if (retval < 0) { |
413 | printk(KERN_WARNING "SuperIO: Register Serial #0 failed.\n"); | 416 | printk(KERN_WARNING "SuperIO: Register Serial #0 failed.\n"); |
414 | return; | 417 | return; |
415 | } | 418 | } |
416 | 419 | ||
417 | serial[1].iobase = sio_dev.sp2_base; | 420 | serial[1].iobase = sio_dev.sp2_base; |
418 | serial[1].irq = SP2_IRQ; | 421 | serial[1].irq = SP2_IRQ; |
419 | spin_lock_init(&serial[1].lock); | 422 | spin_lock_init(&serial[1].lock); |
420 | retval = early_serial_setup(&serial[1]); | 423 | retval = early_serial_setup(&serial[1]); |
421 | 424 | ||
422 | if (retval < 0) | 425 | if (retval < 0) |
423 | printk(KERN_WARNING "SuperIO: Register Serial #1 failed.\n"); | 426 | printk(KERN_WARNING "SuperIO: Register Serial #1 failed.\n"); |
424 | #endif /* CONFIG_SERIAL_8250 */ | 427 | #endif /* CONFIG_SERIAL_8250 */ |
425 | } | 428 | } |
426 | 429 | ||
427 | 430 | ||
428 | static void __devinit superio_parport_init(void) | 431 | static void __devinit superio_parport_init(void) |
429 | { | 432 | { |
430 | #ifdef CONFIG_PARPORT_PC | 433 | #ifdef CONFIG_PARPORT_PC |
431 | if (!parport_pc_probe_port(sio_dev.pp_base, | 434 | if (!parport_pc_probe_port(sio_dev.pp_base, |
432 | 0 /*base_hi*/, | 435 | 0 /*base_hi*/, |
433 | PAR_IRQ, | 436 | PAR_IRQ, |
434 | PARPORT_DMA_NONE /* dma */, | 437 | PARPORT_DMA_NONE /* dma */, |
435 | NULL /*struct pci_dev* */) ) | 438 | NULL /*struct pci_dev* */) ) |
436 | 439 | ||
437 | printk(KERN_WARNING "SuperIO: Probing parallel port failed.\n"); | 440 | printk(KERN_WARNING "SuperIO: Probing parallel port failed.\n"); |
438 | #endif /* CONFIG_PARPORT_PC */ | 441 | #endif /* CONFIG_PARPORT_PC */ |
439 | } | 442 | } |
440 | 443 | ||
441 | 444 | ||
442 | static void superio_fixup_pci(struct pci_dev *pdev) | 445 | static void superio_fixup_pci(struct pci_dev *pdev) |
443 | { | 446 | { |
444 | u8 prog; | 447 | u8 prog; |
445 | 448 | ||
446 | pdev->class |= 0x5; | 449 | pdev->class |= 0x5; |
447 | pci_write_config_byte(pdev, PCI_CLASS_PROG, pdev->class); | 450 | pci_write_config_byte(pdev, PCI_CLASS_PROG, pdev->class); |
448 | 451 | ||
449 | pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog); | 452 | pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog); |
450 | printk("PCI: Enabled native mode for NS87415 (pif=0x%x)\n", prog); | 453 | printk("PCI: Enabled native mode for NS87415 (pif=0x%x)\n", prog); |
451 | } | 454 | } |
452 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87415, superio_fixup_pci); | 455 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87415, superio_fixup_pci); |
453 | 456 | ||
454 | 457 | ||
455 | static int __devinit superio_probe(struct pci_dev *dev, const struct pci_device_id *id) | 458 | static int __devinit |
459 | superio_probe(struct pci_dev *dev, const struct pci_device_id *id) | ||
456 | { | 460 | { |
461 | struct superio_device *sio = &sio_dev; | ||
457 | 462 | ||
458 | /* | 463 | /* |
459 | ** superio_probe(00:0e.0) ven 0x100b dev 0x2 sv 0x0 sd 0x0 class 0x1018a | 464 | ** superio_probe(00:0e.0) ven 0x100b dev 0x2 sv 0x0 sd 0x0 class 0x1018a |
460 | ** superio_probe(00:0e.1) ven 0x100b dev 0xe sv 0x0 sd 0x0 class 0x68000 | 465 | ** superio_probe(00:0e.1) ven 0x100b dev 0xe sv 0x0 sd 0x0 class 0x68000 |
461 | ** superio_probe(00:0e.2) ven 0x100b dev 0x12 sv 0x0 sd 0x0 class 0xc0310 | 466 | ** superio_probe(00:0e.2) ven 0x100b dev 0x12 sv 0x0 sd 0x0 class 0xc0310 |
462 | */ | 467 | */ |
463 | DBG_INIT("superio_probe(%s) ven 0x%x dev 0x%x sv 0x%x sd 0x%x class 0x%x\n", | 468 | DBG_INIT("superio_probe(%s) ven 0x%x dev 0x%x sv 0x%x sd 0x%x class 0x%x\n", |
464 | pci_name(dev), | 469 | pci_name(dev), |
465 | dev->vendor, dev->device, | 470 | dev->vendor, dev->device, |
466 | dev->subsystem_vendor, dev->subsystem_device, | 471 | dev->subsystem_vendor, dev->subsystem_device, |
467 | dev->class); | 472 | dev->class); |
468 | 473 | ||
469 | superio_init(&sio_dev); | 474 | if (!sio->suckyio_irq_enabled) |
475 | BUG(); /* Enabled by PCI_FIXUP_FINAL */ | ||
470 | 476 | ||
471 | if (dev->device == PCI_DEVICE_ID_NS_87560_LIO) { /* Function 1 */ | 477 | if (dev->device == PCI_DEVICE_ID_NS_87560_LIO) { /* Function 1 */ |
472 | superio_parport_init(); | 478 | superio_parport_init(); |
473 | superio_serial_init(); | 479 | superio_serial_init(); |
474 | /* REVISIT XXX : superio_fdc_init() ? */ | 480 | /* REVISIT XXX : superio_fdc_init() ? */ |
475 | return 0; | 481 | return 0; |
476 | } else if (dev->device == PCI_DEVICE_ID_NS_87415) { /* Function 0 */ | 482 | } else if (dev->device == PCI_DEVICE_ID_NS_87415) { /* Function 0 */ |
477 | DBG_INIT("superio_probe: ignoring IDE 87415\n"); | 483 | DBG_INIT("superio_probe: ignoring IDE 87415\n"); |
478 | } else if (dev->device == PCI_DEVICE_ID_NS_87560_USB) { /* Function 2 */ | 484 | } else if (dev->device == PCI_DEVICE_ID_NS_87560_USB) { /* Function 2 */ |
479 | DBG_INIT("superio_probe: ignoring USB OHCI controller\n"); | 485 | DBG_INIT("superio_probe: ignoring USB OHCI controller\n"); |
480 | } else { | 486 | } else { |
481 | DBG_INIT("superio_probe: WTF? Fire Extinguisher?\n"); | 487 | DBG_INIT("superio_probe: WTF? Fire Extinguisher?\n"); |
482 | } | 488 | } |
483 | 489 | ||
484 | /* Let appropriate other driver claim this device. */ | 490 | /* Let appropriate other driver claim this device. */ |
485 | return -ENODEV; | 491 | return -ENODEV; |
486 | } | 492 | } |
487 | 493 | ||
488 | static struct pci_device_id superio_tbl[] = { | 494 | static struct pci_device_id superio_tbl[] = { |
489 | { PCI_VENDOR_ID_NS, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | 495 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87560_LIO) }, |
496 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87560_USB) }, | ||
497 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87415) }, | ||
490 | { 0, } | 498 | { 0, } |
491 | }; | 499 | }; |
492 | 500 | ||
493 | static struct pci_driver superio_driver = { | 501 | static struct pci_driver superio_driver = { |
494 | .name = "SuperIO", | 502 | .name = "SuperIO", |
495 | .id_table = superio_tbl, | 503 | .id_table = superio_tbl, |
496 | .probe = superio_probe, | 504 | .probe = superio_probe, |
497 | }; | 505 | }; |
498 | 506 | ||
499 | static int __init superio_modinit(void) | 507 | static int __init superio_modinit(void) |
500 | { | 508 | { |
501 | return pci_register_driver(&superio_driver); | 509 | return pci_register_driver(&superio_driver); |
502 | } | 510 | } |
503 | 511 | ||
504 | static void __exit superio_exit(void) | 512 | static void __exit superio_exit(void) |
505 | { | 513 | { |
506 | pci_unregister_driver(&superio_driver); | 514 | pci_unregister_driver(&superio_driver); |
507 | } | 515 | } |
508 | |||
509 | 516 |