libata: clean up ZPODD when a port is detached
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / ata / pata_isapnp.c
CommitLineData
669a5db4
JG
1
2/*
3 * pata-isapnp.c - ISA PnP PATA controller driver.
ab771630 4 * Copyright 2005/2006 Red Hat Inc, all rights reserved.
669a5db4
JG
5 *
6 * Based in part on ide-pnp.c by Andrey Panin <pazke@donpac.ru>
7 */
8
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>
18
19#define DRV_NAME "pata_isapnp"
c96f1732 20#define DRV_VERSION "0.2.5"
669a5db4
JG
21
22static struct scsi_host_template isapnp_sht = {
68d1d07b 23 ATA_PIO_SHT(DRV_NAME),
669a5db4
JG
24};
25
26static struct ata_port_operations isapnp_port_ops = {
029cfd6b 27 .inherits = &ata_sff_port_ops,
a73984a0 28 .cable_detect = ata_cable_40wire,
669a5db4
JG
29};
30
c96f1732
AC
31static struct ata_port_operations isapnp_noalt_port_ops = {
32 .inherits = &ata_sff_port_ops,
33 .cable_detect = ata_cable_40wire,
34 /* No altstatus so we don't want to use the lost interrupt poll */
35 .lost_interrupt = ATA_OP_NULL,
36};
37
669a5db4
JG
38/**
39 * isapnp_init_one - attach an isapnp interface
40 * @idev: PnP device
41 * @dev_id: matching detect line
42 *
43 * Register an ISA bus IDE interface. Such interfaces are PIO 0 and
44 * non shared IRQ.
45 */
46
47static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
48{
5d728824
TH
49 struct ata_host *host;
50 struct ata_port *ap;
0d5ff566 51 void __iomem *cmd_addr, *ctl_addr;
91e33d31
AC
52 int irq = 0;
53 irq_handler_t handler = NULL;
669a5db4
JG
54
55 if (pnp_port_valid(idev, 0) == 0)
56 return -ENODEV;
57
91e33d31
AC
58 if (pnp_irq_valid(idev, 0)) {
59 irq = pnp_irq(idev, 0);
9363c382 60 handler = ata_sff_interrupt;
91e33d31 61 }
669a5db4 62
5d728824
TH
63 /* allocate host */
64 host = ata_host_alloc(&idev->dev, 1);
65 if (!host)
66 return -ENOMEM;
67
68 /* acquire resources and fill host */
0d5ff566
TH
69 cmd_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 0), 8);
70 if (!cmd_addr)
71 return -ENOMEM;
72
5d728824
TH
73 ap = host->ports[0];
74
c96f1732 75 ap->ops = &isapnp_noalt_port_ops;
14bdef98 76 ap->pio_mask = ATA_PIO0;
5d728824
TH
77 ap->flags |= ATA_FLAG_SLAVE_POSS;
78
79 ap->ioaddr.cmd_addr = cmd_addr;
669a5db4
JG
80
81 if (pnp_port_valid(idev, 1) == 0) {
0d5ff566
TH
82 ctl_addr = devm_ioport_map(&idev->dev,
83 pnp_port_start(idev, 1), 1);
5d728824
TH
84 ap->ioaddr.altstatus_addr = ctl_addr;
85 ap->ioaddr.ctl_addr = ctl_addr;
c96f1732 86 ap->ops = &isapnp_port_ops;
669a5db4 87 }
669a5db4 88
9363c382 89 ata_sff_std_ports(&ap->ioaddr);
5d728824 90
cbcdd875
TH
91 ata_port_desc(ap, "cmd 0x%llx ctl 0x%llx",
92 (unsigned long long)pnp_port_start(idev, 0),
93 (unsigned long long)pnp_port_start(idev, 1));
94
5d728824 95 /* activate */
91e33d31 96 return ata_host_activate(host, irq, handler, 0,
5d728824 97 &isapnp_sht);
669a5db4
JG
98}
99
100/**
101 * isapnp_remove_one - unplug an isapnp interface
102 * @idev: PnP device
103 *
104 * Remove a previously configured PnP ATA port. Called only on module
105 * unload events as the core does not currently deal with ISAPnP docking.
106 */
107
108static void isapnp_remove_one(struct pnp_dev *idev)
109{
110 struct device *dev = &idev->dev;
111 struct ata_host *host = dev_get_drvdata(dev);
112
24dc5f33 113 ata_host_detach(host);
669a5db4
JG
114}
115
116static struct pnp_device_id isapnp_devices[] = {
117 /* Generic ESDI/IDE/ATA compatible hard disk controller */
118 {.id = "PNP0600", .driver_data = 0},
119 {.id = ""}
120};
121
6a286a6d
JG
122MODULE_DEVICE_TABLE(pnp, isapnp_devices);
123
669a5db4
JG
124static struct pnp_driver isapnp_driver = {
125 .name = DRV_NAME,
126 .id_table = isapnp_devices,
127 .probe = isapnp_init_one,
128 .remove = isapnp_remove_one,
129};
130
131static int __init isapnp_init(void)
132{
133 return pnp_register_driver(&isapnp_driver);
134}
135
136static void __exit isapnp_exit(void)
137{
138 pnp_unregister_driver(&isapnp_driver);
139}
140
141MODULE_AUTHOR("Alan Cox");
142MODULE_DESCRIPTION("low-level driver for ISA PnP ATA");
143MODULE_LICENSE("GPL");
144MODULE_VERSION(DRV_VERSION);
145
146module_init(isapnp_init);
147module_exit(isapnp_exit);