📄 i82365.c
字号:
struct i82365_socket *t = &socket[s]; if (t->flags & IS_CIRRUS) cirrus_set_state(s); else { i365_set(s, I365_GBLCTL, 0x00); i365_set(s, I365_GENCTL, 0x00); } i365_bflip(s, I365_INTCTL, I365_INTR_ENA, t->intr); if (t->flags & IS_VADEM) vg46x_set_state(s);}static u_int __init set_bridge_opts(u_short s, u_short ns){ u_short i; u_int m = 0xffff; char buf[128]; for (i = s; i < s+ns; i++) { if (socket[i].flags & IS_ALIVE) { printk(KERN_INFO " host opts [%d]: already alive!\n", i); continue; } buf[0] = '\0'; get_bridge_state(i); if (socket[i].flags & IS_CIRRUS) m = cirrus_set_opts(i, buf); else if (socket[i].flags & IS_VADEM) m = vg46x_set_opts(i, buf); set_bridge_state(i); printk(KERN_INFO " host opts [%d]:%s\n", i, (*buf) ? buf : " none"); } return m;}/*====================================================================== Interrupt testing code, for ISA and PCI interrupts ======================================================================*/static volatile u_int irq_hits;static u_short irq_sock;static irqreturn_t i365_count_irq(int irq, void *dev){ i365_get(irq_sock, I365_CSC); irq_hits++; debug(2, "-> hit on irq %d\n", irq); return IRQ_HANDLED;}static u_int __init test_irq(u_short sock, int irq){ debug(2, " testing ISA irq %d\n", irq); if (request_irq(irq, i365_count_irq, IRQF_PROBE_SHARED, "scan", i365_count_irq) != 0) return 1; irq_hits = 0; irq_sock = sock; msleep(10); if (irq_hits) { free_irq(irq, i365_count_irq); debug(2, " spurious hit!\n"); return 1; } /* Generate one interrupt */ i365_set(sock, I365_CSCINT, I365_CSC_DETECT | (irq << 4)); i365_bset(sock, I365_GENCTL, I365_CTL_SW_IRQ); udelay(1000); free_irq(irq, i365_count_irq); /* mask all interrupts */ i365_set(sock, I365_CSCINT, 0); debug(2, " hits = %d\n", irq_hits); return (irq_hits != 1);}static u_int __init isa_scan(u_short sock, u_int mask0){ u_int mask1 = 0; int i;#ifdef __alpha__#define PIC 0x4d0 /* Don't probe level-triggered interrupts -- reserved for PCI */ mask0 &= ~(inb(PIC) | (inb(PIC+1) << 8));#endif if (do_scan) { set_bridge_state(sock); i365_set(sock, I365_CSCINT, 0); for (i = 0; i < 16; i++) if ((mask0 & (1 << i)) && (test_irq(sock, i) == 0)) mask1 |= (1 << i); for (i = 0; i < 16; i++) if ((mask1 & (1 << i)) && (test_irq(sock, i) != 0)) mask1 ^= (1 << i); } printk(KERN_INFO " ISA irqs ("); if (mask1) { printk("scanned"); } else { /* Fallback: just find interrupts that aren't in use */ for (i = 0; i < 16; i++) if ((mask0 & (1 << i)) && (_check_irq(i, IRQF_PROBE_SHARED) == 0)) mask1 |= (1 << i); printk("default"); /* If scan failed, default to polled status */ if (!cs_irq && (poll_interval == 0)) poll_interval = HZ; } printk(") = "); for (i = 0; i < 16; i++) if (mask1 & (1<<i)) printk("%s%d", ((mask1 & ((1<<i)-1)) ? "," : ""), i); if (mask1 == 0) printk("none!"); return mask1;}/*====================================================================*//* Time conversion functions */static int to_cycles(int ns){ return ns/cycle_time;}/*====================================================================*/static int __init identify(kio_addr_t port, u_short sock){ u_char val; int type = -1; /* Use the next free entry in the socket table */ socket[sockets].ioaddr = port; socket[sockets].psock = sock; /* Wake up a sleepy Cirrus controller */ if (wakeup) { i365_bclr(sockets, PD67_MISC_CTL_2, PD67_MC2_SUSPEND); /* Pause at least 50 ms */ mdelay(50); } if ((val = i365_get(sockets, I365_IDENT)) & 0x70) return -1; switch (val) { case 0x82: type = IS_I82365A; break; case 0x83: type = IS_I82365B; break; case 0x84: type = IS_I82365DF; break; case 0x88: case 0x89: case 0x8a: type = IS_IBM; break; } /* Check for Vadem VG-468 chips */ outb(0x0e, port); outb(0x37, port); i365_bset(sockets, VG468_MISC, VG468_MISC_VADEMREV); val = i365_get(sockets, I365_IDENT); if (val & I365_IDENT_VADEM) { i365_bclr(sockets, VG468_MISC, VG468_MISC_VADEMREV); type = ((val & 7) >= 4) ? IS_VG469 : IS_VG468; } /* Check for Ricoh chips */ val = i365_get(sockets, RF5C_CHIP_ID); if ((val == RF5C_CHIP_RF5C296) || (val == RF5C_CHIP_RF5C396)) type = IS_RF5Cx96; /* Check for Cirrus CL-PD67xx chips */ i365_set(sockets, PD67_CHIP_INFO, 0); val = i365_get(sockets, PD67_CHIP_INFO); if ((val & PD67_INFO_CHIP_ID) == PD67_INFO_CHIP_ID) { val = i365_get(sockets, PD67_CHIP_INFO); if ((val & PD67_INFO_CHIP_ID) == 0) { type = (val & PD67_INFO_SLOTS) ? IS_PD672X : IS_PD6710; i365_set(sockets, PD67_EXT_INDEX, 0xe5); if (i365_get(sockets, PD67_EXT_INDEX) != 0xe5) type = IS_VT83C469; } } return type;} /* identify *//*====================================================================== See if a card is present, powered up, in IO mode, and already bound to a (non PC Card) Linux driver. We leave these alone. We make an exception for cards that seem to be serial devices. ======================================================================*/static int __init is_alive(u_short sock){ u_char stat; kio_addr_t start, stop; stat = i365_get(sock, I365_STATUS); start = i365_get_pair(sock, I365_IO(0)+I365_W_START); stop = i365_get_pair(sock, I365_IO(0)+I365_W_STOP); if ((stat & I365_CS_DETECT) && (stat & I365_CS_POWERON) && (i365_get(sock, I365_INTCTL) & I365_PC_IOCARD) && (i365_get(sock, I365_ADDRWIN) & I365_ENA_IO(0)) && ((start & 0xfeef) != 0x02e8)) { if (!request_region(start, stop-start+1, "i82365")) return 1; release_region(start, stop-start+1); } return 0;}/*====================================================================*/static void __init add_socket(kio_addr_t port, int psock, int type){ socket[sockets].ioaddr = port; socket[sockets].psock = psock; socket[sockets].type = type; socket[sockets].flags = pcic[type].flags; if (is_alive(sockets)) socket[sockets].flags |= IS_ALIVE; sockets++;}static void __init add_pcic(int ns, int type){ u_int mask = 0, i, base; int isa_irq = 0; struct i82365_socket *t = &socket[sockets-ns]; base = sockets-ns; if (base == 0) printk("\n"); printk(KERN_INFO " %s", pcic[type].name); printk(" ISA-to-PCMCIA at port %#lx ofs 0x%02x", t->ioaddr, t->psock*0x40); printk(", %d socket%s\n", ns, ((ns > 1) ? "s" : "")); /* Set host options, build basic interrupt mask */ if (irq_list_count == 0) mask = irq_mask; else for (i = mask = 0; i < irq_list_count; i++) mask |= (1<<irq_list[i]); mask &= I365_MASK & set_bridge_opts(base, ns); /* Scan for ISA interrupts */ mask = isa_scan(base, mask); /* Poll if only two interrupts available */ if (!poll_interval) { u_int tmp = (mask & 0xff20); tmp = tmp & (tmp-1); if ((tmp & (tmp-1)) == 0) poll_interval = HZ; } /* Only try an ISA cs_irq if this is the first controller */ if (!grab_irq && (cs_irq || !poll_interval)) { /* Avoid irq 12 unless it is explicitly requested */ u_int cs_mask = mask & ((cs_irq) ? (1<<cs_irq) : ~(1<<12)); for (cs_irq = 15; cs_irq > 0; cs_irq--) if ((cs_mask & (1 << cs_irq)) && (_check_irq(cs_irq, IRQF_PROBE_SHARED) == 0)) break; if (cs_irq) { grab_irq = 1; isa_irq = cs_irq; printk(" status change on irq %d\n", cs_irq); } } if (!isa_irq) { if (poll_interval == 0) poll_interval = HZ; printk(" polling interval = %d ms\n", poll_interval * 1000 / HZ); } /* Update socket interrupt information, capabilities */ for (i = 0; i < ns; i++) { t[i].socket.features |= SS_CAP_PCCARD; t[i].socket.map_size = 0x1000; t[i].socket.irq_mask = mask; t[i].cs_irq = isa_irq; }} /* add_pcic *//*====================================================================*/#ifdef CONFIG_PNPstatic struct isapnp_device_id id_table[] __initdata = { { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P', 'N', 'P'), ISAPNP_FUNCTION(0x0e00), (unsigned long) "Intel 82365-Compatible" }, { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P', 'N', 'P'), ISAPNP_FUNCTION(0x0e01), (unsigned long) "Cirrus Logic CL-PD6720" }, { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P', 'N', 'P'), ISAPNP_FUNCTION(0x0e02), (unsigned long) "VLSI VL82C146" }, { 0 }};MODULE_DEVICE_TABLE(isapnp, id_table);static struct pnp_dev *i82365_pnpdev;#endifstatic void __init isa_probe(void){ int i, j, sock, k, ns, id; kio_addr_t port;#ifdef CONFIG_PNP struct isapnp_device_id *devid; struct pnp_dev *dev; for (devid = id_table; devid->vendor; devid++) { if ((dev = pnp_find_dev(NULL, devid->vendor, devid->function, NULL))) { if (pnp_device_attach(dev) < 0) continue; if (pnp_activate_dev(dev) < 0) { printk("activate failed\n"); pnp_device_detach(dev); break; } if (!pnp_port_valid(dev, 0)) { printk("invalid resources ?\n"); pnp_device_detach(dev); break; } i365_base = pnp_port_start(dev, 0); i82365_pnpdev = dev; break; } }#endif if (!request_region(i365_base, 2, "i82365")) { if (sockets == 0) printk("port conflict at %#lx\n", i365_base); return; } id = identify(i365_base, 0); if ((id == IS_I82365DF) && (identify(i365_base, 1) != id)) { for (i = 0; i < 4; i++) { if (i == ignore) continue; port = i365_base + ((i & 1) << 2) + ((i & 2) << 1); sock = (i & 1) << 1; if (identify(port, sock) == IS_I82365DF) { add_socket(port, sock, IS_VLSI); add_pcic(1, IS_VLSI); } } } else { for (i = 0; i < 8; i += 2) { if (sockets && !extra_sockets && (i == 4)) break; port = i365_base + 2*(i>>2); sock = (i & 3); id = identify(port, sock); if (id < 0) continue; for (j = ns = 0; j < 2; j++) { /* Does the socket exist? */ if ((ignore == i+j) || (identify(port, sock+j) < 0)) continue; /* Check for bad socket decode */ for (k = 0; k <= sockets; k++) i365_set(k, I365_MEM(0)+I365_W_OFF, k); for (k = 0; k <= sockets; k++) if (i365_get(k, I365_MEM(0)+I365_W_OFF) != k) break; if (k <= sockets) break; add_socket(port, sock+j, id); ns++; } if (ns != 0) add_pcic(ns, id); } }}/*====================================================================*/static irqreturn_t pcic_interrupt(int irq, void *dev){ int i, j, csc; u_int events, active; u_long flags = 0; int handled = 0; debug(4, "pcic_interrupt(%d)\n", irq); for (j = 0; j < 20; j++) { active = 0; for (i = 0; i < sockets; i++) { if (socket[i].cs_irq != irq) continue; handled = 1; ISA_LOCK(i, flags); csc = i365_get(i, I365_CSC); if ((csc == 0) || (i365_get(i, I365_IDENT) & 0x70)) { ISA_UNLOCK(i, flags); continue; } events = (csc & I365_CSC_DETECT) ? SS_DETECT : 0; if (i365_get(i, I365_INTCTL) & I365_PC_IOCARD) events |= (csc & I365_CSC_STSCHG) ? SS_STSCHG : 0; else { events |= (csc & I365_CSC_BVD1) ? SS_BATDEAD : 0; events |= (csc & I365_CSC_BVD2) ? SS_BATWARN : 0; events |= (csc & I365_CSC_READY) ? SS_READY : 0; } ISA_UNLOCK(i, flags); debug(2, "socket %d event 0x%02x\n", i, events); if (events) pcmcia_parse_events(&socket[i].socket, events); active |= events; } if (!active) break; } if (j == 20) printk(KERN_NOTICE "i82365: infinite loop in interrupt handler\n"); debug(4, "interrupt done\n"); return IRQ_RETVAL(handled);} /* pcic_interrupt */static void pcic_interrupt_wrapper(u_long data){ pcic_interrupt(0, NULL); poll_timer.expires = jiffies + poll_interval; add_timer(&poll_timer);}/*====================================================================*/static int i365_get_status(u_short sock, u_int *value){ u_int status;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -