Lines Matching refs:socket
69 static int yenta_probe_cb_irq(struct yenta_socket *socket);
70 static unsigned int yenta_probe_irq(struct yenta_socket *socket,
84 static inline u32 cb_readl(struct yenta_socket *socket, unsigned reg) in cb_readl() argument
86 u32 val = readl(socket->base + reg); in cb_readl()
87 debug("%04x %08x\n", socket, reg, val); in cb_readl()
91 static inline void cb_writel(struct yenta_socket *socket, unsigned reg, u32 val) in cb_writel() argument
93 debug("%04x %08x\n", socket, reg, val); in cb_writel()
94 writel(val, socket->base + reg); in cb_writel()
95 readl(socket->base + reg); /* avoid problems with PCI write posting */ in cb_writel()
98 static inline u8 config_readb(struct yenta_socket *socket, unsigned offset) in config_readb() argument
101 pci_read_config_byte(socket->dev, offset, &val); in config_readb()
102 debug("%04x %02x\n", socket, offset, val); in config_readb()
106 static inline u16 config_readw(struct yenta_socket *socket, unsigned offset) in config_readw() argument
109 pci_read_config_word(socket->dev, offset, &val); in config_readw()
110 debug("%04x %04x\n", socket, offset, val); in config_readw()
114 static inline u32 config_readl(struct yenta_socket *socket, unsigned offset) in config_readl() argument
117 pci_read_config_dword(socket->dev, offset, &val); in config_readl()
118 debug("%04x %08x\n", socket, offset, val); in config_readl()
122 static inline void config_writeb(struct yenta_socket *socket, unsigned offset, u8 val) in config_writeb() argument
124 debug("%04x %02x\n", socket, offset, val); in config_writeb()
125 pci_write_config_byte(socket->dev, offset, val); in config_writeb()
128 static inline void config_writew(struct yenta_socket *socket, unsigned offset, u16 val) in config_writew() argument
130 debug("%04x %04x\n", socket, offset, val); in config_writew()
131 pci_write_config_word(socket->dev, offset, val); in config_writew()
134 static inline void config_writel(struct yenta_socket *socket, unsigned offset, u32 val) in config_writel() argument
136 debug("%04x %08x\n", socket, offset, val); in config_writel()
137 pci_write_config_dword(socket->dev, offset, val); in config_writel()
140 static inline u8 exca_readb(struct yenta_socket *socket, unsigned reg) in exca_readb() argument
142 u8 val = readb(socket->base + 0x800 + reg); in exca_readb()
143 debug("%04x %02x\n", socket, reg, val); in exca_readb()
147 static inline u8 exca_readw(struct yenta_socket *socket, unsigned reg) in exca_readw() argument
150 val = readb(socket->base + 0x800 + reg); in exca_readw()
151 val |= readb(socket->base + 0x800 + reg + 1) << 8; in exca_readw()
152 debug("%04x %04x\n", socket, reg, val); in exca_readw()
156 static inline void exca_writeb(struct yenta_socket *socket, unsigned reg, u8 val) in exca_writeb() argument
158 debug("%04x %02x\n", socket, reg, val); in exca_writeb()
159 writeb(val, socket->base + 0x800 + reg); in exca_writeb()
160 readb(socket->base + 0x800 + reg); /* PCI write posting... */ in exca_writeb()
163 static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) in exca_writew() argument
165 debug("%04x %04x\n", socket, reg, val); in exca_writew()
166 writeb(val, socket->base + 0x800 + reg); in exca_writew()
167 writeb(val >> 8, socket->base + 0x800 + reg + 1); in exca_writew()
170 readb(socket->base + 0x800 + reg); in exca_writew()
171 readb(socket->base + 0x800 + reg + 1); in exca_writew()
176 struct yenta_socket *socket = dev_get_drvdata(yentadev); in show_yenta_registers() local
184 val = cb_readl(socket, i); in show_yenta_registers()
198 val = exca_readb(socket, i); in show_yenta_registers()
213 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); in yenta_get_status() local
215 u32 state = cb_readl(socket, CB_SOCKET_STATE); in yenta_get_status()
229 u8 status = exca_readb(socket, I365_STATUS); in yenta_get_status()
231 if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) { in yenta_get_status()
246 static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state) in yenta_set_power() argument
249 if (!(cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) && in yenta_set_power()
250 (socket->flags & YENTA_16BIT_POWER_EXCA)) { in yenta_set_power()
252 reg = old = exca_readb(socket, I365_POWER); in yenta_set_power()
256 if (socket->flags & YENTA_16BIT_POWER_DF) { in yenta_set_power()
298 exca_writeb(socket, I365_POWER, reg); in yenta_set_power()
323 if (reg != cb_readl(socket, CB_SOCKET_CONTROL)) in yenta_set_power()
324 cb_writel(socket, CB_SOCKET_CONTROL, reg); in yenta_set_power()
330 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); in yenta_set_socket() local
335 yenta_set_power(socket, state); in yenta_set_socket()
337 socket->io_irq = state->io_irq; in yenta_set_socket()
338 bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~(CB_BRIDGE_CRST | CB_BRIDGE_INTR); in yenta_set_socket()
339 if (cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) { in yenta_set_socket()
344 intr = exca_readb(socket, I365_INTCTL); in yenta_set_socket()
346 if (!socket->dev->irq) { in yenta_set_socket()
347 intr |= socket->cb_irq ? socket->cb_irq : state->io_irq; in yenta_set_socket()
350 exca_writeb(socket, I365_INTCTL, intr); in yenta_set_socket()
354 reg = exca_readb(socket, I365_INTCTL) & (I365_RING_ENA | I365_INTR_ENA); in yenta_set_socket()
357 if (state->io_irq != socket->dev->irq) { in yenta_set_socket()
361 exca_writeb(socket, I365_INTCTL, reg); in yenta_set_socket()
363 reg = exca_readb(socket, I365_POWER) & (I365_VCC_MASK|I365_VPP1_MASK); in yenta_set_socket()
369 if (exca_readb(socket, I365_POWER) != reg) in yenta_set_socket()
370 exca_writeb(socket, I365_POWER, reg); in yenta_set_socket()
373 reg = exca_readb(socket, I365_CSCINT); in yenta_set_socket()
387 exca_writeb(socket, I365_CSCINT, reg); in yenta_set_socket()
388 exca_readb(socket, I365_CSC); in yenta_set_socket()
392 config_writew(socket, CB_BRIDGE_CONTROL, bridge); in yenta_set_socket()
394 cb_writel(socket, CB_SOCKET_EVENT, -1); in yenta_set_socket()
395 cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK); in yenta_set_socket()
399 yenta_set_power(socket, state); in yenta_set_socket()
405 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); in yenta_set_io_map() local
415 addr = exca_readb(socket, I365_ADDRWIN); in yenta_set_io_map()
420 exca_writeb(socket, I365_ADDRWIN, addr); in yenta_set_io_map()
423 exca_writew(socket, I365_IO(map)+I365_W_START, io->start); in yenta_set_io_map()
424 exca_writew(socket, I365_IO(map)+I365_W_STOP, io->stop); in yenta_set_io_map()
426 ioctl = exca_readb(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map); in yenta_set_io_map()
433 exca_writeb(socket, I365_IOCTL, ioctl); in yenta_set_io_map()
436 exca_writeb(socket, I365_ADDRWIN, addr | enable); in yenta_set_io_map()
442 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); in yenta_set_mem_map() local
449 pcibios_resource_to_bus(socket->dev->bus, ®ion, mem->res); in yenta_set_mem_map()
461 addr = exca_readb(socket, I365_ADDRWIN); in yenta_set_mem_map()
464 exca_writeb(socket, I365_ADDRWIN, addr); in yenta_set_mem_map()
467 exca_writeb(socket, CB_MEM_PAGE(map), start >> 24); in yenta_set_mem_map()
474 exca_writew(socket, I365_MEM(map) + I365_W_START, word); in yenta_set_mem_map()
490 exca_writew(socket, I365_MEM(map) + I365_W_STOP, word); in yenta_set_mem_map()
497 exca_writew(socket, I365_MEM(map) + I365_W_OFF, word); in yenta_set_mem_map()
500 exca_writeb(socket, I365_ADDRWIN, addr | enable); in yenta_set_mem_map()
509 struct yenta_socket *socket = (struct yenta_socket *) dev_id; in yenta_interrupt() local
514 cb_event = cb_readl(socket, CB_SOCKET_EVENT); in yenta_interrupt()
515 cb_writel(socket, CB_SOCKET_EVENT, cb_event); in yenta_interrupt()
517 csc = exca_readb(socket, I365_CSC); in yenta_interrupt()
524 if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) { in yenta_interrupt()
533 pcmcia_parse_events(&socket->socket, events); in yenta_interrupt()
540 struct yenta_socket *socket = from_timer(socket, t, poll_timer); in yenta_interrupt_wrapper() local
542 yenta_interrupt(0, (void *)socket); in yenta_interrupt_wrapper()
543 socket->poll_timer.expires = jiffies + HZ; in yenta_interrupt_wrapper()
544 add_timer(&socket->poll_timer); in yenta_interrupt_wrapper()
547 static void yenta_clear_maps(struct yenta_socket *socket) in yenta_clear_maps() argument
554 yenta_set_socket(&socket->socket, &dead_socket); in yenta_clear_maps()
557 yenta_set_io_map(&socket->socket, &io); in yenta_clear_maps()
561 yenta_set_mem_map(&socket->socket, &mem); in yenta_clear_maps()
566 static void yenta_interrogate(struct yenta_socket *socket) in yenta_interrogate() argument
570 state = cb_readl(socket, CB_SOCKET_STATE); in yenta_interrogate()
574 cb_writel(socket, CB_SOCKET_FORCE, CB_CVSTEST); in yenta_interrogate()
580 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); in yenta_sock_init() local
582 exca_writeb(socket, I365_GBLCTL, 0x00); in yenta_sock_init()
583 exca_writeb(socket, I365_GENCTL, 0x00); in yenta_sock_init()
586 yenta_interrogate(socket); in yenta_sock_init()
588 yenta_clear_maps(socket); in yenta_sock_init()
590 if (socket->type && socket->type->sock_init) in yenta_sock_init()
591 socket->type->sock_init(socket); in yenta_sock_init()
594 cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK); in yenta_sock_init()
601 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); in yenta_sock_suspend() local
604 cb_writel(socket, CB_SOCKET_MASK, 0x0); in yenta_sock_suspend()
670 static int yenta_search_res(struct yenta_socket *socket, struct resource *res, in yenta_search_res() argument
676 pci_bus_for_each_resource(socket->dev->bus, root, i) { in yenta_search_res()
690 static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, i… in yenta_allocate_res() argument
692 struct pci_dev *dev = socket->dev; in yenta_allocate_res()
710 region.start = config_readl(socket, addr_start) & mask; in yenta_allocate_res()
711 region.end = config_readl(socket, addr_end) | ~mask; in yenta_allocate_res()
722 if ((yenta_search_res(socket, res, BRIDGE_IO_MAX)) || in yenta_allocate_res()
723 (yenta_search_res(socket, res, BRIDGE_IO_ACC)) || in yenta_allocate_res()
724 (yenta_search_res(socket, res, BRIDGE_IO_MIN))) in yenta_allocate_res()
728 if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) || in yenta_allocate_res()
729 (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) || in yenta_allocate_res()
730 (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) in yenta_allocate_res()
735 if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) || in yenta_allocate_res()
736 (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) || in yenta_allocate_res()
737 (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) in yenta_allocate_res()
748 static void yenta_free_res(struct yenta_socket *socket, int nr) in yenta_free_res() argument
750 struct pci_dev *dev = socket->dev; in yenta_free_res()
763 static void yenta_allocate_resources(struct yenta_socket *socket) in yenta_allocate_resources() argument
766 program += yenta_allocate_res(socket, PCI_CB_BRIDGE_IO_0_WINDOW, in yenta_allocate_resources()
769 program += yenta_allocate_res(socket, PCI_CB_BRIDGE_IO_1_WINDOW, in yenta_allocate_resources()
772 program += yenta_allocate_res(socket, PCI_CB_BRIDGE_MEM_0_WINDOW, in yenta_allocate_resources()
775 program += yenta_allocate_res(socket, PCI_CB_BRIDGE_MEM_1_WINDOW, in yenta_allocate_resources()
779 pci_setup_cardbus(socket->dev->subordinate); in yenta_allocate_resources()
786 static void yenta_free_resources(struct yenta_socket *socket) in yenta_free_resources() argument
788 yenta_free_res(socket, PCI_CB_BRIDGE_IO_0_WINDOW); in yenta_free_resources()
789 yenta_free_res(socket, PCI_CB_BRIDGE_IO_1_WINDOW); in yenta_free_resources()
790 yenta_free_res(socket, PCI_CB_BRIDGE_MEM_0_WINDOW); in yenta_free_resources()
791 yenta_free_res(socket, PCI_CB_BRIDGE_MEM_1_WINDOW); in yenta_free_resources()
806 pcmcia_unregister_socket(&sock->socket); in yenta_close()
924 static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mask) in yenta_probe_irq() argument
935 cb_writel(socket, CB_SOCKET_EVENT, -1); in yenta_probe_irq()
936 cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK); in yenta_probe_irq()
937 reg = exca_readb(socket, I365_CSCINT); in yenta_probe_irq()
938 exca_writeb(socket, I365_CSCINT, 0); in yenta_probe_irq()
943 exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG | (i << 4)); in yenta_probe_irq()
944 cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS); in yenta_probe_irq()
946 cb_writel(socket, CB_SOCKET_EVENT, -1); in yenta_probe_irq()
948 cb_writel(socket, CB_SOCKET_MASK, 0); in yenta_probe_irq()
949 exca_writeb(socket, I365_CSCINT, reg); in yenta_probe_irq()
966 struct yenta_socket *socket = (struct yenta_socket *) dev_id; in yenta_probe_handler() local
971 cb_event = cb_readl(socket, CB_SOCKET_EVENT); in yenta_probe_handler()
972 cb_writel(socket, CB_SOCKET_EVENT, -1); in yenta_probe_handler()
973 csc = exca_readb(socket, I365_CSC); in yenta_probe_handler()
976 socket->probe_status = 1; in yenta_probe_handler()
984 static int yenta_probe_cb_irq(struct yenta_socket *socket) in yenta_probe_cb_irq() argument
988 if (!socket->cb_irq) in yenta_probe_cb_irq()
991 socket->probe_status = 0; in yenta_probe_cb_irq()
993 if (request_irq(socket->cb_irq, yenta_probe_handler, IRQF_SHARED, "yenta", socket)) { in yenta_probe_cb_irq()
994 dev_warn(&socket->dev->dev, in yenta_probe_cb_irq()
1000 if (!socket->dev->irq) in yenta_probe_cb_irq()
1001 reg = exca_readb(socket, I365_CSCINT); in yenta_probe_cb_irq()
1002 exca_writeb(socket, I365_CSCINT, reg | I365_CSC_STSCHG); in yenta_probe_cb_irq()
1003 cb_writel(socket, CB_SOCKET_EVENT, -1); in yenta_probe_cb_irq()
1004 cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK); in yenta_probe_cb_irq()
1005 cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS); in yenta_probe_cb_irq()
1010 cb_writel(socket, CB_SOCKET_MASK, 0); in yenta_probe_cb_irq()
1011 exca_writeb(socket, I365_CSCINT, reg); in yenta_probe_cb_irq()
1012 cb_writel(socket, CB_SOCKET_EVENT, -1); in yenta_probe_cb_irq()
1013 exca_readb(socket, I365_CSC); in yenta_probe_cb_irq()
1015 free_irq(socket->cb_irq, socket); in yenta_probe_cb_irq()
1017 return (int) socket->probe_status; in yenta_probe_cb_irq()
1026 static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_irq_mask) in yenta_get_socket_capabilities() argument
1028 socket->socket.pci_irq = socket->cb_irq; in yenta_get_socket_capabilities()
1030 socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask); in yenta_get_socket_capabilities()
1032 socket->socket.irq_mask = 0; in yenta_get_socket_capabilities()
1034 dev_info(&socket->dev->dev, "ISA IRQ mask 0x%04x, PCI irq %d\n", in yenta_get_socket_capabilities()
1035 socket->socket.irq_mask, socket->cb_irq); in yenta_get_socket_capabilities()
1041 static void yenta_config_init(struct yenta_socket *socket) in yenta_config_init() argument
1044 struct pci_dev *dev = socket->dev; in yenta_config_init()
1047 pcibios_resource_to_bus(socket->dev->bus, ®ion, &dev->resource[0]); in yenta_config_init()
1049 config_writel(socket, CB_LEGACY_MODE_BASE, 0); in yenta_config_init()
1050 config_writel(socket, PCI_BASE_ADDRESS_0, region.start); in yenta_config_init()
1051 config_writew(socket, PCI_COMMAND, in yenta_config_init()
1058 config_writeb(socket, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4); in yenta_config_init()
1059 config_writeb(socket, PCI_LATENCY_TIMER, 168); in yenta_config_init()
1060 config_writel(socket, PCI_PRIMARY_BUS, in yenta_config_init()
1072 bridge = config_readw(socket, CB_BRIDGE_CONTROL); in yenta_config_init()
1075 config_writew(socket, CB_BRIDGE_CONTROL, bridge); in yenta_config_init()
1158 struct yenta_socket *socket; in yenta_probe() local
1171 socket = kzalloc(sizeof(struct yenta_socket), GFP_KERNEL); in yenta_probe()
1172 if (!socket) in yenta_probe()
1176 socket->socket.ops = ¥ta_socket_operations; in yenta_probe()
1177 socket->socket.resource_ops = &pccard_nonstatic_ops; in yenta_probe()
1178 socket->socket.dev.parent = &dev->dev; in yenta_probe()
1179 socket->socket.driver_data = socket; in yenta_probe()
1180 socket->socket.owner = THIS_MODULE; in yenta_probe()
1181 socket->socket.features = SS_CAP_PAGE_REGS | SS_CAP_PCCARD; in yenta_probe()
1182 socket->socket.map_size = 0x1000; in yenta_probe()
1183 socket->socket.cb_dev = dev; in yenta_probe()
1186 socket->dev = dev; in yenta_probe()
1187 pci_set_drvdata(dev, socket); in yenta_probe()
1211 socket->base = ioremap(pci_resource_start(dev, 0), 0x1000); in yenta_probe()
1212 if (!socket->base) { in yenta_probe()
1224 yenta_config_init(socket); in yenta_probe()
1227 cb_writel(socket, CB_SOCKET_MASK, 0x0); in yenta_probe()
1230 yenta_allocate_resources(socket); in yenta_probe()
1232 socket->cb_irq = dev->irq; in yenta_probe()
1237 socket->type = &cardbus_type[id->driver_data]; in yenta_probe()
1239 ret = socket->type->override(socket); in yenta_probe()
1246 …if (!socket->cb_irq || request_irq(socket->cb_irq, yenta_interrupt, IRQF_SHARED, "yenta", socket))… in yenta_probe()
1248 socket->cb_irq = 0; /* But zero is a valid IRQ number. */ in yenta_probe()
1249 timer_setup(&socket->poll_timer, yenta_interrupt_wrapper, 0); in yenta_probe()
1250 mod_timer(&socket->poll_timer, jiffies + HZ); in yenta_probe()
1256 socket->socket.features |= SS_CAP_CARDBUS; in yenta_probe()
1260 yenta_interrogate(socket); in yenta_probe()
1261 yenta_get_socket_capabilities(socket, isa_interrupts); in yenta_probe()
1263 cb_readl(socket, CB_SOCKET_STATE)); in yenta_probe()
1268 ret = pcmcia_register_socket(&socket->socket); in yenta_probe()
1281 pcmcia_unregister_socket(&socket->socket); in yenta_probe()
1283 if (socket->cb_irq) in yenta_probe()
1284 free_irq(socket->cb_irq, socket); in yenta_probe()
1286 del_timer_sync(&socket->poll_timer); in yenta_probe()
1288 iounmap(socket->base); in yenta_probe()
1289 yenta_free_resources(socket); in yenta_probe()
1296 kfree(socket); in yenta_probe()
1304 struct yenta_socket *socket = pci_get_drvdata(pdev); in yenta_dev_suspend_noirq() local
1306 if (!socket) in yenta_dev_suspend_noirq()
1309 if (socket->type && socket->type->save_state) in yenta_dev_suspend_noirq()
1310 socket->type->save_state(socket); in yenta_dev_suspend_noirq()
1313 pci_read_config_dword(pdev, 16*4, &socket->saved_state[0]); in yenta_dev_suspend_noirq()
1314 pci_read_config_dword(pdev, 17*4, &socket->saved_state[1]); in yenta_dev_suspend_noirq()
1323 struct yenta_socket *socket = pci_get_drvdata(pdev); in yenta_dev_resume_noirq() local
1326 if (!socket) in yenta_dev_resume_noirq()
1329 pci_write_config_dword(pdev, 16*4, socket->saved_state[0]); in yenta_dev_resume_noirq()
1330 pci_write_config_dword(pdev, 17*4, socket->saved_state[1]); in yenta_dev_resume_noirq()
1338 if (socket->type && socket->type->restore_state) in yenta_dev_resume_noirq()
1339 socket->type->restore_state(socket); in yenta_dev_resume_noirq()