3 * pata-isapnp.c - ISA PnP PATA controller driver.
4 * Copyright 2005/2006 Red Hat Inc <alan@redhat.com>, all rights reserved.
6 * Based in part on ide-pnp.c by Andrey Panin <pazke@donpac.ru>
9 #include <linux/kernel.h>
10 #include <linux/module.h>
11 #include <linux/isapnp.h>
12 #include <linux/init.h>
13 #include <linux/blkdev.h>
14 #include <linux/delay.h>
15 #include <scsi/scsi_host.h>
16 #include <linux/ata.h>
17 #include <linux/libata.h>
19 #define DRV_NAME "pata_isapnp"
20 #define DRV_VERSION "0.2.2"
22 static struct scsi_host_template isapnp_sht = {
23 ATA_PIO_SHT(DRV_NAME),
26 static struct ata_port_operations isapnp_port_ops = {
27 .tf_load = ata_tf_load,
28 .tf_read = ata_tf_read,
29 .check_status = ata_check_status,
30 .exec_command = ata_exec_command,
31 .dev_select = ata_std_dev_select,
33 .freeze = ata_bmdma_freeze,
34 .thaw = ata_bmdma_thaw,
35 .error_handler = ata_bmdma_error_handler,
36 .post_internal_cmd = ata_bmdma_post_internal_cmd,
37 .cable_detect = ata_cable_40wire,
39 .qc_prep = ata_qc_prep,
40 .qc_issue = ata_qc_issue_prot,
42 .data_xfer = ata_data_xfer,
44 .irq_clear = ata_noop_irq_clear,
47 .port_start = ata_sff_port_start,
51 * isapnp_init_one - attach an isapnp interface
53 * @dev_id: matching detect line
55 * Register an ISA bus IDE interface. Such interfaces are PIO 0 and
59 static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
61 struct ata_host *host;
63 void __iomem *cmd_addr, *ctl_addr;
65 irq_handler_t handler = NULL;
67 if (pnp_port_valid(idev, 0) == 0)
70 if (pnp_irq_valid(idev, 0)) {
71 irq = pnp_irq(idev, 0);
72 handler = ata_interrupt;
76 host = ata_host_alloc(&idev->dev, 1);
80 /* acquire resources and fill host */
81 cmd_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 0), 8);
87 ap->ops = &isapnp_port_ops;
89 ap->flags |= ATA_FLAG_SLAVE_POSS;
91 ap->ioaddr.cmd_addr = cmd_addr;
93 if (pnp_port_valid(idev, 1) == 0) {
94 ctl_addr = devm_ioport_map(&idev->dev,
95 pnp_port_start(idev, 1), 1);
96 ap->ioaddr.altstatus_addr = ctl_addr;
97 ap->ioaddr.ctl_addr = ctl_addr;
100 ata_std_ports(&ap->ioaddr);
102 ata_port_desc(ap, "cmd 0x%llx ctl 0x%llx",
103 (unsigned long long)pnp_port_start(idev, 0),
104 (unsigned long long)pnp_port_start(idev, 1));
107 return ata_host_activate(host, irq, handler, 0,
112 * isapnp_remove_one - unplug an isapnp interface
115 * Remove a previously configured PnP ATA port. Called only on module
116 * unload events as the core does not currently deal with ISAPnP docking.
119 static void isapnp_remove_one(struct pnp_dev *idev)
121 struct device *dev = &idev->dev;
122 struct ata_host *host = dev_get_drvdata(dev);
124 ata_host_detach(host);
127 static struct pnp_device_id isapnp_devices[] = {
128 /* Generic ESDI/IDE/ATA compatible hard disk controller */
129 {.id = "PNP0600", .driver_data = 0},
133 MODULE_DEVICE_TABLE(pnp, isapnp_devices);
135 static struct pnp_driver isapnp_driver = {
137 .id_table = isapnp_devices,
138 .probe = isapnp_init_one,
139 .remove = isapnp_remove_one,
142 static int __init isapnp_init(void)
144 return pnp_register_driver(&isapnp_driver);
147 static void __exit isapnp_exit(void)
149 pnp_unregister_driver(&isapnp_driver);
152 MODULE_AUTHOR("Alan Cox");
153 MODULE_DESCRIPTION("low-level driver for ISA PnP ATA");
154 MODULE_LICENSE("GPL");
155 MODULE_VERSION(DRV_VERSION);
157 module_init(isapnp_init);
158 module_exit(isapnp_exit);