2006-09-29 10:30:05 -07:00
|
|
|
/*
|
|
|
|
* pata_winbond.c - Winbond VLB ATA controllers
|
2008-10-27 08:09:10 -07:00
|
|
|
* (C) 2006 Red Hat
|
2006-09-29 10:30:05 -07:00
|
|
|
*
|
|
|
|
* Support for the Winbond 83759A when operating in advanced mode.
|
|
|
|
* Multichip mode is not currently supported.
|
|
|
|
*/
|
2006-12-11 09:14:06 -07:00
|
|
|
|
2006-09-29 10:30:05 -07:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <linux/libata.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
|
|
|
|
#define DRV_NAME "pata_winbond"
|
2007-05-21 17:26:38 -07:00
|
|
|
#define DRV_VERSION "0.0.3"
|
2006-09-29 10:30:05 -07:00
|
|
|
|
|
|
|
#define NR_HOST 4 /* Two winbond controllers, two channels each */
|
|
|
|
|
|
|
|
struct winbond_data {
|
|
|
|
unsigned long config;
|
|
|
|
struct platform_device *platform_dev;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ata_host *winbond_host[NR_HOST];
|
|
|
|
static struct winbond_data winbond_data[NR_HOST];
|
|
|
|
static int nr_winbond_host;
|
|
|
|
|
|
|
|
#ifdef MODULE
|
|
|
|
static int probe_winbond = 1;
|
|
|
|
#else
|
|
|
|
static int probe_winbond;
|
|
|
|
#endif
|
|
|
|
|
2007-04-26 00:19:27 -07:00
|
|
|
static DEFINE_SPINLOCK(winbond_lock);
|
2006-09-29 10:30:05 -07:00
|
|
|
|
|
|
|
static void winbond_writecfg(unsigned long port, u8 reg, u8 val)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&winbond_lock, flags);
|
|
|
|
outb(reg, port + 0x01);
|
|
|
|
outb(val, port + 0x02);
|
|
|
|
spin_unlock_irqrestore(&winbond_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 winbond_readcfg(unsigned long port, u8 reg)
|
|
|
|
{
|
|
|
|
u8 val;
|
|
|
|
|
|
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&winbond_lock, flags);
|
|
|
|
outb(reg, port + 0x01);
|
|
|
|
val = inb(port + 0x02);
|
|
|
|
spin_unlock_irqrestore(&winbond_lock, flags);
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
struct ata_timing t;
|
|
|
|
struct winbond_data *winbond = ap->host->private_data;
|
|
|
|
int active, recovery;
|
|
|
|
u8 reg;
|
|
|
|
int timing = 0x88 + (ap->port_no * 4) + (adev->devno * 2);
|
|
|
|
|
|
|
|
reg = winbond_readcfg(winbond->config, 0x81);
|
2006-12-11 09:14:06 -07:00
|
|
|
|
2006-09-29 10:30:05 -07:00
|
|
|
/* Get the timing data in cycles */
|
|
|
|
if (reg & 0x40) /* Fast VLB bus, assume 50MHz */
|
|
|
|
ata_timing_compute(adev, adev->pio_mode, &t, 20000, 1000);
|
|
|
|
else
|
|
|
|
ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
|
|
|
|
|
2008-05-14 16:17:00 -07:00
|
|
|
active = (clamp_val(t.active, 3, 17) - 1) & 0x0F;
|
|
|
|
recovery = (clamp_val(t.recover, 1, 15) + 1) & 0x0F;
|
2006-09-29 10:30:05 -07:00
|
|
|
timing = (active << 4) | recovery;
|
|
|
|
winbond_writecfg(winbond->config, timing, reg);
|
2006-12-11 09:14:06 -07:00
|
|
|
|
2006-09-29 10:30:05 -07:00
|
|
|
/* Load the setup timing */
|
2006-12-11 09:14:06 -07:00
|
|
|
|
2006-09-29 10:30:05 -07:00
|
|
|
reg = 0x35;
|
|
|
|
if (adev->class != ATA_DEV_ATA)
|
|
|
|
reg |= 0x08; /* FIFO off */
|
|
|
|
if (!ata_pio_need_iordy(adev))
|
|
|
|
reg |= 0x02; /* IORDY off */
|
2008-05-14 16:17:00 -07:00
|
|
|
reg |= (clamp_val(t.setup, 0, 3) << 6);
|
2006-09-29 10:30:05 -07:00
|
|
|
winbond_writecfg(winbond->config, timing + 1, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-10 15:33:04 -07:00
|
|
|
static unsigned int winbond_data_xfer(struct ata_device *dev,
|
|
|
|
unsigned char *buf, unsigned int buflen, int rw)
|
2006-09-29 10:30:05 -07:00
|
|
|
{
|
2007-12-05 00:43:07 -07:00
|
|
|
struct ata_port *ap = dev->link->ap;
|
2006-09-29 10:30:05 -07:00
|
|
|
int slop = buflen & 3;
|
|
|
|
|
2007-12-05 00:43:07 -07:00
|
|
|
if (ata_id_has_dword_io(dev->id)) {
|
|
|
|
if (rw == READ)
|
2007-01-31 23:06:36 -07:00
|
|
|
ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
|
2007-12-05 00:43:07 -07:00
|
|
|
else
|
|
|
|
iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
|
2006-09-29 10:30:05 -07:00
|
|
|
|
|
|
|
if (unlikely(slop)) {
|
2008-06-18 17:16:43 -07:00
|
|
|
__le32 pad;
|
2007-12-05 00:43:07 -07:00
|
|
|
if (rw == READ) {
|
2008-01-12 07:16:14 -07:00
|
|
|
pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
|
2006-09-29 10:30:05 -07:00
|
|
|
memcpy(buf + buflen - slop, &pad, slop);
|
2007-12-05 00:43:07 -07:00
|
|
|
} else {
|
|
|
|
memcpy(&pad, buf + buflen - slop, slop);
|
|
|
|
iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr);
|
2006-09-29 10:30:05 -07:00
|
|
|
}
|
2007-12-05 00:43:07 -07:00
|
|
|
buflen += 4 - slop;
|
2006-09-29 10:30:05 -07:00
|
|
|
}
|
|
|
|
} else
|
2008-04-07 06:47:16 -07:00
|
|
|
buflen = ata_sff_data_xfer(dev, buf, buflen, rw);
|
2007-12-05 00:43:07 -07:00
|
|
|
|
|
|
|
return buflen;
|
2006-09-29 10:30:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct scsi_host_template winbond_sht = {
|
2008-03-24 20:22:49 -07:00
|
|
|
ATA_PIO_SHT(DRV_NAME),
|
2006-09-29 10:30:05 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct ata_port_operations winbond_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-24 20:22:49 -07:00
|
|
|
.inherits = &ata_sff_port_ops,
|
2008-04-07 06:47:16 -07:00
|
|
|
.sff_data_xfer = winbond_data_xfer,
|
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-24 20:22:49 -07:00
|
|
|
.cable_detect = ata_cable_40wire,
|
|
|
|
.set_piomode = winbond_set_piomode,
|
2006-09-29 10:30:05 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* winbond_init_one - attach a winbond interface
|
|
|
|
* @type: Type to display
|
|
|
|
* @io: I/O port start
|
|
|
|
* @irq: interrupt line
|
|
|
|
* @fast: True if on a > 33Mhz VLB
|
|
|
|
*
|
|
|
|
* Register a VLB bus IDE interface. Such interfaces are PIO and we
|
|
|
|
* assume do not support IRQ sharing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static __init int winbond_init_one(unsigned long port)
|
|
|
|
{
|
|
|
|
struct platform_device *pdev;
|
|
|
|
u8 reg;
|
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
|
|
|
int i, rc;
|
2006-09-29 10:30:05 -07:00
|
|
|
|
|
|
|
reg = winbond_readcfg(port, 0x81);
|
|
|
|
reg |= 0x80; /* jumpered mode off */
|
|
|
|
winbond_writecfg(port, 0x81, reg);
|
|
|
|
reg = winbond_readcfg(port, 0x83);
|
|
|
|
reg |= 0xF0; /* local control */
|
|
|
|
winbond_writecfg(port, 0x83, reg);
|
|
|
|
reg = winbond_readcfg(port, 0x85);
|
|
|
|
reg |= 0xF0; /* programmable timing */
|
|
|
|
winbond_writecfg(port, 0x85, reg);
|
|
|
|
|
|
|
|
reg = winbond_readcfg(port, 0x81);
|
2006-12-11 09:14:06 -07:00
|
|
|
|
2006-09-29 10:30:05 -07:00
|
|
|
if (!(reg & 0x03)) /* Disabled */
|
2008-01-19 08:53:55 -07:00
|
|
|
return -ENODEV;
|
2006-09-29 10:30:05 -07:00
|
|
|
|
|
|
|
for (i = 0; i < 2 ; i ++) {
|
2007-01-31 23:06:36 -07:00
|
|
|
unsigned long cmd_port = 0x1F0 - (0x80 * i);
|
2007-08-17 21:14:55 -07:00
|
|
|
unsigned long ctl_port = cmd_port + 0x206;
|
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-09-29 10:30:05 -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
|
|
|
if (!(reg & (1 << i)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pdev = platform_device_register_simple(DRV_NAME, nr_winbond_host, NULL, 0);
|
|
|
|
if (IS_ERR(pdev))
|
|
|
|
return PTR_ERR(pdev);
|
|
|
|
|
|
|
|
rc = -ENOMEM;
|
|
|
|
host = ata_host_alloc(&pdev->dev, 1);
|
|
|
|
if (!host)
|
|
|
|
goto err_unregister;
|
2007-08-17 21:14:55 -07:00
|
|
|
ap = host->ports[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 07:44:08 -07:00
|
|
|
|
|
|
|
rc = -ENOMEM;
|
|
|
|
cmd_addr = devm_ioport_map(&pdev->dev, cmd_port, 8);
|
2007-08-17 21:14:55 -07:00
|
|
|
ctl_addr = devm_ioport_map(&pdev->dev, ctl_port, 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
|
|
|
if (!cmd_addr || !ctl_addr)
|
|
|
|
goto err_unregister;
|
|
|
|
|
2007-08-17 21:14:55 -07:00
|
|
|
ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", cmd_port, ctl_port);
|
|
|
|
|
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->ops = &winbond_port_ops;
|
2009-03-14 13:38:24 -07:00
|
|
|
ap->pio_mask = ATA_PIO4;
|
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->flags |= ATA_FLAG_SLAVE_POSS;
|
|
|
|
ap->ioaddr.cmd_addr = cmd_addr;
|
|
|
|
ap->ioaddr.altstatus_addr = ctl_addr;
|
|
|
|
ap->ioaddr.ctl_addr = ctl_addr;
|
2008-04-07 06:47:16 -07: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 07:44:08 -07:00
|
|
|
|
|
|
|
/* hook in a private data structure per channel */
|
|
|
|
host->private_data = &winbond_data[nr_winbond_host];
|
|
|
|
winbond_data[nr_winbond_host].config = port;
|
|
|
|
winbond_data[nr_winbond_host].platform_dev = pdev;
|
|
|
|
|
|
|
|
/* activate */
|
2008-04-07 06:47:16 -07:00
|
|
|
rc = ata_host_activate(host, 14 + i, ata_sff_interrupt, 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 07:44:08 -07:00
|
|
|
&winbond_sht);
|
|
|
|
if (rc)
|
|
|
|
goto err_unregister;
|
|
|
|
|
|
|
|
winbond_host[nr_winbond_host++] = dev_get_drvdata(&pdev->dev);
|
2006-09-29 10:30:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 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 07:44:08 -07:00
|
|
|
|
|
|
|
err_unregister:
|
|
|
|
platform_device_unregister(pdev);
|
|
|
|
return rc;
|
2006-09-29 10:30:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* winbond_init - attach winbond interfaces
|
|
|
|
*
|
|
|
|
* Attach winbond IDE interfaces by scanning the ports it may occupy.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static __init int winbond_init(void)
|
|
|
|
{
|
|
|
|
static const unsigned long config[2] = { 0x130, 0x1B0 };
|
|
|
|
|
|
|
|
int ct = 0;
|
|
|
|
int i;
|
2006-12-11 09:14:06 -07:00
|
|
|
|
2006-09-29 10:30:05 -07:00
|
|
|
if (probe_winbond == 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check both base addresses
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
if (probe_winbond & (1<<i)) {
|
|
|
|
int ret = 0;
|
|
|
|
unsigned long port = config[i];
|
|
|
|
|
|
|
|
if (request_region(port, 2, "pata_winbond")) {
|
|
|
|
ret = winbond_init_one(port);
|
2007-10-25 17:47:30 -07:00
|
|
|
if (ret <= 0)
|
2006-09-29 10:30:05 -07:00
|
|
|
release_region(port, 2);
|
|
|
|
else ct+= ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ct != 0)
|
|
|
|
return 0;
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __exit void winbond_exit(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < nr_winbond_host; i++) {
|
2007-01-20 00:00:28 -07:00
|
|
|
ata_host_detach(winbond_host[i]);
|
2006-09-29 10:30:05 -07:00
|
|
|
release_region(winbond_data[i].config, 2);
|
|
|
|
platform_device_unregister(winbond_data[i].platform_dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Alan Cox");
|
|
|
|
MODULE_DESCRIPTION("low-level driver for Winbond VL ATA");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_VERSION(DRV_VERSION);
|
|
|
|
|
|
|
|
module_init(winbond_init);
|
|
|
|
module_exit(winbond_exit);
|
|
|
|
|
|
|
|
module_param(probe_winbond, int, 0);
|
|
|
|
|