• Home
  • Raw
  • Download

Lines Matching +full:host +full:- +full:command

2  * SCSI low-level driver for the 53c94 SCSI bus adaptor found
4 * We assume the 53c94 is connected to a DBDMA (descriptor-based DMA)
49 struct Scsi_Host *host; member
74 if (cmd->sc_data_direction == DMA_TO_DEVICE) { in mac53c94_queue_lck()
76 printk(KERN_DEBUG "mac53c94_queue %p: command is", cmd); in mac53c94_queue_lck()
77 for (i = 0; i < cmd->cmd_len; ++i) in mac53c94_queue_lck()
78 printk(KERN_CONT " %.2x", cmd->cmnd[i]); in mac53c94_queue_lck()
85 cmd->scsi_done = done; in mac53c94_queue_lck()
86 cmd->host_scribble = NULL; in mac53c94_queue_lck()
88 state = (struct fsc_state *) cmd->device->host->hostdata; in mac53c94_queue_lck()
90 if (state->request_q == NULL) in mac53c94_queue_lck()
91 state->request_q = cmd; in mac53c94_queue_lck()
93 state->request_qtail->host_scribble = (void *) cmd; in mac53c94_queue_lck()
94 state->request_qtail = cmd; in mac53c94_queue_lck()
96 if (state->phase == idle) in mac53c94_queue_lck()
106 struct fsc_state *state = (struct fsc_state *) cmd->device->host->hostdata; in DEF_SCSI_QCMD()
107 struct mac53c94_regs __iomem *regs = state->regs; in DEF_SCSI_QCMD()
108 struct dbdma_regs __iomem *dma = state->dma; in DEF_SCSI_QCMD()
111 spin_lock_irqsave(cmd->device->host->host_lock, flags); in DEF_SCSI_QCMD()
113 writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control); in DEF_SCSI_QCMD()
114 writeb(CMD_SCSI_RESET, &regs->command); /* assert RST */ in DEF_SCSI_QCMD()
116 writeb(CMD_RESET, &regs->command); in DEF_SCSI_QCMD()
119 writeb(CMD_NOP, &regs->command); in DEF_SCSI_QCMD()
121 spin_unlock_irqrestore(cmd->device->host->host_lock, flags); in DEF_SCSI_QCMD()
127 struct mac53c94_regs __iomem *regs = state->regs; in mac53c94_init()
128 struct dbdma_regs __iomem *dma = state->dma; in mac53c94_init()
131 writeb(state->host->this_id | CF1_PAR_ENABLE, &regs->config1); in mac53c94_init()
132 writeb(TIMO_VAL(250), &regs->sel_timeout); /* 250ms */ in mac53c94_init()
133 writeb(CLKF_VAL(state->clk_freq), &regs->clk_factor); in mac53c94_init()
134 writeb(CF2_FEATURE_EN, &regs->config2); in mac53c94_init()
135 writeb(0, &regs->config3); in mac53c94_init()
136 writeb(0, &regs->sync_period); in mac53c94_init()
137 writeb(0, &regs->sync_offset); in mac53c94_init()
138 x = readb(&regs->interrupt); in mac53c94_init()
139 writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control); in mac53c94_init()
143 * Start the next command for a 53C94.
149 struct mac53c94_regs __iomem *regs = state->regs; in mac53c94_start()
152 if (state->phase != idle || state->current_req != NULL) in mac53c94_start()
154 if (state->request_q == NULL) in mac53c94_start()
156 state->current_req = cmd = state->request_q; in mac53c94_start()
157 state->request_q = (struct scsi_cmnd *) cmd->host_scribble; in mac53c94_start()
160 writeb(0, &regs->count_lo); in mac53c94_start()
161 writeb(0, &regs->count_mid); in mac53c94_start()
162 writeb(0, &regs->count_hi); in mac53c94_start()
163 writeb(CMD_NOP + CMD_DMA_MODE, &regs->command); in mac53c94_start()
165 writeb(CMD_FLUSH, &regs->command); in mac53c94_start()
167 writeb(cmd->device->id, &regs->dest_id); in mac53c94_start()
168 writeb(0, &regs->sync_period); in mac53c94_start()
169 writeb(0, &regs->sync_offset); in mac53c94_start()
171 /* load the command into the FIFO */ in mac53c94_start()
172 for (i = 0; i < cmd->cmd_len; ++i) in mac53c94_start()
173 writeb(cmd->cmnd[i], &regs->fifo); in mac53c94_start()
176 writeb(CMD_SELECT, &regs->command); in mac53c94_start()
177 state->phase = selecting; in mac53c94_start()
185 struct Scsi_Host *dev = ((struct fsc_state *) dev_id)->current_req->device->host; in do_mac53c94_interrupt()
187 spin_lock_irqsave(dev->host_lock, flags); in do_mac53c94_interrupt()
189 spin_unlock_irqrestore(dev->host_lock, flags); in do_mac53c94_interrupt()
196 struct mac53c94_regs __iomem *regs = state->regs; in mac53c94_interrupt()
197 struct dbdma_regs __iomem *dma = state->dma; in mac53c94_interrupt()
198 struct scsi_cmnd *cmd = state->current_req; in mac53c94_interrupt()
206 seq = readb(&regs->seqstep); in mac53c94_interrupt()
207 stat = readb(&regs->status); in mac53c94_interrupt()
208 intr = readb(&regs->interrupt); in mac53c94_interrupt()
212 intr, stat, seq, state->phase); in mac53c94_interrupt()
218 writeb(CMD_NOP, &regs->command); in mac53c94_interrupt()
219 writel(RUN << 16, &dma->control); /* stop dma */ in mac53c94_interrupt()
225 intr, stat, seq, state->phase); in mac53c94_interrupt()
233 intr, stat, seq, state->phase); in mac53c94_interrupt()
236 writeb(CMD_NOP + CMD_DMA_MODE, &regs->command); in mac53c94_interrupt()
239 printk(KERN_DEBUG "53c94: interrupt with no command active?\n"); in mac53c94_interrupt()
247 switch (state->phase) { in mac53c94_interrupt()
260 printk(KERN_DEBUG "seq step %x after command\n", seq); in mac53c94_interrupt()
264 writeb(CMD_NOP, &regs->command); in mac53c94_interrupt()
268 nb = cmd->SCp.this_residual; in mac53c94_interrupt()
271 cmd->SCp.this_residual -= nb; in mac53c94_interrupt()
272 writeb(nb, &regs->count_lo); in mac53c94_interrupt()
273 writeb(nb >> 8, &regs->count_mid); in mac53c94_interrupt()
274 writeb(CMD_DMA_MODE + CMD_NOP, &regs->command); in mac53c94_interrupt()
275 writel(virt_to_phys(state->dma_cmds), &dma->cmdptr); in mac53c94_interrupt()
276 writel((RUN << 16) | RUN, &dma->control); in mac53c94_interrupt()
277 writeb(CMD_DMA_MODE + CMD_XFER_DATA, &regs->command); in mac53c94_interrupt()
278 state->phase = dataing; in mac53c94_interrupt()
282 writeb(CMD_I_COMPLETE, &regs->command); in mac53c94_interrupt()
283 state->phase = completing; in mac53c94_interrupt()
298 if (cmd->SCp.this_residual != 0 in mac53c94_interrupt()
301 nb = cmd->SCp.this_residual; in mac53c94_interrupt()
304 cmd->SCp.this_residual -= nb; in mac53c94_interrupt()
305 writeb(nb, &regs->count_lo); in mac53c94_interrupt()
306 writeb(nb >> 8, &regs->count_mid); in mac53c94_interrupt()
307 writeb(CMD_DMA_MODE + CMD_NOP, &regs->command); in mac53c94_interrupt()
308 writeb(CMD_DMA_MODE + CMD_XFER_DATA, &regs->command); in mac53c94_interrupt()
314 writel(RUN << 16, &dma->control); /* stop dma */ in mac53c94_interrupt()
317 writeb(CMD_I_COMPLETE, &regs->command); in mac53c94_interrupt()
318 state->phase = completing; in mac53c94_interrupt()
326 cmd->SCp.Status = readb(&regs->fifo); in mac53c94_interrupt()
327 cmd->SCp.Message = readb(&regs->fifo); in mac53c94_interrupt()
328 cmd->result = CMD_ACCEPT_MSG; in mac53c94_interrupt()
329 writeb(CMD_ACCEPT_MSG, &regs->command); in mac53c94_interrupt()
330 state->phase = busfreeing; in mac53c94_interrupt()
336 cmd_done(state, (DID_OK << 16) + (cmd->SCp.Message << 8) in mac53c94_interrupt()
337 + cmd->SCp.Status); in mac53c94_interrupt()
340 printk(KERN_DEBUG "don't know about phase %d\n", state->phase); in mac53c94_interrupt()
348 cmd = state->current_req; in cmd_done()
350 cmd->result = result; in cmd_done()
351 (*cmd->scsi_done)(cmd); in cmd_done()
352 state->current_req = NULL; in cmd_done()
354 state->phase = idle; in cmd_done()
374 dma_cmd = cmd->sc_data_direction == DMA_TO_DEVICE ? in set_dma_cmds()
376 dcmds = state->dma_cmds; in set_dma_cmds()
385 dcmds->req_count = cpu_to_le16(dma_len); in set_dma_cmds()
386 dcmds->command = cpu_to_le16(dma_cmd); in set_dma_cmds()
387 dcmds->phy_addr = cpu_to_le32(dma_addr); in set_dma_cmds()
388 dcmds->xfer_status = 0; in set_dma_cmds()
392 dma_cmd += OUTPUT_LAST - OUTPUT_MORE; in set_dma_cmds()
393 dcmds[-1].command = cpu_to_le16(dma_cmd); in set_dma_cmds()
394 dcmds->command = cpu_to_le16(DBDMA_STOP); in set_dma_cmds()
395 cmd->SCp.this_residual = total; in set_dma_cmds()
414 struct Scsi_Host *host; in mac53c94_probe() local
417 int proplen, rc = -ENODEV; in mac53c94_probe()
423 return -ENODEV; in mac53c94_probe()
428 return -EBUSY; in mac53c94_probe()
431 host = scsi_host_alloc(&mac53c94_template, sizeof(struct fsc_state)); in mac53c94_probe()
432 if (host == NULL) { in mac53c94_probe()
433 printk(KERN_ERR "mac53c94: couldn't register host"); in mac53c94_probe()
434 rc = -ENOMEM; in mac53c94_probe()
438 state = (struct fsc_state *) host->hostdata; in mac53c94_probe()
440 state->host = host; in mac53c94_probe()
441 state->pdev = pdev; in mac53c94_probe()
442 state->mdev = mdev; in mac53c94_probe()
444 state->regs = (struct mac53c94_regs __iomem *) in mac53c94_probe()
446 state->intr = macio_irq(mdev, 0); in mac53c94_probe()
447 state->dma = (struct dbdma_regs __iomem *) in mac53c94_probe()
449 state->dmaintr = macio_irq(mdev, 1); in mac53c94_probe()
450 if (state->regs == NULL || state->dma == NULL) { in mac53c94_probe()
455 clkprop = of_get_property(node, "clock-frequency", &proplen); in mac53c94_probe()
459 state->clk_freq = 25000000; in mac53c94_probe()
461 state->clk_freq = *(int *)clkprop; in mac53c94_probe()
463 /* Space for dma command list: +1 for stop command, in mac53c94_probe()
467 dma_cmd_space = kmalloc_array(host->sg_tablesize + 2, in mac53c94_probe()
472 "command space for %pOF\n", node); in mac53c94_probe()
473 rc = -ENOMEM; in mac53c94_probe()
476 state->dma_cmds = (struct dbdma_cmd *)DBDMA_ALIGN(dma_cmd_space); in mac53c94_probe()
477 memset(state->dma_cmds, 0, (host->sg_tablesize + 1) in mac53c94_probe()
479 state->dma_cmd_space = dma_cmd_space; in mac53c94_probe()
483 if (request_irq(state->intr, do_mac53c94_interrupt, 0, "53C94",state)) { in mac53c94_probe()
485 state->intr, node); in mac53c94_probe()
489 rc = scsi_add_host(host, &mdev->ofdev.dev); in mac53c94_probe()
493 scsi_scan_host(host); in mac53c94_probe()
497 free_irq(state->intr, state); in mac53c94_probe()
499 kfree(state->dma_cmd_space); in mac53c94_probe()
501 if (state->dma != NULL) in mac53c94_probe()
502 iounmap(state->dma); in mac53c94_probe()
503 if (state->regs != NULL) in mac53c94_probe()
504 iounmap(state->regs); in mac53c94_probe()
505 scsi_host_put(host); in mac53c94_probe()
515 struct Scsi_Host *host = fp->host; in mac53c94_remove() local
517 scsi_remove_host(host); in mac53c94_remove()
519 free_irq(fp->intr, fp); in mac53c94_remove()
521 if (fp->regs) in mac53c94_remove()
522 iounmap(fp->regs); in mac53c94_remove()
523 if (fp->dma) in mac53c94_remove()
524 iounmap(fp->dma); in mac53c94_remove()
525 kfree(fp->dma_cmd_space); in mac53c94_remove()
527 scsi_host_put(host); in mac53c94_remove()