s3c2410fb: make use of default_display settings
[linux-2.6/linux-2.6-openrd.git] / drivers / ata / pata_isapnp.c
blob88ab0e1d353fb506d1ac1de6b3b9eac1d81d6bb9
2 /*
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>
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 .module = THIS_MODULE,
24 .name = DRV_NAME,
25 .ioctl = ata_scsi_ioctl,
26 .queuecommand = ata_scsi_queuecmd,
27 .can_queue = ATA_DEF_QUEUE,
28 .this_id = ATA_SHT_THIS_ID,
29 .sg_tablesize = LIBATA_MAX_PRD,
30 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
31 .emulated = ATA_SHT_EMULATED,
32 .use_clustering = ATA_SHT_USE_CLUSTERING,
33 .proc_name = DRV_NAME,
34 .dma_boundary = ATA_DMA_BOUNDARY,
35 .slave_configure = ata_scsi_slave_config,
36 .slave_destroy = ata_scsi_slave_destroy,
37 .bios_param = ata_std_bios_param,
40 static struct ata_port_operations isapnp_port_ops = {
41 .tf_load = ata_tf_load,
42 .tf_read = ata_tf_read,
43 .check_status = ata_check_status,
44 .exec_command = ata_exec_command,
45 .dev_select = ata_std_dev_select,
47 .freeze = ata_bmdma_freeze,
48 .thaw = ata_bmdma_thaw,
49 .error_handler = ata_bmdma_error_handler,
50 .post_internal_cmd = ata_bmdma_post_internal_cmd,
51 .cable_detect = ata_cable_40wire,
53 .qc_prep = ata_qc_prep,
54 .qc_issue = ata_qc_issue_prot,
56 .data_xfer = ata_data_xfer,
58 .irq_clear = ata_bmdma_irq_clear,
59 .irq_on = ata_irq_on,
61 .port_start = ata_sff_port_start,
64 /**
65 * isapnp_init_one - attach an isapnp interface
66 * @idev: PnP device
67 * @dev_id: matching detect line
69 * Register an ISA bus IDE interface. Such interfaces are PIO 0 and
70 * non shared IRQ.
73 static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
75 struct ata_host *host;
76 struct ata_port *ap;
77 void __iomem *cmd_addr, *ctl_addr;
79 if (pnp_port_valid(idev, 0) == 0)
80 return -ENODEV;
82 /* FIXME: Should selected polled PIO here not fail */
83 if (pnp_irq_valid(idev, 0) == 0)
84 return -ENODEV;
86 /* allocate host */
87 host = ata_host_alloc(&idev->dev, 1);
88 if (!host)
89 return -ENOMEM;
91 /* acquire resources and fill host */
92 cmd_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 0), 8);
93 if (!cmd_addr)
94 return -ENOMEM;
96 ap = host->ports[0];
98 ap->ops = &isapnp_port_ops;
99 ap->pio_mask = 1;
100 ap->flags |= ATA_FLAG_SLAVE_POSS;
102 ap->ioaddr.cmd_addr = cmd_addr;
104 if (pnp_port_valid(idev, 1) == 0) {
105 ctl_addr = devm_ioport_map(&idev->dev,
106 pnp_port_start(idev, 1), 1);
107 ap->ioaddr.altstatus_addr = ctl_addr;
108 ap->ioaddr.ctl_addr = ctl_addr;
111 ata_std_ports(&ap->ioaddr);
113 ata_port_desc(ap, "cmd 0x%llx ctl 0x%llx",
114 (unsigned long long)pnp_port_start(idev, 0),
115 (unsigned long long)pnp_port_start(idev, 1));
117 /* activate */
118 return ata_host_activate(host, pnp_irq(idev, 0), ata_interrupt, 0,
119 &isapnp_sht);
123 * isapnp_remove_one - unplug an isapnp interface
124 * @idev: PnP device
126 * Remove a previously configured PnP ATA port. Called only on module
127 * unload events as the core does not currently deal with ISAPnP docking.
130 static void isapnp_remove_one(struct pnp_dev *idev)
132 struct device *dev = &idev->dev;
133 struct ata_host *host = dev_get_drvdata(dev);
135 ata_host_detach(host);
138 static struct pnp_device_id isapnp_devices[] = {
139 /* Generic ESDI/IDE/ATA compatible hard disk controller */
140 {.id = "PNP0600", .driver_data = 0},
141 {.id = ""}
144 MODULE_DEVICE_TABLE(pnp, isapnp_devices);
146 static struct pnp_driver isapnp_driver = {
147 .name = DRV_NAME,
148 .id_table = isapnp_devices,
149 .probe = isapnp_init_one,
150 .remove = isapnp_remove_one,
153 static int __init isapnp_init(void)
155 return pnp_register_driver(&isapnp_driver);
158 static void __exit isapnp_exit(void)
160 pnp_unregister_driver(&isapnp_driver);
163 MODULE_AUTHOR("Alan Cox");
164 MODULE_DESCRIPTION("low-level driver for ISA PnP ATA");
165 MODULE_LICENSE("GPL");
166 MODULE_VERSION(DRV_VERSION);
168 module_init(isapnp_init);
169 module_exit(isapnp_exit);