6 #include <linux/kernel.h>
7 #include <linux/types.h>
9 #include <linux/module.h>
25 #define DRV_MODULE_NAME "sun_esp"
26 #define PFX DRV_MODULE_NAME ": "
27 #define DRV_VERSION "1.100"
28 #define DRV_MODULE_RELDATE "August 27, 2008"
30 #define dma_read32(REG) \
31 sbus_readl(esp->dma_regs + (REG))
32 #define dma_write32(VAL, REG) \
33 sbus_writel((VAL), esp->dma_regs + (REG))
102 static int __devinit esp_sbus_map_command_block(
struct esp *esp)
114 static int __devinit esp_sbus_register_irq(
struct esp *esp)
128 dp = op->
dev.of_node;
138 "scsi-initiator-id", 7);
145 static void __devinit esp_get_differential(
struct esp *esp)
150 dp = op->
dev.of_node;
157 static void __devinit esp_get_clock_params(
struct esp *esp)
163 dp = op->
dev.of_node;
180 dp = op->
dev.of_node;
190 if (bursts == 0xff ||
193 bursts = (DMA_BURST32 - 1);
200 esp_get_scsi_id(esp, espdma);
201 esp_get_differential(esp);
202 esp_get_clock_params(esp);
203 esp_get_bursts(esp, espdma);
206 static void sbus_esp_write8(
struct esp *esp,
u8 val,
unsigned long reg)
211 static u8 sbus_esp_read8(
struct esp *esp,
unsigned long reg)
216 static dma_addr_t sbus_esp_map_single(
struct esp *esp,
void *
buf,
224 static int sbus_esp_map_sg(
struct esp *esp,
struct scatterlist *
sg,
232 static void sbus_esp_unmap_single(
struct esp *esp,
dma_addr_t addr,
240 static void sbus_esp_unmap_sg(
struct esp *esp,
struct scatterlist *
sg,
248 static int sbus_esp_irq_pending(
struct esp *esp)
255 static void sbus_esp_reset_dma(
struct esp *esp)
257 int can_do_burst16, can_do_burst32, can_do_burst64;
258 int can_do_sbus64, lim;
267 if (sbus_can_dma_64bit())
269 if (sbus_can_burst64())
291 else if (can_do_burst32)
304 esp->
host->unique_id);
327 if (can_do_burst32) {
338 if (!can_do_burst32 && can_do_burst16) {
355 static void sbus_esp_dma_drain(
struct esp *esp)
374 esp->
host->unique_id);
381 static void sbus_esp_dma_invalidate(
struct esp *esp)
406 "invalidate!\n", esp->
host->unique_id);
420 static void sbus_esp_send_dma_cmd(
struct esp *esp,
u32 addr,
u32 esp_count,
427 sbus_esp_write8(esp, (esp_count >> 0) & 0xff,
ESP_TCLOW);
428 sbus_esp_write8(esp, (esp_count >> 8) & 0xff,
ESP_TCMED);
430 sbus_esp_write8(esp, (esp_count >> 16) & 0xff,
FAS_RLO);
431 sbus_esp_write8(esp, 0,
FAS_RHI);
465 static int sbus_esp_dma_error(
struct esp *esp)
476 .esp_write8 = sbus_esp_write8,
477 .esp_read8 = sbus_esp_read8,
478 .map_single = sbus_esp_map_single,
479 .map_sg = sbus_esp_map_sg,
480 .unmap_single = sbus_esp_unmap_single,
481 .unmap_sg = sbus_esp_unmap_sg,
482 .irq_pending = sbus_esp_irq_pending,
483 .reset_dma = sbus_esp_reset_dma,
484 .dma_drain = sbus_esp_dma_drain,
485 .dma_invalidate = sbus_esp_dma_invalidate,
486 .send_dma_cmd = sbus_esp_send_dma_cmd,
487 .dma_error = sbus_esp_dma_error,
505 host->
max_id = (hme ? 16 : 8);
506 esp = shost_priv(host);
510 esp->
ops = &sbus_esp_ops;
515 err = esp_sbus_setup_dma(esp, espdma);
519 err = esp_sbus_map_regs(esp, hme);
523 err = esp_sbus_map_command_block(esp);
525 goto fail_unmap_regs;
527 err = esp_sbus_register_irq(esp);
529 goto fail_unmap_command_block;
531 esp_sbus_get_props(esp, espdma);
553 fail_unmap_command_block:
577 dma_node = op->
dev.of_node;
585 return esp_sbus_probe_one(op, dma_of, hme);
592 unsigned int irq = esp->
host->irq;
612 resource_size(&dma_of->
resource[0]));
639 .of_match_table = esp_match,
641 .probe = esp_sbus_probe,
645 static int __init sunesp_init(
void)
650 static void __exit sunesp_exit(
void)