Lines Matching +full:board +full:- +full:control

1 // SPDX-License-Identifier: GPL-2.0
3 * ESP front-end for Amiga ZORRO SCSI systems.
24 * Rewritten to use 53c700.c by Kars de Jong <jongk@linux-m68k.org>
32 #include <linux/dma-mapping.h>
55 /* per-board register layout definitions */
76 unsigned char dma_led_ctrl; /* DMA led control [0x000] */
87 /* DMA control bits */
102 #define ctrl_reg cond_reg /* DMA control (wo) [0x402] */
105 /* DMA control bits */
115 #define ctrl_reg cond_reg /* DMA control (wo) [0x000] */
130 #define ctrl_reg cond_reg /* DMA control (wo) [0x0000] */
146 /* DMA control bits */
158 struct esp *esp; /* our ESP instance - for Scsi_host* */
159 void __iomem *board_base; /* virtual address (Zorro III board) */
160 int zorro3; /* board is Zorro III */
167 * On Oktagon, it is one byte - use a different accessor there.
169 * Oktagon needs PDMA - currently unsupported!
174 writeb(val, esp->regs + (reg * 4UL)); in zorro_esp_write8()
179 return readb(esp->regs + (reg * 4UL)); in zorro_esp_read8()
193 struct cyber_dma_registers __iomem *dregs = esp->dma_regs; in cyber_esp_irq_pending()
194 unsigned char dma_status = readb(&dregs->cond_reg); in cyber_esp_irq_pending()
203 struct fastlane_dma_registers __iomem *dregs = esp->dma_regs; in fastlane_esp_irq_pending()
206 dma_status = readb(&dregs->cond_reg); in fastlane_esp_irq_pending()
211 /* Return non-zero if ESP requested IRQ */ in fastlane_esp_irq_pending()
248 struct zorro_esp_priv *zep = dev_get_drvdata(esp->dev); in fastlane_esp_dma_invalidate()
249 struct fastlane_dma_registers __iomem *dregs = esp->dma_regs; in fastlane_esp_dma_invalidate()
250 unsigned char *ctrl_data = &zep->ctrl_data; in fastlane_esp_dma_invalidate()
253 writeb(0, &dregs->clear_strobe); in fastlane_esp_dma_invalidate()
254 z_writel(0, zep->board_base); in fastlane_esp_dma_invalidate()
257 /* Blizzard 1230/60 SCSI-IV DMA */
262 struct blz1230_dma_registers __iomem *dregs = esp->dma_regs; in zorro_esp_send_blz1230_dma_cmd()
263 u8 phase = esp->sreg & ESP_STAT_PMASK; in zorro_esp_send_blz1230_dma_cmd()
266 * Use PIO if transferring message bytes to esp->command_block_dma. in zorro_esp_send_blz1230_dma_cmd()
267 * PIO requires a virtual address, so substitute esp->command_block in zorro_esp_send_blz1230_dma_cmd()
270 if (phase == ESP_MIP && addr == esp->command_block_dma) { in zorro_esp_send_blz1230_dma_cmd()
271 esp_send_pio_cmd(esp, (u32)esp->command_block, esp_count, in zorro_esp_send_blz1230_dma_cmd()
276 /* Clear the results of a possible prior esp->ops->send_dma_cmd() */ in zorro_esp_send_blz1230_dma_cmd()
277 esp->send_cmd_error = 0; in zorro_esp_send_blz1230_dma_cmd()
278 esp->send_cmd_residual = 0; in zorro_esp_send_blz1230_dma_cmd()
282 dma_sync_single_for_device(esp->dev, addr, esp_count, in zorro_esp_send_blz1230_dma_cmd()
286 dma_sync_single_for_device(esp->dev, addr, esp_count, in zorro_esp_send_blz1230_dma_cmd()
295 writeb((addr >> 24) & 0xff, &dregs->dma_latch); in zorro_esp_send_blz1230_dma_cmd()
296 writeb((addr >> 24) & 0xff, &dregs->dma_addr); in zorro_esp_send_blz1230_dma_cmd()
297 writeb((addr >> 16) & 0xff, &dregs->dma_addr); in zorro_esp_send_blz1230_dma_cmd()
298 writeb((addr >> 8) & 0xff, &dregs->dma_addr); in zorro_esp_send_blz1230_dma_cmd()
299 writeb(addr & 0xff, &dregs->dma_addr); in zorro_esp_send_blz1230_dma_cmd()
308 /* Blizzard 1230-II DMA */
313 struct blz1230II_dma_registers __iomem *dregs = esp->dma_regs; in zorro_esp_send_blz1230II_dma_cmd()
314 u8 phase = esp->sreg & ESP_STAT_PMASK; in zorro_esp_send_blz1230II_dma_cmd()
316 /* Use PIO if transferring message bytes to esp->command_block_dma */ in zorro_esp_send_blz1230II_dma_cmd()
317 if (phase == ESP_MIP && addr == esp->command_block_dma) { in zorro_esp_send_blz1230II_dma_cmd()
318 esp_send_pio_cmd(esp, (u32)esp->command_block, esp_count, in zorro_esp_send_blz1230II_dma_cmd()
323 esp->send_cmd_error = 0; in zorro_esp_send_blz1230II_dma_cmd()
324 esp->send_cmd_residual = 0; in zorro_esp_send_blz1230II_dma_cmd()
328 dma_sync_single_for_device(esp->dev, addr, esp_count, in zorro_esp_send_blz1230II_dma_cmd()
332 dma_sync_single_for_device(esp->dev, addr, esp_count, in zorro_esp_send_blz1230II_dma_cmd()
341 writeb((addr >> 24) & 0xff, &dregs->dma_latch); in zorro_esp_send_blz1230II_dma_cmd()
342 writeb((addr >> 16) & 0xff, &dregs->dma_addr); in zorro_esp_send_blz1230II_dma_cmd()
343 writeb((addr >> 8) & 0xff, &dregs->dma_addr); in zorro_esp_send_blz1230II_dma_cmd()
344 writeb(addr & 0xff, &dregs->dma_addr); in zorro_esp_send_blz1230II_dma_cmd()
358 struct blz2060_dma_registers __iomem *dregs = esp->dma_regs; in zorro_esp_send_blz2060_dma_cmd()
359 u8 phase = esp->sreg & ESP_STAT_PMASK; in zorro_esp_send_blz2060_dma_cmd()
361 /* Use PIO if transferring message bytes to esp->command_block_dma */ in zorro_esp_send_blz2060_dma_cmd()
362 if (phase == ESP_MIP && addr == esp->command_block_dma) { in zorro_esp_send_blz2060_dma_cmd()
363 esp_send_pio_cmd(esp, (u32)esp->command_block, esp_count, in zorro_esp_send_blz2060_dma_cmd()
368 esp->send_cmd_error = 0; in zorro_esp_send_blz2060_dma_cmd()
369 esp->send_cmd_residual = 0; in zorro_esp_send_blz2060_dma_cmd()
373 dma_sync_single_for_device(esp->dev, addr, esp_count, in zorro_esp_send_blz2060_dma_cmd()
377 dma_sync_single_for_device(esp->dev, addr, esp_count, in zorro_esp_send_blz2060_dma_cmd()
386 writeb(addr & 0xff, &dregs->dma_addr3); in zorro_esp_send_blz2060_dma_cmd()
387 writeb((addr >> 8) & 0xff, &dregs->dma_addr2); in zorro_esp_send_blz2060_dma_cmd()
388 writeb((addr >> 16) & 0xff, &dregs->dma_addr1); in zorro_esp_send_blz2060_dma_cmd()
389 writeb((addr >> 24) & 0xff, &dregs->dma_addr0); in zorro_esp_send_blz2060_dma_cmd()
403 struct zorro_esp_priv *zep = dev_get_drvdata(esp->dev); in zorro_esp_send_cyber_dma_cmd()
404 struct cyber_dma_registers __iomem *dregs = esp->dma_regs; in zorro_esp_send_cyber_dma_cmd()
405 u8 phase = esp->sreg & ESP_STAT_PMASK; in zorro_esp_send_cyber_dma_cmd()
406 unsigned char *ctrl_data = &zep->ctrl_data; in zorro_esp_send_cyber_dma_cmd()
408 /* Use PIO if transferring message bytes to esp->command_block_dma */ in zorro_esp_send_cyber_dma_cmd()
409 if (phase == ESP_MIP && addr == esp->command_block_dma) { in zorro_esp_send_cyber_dma_cmd()
410 esp_send_pio_cmd(esp, (u32)esp->command_block, esp_count, in zorro_esp_send_cyber_dma_cmd()
415 esp->send_cmd_error = 0; in zorro_esp_send_cyber_dma_cmd()
416 esp->send_cmd_residual = 0; in zorro_esp_send_cyber_dma_cmd()
423 dma_sync_single_for_device(esp->dev, addr, esp_count, in zorro_esp_send_cyber_dma_cmd()
428 dma_sync_single_for_device(esp->dev, addr, esp_count, in zorro_esp_send_cyber_dma_cmd()
433 writeb((addr >> 24) & 0xff, &dregs->dma_addr0); in zorro_esp_send_cyber_dma_cmd()
434 writeb((addr >> 16) & 0xff, &dregs->dma_addr1); in zorro_esp_send_cyber_dma_cmd()
435 writeb((addr >> 8) & 0xff, &dregs->dma_addr2); in zorro_esp_send_cyber_dma_cmd()
436 writeb(addr & 0xff, &dregs->dma_addr3); in zorro_esp_send_cyber_dma_cmd()
445 writeb(*ctrl_data, &dregs->ctrl_reg); in zorro_esp_send_cyber_dma_cmd()
455 struct cyberII_dma_registers __iomem *dregs = esp->dma_regs; in zorro_esp_send_cyberII_dma_cmd()
456 u8 phase = esp->sreg & ESP_STAT_PMASK; in zorro_esp_send_cyberII_dma_cmd()
458 /* Use PIO if transferring message bytes to esp->command_block_dma */ in zorro_esp_send_cyberII_dma_cmd()
459 if (phase == ESP_MIP && addr == esp->command_block_dma) { in zorro_esp_send_cyberII_dma_cmd()
460 esp_send_pio_cmd(esp, (u32)esp->command_block, esp_count, in zorro_esp_send_cyberII_dma_cmd()
465 esp->send_cmd_error = 0; in zorro_esp_send_cyberII_dma_cmd()
466 esp->send_cmd_residual = 0; in zorro_esp_send_cyberII_dma_cmd()
473 dma_sync_single_for_device(esp->dev, addr, esp_count, in zorro_esp_send_cyberII_dma_cmd()
478 dma_sync_single_for_device(esp->dev, addr, esp_count, in zorro_esp_send_cyberII_dma_cmd()
483 writeb((addr >> 24) & 0xff, &dregs->dma_addr0); in zorro_esp_send_cyberII_dma_cmd()
484 writeb((addr >> 16) & 0xff, &dregs->dma_addr1); in zorro_esp_send_cyberII_dma_cmd()
485 writeb((addr >> 8) & 0xff, &dregs->dma_addr2); in zorro_esp_send_cyberII_dma_cmd()
486 writeb(addr & 0xff, &dregs->dma_addr3); in zorro_esp_send_cyberII_dma_cmd()
496 struct zorro_esp_priv *zep = dev_get_drvdata(esp->dev); in zorro_esp_send_fastlane_dma_cmd()
497 struct fastlane_dma_registers __iomem *dregs = esp->dma_regs; in zorro_esp_send_fastlane_dma_cmd()
498 u8 phase = esp->sreg & ESP_STAT_PMASK; in zorro_esp_send_fastlane_dma_cmd()
499 unsigned char *ctrl_data = &zep->ctrl_data; in zorro_esp_send_fastlane_dma_cmd()
501 /* Use PIO if transferring message bytes to esp->command_block_dma */ in zorro_esp_send_fastlane_dma_cmd()
502 if (phase == ESP_MIP && addr == esp->command_block_dma) { in zorro_esp_send_fastlane_dma_cmd()
503 esp_send_pio_cmd(esp, (u32)esp->command_block, esp_count, in zorro_esp_send_fastlane_dma_cmd()
508 esp->send_cmd_error = 0; in zorro_esp_send_fastlane_dma_cmd()
509 esp->send_cmd_residual = 0; in zorro_esp_send_fastlane_dma_cmd()
516 dma_sync_single_for_device(esp->dev, addr, esp_count, in zorro_esp_send_fastlane_dma_cmd()
521 dma_sync_single_for_device(esp->dev, addr, esp_count, in zorro_esp_send_fastlane_dma_cmd()
526 writeb(0, &dregs->clear_strobe); in zorro_esp_send_fastlane_dma_cmd()
527 z_writel(addr, ((addr & 0x00ffffff) + zep->board_base)); in zorro_esp_send_fastlane_dma_cmd()
538 writeb(*ctrl_data, &dregs->ctrl_reg); in zorro_esp_send_fastlane_dma_cmd()
545 return esp->send_cmd_error; in zorro_esp_dma_error()
548 /* per-board ESP driver ops */
633 /* board types */
644 /* per-board config data */
721 unsigned long board, ioaddr, dmaaddr; in zorro_esp_probe() local
724 board = zorro_resource_start(z); in zorro_esp_probe()
725 zdd = &zorro_esp_boards[ent->driver_data]; in zorro_esp_probe()
727 pr_info("%s found at address 0x%lx.\n", zdd->name, board); in zorro_esp_probe()
732 return -ENOMEM; in zorro_esp_probe()
735 /* let's figure out whether we have a Zorro II or Zorro III board */ in zorro_esp_probe()
736 if ((z->rom.er_Type & ERT_TYPEMASK) == ERT_ZORROIII) { in zorro_esp_probe()
737 if (board > 0xffffff) in zorro_esp_probe()
738 zep->zorro3 = 1; in zorro_esp_probe()
745 z->dev.coherent_dma_mask = DMA_BIT_MASK(32); in zorro_esp_probe()
750 * contains data for the Blizzard 1230 II board which does share the in zorro_esp_probe()
756 if (zep->zorro3 && ent->driver_data == ZORRO_BLZ1230II) { in zorro_esp_probe()
758 zdd->name, board); in zorro_esp_probe()
762 if (zdd->absolute) { in zorro_esp_probe()
763 ioaddr = zdd->offset; in zorro_esp_probe()
764 dmaaddr = zdd->dma_offset; in zorro_esp_probe()
766 ioaddr = board + zdd->offset; in zorro_esp_probe()
767 dmaaddr = board + zdd->dma_offset; in zorro_esp_probe()
770 if (!zorro_request_device(z, zdd->name)) { in zorro_esp_probe()
772 board); in zorro_esp_probe()
773 err = -EBUSY; in zorro_esp_probe()
780 pr_err("No host detected; board configuration problem?\n"); in zorro_esp_probe()
781 err = -ENOMEM; in zorro_esp_probe()
785 host->base = ioaddr; in zorro_esp_probe()
786 host->this_id = 7; in zorro_esp_probe()
789 esp->host = host; in zorro_esp_probe()
790 esp->dev = &z->dev; in zorro_esp_probe()
792 esp->scsi_id = host->this_id; in zorro_esp_probe()
793 esp->scsi_id_mask = (1 << esp->scsi_id); in zorro_esp_probe()
795 esp->cfreq = 40000000; in zorro_esp_probe()
797 zep->esp = esp; in zorro_esp_probe()
799 dev_set_drvdata(esp->dev, zep); in zorro_esp_probe()
802 if (zep->zorro3 && ent->driver_data == ZORRO_BLZ1230II) { in zorro_esp_probe()
804 zep->board_base = ioremap(board, FASTLANE_ESP_ADDR - 1); in zorro_esp_probe()
805 if (!zep->board_base) { in zorro_esp_probe()
806 pr_err("Cannot allocate board address space\n"); in zorro_esp_probe()
807 err = -ENOMEM; in zorro_esp_probe()
810 /* initialize DMA control shadow register */ in zorro_esp_probe()
811 zep->ctrl_data = (FASTLANE_DMA_FCODE | in zorro_esp_probe()
815 esp->ops = zdd->esp_ops; in zorro_esp_probe()
818 esp->regs = ioremap(ioaddr, 0x20); in zorro_esp_probe()
821 esp->regs = ZTWO_VADDR(ioaddr); in zorro_esp_probe()
823 if (!esp->regs) { in zorro_esp_probe()
824 err = -ENOMEM; in zorro_esp_probe()
828 esp->fifo_reg = esp->regs + ESP_FDATA * 4; in zorro_esp_probe()
831 if (zdd->scsi_option) { in zorro_esp_probe()
834 err = -ENODEV; in zorro_esp_probe()
839 if (zep->zorro3) { in zorro_esp_probe()
841 * Only Fastlane Z3 for now - add switch for correct struct in zorro_esp_probe()
844 esp->dma_regs = ioremap(dmaaddr, in zorro_esp_probe()
848 esp->dma_regs = ZTWO_VADDR(dmaaddr); in zorro_esp_probe()
850 if (!esp->dma_regs) { in zorro_esp_probe()
851 err = -ENOMEM; in zorro_esp_probe()
855 esp->command_block = dma_alloc_coherent(esp->dev, 16, in zorro_esp_probe()
856 &esp->command_block_dma, in zorro_esp_probe()
859 if (!esp->command_block) { in zorro_esp_probe()
860 err = -ENOMEM; in zorro_esp_probe()
864 host->irq = IRQ_AMIGA_PORTS; in zorro_esp_probe()
865 err = request_irq(host->irq, scsi_esp_intr, IRQF_SHARED, in zorro_esp_probe()
868 err = -ENODEV; in zorro_esp_probe()
876 err = -ENOMEM; in zorro_esp_probe()
883 free_irq(host->irq, esp); in zorro_esp_probe()
886 dma_free_coherent(esp->dev, 16, in zorro_esp_probe()
887 esp->command_block, in zorro_esp_probe()
888 esp->command_block_dma); in zorro_esp_probe()
891 if (zep->zorro3) in zorro_esp_probe()
892 iounmap(esp->dma_regs); in zorro_esp_probe()
896 iounmap(esp->regs); in zorro_esp_probe()
899 if (zep->zorro3) in zorro_esp_probe()
900 iounmap(zep->board_base); in zorro_esp_probe()
916 struct zorro_esp_priv *zep = dev_get_drvdata(&z->dev); in zorro_esp_remove()
917 struct esp *esp = zep->esp; in zorro_esp_remove()
918 struct Scsi_Host *host = esp->host; in zorro_esp_remove()
922 free_irq(host->irq, esp); in zorro_esp_remove()
923 dma_free_coherent(esp->dev, 16, in zorro_esp_remove()
924 esp->command_block, in zorro_esp_remove()
925 esp->command_block_dma); in zorro_esp_remove()
927 if (zep->zorro3) { in zorro_esp_remove()
928 iounmap(zep->board_base); in zorro_esp_remove()
929 iounmap(esp->dma_regs); in zorro_esp_remove()
932 if (host->base > 0xffffff) in zorro_esp_remove()
933 iounmap(esp->regs); in zorro_esp_remove()