This source file includes following definitions.
- superio_interrupt
- superio_init
- superio_mask_irq
- superio_unmask_irq
- superio_fixup_irq
- superio_serial_init
- superio_parport_init
- superio_fixup_pci
- superio_probe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 #include <linux/errno.h>
60 #include <linux/init.h>
61 #include <linux/module.h>
62 #include <linux/types.h>
63 #include <linux/interrupt.h>
64 #include <linux/ioport.h>
65 #include <linux/serial.h>
66 #include <linux/pci.h>
67 #include <linux/parport.h>
68 #include <linux/parport_pc.h>
69 #include <linux/termios.h>
70 #include <linux/tty.h>
71 #include <linux/serial_core.h>
72 #include <linux/serial_8250.h>
73 #include <linux/delay.h>
74
75 #include <asm/io.h>
76 #include <asm/hardware.h>
77 #include <asm/superio.h>
78
79 static struct superio_device sio_dev;
80
81
82 #undef DEBUG_SUPERIO_INIT
83
84 #ifdef DEBUG_SUPERIO_INIT
85 #define DBG_INIT(x...) printk(x)
86 #else
87 #define DBG_INIT(x...)
88 #endif
89
90 #define SUPERIO "SuperIO"
91 #define PFX SUPERIO ": "
92
93 static irqreturn_t
94 superio_interrupt(int parent_irq, void *devp)
95 {
96 u8 results;
97 u8 local_irq;
98
99
100 outb (OCW3_POLL,IC_PIC1+0);
101
102 results = inb(IC_PIC1+0);
103
104
105
106
107
108
109 if ((results & 0x80) == 0) {
110
111
112
113
114 return IRQ_NONE;
115 }
116
117
118 local_irq = results & 0x0f;
119
120 if (local_irq == 2 || local_irq > 7) {
121 printk(KERN_ERR PFX "slave interrupted!\n");
122 return IRQ_HANDLED;
123 }
124
125 if (local_irq == 7) {
126
127
128
129 outb(OCW3_ISR,IC_PIC1+0);
130 results = inb(IC_PIC1+0);
131 if ((results & 0x80) == 0) {
132 printk(KERN_WARNING PFX "spurious interrupt!\n");
133 return IRQ_HANDLED;
134 }
135 }
136
137
138 generic_handle_irq(local_irq);
139
140
141
142
143 outb((OCW2_SEOI|local_irq),IC_PIC1 + 0);
144 return IRQ_HANDLED;
145 }
146
147
148 static void
149 superio_init(struct pci_dev *pcidev)
150 {
151 struct superio_device *sio = &sio_dev;
152 struct pci_dev *pdev = sio->lio_pdev;
153 u16 word;
154 int ret;
155
156 if (sio->suckyio_irq_enabled)
157 return;
158
159 BUG_ON(!pdev);
160 BUG_ON(!sio->usb_pdev);
161
162
163 pdev->irq = sio->usb_pdev->irq;
164
165
166 sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev);
167
168 printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i)\n",
169 pci_name(pdev), pdev->irq);
170
171 pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base);
172 sio->sp1_base &= ~1;
173 printk(KERN_INFO PFX "Serial port 1 at 0x%x\n", sio->sp1_base);
174
175 pci_read_config_dword (pdev, SIO_SP2BAR, &sio->sp2_base);
176 sio->sp2_base &= ~1;
177 printk(KERN_INFO PFX "Serial port 2 at 0x%x\n", sio->sp2_base);
178
179 pci_read_config_dword (pdev, SIO_PPBAR, &sio->pp_base);
180 sio->pp_base &= ~1;
181 printk(KERN_INFO PFX "Parallel port at 0x%x\n", sio->pp_base);
182
183 pci_read_config_dword (pdev, SIO_FDCBAR, &sio->fdc_base);
184 sio->fdc_base &= ~1;
185 printk(KERN_INFO PFX "Floppy controller at 0x%x\n", sio->fdc_base);
186 pci_read_config_dword (pdev, SIO_ACPIBAR, &sio->acpi_base);
187 sio->acpi_base &= ~1;
188 printk(KERN_INFO PFX "ACPI at 0x%x\n", sio->acpi_base);
189
190 request_region (IC_PIC1, 0x1f, "pic1");
191 request_region (IC_PIC2, 0x1f, "pic2");
192 request_region (sio->acpi_base, 0x1f, "acpi");
193
194
195 pci_read_config_word (pdev, PCI_COMMAND, &word);
196 word |= PCI_COMMAND_SERR | PCI_COMMAND_PARITY | PCI_COMMAND_IO;
197 pci_write_config_word (pdev, PCI_COMMAND, word);
198
199 pci_set_master (pdev);
200 ret = pci_enable_device(pdev);
201 BUG_ON(ret < 0);
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218 pci_write_config_dword (pdev, 0x64, 0x82000000U);
219
220
221
222
223
224
225
226 pci_write_config_dword (pdev, TRIGGER_2, 0x07654300U);
227
228
229
230
231
232
233
234 pci_write_config_dword (pdev, CFG_IR_INTAB, 0x00001000U);
235
236
237
238
239
240
241 pci_write_config_dword (pdev, CFG_IR_USB, 0x4c880000U);
242
243
244 outb (0x11,IC_PIC1+0);
245 outb (0x00,IC_PIC1+1);
246 outb (0x04,IC_PIC1+1);
247 outb (0x01,IC_PIC1+1);
248
249
250 outb (0xff,IC_PIC1+1);
251 outb (0xc2,IC_PIC1+0);
252
253
254 outb (0x11,IC_PIC2+0);
255 outb (0x00,IC_PIC2+1);
256 outb (0x02,IC_PIC2+1);
257 outb (0x01,IC_PIC2+1);
258
259
260 outb (0xff,IC_PIC1+1);
261 outb (0x68,IC_PIC1+0);
262
263
264 outb (0xff,IC_PIC1+1);
265
266
267 outb(1, sio->acpi_base + USB_REG_CR);
268 if (inb(sio->acpi_base + USB_REG_CR) & 1)
269 printk(KERN_INFO PFX "USB regulator enabled\n");
270 else
271 printk(KERN_ERR PFX "USB regulator not initialized!\n");
272
273 if (request_irq(pdev->irq, superio_interrupt, 0,
274 SUPERIO, (void *)sio)) {
275
276 printk(KERN_ERR PFX "could not get irq\n");
277 BUG();
278 return;
279 }
280
281 sio->suckyio_irq_enabled = 1;
282 }
283 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87560_LIO, superio_init);
284
285 static void superio_mask_irq(struct irq_data *d)
286 {
287 unsigned int irq = d->irq;
288 u8 r8;
289
290 if ((irq < 1) || (irq == 2) || (irq > 7)) {
291 printk(KERN_ERR PFX "Illegal irq number.\n");
292 BUG();
293 return;
294 }
295
296
297
298 r8 = inb(IC_PIC1+1);
299 r8 |= (1 << irq);
300 outb (r8,IC_PIC1+1);
301 }
302
303 static void superio_unmask_irq(struct irq_data *d)
304 {
305 unsigned int irq = d->irq;
306 u8 r8;
307
308 if ((irq < 1) || (irq == 2) || (irq > 7)) {
309 printk(KERN_ERR PFX "Illegal irq number (%d).\n", irq);
310 BUG();
311 return;
312 }
313
314
315 r8 = inb(IC_PIC1+1);
316 r8 &= ~(1 << irq);
317 outb (r8,IC_PIC1+1);
318 }
319
320 static struct irq_chip superio_interrupt_type = {
321 .name = SUPERIO,
322 .irq_unmask = superio_unmask_irq,
323 .irq_mask = superio_mask_irq,
324 };
325
326 #ifdef DEBUG_SUPERIO_INIT
327 static unsigned short expected_device[3] = {
328 PCI_DEVICE_ID_NS_87415,
329 PCI_DEVICE_ID_NS_87560_LIO,
330 PCI_DEVICE_ID_NS_87560_USB
331 };
332 #endif
333
334 int superio_fixup_irq(struct pci_dev *pcidev)
335 {
336 int local_irq, i;
337
338 #ifdef DEBUG_SUPERIO_INIT
339 int fn;
340 fn = PCI_FUNC(pcidev->devfn);
341
342
343 if (expected_device[fn] != pcidev->device) {
344 BUG();
345 return -1;
346 }
347 printk(KERN_DEBUG "superio_fixup_irq(%s) ven 0x%x dev 0x%x from %ps\n",
348 pci_name(pcidev),
349 pcidev->vendor, pcidev->device,
350 __builtin_return_address(0));
351 #endif
352
353 for (i = 0; i < 16; i++) {
354 irq_set_chip_and_handler(i, &superio_interrupt_type,
355 handle_simple_irq);
356 }
357
358
359
360
361
362
363
364 switch(pcidev->device) {
365 case PCI_DEVICE_ID_NS_87415:
366 local_irq = IDE_IRQ;
367 break;
368 case PCI_DEVICE_ID_NS_87560_LIO:
369 sio_dev.lio_pdev = pcidev;
370 return -1;
371 case PCI_DEVICE_ID_NS_87560_USB:
372 sio_dev.usb_pdev = pcidev;
373 local_irq = USB_IRQ;
374 break;
375 default:
376 local_irq = -1;
377 BUG();
378 break;
379 }
380
381 return local_irq;
382 }
383
384 static void __init superio_serial_init(void)
385 {
386 #ifdef CONFIG_SERIAL_8250
387 int retval;
388 struct uart_port serial_port;
389
390 memset(&serial_port, 0, sizeof(serial_port));
391 serial_port.iotype = UPIO_PORT;
392 serial_port.type = PORT_16550A;
393 serial_port.uartclk = 115200*16;
394 serial_port.flags = UPF_FIXED_PORT | UPF_FIXED_TYPE |
395 UPF_BOOT_AUTOCONF;
396
397
398 serial_port.iobase = sio_dev.sp1_base;
399 serial_port.irq = SP1_IRQ;
400 serial_port.line = 0;
401 retval = early_serial_setup(&serial_port);
402 if (retval < 0) {
403 printk(KERN_WARNING PFX "Register Serial #0 failed.\n");
404 return;
405 }
406
407
408 serial_port.iobase = sio_dev.sp2_base;
409 serial_port.irq = SP2_IRQ;
410 serial_port.line = 1;
411 retval = early_serial_setup(&serial_port);
412 if (retval < 0)
413 printk(KERN_WARNING PFX "Register Serial #1 failed.\n");
414 #endif
415 }
416
417
418 static void __init superio_parport_init(void)
419 {
420 #ifdef CONFIG_PARPORT_PC
421 if (!parport_pc_probe_port(sio_dev.pp_base,
422 0 ,
423 PAR_IRQ,
424 PARPORT_DMA_NONE ,
425 NULL ,
426 0 ))
427
428 printk(KERN_WARNING PFX "Probing parallel port failed.\n");
429 #endif
430 }
431
432
433 static void superio_fixup_pci(struct pci_dev *pdev)
434 {
435 u8 prog;
436
437 pdev->class |= 0x5;
438 pci_write_config_byte(pdev, PCI_CLASS_PROG, pdev->class);
439
440 pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog);
441 printk("PCI: Enabled native mode for NS87415 (pif=0x%x)\n", prog);
442 }
443 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87415, superio_fixup_pci);
444
445
446 static int __init
447 superio_probe(struct pci_dev *dev, const struct pci_device_id *id)
448 {
449 struct superio_device *sio = &sio_dev;
450
451
452
453
454
455
456 DBG_INIT("superio_probe(%s) ven 0x%x dev 0x%x sv 0x%x sd 0x%x class 0x%x\n",
457 pci_name(dev),
458 dev->vendor, dev->device,
459 dev->subsystem_vendor, dev->subsystem_device,
460 dev->class);
461
462 BUG_ON(!sio->suckyio_irq_enabled);
463
464 if (dev->device == PCI_DEVICE_ID_NS_87560_LIO) {
465 superio_parport_init();
466 superio_serial_init();
467
468 return 0;
469 } else if (dev->device == PCI_DEVICE_ID_NS_87415) {
470 DBG_INIT("superio_probe: ignoring IDE 87415\n");
471 } else if (dev->device == PCI_DEVICE_ID_NS_87560_USB) {
472 DBG_INIT("superio_probe: ignoring USB OHCI controller\n");
473 } else {
474 DBG_INIT("superio_probe: WTF? Fire Extinguisher?\n");
475 }
476
477
478 return -ENODEV;
479 }
480
481 static const struct pci_device_id superio_tbl[] __initconst = {
482 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87560_LIO) },
483 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87560_USB) },
484 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87415) },
485 { 0, }
486 };
487
488 static struct pci_driver superio_driver __refdata = {
489 .name = SUPERIO,
490 .id_table = superio_tbl,
491 .probe = superio_probe,
492 };
493
494 module_pci_driver(superio_driver);