2006-08-30 02:12:40 +04:00
|
|
|
/*
|
|
|
|
* pata_qdi.c - QDI VLB ATA controllers
|
2008-10-27 18:09:10 +03:00
|
|
|
* (C) 2006 Red Hat
|
2006-08-30 02:12:40 +04:00
|
|
|
*
|
|
|
|
* This driver mostly exists as a proof of concept for non PCI devices under
|
|
|
|
* libata. While the QDI6580 was 'neat' in 1993 it is no longer terribly
|
|
|
|
* useful.
|
|
|
|
*
|
|
|
|
* Tuning code written from the documentation at
|
|
|
|
* http://www.ryston.cz/petr/vlb/qd6500.html
|
|
|
|
* http://www.ryston.cz/petr/vlb/qd6580.html
|
|
|
|
*
|
|
|
|
* Probe code based on drivers/ide/legacy/qd65xx.c
|
|
|
|
* Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by
|
2009-02-03 15:12:58 +03:00
|
|
|
* Samuel Thibault <samuel.thibault@ens-lyon.org>
|
2006-08-30 02:12:40 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/pci.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_qdi"
|
2007-05-22 04:26:38 +04:00
|
|
|
#define DRV_VERSION "0.3.1"
|
2006-08-30 02:12:40 +04:00
|
|
|
|
|
|
|
#define NR_HOST 4 /* Two 6580s */
|
|
|
|
|
|
|
|
struct qdi_data {
|
|
|
|
unsigned long timing;
|
|
|
|
u8 clock[2];
|
|
|
|
u8 last;
|
|
|
|
int fast;
|
|
|
|
struct platform_device *platform_dev;
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct ata_host *qdi_host[NR_HOST];
|
|
|
|
static struct qdi_data qdi_data[NR_HOST];
|
|
|
|
static int nr_qdi_host;
|
|
|
|
|
|
|
|
#ifdef MODULE
|
|
|
|
static int probe_qdi = 1;
|
|
|
|
#else
|
|
|
|
static int probe_qdi;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void qdi6500_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
struct ata_timing t;
|
|
|
|
struct qdi_data *qdi = ap->host->private_data;
|
|
|
|
int active, recovery;
|
|
|
|
u8 timing;
|
|
|
|
|
|
|
|
/* Get the timing data in cycles */
|
|
|
|
ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
if (qdi->fast) {
|
2008-05-15 03:17:00 +04:00
|
|
|
active = 8 - clamp_val(t.active, 1, 8);
|
|
|
|
recovery = 18 - clamp_val(t.recover, 3, 18);
|
2006-08-30 02:12:40 +04:00
|
|
|
} else {
|
2008-05-15 03:17:00 +04:00
|
|
|
active = 9 - clamp_val(t.active, 2, 9);
|
|
|
|
recovery = 15 - clamp_val(t.recover, 0, 15);
|
2006-08-30 02:12:40 +04:00
|
|
|
}
|
|
|
|
timing = (recovery << 4) | active | 0x08;
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
qdi->clock[adev->devno] = timing;
|
|
|
|
|
2006-08-31 08:03:49 +04:00
|
|
|
outb(timing, qdi->timing);
|
2006-08-30 02:12:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void qdi6580_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
struct ata_timing t;
|
|
|
|
struct qdi_data *qdi = ap->host->private_data;
|
|
|
|
int active, recovery;
|
|
|
|
u8 timing;
|
|
|
|
|
|
|
|
/* Get the timing data in cycles */
|
|
|
|
ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
if (qdi->fast) {
|
2008-05-15 03:17:00 +04:00
|
|
|
active = 8 - clamp_val(t.active, 1, 8);
|
|
|
|
recovery = 18 - clamp_val(t.recover, 3, 18);
|
2006-08-30 02:12:40 +04:00
|
|
|
} else {
|
2008-05-15 03:17:00 +04:00
|
|
|
active = 9 - clamp_val(t.active, 2, 9);
|
|
|
|
recovery = 15 - clamp_val(t.recover, 0, 15);
|
2006-08-30 02:12:40 +04:00
|
|
|
}
|
|
|
|
timing = (recovery << 4) | active | 0x08;
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
qdi->clock[adev->devno] = timing;
|
|
|
|
|
|
|
|
outb(timing, qdi->timing);
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
/* Clear the FIFO */
|
|
|
|
if (adev->class != ATA_DEV_ATA)
|
|
|
|
outb(0x5F, (qdi->timing & 0xFFF0) + 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-04-07 17:47:16 +04:00
|
|
|
* qdi_qc_issue - command issue
|
2006-08-30 02:12:40 +04:00
|
|
|
* @qc: command pending
|
|
|
|
*
|
|
|
|
* Called when the libata layer is about to issue a command. We wrap
|
|
|
|
* this interface so that we can load the correct ATA timings.
|
|
|
|
*/
|
|
|
|
|
2008-04-07 17:47:16 +04:00
|
|
|
static unsigned int qdi_qc_issue(struct ata_queued_cmd *qc)
|
2006-08-30 02:12:40 +04:00
|
|
|
{
|
|
|
|
struct ata_port *ap = qc->ap;
|
|
|
|
struct ata_device *adev = qc->dev;
|
|
|
|
struct qdi_data *qdi = ap->host->private_data;
|
|
|
|
|
|
|
|
if (qdi->clock[adev->devno] != qdi->last) {
|
|
|
|
if (adev->pio_mode) {
|
|
|
|
qdi->last = qdi->clock[adev->devno];
|
|
|
|
outb(qdi->clock[adev->devno], qdi->timing);
|
|
|
|
}
|
|
|
|
}
|
2008-04-07 17:47:16 +04:00
|
|
|
return ata_sff_qc_issue(qc);
|
2006-08-30 02:12:40 +04:00
|
|
|
}
|
|
|
|
|
2007-12-05 10:43:07 +03:00
|
|
|
static unsigned int qdi_data_xfer(struct ata_device *dev, unsigned char *buf,
|
|
|
|
unsigned int buflen, int rw)
|
2006-08-30 02:12:40 +04:00
|
|
|
{
|
2007-12-05 10:43:07 +03:00
|
|
|
if (ata_id_has_dword_io(dev->id)) {
|
|
|
|
struct ata_port *ap = dev->link->ap;
|
|
|
|
int slop = buflen & 3;
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2007-12-05 10:43:07 +03:00
|
|
|
if (rw == READ)
|
2007-02-01 09:06:36 +03:00
|
|
|
ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
|
2007-12-05 10:43:07 +03:00
|
|
|
else
|
|
|
|
iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
if (unlikely(slop)) {
|
2008-06-19 04:16:43 +04:00
|
|
|
__le32 pad;
|
2007-12-05 10:43:07 +03:00
|
|
|
if (rw == READ) {
|
2008-01-12 17:16:14 +03:00
|
|
|
pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
|
2006-08-30 02:12:40 +04:00
|
|
|
memcpy(buf + buflen - slop, &pad, slop);
|
2007-12-05 10:43:07 +03:00
|
|
|
} else {
|
|
|
|
memcpy(&pad, buf + buflen - slop, slop);
|
|
|
|
iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr);
|
2006-08-30 02:12:40 +04:00
|
|
|
}
|
2007-12-05 10:43:07 +03:00
|
|
|
buflen += 4 - slop;
|
2006-08-30 02:12:40 +04:00
|
|
|
}
|
|
|
|
} else
|
2008-04-07 17:47:16 +04:00
|
|
|
buflen = ata_sff_data_xfer(dev, buf, buflen, rw);
|
2007-12-05 10:43:07 +03:00
|
|
|
|
|
|
|
return buflen;
|
2006-08-30 02:12:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct scsi_host_template qdi_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 qdi6500_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,
|
2008-04-07 17:47:16 +04:00
|
|
|
.qc_issue = qdi_qc_issue,
|
2008-04-07 17:47:16 +04:00
|
|
|
.sff_data_xfer = qdi_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-25 06:22:49 +03:00
|
|
|
.cable_detect = ata_cable_40wire,
|
|
|
|
.set_piomode = qdi6500_set_piomode,
|
2006-08-31 08:03:49 +04:00
|
|
|
};
|
2006-08-30 02:12:40 +04:00
|
|
|
|
|
|
|
static struct ata_port_operations qdi6580_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 = &qdi6500_port_ops,
|
2006-08-30 02:12:40 +04:00
|
|
|
.set_piomode = qdi6580_set_piomode,
|
2006-08-31 08:03:49 +04:00
|
|
|
};
|
2006-08-30 02:12:40 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* qdi_init_one - attach a qdi interface
|
|
|
|
* @type: Type to display
|
|
|
|
* @io: I/O port start
|
|
|
|
* @irq: interrupt line
|
|
|
|
* @fast: True if on a > 33Mhz VLB
|
|
|
|
*
|
|
|
|
* Register an ISA bus IDE interface. Such interfaces are PIO and we
|
|
|
|
* assume do not support IRQ sharing.
|
|
|
|
*/
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
static __init int qdi_init_one(unsigned long port, int type, unsigned long io, int irq, int fast)
|
|
|
|
{
|
2007-08-18 08:14:55 +04:00
|
|
|
unsigned long ctl = io + 0x206;
|
2006-08-30 02:12:40 +04:00
|
|
|
struct platform_device *pdev;
|
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 *io_addr, *ctl_addr;
|
2006-08-30 02:12:40 +04:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in a probe structure first of all
|
|
|
|
*/
|
|
|
|
|
|
|
|
pdev = platform_device_register_simple(DRV_NAME, nr_qdi_host, NULL, 0);
|
2006-12-16 00:08:51 +03:00
|
|
|
if (IS_ERR(pdev))
|
|
|
|
return PTR_ERR(pdev);
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2007-02-01 09:06:36 +03:00
|
|
|
ret = -ENOMEM;
|
|
|
|
io_addr = devm_ioport_map(&pdev->dev, io, 8);
|
2007-08-18 08:14:55 +04:00
|
|
|
ctl_addr = devm_ioport_map(&pdev->dev, ctl, 1);
|
2007-02-01 09:06:36 +03:00
|
|
|
if (!io_addr || !ctl_addr)
|
|
|
|
goto fail;
|
|
|
|
|
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
|
|
|
ret = -ENOMEM;
|
|
|
|
host = ata_host_alloc(&pdev->dev, 1);
|
|
|
|
if (!host)
|
|
|
|
goto fail;
|
|
|
|
ap = host->ports[0];
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
if (type == 6580) {
|
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->ops = &qdi6580_port_ops;
|
2009-03-14 23:38:24 +03: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 18:44:08 +04:00
|
|
|
ap->flags |= ATA_FLAG_SLAVE_POSS;
|
2006-08-30 02:12:40 +04:00
|
|
|
} else {
|
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->ops = &qdi6500_port_ops;
|
2009-03-14 23:38:24 +03:00
|
|
|
ap->pio_mask = ATA_PIO2; /* Actually PIO3 !IORDY is possible */
|
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 | ATA_FLAG_NO_IORDY;
|
2006-08-30 02:12:40 +04:00
|
|
|
}
|
2006-08-31 08:03:49 +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
|
|
|
ap->ioaddr.cmd_addr = io_addr;
|
|
|
|
ap->ioaddr.altstatus_addr = ctl_addr;
|
|
|
|
ap->ioaddr.ctl_addr = ctl_addr;
|
2008-04-07 17:47:16 +04:00
|
|
|
ata_sff_std_ports(&ap->ioaddr);
|
2006-08-30 02:12:40 +04:00
|
|
|
|
2007-08-18 08:14:55 +04:00
|
|
|
ata_port_desc(ap, "cmd %lx ctl %lx", io, ctl);
|
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
/*
|
|
|
|
* Hook in a private data structure per channel
|
|
|
|
*/
|
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->private_data = &qdi_data[nr_qdi_host];
|
2006-08-30 02:12:40 +04:00
|
|
|
|
|
|
|
qdi_data[nr_qdi_host].timing = port;
|
|
|
|
qdi_data[nr_qdi_host].fast = fast;
|
|
|
|
qdi_data[nr_qdi_host].platform_dev = pdev;
|
|
|
|
|
|
|
|
printk(KERN_INFO DRV_NAME": qd%d at 0x%lx.\n", type, io);
|
2007-02-01 09:06:36 +03: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
|
|
|
/* activate */
|
2008-04-07 17:47:16 +04:00
|
|
|
ret = ata_host_activate(host, irq, ata_sff_interrupt, 0, &qdi_sht);
|
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
|
|
|
if (ret)
|
2007-02-01 09:06:36 +03:00
|
|
|
goto fail;
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
qdi_host[nr_qdi_host++] = dev_get_drvdata(&pdev->dev);
|
2006-08-31 08:03:49 +04:00
|
|
|
return 0;
|
2007-02-01 09:06:36 +03:00
|
|
|
|
|
|
|
fail:
|
|
|
|
platform_device_unregister(pdev);
|
|
|
|
return ret;
|
2006-08-30 02:12:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* qdi_init - attach qdi interfaces
|
|
|
|
*
|
|
|
|
* Attach qdi IDE interfaces by scanning the ports it may occupy.
|
|
|
|
*/
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
static __init int qdi_init(void)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
static const unsigned long qd_port[2] = { 0x30, 0xB0 };
|
|
|
|
static const unsigned long ide_port[2] = { 0x170, 0x1F0 };
|
|
|
|
static const int ide_irq[2] = { 14, 15 };
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
int ct = 0;
|
|
|
|
int i;
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
if (probe_qdi == 0)
|
|
|
|
return -ENODEV;
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
/*
|
|
|
|
* Check each possible QD65xx base address
|
|
|
|
*/
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
unsigned long port = qd_port[i];
|
|
|
|
u8 r, res;
|
2006-08-31 08:03:49 +04:00
|
|
|
|
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
if (request_region(port, 2, "pata_qdi")) {
|
|
|
|
/* Check for a card */
|
|
|
|
local_irq_save(flags);
|
|
|
|
r = inb_p(port);
|
|
|
|
outb_p(0x19, port);
|
|
|
|
res = inb_p(port);
|
|
|
|
outb_p(r, port);
|
|
|
|
local_irq_restore(flags);
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
/* Fail */
|
|
|
|
if (res == 0x19)
|
|
|
|
{
|
|
|
|
release_region(port, 2);
|
|
|
|
continue;
|
|
|
|
}
|
2006-08-31 08:03:49 +04:00
|
|
|
|
2006-08-30 02:12:40 +04:00
|
|
|
/* Passes the presence test */
|
|
|
|
r = inb_p(port + 1); /* Check port agrees with port set */
|
|
|
|
if ((r & 2) >> 1 != i) {
|
|
|
|
release_region(port, 2);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-08-31 08:03:49 +04:00
|
|
|
/* Check card type */
|
2006-08-30 02:12:40 +04:00
|
|
|
if ((r & 0xF0) == 0xC0) {
|
|
|
|
/* QD6500: single channel */
|
|
|
|
if (r & 8) {
|
|
|
|
/* Disabled ? */
|
|
|
|
release_region(port, 2);
|
|
|
|
continue;
|
|
|
|
}
|
2007-03-02 17:56:35 +03:00
|
|
|
if (qdi_init_one(port, 6500, ide_port[r & 0x01], ide_irq[r & 0x01], r & 0x04) == 0)
|
|
|
|
ct++;
|
2006-08-30 02:12:40 +04:00
|
|
|
}
|
|
|
|
if (((r & 0xF0) == 0xA0) || (r & 0xF0) == 0x50) {
|
|
|
|
/* QD6580: dual channel */
|
|
|
|
if (!request_region(port + 2 , 2, "pata_qdi"))
|
|
|
|
{
|
|
|
|
release_region(port, 2);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
res = inb(port + 3);
|
|
|
|
if (res & 1) {
|
|
|
|
/* Single channel mode */
|
2007-05-03 13:30:25 +04:00
|
|
|
if (qdi_init_one(port, 6580, ide_port[r & 0x01], ide_irq[r & 0x01], r & 0x04) == 0)
|
2007-03-02 17:56:35 +03:00
|
|
|
ct++;
|
2006-08-30 02:12:40 +04:00
|
|
|
} else {
|
|
|
|
/* Dual channel mode */
|
2007-03-02 17:56:35 +03:00
|
|
|
if (qdi_init_one(port, 6580, 0x1F0, 14, r & 0x04) == 0)
|
|
|
|
ct++;
|
|
|
|
if (qdi_init_one(port + 2, 6580, 0x170, 15, r & 0x04) == 0)
|
|
|
|
ct++;
|
2006-08-30 02:12:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ct != 0)
|
|
|
|
return 0;
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __exit void qdi_exit(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < nr_qdi_host; i++) {
|
2007-01-20 10:00:28 +03:00
|
|
|
ata_host_detach(qdi_host[i]);
|
2006-08-30 02:12:40 +04:00
|
|
|
/* Free the control resource. The 6580 dual channel has the resources
|
|
|
|
* claimed as a pair of 2 byte resources so we need no special cases...
|
|
|
|
*/
|
|
|
|
release_region(qdi_data[i].timing, 2);
|
|
|
|
platform_device_unregister(qdi_data[i].platform_dev);
|
2006-08-31 08:03:49 +04:00
|
|
|
}
|
2006-08-30 02:12:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Alan Cox");
|
|
|
|
MODULE_DESCRIPTION("low-level driver for qdi ATA");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_VERSION(DRV_VERSION);
|
|
|
|
|
|
|
|
module_init(qdi_init);
|
|
|
|
module_exit(qdi_exit);
|
|
|
|
|
|
|
|
module_param(probe_qdi, int, 0);
|
|
|
|
|