^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 1997 Wu Ching Chen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * 2.1.x update (C) 1998 Krzysztof G. Baranowski
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * 2.5.x update (C) 2002 Red Hat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * 2.6.x update (C) 2004 Red Hat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Marcelo Tosatti <marcelo@conectiva.com.br> : SMP fixes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Wu Ching Chen : NULL pointer fixes 2000/06/02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * support atp876 chip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * enable 32 bit fifo transfer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * support cdrom & remove device run ultra speed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * fix disconnect bug 2000/12/21
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * support atp880 chip lvd u160 2001/05/15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * fix prd table bug 2001/09/12 (7.1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * atp885 support add by ACARD Hao Ping Lian 2005/01/05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/dma-mapping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <scsi/scsi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <scsi/scsi_cmnd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <scsi/scsi_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <scsi/scsi_host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include "atp870u.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static struct scsi_host_template atp870u_template;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static void send_s870(struct atp_unit *dev,unsigned char c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static void atp_is(struct atp_unit *dev, unsigned char c, bool wide_chip, unsigned char lvdmode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static inline void atp_writeb_base(struct atp_unit *atp, u8 reg, u8 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) outb(val, atp->baseport + reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static inline void atp_writew_base(struct atp_unit *atp, u8 reg, u16 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) outw(val, atp->baseport + reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static inline void atp_writeb_io(struct atp_unit *atp, u8 channel, u8 reg, u8 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) outb(val, atp->ioport[channel] + reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static inline void atp_writew_io(struct atp_unit *atp, u8 channel, u8 reg, u16 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) outw(val, atp->ioport[channel] + reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static inline void atp_writeb_pci(struct atp_unit *atp, u8 channel, u8 reg, u8 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) outb(val, atp->pciport[channel] + reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static inline void atp_writel_pci(struct atp_unit *atp, u8 channel, u8 reg, u32 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) outl(val, atp->pciport[channel] + reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static inline u8 atp_readb_base(struct atp_unit *atp, u8 reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) return inb(atp->baseport + reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static inline u16 atp_readw_base(struct atp_unit *atp, u8 reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return inw(atp->baseport + reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static inline u32 atp_readl_base(struct atp_unit *atp, u8 reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return inl(atp->baseport + reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) static inline u8 atp_readb_io(struct atp_unit *atp, u8 channel, u8 reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) return inb(atp->ioport[channel] + reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static inline u16 atp_readw_io(struct atp_unit *atp, u8 channel, u8 reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) return inw(atp->ioport[channel] + reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static inline u8 atp_readb_pci(struct atp_unit *atp, u8 channel, u8 reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) return inb(atp->pciport[channel] + reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static inline bool is880(struct atp_unit *atp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) return atp->pdev->device == ATP880_DEVID1 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) atp->pdev->device == ATP880_DEVID2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static inline bool is885(struct atp_unit *atp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) return atp->pdev->device == ATP885_DEVID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) unsigned short int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) unsigned char i, j, c, target_id, lun,cmdp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) unsigned char *prd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct scsi_cmnd *workreq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) unsigned long adrcnt, k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) unsigned long l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct Scsi_Host *host = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct atp_unit *dev = (struct atp_unit *)&host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) for (c = 0; c < 2; c++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) j = atp_readb_io(dev, c, 0x1f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if ((j & 0x80) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if ((j & 0x80) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return IRQ_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) printk("atp870u_intr_handle enter\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) dev->in_int[c] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) cmdp = atp_readb_io(dev, c, 0x10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) if (dev->working[c] != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (is885(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if ((atp_readb_io(dev, c, 0x16) & 0x80) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) atp_writeb_io(dev, c, 0x16, (atp_readb_io(dev, c, 0x16) | 0x80));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if ((atp_readb_pci(dev, c, 0x00) & 0x08) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) for (k=0; k < 1000; k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if ((atp_readb_pci(dev, c, 2) & 0x08) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if ((atp_readb_pci(dev, c, 2) & 0x01) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) atp_writeb_pci(dev, c, 0, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) i = atp_readb_io(dev, c, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) if (is885(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) atp_writeb_pci(dev, c, 2, 0x06);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) target_id = atp_readb_io(dev, c, 0x15);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * Remap wide devices onto id numbers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if ((target_id & 0x40) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) target_id = (target_id & 0x07) | 0x08;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) target_id &= 0x07;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if ((j & 0x40) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) if (dev->last_cmd[c] == 0xff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) dev->last_cmd[c] = target_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) dev->last_cmd[c] |= 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (is885(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) dev->r1f[c][target_id] |= j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) printk("atp870u_intr_handle status = %x\n",i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) if (i == 0x85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if ((dev->last_cmd[c] & 0xf0) != 0x40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) dev->last_cmd[c] = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (is885(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) adrcnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) ((unsigned char *) &adrcnt)[2] = atp_readb_io(dev, c, 0x12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) ((unsigned char *) &adrcnt)[1] = atp_readb_io(dev, c, 0x13);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) ((unsigned char *) &adrcnt)[0] = atp_readb_io(dev, c, 0x14);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (dev->id[c][target_id].last_len != adrcnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) k = dev->id[c][target_id].last_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) k -= adrcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) dev->id[c][target_id].tran_len = k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) dev->id[c][target_id].last_len = adrcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) printk("dev->id[c][target_id].last_len = %d dev->id[c][target_id].tran_len = %d\n",dev->id[c][target_id].last_len,dev->id[c][target_id].tran_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * Flip wide
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) if (dev->wide_id[c] != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) atp_writeb_io(dev, c, 0x1b, 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) while ((atp_readb_io(dev, c, 0x1b) & 0x01) != 0x01)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) atp_writeb_io(dev, c, 0x1b, 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * Issue more commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) spin_lock_irqsave(dev->host->host_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (((dev->quhd[c] != dev->quend[c]) || (dev->last_cmd[c] != 0xff)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) (dev->in_snd[c] == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) printk("Call sent_s870\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) send_s870(dev,c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) spin_unlock_irqrestore(dev->host->host_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * Done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) printk("Status 0x85 return\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (i == 0x40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) dev->last_cmd[c] |= 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) if (i == 0x21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) if ((dev->last_cmd[c] & 0xf0) != 0x40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) dev->last_cmd[c] = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) adrcnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) ((unsigned char *) &adrcnt)[2] = atp_readb_io(dev, c, 0x12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) ((unsigned char *) &adrcnt)[1] = atp_readb_io(dev, c, 0x13);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) ((unsigned char *) &adrcnt)[0] = atp_readb_io(dev, c, 0x14);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) k = dev->id[c][target_id].last_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) k -= adrcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) dev->id[c][target_id].tran_len = k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) dev->id[c][target_id].last_len = adrcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) atp_writeb_io(dev, c, 0x10, 0x41);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) if (is885(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if ((i == 0x4c) || (i == 0x4d) || (i == 0x8c) || (i == 0x8d)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) if ((i == 0x4c) || (i == 0x8c))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) i=0x48;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) i=0x49;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) if ((i == 0x80) || (i == 0x8f)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) printk(KERN_DEBUG "Device reselect\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) lun = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) if (cmdp == 0x44 || i == 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) lun = atp_readb_io(dev, c, 0x1d) & 0x07;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if ((dev->last_cmd[c] & 0xf0) != 0x40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) dev->last_cmd[c] = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) if (cmdp == 0x41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) printk("cmdp = 0x41\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) adrcnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) ((unsigned char *) &adrcnt)[2] = atp_readb_io(dev, c, 0x12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) ((unsigned char *) &adrcnt)[1] = atp_readb_io(dev, c, 0x13);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) ((unsigned char *) &adrcnt)[0] = atp_readb_io(dev, c, 0x14);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) k = dev->id[c][target_id].last_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) k -= adrcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) dev->id[c][target_id].tran_len = k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) dev->id[c][target_id].last_len = adrcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) printk("cmdp != 0x41\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) atp_writeb_io(dev, c, 0x10, 0x46);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) dev->id[c][target_id].dirct = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) atp_writeb_io(dev, c, 0x12, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) atp_writeb_io(dev, c, 0x13, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) atp_writeb_io(dev, c, 0x14, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) if (dev->last_cmd[c] != 0xff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) dev->last_cmd[c] |= 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) if (is885(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) j = atp_readb_base(dev, 0x29) & 0xfe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) atp_writeb_base(dev, 0x29, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) atp_writeb_io(dev, c, 0x10, 0x45);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) target_id = atp_readb_io(dev, c, 0x16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) * Remap wide identifiers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) if ((target_id & 0x10) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) target_id = (target_id & 0x07) | 0x08;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) target_id &= 0x07;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) if (is885(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) atp_writeb_io(dev, c, 0x10, 0x45);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) workreq = dev->id[c][target_id].curr_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) scmd_printk(KERN_DEBUG, workreq, "CDB");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) for (l = 0; l < workreq->cmd_len; l++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) printk(KERN_DEBUG " %x",workreq->cmnd[l]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) printk("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) atp_writeb_io(dev, c, 0x0f, lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) atp_writeb_io(dev, c, 0x11, dev->id[c][target_id].devsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) adrcnt = dev->id[c][target_id].tran_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) k = dev->id[c][target_id].last_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) atp_writeb_io(dev, c, 0x12, ((unsigned char *) &k)[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) atp_writeb_io(dev, c, 0x13, ((unsigned char *) &k)[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) atp_writeb_io(dev, c, 0x14, ((unsigned char *) &k)[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) printk("k %x, k[0] 0x%x k[1] 0x%x k[2] 0x%x\n", k, atp_readb_io(dev, c, 0x14), atp_readb_io(dev, c, 0x13), atp_readb_io(dev, c, 0x12));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) /* Remap wide */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) j = target_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) if (target_id > 7) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) j = (j & 0x07) | 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) /* Add direction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) j |= dev->id[c][target_id].dirct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) atp_writeb_io(dev, c, 0x15, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) atp_writeb_io(dev, c, 0x16, 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) /* enable 32 bit fifo transfer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) if (is885(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) i = atp_readb_pci(dev, c, 1) & 0xf3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) //j=workreq->cmnd[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) i |= 0x0c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) atp_writeb_pci(dev, c, 1, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) } else if (is880(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) atp_writeb_base(dev, 0x3b, (atp_readb_base(dev, 0x3b) & 0x3f) | 0xc0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) atp_writeb_base(dev, 0x3b, atp_readb_base(dev, 0x3b) & 0x3f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) atp_writeb_base(dev, 0x3a, (atp_readb_base(dev, 0x3a) & 0xf3) | 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) atp_writeb_base(dev, 0x3a, atp_readb_base(dev, 0x3a) & 0xf3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) id = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) id = id << target_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) * Is this a wide device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) if ((id & dev->wide_id[c]) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) j |= 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) atp_writeb_io(dev, c, 0x1b, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) while ((atp_readb_io(dev, c, 0x1b) & 0x01) != j)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) atp_writeb_io(dev, c, 0x1b, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) if (dev->id[c][target_id].last_len == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) printk("dev->id[c][target_id].last_len = 0\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) printk("target_id = %d adrcnt = %d\n",target_id,adrcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) prd = dev->id[c][target_id].prd_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) while (adrcnt != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) id = ((unsigned short int *)prd)[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) if (id == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) k = 0x10000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) k = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) if (k > adrcnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) ((unsigned short int *)prd)[2] = (unsigned short int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) (k - adrcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) ((unsigned long *)prd)[0] += adrcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) adrcnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) dev->id[c][target_id].prd_pos = prd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) adrcnt -= k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) dev->id[c][target_id].prdaddr += 0x08;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) prd += 0x08;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) if (adrcnt == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) dev->id[c][target_id].prd_pos = prd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) atp_writel_pci(dev, c, 0x04, dev->id[c][target_id].prdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) printk("dev->id[%d][%d].prdaddr 0x%8x\n", c, target_id, dev->id[c][target_id].prdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) if (!is885(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) atp_writeb_pci(dev, c, 2, 0x06);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) atp_writeb_pci(dev, c, 2, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) * Check transfer direction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if (dev->id[c][target_id].dirct != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) atp_writeb_pci(dev, c, 0, 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) printk("status 0x80 return dirct != 0\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) atp_writeb_pci(dev, c, 0, 0x09);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) printk("status 0x80 return dirct = 0\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) * Current scsi request on this target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) workreq = dev->id[c][target_id].curr_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) if (i == 0x42 || i == 0x16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) if ((dev->last_cmd[c] & 0xf0) != 0x40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) dev->last_cmd[c] = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) if (i == 0x16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) workreq->result = atp_readb_io(dev, c, 0x0f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) if (((dev->r1f[c][target_id] & 0x10) != 0) && is885(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) printk(KERN_WARNING "AEC67162 CRC ERROR !\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) workreq->result = 0x02;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) workreq->result = 0x02;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) if (is885(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) j = atp_readb_base(dev, 0x29) | 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) atp_writeb_base(dev, 0x29, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) * Complete the command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) scsi_dma_unmap(workreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) spin_lock_irqsave(dev->host->host_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) (*workreq->scsi_done) (workreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) printk("workreq->scsi_done\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) * Clear it off the queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) dev->id[c][target_id].curr_req = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) dev->working[c]--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) spin_unlock_irqrestore(dev->host->host_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) * Take it back wide
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) if (dev->wide_id[c] != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) atp_writeb_io(dev, c, 0x1b, 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) while ((atp_readb_io(dev, c, 0x1b) & 0x01) != 0x01)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) atp_writeb_io(dev, c, 0x1b, 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) * If there is stuff to send and nothing going then send it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) spin_lock_irqsave(dev->host->host_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) if (((dev->last_cmd[c] != 0xff) || (dev->quhd[c] != dev->quend[c])) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) (dev->in_snd[c] == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) printk("Call sent_s870(scsi_done)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) send_s870(dev,c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) spin_unlock_irqrestore(dev->host->host_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) if ((dev->last_cmd[c] & 0xf0) != 0x40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) dev->last_cmd[c] = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) if (i == 0x4f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) i = 0x89;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) i &= 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) if (i == 0x09) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) atp_writel_pci(dev, c, 4, dev->id[c][target_id].prdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) atp_writeb_pci(dev, c, 2, 0x06);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) atp_writeb_pci(dev, c, 2, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) atp_writeb_io(dev, c, 0x10, 0x41);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) if (is885(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) k = dev->id[c][target_id].last_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) atp_writeb_io(dev, c, 0x12, ((unsigned char *) (&k))[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) atp_writeb_io(dev, c, 0x13, ((unsigned char *) (&k))[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) atp_writeb_io(dev, c, 0x14, ((unsigned char *) (&k))[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) dev->id[c][target_id].dirct = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) dev->id[c][target_id].dirct = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) atp_writeb_pci(dev, c, 0, 0x09);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) if (i == 0x08) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) atp_writel_pci(dev, c, 4, dev->id[c][target_id].prdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) atp_writeb_pci(dev, c, 2, 0x06);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) atp_writeb_pci(dev, c, 2, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) atp_writeb_io(dev, c, 0x10, 0x41);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) if (is885(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) k = dev->id[c][target_id].last_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) atp_writeb_io(dev, c, 0x12, ((unsigned char *) (&k))[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) atp_writeb_io(dev, c, 0x13, ((unsigned char *) (&k))[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) atp_writeb_io(dev, c, 0x14, ((unsigned char *) (&k))[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) atp_writeb_io(dev, c, 0x15, atp_readb_io(dev, c, 0x15) | 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) dev->id[c][target_id].dirct = 0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) atp_writeb_pci(dev, c, 0, 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) if (i == 0x0a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) atp_writeb_io(dev, c, 0x10, 0x30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) atp_writeb_io(dev, c, 0x10, 0x46);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) dev->id[c][target_id].dirct = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) atp_writeb_io(dev, c, 0x12, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) atp_writeb_io(dev, c, 0x13, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) atp_writeb_io(dev, c, 0x14, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) * atp870u_queuecommand - Queue SCSI command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) * @req_p: request block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) * @done: completion function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) * Queue a command to the ATP queue. Called with the host lock held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) void (*done) (struct scsi_cmnd *))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) unsigned char c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) unsigned int m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) struct atp_unit *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) struct Scsi_Host *host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) c = scmd_channel(req_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) req_p->sense_buffer[0]=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) scsi_set_resid(req_p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) if (scmd_channel(req_p) > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) req_p->result = 0x00040000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) done(req_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) printk("atp870u_queuecommand : req_p->device->channel > 1\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) host = req_p->device->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) dev = (struct atp_unit *)&host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) m = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) m = m << scmd_id(req_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) * Fake a timeout for missing targets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) if ((m & dev->active_id[c]) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) req_p->result = 0x00040000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) done(req_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) if (done) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) req_p->scsi_done = done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) printk( "atp870u_queuecommand: done can't be NULL\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) req_p->result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) done(req_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) * Count new command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) dev->quend[c]++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) if (dev->quend[c] >= qcnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) dev->quend[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) * Check queue state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) if (dev->quhd[c] == dev->quend[c]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) if (dev->quend[c] == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) dev->quend[c] = qcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) printk("atp870u_queuecommand : dev->quhd[c] == dev->quend[c]\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) dev->quend[c]--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) req_p->result = 0x00020000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) done(req_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) dev->quereq[c][dev->quend[c]] = req_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) printk("dev->ioport[c] = %x atp_readb_io(dev, c, 0x1c) = %x dev->in_int[%d] = %d dev->in_snd[%d] = %d\n",dev->ioport[c],atp_readb_io(dev, c, 0x1c),c,dev->in_int[c],c,dev->in_snd[c]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) if ((atp_readb_io(dev, c, 0x1c) == 0) && (dev->in_int[c] == 0) && (dev->in_snd[c] == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) printk("Call sent_s870(atp870u_queuecommand)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) send_s870(dev,c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) printk("atp870u_queuecommand : exit\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) static DEF_SCSI_QCMD(atp870u_queuecommand)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) * send_s870 - send a command to the controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) * @host: host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) * On entry there is work queued to be done. We move some of that work to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) * controller itself.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) * Caller holds the host lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) static void send_s870(struct atp_unit *dev,unsigned char c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) struct scsi_cmnd *workreq = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) unsigned int i;//,k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) unsigned char j, target_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) unsigned char *prd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) unsigned short int w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) unsigned long l, bttl = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) unsigned long sg_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) if (dev->in_snd[c] != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) printk("cmnd in_snd\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) printk("Sent_s870 enter\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) dev->in_snd[c] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) if ((dev->last_cmd[c] != 0xff) && ((dev->last_cmd[c] & 0x40) != 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) dev->last_cmd[c] &= 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) workreq = dev->id[c][dev->last_cmd[c]].curr_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) if (!workreq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) dev->last_cmd[c] = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) if (dev->quhd[c] == dev->quend[c]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) dev->in_snd[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) if (!workreq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) if ((dev->last_cmd[c] != 0xff) && (dev->working[c] != 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) dev->in_snd[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) dev->working[c]++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) j = dev->quhd[c];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) dev->quhd[c]++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) if (dev->quhd[c] >= qcnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) dev->quhd[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) workreq = dev->quereq[c][dev->quhd[c]];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) if (dev->id[c][scmd_id(workreq)].curr_req != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) dev->quhd[c] = j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) dev->working[c]--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) dev->in_snd[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) dev->id[c][scmd_id(workreq)].curr_req = workreq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) dev->last_cmd[c] = scmd_id(workreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) if ((atp_readb_io(dev, c, 0x1f) & 0xb0) != 0 || atp_readb_io(dev, c, 0x1c) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) printk("Abort to Send\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) dev->last_cmd[c] |= 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) dev->in_snd[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) printk("OK to Send\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) scmd_printk(KERN_DEBUG, workreq, "CDB");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) for(i=0;i<workreq->cmd_len;i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) printk(" %x",workreq->cmnd[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) printk("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) l = scsi_bufflen(workreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) if (is885(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) j = atp_readb_base(dev, 0x29) & 0xfe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) atp_writeb_base(dev, 0x29, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) dev->r1f[c][scmd_id(workreq)] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) if (workreq->cmnd[0] == READ_CAPACITY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) if (l > 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) l = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) if (workreq->cmnd[0] == 0x00) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) l = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) target_id = scmd_id(workreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) * Wide ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) w = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) w = w << target_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) if ((w & dev->wide_id[c]) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) j |= 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) atp_writeb_io(dev, c, 0x1b, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) while ((atp_readb_io(dev, c, 0x1b) & 0x01) != j) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) atp_writeb_pci(dev, c, 0x1b, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) printk("send_s870 while loop 1\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) * Write the command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) atp_writeb_io(dev, c, 0x00, workreq->cmd_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) atp_writeb_io(dev, c, 0x01, 0x2c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) if (is885(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) atp_writeb_io(dev, c, 0x02, 0x7f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) atp_writeb_io(dev, c, 0x02, 0xcf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) for (i = 0; i < workreq->cmd_len; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) atp_writeb_io(dev, c, 0x03 + i, workreq->cmnd[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) atp_writeb_io(dev, c, 0x0f, workreq->device->lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) * Write the target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) atp_writeb_io(dev, c, 0x11, dev->id[c][target_id].devsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) printk("dev->id[%d][%d].devsp = %2x\n",c,target_id,dev->id[c][target_id].devsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) sg_count = scsi_dma_map(workreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) * Write transfer size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) atp_writeb_io(dev, c, 0x12, ((unsigned char *) (&l))[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) atp_writeb_io(dev, c, 0x13, ((unsigned char *) (&l))[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) atp_writeb_io(dev, c, 0x14, ((unsigned char *) (&l))[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) j = target_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) dev->id[c][j].last_len = l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) dev->id[c][j].tran_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) printk("dev->id[%2d][%2d].last_len = %d\n",c,j,dev->id[c][j].last_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) * Flip the wide bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) if ((j & 0x08) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) j = (j & 0x07) | 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) * Check transfer direction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) if (workreq->sc_data_direction == DMA_TO_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) atp_writeb_io(dev, c, 0x15, j | 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) atp_writeb_io(dev, c, 0x15, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) atp_writeb_io(dev, c, 0x16, atp_readb_io(dev, c, 0x16) | 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) atp_writeb_io(dev, c, 0x16, 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) dev->id[c][target_id].dirct = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) if (l == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) if (atp_readb_io(dev, c, 0x1c) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) printk("change SCSI_CMD_REG 0x08\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) dev->last_cmd[c] |= 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) dev->in_snd[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) prd = dev->id[c][target_id].prd_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) dev->id[c][target_id].prd_pos = prd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) * Now write the request list. Either as scatter/gather or as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) * a linear chain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) if (l) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) struct scatterlist *sgpnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) scsi_for_each_sg(workreq, sgpnt, sg_count, j) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) bttl = sg_dma_address(sgpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) l=sg_dma_len(sgpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) printk("1. bttl %x, l %x\n",bttl, l);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) while (l > 0x10000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) (((u16 *) (prd))[i + 3]) = 0x0000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) (((u16 *) (prd))[i + 2]) = 0x0000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) l -= 0x10000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) bttl += 0x10000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) i += 0x04;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) (((u16 *) (prd))[i + 2]) = cpu_to_le16(l);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) (((u16 *) (prd))[i + 3]) = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) i += 0x04;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) (((u16 *) (prd))[i - 1]) = cpu_to_le16(0x8000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) printk("prd %4x %4x %4x %4x\n",(((unsigned short int *)prd)[0]),(((unsigned short int *)prd)[1]),(((unsigned short int *)prd)[2]),(((unsigned short int *)prd)[3]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) printk("2. bttl %x, l %x\n",bttl, l);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) printk("send_s870: prdaddr_2 0x%8x target_id %d\n", dev->id[c][target_id].prdaddr,target_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) dev->id[c][target_id].prdaddr = dev->id[c][target_id].prd_bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) atp_writel_pci(dev, c, 4, dev->id[c][target_id].prdaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) atp_writeb_pci(dev, c, 2, 0x06);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) atp_writeb_pci(dev, c, 2, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) if (is885(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) j = atp_readb_pci(dev, c, 1) & 0xf3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) j |= 0x0c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) atp_writeb_pci(dev, c, 1, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) } else if (is880(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) atp_writeb_base(dev, 0x3b, (atp_readb_base(dev, 0x3b) & 0x3f) | 0xc0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) atp_writeb_base(dev, 0x3b, atp_readb_base(dev, 0x3b) & 0x3f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) if ((workreq->cmnd[0] == 0x08) || (workreq->cmnd[0] == 0x28) || (workreq->cmnd[0] == 0x0a) || (workreq->cmnd[0] == 0x2a))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) atp_writeb_base(dev, 0x3a, (atp_readb_base(dev, 0x3a) & 0xf3) | 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) atp_writeb_base(dev, 0x3a, atp_readb_base(dev, 0x3a) & 0xf3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) if(workreq->sc_data_direction == DMA_TO_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) dev->id[c][target_id].dirct = 0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) if (atp_readb_io(dev, c, 0x1c) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) atp_writeb_pci(dev, c, 0, 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) printk( "start DMA(to target)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) dev->last_cmd[c] |= 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) dev->in_snd[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) if (atp_readb_io(dev, c, 0x1c) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) atp_writeb_pci(dev, c, 0, 0x09);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) printk( "start DMA(to host)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) dev->last_cmd[c] |= 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) dev->in_snd[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) static unsigned char fun_scam(struct atp_unit *dev, unsigned short int *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) unsigned short int i, k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) unsigned char j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) atp_writew_io(dev, 0, 0x1c, *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) for (i = 0; i < 10; i++) { /* stable >= bus settle delay(400 ns) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) k = atp_readw_io(dev, 0, 0x1c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) j = (unsigned char) (k >> 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) if ((k & 0x8000) != 0) /* DB7 all release? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) *val |= 0x4000; /* assert DB6 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) atp_writew_io(dev, 0, 0x1c, *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) *val &= 0xdfff; /* assert DB5 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) atp_writew_io(dev, 0, 0x1c, *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) for (i = 0; i < 10; i++) { /* stable >= bus settle delay(400 ns) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) if ((atp_readw_io(dev, 0, 0x1c) & 0x2000) != 0) /* DB5 all release? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) *val |= 0x8000; /* no DB4-0, assert DB7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) *val &= 0xe0ff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) atp_writew_io(dev, 0, 0x1c, *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) *val &= 0xbfff; /* release DB6 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) atp_writew_io(dev, 0, 0x1c, *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) for (i = 0; i < 10; i++) { /* stable >= bus settle delay(400 ns) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) if ((atp_readw_io(dev, 0, 0x1c) & 0x4000) != 0) /* DB6 all release? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) return j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) static void tscam(struct Scsi_Host *host, bool wide_chip, u8 scam_on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) unsigned char i, j, k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) unsigned long n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) unsigned short int m, assignid_map, val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) unsigned char mbuf[33], quintet[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) struct atp_unit *dev = (struct atp_unit *)&host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) static unsigned char g2q_tab[8] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) 0x38, 0x31, 0x32, 0x2b, 0x34, 0x2d, 0x2e, 0x27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) /* I can't believe we need this before we've even done anything. Remove it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) * and see if anyone bitches.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) for (i = 0; i < 0x10; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) udelay(0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) atp_writeb_io(dev, 0, 1, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) atp_writeb_io(dev, 0, 2, 0x7f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) atp_writeb_io(dev, 0, 0x11, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) if ((scam_on & 0x40) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) m = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) m <<= dev->host_id[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) j = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) if (!wide_chip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) m |= 0xff00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) j = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) assignid_map = m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) atp_writeb_io(dev, 0, 0x02, 0x02); /* 2*2=4ms,3EH 2/32*3E=3.9ms */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) atp_writeb_io(dev, 0, 0x03, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) atp_writeb_io(dev, 0, 0x04, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) atp_writeb_io(dev, 0, 0x05, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) atp_writeb_io(dev, 0, 0x06, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) atp_writeb_io(dev, 0, 0x07, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) atp_writeb_io(dev, 0, 0x08, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) for (i = 0; i < j; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) m = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) m = m << i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) if ((m & assignid_map) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) atp_writeb_io(dev, 0, 0x0f, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) atp_writeb_io(dev, 0, 0x12, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) atp_writeb_io(dev, 0, 0x13, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) atp_writeb_io(dev, 0, 0x14, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) if (i > 7) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) k = (i & 0x07) | 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) k = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) atp_writeb_io(dev, 0, 0x15, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) if (wide_chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) atp_writeb_io(dev, 0, 0x1b, 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) atp_writeb_io(dev, 0, 0x1b, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) atp_writeb_io(dev, 0, 0x18, 0x09);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) while ((atp_readb_io(dev, 0, 0x1f) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) k = atp_readb_io(dev, 0, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) if ((k == 0x85) || (k == 0x42))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) if (k != 0x16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) atp_writeb_io(dev, 0, 0x10, 0x41);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) } while (k != 0x16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) if ((k == 0x85) || (k == 0x42))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) assignid_map |= m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) atp_writeb_io(dev, 0, 0x02, 0x7f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) atp_writeb_io(dev, 0, 0x1b, 0x02);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) udelay(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) val = 0x0080; /* bsy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) atp_writew_io(dev, 0, 0x1c, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) val |= 0x0040; /* sel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) atp_writew_io(dev, 0, 0x1c, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) val |= 0x0004; /* msg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) atp_writew_io(dev, 0, 0x1c, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) udelay(2); /* 2 deskew delay(45ns*2=90ns) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) val &= 0x007f; /* no bsy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) atp_writew_io(dev, 0, 0x1c, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) msleep(128);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) val &= 0x00fb; /* after 1ms no msg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) atp_writew_io(dev, 0, 0x1c, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) while ((atp_readb_io(dev, 0, 0x1c) & 0x04) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) udelay(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) udelay(100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) for (n = 0; n < 0x30000; n++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) if ((atp_readb_io(dev, 0, 0x1c) & 0x80) != 0) /* bsy ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) if (n < 0x30000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) for (n = 0; n < 0x30000; n++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) if ((atp_readb_io(dev, 0, 0x1c) & 0x81) == 0x0081) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) udelay(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) val |= 0x8003; /* io,cd,db7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) atp_writew_io(dev, 0, 0x1c, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) udelay(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) val &= 0x00bf; /* no sel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) atp_writew_io(dev, 0, 0x1c, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) udelay(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) * The funny division into multiple delays is to accomodate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) * arches like ARM where udelay() multiplies its argument by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) * a large number to initialize a loop counter. To avoid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) * overflow, the maximum supported udelay is 2000 microseconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) * XXX it would be more polite to find a way to use msleep()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) mdelay(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) udelay(48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) if ((atp_readb_io(dev, 0, 0x1c) & 0x80) == 0x00) { /* bsy ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) atp_writew_io(dev, 0, 0x1c, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) atp_writeb_io(dev, 0, 0x1b, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) atp_writeb_io(dev, 0, 0x15, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) atp_writeb_io(dev, 0, 0x18, 0x09);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) while ((atp_readb_io(dev, 0, 0x1f) & 0x80) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) atp_readb_io(dev, 0, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) val &= 0x00ff; /* synchronization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) val |= 0x3f00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) fun_scam(dev, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) udelay(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) val &= 0x00ff; /* isolation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) val |= 0x2000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) fun_scam(dev, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) udelay(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) i = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) if ((atp_readw_io(dev, 0, 0x1c) & 0x2000) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) udelay(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) val &= 0x00ff; /* get ID_STRING */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) val |= 0x2000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) k = fun_scam(dev, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) if ((k & 0x03) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) mbuf[j] <<= 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) mbuf[j] &= 0xfe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) if ((k & 0x02) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) mbuf[j] |= 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) i--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) if (i > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) j++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) i = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) /* isolation complete.. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) /* mbuf[32]=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) printk(" \n%x %x %x %s\n ",assignid_map,mbuf[0],mbuf[1],&mbuf[2]); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) i = 15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) j = mbuf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) if ((j & 0x20) != 0) { /* bit5=1:ID up to 7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) i = 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) if ((j & 0x06) != 0) { /* IDvalid? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) k = mbuf[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) m = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) m <<= k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) if ((m & assignid_map) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) if (k > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) k--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) if ((m & assignid_map) != 0) { /* srch from max acceptable ID# */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) k = i; /* max acceptable ID# */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) m = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) m <<= k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) if ((m & assignid_map) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) if (k > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) k--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) /* k=binID#, */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) assignid_map |= m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) if (k < 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) quintet[0] = 0x38; /* 1st dft ID<8 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) quintet[0] = 0x31; /* 1st ID>=8 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) k &= 0x07;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) quintet[1] = g2q_tab[k];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) val &= 0x00ff; /* AssignID 1stQuintet,AH=001xxxxx */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) m = quintet[0] << 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) val |= m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) fun_scam(dev, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) val &= 0x00ff; /* AssignID 2ndQuintet,AH=001xxxxx */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) m = quintet[1] << 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) val |= m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) fun_scam(dev, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) static void atp870u_free_tables(struct Scsi_Host *host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) struct atp_unit *atp_dev = (struct atp_unit *)&host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) int j, k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) for (j=0; j < 2; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) for (k = 0; k < 16; k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) if (!atp_dev->id[j][k].prd_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) dma_free_coherent(&atp_dev->pdev->dev, 1024, atp_dev->id[j][k].prd_table, atp_dev->id[j][k].prd_bus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) atp_dev->id[j][k].prd_table = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) static int atp870u_init_tables(struct Scsi_Host *host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) struct atp_unit *atp_dev = (struct atp_unit *)&host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) int c,k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) for(c=0;c < 2;c++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) for(k=0;k<16;k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) atp_dev->id[c][k].prd_table = dma_alloc_coherent(&atp_dev->pdev->dev, 1024, &(atp_dev->id[c][k].prd_bus), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) if (!atp_dev->id[c][k].prd_table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) printk("atp870u_init_tables fail\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) atp870u_free_tables(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) atp_dev->id[c][k].prdaddr = atp_dev->id[c][k].prd_bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) atp_dev->id[c][k].devsp=0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) atp_dev->id[c][k].devtype = 0x7f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) atp_dev->id[c][k].curr_req = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) atp_dev->active_id[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) atp_dev->wide_id[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) atp_dev->host_id[c] = 0x07;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) atp_dev->quhd[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) atp_dev->quend[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) atp_dev->last_cmd[c] = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) atp_dev->in_snd[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) atp_dev->in_int[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) for (k = 0; k < qcnt; k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) atp_dev->quereq[c][k] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) for (k = 0; k < 16; k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) atp_dev->id[c][k].curr_req = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) atp_dev->sp[c][k] = 0x04;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) static void atp_set_host_id(struct atp_unit *atp, u8 c, u8 host_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) atp_writeb_io(atp, c, 0, host_id | 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) atp_writeb_io(atp, c, 0x18, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) while ((atp_readb_io(atp, c, 0x1f) & 0x80) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) mdelay(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) atp_readb_io(atp, c, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) atp_writeb_io(atp, c, 1, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) atp_writeb_io(atp, c, 2, 0x7f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) atp_writeb_io(atp, c, 0x11, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) static void atp870_init(struct Scsi_Host *shpnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) struct atp_unit *atpdev = shost_priv(shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) struct pci_dev *pdev = atpdev->pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) unsigned char k, host_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) u8 scam_on;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) bool wide_chip =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) (pdev->device == PCI_DEVICE_ID_ARTOP_AEC7610 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) pdev->revision == 4) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) (pdev->device == PCI_DEVICE_ID_ARTOP_AEC7612UW) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) (pdev->device == PCI_DEVICE_ID_ARTOP_AEC7612SUW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) pci_read_config_byte(pdev, 0x49, &host_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) dev_info(&pdev->dev, "ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter: IO:%lx, IRQ:%d.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) shpnt->io_port, shpnt->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) atpdev->ioport[0] = shpnt->io_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) atpdev->pciport[0] = shpnt->io_port + 0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) host_id &= 0x07;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) atpdev->host_id[0] = host_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) scam_on = atp_readb_pci(atpdev, 0, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) atpdev->global_map[0] = atp_readb_base(atpdev, 0x2d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) atpdev->ultra_map[0] = atp_readw_base(atpdev, 0x2e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) if (atpdev->ultra_map[0] == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) scam_on = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) atpdev->global_map[0] = 0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) atpdev->ultra_map[0] = 0xffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) if (pdev->revision > 0x07) /* check if atp876 chip */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) atp_writeb_base(atpdev, 0x3e, 0x00); /* enable terminator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) k = (atp_readb_base(atpdev, 0x3a) & 0xf3) | 0x10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) atp_writeb_base(atpdev, 0x3a, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) atp_writeb_base(atpdev, 0x3a, k & 0xdf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) msleep(32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) atp_writeb_base(atpdev, 0x3a, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) msleep(32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) atp_set_host_id(atpdev, 0, host_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) tscam(shpnt, wide_chip, scam_on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) atp_writeb_base(atpdev, 0x3a, atp_readb_base(atpdev, 0x3a) | 0x10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) atp_is(atpdev, 0, wide_chip, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) atp_writeb_base(atpdev, 0x3a, atp_readb_base(atpdev, 0x3a) & 0xef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) atp_writeb_base(atpdev, 0x3b, atp_readb_base(atpdev, 0x3b) | 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) shpnt->max_id = wide_chip ? 16 : 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) shpnt->this_id = host_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) static void atp880_init(struct Scsi_Host *shpnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) struct atp_unit *atpdev = shost_priv(shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) struct pci_dev *pdev = atpdev->pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) unsigned char k, m, host_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) unsigned int n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) atpdev->ioport[0] = shpnt->io_port + 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) atpdev->pciport[0] = shpnt->io_port + 0x28;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) host_id = atp_readb_base(atpdev, 0x39) >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) dev_info(&pdev->dev, "ACARD AEC-67160 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) shpnt->io_port, shpnt->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) atpdev->host_id[0] = host_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) atpdev->global_map[0] = atp_readb_base(atpdev, 0x35);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) atpdev->ultra_map[0] = atp_readw_base(atpdev, 0x3c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) n = 0x3f09;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) while (n < 0x4000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) m = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) atp_writew_base(atpdev, 0x34, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) n += 0x0002;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) if (atp_readb_base(atpdev, 0x30) == 0xff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) atp_writew_base(atpdev, 0x34, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) n += 0x0002;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) atp_writew_base(atpdev, 0x34, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) n += 0x0002;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) atp_writew_base(atpdev, 0x34, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) n += 0x0002;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) n += 0x0018;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) atp_writew_base(atpdev, 0x34, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) atpdev->ultra_map[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) atpdev->async[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) for (k = 0; k < 16; k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) n = 1 << k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) if (atpdev->sp[0][k] > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) atpdev->ultra_map[0] |= n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) if (atpdev->sp[0][k] == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) atpdev->async[0] |= n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) atpdev->async[0] = ~(atpdev->async[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) atp_writeb_base(atpdev, 0x35, atpdev->global_map[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) k = atp_readb_base(atpdev, 0x38) & 0x80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) atp_writeb_base(atpdev, 0x38, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) atp_writeb_base(atpdev, 0x3b, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) msleep(32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) atp_writeb_base(atpdev, 0x3b, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) msleep(32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) atp_readb_io(atpdev, 0, 0x1b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) atp_readb_io(atpdev, 0, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) atp_set_host_id(atpdev, 0, host_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) tscam(shpnt, true, atp_readb_base(atpdev, 0x22));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) atp_is(atpdev, 0, true, atp_readb_base(atpdev, 0x3f) & 0x40);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) atp_writeb_base(atpdev, 0x38, 0xb0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) shpnt->max_id = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) shpnt->this_id = host_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) static void atp885_init(struct Scsi_Host *shpnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) struct atp_unit *atpdev = shost_priv(shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) struct pci_dev *pdev = atpdev->pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) unsigned char k, m, c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) unsigned int n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) unsigned char setupdata[2][16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) dev_info(&pdev->dev, "ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) shpnt->io_port, shpnt->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) atpdev->ioport[0] = shpnt->io_port + 0x80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) atpdev->ioport[1] = shpnt->io_port + 0xc0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) atpdev->pciport[0] = shpnt->io_port + 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) atpdev->pciport[1] = shpnt->io_port + 0x50;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) c = atp_readb_base(atpdev, 0x29);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) atp_writeb_base(atpdev, 0x29, c | 0x04);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) n = 0x1f80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) while (n < 0x2000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) atp_writew_base(atpdev, 0x3c, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) if (atp_readl_base(atpdev, 0x38) == 0xffffffff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) for (m = 0; m < 2; m++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) atpdev->global_map[m] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) for (k = 0; k < 4; k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) atp_writew_base(atpdev, 0x3c, n++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) ((u32 *)&setupdata[m][0])[k] = atp_readl_base(atpdev, 0x38);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) for (k = 0; k < 4; k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) atp_writew_base(atpdev, 0x3c, n++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) ((u32 *)&atpdev->sp[m][0])[k] = atp_readl_base(atpdev, 0x38);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) n += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) c = atp_readb_base(atpdev, 0x29);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) atp_writeb_base(atpdev, 0x29, c & 0xfb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) for (c = 0; c < 2; c++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) atpdev->ultra_map[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) atpdev->async[c] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) for (k = 0; k < 16; k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) n = 1 << k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) if (atpdev->sp[c][k] > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) atpdev->ultra_map[c] |= n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) if (atpdev->sp[c][k] == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) atpdev->async[c] |= n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) atpdev->async[c] = ~(atpdev->async[c]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) if (atpdev->global_map[c] == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) k = setupdata[c][1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) if ((k & 0x40) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) atpdev->global_map[c] |= 0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) k &= 0x07;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) atpdev->global_map[c] |= k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) if ((setupdata[c][2] & 0x04) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) atpdev->global_map[c] |= 0x08;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) atpdev->host_id[c] = setupdata[c][0] & 0x07;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) k = atp_readb_base(atpdev, 0x28) & 0x8f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) k |= 0x10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) atp_writeb_base(atpdev, 0x28, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) atp_writeb_pci(atpdev, 0, 1, 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) atp_writeb_pci(atpdev, 1, 1, 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) msleep(100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) atp_writeb_pci(atpdev, 0, 1, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) atp_writeb_pci(atpdev, 1, 1, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) msleep(1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) atp_readb_io(atpdev, 0, 0x1b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) atp_readb_io(atpdev, 0, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) atp_readb_io(atpdev, 1, 0x1b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) atp_readb_io(atpdev, 1, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) k = atpdev->host_id[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) if (k > 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) k = (k & 0x07) | 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) atp_set_host_id(atpdev, 0, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) k = atpdev->host_id[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) if (k > 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) k = (k & 0x07) | 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) atp_set_host_id(atpdev, 1, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) msleep(600); /* this delay used to be called tscam_885() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) dev_info(&pdev->dev, "Scanning Channel A SCSI Device ...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) atp_is(atpdev, 0, true, atp_readb_io(atpdev, 0, 0x1b) >> 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) atp_writeb_io(atpdev, 0, 0x16, 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) dev_info(&pdev->dev, "Scanning Channel B SCSI Device ...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) atp_is(atpdev, 1, true, atp_readb_io(atpdev, 1, 0x1b) >> 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) atp_writeb_io(atpdev, 1, 0x16, 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) k = atp_readb_base(atpdev, 0x28) & 0xcf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) k |= 0xc0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) atp_writeb_base(atpdev, 0x28, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) k = atp_readb_base(atpdev, 0x1f) | 0x80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) atp_writeb_base(atpdev, 0x1f, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) k = atp_readb_base(atpdev, 0x29) | 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) atp_writeb_base(atpdev, 0x29, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) shpnt->max_id = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) shpnt->max_lun = (atpdev->global_map[0] & 0x07) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) shpnt->max_channel = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) shpnt->this_id = atpdev->host_id[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) /* return non-zero on detection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) struct Scsi_Host *shpnt = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) struct atp_unit *atpdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) if (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 && pdev->revision < 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) dev_err(&pdev->dev, "ATP850S chips (AEC6710L/F cards) are not supported.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) err = pci_enable_device(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) printk(KERN_ERR "atp870u: DMA mask required but not available.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) goto disable_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) err = pci_request_regions(pdev, "atp870u");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) goto disable_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) pci_set_master(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) shpnt = scsi_host_alloc(&atp870u_template, sizeof(struct atp_unit));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) if (!shpnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) goto release_region;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) atpdev = shost_priv(shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) atpdev->host = shpnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) atpdev->pdev = pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) pci_set_drvdata(pdev, atpdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) shpnt->io_port = pci_resource_start(pdev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) shpnt->io_port &= 0xfffffff8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) shpnt->n_io_port = pci_resource_len(pdev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) atpdev->baseport = shpnt->io_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) shpnt->unique_id = shpnt->io_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) shpnt->irq = pdev->irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) err = atp870u_init_tables(shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) dev_err(&pdev->dev, "Unable to allocate tables for Acard controller\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) goto unregister;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) if (is880(atpdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) atp880_init(shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) else if (is885(atpdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) atp885_init(shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) atp870_init(shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) err = request_irq(shpnt->irq, atp870u_intr_handle, IRQF_SHARED, "atp870u", shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) dev_err(&pdev->dev, "Unable to allocate IRQ %d.\n", shpnt->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) goto free_tables;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) err = scsi_add_host(shpnt, &pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) goto scsi_add_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) scsi_scan_host(shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) scsi_add_fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) free_irq(shpnt->irq, shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) free_tables:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) atp870u_free_tables(shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) unregister:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) scsi_host_put(shpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) release_region:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) pci_release_regions(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) disable_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) pci_disable_device(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) /* The abort command does not leave the device in a clean state where
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) it is available to be used again. Until this gets worked out, we will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) leave it commented out. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) static int atp870u_abort(struct scsi_cmnd * SCpnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) unsigned char j, k, c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) struct scsi_cmnd *workrequ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) struct atp_unit *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) struct Scsi_Host *host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) host = SCpnt->device->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) dev = (struct atp_unit *)&host->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) c = scmd_channel(SCpnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) printk(" atp870u: abort Channel = %x \n", c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) printk("working=%x last_cmd=%x ", dev->working[c], dev->last_cmd[c]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) printk(" quhdu=%x quendu=%x ", dev->quhd[c], dev->quend[c]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) for (j = 0; j < 0x18; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) printk(" r%2x=%2x", j, atp_readb_io(dev, c, j));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) printk(" r1c=%2x", atp_readb_io(dev, c, 0x1c));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) printk(" r1f=%2x in_snd=%2x ", atp_readb_io(dev, c, 0x1f), dev->in_snd[c]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) printk(" d00=%2x", atp_readb_pci(dev, c, 0x00));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) printk(" d02=%2x", atp_readb_pci(dev, c, 0x02));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) for(j=0;j<16;j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) if (dev->id[c][j].curr_req != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) workrequ = dev->id[c][j].curr_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) printk("\n que cdb= ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) for (k=0; k < workrequ->cmd_len; k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) printk(" %2x ",workrequ->cmnd[k]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) printk(" last_lenu= %x ",(unsigned int)dev->id[c][j].last_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) static const char *atp870u_info(struct Scsi_Host *notused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) static char buffer[128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) strcpy(buffer, "ACARD AEC-6710/6712/67160 PCI Ultra/W/LVD SCSI-3 Adapter Driver V2.6+ac ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) return buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) static int atp870u_show_info(struct seq_file *m, struct Scsi_Host *HBAptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) seq_puts(m, "ACARD AEC-671X Driver Version: 2.6+ac\n\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) "Adapter Configuration:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) seq_printf(m, " Base IO: %#.4lx\n", HBAptr->io_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) seq_printf(m, " IRQ: %d\n", HBAptr->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) static int atp870u_biosparam(struct scsi_device *disk, struct block_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) sector_t capacity, int *ip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) int heads, sectors, cylinders;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) heads = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) sectors = 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) cylinders = (unsigned long)capacity / (heads * sectors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) if (cylinders > 1024) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) heads = 255;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) sectors = 63;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) cylinders = (unsigned long)capacity / (heads * sectors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) ip[0] = heads;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) ip[1] = sectors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) ip[2] = cylinders;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) static void atp870u_remove (struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) struct atp_unit *devext = pci_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) struct Scsi_Host *pshost = devext->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) scsi_remove_host(pshost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) free_irq(pshost->irq, pshost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) pci_release_regions(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) pci_disable_device(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) atp870u_free_tables(pshost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) scsi_host_put(pshost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) static struct scsi_host_template atp870u_template = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) .module = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) .name = "atp870u" /* name */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) .proc_name = "atp870u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) .show_info = atp870u_show_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) .info = atp870u_info /* info */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) .queuecommand = atp870u_queuecommand /* queuecommand */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) .eh_abort_handler = atp870u_abort /* abort */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) .bios_param = atp870u_biosparam /* biosparm */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) .can_queue = qcnt /* can_queue */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) .this_id = 7 /* SCSI ID */,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) .sg_tablesize = ATP870U_SCATTER /*SG_ALL*/,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) .max_sectors = ATP870U_MAX_SECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) static struct pci_device_id atp870u_id_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, ATP885_DEVID) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, ATP880_DEVID1) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, ATP880_DEVID2) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7610) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612UW) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612U) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612S) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612D) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612SUW) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_8060) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) { 0, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) MODULE_DEVICE_TABLE(pci, atp870u_id_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) static struct pci_driver atp870u_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) .id_table = atp870u_id_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) .name = "atp870u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) .probe = atp870u_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) .remove = atp870u_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) module_pci_driver(atp870u_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) static void atp_is(struct atp_unit *dev, unsigned char c, bool wide_chip, unsigned char lvdmode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) unsigned char i, j, k, rmb, n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) unsigned short int m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) static unsigned char mbuf[512];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) static unsigned char satn[9] = { 0, 0, 0, 0, 0, 0, 0, 6, 6 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) static unsigned char inqd[9] = { 0x12, 0, 0, 0, 0x24, 0, 0, 0x24, 6 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) static unsigned char synn[6] = { 0x80, 1, 3, 1, 0x19, 0x0e };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) unsigned char synu[6] = { 0x80, 1, 3, 1, 0x0a, 0x0e };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) static unsigned char synw[6] = { 0x80, 1, 3, 1, 0x19, 0x0e };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) static unsigned char synw_870[6] = { 0x80, 1, 3, 1, 0x0c, 0x07 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) unsigned char synuw[6] = { 0x80, 1, 3, 1, 0x0a, 0x0e };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) static unsigned char wide[6] = { 0x80, 1, 2, 3, 1, 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) static unsigned char u3[9] = { 0x80, 1, 6, 4, 0x09, 00, 0x0e, 0x01, 0x02 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) for (i = 0; i < 16; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) if (!wide_chip && (i > 7))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) m = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) m = m << i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) if ((m & dev->active_id[c]) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) if (i == dev->host_id[c]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) printk(KERN_INFO " ID: %2d Host Adapter\n", dev->host_id[c]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) atp_writeb_io(dev, c, 0x1b, wide_chip ? 0x01 : 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) atp_writeb_io(dev, c, 1, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) atp_writeb_io(dev, c, 2, 0x7f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) atp_writeb_io(dev, c, 3, satn[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) atp_writeb_io(dev, c, 4, satn[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) atp_writeb_io(dev, c, 5, satn[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) atp_writeb_io(dev, c, 6, satn[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) atp_writeb_io(dev, c, 7, satn[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) atp_writeb_io(dev, c, 8, satn[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) atp_writeb_io(dev, c, 0x0f, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) atp_writeb_io(dev, c, 0x11, dev->id[c][i].devsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) atp_writeb_io(dev, c, 0x12, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) atp_writeb_io(dev, c, 0x13, satn[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) atp_writeb_io(dev, c, 0x14, satn[7]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) j = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) if ((j & 0x08) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) j = (j & 0x07) | 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) atp_writeb_io(dev, c, 0x15, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) atp_writeb_io(dev, c, 0x18, satn[8]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) if (atp_readb_io(dev, c, 0x17) != 0x11 && atp_readb_io(dev, c, 0x17) != 0x8e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) while (atp_readb_io(dev, c, 0x17) != 0x8e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) dev->active_id[c] |= m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) atp_writeb_io(dev, c, 0x10, 0x30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) if (is885(dev) || is880(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) atp_writeb_io(dev, c, 0x14, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) else /* result of is870() merge - is this a bug? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) atp_writeb_io(dev, c, 0x04, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) phase_cmd:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) j = atp_readb_io(dev, c, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) if (j != 0x16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) atp_writeb_io(dev, c, 0x10, 0x41);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) goto phase_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) sel_ok:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) atp_writeb_io(dev, c, 3, inqd[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) atp_writeb_io(dev, c, 4, inqd[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) atp_writeb_io(dev, c, 5, inqd[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) atp_writeb_io(dev, c, 6, inqd[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) atp_writeb_io(dev, c, 7, inqd[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) atp_writeb_io(dev, c, 8, inqd[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) atp_writeb_io(dev, c, 0x0f, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) atp_writeb_io(dev, c, 0x11, dev->id[c][i].devsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) atp_writeb_io(dev, c, 0x12, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) atp_writeb_io(dev, c, 0x13, inqd[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) atp_writeb_io(dev, c, 0x14, inqd[7]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) atp_writeb_io(dev, c, 0x18, inqd[8]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) if (atp_readb_io(dev, c, 0x17) != 0x11 && atp_readb_io(dev, c, 0x17) != 0x8e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) while (atp_readb_io(dev, c, 0x17) != 0x8e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) if (wide_chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) atp_writeb_io(dev, c, 0x1b, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) rd_inq_data:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) k = atp_readb_io(dev, c, 0x1f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) if ((k & 0x01) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) mbuf[j++] = atp_readb_io(dev, c, 0x19);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) goto rd_inq_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) if ((k & 0x80) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) goto rd_inq_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) j = atp_readb_io(dev, c, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) if (j == 0x16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) goto inq_ok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) atp_writeb_io(dev, c, 0x10, 0x46);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) atp_writeb_io(dev, c, 0x12, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) atp_writeb_io(dev, c, 0x13, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) atp_writeb_io(dev, c, 0x14, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) if (atp_readb_io(dev, c, 0x17) != 0x16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) goto sel_ok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) inq_ok:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) mbuf[36] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) printk(KERN_INFO " ID: %2d %s\n", i, &mbuf[8]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) dev->id[c][i].devtype = mbuf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) rmb = mbuf[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) n = mbuf[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) if (!wide_chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) goto not_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) if ((mbuf[7] & 0x60) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) goto not_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) if (is885(dev) || is880(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) if ((i < 8) && ((dev->global_map[c] & 0x20) == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) goto not_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) } else { /* result of is870() merge - is this a bug? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) if ((dev->global_map[c] & 0x20) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) goto not_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) if (lvdmode == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) goto chg_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) if (dev->sp[c][i] != 0x04) // force u2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) goto chg_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) atp_writeb_io(dev, c, 0x1b, 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) atp_writeb_io(dev, c, 3, satn[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) atp_writeb_io(dev, c, 4, satn[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) atp_writeb_io(dev, c, 5, satn[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) atp_writeb_io(dev, c, 6, satn[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) atp_writeb_io(dev, c, 7, satn[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) atp_writeb_io(dev, c, 8, satn[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) atp_writeb_io(dev, c, 0x0f, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) atp_writeb_io(dev, c, 0x11, dev->id[c][i].devsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) atp_writeb_io(dev, c, 0x12, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) atp_writeb_io(dev, c, 0x13, satn[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) atp_writeb_io(dev, c, 0x14, satn[7]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) atp_writeb_io(dev, c, 0x18, satn[8]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) if (atp_readb_io(dev, c, 0x17) != 0x11 && atp_readb_io(dev, c, 0x17) != 0x8e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) while (atp_readb_io(dev, c, 0x17) != 0x8e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) try_u3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) atp_writeb_io(dev, c, 0x14, 0x09);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) atp_writeb_io(dev, c, 0x18, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) if ((atp_readb_io(dev, c, 0x1f) & 0x01) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) atp_writeb_io(dev, c, 0x19, u3[j++]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) while ((atp_readb_io(dev, c, 0x17) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) j = atp_readb_io(dev, c, 0x17) & 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) if (j == 0x0f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) goto u3p_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) if (j == 0x0a) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) goto u3p_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) if (j == 0x0e) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) goto try_u3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) u3p_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) atp_writeb_io(dev, c, 0x18, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) if ((atp_readb_io(dev, c, 0x1f) & 0x01) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) atp_writeb_io(dev, c, 0x19, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) j = atp_readb_io(dev, c, 0x17) & 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) if (j == 0x0f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) goto u3p_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) if (j == 0x0a) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) goto u3p_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) if (j == 0x0e) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) goto u3p_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) u3p_in:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) atp_writeb_io(dev, c, 0x14, 0x09);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) atp_writeb_io(dev, c, 0x18, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) k = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) u3p_in1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) j = atp_readb_io(dev, c, 0x1f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) if ((j & 0x01) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) mbuf[k++] = atp_readb_io(dev, c, 0x19);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) goto u3p_in1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) if ((j & 0x80) == 0x00) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) goto u3p_in1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) j = atp_readb_io(dev, c, 0x17) & 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) if (j == 0x0f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) goto u3p_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) if (j == 0x0a) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) goto u3p_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) if (j == 0x0e) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) goto u3p_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) u3p_cmd:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) atp_writeb_io(dev, c, 0x10, 0x30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) atp_writeb_io(dev, c, 0x14, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) j = atp_readb_io(dev, c, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) if (j != 0x16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) if (j == 0x4e) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) goto u3p_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) if (mbuf[0] != 0x01) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) goto chg_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) if (mbuf[1] != 0x06) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) goto chg_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) if (mbuf[2] != 0x04) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) goto chg_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) if (mbuf[3] == 0x09) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) m = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) m = m << i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) dev->wide_id[c] |= m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) dev->id[c][i].devsp = 0xce;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) printk("dev->id[%2d][%2d].devsp = %2x\n",c,i,dev->id[c][i].devsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) chg_wide:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) atp_writeb_io(dev, c, 0x1b, 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) atp_writeb_io(dev, c, 3, satn[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) atp_writeb_io(dev, c, 4, satn[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) atp_writeb_io(dev, c, 5, satn[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) atp_writeb_io(dev, c, 6, satn[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) atp_writeb_io(dev, c, 7, satn[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) atp_writeb_io(dev, c, 8, satn[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) atp_writeb_io(dev, c, 0x0f, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) atp_writeb_io(dev, c, 0x11, dev->id[c][i].devsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) atp_writeb_io(dev, c, 0x12, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) atp_writeb_io(dev, c, 0x13, satn[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) atp_writeb_io(dev, c, 0x14, satn[7]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) atp_writeb_io(dev, c, 0x18, satn[8]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) if (atp_readb_io(dev, c, 0x17) != 0x11 && atp_readb_io(dev, c, 0x17) != 0x8e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) while (atp_readb_io(dev, c, 0x17) != 0x8e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) try_wide:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) atp_writeb_io(dev, c, 0x14, 0x05);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) atp_writeb_io(dev, c, 0x18, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) if ((atp_readb_io(dev, c, 0x1f) & 0x01) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) atp_writeb_io(dev, c, 0x19, wide[j++]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) while ((atp_readb_io(dev, c, 0x17) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) j = atp_readb_io(dev, c, 0x17) & 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) if (j == 0x0f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) goto widep_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) if (j == 0x0a) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) goto widep_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) if (j == 0x0e) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) goto try_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) widep_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) atp_writeb_io(dev, c, 0x18, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) if ((atp_readb_io(dev, c, 0x1f) & 0x01) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) atp_writeb_io(dev, c, 0x19, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) j = atp_readb_io(dev, c, 0x17) & 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) if (j == 0x0f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) goto widep_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) if (j == 0x0a) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) goto widep_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) if (j == 0x0e) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) goto widep_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) widep_in:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) atp_writeb_io(dev, c, 0x14, 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) atp_writeb_io(dev, c, 0x18, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) k = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) widep_in1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) j = atp_readb_io(dev, c, 0x1f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) if ((j & 0x01) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) mbuf[k++] = atp_readb_io(dev, c, 0x19);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) goto widep_in1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) if ((j & 0x80) == 0x00) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) goto widep_in1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) j = atp_readb_io(dev, c, 0x17) & 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) if (j == 0x0f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) goto widep_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) if (j == 0x0a) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) goto widep_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) if (j == 0x0e) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) goto widep_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) widep_cmd:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) atp_writeb_io(dev, c, 0x10, 0x30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) atp_writeb_io(dev, c, 0x14, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) j = atp_readb_io(dev, c, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) if (j != 0x16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) if (j == 0x4e) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) goto widep_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) if (mbuf[0] != 0x01) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) goto not_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) if (mbuf[1] != 0x02) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) goto not_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) if (mbuf[2] != 0x03) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) goto not_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) if (mbuf[3] != 0x01) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) goto not_wide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) m = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) m = m << i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) dev->wide_id[c] |= m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) not_wide:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) if ((dev->id[c][i].devtype == 0x00) || (dev->id[c][i].devtype == 0x07) || ((dev->id[c][i].devtype == 0x05) && ((n & 0x10) != 0))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) m = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) m = m << i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) if ((dev->async[c] & m) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) goto set_sync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) set_sync:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) if ((!is885(dev) && !is880(dev)) || (dev->sp[c][i] == 0x02)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) synu[4] = 0x0c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) synuw[4] = 0x0c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) if (dev->sp[c][i] >= 0x03) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) synu[4] = 0x0a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) synuw[4] = 0x0a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) if ((m & dev->wide_id[c]) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) j |= 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) atp_writeb_io(dev, c, 0x1b, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) atp_writeb_io(dev, c, 3, satn[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) atp_writeb_io(dev, c, 4, satn[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) atp_writeb_io(dev, c, 5, satn[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) atp_writeb_io(dev, c, 6, satn[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) atp_writeb_io(dev, c, 7, satn[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) atp_writeb_io(dev, c, 8, satn[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) atp_writeb_io(dev, c, 0x0f, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) atp_writeb_io(dev, c, 0x11, dev->id[c][i].devsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) atp_writeb_io(dev, c, 0x12, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) atp_writeb_io(dev, c, 0x13, satn[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) atp_writeb_io(dev, c, 0x14, satn[7]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) atp_writeb_io(dev, c, 0x18, satn[8]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) if (atp_readb_io(dev, c, 0x17) != 0x11 && atp_readb_io(dev, c, 0x17) != 0x8e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) while (atp_readb_io(dev, c, 0x17) != 0x8e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) try_sync:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) atp_writeb_io(dev, c, 0x14, 0x06);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) atp_writeb_io(dev, c, 0x18, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) if ((atp_readb_io(dev, c, 0x1f) & 0x01) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) if ((m & dev->wide_id[c]) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) if (is885(dev) || is880(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) if ((m & dev->ultra_map[c]) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) atp_writeb_io(dev, c, 0x19, synuw[j++]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) atp_writeb_io(dev, c, 0x19, synw[j++]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) atp_writeb_io(dev, c, 0x19, synw_870[j++]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) if ((m & dev->ultra_map[c]) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) atp_writeb_io(dev, c, 0x19, synu[j++]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) atp_writeb_io(dev, c, 0x19, synn[j++]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) while ((atp_readb_io(dev, c, 0x17) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) j = atp_readb_io(dev, c, 0x17) & 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) if (j == 0x0f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) goto phase_ins;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) if (j == 0x0a) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) goto phase_cmds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) if (j == 0x0e) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) goto try_sync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) phase_outs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) atp_writeb_io(dev, c, 0x18, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) if ((atp_readb_io(dev, c, 0x1f) & 0x01) != 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) atp_writeb_io(dev, c, 0x19, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) j = atp_readb_io(dev, c, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) if (j == 0x85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) goto tar_dcons;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) j &= 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) if (j == 0x0f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) goto phase_ins;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) if (j == 0x0a) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) goto phase_cmds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) if (j == 0x0e) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) goto phase_outs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) phase_ins:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) if (is885(dev) || is880(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) atp_writeb_io(dev, c, 0x14, 0x06);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) atp_writeb_io(dev, c, 0x14, 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) atp_writeb_io(dev, c, 0x18, 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) k = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) phase_ins1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) j = atp_readb_io(dev, c, 0x1f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) if ((j & 0x01) != 0x00) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) mbuf[k++] = atp_readb_io(dev, c, 0x19);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) goto phase_ins1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) if ((j & 0x80) == 0x00) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) goto phase_ins1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) while ((atp_readb_io(dev, c, 0x17) & 0x80) == 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) j = atp_readb_io(dev, c, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) if (j == 0x85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) goto tar_dcons;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) j &= 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) if (j == 0x0f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) goto phase_ins;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) if (j == 0x0a) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) goto phase_cmds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) if (j == 0x0e) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) goto phase_outs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) phase_cmds:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) atp_writeb_io(dev, c, 0x10, 0x30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) tar_dcons:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) atp_writeb_io(dev, c, 0x14, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) atp_writeb_io(dev, c, 0x18, 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) cpu_relax();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) j = atp_readb_io(dev, c, 0x17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) if (j != 0x16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) if (mbuf[0] != 0x01) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) if (mbuf[1] != 0x03) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) if (mbuf[4] == 0x00) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) if (mbuf[3] > 0x64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) if (is885(dev) || is880(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) if (mbuf[4] > 0x0e) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) mbuf[4] = 0x0e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) if (mbuf[4] > 0x0c) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) mbuf[4] = 0x0c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) dev->id[c][i].devsp = mbuf[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) if (is885(dev) || is880(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) if (mbuf[3] < 0x0c) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) j = 0xb0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) goto set_syn_ok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) if ((mbuf[3] < 0x0d) && (rmb == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) j = 0xa0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) goto set_syn_ok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) if (mbuf[3] < 0x1a) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) j = 0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) goto set_syn_ok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) if (mbuf[3] < 0x33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) j = 0x40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) goto set_syn_ok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) if (mbuf[3] < 0x4c) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) j = 0x50;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) goto set_syn_ok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) j = 0x60;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) set_syn_ok:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) dev->id[c][i].devsp = (dev->id[c][i].devsp & 0x0f) | j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) #ifdef ED_DBGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) printk("dev->id[%2d][%2d].devsp = %2x\n",c,i,dev->id[c][i].devsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) }