drivers/ata/pata_gayle.c

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

File Facts

System
Linux kernel
Corpus path
drivers/ata/pata_gayle.c
Extension
.c
Size
5300 bytes
Lines
218
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_gayle_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_gayle_irq_check(struct ata_port *ap)
{
	u8 ch;

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

	return !!(ch & GAYLE_IRQ_IDE);
}

static void pata_gayle_irq_clear(struct ata_port *ap)
{
	(void)z_readb((unsigned long)ap->ioaddr.status_addr);
	z_writeb(0x7c, (unsigned long)ap->private_data);
}

static struct ata_port_operations pata_gayle_a1200_ops = {
	.inherits	= &ata_sff_port_ops,
	.sff_data_xfer	= pata_gayle_data_xfer,
	.sff_irq_check	= pata_gayle_irq_check,
	.sff_irq_clear	= pata_gayle_irq_clear,
	.cable_detect	= ata_cable_unknown,
	.set_mode	= pata_gayle_set_mode,
};

static struct ata_port_operations pata_gayle_a4000_ops = {
	.inherits	= &ata_sff_port_ops,
	.sff_data_xfer	= pata_gayle_data_xfer,
	.cable_detect	= ata_cable_unknown,
	.set_mode	= pata_gayle_set_mode,
};

static int pata_gayle_init_one(struct platform_device *pdev)
{
	struct resource *res;
	struct gayle_ide_platform_data *pdata;
	struct ata_host *host;
	struct ata_port *ap;
	void __iomem *base;
	int ret;

	pdata = dev_get_platdata(&pdev->dev);

	dev_info(&pdev->dev, "Amiga Gayle IDE controller (A%u style)\n",
		pdata->explicit_ack ? 1200 : 4000);

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res)
		return -ENODEV;

	if (!devm_request_mem_region(&pdev->dev, res->start,
				     resource_size(res), DRV_NAME)) {
		pr_err(DRV_NAME ": resources busy\n");
		return -EBUSY;
	}

	/* allocate host */
	host = ata_host_alloc(&pdev->dev, 1);
	if (!host)

Annotation

Implementation Notes