Lines Matching full:esp
3 * ESP front-end for Amiga ZORRO SCSI systems.
8 * migration to ESP SCSI core
52 MODULE_DESCRIPTION("Amiga Zorro NCR5C9x (ESP) driver");
158 struct esp *esp; /* our ESP instance - for Scsi_host* */ member
165 * On all implementations except for the Oktagon, padding between ESP
172 static void zorro_esp_write8(struct esp *esp, u8 val, unsigned long reg) in zorro_esp_write8() argument
174 writeb(val, esp->regs + (reg * 4UL)); in zorro_esp_write8()
177 static u8 zorro_esp_read8(struct esp *esp, unsigned long reg) in zorro_esp_read8() argument
179 return readb(esp->regs + (reg * 4UL)); in zorro_esp_read8()
182 static int zorro_esp_irq_pending(struct esp *esp) in zorro_esp_irq_pending() argument
184 /* check ESP status register; DMA has no status reg. */ in zorro_esp_irq_pending()
185 if (zorro_esp_read8(esp, ESP_STATUS) & ESP_STAT_INTR) in zorro_esp_irq_pending()
191 static int cyber_esp_irq_pending(struct esp *esp) in cyber_esp_irq_pending() argument
193 struct cyber_dma_registers __iomem *dregs = esp->dma_regs; in cyber_esp_irq_pending()
197 return ((zorro_esp_read8(esp, ESP_STATUS) & ESP_STAT_INTR) && in cyber_esp_irq_pending()
201 static int fastlane_esp_irq_pending(struct esp *esp) in fastlane_esp_irq_pending() argument
203 struct fastlane_dma_registers __iomem *dregs = esp->dma_regs; in fastlane_esp_irq_pending()
211 /* Return non-zero if ESP requested IRQ */ in fastlane_esp_irq_pending()
215 (zorro_esp_read8(esp, ESP_STATUS) & ESP_STAT_INTR)); in fastlane_esp_irq_pending()
218 static u32 zorro_esp_dma_length_limit(struct esp *esp, u32 dma_addr, in zorro_esp_dma_length_limit() argument
224 static u32 fastlane_esp_dma_length_limit(struct esp *esp, u32 dma_addr, in fastlane_esp_dma_length_limit() argument
231 static void zorro_esp_reset_dma(struct esp *esp) in zorro_esp_reset_dma() argument
236 static void zorro_esp_dma_drain(struct esp *esp) in zorro_esp_dma_drain() argument
241 static void zorro_esp_dma_invalidate(struct esp *esp) in zorro_esp_dma_invalidate() argument
246 static void fastlane_esp_dma_invalidate(struct esp *esp) in fastlane_esp_dma_invalidate() argument
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()
259 static void zorro_esp_send_blz1230_dma_cmd(struct esp *esp, u32 addr, in zorro_esp_send_blz1230_dma_cmd() argument
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()
301 scsi_esp_cmd(esp, ESP_CMD_DMA); in zorro_esp_send_blz1230_dma_cmd()
302 zorro_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW); in zorro_esp_send_blz1230_dma_cmd()
303 zorro_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED); in zorro_esp_send_blz1230_dma_cmd()
305 scsi_esp_cmd(esp, cmd); in zorro_esp_send_blz1230_dma_cmd()
310 static void zorro_esp_send_blz1230II_dma_cmd(struct esp *esp, u32 addr, in zorro_esp_send_blz1230II_dma_cmd() argument
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()
346 scsi_esp_cmd(esp, ESP_CMD_DMA); in zorro_esp_send_blz1230II_dma_cmd()
347 zorro_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW); in zorro_esp_send_blz1230II_dma_cmd()
348 zorro_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED); in zorro_esp_send_blz1230II_dma_cmd()
350 scsi_esp_cmd(esp, cmd); in zorro_esp_send_blz1230II_dma_cmd()
355 static void zorro_esp_send_blz2060_dma_cmd(struct esp *esp, u32 addr, in zorro_esp_send_blz2060_dma_cmd() argument
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()
391 scsi_esp_cmd(esp, ESP_CMD_DMA); in zorro_esp_send_blz2060_dma_cmd()
392 zorro_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW); in zorro_esp_send_blz2060_dma_cmd()
393 zorro_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED); in zorro_esp_send_blz2060_dma_cmd()
395 scsi_esp_cmd(esp, cmd); in zorro_esp_send_blz2060_dma_cmd()
400 static void zorro_esp_send_cyber_dma_cmd(struct esp *esp, u32 addr, in zorro_esp_send_cyber_dma_cmd() argument
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()
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()
418 zorro_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW); in zorro_esp_send_cyber_dma_cmd()
419 zorro_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED); 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()
447 scsi_esp_cmd(esp, cmd); in zorro_esp_send_cyber_dma_cmd()
452 static void zorro_esp_send_cyberII_dma_cmd(struct esp *esp, u32 addr, in zorro_esp_send_cyberII_dma_cmd() argument
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()
468 zorro_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW); in zorro_esp_send_cyberII_dma_cmd()
469 zorro_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED); 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()
488 scsi_esp_cmd(esp, cmd); in zorro_esp_send_cyberII_dma_cmd()
493 static void zorro_esp_send_fastlane_dma_cmd(struct esp *esp, u32 addr, in zorro_esp_send_fastlane_dma_cmd() argument
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()
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()
511 zorro_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW); in zorro_esp_send_fastlane_dma_cmd()
512 zorro_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED); 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()
540 scsi_esp_cmd(esp, cmd); in zorro_esp_send_fastlane_dma_cmd()
543 static int zorro_esp_dma_error(struct esp *esp) in zorro_esp_dma_error() argument
545 return esp->send_cmd_error; in zorro_esp_dma_error()
548 /* per-board ESP driver ops */
718 struct esp *esp; in zorro_esp_probe() local
754 * for presence of ESP chip later, but don't try to fix up yet. in zorro_esp_probe()
777 host = scsi_host_alloc(tpnt, sizeof(struct esp)); in zorro_esp_probe()
788 esp = shost_priv(host); 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()
803 /* map full address space up to ESP base for DMA */ 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()
828 esp->fifo_reg = esp->regs + ESP_FDATA * 4; in zorro_esp_probe()
832 zorro_esp_write8(esp, (ESP_CONFIG1_PENABLE | 7), ESP_CFG1); in zorro_esp_probe()
833 if (zorro_esp_read8(esp, ESP_CFG1) != (ESP_CONFIG1_PENABLE|7)) { 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()
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()
866 "Amiga Zorro ESP", esp); in zorro_esp_probe()
873 err = scsi_esp_register(esp); 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()
892 iounmap(esp->dma_regs); in zorro_esp_probe()
896 iounmap(esp->regs); in zorro_esp_probe()
917 struct esp *esp = zep->esp; in zorro_esp_remove() local
918 struct Scsi_Host *host = esp->host; in zorro_esp_remove()
920 scsi_esp_unregister(esp); 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()
929 iounmap(esp->dma_regs); in zorro_esp_remove()
933 iounmap(esp->regs); in zorro_esp_remove()