• Home
  • Raw
  • Download

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

1 // SPDX-License-Identifier: GPL-2.0-only
3 * SCSI low-level driver for the 53c94 SCSI bus adaptor found
5 * We assume the 53c94 is connected to a DBDMA (descriptor-based DMA)
50 struct Scsi_Host *host; member
75 if (cmd->sc_data_direction == DMA_TO_DEVICE) { in mac53c94_queue_lck()
77 printk(KERN_DEBUG "mac53c94_queue %p: command is", cmd); in mac53c94_queue_lck()
78 for (i = 0; i < cmd->cmd_len; ++i) in mac53c94_queue_lck()
79 printk(KERN_CONT " %.2x", cmd->cmnd[i]); in mac53c94_queue_lck()
86 cmd->scsi_done = done; in mac53c94_queue_lck()
87 cmd->host_scribble = NULL; in mac53c94_queue_lck()
89 state = (struct fsc_state *) cmd->device->host->hostdata; in mac53c94_queue_lck()
91 if (state->request_q == NULL) in mac53c94_queue_lck()
92 state->request_q = cmd; in mac53c94_queue_lck()
94 state->request_qtail->host_scribble = (void *) cmd; in mac53c94_queue_lck()
95 state->request_qtail = cmd; in mac53c94_queue_lck()
97 if (state->phase == idle) in mac53c94_queue_lck()
107 struct fsc_state *state = (struct fsc_state *) cmd->device->host->hostdata; in DEF_SCSI_QCMD()
108 struct mac53c94_regs __iomem *regs = state->regs; in DEF_SCSI_QCMD()
109 struct dbdma_regs __iomem *dma = state->dma; in DEF_SCSI_QCMD()
112 spin_lock_irqsave(cmd->device->host->host_lock, flags); in DEF_SCSI_QCMD()
114 writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control); in DEF_SCSI_QCMD()
115 writeb(CMD_SCSI_RESET, &regs->command); /* assert RST */ in DEF_SCSI_QCMD()
117 writeb(CMD_RESET, &regs->command); in DEF_SCSI_QCMD()
120 writeb(CMD_NOP, &regs->command); in DEF_SCSI_QCMD()
122 spin_unlock_irqrestore(cmd->device->host->host_lock, flags); in DEF_SCSI_QCMD()
128 struct mac53c94_regs __iomem *regs = state->regs; in mac53c94_init()
129 struct dbdma_regs __iomem *dma = state->dma; in mac53c94_init()
132 writeb(state->host->this_id | CF1_PAR_ENABLE, &regs->config1); in mac53c94_init()
133 writeb(TIMO_VAL(250), &regs->sel_timeout); /* 250ms */ in mac53c94_init()
134 writeb(CLKF_VAL(state->clk_freq), &regs->clk_factor); in mac53c94_init()
135 writeb(CF2_FEATURE_EN, &regs->config2); in mac53c94_init()
136 writeb(0, &regs->config3); in mac53c94_init()
137 writeb(0, &regs->sync_period); in mac53c94_init()
138 writeb(0, &regs->sync_offset); in mac53c94_init()
139 x = readb(&regs->interrupt); in mac53c94_init()
140 writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control); in mac53c94_init()
144 * Start the next command for a 53C94.
150 struct mac53c94_regs __iomem *regs = state->regs; in mac53c94_start()
153 if (state->phase != idle || state->current_req != NULL) in mac53c94_start()
155 if (state->request_q == NULL) in mac53c94_start()
157 state->current_req = cmd = state->request_q; in mac53c94_start()
158 state->request_q = (struct scsi_cmnd *) cmd->host_scribble; in mac53c94_start()
161 writeb(0, &regs->count_lo); in mac53c94_start()
162 writeb(0, &regs->count_mid); in mac53c94_start()
163 writeb(0, &regs->count_hi); in mac53c94_start()
164 writeb(CMD_NOP + CMD_DMA_MODE, &regs->command); in mac53c94_start()
166 writeb(CMD_FLUSH, &regs->command); in mac53c94_start()
168 writeb(cmd->device->id, &regs->dest_id); in mac53c94_start()
169 writeb(0, &regs->sync_period); in mac53c94_start()
170 writeb(0, &regs->sync_offset); in mac53c94_start()
172 /* load the command into the FIFO */ in mac53c94_start()
173 for (i = 0; i < cmd->cmd_len; ++i) in mac53c94_start()
174 writeb(cmd->cmnd[i], &regs->fifo); in mac53c94_start()
177 writeb(CMD_SELECT, &regs->command); in mac53c94_start()
178 state->phase = selecting; in mac53c94_start()
186 struct Scsi_Host *dev = ((struct fsc_state *) dev_id)->current_req->device->host; in do_mac53c94_interrupt()
188 spin_lock_irqsave(dev->host_lock, flags); in do_mac53c94_interrupt()
190 spin_unlock_irqrestore(dev->host_lock, flags); in do_mac53c94_interrupt()
197 struct mac53c94_regs __iomem *regs = state->regs; in mac53c94_interrupt()
198 struct dbdma_regs __iomem *dma = state->dma; in mac53c94_interrupt()
199 struct scsi_cmnd *cmd = state->current_req; in mac53c94_interrupt()
207 seq = readb(&regs->seqstep); in mac53c94_interrupt()
208 stat = readb(&regs->status); in mac53c94_interrupt()
209 intr = readb(&regs->interrupt); in mac53c94_interrupt()
213 intr, stat, seq, state->phase); in mac53c94_interrupt()
219 writeb(CMD_NOP, &regs->command); in mac53c94_interrupt()
220 writel(RUN << 16, &dma->control); /* stop dma */ in mac53c94_interrupt()
226 intr, stat, seq, state->phase); in mac53c94_interrupt()
234 intr, stat, seq, state->phase); in mac53c94_interrupt()
237 writeb(CMD_NOP + CMD_DMA_MODE, &regs->command); in mac53c94_interrupt()
240 printk(KERN_DEBUG "53c94: interrupt with no command active?\n"); in mac53c94_interrupt()
248 switch (state->phase) { in mac53c94_interrupt()
261 printk(KERN_DEBUG "seq step %x after command\n", seq); in mac53c94_interrupt()
265 writeb(CMD_NOP, &regs->command); in mac53c94_interrupt()
269 nb = cmd->SCp.this_residual; in mac53c94_interrupt()
272 cmd->SCp.this_residual -= nb; in mac53c94_interrupt()
273 writeb(nb, &regs->count_lo); in mac53c94_interrupt()
274 writeb(nb >> 8, &regs->count_mid); in mac53c94_interrupt()
275 writeb(CMD_DMA_MODE + CMD_NOP, &regs->command); in mac53c94_interrupt()
276 writel(virt_to_phys(state->dma_cmds), &dma->cmdptr); in mac53c94_interrupt()
277 writel((RUN << 16) | RUN, &dma->control); in mac53c94_interrupt()
278 writeb(CMD_DMA_MODE + CMD_XFER_DATA, &regs->command); in mac53c94_interrupt()
279 state->phase = dataing; in mac53c94_interrupt()
283 writeb(CMD_I_COMPLETE, &regs->command); in mac53c94_interrupt()
284 state->phase = completing; in mac53c94_interrupt()
299 if (cmd->SCp.this_residual != 0 in mac53c94_interrupt()
302 nb = cmd->SCp.this_residual; in mac53c94_interrupt()
305 cmd->SCp.this_residual -= nb; in mac53c94_interrupt()
306 writeb(nb, &regs->count_lo); in mac53c94_interrupt()
307 writeb(nb >> 8, &regs->count_mid); in mac53c94_interrupt()
308 writeb(CMD_DMA_MODE + CMD_NOP, &regs->command); in mac53c94_interrupt()
309 writeb(CMD_DMA_MODE + CMD_XFER_DATA, &regs->command); in mac53c94_interrupt()
315 writel(RUN << 16, &dma->control); /* stop dma */ in mac53c94_interrupt()
318 writeb(CMD_I_COMPLETE, &regs->command); in mac53c94_interrupt()
319 state->phase = completing; in mac53c94_interrupt()
327 cmd->SCp.Status = readb(&regs->fifo); in mac53c94_interrupt()
328 cmd->SCp.Message = readb(&regs->fifo); in mac53c94_interrupt()
329 cmd->result = CMD_ACCEPT_MSG; in mac53c94_interrupt()
330 writeb(CMD_ACCEPT_MSG, &regs->command); in mac53c94_interrupt()
331 state->phase = busfreeing; in mac53c94_interrupt()
337 cmd_done(state, (DID_OK << 16) + (cmd->SCp.Message << 8) in mac53c94_interrupt()
338 + cmd->SCp.Status); in mac53c94_interrupt()
341 printk(KERN_DEBUG "don't know about phase %d\n", state->phase); in mac53c94_interrupt()
349 cmd = state->current_req; in cmd_done()
351 cmd->result = result; in cmd_done()
352 (*cmd->scsi_done)(cmd); in cmd_done()
353 state->current_req = NULL; in cmd_done()
355 state->phase = idle; in cmd_done()
375 dma_cmd = cmd->sc_data_direction == DMA_TO_DEVICE ? in set_dma_cmds()
377 dcmds = state->dma_cmds; in set_dma_cmds()
386 dcmds->req_count = cpu_to_le16(dma_len); in set_dma_cmds()
387 dcmds->command = cpu_to_le16(dma_cmd); in set_dma_cmds()
388 dcmds->phy_addr = cpu_to_le32(dma_addr); in set_dma_cmds()
389 dcmds->xfer_status = 0; in set_dma_cmds()
393 dma_cmd += OUTPUT_LAST - OUTPUT_MORE; in set_dma_cmds()
394 dcmds[-1].command = cpu_to_le16(dma_cmd); in set_dma_cmds()
395 dcmds->command = cpu_to_le16(DBDMA_STOP); in set_dma_cmds()
396 cmd->SCp.this_residual = total; in set_dma_cmds()
415 struct Scsi_Host *host; in mac53c94_probe() local
418 int proplen, rc = -ENODEV; in mac53c94_probe()
424 return -ENODEV; in mac53c94_probe()
429 return -EBUSY; in mac53c94_probe()
432 host = scsi_host_alloc(&mac53c94_template, sizeof(struct fsc_state)); in mac53c94_probe()
433 if (host == NULL) { in mac53c94_probe()
434 printk(KERN_ERR "mac53c94: couldn't register host"); in mac53c94_probe()
435 rc = -ENOMEM; in mac53c94_probe()
439 state = (struct fsc_state *) host->hostdata; in mac53c94_probe()
441 state->host = host; in mac53c94_probe()
442 state->pdev = pdev; in mac53c94_probe()
443 state->mdev = mdev; in mac53c94_probe()
445 state->regs = (struct mac53c94_regs __iomem *) in mac53c94_probe()
447 state->intr = macio_irq(mdev, 0); in mac53c94_probe()
448 state->dma = (struct dbdma_regs __iomem *) in mac53c94_probe()
450 state->dmaintr = macio_irq(mdev, 1); in mac53c94_probe()
451 if (state->regs == NULL || state->dma == NULL) { in mac53c94_probe()
456 clkprop = of_get_property(node, "clock-frequency", &proplen); in mac53c94_probe()
460 state->clk_freq = 25000000; in mac53c94_probe()
462 state->clk_freq = *(int *)clkprop; in mac53c94_probe()
464 /* Space for dma command list: +1 for stop command, in mac53c94_probe()
468 dma_cmd_space = kmalloc_array(host->sg_tablesize + 2, in mac53c94_probe()
473 "command space for %pOF\n", node); in mac53c94_probe()
474 rc = -ENOMEM; in mac53c94_probe()
477 state->dma_cmds = (struct dbdma_cmd *)DBDMA_ALIGN(dma_cmd_space); in mac53c94_probe()
478 memset(state->dma_cmds, 0, (host->sg_tablesize + 1) in mac53c94_probe()
480 state->dma_cmd_space = dma_cmd_space; in mac53c94_probe()
484 if (request_irq(state->intr, do_mac53c94_interrupt, 0, "53C94",state)) { in mac53c94_probe()
486 state->intr, node); in mac53c94_probe()
490 rc = scsi_add_host(host, &mdev->ofdev.dev); in mac53c94_probe()
494 scsi_scan_host(host); in mac53c94_probe()
498 free_irq(state->intr, state); in mac53c94_probe()
500 kfree(state->dma_cmd_space); in mac53c94_probe()
502 if (state->dma != NULL) in mac53c94_probe()
503 iounmap(state->dma); in mac53c94_probe()
504 if (state->regs != NULL) in mac53c94_probe()
505 iounmap(state->regs); in mac53c94_probe()
506 scsi_host_put(host); in mac53c94_probe()
516 struct Scsi_Host *host = fp->host; in mac53c94_remove() local
518 scsi_remove_host(host); in mac53c94_remove()
520 free_irq(fp->intr, fp); in mac53c94_remove()
522 if (fp->regs) in mac53c94_remove()
523 iounmap(fp->regs); in mac53c94_remove()
524 if (fp->dma) in mac53c94_remove()
525 iounmap(fp->dma); in mac53c94_remove()
526 kfree(fp->dma_cmd_space); in mac53c94_remove()
528 scsi_host_put(host); in mac53c94_remove()