Lines Matching +full:pin +full:- +full:count

1 // SPDX-License-Identifier: GPL-2.0
3 * pcic.c: MicroSPARC-IIep PCI controller support
11 * CP-1200 by Eric Brower.
49 * schematics. And this actually sucks. -- zaitcev 1999/05/12
56 * find PCIC pin number where INT line goes. Then we may either program
62 unsigned char pin; /* PCIC external interrupt pin */ member
74 * JavaEngine-1 apparently has different versions.
76 * According to communications with Sun folks, for P2 build 501-4628-03:
77 * pin 0 - parallel, audio;
78 * pin 1 - Ethernet;
79 * pin 2 - su;
80 * pin 3 - PS/2 kbd and mouse.
82 * OEM manual (805-1486):
83 * pin 0: Ethernet
84 * pin 1: All EBus
85 * pin 2: IGA (unused)
86 * pin 3: Not connected
87 * OEM manual says that 501-4628 & 501-4811 are the same thing,
92 static struct pcic_ca2irq pcic_i_je1a[] = { /* 501-4811-03 */
98 /* XXX JS-E entry is incomplete - PCI Slot 2 address (pin 7)? */
100 { 0, 0x00, 0, 13, 0 }, /* Ebus - serial and keyboard */
102 { 0, 0x08, 2, 9, 0 }, /* VGA - we hope not used :) */
107 /* {0,0x88, 0,0,0} - unknown device... PMU? Probably no interrupt. */
110 * Some pins belong to non-PCI devices, we hardcode them in drivers.
111 * sun4m timers - irq 10, 14
112 * PC style RTC - pin 7, irq 4 ?
113 * Smart card, Parallel - pin 4 shared with USB, ISA
114 * audio - pin 3, irq 5 ?
118 /* SPARCengine-6 was the original release name of CP1200.
132 * pin 0 - kbd, mouse, serial;
133 * pin 1 - Ethernet;
134 * pin 2 - igs (we do not use it);
135 * pin 3 - audio;
136 * pin 4,5,6 - unused;
137 * pin 7 - RTC (from P2 onwards as David B. says).
140 { 0, 0x00, 0, 13, 0 }, /* Ebus - serial and keyboard */
153 SN2L_INIT("SUNW,JS-E", pcic_i_jse), /* PROLL JavaStation-E */
154 SN2L_INIT("SUNW,SPARCengine-6", pcic_i_se6), /* SPARCengine-6/CP-1200 */
155 SN2L_INIT("SUNW,JS-NC", pcic_i_jk), /* PROLL JavaStation-NC */
156 SN2L_INIT("SUNW,JSIIep", pcic_i_jk), /* OBP JavaStation-NC */
190 writel(CONFIG_CMD(busno, devfn, where), pcic->pcic_config_space_addr); in pcic_read_config_dword()
201 *value = readl(pcic->pcic_config_space_data + (where&4)); in pcic_read_config_dword()
219 if (bus->number != 0) return -EINVAL; in pcic_read_config()
222 pcic_read_config_dword(bus->number, devfn, where&~3, &v); in pcic_read_config()
226 if (where&1) return -EINVAL; in pcic_read_config()
227 pcic_read_config_dword(bus->number, devfn, where&~3, &v); in pcic_read_config()
231 if (where&3) return -EINVAL; in pcic_read_config()
232 pcic_read_config_dword(bus->number, devfn, where&~3, val); in pcic_read_config()
235 return -EINVAL; in pcic_read_config()
247 writel(CONFIG_CMD(busno, devfn, where), pcic->pcic_config_space_addr); in pcic_write_config_dword()
248 writel(value, pcic->pcic_config_space_data + (where&4)); in pcic_write_config_dword()
258 if (bus->number != 0) return -EINVAL; in pcic_write_config()
261 pcic_read_config_dword(bus->number, devfn, where&~3, &v); in pcic_write_config()
264 return pcic_write_config_dword(bus->number, devfn, where&~3, v); in pcic_write_config()
266 if (where&1) return -EINVAL; in pcic_write_config()
267 pcic_read_config_dword(bus->number, devfn, where&~3, &v); in pcic_write_config()
270 return pcic_write_config_dword(bus->number, devfn, where&~3, v); in pcic_write_config()
272 if (where&3) return -EINVAL; in pcic_write_config()
273 return pcic_write_config_dword(bus->number, devfn, where, val); in pcic_write_config()
275 return -EINVAL; in pcic_write_config()
306 return -ENODEV; in pcic_probe()
311 if (err == 0 || err == -1) { in pcic_probe()
319 pcic->pcic_res_regs.name = "pcic_registers"; in pcic_probe()
320 pcic->pcic_regs = ioremap(regs[0].phys_addr, regs[0].reg_size); in pcic_probe()
321 if (!pcic->pcic_regs) { in pcic_probe()
326 pcic->pcic_res_io.name = "pcic_io"; in pcic_probe()
327 if ((pcic->pcic_io = (unsigned long) in pcic_probe()
333 pcic->pcic_res_cfg_addr.name = "pcic_cfg_addr"; in pcic_probe()
334 if ((pcic->pcic_config_space_addr = in pcic_probe()
345 pcic->pcic_res_cfg_data.name = "pcic_cfg_data"; in pcic_probe()
346 if ((pcic->pcic_config_space_data = in pcic_probe()
353 pbm = &pcic->pbm; in pcic_probe()
354 pbm->prom_node = node; in pcic_probe()
356 strscpy(pbm->prom_name, namebuf); in pcic_probe()
366 pcic_regs = pcic->pcic_regs; in pcic_probe()
373 for (p = pcic_known_sysnames; p->sysname != NULL; p++) { in pcic_probe()
374 if (strcmp(namebuf, p->sysname) == 0) in pcic_probe()
377 pcic->pcic_imap = p->intmap; in pcic_probe()
378 pcic->pcic_imdim = p->mapdim; in pcic_probe()
380 if (pcic->pcic_imap == NULL) { in pcic_probe()
393 struct linux_pbm_info *pbm = &pcic->pbm; in pcic_pbm_scan_bus()
395 pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm); in pcic_pbm_scan_bus()
396 if (!pbm->pci_bus) in pcic_pbm_scan_bus()
400 pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node); in pcic_pbm_scan_bus()
401 pci_record_assignments(pbm, pbm->pci_bus); in pcic_pbm_scan_bus()
402 pci_assign_unassigned(pbm, pbm->pci_bus); in pcic_pbm_scan_bus()
403 pci_fixup_irq(pbm, pbm->pci_bus); in pcic_pbm_scan_bus()
405 pci_bus_add_devices(pbm->pci_bus); in pcic_pbm_scan_bus()
427 pcic->pcic_regs+PCI_DVMA_CONTROL); in pcic_init()
434 writel(0xF0000000UL, pcic->pcic_regs+PCI_SIZE_0); in pcic_init()
436 pcic->pcic_regs+PCI_BASE_ADDRESS_0); in pcic_init()
452 phandle node = prom_getchild(pbm->prom_node); in pdev_to_pnode()
457 if(err != 0 && err != -1) { in pdev_to_pnode()
459 if(devfn == pdev->devfn) in pdev_to_pnode()
480 if (node == 0 || node == -1) { in pcic_map_pci_device()
487 address = dev->resource[j].start; in pcic_map_pci_device()
489 flags = dev->resource[j].flags; in pcic_map_pci_device()
498 * do ioremap() before accessing PC-style I/O, in pcic_map_pci_device()
509 dev->resource[j].start = in pcic_map_pci_device()
510 pcic->pcic_io + address; in pcic_map_pci_device()
511 dev->resource[j].end = 1; /* XXX */ in pcic_map_pci_device()
512 dev->resource[j].flags = in pcic_map_pci_device()
539 if (node == 0 || node == -1) { in pcic_fill_irq()
545 if ((p = pcic->pcic_imap) == NULL) { in pcic_fill_irq()
546 dev->irq = 0; in pcic_fill_irq()
549 for (i = 0; i < pcic->pcic_imdim; i++) { in pcic_fill_irq()
550 if (p->busno == dev->bus->number && p->devfn == dev->devfn) in pcic_fill_irq()
554 if (i >= pcic->pcic_imdim) { in pcic_fill_irq()
556 pcic->pcic_imdim); in pcic_fill_irq()
557 dev->irq = 0; in pcic_fill_irq()
561 i = p->pin; in pcic_fill_irq()
563 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_LO); in pcic_fill_irq()
566 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI); in pcic_fill_irq()
567 real_irq = ivec >> ((i-4) << 2) & 0xF; in pcic_fill_irq()
569 pci_info(dev, "PCIC: BAD PIN %d\n", i); for (;;) {} in pcic_fill_irq()
571 /* P3 */ /* printk("PCIC: device %s pin %d ivec 0x%x irq %x\n", namebuf, i, ivec, dev->irq); */ in pcic_fill_irq()
574 * half of PCIC. This happens on JS-E with PROM 3.11, for instance. in pcic_fill_irq()
576 if (real_irq == 0 || p->force) { in pcic_fill_irq()
577 if (p->irq == 0 || p->irq >= 15) { /* Corrupted map */ in pcic_fill_irq()
578 pci_info(dev, "PCIC: BAD IRQ %d\n", p->irq); for (;;) {} in pcic_fill_irq()
580 pci_info(dev, "PCIC: setting irq %d at pin %d\n", p->irq, in pcic_fill_irq()
581 p->pin); in pcic_fill_irq()
582 real_irq = p->irq; in pcic_fill_irq()
584 i = p->pin; in pcic_fill_irq()
586 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI); in pcic_fill_irq()
587 ivec &= ~(0xF << ((i - 4) << 2)); in pcic_fill_irq()
588 ivec |= p->irq << ((i - 4) << 2); in pcic_fill_irq()
589 writew(ivec, pcic->pcic_regs+PCI_INT_SELECT_HI); in pcic_fill_irq()
591 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_LO); in pcic_fill_irq()
593 ivec |= p->irq << (i << 2); in pcic_fill_irq()
594 writew(ivec, pcic->pcic_regs+PCI_INT_SELECT_LO); in pcic_fill_irq()
597 dev->irq = pcic_build_device_irq(NULL, real_irq); in pcic_fill_irq()
607 /* struct linux_pbm_info* pbm = &pcic->pbm; */ in pcibios_fixup_bus()
620 if (bus->number != 0) { in pcibios_fixup_bus()
622 bus->number); in pcibios_fixup_bus()
626 list_for_each_entry(dev, &bus->devices, bus_list) { in pcibios_fixup_bus()
627 node = pdev_to_pnode(&pcic->pbm, dev); in pcibios_fixup_bus()
629 node = -1; in pcibios_fixup_bus()
633 pcp->pbm = &pcic->pbm; in pcibios_fixup_bus()
634 pcp->prom_node = of_find_node_by_phandle(node); in pcibios_fixup_bus()
635 dev->sysdata = pcp; in pcibios_fixup_bus()
638 if ((dev->class>>16) != PCI_BASE_CLASS_BRIDGE) in pcibios_fixup_bus()
659 u32 value, count; in pcic_cycles_offset() local
662 count = value & ~PCI_SYS_COUNTER_OVERFLOW; in pcic_cycles_offset()
665 count += TICK_TIMER_LIMIT; in pcic_cycles_offset()
670 count = ((count / HZ) * USECS_PER_JIFFY) / (TICK_TIMER_LIMIT / HZ); in pcic_cycles_offset()
673 return count * 2; in pcic_cycles_offset()
694 writel (TICK_TIMER_LIMIT, pcic->pcic_regs+PCI_SYS_LIMIT); in pci_time_init()
696 v = readb(pcic->pcic_regs+PCI_COUNTER_IRQ); in pci_time_init()
699 pcic->pcic_regs+PCI_COUNTER_IRQ); in pci_time_init()
713 writeb(0, pcic->pcic_regs+PCI_SYS_STATUS);
726 * XXX On CP-1200 PCI #SERR may happen, we do not know in pcic_nmi()
730 pend, (int)regs->pc, pcic_speculative); in pcic_nmi()
735 regs->pc = regs->npc; in pcic_nmi()
736 regs->npc += 4; in pcic_nmi()
748 mask = (unsigned long)data->chip_data; in pcic_mask_irq()
758 mask = (unsigned long)data->chip_data; in pcic_unmask_irq()
766 irq_link(data->irq); in pcic_startup_irq()