hugetlb: make unmap_ref_private multi-size-aware
[zen-stable.git] / drivers / ata / pata_isapnp.c
blob15cdb9148aab2500085a664dad6e0c624aa71f4f
2 /*
3 * pata-isapnp.c - ISA PnP PATA controller driver.
4 * Copyright 2005/2006 Red Hat Inc, all rights reserved.
6 * Based in part on ide-pnp.c by Andrey Panin <pazke@donpac.ru>
7 */
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 .inherits = &ata_sff_port_ops,
28 .cable_detect = ata_cable_40wire,
31 /**
32 * isapnp_init_one - attach an isapnp interface
33 * @idev: PnP device
34 * @dev_id: matching detect line
36 * Register an ISA bus IDE interface. Such interfaces are PIO 0 and
37 * non shared IRQ.
40 static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
42 struct ata_host *host;
43 struct ata_port *ap;
44 void __iomem *cmd_addr, *ctl_addr;
45 int irq = 0;
46 irq_handler_t handler = NULL;
48 if (pnp_port_valid(idev, 0) == 0)
49 return -ENODEV;
51 if (pnp_irq_valid(idev, 0)) {
52 irq = pnp_irq(idev, 0);
53 handler = ata_sff_interrupt;
56 /* allocate host */
57 host = ata_host_alloc(&idev->dev, 1);
58 if (!host)
59 return -ENOMEM;
61 /* acquire resources and fill host */
62 cmd_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 0), 8);
63 if (!cmd_addr)
64 return -ENOMEM;
66 ap = host->ports[0];
68 ap->ops = &isapnp_port_ops;
69 ap->pio_mask = 1;
70 ap->flags |= ATA_FLAG_SLAVE_POSS;
72 ap->ioaddr.cmd_addr = cmd_addr;
74 if (pnp_port_valid(idev, 1) == 0) {
75 ctl_addr = devm_ioport_map(&idev->dev,
76 pnp_port_start(idev, 1), 1);
77 ap->ioaddr.altstatus_addr = ctl_addr;
78 ap->ioaddr.ctl_addr = ctl_addr;
81 ata_sff_std_ports(&ap->ioaddr);
83 ata_port_desc(ap, "cmd 0x%llx ctl 0x%llx",
84 (unsigned long long)pnp_port_start(idev, 0),
85 (unsigned long long)pnp_port_start(idev, 1));
87 /* activate */
88 return ata_host_activate(host, irq, handler, 0,
89 &isapnp_sht);
92 /**
93 * isapnp_remove_one - unplug an isapnp interface
94 * @idev: PnP device
96 * Remove a previously configured PnP ATA port. Called only on module
97 * unload events as the core does not currently deal with ISAPnP docking.
100 static void isapnp_remove_one(struct pnp_dev *idev)
102 struct device *dev = &idev->dev;
103 struct ata_host *host = dev_get_drvdata(dev);
105 ata_host_detach(host);
108 static struct pnp_device_id isapnp_devices[] = {
109 /* Generic ESDI/IDE/ATA compatible hard disk controller */
110 {.id = "PNP0600", .driver_data = 0},
111 {.id = ""}
114 MODULE_DEVICE_TABLE(pnp, isapnp_devices);
116 static struct pnp_driver isapnp_driver = {
117 .name = DRV_NAME,
118 .id_table = isapnp_devices,
119 .probe = isapnp_init_one,
120 .remove = isapnp_remove_one,
123 static int __init isapnp_init(void)
125 return pnp_register_driver(&isapnp_driver);
128 static void __exit isapnp_exit(void)
130 pnp_unregister_driver(&isapnp_driver);
133 MODULE_AUTHOR("Alan Cox");
134 MODULE_DESCRIPTION("low-level driver for ISA PnP ATA");
135 MODULE_LICENSE("GPL");
136 MODULE_VERSION(DRV_VERSION);
138 module_init(isapnp_init);
139 module_exit(isapnp_exit);