drivers/scsi/atp870u.c

Source file repositories/reference/linux-study-clean/drivers/scsi/atp870u.c

File Facts

System
Linux kernel
Corpus path
drivers/scsi/atp870u.c
Extension
.c
Size
60284 bytes
Lines
2383
Domain
Driver Families
Bucket
drivers/scsi
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

static struct pci_driver atp870u_driver = {
	.id_table	= atp870u_id_table,
	.name		= "atp870u",
	.probe		= atp870u_probe,
	.remove		= atp870u_remove,
};

module_pci_driver(atp870u_driver);

static void atp_is(struct atp_unit *dev, unsigned char c, bool wide_chip,
		   unsigned char lvdmode)
{
	unsigned char i, j, k, rmb, n;
	unsigned short int m;
	static unsigned char mbuf[512];
	static unsigned char satn[9] = { 0, 0, 0, 0, 0, 0, 0, 6, 6 };
	static unsigned char inqd[9] = { 0x12, 0, 0, 0, 0x24, 0, 0, 0x24, 6 };
	static unsigned char synn[6] = { 0x80, 1, 3, 1, 0x19, 0x0e };
	unsigned char synu[6] = { 0x80, 1, 3, 1, 0x0a, 0x0e };
	static unsigned char synw[6] = { 0x80, 1, 3, 1, 0x19, 0x0e };
	static unsigned char synw_870[6] = { 0x80, 1, 3, 1, 0x0c, 0x07 };
	unsigned char synuw[6] = { 0x80, 1, 3, 1, 0x0a, 0x0e };
	static unsigned char wide[6] = { 0x80, 1, 2, 3, 1, 0 };
	static unsigned char u3[9] = { 0x80, 1, 6, 4, 0x09, 00, 0x0e, 0x01, 0x02 };

	for (i = 0; i < 16; i++) {
		if (!wide_chip && (i > 7))
			break;
		m = 1;
		m = m << i;
		if ((m & dev->active_id[c]) != 0) {
			continue;
		}
		if (i == dev->host_id[c]) {
			printk(KERN_INFO "         ID: %2d  Host Adapter\n", dev->host_id[c]);
			continue;
		}
		atp_writeb_io(dev, c, 0x1b, wide_chip ? 0x01 : 0x00);
		atp_writeb_io(dev, c, 1, 0x08);
		atp_writeb_io(dev, c, 2, 0x7f);
		atp_writeb_io(dev, c, 3, satn[0]);
		atp_writeb_io(dev, c, 4, satn[1]);
		atp_writeb_io(dev, c, 5, satn[2]);
		atp_writeb_io(dev, c, 6, satn[3]);
		atp_writeb_io(dev, c, 7, satn[4]);
		atp_writeb_io(dev, c, 8, satn[5]);
		atp_writeb_io(dev, c, 0x0f, 0);
		atp_writeb_io(dev, c, 0x11, dev->id[c][i].devsp);
		atp_writeb_io(dev, c, 0x12, 0);
		atp_writeb_io(dev, c, 0x13, satn[6]);
		atp_writeb_io(dev, c, 0x14, satn[7]);
		j = i;
		if ((j & 0x08) != 0) {
			j = (j & 0x07) | 0x40;
		}
		atp_writeb_io(dev, c, 0x15, j);
		atp_writeb_io(dev, c, 0x18, satn[8]);

		while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00)
			cpu_relax();

		if (atp_readb_io(dev, c, 0x17) != 0x11 && atp_readb_io(dev, c, 0x17) != 0x8e)
			continue;

		while (atp_readb_io(dev, c, 0x17) != 0x8e)
			cpu_relax();

		dev->active_id[c] |= m;

		atp_writeb_io(dev, c, 0x10, 0x30);
		if (is885(dev) || is880(dev))
			atp_writeb_io(dev, c, 0x14, 0x00);
		else /* result of is870() merge - is this a bug? */
			atp_writeb_io(dev, c, 0x04, 0x00);

phase_cmd:
		atp_writeb_io(dev, c, 0x18, 0x08);

		while ((atp_readb_io(dev, c, 0x1f) & 0x80) == 0x00)
			cpu_relax();

		j = atp_readb_io(dev, c, 0x17);
		if (j != 0x16) {
			atp_writeb_io(dev, c, 0x10, 0x41);
			goto phase_cmd;
		}
sel_ok:
		atp_writeb_io(dev, c, 3, inqd[0]);
		atp_writeb_io(dev, c, 4, inqd[1]);
		atp_writeb_io(dev, c, 5, inqd[2]);

Annotation

Implementation Notes