drivers/ata/pata_parport/frpw.c

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

File Facts

System
Linux kernel
Corpus path
drivers/ata/pata_parport/frpw.c
Extension
.c
Size
6361 bytes
Lines
299
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

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * (c) 1996-1998  Grant R. Guenther <grant@torque.net>
 *
 * frpw.c is a low-level protocol driver for the Freecom "Power" parallel port
 * IDE adapter.
 *
 * Some applications of this adapter may require a "printer" reset prior to
 * loading the driver.  This can be done by loading and unloading the "lp"
 * driver, or it can be done by this driver if you define FRPW_HARD_RESET.
 * The latter is not recommended as it may upset devices on other ports.
 */

#include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/wait.h>
#include <asm/io.h>
#include "pata_parport.h"

#define cec4		w2(0xc);w2(0xe);w2(0xe);w2(0xc);w2(4);w2(4);w2(4);
#define j44(l,h)	(((l>>4)&0x0f)|(h&0xf0))

/*
 * cont = 0 - access the IDE register file
 * cont = 1 - access the IDE command set
 */
static int  cont_map[2] = { 0x08, 0x10 };

static int frpw_read_regr(struct pi_adapter *pi, int cont, int regr)
{
	int h, l, r;

	r = regr + cont_map[cont];

	w2(4);
	w0(r); cec4;
	w2(6); l = r1();
	w2(4); h = r1();
	w2(4);

	return j44(l, h);
}

static void frpw_write_regr(struct pi_adapter *pi, int cont, int regr, int val)
{
	int r = regr + cont_map[cont];

	w2(4); w0(r); cec4;
	w0(val);
	w2(5); w2(7); w2(5); w2(4);
}

static void frpw_read_block_int(struct pi_adapter *pi, char *buf, int count,
				int regr)
{
	int h, l, k, ph;

	switch (pi->mode) {
	case 0:
		w2(4); w0(regr); cec4;
		for (k = 0; k < count; k++) {
			w2(6); l = r1();
			w2(4); h = r1();
			buf[k] = j44(l, h);
		}
		w2(4);
		break;

	case 1:
		ph = 2;
		w2(4); w0(regr + 0xc0); cec4;
		w0(0xff);
		for (k = 0; k < count; k++) {
			w2(0xa4 + ph);
			buf[k] = r0();
			ph = 2 - ph;
		}
		w2(0xac); w2(0xa4); w2(4);
		break;

	case 2:
		w2(4); w0(regr + 0x80); cec4;
		for (k = 0; k < count; k++)
			buf[k] = r4();
		w2(0xac); w2(0xa4);
		w2(4);
		break;

Annotation

Implementation Notes