2006-08-29 15:12:40 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* pata-isapnp.c - ISA PnP PATA controller driver.
|
|
|
|
* Copyright 2005/2006 Red Hat Inc <alan@redhat.com>, all rights reserved.
|
|
|
|
*
|
|
|
|
* Based in part on ide-pnp.c by Andrey Panin <pazke@donpac.ru>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/isapnp.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <linux/ata.h>
|
|
|
|
#include <linux/libata.h>
|
|
|
|
|
|
|
|
#define DRV_NAME "pata_isapnp"
|
2007-08-31 01:54:06 -07:00
|
|
|
#define DRV_VERSION "0.2.2"
|
2006-08-29 15:12:40 -07:00
|
|
|
|
|
|
|
static struct scsi_host_template isapnp_sht = {
|
|
|
|
.module = THIS_MODULE,
|
|
|
|
.name = DRV_NAME,
|
|
|
|
.ioctl = ata_scsi_ioctl,
|
|
|
|
.queuecommand = ata_scsi_queuecmd,
|
|
|
|
.can_queue = ATA_DEF_QUEUE,
|
|
|
|
.this_id = ATA_SHT_THIS_ID,
|
|
|
|
.sg_tablesize = LIBATA_MAX_PRD,
|
|
|
|
.cmd_per_lun = ATA_SHT_CMD_PER_LUN,
|
|
|
|
.emulated = ATA_SHT_EMULATED,
|
|
|
|
.use_clustering = ATA_SHT_USE_CLUSTERING,
|
|
|
|
.proc_name = DRV_NAME,
|
|
|
|
.dma_boundary = ATA_DMA_BOUNDARY,
|
|
|
|
.slave_configure = ata_scsi_slave_config,
|
2006-11-28 19:26:47 -07:00
|
|
|
.slave_destroy = ata_scsi_slave_destroy,
|
2006-08-29 15:12:40 -07:00
|
|
|
.bios_param = ata_std_bios_param,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ata_port_operations isapnp_port_ops = {
|
|
|
|
.tf_load = ata_tf_load,
|
|
|
|
.tf_read = ata_tf_read,
|
|
|
|
.check_status = ata_check_status,
|
|
|
|
.exec_command = ata_exec_command,
|
|
|
|
.dev_select = ata_std_dev_select,
|
|
|
|
|
|
|
|
.freeze = ata_bmdma_freeze,
|
|
|
|
.thaw = ata_bmdma_thaw,
|
|
|
|
.error_handler = ata_bmdma_error_handler,
|
|
|
|
.post_internal_cmd = ata_bmdma_post_internal_cmd,
|
2007-03-09 06:37:46 -07:00
|
|
|
.cable_detect = ata_cable_40wire,
|
2006-08-29 15:12:40 -07:00
|
|
|
|
|
|
|
.qc_prep = ata_qc_prep,
|
|
|
|
.qc_issue = ata_qc_issue_prot,
|
2006-09-27 02:41:13 -07:00
|
|
|
|
2007-01-31 23:06:36 -07:00
|
|
|
.data_xfer = ata_data_xfer,
|
2006-08-29 15:12:40 -07:00
|
|
|
|
|
|
|
.irq_clear = ata_bmdma_irq_clear,
|
2007-01-26 00:27:58 -07:00
|
|
|
.irq_on = ata_irq_on,
|
2006-08-29 15:12:40 -07:00
|
|
|
|
|
|
|
.port_start = ata_port_start,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* isapnp_init_one - attach an isapnp interface
|
|
|
|
* @idev: PnP device
|
|
|
|
* @dev_id: matching detect line
|
|
|
|
*
|
|
|
|
* Register an ISA bus IDE interface. Such interfaces are PIO 0 and
|
|
|
|
* non shared IRQ.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
|
|
|
|
{
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
struct ata_host *host;
|
|
|
|
struct ata_port *ap;
|
2007-01-31 23:06:36 -07:00
|
|
|
void __iomem *cmd_addr, *ctl_addr;
|
2006-08-29 15:12:40 -07:00
|
|
|
|
|
|
|
if (pnp_port_valid(idev, 0) == 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* FIXME: Should selected polled PIO here not fail */
|
|
|
|
if (pnp_irq_valid(idev, 0) == 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
/* allocate host */
|
|
|
|
host = ata_host_alloc(&idev->dev, 1);
|
|
|
|
if (!host)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/* acquire resources and fill host */
|
2007-01-31 23:06:36 -07:00
|
|
|
cmd_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 0), 8);
|
|
|
|
if (!cmd_addr)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ap = host->ports[0];
|
|
|
|
|
|
|
|
ap->ops = &isapnp_port_ops;
|
|
|
|
ap->pio_mask = 1;
|
|
|
|
ap->flags |= ATA_FLAG_SLAVE_POSS;
|
|
|
|
|
|
|
|
ap->ioaddr.cmd_addr = cmd_addr;
|
2006-08-29 15:12:40 -07:00
|
|
|
|
|
|
|
if (pnp_port_valid(idev, 1) == 0) {
|
2007-01-31 23:06:36 -07:00
|
|
|
ctl_addr = devm_ioport_map(&idev->dev,
|
|
|
|
pnp_port_start(idev, 1), 1);
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ap->ioaddr.altstatus_addr = ctl_addr;
|
|
|
|
ap->ioaddr.ctl_addr = ctl_addr;
|
2006-08-29 15:12:40 -07:00
|
|
|
}
|
|
|
|
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ata_std_ports(&ap->ioaddr);
|
|
|
|
|
|
|
|
/* activate */
|
|
|
|
return ata_host_activate(host, pnp_irq(idev, 0), ata_interrupt, 0,
|
|
|
|
&isapnp_sht);
|
2006-08-29 15:12:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* isapnp_remove_one - unplug an isapnp interface
|
|
|
|
* @idev: PnP device
|
|
|
|
*
|
|
|
|
* Remove a previously configured PnP ATA port. Called only on module
|
|
|
|
* unload events as the core does not currently deal with ISAPnP docking.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void isapnp_remove_one(struct pnp_dev *idev)
|
|
|
|
{
|
|
|
|
struct device *dev = &idev->dev;
|
|
|
|
struct ata_host *host = dev_get_drvdata(dev);
|
|
|
|
|
2007-01-20 00:00:28 -07:00
|
|
|
ata_host_detach(host);
|
2006-08-29 15:12:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct pnp_device_id isapnp_devices[] = {
|
|
|
|
/* Generic ESDI/IDE/ATA compatible hard disk controller */
|
|
|
|
{.id = "PNP0600", .driver_data = 0},
|
|
|
|
{.id = ""}
|
|
|
|
};
|
|
|
|
|
2007-08-03 08:25:50 -07:00
|
|
|
MODULE_DEVICE_TABLE(pnp, isapnp_devices);
|
|
|
|
|
2006-08-29 15:12:40 -07:00
|
|
|
static struct pnp_driver isapnp_driver = {
|
|
|
|
.name = DRV_NAME,
|
|
|
|
.id_table = isapnp_devices,
|
|
|
|
.probe = isapnp_init_one,
|
|
|
|
.remove = isapnp_remove_one,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init isapnp_init(void)
|
|
|
|
{
|
|
|
|
return pnp_register_driver(&isapnp_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit isapnp_exit(void)
|
|
|
|
{
|
|
|
|
pnp_unregister_driver(&isapnp_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Alan Cox");
|
|
|
|
MODULE_DESCRIPTION("low-level driver for ISA PnP ATA");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_VERSION(DRV_VERSION);
|
|
|
|
|
|
|
|
module_init(isapnp_init);
|
|
|
|
module_exit(isapnp_exit);
|