Lines Matching +full:nand +full:- +full:style

1 // SPDX-License-Identifier: GPL-2.0
3 * pcic.c: MicroSPARC-IIep PCI controller support
11 * CP-1200 by Eric Brower.
48 * schematics. And this actually sucks. -- zaitcev 1999/05/12
73 * JavaEngine-1 apparently has different versions.
75 * According to communications with Sun folks, for P2 build 501-4628-03:
76 * pin 0 - parallel, audio;
77 * pin 1 - Ethernet;
78 * pin 2 - su;
79 * pin 3 - PS/2 kbd and mouse.
81 * OEM manual (805-1486):
86 * OEM manual says that 501-4628 & 501-4811 are the same thing,
87 * only the latter has NAND flash in place.
91 static struct pcic_ca2irq pcic_i_je1a[] = { /* 501-4811-03 */
97 /* XXX JS-E entry is incomplete - PCI Slot 2 address (pin 7)? */
99 { 0, 0x00, 0, 13, 0 }, /* Ebus - serial and keyboard */
101 { 0, 0x08, 2, 9, 0 }, /* VGA - we hope not used :) */
106 /* {0,0x88, 0,0,0} - unknown device... PMU? Probably no interrupt. */
109 * Some pins belong to non-PCI devices, we hardcode them in drivers.
110 * sun4m timers - irq 10, 14
111 * PC style RTC - pin 7, irq 4 ?
112 * Smart card, Parallel - pin 4 shared with USB, ISA
113 * audio - pin 3, irq 5 ?
117 /* SPARCengine-6 was the original release name of CP1200.
131 * pin 0 - kbd, mouse, serial;
132 * pin 1 - Ethernet;
133 * pin 2 - igs (we do not use it);
134 * pin 3 - audio;
135 * pin 4,5,6 - unused;
136 * pin 7 - RTC (from P2 onwards as David B. says).
139 { 0, 0x00, 0, 13, 0 }, /* Ebus - serial and keyboard */
152 SN2L_INIT("SUNW,JS-E", pcic_i_jse), /* PROLL JavaStation-E */
153 SN2L_INIT("SUNW,SPARCengine-6", pcic_i_se6), /* SPARCengine-6/CP-1200 */
154 SN2L_INIT("SUNW,JS-NC", pcic_i_jk), /* PROLL JavaStation-NC */
155 SN2L_INIT("SUNW,JSIIep", pcic_i_jk), /* OBP JavaStation-NC */
189 writel(CONFIG_CMD(busno, devfn, where), pcic->pcic_config_space_addr); in pcic_read_config_dword()
200 *value = readl(pcic->pcic_config_space_data + (where&4)); in pcic_read_config_dword()
218 if (bus->number != 0) return -EINVAL; in pcic_read_config()
221 pcic_read_config_dword(bus->number, devfn, where&~3, &v); in pcic_read_config()
225 if (where&1) return -EINVAL; in pcic_read_config()
226 pcic_read_config_dword(bus->number, devfn, where&~3, &v); in pcic_read_config()
230 if (where&3) return -EINVAL; in pcic_read_config()
231 pcic_read_config_dword(bus->number, devfn, where&~3, val); in pcic_read_config()
234 return -EINVAL; in pcic_read_config()
246 writel(CONFIG_CMD(busno, devfn, where), pcic->pcic_config_space_addr); in pcic_write_config_dword()
247 writel(value, pcic->pcic_config_space_data + (where&4)); in pcic_write_config_dword()
257 if (bus->number != 0) return -EINVAL; in pcic_write_config()
260 pcic_read_config_dword(bus->number, devfn, where&~3, &v); in pcic_write_config()
263 return pcic_write_config_dword(bus->number, devfn, where&~3, v); in pcic_write_config()
265 if (where&1) return -EINVAL; in pcic_write_config()
266 pcic_read_config_dword(bus->number, devfn, where&~3, &v); in pcic_write_config()
269 return pcic_write_config_dword(bus->number, devfn, where&~3, v); in pcic_write_config()
271 if (where&3) return -EINVAL; in pcic_write_config()
272 return pcic_write_config_dword(bus->number, devfn, where, val); in pcic_write_config()
274 return -EINVAL; in pcic_write_config()
305 return -ENODEV; in pcic_probe()
310 if (err == 0 || err == -1) { in pcic_probe()
318 pcic->pcic_res_regs.name = "pcic_registers"; in pcic_probe()
319 pcic->pcic_regs = ioremap(regs[0].phys_addr, regs[0].reg_size); in pcic_probe()
320 if (!pcic->pcic_regs) { in pcic_probe()
325 pcic->pcic_res_io.name = "pcic_io"; in pcic_probe()
326 if ((pcic->pcic_io = (unsigned long) in pcic_probe()
332 pcic->pcic_res_cfg_addr.name = "pcic_cfg_addr"; in pcic_probe()
333 if ((pcic->pcic_config_space_addr = in pcic_probe()
344 pcic->pcic_res_cfg_data.name = "pcic_cfg_data"; in pcic_probe()
345 if ((pcic->pcic_config_space_data = in pcic_probe()
352 pbm = &pcic->pbm; in pcic_probe()
353 pbm->prom_node = node; in pcic_probe()
355 strcpy(pbm->prom_name, namebuf); in pcic_probe()
365 pcic_regs = pcic->pcic_regs; in pcic_probe()
372 for (p = pcic_known_sysnames; p->sysname != NULL; p++) { in pcic_probe()
373 if (strcmp(namebuf, p->sysname) == 0) in pcic_probe()
376 pcic->pcic_imap = p->intmap; in pcic_probe()
377 pcic->pcic_imdim = p->mapdim; in pcic_probe()
379 if (pcic->pcic_imap == NULL) { in pcic_probe()
392 struct linux_pbm_info *pbm = &pcic->pbm; in pcic_pbm_scan_bus()
394 pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm); in pcic_pbm_scan_bus()
395 if (!pbm->pci_bus) in pcic_pbm_scan_bus()
399 pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node); in pcic_pbm_scan_bus()
400 pci_record_assignments(pbm, pbm->pci_bus); in pcic_pbm_scan_bus()
401 pci_assign_unassigned(pbm, pbm->pci_bus); in pcic_pbm_scan_bus()
402 pci_fixup_irq(pbm, pbm->pci_bus); in pcic_pbm_scan_bus()
404 pci_bus_add_devices(pbm->pci_bus); in pcic_pbm_scan_bus()
426 pcic->pcic_regs+PCI_DVMA_CONTROL); in pcic_init()
433 writel(0xF0000000UL, pcic->pcic_regs+PCI_SIZE_0); in pcic_init()
435 pcic->pcic_regs+PCI_BASE_ADDRESS_0); in pcic_init()
451 phandle node = prom_getchild(pbm->prom_node); in pdev_to_pnode()
456 if(err != 0 && err != -1) { in pdev_to_pnode()
458 if(devfn == pdev->devfn) in pdev_to_pnode()
479 if (node == 0 || node == -1) { in pcic_map_pci_device()
486 address = dev->resource[j].start; in pcic_map_pci_device()
488 flags = dev->resource[j].flags; in pcic_map_pci_device()
497 * do ioremap() before accessing PC-style I/O, in pcic_map_pci_device()
508 dev->resource[j].start = in pcic_map_pci_device()
509 pcic->pcic_io + address; in pcic_map_pci_device()
510 dev->resource[j].end = 1; /* XXX */ in pcic_map_pci_device()
511 dev->resource[j].flags = in pcic_map_pci_device()
538 if (node == 0 || node == -1) { in pcic_fill_irq()
544 if ((p = pcic->pcic_imap) == NULL) { in pcic_fill_irq()
545 dev->irq = 0; in pcic_fill_irq()
548 for (i = 0; i < pcic->pcic_imdim; i++) { in pcic_fill_irq()
549 if (p->busno == dev->bus->number && p->devfn == dev->devfn) in pcic_fill_irq()
553 if (i >= pcic->pcic_imdim) { in pcic_fill_irq()
555 pcic->pcic_imdim); in pcic_fill_irq()
556 dev->irq = 0; in pcic_fill_irq()
560 i = p->pin; in pcic_fill_irq()
562 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_LO); in pcic_fill_irq()
565 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI); in pcic_fill_irq()
566 real_irq = ivec >> ((i-4) << 2) & 0xF; in pcic_fill_irq()
570 /* P3 */ /* printk("PCIC: device %s pin %d ivec 0x%x irq %x\n", namebuf, i, ivec, dev->irq); */ in pcic_fill_irq()
573 * half of PCIC. This happens on JS-E with PROM 3.11, for instance. in pcic_fill_irq()
575 if (real_irq == 0 || p->force) { in pcic_fill_irq()
576 if (p->irq == 0 || p->irq >= 15) { /* Corrupted map */ in pcic_fill_irq()
577 pci_info(dev, "PCIC: BAD IRQ %d\n", p->irq); for (;;) {} in pcic_fill_irq()
579 pci_info(dev, "PCIC: setting irq %d at pin %d\n", p->irq, in pcic_fill_irq()
580 p->pin); in pcic_fill_irq()
581 real_irq = p->irq; in pcic_fill_irq()
583 i = p->pin; in pcic_fill_irq()
585 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI); in pcic_fill_irq()
586 ivec &= ~(0xF << ((i - 4) << 2)); in pcic_fill_irq()
587 ivec |= p->irq << ((i - 4) << 2); in pcic_fill_irq()
588 writew(ivec, pcic->pcic_regs+PCI_INT_SELECT_HI); in pcic_fill_irq()
590 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_LO); in pcic_fill_irq()
592 ivec |= p->irq << (i << 2); in pcic_fill_irq()
593 writew(ivec, pcic->pcic_regs+PCI_INT_SELECT_LO); in pcic_fill_irq()
596 dev->irq = pcic_build_device_irq(NULL, real_irq); in pcic_fill_irq()
606 /* struct linux_pbm_info* pbm = &pcic->pbm; */ in pcibios_fixup_bus()
619 if (bus->number != 0) { in pcibios_fixup_bus()
621 bus->number); in pcibios_fixup_bus()
625 list_for_each_entry(dev, &bus->devices, bus_list) { in pcibios_fixup_bus()
626 node = pdev_to_pnode(&pcic->pbm, dev); in pcibios_fixup_bus()
628 node = -1; in pcibios_fixup_bus()
632 pcp->pbm = &pcic->pbm; in pcibios_fixup_bus()
633 pcp->prom_node = of_find_node_by_phandle(node); in pcibios_fixup_bus()
634 dev->sysdata = pcp; in pcibios_fixup_bus()
637 if ((dev->class>>16) != PCI_BASE_CLASS_BRIDGE) in pcibios_fixup_bus()
658 if (res->flags & IORESOURCE_IO) in pcibios_enable_device()
660 if (res->flags & IORESOURCE_MEM) in pcibios_enable_device()
665 pci_info(dev, "enabling device (%04x -> %04x)\n", oldcmd, cmd); in pcibios_enable_device()
720 writel (TICK_TIMER_LIMIT, pcic->pcic_regs+PCI_SYS_LIMIT); in pci_time_init()
722 v = readb(pcic->pcic_regs+PCI_COUNTER_IRQ); in pci_time_init()
725 pcic->pcic_regs+PCI_COUNTER_IRQ); in pci_time_init()
739 writeb(0, pcic->pcic_regs+PCI_SYS_STATUS);
752 * XXX On CP-1200 PCI #SERR may happen, we do not know in pcic_nmi()
756 pend, (int)regs->pc, pcic_speculative); in pcic_nmi()
761 regs->pc = regs->npc; in pcic_nmi()
762 regs->npc += 4; in pcic_nmi()
774 mask = (unsigned long)data->chip_data; in pcic_mask_irq()
784 mask = (unsigned long)data->chip_data; in pcic_unmask_irq()
792 irq_link(data->irq); in pcic_startup_irq()