Lines Matching +full:nr +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0-only
13 * The Db1000 is used as a reference: Per-socket card-, carddetect- and
14 * statuschange IRQs connected to SoC GPIOs, control and status register
15 * bits arranged in per-socket groups in an external PLD. All boards
19 * - Pb1100/Pb1500: single socket only; voltage key bits VS are
21 * - Au1200-based: additional card-eject irqs, irqs not gpios!
22 * - Db1300: Db1200-like, no pwr ctrl, single socket (#1).
37 #include <asm/mach-au1x00/au1000.h>
38 #include <asm/mach-db1x00/bcsr.h>
45 int nr; /* socket number */ member
57 int stschg_irq; /* card-status-change irq */
63 #define BOARD_TYPE_DB1200 1 /* IRQs aren't gpios */
82 return sigstat & 1 << (8 + 2 * sock->nr); in db1200_card_inserted()
85 /* carddetect gpio: low-active */
88 return !gpio_get_value(sock->insert_gpio); in db1000_card_inserted()
93 switch (sock->board_type) { in db1x_card_inserted()
105 * after reset to a card has been de-asserted.
109 if (sock->stschg_irq != -1) { in set_stschg()
111 enable_irq(sock->stschg_irq); in set_stschg()
113 disable_irq(sock->stschg_irq); in set_stschg()
121 pcmcia_parse_events(&sock->socket, SS_DETECT); in db1000_pcmcia_cdirq()
130 pcmcia_parse_events(&sock->socket, SS_STSCHG); in db1000_pcmcia_stschgirq()
135 /* Db/Pb1200 have separate per-socket insertion and ejection
152 if (irq == sock->insert_irq) in db1200_pcmcia_cdirq_fn()
153 enable_irq(sock->eject_irq); in db1200_pcmcia_cdirq_fn()
155 enable_irq(sock->insert_irq); in db1200_pcmcia_cdirq_fn()
157 pcmcia_parse_events(&sock->socket, SS_DETECT); in db1200_pcmcia_cdirq_fn()
166 if (sock->stschg_irq != -1) { in db1x_pcmcia_setup_irqs()
167 ret = request_irq(sock->stschg_irq, db1000_pcmcia_stschgirq, in db1x_pcmcia_setup_irqs()
173 /* Db/Pb1200 have separate per-socket insertion and ejection in db1x_pcmcia_setup_irqs()
179 if ((sock->board_type == BOARD_TYPE_DB1200) || in db1x_pcmcia_setup_irqs()
180 (sock->board_type == BOARD_TYPE_DB1300)) { in db1x_pcmcia_setup_irqs()
181 ret = request_threaded_irq(sock->insert_irq, db1200_pcmcia_cdirq, in db1x_pcmcia_setup_irqs()
186 ret = request_threaded_irq(sock->eject_irq, db1200_pcmcia_cdirq, in db1x_pcmcia_setup_irqs()
189 free_irq(sock->insert_irq, sock); in db1x_pcmcia_setup_irqs()
195 enable_irq(sock->eject_irq); in db1x_pcmcia_setup_irqs()
197 enable_irq(sock->insert_irq); in db1x_pcmcia_setup_irqs()
200 * card detection status: use both-edge triggers. in db1x_pcmcia_setup_irqs()
202 irq_set_irq_type(sock->insert_irq, IRQ_TYPE_EDGE_BOTH); in db1x_pcmcia_setup_irqs()
203 ret = request_irq(sock->insert_irq, db1000_pcmcia_cdirq, in db1x_pcmcia_setup_irqs()
213 if (sock->stschg_irq != -1) in db1x_pcmcia_setup_irqs()
214 free_irq(sock->stschg_irq, sock); in db1x_pcmcia_setup_irqs()
221 if (sock->stschg_irq != -1) in db1x_pcmcia_free_irqs()
222 free_irq(sock->stschg_irq, sock); in db1x_pcmcia_free_irqs()
224 free_irq(sock->insert_irq, sock); in db1x_pcmcia_free_irqs()
225 if (sock->eject_irq != -1) in db1x_pcmcia_free_irqs()
226 free_irq(sock->eject_irq, sock); in db1x_pcmcia_free_irqs()
251 cr_clr = (0xf << (sock->nr * 8)); /* clear voltage settings */ in db1x_pcmcia_configure()
255 switch (state->Vcc) { in db1x_pcmcia_configure()
266 sock->nr, state->Vcc); in db1x_pcmcia_configure()
269 switch (state->Vpp) { in db1x_pcmcia_configure()
281 sock->nr, state->Vpp); in db1x_pcmcia_configure()
285 if (((state->Vcc == 33) && (state->Vpp == 50)) || in db1x_pcmcia_configure()
286 ((state->Vcc == 50) && (state->Vpp == 33))) { in db1x_pcmcia_configure()
288 sock->nr, state->Vcc, state->Vpp); in db1x_pcmcia_configure()
290 ret = -EINVAL; in db1x_pcmcia_configure()
294 if (sock->board_type != BOARD_TYPE_DB1300) in db1x_pcmcia_configure()
295 cr_set |= ((v << 2) | p) << (sock->nr * 8); in db1x_pcmcia_configure()
297 changed = state->flags ^ sock->old_flags; in db1x_pcmcia_configure()
300 if (state->flags & SS_RESET) { in db1x_pcmcia_configure()
303 cr_clr |= (1 << (7 + (sock->nr * 8))); in db1x_pcmcia_configure()
304 cr_clr |= (1 << (4 + (sock->nr * 8))); in db1x_pcmcia_configure()
306 /* de-assert reset, enable io buffers */ in db1x_pcmcia_configure()
307 cr_set |= 1 << (7 + (sock->nr * 8)); in db1x_pcmcia_configure()
308 cr_set |= 1 << (4 + (sock->nr * 8)); in db1x_pcmcia_configure()
315 sock->old_flags = state->flags; in db1x_pcmcia_configure()
318 if ((changed & SS_RESET) && !(state->flags & SS_RESET)) { in db1x_pcmcia_configure()
351 if (sock->board_type == BOARD_TYPE_PB1100) in db1x_pcmcia_get_status()
355 switch (GET_VS(sr, sock->nr)) { in db1x_pcmcia_get_status()
367 status |= GET_VCC(cr, sock->nr) ? SS_POWERON : 0; in db1x_pcmcia_get_status()
370 if ((sock->board_type == BOARD_TYPE_DB1300) && (status & SS_DETECT)) in db1x_pcmcia_get_status()
373 /* reset de-asserted? then we're ready */ in db1x_pcmcia_get_status()
374 status |= (GET_RESET(cr, sock->nr)) ? SS_READY : SS_RESET; in db1x_pcmcia_get_status()
396 map->start = (u32)sock->virt_io; in au1x00_pcmcia_set_io_map()
397 map->stop = map->start + IO_MAP_SIZE; in au1x00_pcmcia_set_io_map()
407 if (map->flags & MAP_ATTRIB) in au1x00_pcmcia_set_mem_map()
408 map->static_start = sock->phys_attr + map->card_start; in au1x00_pcmcia_set_mem_map()
410 map->static_start = sock->phys_mem + map->card_start; in au1x00_pcmcia_set_mem_map()
432 return -ENOMEM; in db1x_pcmcia_socket_probe()
434 sock->nr = pdev->id; in db1x_pcmcia_socket_probe()
441 sock->board_type = BOARD_TYPE_PB1100; in db1x_pcmcia_socket_probe()
444 sock->board_type = BOARD_TYPE_DEFAULT; in db1x_pcmcia_socket_probe()
447 sock->board_type = BOARD_TYPE_DB1200; in db1x_pcmcia_socket_probe()
450 sock->board_type = BOARD_TYPE_DB1300; in db1x_pcmcia_socket_probe()
453 printk(KERN_INFO "db1xxx-ss: unknown board %d!\n", bid); in db1x_pcmcia_socket_probe()
454 ret = -ENODEV; in db1x_pcmcia_socket_probe()
459 * gather resources necessary and optional nice-to-haves to in db1x_pcmcia_socket_probe()
470 sock->card_irq = r ? r->start : 0; in db1x_pcmcia_socket_probe()
476 sock->insert_irq = r ? r->start : -1; in db1x_pcmcia_socket_probe()
477 if (sock->board_type == BOARD_TYPE_DEFAULT) { in db1x_pcmcia_socket_probe()
478 sock->insert_gpio = r ? r->start : -1; in db1x_pcmcia_socket_probe()
479 sock->insert_irq = r ? gpio_to_irq(r->start) : -1; in db1x_pcmcia_socket_probe()
484 sock->stschg_irq = r ? r->start : -1; in db1x_pcmcia_socket_probe()
488 sock->eject_irq = r ? r->start : -1; in db1x_pcmcia_socket_probe()
490 ret = -ENODEV; in db1x_pcmcia_socket_probe()
493 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pcmcia-attr"); in db1x_pcmcia_socket_probe()
495 printk(KERN_ERR "pcmcia%d has no 'pseudo-attr' resource!\n", in db1x_pcmcia_socket_probe()
496 sock->nr); in db1x_pcmcia_socket_probe()
499 sock->phys_attr = r->start; in db1x_pcmcia_socket_probe()
502 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pcmcia-mem"); in db1x_pcmcia_socket_probe()
504 printk(KERN_ERR "pcmcia%d has no 'pseudo-mem' resource!\n", in db1x_pcmcia_socket_probe()
505 sock->nr); in db1x_pcmcia_socket_probe()
508 sock->phys_mem = r->start; in db1x_pcmcia_socket_probe()
511 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pcmcia-io"); in db1x_pcmcia_socket_probe()
513 printk(KERN_ERR "pcmcia%d has no 'pseudo-io' resource!\n", in db1x_pcmcia_socket_probe()
514 sock->nr); in db1x_pcmcia_socket_probe()
517 sock->phys_io = r->start; in db1x_pcmcia_socket_probe()
527 sock->virt_io = (void *)(ioremap(sock->phys_io, IO_MAP_SIZE) - in db1x_pcmcia_socket_probe()
530 if (!sock->virt_io) { in db1x_pcmcia_socket_probe()
532 sock->nr); in db1x_pcmcia_socket_probe()
533 ret = -ENOMEM; in db1x_pcmcia_socket_probe()
537 sock->socket.ops = &db1x_pcmcia_operations; in db1x_pcmcia_socket_probe()
538 sock->socket.owner = THIS_MODULE; in db1x_pcmcia_socket_probe()
539 sock->socket.pci_irq = sock->card_irq; in db1x_pcmcia_socket_probe()
540 sock->socket.features = SS_CAP_STATIC_MAP | SS_CAP_PCCARD; in db1x_pcmcia_socket_probe()
541 sock->socket.map_size = MEM_MAP_SIZE; in db1x_pcmcia_socket_probe()
542 sock->socket.io_offset = (unsigned long)sock->virt_io; in db1x_pcmcia_socket_probe()
543 sock->socket.dev.parent = &pdev->dev; in db1x_pcmcia_socket_probe()
544 sock->socket.resource_ops = &pccard_static_ops; in db1x_pcmcia_socket_probe()
551 sock->nr); in db1x_pcmcia_socket_probe()
557 ret = pcmcia_register_socket(&sock->socket); in db1x_pcmcia_socket_probe()
559 printk(KERN_ERR "pcmcia%d failed to register\n", sock->nr); in db1x_pcmcia_socket_probe()
565 "%d %d %d\n", sock->nr, sock->phys_io, sock->virt_io, in db1x_pcmcia_socket_probe()
566 sock->phys_attr, sock->phys_mem, sock->card_irq, in db1x_pcmcia_socket_probe()
567 sock->insert_irq, sock->stschg_irq, sock->eject_irq); in db1x_pcmcia_socket_probe()
574 iounmap((void *)(sock->virt_io + (u32)mips_io_port_base)); in db1x_pcmcia_socket_probe()
585 pcmcia_unregister_socket(&sock->socket); in db1x_pcmcia_socket_remove()
586 iounmap((void *)(sock->virt_io + (u32)mips_io_port_base)); in db1x_pcmcia_socket_remove()