2006-08-30 02:12:40 +04:00
/*
* pata - isapnp . c - ISA PnP PATA controller driver .
2008-10-27 18:09:10 +03:00
* Copyright 2005 / 2006 Red Hat Inc , all rights reserved .
2006-08-30 02:12:40 +04:00
*
* 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"
2009-03-24 13:23:46 +03:00
# define DRV_VERSION "0.2.5"
2006-08-30 02:12:40 +04:00
static struct scsi_host_template isapnp_sht = {
2008-03-25 06:22:49 +03:00
ATA_PIO_SHT ( DRV_NAME ) ,
2006-08-30 02:12:40 +04:00
} ;
static struct ata_port_operations isapnp_port_ops = {
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-25 06:22:49 +03:00
. inherits = & ata_sff_port_ops ,
2007-03-09 16:37:46 +03:00
. cable_detect = ata_cable_40wire ,
2006-08-30 02:12:40 +04:00
} ;
2009-03-24 13:23:46 +03:00
static struct ata_port_operations isapnp_noalt_port_ops = {
. inherits = & ata_sff_port_ops ,
. cable_detect = ata_cable_40wire ,
/* No altstatus so we don't want to use the lost interrupt poll */
. lost_interrupt = ATA_OP_NULL ,
} ;
2006-08-30 02:12:40 +04:00
/**
* 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 18:44:08 +04:00
struct ata_host * host ;
struct ata_port * ap ;
2007-02-01 09:06:36 +03:00
void __iomem * cmd_addr , * ctl_addr ;
2007-11-19 17:41:05 +03:00
int irq = 0 ;
irq_handler_t handler = NULL ;
2006-08-30 02:12:40 +04:00
if ( pnp_port_valid ( idev , 0 ) = = 0 )
return - ENODEV ;
2007-11-19 17:41:05 +03:00
if ( pnp_irq_valid ( idev , 0 ) ) {
irq = pnp_irq ( idev , 0 ) ;
2008-04-07 17:47:16 +04:00
handler = ata_sff_interrupt ;
2007-11-19 17:41:05 +03:00
}
2006-08-30 02:12:40 +04: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 18:44:08 +04:00
/* allocate host */
host = ata_host_alloc ( & idev - > dev , 1 ) ;
if ( ! host )
return - ENOMEM ;
/* acquire resources and fill host */
2007-02-01 09:06:36 +03: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 18:44:08 +04:00
ap = host - > ports [ 0 ] ;
2009-03-24 13:23:46 +03:00
ap - > ops = & isapnp_noalt_port_ops ;
2009-03-14 23:38:24 +03:00
ap - > pio_mask = ATA_PIO0 ;
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 18:44:08 +04:00
ap - > flags | = ATA_FLAG_SLAVE_POSS ;
ap - > ioaddr . cmd_addr = cmd_addr ;
2006-08-30 02:12:40 +04:00
2013-09-13 01:01:29 +04:00
if ( pnp_port_valid ( idev , 1 ) ) {
2007-02-01 09:06:36 +03: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 18:44:08 +04:00
ap - > ioaddr . altstatus_addr = ctl_addr ;
ap - > ioaddr . ctl_addr = ctl_addr ;
2009-03-24 13:23:46 +03:00
ap - > ops = & isapnp_port_ops ;
2006-08-30 02:12:40 +04:00
}
2008-04-07 17:47:16 +04:00
ata_sff_std_ports ( & ap - > ioaddr ) ;
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 18:44:08 +04:00
2007-08-18 08:14:55 +04:00
ata_port_desc ( ap , " cmd 0x%llx ctl 0x%llx " ,
( unsigned long long ) pnp_port_start ( idev , 0 ) ,
( unsigned long long ) pnp_port_start ( idev , 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 18:44:08 +04:00
/* activate */
2007-11-19 17:41:05 +03:00
return ata_host_activate ( host , irq , handler , 0 ,
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 18:44:08 +04:00
& isapnp_sht ) ;
2006-08-30 02:12:40 +04: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 10:00:28 +03:00
ata_host_detach ( host ) ;
2006-08-30 02:12:40 +04: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 19:25:50 +04:00
MODULE_DEVICE_TABLE ( pnp , isapnp_devices ) ;
2006-08-30 02:12:40 +04:00
static struct pnp_driver isapnp_driver = {
. name = DRV_NAME ,
. id_table = isapnp_devices ,
. probe = isapnp_init_one ,
. remove = isapnp_remove_one ,
} ;
2015-03-16 23:46:32 +03:00
module_pnp_driver ( isapnp_driver ) ;
2006-08-30 02:12:40 +04:00
MODULE_AUTHOR ( " Alan Cox " ) ;
MODULE_DESCRIPTION ( " low-level driver for ISA PnP ATA " ) ;
MODULE_LICENSE ( " GPL " ) ;
MODULE_VERSION ( DRV_VERSION ) ;