drivers/ata/pata_parport/epia.c

Source file repositories/reference/linux-study-clean/drivers/ata/pata_parport/epia.c

File Facts

System
Linux kernel
Corpus path
drivers/ata/pata_parport/epia.c
Extension
.c
Size
6349 bytes
Lines
313
Domain
Driver Families
Bucket
drivers/ata
Inferred role
Driver Families: implementation source
Status
source 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

if (d != last) {
				last = d;
				w0(d);
			}
			w2(4 + ph);
			ph = 1 - ph;
		}
		w2(7); w2(4);
		break;
	case 3:
		if (count < 512)
			WR(0x84, 1);
		w3(0x40);
		for (k = 0; k < count; k++)
			w4(buf[k]);
		if (count < 512)
			WR(0x84, 0);
		break;
	case 4:
		if (count < 512)
			WR(0x84, 1);
		w3(0x40);
		for (k = 0; k < count / 2; k++)
			w4w(((u16 *)buf)[k]);
		if (count < 512)
			WR(0x84, 0);
		break;
	case 5:
		if (count < 512)
			WR(0x84, 1);
		w3(0x40);
		for (k = 0; k < count / 4; k++)
			w4l(((u32 *)buf)[k]);
		if (count < 512)
			WR(0x84, 0);
		break;
	}
}

static int epia_test_proto(struct pi_adapter *pi)
{
	int j, k, f;
	int e[2] = { 0, 0 };
	char scratch[512];

	epia_connect(pi);
	for (j = 0; j < 2; j++) {
		WR(6, 0xa0 + j * 0x10);
		for (k = 0; k < 256; k++) {
			WR(2, k ^ 0xaa);
			WR(3, k ^ 0x55);
			if (RR(2) != (k ^ 0xaa))
				e[j]++;
		}
		WR(2, 1); WR(3, 1);
	}
	epia_disconnect(pi);

	f = 0;
	epia_connect(pi);
	WR(0x84, 8);
	epia_read_block(pi, scratch, 512);
	for (k = 0; k < 256; k++) {
		if ((scratch[2 * k] & 0xff) != ((k + 1) & 0xff))
			f++;
		if ((scratch[2 * k + 1] & 0xff) != ((-2 - k) & 0xff))
			f++;
	}
	WR(0x84, 0);
	epia_disconnect(pi);

	dev_dbg(&pi->dev, "epia: port 0x%x, mode %d, test=(%d,%d,%d)\n",
		pi->port, pi->mode, e[0], e[1], f);

	return (e[0] && e[1]) || f;
}


static void epia_log_adapter(struct pi_adapter *pi)
{
	char *mode[6] = { "4-bit", "5/3", "8-bit", "EPP-8", "EPP-16", "EPP-32"};

	dev_info(&pi->dev,
		 "Shuttle EPIA at 0x%x, mode %d (%s), delay %d\n",
		 pi->port, pi->mode, mode[pi->mode], pi->delay);
}

static struct pi_protocol epia = {
	.owner		= THIS_MODULE,
	.name		= "epia",

Annotation

Implementation Notes