Lines Matching defs:sock
67 static int db1200_card_inserted(struct db1x_pcmcia_sock *sock)
72 return sigstat & 1 << (8 + 2 * sock->nr);
76 static int db1000_card_inserted(struct db1x_pcmcia_sock *sock)
78 return !gpio_get_value(irq_to_gpio(sock->insert_irq));
81 static int db1x_card_inserted(struct db1x_pcmcia_sock *sock)
83 switch (sock->board_type) {
85 return db1200_card_inserted(sock);
87 return db1000_card_inserted(sock);
95 static inline void set_stschg(struct db1x_pcmcia_sock *sock, int en)
97 if (sock->stschg_irq != -1) {
99 enable_irq(sock->stschg_irq);
101 disable_irq(sock->stschg_irq);
107 struct db1x_pcmcia_sock *sock = data;
109 pcmcia_parse_events(&sock->socket, SS_DETECT);
116 struct db1x_pcmcia_sock *sock = data;
118 pcmcia_parse_events(&sock->socket, SS_STSCHG);
125 struct db1x_pcmcia_sock *sock = data;
132 if (irq == sock->insert_irq) {
133 disable_irq_nosync(sock->insert_irq);
134 enable_irq(sock->eject_irq);
136 disable_irq_nosync(sock->eject_irq);
137 enable_irq(sock->insert_irq);
140 pcmcia_parse_events(&sock->socket, SS_DETECT);
145 static int db1x_pcmcia_setup_irqs(struct db1x_pcmcia_sock *sock)
149 if (sock->stschg_irq != -1) {
150 ret = request_irq(sock->stschg_irq, db1000_pcmcia_stschgirq,
151 0, "pcmcia_stschg", sock);
162 if (sock->board_type == BOARD_TYPE_DB1200) {
163 ret = request_irq(sock->insert_irq, db1200_pcmcia_cdirq,
164 IRQF_DISABLED, "pcmcia_insert", sock);
168 ret = request_irq(sock->eject_irq, db1200_pcmcia_cdirq,
169 IRQF_DISABLED, "pcmcia_eject", sock);
171 free_irq(sock->insert_irq, sock);
176 if (db1200_card_inserted(sock))
177 enable_irq(sock->eject_irq);
179 enable_irq(sock->insert_irq);
184 set_irq_type(sock->insert_irq, IRQ_TYPE_EDGE_BOTH);
185 ret = request_irq(sock->insert_irq, db1000_pcmcia_cdirq,
186 0, "pcmcia_carddetect", sock);
195 if (sock->stschg_irq != -1)
196 free_irq(sock->stschg_irq, sock);
201 static void db1x_pcmcia_free_irqs(struct db1x_pcmcia_sock *sock)
203 if (sock->stschg_irq != -1)
204 free_irq(sock->stschg_irq, sock);
206 free_irq(sock->insert_irq, sock);
207 if (sock->eject_irq != -1)
208 free_irq(sock->eject_irq, sock);
227 struct db1x_pcmcia_sock *sock = to_db1x_socket(skt);
233 cr_clr = (0xf << (sock->nr * 8)); /* clear voltage settings */
246 sock->nr, state->Vcc);
259 sock->nr, state->Vpp);
266 sock->nr, state->Vcc, state->Vpp);
272 cr_set |= ((v << 2) | p) << (sock->nr * 8);
274 changed = state->flags ^ sock->old_flags;
278 set_stschg(sock, 0);
280 cr_clr |= (1 << (7 + (sock->nr * 8)));
281 cr_clr |= (1 << (4 + (sock->nr * 8)));
284 cr_set |= 1 << (7 + (sock->nr * 8));
285 cr_set |= 1 << (4 + (sock->nr * 8));
292 sock->old_flags = state->flags;
297 set_stschg(sock, 1);
318 struct db1x_pcmcia_sock *sock = to_db1x_socket(skt);
322 status = db1x_card_inserted(sock) ? SS_DETECT : 0;
328 if (sock->board_type == BOARD_TYPE_PB1100)
332 switch (GET_VS(sr, sock->nr)) {
343 status |= GET_VCC(cr, sock->nr) ? SS_POWERON : 0;
346 status |= (GET_RESET(cr, sock->nr)) ? SS_READY : SS_RESET;
366 struct db1x_pcmcia_sock *sock = to_db1x_socket(skt);
368 map->start = (u32)sock->virt_io;
377 struct db1x_pcmcia_sock *sock = to_db1x_socket(skt);
380 map->static_start = sock->phys_attr + map->card_start;
382 map->static_start = sock->phys_mem + map->card_start;
398 struct db1x_pcmcia_sock *sock;
402 sock = kzalloc(sizeof(struct db1x_pcmcia_sock), GFP_KERNEL);
403 if (!sock)
406 sock->nr = pdev->id;
413 sock->board_type = BOARD_TYPE_PB1100;
416 sock->board_type = BOARD_TYPE_DEFAULT;
419 sock->board_type = BOARD_TYPE_DB1200;
439 sock->card_irq = r ? r->start : 0;
443 sock->insert_irq = r ? r->start : -1;
447 sock->stschg_irq = r ? r->start : -1;
451 sock->eject_irq = r ? r->start : -1;
459 sock->nr);
462 sock->phys_attr = r->start;
468 sock->nr);
471 sock->phys_mem = r->start;
477 sock->nr);
480 sock->phys_io = r->start;
490 sock->virt_io = (void *)(ioremap(sock->phys_io, IO_MAP_SIZE) -
493 if (!sock->virt_io) {
495 sock->nr);
500 sock->socket.ops = &db1x_pcmcia_operations;
501 sock->socket.owner = THIS_MODULE;
502 sock->socket.pci_irq = sock->card_irq;
503 sock->socket.features = SS_CAP_STATIC_MAP | SS_CAP_PCCARD;
504 sock->socket.map_size = MEM_MAP_SIZE;
505 sock->socket.io_offset = (unsigned long)sock->virt_io;
506 sock->socket.dev.parent = &pdev->dev;
507 sock->socket.resource_ops = &pccard_static_ops;
509 platform_set_drvdata(pdev, sock);
511 ret = db1x_pcmcia_setup_irqs(sock);
514 sock->nr);
518 set_stschg(sock, 0);
520 ret = pcmcia_register_socket(&sock->socket);
522 printk(KERN_ERR "pcmcia%d failed to register\n", sock->nr);
528 "%d %d %d\n", sock->nr, sock->phys_io, sock->virt_io,
529 sock->phys_attr, sock->phys_mem, sock->card_irq,
530 sock->insert_irq, sock->stschg_irq, sock->eject_irq);
535 db1x_pcmcia_free_irqs(sock);
537 iounmap((void *)(sock->virt_io + (u32)mips_io_port_base));
539 kfree(sock);
545 struct db1x_pcmcia_sock *sock = platform_get_drvdata(pdev);
547 db1x_pcmcia_free_irqs(sock);
548 pcmcia_unregister_socket(&sock->socket);
549 iounmap((void *)(sock->virt_io + (u32)mips_io_port_base));
550 kfree(sock);