drivers/ata/pata_buddha.c

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

File Facts

System
Linux kernel
Corpus path
drivers/ata/pata_buddha.c
Extension
.c
Size
7622 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

if (rw == READ) {
			raw_insw((u16 *)data_addr, (u16 *)pad, 1);
			*buf = pad[0];
		} else {
			pad[0] = *buf;
			raw_outsw((u16 *)data_addr, (u16 *)pad, 1);
		}
		words++;
	}

	return words << 1;
}

/*
 * Provide our own set_mode() as we don't want to change anything that has
 * already been configured..
 */
static int pata_buddha_set_mode(struct ata_link *link,
				struct ata_device **unused)
{
	struct ata_device *dev;

	ata_for_each_dev(dev, link, ENABLED) {
		/* We don't really care */
		dev->pio_mode = dev->xfer_mode = XFER_PIO_0;
		dev->xfer_shift = ATA_SHIFT_PIO;
		dev->flags |= ATA_DFLAG_PIO;
		ata_dev_info(dev, "configured for PIO\n");
	}
	return 0;
}

static bool pata_buddha_irq_check(struct ata_port *ap)
{
	u8 ch;

	ch = z_readb((unsigned long)ap->private_data);

	return !!(ch & 0x80);
}

static void pata_xsurf_irq_clear(struct ata_port *ap)
{
	z_writeb(0, (unsigned long)ap->private_data);
}

static struct ata_port_operations pata_buddha_ops = {
	.inherits	= &ata_sff_port_ops,
	.sff_data_xfer	= pata_buddha_data_xfer,
	.sff_irq_check	= pata_buddha_irq_check,
	.cable_detect	= ata_cable_unknown,
	.set_mode	= pata_buddha_set_mode,
};

static struct ata_port_operations pata_xsurf_ops = {
	.inherits	= &ata_sff_port_ops,
	.sff_data_xfer	= pata_buddha_data_xfer,
	.sff_irq_check	= pata_buddha_irq_check,
	.sff_irq_clear	= pata_xsurf_irq_clear,
	.cable_detect	= ata_cable_unknown,
	.set_mode	= pata_buddha_set_mode,
};

static int pata_buddha_probe(struct zorro_dev *z,
			     const struct zorro_device_id *ent)
{
	static const char * const board_name[] = {
		"Buddha", "Catweasel", "X-Surf"
	};
	struct ata_host *host;
	void __iomem *buddha_board;
	unsigned long board;
	unsigned int type = ent->driver_data;
	unsigned int nr_ports = (type == BOARD_CATWEASEL) ? 3 : 2;
	void *old_drvdata;
	int i;

	dev_info(&z->dev, "%s IDE controller\n", board_name[type]);

	board = z->resource.start;

	if (type != BOARD_XSURF) {
		if (!devm_request_mem_region(&z->dev,
					     board + BUDDHA_BASE1,
					     0x800, DRV_NAME))
			return -ENXIO;
	} else {
		if (!devm_request_mem_region(&z->dev,
					     board + XSURF_BASE1,
					     0x1000, DRV_NAME))

Annotation

Implementation Notes