2 * pcic.c: MicroSPARC-IIep PCI controller support
4 * Copyright (C) 1998 V. Roganov and G. Raiko
6 * Code is derived from Ultra/PCI PSYCHO controller support, see that
9 * Support for diverse IIep based platforms by Pete Zaitcev.
10 * CP-1200 by Eric Brower.
13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <linux/init.h>
17 #include <linux/slab.h>
18 #include <linux/jiffies.h>
20 #include <asm/swift.h> /* for cache flushing. */
23 #include <linux/ctype.h>
24 #include <linux/pci.h>
25 #include <linux/time.h>
26 #include <linux/timex.h>
27 #include <linux/interrupt.h>
30 #include <asm/oplib.h>
33 #include <asm/timex.h>
34 #include <asm/timer.h>
35 #include <asm/uaccess.h>
36 #include <asm/irq_regs.h>
41 * I studied different documents and many live PROMs both from 2.30
42 * family and 3.xx versions. I came to the amazing conclusion: there is
43 * absolutely no way to route interrupts in IIep systems relying on
44 * information which PROM presents. We must hardcode interrupt routing
45 * schematics. And this actually sucks. -- zaitcev 1999/05/12
47 * To find irq for a device we determine which routing map
48 * is in effect or, in other words, on which machine we are running.
49 * We use PROM name for this although other techniques may be used
50 * in special cases (Gleb reports a PROMless IIep based system).
51 * Once we know the map we take device configuration address and
52 * find PCIC pin number where INT line goes. Then we may either program
53 * preferred irq into the PCIC or supply the preexisting irq to the device.
56 unsigned char busno
; /* PCI bus number */
57 unsigned char devfn
; /* Configuration address */
58 unsigned char pin
; /* PCIC external interrupt pin */
59 unsigned char irq
; /* Preferred IRQ (mappable in PCIC) */
60 unsigned int force
; /* Enforce preferred IRQ */
65 struct pcic_ca2irq
*intmap
;
70 * JavaEngine-1 apparently has different versions.
72 * According to communications with Sun folks, for P2 build 501-4628-03:
73 * pin 0 - parallel, audio;
76 * pin 3 - PS/2 kbd and mouse.
78 * OEM manual (805-1486):
82 * pin 3: Not connected
83 * OEM manual says that 501-4628 & 501-4811 are the same thing,
84 * only the latter has NAND flash in place.
86 * So far unofficial Sun wins over the OEM manual. Poor OEMs...
88 static struct pcic_ca2irq pcic_i_je1a
[] = { /* 501-4811-03 */
89 { 0, 0x00, 2, 12, 0 }, /* EBus: hogs all */
90 { 0, 0x01, 1, 6, 1 }, /* Happy Meal */
91 { 0, 0x80, 0, 7, 0 }, /* IGA (unused) */
94 /* XXX JS-E entry is incomplete - PCI Slot 2 address (pin 7)? */
95 static struct pcic_ca2irq pcic_i_jse
[] = {
96 { 0, 0x00, 0, 13, 0 }, /* Ebus - serial and keyboard */
97 { 0, 0x01, 1, 6, 0 }, /* hme */
98 { 0, 0x08, 2, 9, 0 }, /* VGA - we hope not used :) */
99 { 0, 0x10, 6, 8, 0 }, /* PCI INTA# in Slot 1 */
100 { 0, 0x18, 7, 12, 0 }, /* PCI INTA# in Slot 2, shared w. RTC */
101 { 0, 0x38, 4, 9, 0 }, /* All ISA devices. Read 8259. */
102 { 0, 0x80, 5, 11, 0 }, /* EIDE */
103 /* {0,0x88, 0,0,0} - unknown device... PMU? Probably no interrupt. */
104 { 0, 0xA0, 4, 9, 0 }, /* USB */
106 * Some pins belong to non-PCI devices, we hardcode them in drivers.
107 * sun4m timers - irq 10, 14
108 * PC style RTC - pin 7, irq 4 ?
109 * Smart card, Parallel - pin 4 shared with USB, ISA
110 * audio - pin 3, irq 5 ?
114 /* SPARCengine-6 was the original release name of CP1200.
115 * The documentation differs between the two versions
117 static struct pcic_ca2irq pcic_i_se6
[] = {
118 { 0, 0x08, 0, 2, 0 }, /* SCSI */
119 { 0, 0x01, 1, 6, 0 }, /* HME */
120 { 0, 0x00, 3, 13, 0 }, /* EBus */
124 * Krups (courtesy of Varol Kaptan)
125 * No documentation available, but it was easy to guess
126 * because it was very similar to Espresso.
128 * pin 0 - kbd, mouse, serial;
130 * pin 2 - igs (we do not use it);
132 * pin 4,5,6 - unused;
133 * pin 7 - RTC (from P2 onwards as David B. says).
135 static struct pcic_ca2irq pcic_i_jk
[] = {
136 { 0, 0x00, 0, 13, 0 }, /* Ebus - serial and keyboard */
137 { 0, 0x01, 1, 6, 0 }, /* hme */
141 * Several entries in this list may point to the same routing map
142 * as several PROMs may be installed on the same physical board.
144 #define SN2L_INIT(name, map) \
145 { name, map, ARRAY_SIZE(map) }
147 static struct pcic_sn2list pcic_known_sysnames
[] = {
148 SN2L_INIT("SUNW,JavaEngine1", pcic_i_je1a
), /* JE1, PROM 2.32 */
149 SN2L_INIT("SUNW,JS-E", pcic_i_jse
), /* PROLL JavaStation-E */
150 SN2L_INIT("SUNW,SPARCengine-6", pcic_i_se6
), /* SPARCengine-6/CP-1200 */
151 SN2L_INIT("SUNW,JS-NC", pcic_i_jk
), /* PROLL JavaStation-NC */
152 SN2L_INIT("SUNW,JSIIep", pcic_i_jk
), /* OBP JavaStation-NC */
157 * Only one PCIC per IIep,
158 * and since we have no SMP IIep, only one per system.
161 static struct linux_pcic pcic0
;
163 void __iomem
*pcic_regs
;
164 volatile int pcic_speculative
;
165 volatile int pcic_trapped
;
168 #define CONFIG_CMD(bus, device_fn, where) (0x80000000 | (((unsigned int)bus) << 16) | (((unsigned int)device_fn) << 8) | (where & ~3))
170 static int pcic_read_config_dword(unsigned int busno
, unsigned int devfn
,
171 int where
, u32
*value
)
173 struct linux_pcic
*pcic
;
178 local_irq_save(flags
);
179 #if 0 /* does not fail here */
180 pcic_speculative
= 1;
183 writel(CONFIG_CMD(busno
, devfn
, where
), pcic
->pcic_config_space_addr
);
184 #if 0 /* does not fail here */
187 local_irq_restore(flags
);
192 pcic_speculative
= 2;
194 *value
= readl(pcic
->pcic_config_space_data
+ (where
&4));
197 pcic_speculative
= 0;
198 local_irq_restore(flags
);
202 pcic_speculative
= 0;
203 local_irq_restore(flags
);
207 static int pcic_read_config(struct pci_bus
*bus
, unsigned int devfn
,
208 int where
, int size
, u32
*val
)
212 if (bus
->number
!= 0) return -EINVAL
;
215 pcic_read_config_dword(bus
->number
, devfn
, where
&~3, &v
);
216 *val
= 0xff & (v
>> (8*(where
& 3)));
219 if (where
&1) return -EINVAL
;
220 pcic_read_config_dword(bus
->number
, devfn
, where
&~3, &v
);
221 *val
= 0xffff & (v
>> (8*(where
& 3)));
224 if (where
&3) return -EINVAL
;
225 pcic_read_config_dword(bus
->number
, devfn
, where
&~3, val
);
231 static int pcic_write_config_dword(unsigned int busno
, unsigned int devfn
,
232 int where
, u32 value
)
234 struct linux_pcic
*pcic
;
239 local_irq_save(flags
);
240 writel(CONFIG_CMD(busno
, devfn
, where
), pcic
->pcic_config_space_addr
);
241 writel(value
, pcic
->pcic_config_space_data
+ (where
&4));
242 local_irq_restore(flags
);
246 static int pcic_write_config(struct pci_bus
*bus
, unsigned int devfn
,
247 int where
, int size
, u32 val
)
251 if (bus
->number
!= 0) return -EINVAL
;
254 pcic_read_config_dword(bus
->number
, devfn
, where
&~3, &v
);
255 v
= (v
& ~(0xff << (8*(where
&3)))) |
256 ((0xff&val
) << (8*(where
&3)));
257 return pcic_write_config_dword(bus
->number
, devfn
, where
&~3, v
);
259 if (where
&1) return -EINVAL
;
260 pcic_read_config_dword(bus
->number
, devfn
, where
&~3, &v
);
261 v
= (v
& ~(0xffff << (8*(where
&3)))) |
262 ((0xffff&val
) << (8*(where
&3)));
263 return pcic_write_config_dword(bus
->number
, devfn
, where
&~3, v
);
265 if (where
&3) return -EINVAL
;
266 return pcic_write_config_dword(bus
->number
, devfn
, where
, val
);
271 static struct pci_ops pcic_ops
= {
272 .read
= pcic_read_config
,
273 .write
= pcic_write_config
,
277 * On sparc64 pcibios_init() calls pci_controller_probe().
278 * We want PCIC probed little ahead so that interrupt controller
279 * would be operational.
281 int __init
pcic_probe(void)
283 struct linux_pcic
*pcic
;
284 struct linux_prom_registers regs
[PROMREG_MAX
];
285 struct linux_pbm_info
* pbm
;
291 prom_printf("PCIC: called twice!\n");
296 node
= prom_getchild (prom_root_node
);
297 node
= prom_searchsiblings (node
, "pci");
301 * Map in PCIC register set, config space, and IO base
303 err
= prom_getproperty(node
, "reg", (char*)regs
, sizeof(regs
));
304 if (err
== 0 || err
== -1) {
305 prom_printf("PCIC: Error, cannot get PCIC registers "
312 pcic
->pcic_res_regs
.name
= "pcic_registers";
313 pcic
->pcic_regs
= ioremap(regs
[0].phys_addr
, regs
[0].reg_size
);
314 if (!pcic
->pcic_regs
) {
315 prom_printf("PCIC: Error, cannot map PCIC registers.\n");
319 pcic
->pcic_res_io
.name
= "pcic_io";
320 if ((pcic
->pcic_io
= (unsigned long)
321 ioremap(regs
[1].phys_addr
, 0x10000)) == 0) {
322 prom_printf("PCIC: Error, cannot map PCIC IO Base.\n");
326 pcic
->pcic_res_cfg_addr
.name
= "pcic_cfg_addr";
327 if ((pcic
->pcic_config_space_addr
=
328 ioremap(regs
[2].phys_addr
, regs
[2].reg_size
* 2)) == 0) {
329 prom_printf("PCIC: Error, cannot map "
330 "PCI Configuration Space Address.\n");
335 * Docs say three least significant bits in address and data
336 * must be the same. Thus, we need adjust size of data.
338 pcic
->pcic_res_cfg_data
.name
= "pcic_cfg_data";
339 if ((pcic
->pcic_config_space_data
=
340 ioremap(regs
[3].phys_addr
, regs
[3].reg_size
* 2)) == 0) {
341 prom_printf("PCIC: Error, cannot map "
342 "PCI Configuration Space Data.\n");
347 pbm
->prom_node
= node
;
348 prom_getstring(node
, "name", namebuf
, 63); namebuf
[63] = 0;
349 strcpy(pbm
->prom_name
, namebuf
);
352 extern volatile int t_nmi
[1];
353 extern int pcic_nmi_trap_patch
[1];
355 t_nmi
[0] = pcic_nmi_trap_patch
[0];
356 t_nmi
[1] = pcic_nmi_trap_patch
[1];
357 t_nmi
[2] = pcic_nmi_trap_patch
[2];
358 t_nmi
[3] = pcic_nmi_trap_patch
[3];
359 swift_flush_dcache();
360 pcic_regs
= pcic
->pcic_regs
;
363 prom_getstring(prom_root_node
, "name", namebuf
, 63); namebuf
[63] = 0;
365 struct pcic_sn2list
*p
;
367 for (p
= pcic_known_sysnames
; p
->sysname
!= NULL
; p
++) {
368 if (strcmp(namebuf
, p
->sysname
) == 0)
371 pcic
->pcic_imap
= p
->intmap
;
372 pcic
->pcic_imdim
= p
->mapdim
;
374 if (pcic
->pcic_imap
== NULL
) {
376 * We do not panic here for the sake of embedded systems.
378 printk("PCIC: System %s is unknown, cannot route interrupts\n",
385 static void __init
pcic_pbm_scan_bus(struct linux_pcic
*pcic
)
387 struct linux_pbm_info
*pbm
= &pcic
->pbm
;
389 pbm
->pci_bus
= pci_scan_bus(pbm
->pci_first_busno
, &pcic_ops
, pbm
);
390 #if 0 /* deadwood transplanted from sparc64 */
391 pci_fill_in_pbm_cookies(pbm
->pci_bus
, pbm
, pbm
->prom_node
);
392 pci_record_assignments(pbm
, pbm
->pci_bus
);
393 pci_assign_unassigned(pbm
, pbm
->pci_bus
);
394 pci_fixup_irq(pbm
, pbm
->pci_bus
);
399 * Main entry point from the PCI subsystem.
401 static int __init
pcic_init(void)
403 struct linux_pcic
*pcic
;
406 * PCIC should be initialized at start of the timer.
407 * So, here we report the presence of PCIC and do some magic passes.
414 * Switch off IOTLB translation.
416 writeb(PCI_DVMA_CONTROL_IOTLB_DISABLE
,
417 pcic
->pcic_regs
+PCI_DVMA_CONTROL
);
420 * Increase mapped size for PCI memory space (DMA access).
421 * Should be done in that order (size first, address second).
422 * Why we couldn't set up 4GB and forget about it? XXX
424 writel(0xF0000000UL
, pcic
->pcic_regs
+PCI_SIZE_0
);
425 writel(0+PCI_BASE_ADDRESS_SPACE_MEMORY
,
426 pcic
->pcic_regs
+PCI_BASE_ADDRESS_0
);
428 pcic_pbm_scan_bus(pcic
);
433 int pcic_present(void)
438 static int __devinit
pdev_to_pnode(struct linux_pbm_info
*pbm
,
439 struct pci_dev
*pdev
)
441 struct linux_prom_pci_registers regs
[PROMREG_MAX
];
443 int node
= prom_getchild(pbm
->prom_node
);
446 err
= prom_getproperty(node
, "reg",
447 (char *)®s
[0], sizeof(regs
));
448 if(err
!= 0 && err
!= -1) {
449 unsigned long devfn
= (regs
[0].which_io
>> 8) & 0xff;
450 if(devfn
== pdev
->devfn
)
453 node
= prom_getsibling(node
);
458 static inline struct pcidev_cookie
*pci_devcookie_alloc(void)
460 return kmalloc(sizeof(struct pcidev_cookie
), GFP_ATOMIC
);
463 static void pcic_map_pci_device(struct linux_pcic
*pcic
,
464 struct pci_dev
*dev
, int node
)
467 unsigned long address
;
471 if (node
== 0 || node
== -1) {
472 strcpy(namebuf
, "???");
474 prom_getstring(node
, "name", namebuf
, 63); namebuf
[63] = 0;
477 for (j
= 0; j
< 6; j
++) {
478 address
= dev
->resource
[j
].start
;
479 if (address
== 0) break; /* are sequential */
480 flags
= dev
->resource
[j
].flags
;
481 if ((flags
& IORESOURCE_IO
) != 0) {
482 if (address
< 0x10000) {
484 * A device responds to I/O cycles on PCI.
485 * We generate these cycles with memory
486 * access into the fixed map (phys 0x30000000).
488 * Since a device driver does not want to
489 * do ioremap() before accessing PC-style I/O,
490 * we supply virtual, ready to access address.
492 * Note that request_region()
493 * works for these devices.
495 * XXX Neat trick, but it's a *bad* idea
496 * to shit into regions like that.
497 * What if we want to allocate one more
498 * PCI base address...
500 dev
->resource
[j
].start
=
501 pcic
->pcic_io
+ address
;
502 dev
->resource
[j
].end
= 1; /* XXX */
503 dev
->resource
[j
].flags
=
504 (flags
& ~IORESOURCE_IO
) | IORESOURCE_MEM
;
507 * OOPS... PCI Spec allows this. Sun does
508 * not have any devices getting above 64K
509 * so it must be user with a weird I/O
510 * board in a PCI slot. We must remap it
511 * under 64K but it is not done yet. XXX
513 printk("PCIC: Skipping I/O space at 0x%lx, "
514 "this will Oops if a driver attaches "
515 "device '%s' at %02x:%02x)\n", address
,
516 namebuf
, dev
->bus
->number
, dev
->devfn
);
523 pcic_fill_irq(struct linux_pcic
*pcic
, struct pci_dev
*dev
, int node
)
525 struct pcic_ca2irq
*p
;
529 if (node
== 0 || node
== -1) {
530 strcpy(namebuf
, "???");
532 prom_getstring(node
, "name", namebuf
, sizeof(namebuf
));
535 if ((p
= pcic
->pcic_imap
) == 0) {
539 for (i
= 0; i
< pcic
->pcic_imdim
; i
++) {
540 if (p
->busno
== dev
->bus
->number
&& p
->devfn
== dev
->devfn
)
544 if (i
>= pcic
->pcic_imdim
) {
545 printk("PCIC: device %s devfn %02x:%02x not found in %d\n",
546 namebuf
, dev
->bus
->number
, dev
->devfn
, pcic
->pcic_imdim
);
552 if (i
>= 0 && i
< 4) {
553 ivec
= readw(pcic
->pcic_regs
+PCI_INT_SELECT_LO
);
554 dev
->irq
= ivec
>> (i
<< 2) & 0xF;
555 } else if (i
>= 4 && i
< 8) {
556 ivec
= readw(pcic
->pcic_regs
+PCI_INT_SELECT_HI
);
557 dev
->irq
= ivec
>> ((i
-4) << 2) & 0xF;
558 } else { /* Corrupted map */
559 printk("PCIC: BAD PIN %d\n", i
); for (;;) {}
561 /* P3 */ /* printk("PCIC: device %s pin %d ivec 0x%x irq %x\n", namebuf, i, ivec, dev->irq); */
564 * dev->irq=0 means PROM did not bother to program the upper
565 * half of PCIC. This happens on JS-E with PROM 3.11, for instance.
567 if (dev
->irq
== 0 || p
->force
) {
568 if (p
->irq
== 0 || p
->irq
>= 15) { /* Corrupted map */
569 printk("PCIC: BAD IRQ %d\n", p
->irq
); for (;;) {}
571 printk("PCIC: setting irq %d at pin %d for device %02x:%02x\n",
572 p
->irq
, p
->pin
, dev
->bus
->number
, dev
->devfn
);
577 ivec
= readw(pcic
->pcic_regs
+PCI_INT_SELECT_HI
);
578 ivec
&= ~(0xF << ((i
- 4) << 2));
579 ivec
|= p
->irq
<< ((i
- 4) << 2);
580 writew(ivec
, pcic
->pcic_regs
+PCI_INT_SELECT_HI
);
582 ivec
= readw(pcic
->pcic_regs
+PCI_INT_SELECT_LO
);
583 ivec
&= ~(0xF << (i
<< 2));
584 ivec
|= p
->irq
<< (i
<< 2);
585 writew(ivec
, pcic
->pcic_regs
+PCI_INT_SELECT_LO
);
593 * Normally called from {do_}pci_scan_bus...
595 void __devinit
pcibios_fixup_bus(struct pci_bus
*bus
)
598 int i
, has_io
, has_mem
;
600 struct linux_pcic
*pcic
;
601 /* struct linux_pbm_info* pbm = &pcic->pbm; */
603 struct pcidev_cookie
*pcp
;
606 printk("pcibios_fixup_bus: no PCIC\n");
612 * Next crud is an equivalent of pbm = pcic_bus_to_pbm(bus);
614 if (bus
->number
!= 0) {
615 printk("pcibios_fixup_bus: nonzero bus 0x%x\n", bus
->number
);
619 list_for_each_entry(dev
, &bus
->devices
, bus_list
) {
622 * Comment from i386 branch:
623 * There are buggy BIOSes that forget to enable I/O and memory
624 * access to PCI devices. We try to fix this, but we need to
625 * be sure that the BIOS didn't forget to assign an address
626 * to the device. [mj]
627 * OBP is a case of such BIOS :-)
629 has_io
= has_mem
= 0;
631 unsigned long f
= dev
->resource
[i
].flags
;
632 if (f
& IORESOURCE_IO
) {
634 } else if (f
& IORESOURCE_MEM
)
637 pcic_read_config(dev
->bus
, dev
->devfn
, PCI_COMMAND
, 2, &cmd
);
638 if (has_io
&& !(cmd
& PCI_COMMAND_IO
)) {
639 printk("PCIC: Enabling I/O for device %02x:%02x\n",
640 dev
->bus
->number
, dev
->devfn
);
641 cmd
|= PCI_COMMAND_IO
;
642 pcic_write_config(dev
->bus
, dev
->devfn
,
643 PCI_COMMAND
, 2, cmd
);
645 if (has_mem
&& !(cmd
& PCI_COMMAND_MEMORY
)) {
646 printk("PCIC: Enabling memory for device %02x:%02x\n",
647 dev
->bus
->number
, dev
->devfn
);
648 cmd
|= PCI_COMMAND_MEMORY
;
649 pcic_write_config(dev
->bus
, dev
->devfn
,
650 PCI_COMMAND
, 2, cmd
);
653 node
= pdev_to_pnode(&pcic
->pbm
, dev
);
658 pcp
= pci_devcookie_alloc();
659 pcp
->pbm
= &pcic
->pbm
;
660 pcp
->prom_node
= of_find_node_by_phandle(node
);
663 /* fixing I/O to look like memory */
664 if ((dev
->class>>16) != PCI_BASE_CLASS_BRIDGE
)
665 pcic_map_pci_device(pcic
, dev
, node
);
667 pcic_fill_irq(pcic
, dev
, node
);
672 * pcic_pin_to_irq() is exported to bus probing code
675 pcic_pin_to_irq(unsigned int pin
, const char *name
)
677 struct linux_pcic
*pcic
= &pcic0
;
682 ivec
= readw(pcic
->pcic_regs
+PCI_INT_SELECT_LO
);
683 irq
= ivec
>> (pin
<< 2) & 0xF;
684 } else if (pin
< 8) {
685 ivec
= readw(pcic
->pcic_regs
+PCI_INT_SELECT_HI
);
686 irq
= ivec
>> ((pin
-4) << 2) & 0xF;
687 } else { /* Corrupted map */
688 printk("PCIC: BAD PIN %d FOR %s\n", pin
, name
);
689 for (;;) {} /* XXX Cannot panic properly in case of PROLL */
691 /* P3 */ /* printk("PCIC: dev %s pin %d ivec 0x%x irq %x\n", name, pin, ivec, irq); */
695 /* Makes compiler happy */
696 static volatile int pcic_timer_dummy
;
698 static void pcic_clear_clock_irq(void)
700 pcic_timer_dummy
= readl(pcic0
.pcic_regs
+PCI_SYS_LIMIT
);
703 static irqreturn_t
pcic_timer_handler (int irq
, void *h
)
705 write_seqlock(&xtime_lock
); /* Dummy, to show that we remember */
706 pcic_clear_clock_irq();
708 write_sequnlock(&xtime_lock
);
710 update_process_times(user_mode(get_irq_regs()));
715 #define USECS_PER_JIFFY 10000 /* We have 100HZ "standard" timer for sparc */
716 #define TICK_TIMER_LIMIT ((100*1000000/4)/100)
718 u32
pci_gettimeoffset(void)
721 * We divide all by 100
722 * to have microsecond resolution and to avoid overflow
724 unsigned long count
=
725 readl(pcic0
.pcic_regs
+PCI_SYS_COUNTER
) & ~PCI_SYS_COUNTER_OVERFLOW
;
726 count
= ((count
/100)*USECS_PER_JIFFY
) / (TICK_TIMER_LIMIT
/100);
731 void __init
pci_time_init(void)
733 struct linux_pcic
*pcic
= &pcic0
;
737 do_arch_gettimeoffset
= pci_gettimeoffset
;
741 writel (TICK_TIMER_LIMIT
, pcic
->pcic_regs
+PCI_SYS_LIMIT
);
742 /* PROM should set appropriate irq */
743 v
= readb(pcic
->pcic_regs
+PCI_COUNTER_IRQ
);
744 timer_irq
= PCI_COUNTER_IRQ_SYS(v
);
745 writel (PCI_COUNTER_IRQ_SET(timer_irq
, 0),
746 pcic
->pcic_regs
+PCI_COUNTER_IRQ
);
747 irq
= request_irq(timer_irq
, pcic_timer_handler
,
748 (IRQF_DISABLED
| SA_STATIC_ALLOC
), "timer", NULL
);
750 prom_printf("time_init: unable to attach IRQ%d\n", timer_irq
);
758 static void watchdog_reset() {
759 writeb(0, pcic
->pcic_regs
+PCI_SYS_STATUS
);
764 * Other archs parse arguments here.
766 char * __devinit
pcibios_setup(char *str
)
771 resource_size_t
pcibios_align_resource(void *data
, const struct resource
*res
,
772 resource_size_t size
, resource_size_t align
)
777 int pcibios_enable_device(struct pci_dev
*pdev
, int mask
)
785 void pcic_nmi(unsigned int pend
, struct pt_regs
*regs
)
788 pend
= flip_dword(pend
);
790 if (!pcic_speculative
|| (pend
& PCI_SYS_INT_PENDING_PIO
) == 0) {
792 * XXX On CP-1200 PCI #SERR may happen, we do not know
793 * what to do about it yet.
795 printk("Aiee, NMI pend 0x%x pc 0x%x spec %d, hanging\n",
796 pend
, (int)regs
->pc
, pcic_speculative
);
799 pcic_speculative
= 0;
801 regs
->pc
= regs
->npc
;
805 static inline unsigned long get_irqmask(int irq_nr
)
810 static void pcic_disable_irq(unsigned int irq_nr
)
812 unsigned long mask
, flags
;
814 mask
= get_irqmask(irq_nr
);
815 local_irq_save(flags
);
816 writel(mask
, pcic0
.pcic_regs
+PCI_SYS_INT_TARGET_MASK_SET
);
817 local_irq_restore(flags
);
820 static void pcic_enable_irq(unsigned int irq_nr
)
822 unsigned long mask
, flags
;
824 mask
= get_irqmask(irq_nr
);
825 local_irq_save(flags
);
826 writel(mask
, pcic0
.pcic_regs
+PCI_SYS_INT_TARGET_MASK_CLEAR
);
827 local_irq_restore(flags
);
830 static void pcic_load_profile_irq(int cpu
, unsigned int limit
)
832 printk("PCIC: unimplemented code: FILE=%s LINE=%d", __FILE__
, __LINE__
);
835 /* We assume the caller has disabled local interrupts when these are called,
836 * or else very bizarre behavior will result.
838 static void pcic_disable_pil_irq(unsigned int pil
)
840 writel(get_irqmask(pil
), pcic0
.pcic_regs
+PCI_SYS_INT_TARGET_MASK_SET
);
843 static void pcic_enable_pil_irq(unsigned int pil
)
845 writel(get_irqmask(pil
), pcic0
.pcic_regs
+PCI_SYS_INT_TARGET_MASK_CLEAR
);
848 void __init
sun4m_pci_init_IRQ(void)
850 BTFIXUPSET_CALL(enable_irq
, pcic_enable_irq
, BTFIXUPCALL_NORM
);
851 BTFIXUPSET_CALL(disable_irq
, pcic_disable_irq
, BTFIXUPCALL_NORM
);
852 BTFIXUPSET_CALL(enable_pil_irq
, pcic_enable_pil_irq
, BTFIXUPCALL_NORM
);
853 BTFIXUPSET_CALL(disable_pil_irq
, pcic_disable_pil_irq
, BTFIXUPCALL_NORM
);
854 BTFIXUPSET_CALL(clear_clock_irq
, pcic_clear_clock_irq
, BTFIXUPCALL_NORM
);
855 BTFIXUPSET_CALL(load_profile_irq
, pcic_load_profile_irq
, BTFIXUPCALL_NORM
);
858 int pcibios_assign_resource(struct pci_dev
*pdev
, int resource
)
863 struct device_node
*pci_device_to_OF_node(struct pci_dev
*pdev
)
865 struct pcidev_cookie
*pc
= pdev
->sysdata
;
867 return pc
->prom_node
;
869 EXPORT_SYMBOL(pci_device_to_OF_node
);
872 * This probably belongs here rather than ioport.c because
873 * we do not want this crud linked into SBus kernels.
874 * Also, think for a moment about likes of floppy.c that
875 * include architecture specific parts. They may want to redefine ins/outs.
877 * We do not use horrible macros here because we want to
878 * advance pointer by sizeof(size).
880 void outsb(unsigned long addr
, const void *src
, unsigned long count
)
884 outb(*(const char *)src
, addr
);
889 EXPORT_SYMBOL(outsb
);
891 void outsw(unsigned long addr
, const void *src
, unsigned long count
)
895 outw(*(const short *)src
, addr
);
900 EXPORT_SYMBOL(outsw
);
902 void outsl(unsigned long addr
, const void *src
, unsigned long count
)
906 outl(*(const long *)src
, addr
);
911 EXPORT_SYMBOL(outsl
);
913 void insb(unsigned long addr
, void *dst
, unsigned long count
)
917 *(unsigned char *)dst
= inb(addr
);
924 void insw(unsigned long addr
, void *dst
, unsigned long count
)
928 *(unsigned short *)dst
= inw(addr
);
935 void insl(unsigned long addr
, void *dst
, unsigned long count
)
940 * XXX I am sure we are in for an unaligned trap here.
942 *(unsigned long *)dst
= inl(addr
);
949 subsys_initcall(pcic_init
);