Lines Matching +full:fiq +full:- +full:index
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright 1995-2001 Russell King
11 * 08-Dec-1996 RMK Added code for the 9'th expansion card - the ether
13 * 06-May-1997 RMK Added blacklist for cards whose loader doesn't work.
14 * 12-Sep-1997 RMK Created new handling of interrupt enables/disables
15 * - cards can now register their own routine to control
17 * 29-Sep-1997 RMK Expansion card interrupt hardware not being re-enabled
20 * 15-Feb-1998 RMK Added DMA support
21 * 12-Sep-1998 RMK Added EASI support
22 * 10-Jan-1999 RMK Run loaders in a simulated RISC OS environment.
23 * 17-Apr-1999 RMK Support for EASI Type C cycles.
121 struct expansion_card *ec = req->ec; in ecard_task_reset()
124 res = ec->slot_no == 8 in ecard_task_reset()
125 ? &ec->resource[ECARD_RES_MEMC] in ecard_task_reset()
126 : ec->easi in ecard_task_reset()
127 ? &ec->resource[ECARD_RES_EASI] in ecard_task_reset()
128 : &ec->resource[ECARD_RES_IOCSYNC]; in ecard_task_reset()
130 ecard_loader_reset(res->start, ec->loader); in ecard_task_reset()
135 struct expansion_card *ec = req->ec; in ecard_task_readbytes()
136 unsigned char *buf = req->buffer; in ecard_task_readbytes()
137 unsigned int len = req->length; in ecard_task_readbytes()
138 unsigned int off = req->address; in ecard_task_readbytes()
140 if (ec->slot_no == 8) { in ecard_task_readbytes()
142 ec->resource[ECARD_RES_MEMC].start; in ecard_task_readbytes()
145 * The card maintains an index which increments the address in ecard_task_readbytes()
146 * into a 4096-byte page on each access. We need to keep in ecard_task_readbytes()
149 static unsigned int index; in ecard_task_readbytes() local
159 * If we are reading offset 0, or our current index is in ecard_task_readbytes()
160 * greater than the offset, reset the hardware index counter. in ecard_task_readbytes()
162 if (off == 0 || index > off) { in ecard_task_readbytes()
164 index = 0; in ecard_task_readbytes()
168 * Increment the hardware index counter until we get to the in ecard_task_readbytes()
171 while (index < off) { in ecard_task_readbytes()
173 index += 1; in ecard_task_readbytes()
176 while (len--) { in ecard_task_readbytes()
178 index += 1; in ecard_task_readbytes()
181 unsigned long base = (ec->easi in ecard_task_readbytes()
182 ? &ec->resource[ECARD_RES_EASI] in ecard_task_readbytes()
183 : &ec->resource[ECARD_RES_IOCSYNC])->start; in ecard_task_readbytes()
186 if (!req->use_loader || !ec->loader) { in ecard_task_readbytes()
188 while (len--) { in ecard_task_readbytes()
193 while(len--) { in ecard_task_readbytes()
200 ec->loader); in ecard_task_readbytes()
248 struct mm_struct *active_mm = current->active_mm; in ecard_init_mm()
251 return -ENOMEM; in ecard_init_mm()
253 current->mm = mm; in ecard_init_mm()
254 current->active_mm = mm; in ecard_init_mm()
265 * Allocate a mm. We're not a lazy-TLB kernel task since we need in ecard_task()
280 req->fn(req); in ecard_task()
281 complete(req->complete); in ecard_task()
296 req->complete = &completion; in ecard_call()
309 /* ======================= Mid-level card control ===================== */
329 int index = 16; in ecard_readchunk() local
332 if (!ec->cid.cd) in ecard_readchunk()
336 ecard_readbytes(&excd, ec, index, 8, useld); in ecard_readchunk()
337 index += 8; in ecard_readchunk()
339 if (!useld && ec->loader) { in ecard_readchunk()
341 index = 0; in ecard_readchunk()
347 index = c_start(&excd); in ecard_readchunk()
351 if (!ec->loader) { in ecard_readchunk()
352 ec->loader = kmalloc(c_len(&excd), in ecard_readchunk()
354 if (ec->loader) in ecard_readchunk()
355 ecard_readbytes(ec->loader, ec, in ecard_readchunk()
363 if (c_id(&excd) == id && num-- == 0) in ecard_readchunk()
378 cd->start_offset = c_start(&excd); in ecard_readchunk()
379 memcpy(cd->d.string, excd.d.string, 256); in ecard_readchunk()
395 return !ec->irqmask || readb(ec->irqaddr) & ec->irqmask; in ecard_def_irq_pending()
400 panic("ecard_def_fiq_enable called - impossible"); in ecard_def_fiq_enable()
405 panic("ecard_def_fiq_disable called - impossible"); in ecard_def_fiq_disable()
410 return !ec->fiqmask || readb(ec->fiqaddr) & ec->fiqmask; in ecard_def_fiq_pending()
433 if (!ec->ops) in ecard_irq_unmask()
434 ec->ops = &ecard_default_ops; in ecard_irq_unmask()
436 if (ec->claimed && ec->ops->irqenable) in ecard_irq_unmask()
437 ec->ops->irqenable(ec, d->irq); in ecard_irq_unmask()
440 "enable IRQs for %d\n", d->irq); in ecard_irq_unmask()
449 if (!ec->ops) in ecard_irq_mask()
450 ec->ops = &ecard_default_ops; in ecard_irq_mask()
452 if (ec->ops && ec->ops->irqdisable) in ecard_irq_mask()
453 ec->ops->irqdisable(ec, d->irq); in ecard_irq_mask()
469 if (!ec->ops) in ecard_enablefiq()
470 ec->ops = &ecard_default_ops; in ecard_enablefiq()
472 if (ec->claimed && ec->ops->fiqenable) in ecard_enablefiq()
473 ec->ops->fiqenable(ec, fiqnr); in ecard_enablefiq()
485 if (!ec->ops) in ecard_disablefiq()
486 ec->ops = &ecard_default_ops; in ecard_disablefiq()
488 if (ec->ops->fiqdisable) in ecard_disablefiq()
489 ec->ops->fiqdisable(ec, fiqnr); in ecard_disablefiq()
499 for (ec = cards; ec; ec = ec->next) { in ecard_dump_irq_state()
502 if (ec->slot_no == 8) in ecard_dump_irq_state()
505 claimed = ec->claimed ? "" : "not "; in ecard_dump_irq_state()
507 if (ec->ops && ec->ops->irqpending && in ecard_dump_irq_state()
508 ec->ops != &ecard_default_ops) in ecard_dump_irq_state()
510 ec->slot_no, claimed, in ecard_dump_irq_state()
511 ec->ops->irqpending(ec) ? "" : "not "); in ecard_dump_irq_state()
514 ec->slot_no, claimed, in ecard_dump_irq_state()
515 ec->irqaddr, ec->irqmask, readb(ec->irqaddr)); in ecard_dump_irq_state()
530 * Maybe we ought to start a timer to re-enable them some time in ecard_check_lockup()
536 printk(KERN_ERR "\nInterrupt lockup detected - " in ecard_check_lockup()
539 desc->irq_data.chip->irq_mask(&desc->irq_data); in ecard_check_lockup()
561 desc->irq_data.chip->irq_mask(&desc->irq_data); in ecard_irq_handler()
562 for (ec = cards; ec; ec = ec->next) { in ecard_irq_handler()
565 if (!ec->claimed || !ec->irq || ec->slot_no == 8) in ecard_irq_handler()
568 if (ec->ops && ec->ops->irqpending) in ecard_irq_handler()
569 pending = ec->ops->irqpending(ec); in ecard_irq_handler()
574 generic_handle_irq(ec->irq); in ecard_irq_handler()
578 desc->irq_data.chip->irq_unmask(&desc->irq_data); in ecard_irq_handler()
587 int slot = ec->slot_no; in __ecard_address()
589 if (ec->slot_no == 8) in __ecard_address()
604 address = ECARD_IOC4_BASE + ((slot - 4) << 14); in __ecard_address()
627 seq_printf(m, " %d: %s ", ec->slot_no, ec->easi ? "EASI" : " "); in ecard_prints()
629 if (ec->cid.id == 0) { in ecard_prints()
633 ec->cid.manufacturer, ec->cid.product); in ecard_prints()
635 if (!ec->card_desc && ec->cid.cd && in ecard_prints()
637 ec->card_desc = kmalloc(strlen(incd.d.string)+1, GFP_KERNEL); in ecard_prints()
639 if (ec->card_desc) in ecard_prints()
640 strcpy((char *)ec->card_desc, incd.d.string); in ecard_prints()
643 seq_printf(m, "%s\n", ec->card_desc ? ec->card_desc : "*unknown*"); in ecard_prints()
645 seq_printf(m, "Simple card %d\n", ec->cid.id); in ecard_prints()
656 ec = ec->next; in ecard_devices_proc_show()
672 (ec)->resource[nr].name = dev_name(&ec->dev); \
673 (ec)->resource[nr].start = st; \
674 (ec)->resource[nr].end = (st) + (sz) - 1; \
675 (ec)->resource[nr].flags = IORESOURCE_MEM; \
683 if (ec->resource[i].flags) in ecard_free_card()
684 release_resource(&ec->resource[i]); in ecard_free_card()
697 ec = ERR_PTR(-ENOMEM); in ecard_alloc_card()
701 ec->slot_no = slot; in ecard_alloc_card()
702 ec->easi = type == ECARD_EASI; in ecard_alloc_card()
703 ec->irq = 0; in ecard_alloc_card()
704 ec->fiq = 0; in ecard_alloc_card()
705 ec->dma = NO_DMA; in ecard_alloc_card()
706 ec->ops = &ecard_default_ops; in ecard_alloc_card()
708 dev_set_name(&ec->dev, "ecard%d", slot); in ecard_alloc_card()
709 ec->dev.parent = NULL; in ecard_alloc_card()
710 ec->dev.bus = &ecard_bus_type; in ecard_alloc_card()
711 ec->dev.dma_mask = &ec->dma_mask; in ecard_alloc_card()
712 ec->dma_mask = (u64)0xffffffff; in ecard_alloc_card()
713 ec->dev.coherent_dma_mask = ec->dma_mask; in ecard_alloc_card()
721 base = PODSLOT_IOC4_BASE + ((slot - 4) << 14); in ecard_alloc_card()
735 for (i = 0; i <= ECARD_RES_IOCSYNC - ECARD_RES_IOCSLOW; i++) in ecard_alloc_card()
740 if (ec->resource[i].flags && in ecard_alloc_card()
741 request_resource(&iomem_resource, &ec->resource[i])) { in ecard_alloc_card()
742 dev_err(&ec->dev, "resource(s) not available\n"); in ecard_alloc_card()
743 ec->resource[i].end -= ec->resource[i].start; in ecard_alloc_card()
744 ec->resource[i].start = 0; in ecard_alloc_card()
745 ec->resource[i].flags = 0; in ecard_alloc_card()
756 return sprintf(buf, "%u\n", ec->irq); in irq_show()
763 return sprintf(buf, "%u\n", ec->dma); in dma_show()
775 ec->resource[i].start, in resource_show()
776 ec->resource[i].end, in resource_show()
777 ec->resource[i].flags); in resource_show()
779 return str - buf; in resource_show()
786 return sprintf(buf, "%u\n", ec->cid.manufacturer); in vendor_show()
793 return sprintf(buf, "%u\n", ec->cid.product); in device_show()
800 return sprintf(buf, "%s\n", ec->easi ? "EASI" : "IOC"); in type_show()
823 ec->dev.driver->name)) { in ecard_request_resources()
824 err = -EBUSY; in ecard_request_resources()
830 while (i--) in ecard_request_resources()
852 ec->irq_data = irq_data; in ecard_setirq()
854 ec->ops = ops; in ecard_setirq()
864 if (offset > (end - start)) in ecardm_iomap()
868 if (maxsize && end - start > maxsize) in ecardm_iomap()
871 return devm_ioremap(&ec->dev, start, end - start); in ecardm_iomap()
905 rc = -ENODEV; in ecard_probe()
914 ec->cid.id = cid.r_id; in ecard_probe()
915 ec->cid.cd = cid.r_cd; in ecard_probe()
916 ec->cid.is = cid.r_is; in ecard_probe()
917 ec->cid.w = cid.r_w; in ecard_probe()
918 ec->cid.manufacturer = ecard_getu16(cid.r_manu); in ecard_probe()
919 ec->cid.product = ecard_getu16(cid.r_prod); in ecard_probe()
920 ec->cid.country = cid.r_country; in ecard_probe()
921 ec->cid.irqmask = cid.r_irqmask; in ecard_probe()
922 ec->cid.irqoff = ecard_gets24(cid.r_irqoff); in ecard_probe()
923 ec->cid.fiqmask = cid.r_fiqmask; in ecard_probe()
924 ec->cid.fiqoff = ecard_gets24(cid.r_fiqoff); in ecard_probe()
925 ec->fiqaddr = in ecard_probe()
926 ec->irqaddr = addr; in ecard_probe()
928 if (ec->cid.is) { in ecard_probe()
929 ec->irqmask = ec->cid.irqmask; in ecard_probe()
930 ec->irqaddr += ec->cid.irqoff; in ecard_probe()
931 ec->fiqmask = ec->cid.fiqmask; in ecard_probe()
932 ec->fiqaddr += ec->cid.fiqoff; in ecard_probe()
934 ec->irqmask = 1; in ecard_probe()
935 ec->fiqmask = 4; in ecard_probe()
939 if (quirklist[i].manufacturer == ec->cid.manufacturer && in ecard_probe()
940 quirklist[i].product == ec->cid.product) { in ecard_probe()
942 ec->card_desc = quirklist[i].type; in ecard_probe()
948 ec->irq = irq; in ecard_probe()
954 irq_set_chip_and_handler(ec->irq, &ecard_chip, in ecard_probe()
956 irq_set_chip_data(ec->irq, ec); in ecard_probe()
957 irq_clear_status_flags(ec->irq, IRQ_NOREQUEST); in ecard_probe()
963 ec->dma = 2 + slot; in ecard_probe()
966 for (ecp = &cards; *ecp; ecp = &(*ecp)->next); in ecard_probe()
971 rc = device_register(&ec->dev); in ecard_probe()
985 * Locate all hardware - interrupt management and
993 irqbase = irq_alloc_descs(-1, 0, 8, -1); in ecard_init()
1008 if (ecard_probe(slot, irqbase + slot, ECARD_EASI) == -ENODEV) in ecard_init()
1032 if (ec->cid.manufacturer == ids[i].manufacturer && in ecard_match_device()
1033 ec->cid.product == ids[i].product) in ecard_match_device()
1042 struct ecard_driver *drv = ECARD_DRV(dev->driver); in ecard_drv_probe()
1046 id = ecard_match_device(drv->id_table, ec); in ecard_drv_probe()
1048 ec->claimed = 1; in ecard_drv_probe()
1049 ret = drv->probe(ec, id); in ecard_drv_probe()
1051 ec->claimed = 0; in ecard_drv_probe()
1058 struct ecard_driver *drv = ECARD_DRV(dev->driver); in ecard_drv_remove()
1060 drv->remove(ec); in ecard_drv_remove()
1061 ec->claimed = 0; in ecard_drv_remove()
1067 ec->ops = &ecard_default_ops; in ecard_drv_remove()
1069 ec->irq_data = NULL; in ecard_drv_remove()
1074 * sensible state, so it can be re-detected. This means that the first
1081 struct ecard_driver *drv = ECARD_DRV(dev->driver); in ecard_drv_shutdown()
1084 if (dev->driver) { in ecard_drv_shutdown()
1085 if (drv->shutdown) in ecard_drv_shutdown()
1086 drv->shutdown(ec); in ecard_drv_shutdown()
1087 ec->claimed = 0; in ecard_drv_shutdown()
1093 if (ec->loader) { in ecard_drv_shutdown()
1102 drv->drv.bus = &ecard_bus_type; in ecard_register_driver()
1104 return driver_register(&drv->drv); in ecard_register_driver()
1109 driver_unregister(&drv->drv); in ecard_remove_driver()
1118 if (drv->id_table) { in ecard_match()
1119 ret = ecard_match_device(drv->id_table, ec) != NULL; in ecard_match()
1121 ret = ec->cid.id == drv->id; in ecard_match()