1
2
3
4
5
6
7
8
9
10
11
12
13#include <linux/config.h>
14#include <linux/kernel.h>
15#include <linux/types.h>
16#include <linux/init.h>
17#include <linux/mm.h>
18#include <linux/slab.h>
19
20#include <asm/ebus.h>
21#include <asm/sbus.h>
22#include <asm/swift.h>
23#include <asm/io.h>
24
25#include <linux/ctype.h>
26#include <linux/pci.h>
27#include <linux/timex.h>
28#include <linux/interrupt.h>
29
30#include <asm/irq.h>
31#include <asm/oplib.h>
32#include <asm/pcic.h>
33#include <asm/timer.h>
34#include <asm/uaccess.h>
35
36#ifndef CONFIG_PCI
37
38asmlinkage int sys_pciconfig_read(unsigned long bus,
39 unsigned long dfn,
40 unsigned long off,
41 unsigned long len,
42 unsigned char *buf)
43{
44 return -EINVAL;
45}
46
47asmlinkage int sys_pciconfig_write(unsigned long bus,
48 unsigned long dfn,
49 unsigned long off,
50 unsigned long len,
51 unsigned char *buf)
52{
53 return -EINVAL;
54}
55
56#else
57
58#ifdef CONFIG_SUN_JSFLASH
59extern int jsflash_init(void);
60#endif
61
62struct pci_fixup pcibios_fixups[] = {
63 { 0 }
64};
65
66unsigned int pcic_pin_to_irq(unsigned int pin, char *name);
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83struct pcic_ca2irq {
84 unsigned char busno;
85 unsigned char devfn;
86 unsigned char pin;
87 unsigned char irq;
88 unsigned int force;
89};
90
91struct pcic_sn2list {
92 char *sysname;
93 struct pcic_ca2irq *intmap;
94 int mapdim;
95};
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116static struct pcic_ca2irq pcic_i_je1a[] = {
117 { 0, 0x00, 2, 12, 0 },
118 { 0, 0x01, 1, 6, 1 },
119 { 0, 0x80, 0, 7, 0 },
120};
121
122
123static struct pcic_ca2irq pcic_i_jse[] = {
124 { 0, 0x00, 0, 13, 0 },
125 { 0, 0x01, 1, 6, 0 },
126 { 0, 0x08, 2, 9, 0 },
127 { 0, 0x10, 6, 8, 0 },
128 { 0, 0x18, 7, 12, 0 },
129 { 0, 0x38, 4, 9, 0 },
130 { 0, 0x80, 5, 11, 0 },
131
132 { 0, 0xA0, 4, 9, 0 },
133
134
135
136
137
138
139
140};
141
142
143
144
145static struct pcic_ca2irq pcic_i_se6[] = {
146 { 0, 0x08, 0, 2, 0 },
147 { 0, 0x01, 1, 6, 0 },
148 { 0, 0x00, 3, 13, 0 },
149};
150
151
152
153
154
155
156
157
158
159
160
161
162
163static struct pcic_ca2irq pcic_i_jk[] = {
164 { 0, 0x00, 0, 13, 0 },
165 { 0, 0x01, 1, 6, 0 },
166};
167
168
169
170
171
172#define SN2L_INIT(name, map) \
173 { name, map, sizeof(map)/sizeof(struct pcic_ca2irq) }
174
175static struct pcic_sn2list pcic_known_sysnames[] = {
176 SN2L_INIT("SUNW,JavaEngine1", pcic_i_je1a),
177 SN2L_INIT("SUNW,JS-E", pcic_i_jse),
178 SN2L_INIT("SUNW,SPARCengine-6", pcic_i_se6),
179 SN2L_INIT("SUNW,JS-NC", pcic_i_jk),
180 SN2L_INIT("SUNW,JSIIep", pcic_i_jk),
181 { NULL, NULL, 0 }
182};
183
184
185
186
187
188static int pcic0_up;
189static struct linux_pcic pcic0;
190
191unsigned int pcic_regs;
192volatile int pcic_speculative;
193volatile int pcic_trapped;
194
195static void pci_do_gettimeofday(struct timeval *tv);
196static void pci_do_settimeofday(struct timeval *tv);
197
198#define CONFIG_CMD(bus, device_fn, where) (0x80000000 | (((unsigned int)bus) << 16) | (((unsigned int)device_fn) << 8) | (where & ~3))
199
200static int pcic_read_config_dword(struct pci_dev *dev, int where, u32 *value);
201static int pcic_write_config_dword(struct pci_dev *dev, int where, u32 value);
202
203static int pcic_read_config_byte(struct pci_dev *dev, int where, u8 *value)
204{
205 unsigned int v;
206
207 pcic_read_config_dword(dev, where&~3, &v);
208 *value = 0xff & (v >> (8*(where & 3)));
209 return PCIBIOS_SUCCESSFUL;
210}
211
212static int pcic_read_config_word(struct pci_dev *dev, int where, u16 *value)
213{
214 unsigned int v;
215 if (where&1) return PCIBIOS_BAD_REGISTER_NUMBER;
216
217 pcic_read_config_dword(dev, where&~3, &v);
218 *value = 0xffff & (v >> (8*(where & 3)));
219 return PCIBIOS_SUCCESSFUL;
220}
221
222static int pcic_read_config_dword(struct pci_dev *dev, int where, u32 *value)
223{
224 unsigned char bus = dev->bus->number;
225 unsigned char device_fn = dev->devfn;
226
227
228 struct linux_pcic *pcic;
229 unsigned long flags;
230
231 if (where&3) return PCIBIOS_BAD_REGISTER_NUMBER;
232 if (bus != 0) return PCIBIOS_DEVICE_NOT_FOUND;
233 pcic = &pcic0;
234
235 save_and_cli(flags);
236#if 0
237 pcic_speculative = 1;
238 pcic_trapped = 0;
239#endif
240 writel(CONFIG_CMD(bus,device_fn,where), pcic->pcic_config_space_addr);
241#if 0
242 nop();
243 if (pcic_trapped) {
244 restore_flags(flags);
245 *value = ~0;
246 return PCIBIOS_SUCCESSFUL;
247 }
248#endif
249 pcic_speculative = 2;
250 pcic_trapped = 0;
251 *value = readl(pcic->pcic_config_space_data + (where&4));
252 nop();
253 if (pcic_trapped) {
254 pcic_speculative = 0;
255 restore_flags(flags);
256 *value = ~0;
257 return PCIBIOS_SUCCESSFUL;
258 }
259 pcic_speculative = 0;
260 restore_flags(flags);
261 return PCIBIOS_SUCCESSFUL;
262}
263
264static int pcic_write_config_byte(struct pci_dev *dev, int where, u8 value)
265{
266 unsigned int v;
267
268 pcic_read_config_dword(dev, where&~3, &v);
269 v = (v & ~(0xff << (8*(where&3)))) |
270 ((0xff&(unsigned)value) << (8*(where&3)));
271 return pcic_write_config_dword(dev, where&~3, v);
272}
273
274static int pcic_write_config_word(struct pci_dev *dev, int where, u16 value)
275{
276 unsigned int v;
277
278 if (where&1) return PCIBIOS_BAD_REGISTER_NUMBER;
279 pcic_read_config_dword(dev, where&~3, &v);
280 v = (v & ~(0xffff << (8*(where&3)))) |
281 ((0xffff&(unsigned)value) << (8*(where&3)));
282 return pcic_write_config_dword(dev, where&~3, v);
283}
284
285static int pcic_write_config_dword(struct pci_dev *dev, int where, u32 value)
286{
287 unsigned char bus = dev->bus->number;
288 unsigned char devfn = dev->devfn;
289 struct linux_pcic *pcic;
290 unsigned long flags;
291
292 if (where&3) return PCIBIOS_BAD_REGISTER_NUMBER;
293 if (bus != 0) return PCIBIOS_DEVICE_NOT_FOUND;
294 pcic = &pcic0;
295
296 save_and_cli(flags);
297 writel(CONFIG_CMD(bus,devfn,where), pcic->pcic_config_space_addr);
298 writel(value, pcic->pcic_config_space_data + (where&4));
299 restore_flags(flags);
300 return PCIBIOS_SUCCESSFUL;
301}
302
303static struct pci_ops pcic_ops = {
304 pcic_read_config_byte,
305 pcic_read_config_word,
306 pcic_read_config_dword,
307 pcic_write_config_byte,
308 pcic_write_config_word,
309 pcic_write_config_dword,
310};
311
312
313
314
315
316
317int __init pcic_probe(void)
318{
319 struct linux_pcic *pcic;
320 struct linux_prom_registers regs[PROMREG_MAX];
321 struct linux_pbm_info* pbm;
322 char namebuf[64];
323 int node;
324 int err;
325
326 if (pcic0_up) {
327 prom_printf("PCIC: called twice!\n");
328 prom_halt();
329 }
330 pcic = &pcic0;
331
332 node = prom_getchild (prom_root_node);
333 node = prom_searchsiblings (node, "pci");
334 if (node == 0)
335 return -ENODEV;
336
337
338
339 err = prom_getproperty(node, "reg", (char*)regs, sizeof(regs));
340 if (err == 0 || err == -1) {
341 prom_printf("PCIC: Error, cannot get PCIC registers "
342 "from PROM.\n");
343 prom_halt();
344 }
345
346 pcic0_up = 1;
347
348 pcic->pcic_res_regs.name = "pcic_registers";
349 pcic->pcic_regs = (unsigned long)
350 ioremap(regs[0].phys_addr, regs[0].reg_size);
351 if (!pcic->pcic_regs) {
352 prom_printf("PCIC: Error, cannot map PCIC registers.\n");
353 prom_halt();
354 }
355
356 pcic->pcic_res_io.name = "pcic_io";
357 if ((pcic->pcic_io = (unsigned long)
358 ioremap(regs[1].phys_addr, 0x10000)) == 0) {
359 prom_printf("PCIC: Error, cannot map PCIC IO Base.\n");
360 prom_halt();
361 }
362
363 pcic->pcic_res_cfg_addr.name = "pcic_cfg_addr";
364 if ((pcic->pcic_config_space_addr = (unsigned long)
365 ioremap(regs[2].phys_addr, regs[2].reg_size * 2)) == 0) {
366 prom_printf("PCIC: Error, cannot map"
367 "PCI Configuration Space Address.\n");
368 prom_halt();
369 }
370
371
372
373
374
375 pcic->pcic_res_cfg_data.name = "pcic_cfg_data";
376 if ((pcic->pcic_config_space_data = (unsigned long)
377 ioremap(regs[3].phys_addr, regs[3].reg_size * 2)) == 0) {
378 prom_printf("PCIC: Error, cannot map"
379 "PCI Configuration Space Data.\n");
380 prom_halt();
381 }
382
383 pbm = &pcic->pbm;
384 pbm->prom_node = node;
385 prom_getstring(node, "name", namebuf, 63); namebuf[63] = 0;
386 strcpy(pbm->prom_name, namebuf);
387
388 {
389 extern volatile int t_nmi[1];
390 extern int pcic_nmi_trap_patch[1];
391
392 t_nmi[0] = pcic_nmi_trap_patch[0];
393 t_nmi[1] = pcic_nmi_trap_patch[1];
394 t_nmi[2] = pcic_nmi_trap_patch[2];
395 t_nmi[3] = pcic_nmi_trap_patch[3];
396 swift_flush_dcache();
397 pcic_regs = pcic->pcic_regs;
398 }
399
400 prom_getstring(prom_root_node, "name", namebuf, 63); namebuf[63] = 0;
401 {
402 struct pcic_sn2list *p;
403
404 for (p = pcic_known_sysnames; p->sysname != NULL; p++) {
405 if (strcmp(namebuf, p->sysname) == 0)
406 break;
407 }
408 pcic->pcic_imap = p->intmap;
409 pcic->pcic_imdim = p->mapdim;
410 }
411 if (pcic->pcic_imap == NULL) {
412
413
414
415 printk("PCIC: System %s is unknown, cannot route interrupts\n",
416 namebuf);
417 }
418
419 return 0;
420}
421
422static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic)
423{
424 struct linux_pbm_info *pbm = &pcic->pbm;
425
426 pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm);
427#if 0
428 pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node);
429 pci_record_assignments(pbm, pbm->pci_bus);
430 pci_assign_unassigned(pbm, pbm->pci_bus);
431 pci_fixup_irq(pbm, pbm->pci_bus);
432#endif
433}
434
435
436
437
438void __init pcibios_init(void)
439{
440 struct linux_pcic *pcic;
441
442
443
444
445
446 if(!pcic0_up)
447 return;
448 pcic = &pcic0;
449
450
451
452
453 writeb(PCI_DVMA_CONTROL_IOTLB_DISABLE,
454 pcic->pcic_regs+PCI_DVMA_CONTROL);
455
456
457
458
459
460
461 writel(0xF0000000UL, pcic->pcic_regs+PCI_SIZE_0);
462 writel(0+PCI_BASE_ADDRESS_SPACE_MEMORY,
463 pcic->pcic_regs+PCI_BASE_ADDRESS_0);
464
465 pcic_pbm_scan_bus(pcic);
466
467 ebus_init();
468#ifdef CONFIG_SUN_JSFLASH
469 jsflash_init();
470#endif
471}
472
473int pcic_present(void)
474{
475 return pcic0_up;
476}
477
478static int __init pdev_to_pnode(struct linux_pbm_info *pbm,
479 struct pci_dev *pdev)
480{
481 struct linux_prom_pci_registers regs[PROMREG_MAX];
482 int err;
483 int node = prom_getchild(pbm->prom_node);
484
485 while(node) {
486 err = prom_getproperty(node, "reg",
487 (char *)®s[0], sizeof(regs));
488 if(err != 0 && err != -1) {
489 unsigned long devfn = (regs[0].which_io >> 8) & 0xff;
490 if(devfn == pdev->devfn)
491 return node;
492 }
493 node = prom_getsibling(node);
494 }
495 return 0;
496}
497
498static inline struct pcidev_cookie *pci_devcookie_alloc(void)
499{
500 return kmalloc(sizeof(struct pcidev_cookie), GFP_ATOMIC);
501}
502
503static void pcic_map_pci_device(struct linux_pcic *pcic,
504 struct pci_dev *dev, int node)
505{
506 char namebuf[64];
507 unsigned long address;
508 unsigned long flags;
509 int j;
510
511 if (node == 0 || node == -1) {
512 strcpy(namebuf, "???");
513 } else {
514 prom_getstring(node, "name", namebuf, 63); namebuf[63] = 0;
515 }
516
517 for (j = 0; j < 6; j++) {
518 address = dev->resource[j].start;
519 if (address == 0) break;
520 flags = dev->resource[j].flags;
521 if ((flags & IORESOURCE_IO) != 0) {
522 if (address < 0x10000) {
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544 dev->resource[j].start =
545 pcic->pcic_io + address;
546 dev->resource[j].end = 1;
547 dev->resource[j].flags =
548 (flags & ~IORESOURCE_IO) | IORESOURCE_MEM;
549 } else {
550
551
552
553
554
555
556
557 printk("PCIC: Skipping I/O space at 0x%lx,"
558 "this will Oops if a driver attaches;"
559 "device '%s' at %02x:%02x)\n", address,
560 namebuf, dev->bus->number, dev->devfn);
561 }
562 }
563 }
564}
565
566static void
567pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node)
568{
569 struct pcic_ca2irq *p;
570 int i, ivec;
571 char namebuf[64];
572
573 if (node == 0 || node == -1) {
574 strcpy(namebuf, "???");
575 } else {
576 prom_getstring(node, "name", namebuf, sizeof(namebuf));
577 }
578
579 if ((p = pcic->pcic_imap) == 0) {
580 dev->irq = 0;
581 return;
582 }
583 for (i = 0; i < pcic->pcic_imdim; i++) {
584 if (p->busno == dev->bus->number && p->devfn == dev->devfn)
585 break;
586 p++;
587 }
588 if (i >= pcic->pcic_imdim) {
589 printk("PCIC: device %s devfn %02x:%02x not found in %d\n",
590 namebuf, dev->bus->number, dev->devfn, pcic->pcic_imdim);
591 dev->irq = 0;
592 return;
593 }
594
595 i = p->pin;
596 if (i >= 0 && i < 4) {
597 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_LO);
598 dev->irq = ivec >> (i << 2) & 0xF;
599 } else if (i >= 4 && i < 8) {
600 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI);
601 dev->irq = ivec >> ((i-4) << 2) & 0xF;
602 } else {
603 printk("PCIC: BAD PIN %d\n", i); for (;;) {}
604 }
605
606
607
608
609
610
611 if (dev->irq == 0 || p->force) {
612 if (p->irq == 0 || p->irq >= 15) {
613 printk("PCIC: BAD IRQ %d\n", p->irq); for (;;) {}
614 }
615 printk("PCIC: setting irq %d at pin %d for device %02x:%02x\n",
616 p->irq, p->pin, dev->bus->number, dev->devfn);
617 dev->irq = p->irq;
618
619 i = p->pin;
620 if (i >= 4) {
621 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI);
622 ivec &= ~(0xF << ((i - 4) << 2));
623 ivec |= p->irq << ((i - 4) << 2);
624 writew(ivec, pcic->pcic_regs+PCI_INT_SELECT_HI);
625 } else {
626 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_LO);
627 ivec &= ~(0xF << (i << 2));
628 ivec |= p->irq << (i << 2);
629 writew(ivec, pcic->pcic_regs+PCI_INT_SELECT_LO);
630 }
631 }
632
633 return;
634}
635
636
637
638
639void __init pcibios_fixup_bus(struct pci_bus *bus)
640{
641 struct list_head *walk;
642 int i, has_io, has_mem;
643 unsigned short cmd;
644 struct linux_pcic *pcic;
645
646 int node;
647 struct pcidev_cookie *pcp;
648
649 if (!pcic0_up) {
650 printk("pcibios_fixup_bus: no PCIC\n");
651 return;
652 }
653 pcic = &pcic0;
654
655
656
657
658 if (bus->number != 0) {
659 printk("pcibios_fixup_bus: nonzero bus 0x%x\n", bus->number);
660 return;
661 }
662
663 walk = &bus->devices;
664 for (walk = walk->next; walk != &bus->devices; walk = walk->next) {
665 struct pci_dev *dev = pci_dev_b(walk);
666
667
668
669
670
671
672
673
674
675 has_io = has_mem = 0;
676 for(i=0; i<6; i++) {
677 unsigned long f = dev->resource[i].flags;
678 if (f & IORESOURCE_IO) {
679 has_io = 1;
680 } else if (f & IORESOURCE_MEM)
681 has_mem = 1;
682 }
683 pcic_read_config_word(dev, PCI_COMMAND, &cmd);
684 if (has_io && !(cmd & PCI_COMMAND_IO)) {
685 printk("PCIC: Enabling I/O for device %02x:%02x\n",
686 dev->bus->number, dev->devfn);
687 cmd |= PCI_COMMAND_IO;
688 pcic_write_config_word(dev, PCI_COMMAND, cmd);
689 }
690 if (has_mem && !(cmd & PCI_COMMAND_MEMORY)) {
691 printk("PCIC: Enabling memory for device %02x:%02x\n",
692 dev->bus->number, dev->devfn);
693 cmd |= PCI_COMMAND_MEMORY;
694 pcic_write_config_word(dev, PCI_COMMAND, cmd);
695 }
696
697 node = pdev_to_pnode(&pcic->pbm, dev);
698 if(node == 0)
699 node = -1;
700
701
702 pcp = pci_devcookie_alloc();
703 pcp->pbm = &pcic->pbm;
704 pcp->prom_node = node;
705 dev->sysdata = pcp;
706
707
708 if ((dev->class>>16) != PCI_BASE_CLASS_BRIDGE)
709 pcic_map_pci_device(pcic, dev, node);
710
711 pcic_fill_irq(pcic, dev, node);
712 }
713}
714
715
716
717
718unsigned int
719pcic_pin_to_irq(unsigned int pin, char *name)
720{
721 struct linux_pcic *pcic = &pcic0;
722 unsigned int irq;
723 unsigned int ivec;
724
725 if (pin < 4) {
726 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_LO);
727 irq = ivec >> (pin << 2) & 0xF;
728 } else if (pin < 8) {
729 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI);
730 irq = ivec >> ((pin-4) << 2) & 0xF;
731 } else {
732 printk("PCIC: BAD PIN %d FOR %s\n", pin, name);
733 for (;;) {}
734 }
735
736 return irq;
737}
738
739
740static volatile int pcic_timer_dummy;
741
742static void pcic_clear_clock_irq(void)
743{
744 pcic_timer_dummy = readl(pcic0.pcic_regs+PCI_SYS_LIMIT);
745}
746
747static void pcic_timer_handler (int irq, void *h, struct pt_regs *regs)
748{
749 pcic_clear_clock_irq();
750 do_timer(regs);
751}
752
753#define USECS_PER_JIFFY 10000
754#define TICK_TIMER_LIMIT ((100*1000000/4)/100)
755
756void __init pci_time_init(void)
757{
758 struct linux_pcic *pcic = &pcic0;
759 unsigned long v;
760 int timer_irq, irq;
761
762
763
764 ((unsigned int *)do_gettimeofday)[0] =
765 0x10800000 | ((((unsigned long)pci_do_gettimeofday -
766 (unsigned long)do_gettimeofday) >> 2) & 0x003fffff);
767 ((unsigned int *)do_gettimeofday)[1] = 0x01000000;
768 BTFIXUPSET_CALL(bus_do_settimeofday, pci_do_settimeofday, BTFIXUPCALL_NORM);
769 btfixup();
770
771 writel (TICK_TIMER_LIMIT, pcic->pcic_regs+PCI_SYS_LIMIT);
772
773 v = readb(pcic->pcic_regs+PCI_COUNTER_IRQ);
774 timer_irq = PCI_COUNTER_IRQ_SYS(v);
775 writel (PCI_COUNTER_IRQ_SET(timer_irq, 0),
776 pcic->pcic_regs+PCI_COUNTER_IRQ);
777 irq = request_irq(timer_irq, pcic_timer_handler,
778 (SA_INTERRUPT | SA_STATIC_ALLOC), "timer", NULL);
779 if (irq) {
780 prom_printf("time_init: unable to attach IRQ%d\n", timer_irq);
781 prom_halt();
782 }
783 __sti();
784}
785
786static __inline__ unsigned long do_gettimeoffset(void)
787{
788 struct tasklet_struct *t;
789 unsigned long offset = 0;
790
791
792
793
794
795 unsigned long count =
796 readl(pcic0.pcic_regs+PCI_SYS_COUNTER) & ~PCI_SYS_COUNTER_OVERFLOW;
797 count = ((count/100)*USECS_PER_JIFFY) / (TICK_TIMER_LIMIT/100);
798
799 t = &bh_task_vec[TIMER_BH];
800 if (test_bit(TASKLET_STATE_SCHED, &t->state))
801 offset = 1000000;
802 return offset + count;
803}
804
805extern volatile unsigned long wall_jiffies;
806
807static void pci_do_gettimeofday(struct timeval *tv)
808{
809 unsigned long flags;
810
811 save_and_cli(flags);
812 *tv = xtime;
813 tv->tv_usec += do_gettimeoffset();
814
815
816
817
818
819
820 if ((jiffies - wall_jiffies) != 0)
821 tv->tv_usec += USECS_PER_JIFFY;
822
823 restore_flags(flags);
824
825 if (tv->tv_usec >= 1000000) {
826 tv->tv_usec -= 1000000;
827 tv->tv_sec++;
828 }
829}
830
831static void pci_do_settimeofday(struct timeval *tv)
832{
833 cli();
834 tv->tv_usec -= do_gettimeoffset();
835 if(tv->tv_usec < 0) {
836 tv->tv_usec += 1000000;
837 tv->tv_sec--;
838 }
839 xtime = *tv;
840 time_adjust = 0;
841 time_status |= STA_UNSYNC;
842 time_maxerror = NTP_PHASE_LIMIT;
843 time_esterror = NTP_PHASE_LIMIT;
844 sti();
845}
846
847#if 0
848static void watchdog_reset() {
849 writeb(0, pcic->pcic_regs+PCI_SYS_STATUS);
850}
851#endif
852
853
854
855
856char * __init pcibios_setup(char *str)
857{
858 return str;
859}
860
861
862
863void pcibios_update_resource(struct pci_dev *pdev, struct resource *res1,
864 struct resource *res2, int index)
865{
866}
867
868void pcibios_align_resource(void *data, struct resource *res,
869 unsigned long size, unsigned long align)
870{
871}
872
873int pcibios_enable_device(struct pci_dev *pdev, int mask)
874{
875 return 0;
876}
877
878
879
880
881void pcic_nmi(unsigned int pend, struct pt_regs *regs)
882{
883
884 pend = flip_dword(pend);
885
886 if (!pcic_speculative || (pend & PCI_SYS_INT_PENDING_PIO) == 0) {
887
888
889
890
891 printk("Aiee, NMI pend 0x%x pc 0x%x spec %d, hanging\n",
892 pend, (int)regs->pc, pcic_speculative);
893 for (;;) { }
894 }
895 pcic_speculative = 0;
896 pcic_trapped = 1;
897 regs->pc = regs->npc;
898 regs->npc += 4;
899}
900
901static inline unsigned long get_irqmask(int irq_nr)
902{
903 return 1 << irq_nr;
904}
905
906static inline char *pcic_irq_itoa(unsigned int irq)
907{
908 static char buff[16];
909 sprintf(buff, "%d", irq);
910 return buff;
911}
912
913static void pcic_disable_irq(unsigned int irq_nr)
914{
915 unsigned long mask, flags;
916
917 mask = get_irqmask(irq_nr);
918 save_and_cli(flags);
919 writel(mask, pcic0.pcic_regs+PCI_SYS_INT_TARGET_MASK_SET);
920 restore_flags(flags);
921}
922
923static void pcic_enable_irq(unsigned int irq_nr)
924{
925 unsigned long mask, flags;
926
927 mask = get_irqmask(irq_nr);
928 save_and_cli(flags);
929 writel(mask, pcic0.pcic_regs+PCI_SYS_INT_TARGET_MASK_CLEAR);
930 restore_flags(flags);
931}
932
933static void pcic_clear_profile_irq(int cpu)
934{
935 printk("PCIC: unimplemented code: FILE=%s LINE=%d", __FILE__, __LINE__);
936}
937
938static void pcic_load_profile_irq(int cpu, unsigned int limit)
939{
940 printk("PCIC: unimplemented code: FILE=%s LINE=%d", __FILE__, __LINE__);
941}
942
943
944
945
946static void pcic_disable_pil_irq(unsigned int pil)
947{
948 writel(get_irqmask(pil), pcic0.pcic_regs+PCI_SYS_INT_TARGET_MASK_SET);
949}
950
951static void pcic_enable_pil_irq(unsigned int pil)
952{
953 writel(get_irqmask(pil), pcic0.pcic_regs+PCI_SYS_INT_TARGET_MASK_CLEAR);
954}
955
956void __init sun4m_pci_init_IRQ(void)
957{
958 BTFIXUPSET_CALL(enable_irq, pcic_enable_irq, BTFIXUPCALL_NORM);
959 BTFIXUPSET_CALL(disable_irq, pcic_disable_irq, BTFIXUPCALL_NORM);
960 BTFIXUPSET_CALL(enable_pil_irq, pcic_enable_pil_irq, BTFIXUPCALL_NORM);
961 BTFIXUPSET_CALL(disable_pil_irq, pcic_disable_pil_irq, BTFIXUPCALL_NORM);
962 BTFIXUPSET_CALL(clear_clock_irq, pcic_clear_clock_irq, BTFIXUPCALL_NORM);
963 BTFIXUPSET_CALL(clear_profile_irq, pcic_clear_profile_irq, BTFIXUPCALL_NORM);
964 BTFIXUPSET_CALL(load_profile_irq, pcic_load_profile_irq, BTFIXUPCALL_NORM);
965 BTFIXUPSET_CALL(__irq_itoa, pcic_irq_itoa, BTFIXUPCALL_NORM);
966}
967
968int pcibios_assign_resource(struct pci_dev *pdev, int resource)
969{
970 return -ENXIO;
971}
972
973
974
975
976
977
978
979
980
981
982void outsb(unsigned long addr, const void *src, unsigned long count) {
983 while (count) {
984 count -= 1;
985 writeb(*(const char *)src, addr);
986 src += 1;
987 addr += 1;
988 }
989}
990
991void outsw(unsigned long addr, const void *src, unsigned long count) {
992 while (count) {
993 count -= 2;
994 writew(*(const short *)src, addr);
995 src += 2;
996 addr += 2;
997 }
998}
999
1000void outsl(unsigned long addr, const void *src, unsigned long count) {
1001 while (count) {
1002 count -= 4;
1003 writel(*(const long *)src, addr);
1004 src += 4;
1005 addr += 4;
1006 }
1007}
1008
1009void insb(unsigned long addr, void *dst, unsigned long count) {
1010 while (count) {
1011 count -= 1;
1012 *(unsigned char *)dst = readb(addr);
1013 dst += 1;
1014 addr += 1;
1015 }
1016}
1017
1018void insw(unsigned long addr, void *dst, unsigned long count) {
1019 while (count) {
1020 count -= 2;
1021 *(unsigned short *)dst = readw(addr);
1022 dst += 2;
1023 addr += 2;
1024 }
1025}
1026
1027void insl(unsigned long addr, void *dst, unsigned long count) {
1028 while (count) {
1029 count -= 4;
1030
1031
1032
1033 *(unsigned long *)dst = readl(addr);
1034 dst += 4;
1035 addr += 4;
1036 }
1037}
1038
1039#endif
1040