aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/53c700.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/53c700.c')
-rw-r--r--drivers/scsi/53c700.c77
1 files changed, 25 insertions, 52 deletions
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index cb02656eb54c..71ff3fbfce12 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -267,8 +267,6 @@ NCR_700_offset_period_to_sxfer(struct NCR_700_Host_Parameters *hostdata,
267 offset = max_offset; 267 offset = max_offset;
268 } 268 }
269 if(XFERP < min_xferp) { 269 if(XFERP < min_xferp) {
270 printk(KERN_WARNING "53c700: XFERP %d is less than minium, setting to %d\n",
271 XFERP, min_xferp);
272 XFERP = min_xferp; 270 XFERP = min_xferp;
273 } 271 }
274 return (offset & 0x0f) | (XFERP & 0x07)<<4; 272 return (offset & 0x0f) | (XFERP & 0x07)<<4;
@@ -585,16 +583,8 @@ NCR_700_unmap(struct NCR_700_Host_Parameters *hostdata, struct scsi_cmnd *SCp,
585 struct NCR_700_command_slot *slot) 583 struct NCR_700_command_slot *slot)
586{ 584{
587 if(SCp->sc_data_direction != DMA_NONE && 585 if(SCp->sc_data_direction != DMA_NONE &&
588 SCp->sc_data_direction != DMA_BIDIRECTIONAL) { 586 SCp->sc_data_direction != DMA_BIDIRECTIONAL)
589 if(SCp->use_sg) { 587 scsi_dma_unmap(SCp);
590 dma_unmap_sg(hostdata->dev, SCp->request_buffer,
591 SCp->use_sg, SCp->sc_data_direction);
592 } else {
593 dma_unmap_single(hostdata->dev, slot->dma_handle,
594 SCp->request_bufflen,
595 SCp->sc_data_direction);
596 }
597 }
598} 588}
599 589
600STATIC inline void 590STATIC inline void
@@ -661,7 +651,6 @@ NCR_700_chip_setup(struct Scsi_Host *host)
661{ 651{
662 struct NCR_700_Host_Parameters *hostdata = 652 struct NCR_700_Host_Parameters *hostdata =
663 (struct NCR_700_Host_Parameters *)host->hostdata[0]; 653 (struct NCR_700_Host_Parameters *)host->hostdata[0];
664 __u32 dcntl_extra = 0;
665 __u8 min_period; 654 __u8 min_period;
666 __u8 min_xferp = (hostdata->chip710 ? NCR_710_MIN_XFERP : NCR_700_MIN_XFERP); 655 __u8 min_xferp = (hostdata->chip710 ? NCR_710_MIN_XFERP : NCR_700_MIN_XFERP);
667 656
@@ -686,13 +675,14 @@ NCR_700_chip_setup(struct Scsi_Host *host)
686 burst_disable = BURST_DISABLE; 675 burst_disable = BURST_DISABLE;
687 break; 676 break;
688 } 677 }
689 dcntl_extra = COMPAT_700_MODE; 678 hostdata->dcntl_extra |= COMPAT_700_MODE;
690 679
691 NCR_700_writeb(dcntl_extra, host, DCNTL_REG); 680 NCR_700_writeb(hostdata->dcntl_extra, host, DCNTL_REG);
692 NCR_700_writeb(burst_length | hostdata->dmode_extra, 681 NCR_700_writeb(burst_length | hostdata->dmode_extra,
693 host, DMODE_710_REG); 682 host, DMODE_710_REG);
694 NCR_700_writeb(burst_disable | (hostdata->differential ? 683 NCR_700_writeb(burst_disable | hostdata->ctest7_extra |
695 DIFF : 0), host, CTEST7_REG); 684 (hostdata->differential ? DIFF : 0),
685 host, CTEST7_REG);
696 NCR_700_writeb(BTB_TIMER_DISABLE, host, CTEST0_REG); 686 NCR_700_writeb(BTB_TIMER_DISABLE, host, CTEST0_REG);
697 NCR_700_writeb(FULL_ARBITRATION | ENABLE_PARITY | PARITY 687 NCR_700_writeb(FULL_ARBITRATION | ENABLE_PARITY | PARITY
698 | AUTO_ATN, host, SCNTL0_REG); 688 | AUTO_ATN, host, SCNTL0_REG);
@@ -727,13 +717,13 @@ NCR_700_chip_setup(struct Scsi_Host *host)
727 * of spec: sync divider 2, async divider 3 */ 717 * of spec: sync divider 2, async divider 3 */
728 DEBUG(("53c700: sync 2 async 3\n")); 718 DEBUG(("53c700: sync 2 async 3\n"));
729 NCR_700_writeb(SYNC_DIV_2_0, host, SBCL_REG); 719 NCR_700_writeb(SYNC_DIV_2_0, host, SBCL_REG);
730 NCR_700_writeb(ASYNC_DIV_3_0 | dcntl_extra, host, DCNTL_REG); 720 NCR_700_writeb(ASYNC_DIV_3_0 | hostdata->dcntl_extra, host, DCNTL_REG);
731 hostdata->sync_clock = hostdata->clock/2; 721 hostdata->sync_clock = hostdata->clock/2;
732 } else if(hostdata->clock > 50 && hostdata->clock <= 75) { 722 } else if(hostdata->clock > 50 && hostdata->clock <= 75) {
733 /* sync divider 1.5, async divider 3 */ 723 /* sync divider 1.5, async divider 3 */
734 DEBUG(("53c700: sync 1.5 async 3\n")); 724 DEBUG(("53c700: sync 1.5 async 3\n"));
735 NCR_700_writeb(SYNC_DIV_1_5, host, SBCL_REG); 725 NCR_700_writeb(SYNC_DIV_1_5, host, SBCL_REG);
736 NCR_700_writeb(ASYNC_DIV_3_0 | dcntl_extra, host, DCNTL_REG); 726 NCR_700_writeb(ASYNC_DIV_3_0 | hostdata->dcntl_extra, host, DCNTL_REG);
737 hostdata->sync_clock = hostdata->clock*2; 727 hostdata->sync_clock = hostdata->clock*2;
738 hostdata->sync_clock /= 3; 728 hostdata->sync_clock /= 3;
739 729
@@ -741,18 +731,18 @@ NCR_700_chip_setup(struct Scsi_Host *host)
741 /* sync divider 1, async divider 2 */ 731 /* sync divider 1, async divider 2 */
742 DEBUG(("53c700: sync 1 async 2\n")); 732 DEBUG(("53c700: sync 1 async 2\n"));
743 NCR_700_writeb(SYNC_DIV_1_0, host, SBCL_REG); 733 NCR_700_writeb(SYNC_DIV_1_0, host, SBCL_REG);
744 NCR_700_writeb(ASYNC_DIV_2_0 | dcntl_extra, host, DCNTL_REG); 734 NCR_700_writeb(ASYNC_DIV_2_0 | hostdata->dcntl_extra, host, DCNTL_REG);
745 hostdata->sync_clock = hostdata->clock; 735 hostdata->sync_clock = hostdata->clock;
746 } else if(hostdata->clock > 25 && hostdata->clock <=37) { 736 } else if(hostdata->clock > 25 && hostdata->clock <=37) {
747 /* sync divider 1, async divider 1.5 */ 737 /* sync divider 1, async divider 1.5 */
748 DEBUG(("53c700: sync 1 async 1.5\n")); 738 DEBUG(("53c700: sync 1 async 1.5\n"));
749 NCR_700_writeb(SYNC_DIV_1_0, host, SBCL_REG); 739 NCR_700_writeb(SYNC_DIV_1_0, host, SBCL_REG);
750 NCR_700_writeb(ASYNC_DIV_1_5 | dcntl_extra, host, DCNTL_REG); 740 NCR_700_writeb(ASYNC_DIV_1_5 | hostdata->dcntl_extra, host, DCNTL_REG);
751 hostdata->sync_clock = hostdata->clock; 741 hostdata->sync_clock = hostdata->clock;
752 } else { 742 } else {
753 DEBUG(("53c700: sync 1 async 1\n")); 743 DEBUG(("53c700: sync 1 async 1\n"));
754 NCR_700_writeb(SYNC_DIV_1_0, host, SBCL_REG); 744 NCR_700_writeb(SYNC_DIV_1_0, host, SBCL_REG);
755 NCR_700_writeb(ASYNC_DIV_1_0 | dcntl_extra, host, DCNTL_REG); 745 NCR_700_writeb(ASYNC_DIV_1_0 | hostdata->dcntl_extra, host, DCNTL_REG);
756 /* sync divider 1, async divider 1 */ 746 /* sync divider 1, async divider 1 */
757 hostdata->sync_clock = hostdata->clock; 747 hostdata->sync_clock = hostdata->clock;
758 } 748 }
@@ -1263,14 +1253,13 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1263 host->host_no, pun, lun, NCR_700_condition[i], 1253 host->host_no, pun, lun, NCR_700_condition[i],
1264 NCR_700_phase[j], dsp - hostdata->pScript); 1254 NCR_700_phase[j], dsp - hostdata->pScript);
1265 if(SCp != NULL) { 1255 if(SCp != NULL) {
1266 scsi_print_command(SCp); 1256 struct scatterlist *sg;
1267 1257
1268 if(SCp->use_sg) { 1258 scsi_print_command(SCp);
1269 for(i = 0; i < SCp->use_sg + 1; i++) { 1259 scsi_for_each_sg(SCp, sg, scsi_sg_count(SCp) + 1, i) {
1270 printk(KERN_INFO " SG[%d].length = %d, move_insn=%08x, addr %08x\n", i, ((struct scatterlist *)SCp->request_buffer)[i].length, ((struct NCR_700_command_slot *)SCp->host_scribble)->SG[i].ins, ((struct NCR_700_command_slot *)SCp->host_scribble)->SG[i].pAddr); 1260 printk(KERN_INFO " SG[%d].length = %d, move_insn=%08x, addr %08x\n", i, sg->length, ((struct NCR_700_command_slot *)SCp->host_scribble)->SG[i].ins, ((struct NCR_700_command_slot *)SCp->host_scribble)->SG[i].pAddr);
1271 }
1272 } 1261 }
1273 } 1262 }
1274 NCR_700_internal_bus_reset(host); 1263 NCR_700_internal_bus_reset(host);
1275 } else if((dsps & 0xfffff000) == A_DEBUG_INTERRUPT) { 1264 } else if((dsps & 0xfffff000) == A_DEBUG_INTERRUPT) {
1276 printk(KERN_NOTICE "scsi%d (%d:%d) DEBUG INTERRUPT %d AT %08x[%04x], continuing\n", 1265 printk(KERN_NOTICE "scsi%d (%d:%d) DEBUG INTERRUPT %d AT %08x[%04x], continuing\n",
@@ -1844,8 +1833,8 @@ NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *))
1844 } 1833 }
1845 /* sanity check: some of the commands generated by the mid-layer 1834 /* sanity check: some of the commands generated by the mid-layer
1846 * have an eccentric idea of their sc_data_direction */ 1835 * have an eccentric idea of their sc_data_direction */
1847 if(!SCp->use_sg && !SCp->request_bufflen 1836 if(!scsi_sg_count(SCp) && !scsi_bufflen(SCp) &&
1848 && SCp->sc_data_direction != DMA_NONE) { 1837 SCp->sc_data_direction != DMA_NONE) {
1849#ifdef NCR_700_DEBUG 1838#ifdef NCR_700_DEBUG
1850 printk("53c700: Command"); 1839 printk("53c700: Command");
1851 scsi_print_command(SCp); 1840 scsi_print_command(SCp);
@@ -1887,31 +1876,15 @@ NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *))
1887 int i; 1876 int i;
1888 int sg_count; 1877 int sg_count;
1889 dma_addr_t vPtr = 0; 1878 dma_addr_t vPtr = 0;
1879 struct scatterlist *sg;
1890 __u32 count = 0; 1880 __u32 count = 0;
1891 1881
1892 if(SCp->use_sg) { 1882 sg_count = scsi_dma_map(SCp);
1893 sg_count = dma_map_sg(hostdata->dev, 1883 BUG_ON(sg_count < 0);
1894 SCp->request_buffer, SCp->use_sg,
1895 direction);
1896 } else {
1897 vPtr = dma_map_single(hostdata->dev,
1898 SCp->request_buffer,
1899 SCp->request_bufflen,
1900 direction);
1901 count = SCp->request_bufflen;
1902 slot->dma_handle = vPtr;
1903 sg_count = 1;
1904 }
1905
1906 1884
1907 for(i = 0; i < sg_count; i++) { 1885 scsi_for_each_sg(SCp, sg, sg_count, i) {
1908 1886 vPtr = sg_dma_address(sg);
1909 if(SCp->use_sg) { 1887 count = sg_dma_len(sg);
1910 struct scatterlist *sg = SCp->request_buffer;
1911
1912 vPtr = sg_dma_address(&sg[i]);
1913 count = sg_dma_len(&sg[i]);
1914 }
1915 1888
1916 slot->SG[i].ins = bS_to_host(move_ins | count); 1889 slot->SG[i].ins = bS_to_host(move_ins | count);
1917 DEBUG((" scatter block %d: move %d[%08x] from 0x%lx\n", 1890 DEBUG((" scatter block %d: move %d[%08x] from 0x%lx\n",