pata_isapnp.c revision 68d1d07b510bb57a504588adc2bd2758adea0965
1 2/* 3 * pata-isapnp.c - ISA PnP PATA controller driver. 4 * Copyright 2005/2006 Red Hat Inc <alan@redhat.com>, all rights reserved. 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" 20#define DRV_VERSION "0.2.2" 21 22static struct scsi_host_template isapnp_sht = { 23 ATA_PIO_SHT(DRV_NAME), 24}; 25 26static 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, 32 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, 38 39 .qc_prep = ata_qc_prep, 40 .qc_issue = ata_qc_issue_prot, 41 42 .data_xfer = ata_data_xfer, 43 44 .irq_clear = ata_noop_irq_clear, 45 .irq_on = ata_irq_on, 46 47 .port_start = ata_sff_port_start, 48}; 49 50/** 51 * isapnp_init_one - attach an isapnp interface 52 * @idev: PnP device 53 * @dev_id: matching detect line 54 * 55 * Register an ISA bus IDE interface. Such interfaces are PIO 0 and 56 * non shared IRQ. 57 */ 58 59static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id) 60{ 61 struct ata_host *host; 62 struct ata_port *ap; 63 void __iomem *cmd_addr, *ctl_addr; 64 int irq = 0; 65 irq_handler_t handler = NULL; 66 67 if (pnp_port_valid(idev, 0) == 0) 68 return -ENODEV; 69 70 if (pnp_irq_valid(idev, 0)) { 71 irq = pnp_irq(idev, 0); 72 handler = ata_interrupt; 73 } 74 75 /* allocate host */ 76 host = ata_host_alloc(&idev->dev, 1); 77 if (!host) 78 return -ENOMEM; 79 80 /* acquire resources and fill host */ 81 cmd_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 0), 8); 82 if (!cmd_addr) 83 return -ENOMEM; 84 85 ap = host->ports[0]; 86 87 ap->ops = &isapnp_port_ops; 88 ap->pio_mask = 1; 89 ap->flags |= ATA_FLAG_SLAVE_POSS; 90 91 ap->ioaddr.cmd_addr = cmd_addr; 92 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; 98 } 99 100 ata_std_ports(&ap->ioaddr); 101 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)); 105 106 /* activate */ 107 return ata_host_activate(host, irq, handler, 0, 108 &isapnp_sht); 109} 110 111/** 112 * isapnp_remove_one - unplug an isapnp interface 113 * @idev: PnP device 114 * 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. 117 */ 118 119static void isapnp_remove_one(struct pnp_dev *idev) 120{ 121 struct device *dev = &idev->dev; 122 struct ata_host *host = dev_get_drvdata(dev); 123 124 ata_host_detach(host); 125} 126 127static struct pnp_device_id isapnp_devices[] = { 128 /* Generic ESDI/IDE/ATA compatible hard disk controller */ 129 {.id = "PNP0600", .driver_data = 0}, 130 {.id = ""} 131}; 132 133MODULE_DEVICE_TABLE(pnp, isapnp_devices); 134 135static struct pnp_driver isapnp_driver = { 136 .name = DRV_NAME, 137 .id_table = isapnp_devices, 138 .probe = isapnp_init_one, 139 .remove = isapnp_remove_one, 140}; 141 142static int __init isapnp_init(void) 143{ 144 return pnp_register_driver(&isapnp_driver); 145} 146 147static void __exit isapnp_exit(void) 148{ 149 pnp_unregister_driver(&isapnp_driver); 150} 151 152MODULE_AUTHOR("Alan Cox"); 153MODULE_DESCRIPTION("low-level driver for ISA PnP ATA"); 154MODULE_LICENSE("GPL"); 155MODULE_VERSION(DRV_VERSION); 156 157module_init(isapnp_init); 158module_exit(isapnp_exit); 159