2005-10-10 21:53:58 +00:00
|
|
|
/*
|
|
|
|
* pdc_adma.c - Pacific Digital Corporation ADMA
|
|
|
|
*
|
|
|
|
* Maintained by: Mark Lord <mlord@pobox.com>
|
|
|
|
*
|
|
|
|
* Copyright 2005 Mark Lord
|
|
|
|
*
|
2005-10-11 05:44:14 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* libata documentation is available via 'make {ps|pdf}docs',
|
|
|
|
* as Documentation/DocBook/libata.*
|
2005-10-10 21:53:58 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Supports ATA disks in single-packet ADMA mode.
|
|
|
|
* Uses PIO for everything else.
|
|
|
|
*
|
|
|
|
* TODO: Use ADMA transfers for ATAPI devices, when possible.
|
|
|
|
* This requires careful attention to a number of quirks of the chip.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/gfp.h>
|
2005-10-10 21:53:58 +00:00
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/interrupt.h>
|
2005-10-30 19:39:11 +00:00
|
|
|
#include <linux/device.h>
|
2005-10-10 21:53:58 +00:00
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <linux/libata.h>
|
|
|
|
|
|
|
|
#define DRV_NAME "pdc_adma"
|
2007-08-31 08:54:06 +00:00
|
|
|
#define DRV_VERSION "1.0"
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
/* macro to calculate base address for ATA regs */
|
2007-10-26 04:03:37 +00:00
|
|
|
#define ADMA_ATA_REGS(base, port_no) ((base) + ((port_no) * 0x40))
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
/* macro to calculate base address for ADMA regs */
|
2007-10-26 04:03:37 +00:00
|
|
|
#define ADMA_REGS(base, port_no) ((base) + 0x80 + ((port_no) * 0x20))
|
2007-02-01 06:06:36 +00: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 14:44:08 +00:00
|
|
|
/* macro to obtain addresses from ata_port */
|
|
|
|
#define ADMA_PORT_REGS(ap) \
|
|
|
|
ADMA_REGS((ap)->host->iomap[ADMA_MMIO_BAR], ap->port_no)
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
enum {
|
2007-02-01 06:06:36 +00:00
|
|
|
ADMA_MMIO_BAR = 4,
|
|
|
|
|
2005-10-10 21:53:58 +00:00
|
|
|
ADMA_PORTS = 2,
|
|
|
|
ADMA_CPB_BYTES = 40,
|
|
|
|
ADMA_PRD_BYTES = LIBATA_MAX_PRD * 16,
|
|
|
|
ADMA_PKT_BYTES = ADMA_CPB_BYTES + ADMA_PRD_BYTES,
|
|
|
|
|
|
|
|
ADMA_DMA_BOUNDARY = 0xffffffff,
|
|
|
|
|
|
|
|
/* global register offsets */
|
|
|
|
ADMA_MODE_LOCK = 0x00c7,
|
|
|
|
|
|
|
|
/* per-channel register offsets */
|
|
|
|
ADMA_CONTROL = 0x0000, /* ADMA control */
|
|
|
|
ADMA_STATUS = 0x0002, /* ADMA status */
|
|
|
|
ADMA_CPB_COUNT = 0x0004, /* CPB count */
|
|
|
|
ADMA_CPB_CURRENT = 0x000c, /* current CPB address */
|
|
|
|
ADMA_CPB_NEXT = 0x000c, /* next CPB address */
|
|
|
|
ADMA_CPB_LOOKUP = 0x0010, /* CPB lookup table */
|
|
|
|
ADMA_FIFO_IN = 0x0014, /* input FIFO threshold */
|
|
|
|
ADMA_FIFO_OUT = 0x0016, /* output FIFO threshold */
|
|
|
|
|
|
|
|
/* ADMA_CONTROL register bits */
|
|
|
|
aNIEN = (1 << 8), /* irq mask: 1==masked */
|
|
|
|
aGO = (1 << 7), /* packet trigger ("Go!") */
|
|
|
|
aRSTADM = (1 << 5), /* ADMA logic reset */
|
|
|
|
aPIOMD4 = 0x0003, /* PIO mode 4 */
|
|
|
|
|
|
|
|
/* ADMA_STATUS register bits */
|
|
|
|
aPSD = (1 << 6),
|
|
|
|
aUIRQ = (1 << 4),
|
|
|
|
aPERR = (1 << 0),
|
|
|
|
|
|
|
|
/* CPB bits */
|
|
|
|
cDONE = (1 << 0),
|
2007-08-03 15:10:07 +00:00
|
|
|
cATERR = (1 << 3),
|
|
|
|
|
2005-10-10 21:53:58 +00:00
|
|
|
cVLD = (1 << 0),
|
|
|
|
cDAT = (1 << 2),
|
|
|
|
cIEN = (1 << 3),
|
|
|
|
|
|
|
|
/* PRD bits */
|
|
|
|
pORD = (1 << 4),
|
|
|
|
pDIRO = (1 << 5),
|
|
|
|
pEND = (1 << 7),
|
|
|
|
|
|
|
|
/* ATA register flags */
|
|
|
|
rIGN = (1 << 5),
|
|
|
|
rEND = (1 << 7),
|
|
|
|
|
|
|
|
/* ATA register addresses */
|
|
|
|
ADMA_REGS_CONTROL = 0x0e,
|
|
|
|
ADMA_REGS_SECTOR_COUNT = 0x12,
|
|
|
|
ADMA_REGS_LBA_LOW = 0x13,
|
|
|
|
ADMA_REGS_LBA_MID = 0x14,
|
|
|
|
ADMA_REGS_LBA_HIGH = 0x15,
|
|
|
|
ADMA_REGS_DEVICE = 0x16,
|
|
|
|
ADMA_REGS_COMMAND = 0x17,
|
|
|
|
|
|
|
|
/* PCI device IDs */
|
|
|
|
board_1841_idx = 0, /* ADMA 2-port controller */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum { adma_state_idle, adma_state_pkt, adma_state_mmio } adma_state_t;
|
|
|
|
|
|
|
|
struct adma_port_priv {
|
|
|
|
u8 *pkt;
|
|
|
|
dma_addr_t pkt_dma;
|
|
|
|
adma_state_t state;
|
|
|
|
};
|
|
|
|
|
2007-10-26 04:03:37 +00:00
|
|
|
static int adma_ata_init_one(struct pci_dev *pdev,
|
2005-10-10 21:53:58 +00:00
|
|
|
const struct pci_device_id *ent);
|
|
|
|
static int adma_port_start(struct ata_port *ap);
|
|
|
|
static void adma_port_stop(struct ata_port *ap);
|
|
|
|
static void adma_qc_prep(struct ata_queued_cmd *qc);
|
2006-01-23 04:09:36 +00:00
|
|
|
static unsigned int adma_qc_issue(struct ata_queued_cmd *qc);
|
2005-10-10 21:53:58 +00:00
|
|
|
static int adma_check_atapi_dma(struct ata_queued_cmd *qc);
|
2007-08-03 15:10:07 +00:00
|
|
|
static void adma_freeze(struct ata_port *ap);
|
|
|
|
static void adma_thaw(struct ata_port *ap);
|
libata: make reset related methods proper port operations
Currently reset methods are not specified directly in the
ata_port_operations table. If a LLD wants to use custom reset
methods, it should construct and use a error_handler which uses those
reset methods. It's done this way for two reasons.
First, the ops table already contained too many methods and adding
four more of them would noticeably increase the amount of necessary
boilerplate code all over low level drivers.
Second, as ->error_handler uses those reset methods, it can get
confusing. ie. By overriding ->error_handler, those reset ops can be
made useless making layering a bit hazy.
Now that ops table uses inheritance, the first problem doesn't exist
anymore. The second isn't completely solved but is relieved by
providing default values - most drivers can just override what it has
implemented and don't have to concern itself about higher level
callbacks. In fact, there currently is no driver which actually
modifies error handling behavior. Drivers which override
->error_handler just wraps the standard error handler only to prepare
the controller for EH. I don't think making ops layering strict has
any noticeable benefit.
This patch makes ->prereset, ->softreset, ->hardreset, ->postreset and
their PMP counterparts propoer ops. Default ops are provided in the
base ops tables and drivers are converted to override individual reset
methods instead of creating custom error_handler.
* ata_std_error_handler() doesn't use sata_std_hardreset() if SCRs
aren't accessible. sata_promise doesn't need to use separate
error_handlers for PATA and SATA anymore.
* softreset is broken for sata_inic162x and sata_sx4. As libata now
always prefers hardreset, this doesn't really matter but the ops are
forced to NULL using ATA_OP_NULL for documentation purpose.
* pata_hpt374 needs to use different prereset for the first and second
PCI functions. This used to be done by branching from
hpt374_error_handler(). The proper way to do this is to use
separate ops and port_info tables for each function. Converted.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-25 03:22:50 +00:00
|
|
|
static int adma_prereset(struct ata_link *link, unsigned long deadline);
|
2005-10-10 21:53:58 +00:00
|
|
|
|
2005-11-07 05:59:37 +00:00
|
|
|
static struct scsi_host_template adma_ata_sht = {
|
2008-03-25 03:22:49 +00:00
|
|
|
ATA_BASE_SHT(DRV_NAME),
|
2005-10-10 21:53:58 +00:00
|
|
|
.sg_tablesize = LIBATA_MAX_PRD,
|
2007-05-26 22:20:51 +00:00
|
|
|
.dma_boundary = ADMA_DMA_BOUNDARY,
|
2005-10-10 21:53:58 +00:00
|
|
|
};
|
|
|
|
|
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 03:22:49 +00:00
|
|
|
static struct ata_port_operations adma_ata_ops = {
|
2008-03-25 12:35:30 +00:00
|
|
|
.inherits = &ata_sff_port_ops,
|
|
|
|
|
2009-03-24 10:23:46 +00:00
|
|
|
.lost_interrupt = ATA_OP_NULL,
|
|
|
|
|
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 03:22:49 +00:00
|
|
|
.check_atapi_dma = adma_check_atapi_dma,
|
2005-10-10 21:53:58 +00:00
|
|
|
.qc_prep = adma_qc_prep,
|
|
|
|
.qc_issue = adma_qc_issue,
|
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 03:22:49 +00:00
|
|
|
|
2007-08-03 15:10:07 +00:00
|
|
|
.freeze = adma_freeze,
|
|
|
|
.thaw = adma_thaw,
|
libata: make reset related methods proper port operations
Currently reset methods are not specified directly in the
ata_port_operations table. If a LLD wants to use custom reset
methods, it should construct and use a error_handler which uses those
reset methods. It's done this way for two reasons.
First, the ops table already contained too many methods and adding
four more of them would noticeably increase the amount of necessary
boilerplate code all over low level drivers.
Second, as ->error_handler uses those reset methods, it can get
confusing. ie. By overriding ->error_handler, those reset ops can be
made useless making layering a bit hazy.
Now that ops table uses inheritance, the first problem doesn't exist
anymore. The second isn't completely solved but is relieved by
providing default values - most drivers can just override what it has
implemented and don't have to concern itself about higher level
callbacks. In fact, there currently is no driver which actually
modifies error handling behavior. Drivers which override
->error_handler just wraps the standard error handler only to prepare
the controller for EH. I don't think making ops layering strict has
any noticeable benefit.
This patch makes ->prereset, ->softreset, ->hardreset, ->postreset and
their PMP counterparts propoer ops. Default ops are provided in the
base ops tables and drivers are converted to override individual reset
methods instead of creating custom error_handler.
* ata_std_error_handler() doesn't use sata_std_hardreset() if SCRs
aren't accessible. sata_promise doesn't need to use separate
error_handlers for PATA and SATA anymore.
* softreset is broken for sata_inic162x and sata_sx4. As libata now
always prefers hardreset, this doesn't really matter but the ops are
forced to NULL using ATA_OP_NULL for documentation purpose.
* pata_hpt374 needs to use different prereset for the first and second
PCI functions. This used to be done by branching from
hpt374_error_handler(). The proper way to do this is to use
separate ops and port_info tables for each function. Converted.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-25 03:22:50 +00:00
|
|
|
.prereset = adma_prereset,
|
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 03:22:49 +00:00
|
|
|
|
2005-10-10 21:53:58 +00:00
|
|
|
.port_start = adma_port_start,
|
|
|
|
.port_stop = adma_port_stop,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ata_port_info adma_port_info[] = {
|
|
|
|
/* board_1841_idx */
|
|
|
|
{
|
2011-02-04 19:05:48 +00:00
|
|
|
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_POLLING,
|
2009-03-14 20:38:24 +00:00
|
|
|
.pio_mask = ATA_PIO4_ONLY,
|
2007-07-09 16:16:50 +00:00
|
|
|
.udma_mask = ATA_UDMA4,
|
2005-10-10 21:53:58 +00:00
|
|
|
.port_ops = &adma_ata_ops,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2005-11-10 16:04:11 +00:00
|
|
|
static const struct pci_device_id adma_ata_pci_tbl[] = {
|
2006-09-28 02:20:11 +00:00
|
|
|
{ PCI_VDEVICE(PDC, 0x1841), board_1841_idx },
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
{ } /* terminate list */
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct pci_driver adma_ata_pci_driver = {
|
|
|
|
.name = DRV_NAME,
|
|
|
|
.id_table = adma_ata_pci_tbl,
|
|
|
|
.probe = adma_ata_init_one,
|
|
|
|
.remove = ata_pci_remove_one,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int adma_check_atapi_dma(struct ata_queued_cmd *qc)
|
|
|
|
{
|
|
|
|
return 1; /* ATAPI DMA not yet supported */
|
|
|
|
}
|
|
|
|
|
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 14:44:08 +00:00
|
|
|
static void adma_reset_engine(struct ata_port *ap)
|
2005-10-10 21:53:58 +00: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 14:44:08 +00:00
|
|
|
void __iomem *chan = ADMA_PORT_REGS(ap);
|
|
|
|
|
2005-10-10 21:53:58 +00:00
|
|
|
/* reset ADMA to idle state */
|
|
|
|
writew(aPIOMD4 | aNIEN | aRSTADM, chan + ADMA_CONTROL);
|
|
|
|
udelay(2);
|
|
|
|
writew(aPIOMD4, chan + ADMA_CONTROL);
|
|
|
|
udelay(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void adma_reinit_engine(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
struct adma_port_priv *pp = ap->private_data;
|
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 14:44:08 +00:00
|
|
|
void __iomem *chan = ADMA_PORT_REGS(ap);
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
/* mask/clear ATA interrupts */
|
2007-02-01 06:06:36 +00:00
|
|
|
writeb(ATA_NIEN, ap->ioaddr.ctl_addr);
|
2008-04-07 13:47:16 +00:00
|
|
|
ata_sff_check_status(ap);
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
/* reset the ADMA engine */
|
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 14:44:08 +00:00
|
|
|
adma_reset_engine(ap);
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
/* set in-FIFO threshold to 0x100 */
|
|
|
|
writew(0x100, chan + ADMA_FIFO_IN);
|
|
|
|
|
|
|
|
/* set CPB pointer */
|
|
|
|
writel((u32)pp->pkt_dma, chan + ADMA_CPB_NEXT);
|
|
|
|
|
|
|
|
/* set out-FIFO threshold to 0x100 */
|
|
|
|
writew(0x100, chan + ADMA_FIFO_OUT);
|
|
|
|
|
|
|
|
/* set CPB count */
|
|
|
|
writew(1, chan + ADMA_CPB_COUNT);
|
|
|
|
|
|
|
|
/* read/discard ADMA status */
|
|
|
|
readb(chan + ADMA_STATUS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void adma_enter_reg_mode(struct ata_port *ap)
|
|
|
|
{
|
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 14:44:08 +00:00
|
|
|
void __iomem *chan = ADMA_PORT_REGS(ap);
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
writew(aPIOMD4, chan + ADMA_CONTROL);
|
|
|
|
readb(chan + ADMA_STATUS); /* flush */
|
|
|
|
}
|
|
|
|
|
2007-08-03 15:10:07 +00:00
|
|
|
static void adma_freeze(struct ata_port *ap)
|
2005-10-10 21:53:58 +00:00
|
|
|
{
|
2007-08-03 15:10:07 +00:00
|
|
|
void __iomem *chan = ADMA_PORT_REGS(ap);
|
|
|
|
|
|
|
|
/* mask/clear ATA interrupts */
|
|
|
|
writeb(ATA_NIEN, ap->ioaddr.ctl_addr);
|
2008-04-07 13:47:16 +00:00
|
|
|
ata_sff_check_status(ap);
|
2007-08-03 15:10:07 +00:00
|
|
|
|
|
|
|
/* reset ADMA to idle state */
|
|
|
|
writew(aPIOMD4 | aNIEN | aRSTADM, chan + ADMA_CONTROL);
|
|
|
|
udelay(2);
|
|
|
|
writew(aPIOMD4 | aNIEN, chan + ADMA_CONTROL);
|
|
|
|
udelay(2);
|
|
|
|
}
|
2005-10-10 21:53:58 +00:00
|
|
|
|
2007-08-03 15:10:07 +00:00
|
|
|
static void adma_thaw(struct ata_port *ap)
|
|
|
|
{
|
2005-10-10 21:53:58 +00:00
|
|
|
adma_reinit_engine(ap);
|
|
|
|
}
|
|
|
|
|
2007-08-06 09:36:23 +00:00
|
|
|
static int adma_prereset(struct ata_link *link, unsigned long deadline)
|
2005-10-10 21:53:58 +00:00
|
|
|
{
|
2007-08-06 09:36:23 +00:00
|
|
|
struct ata_port *ap = link->ap;
|
2005-10-10 21:53:58 +00:00
|
|
|
struct adma_port_priv *pp = ap->private_data;
|
|
|
|
|
|
|
|
if (pp->state != adma_state_idle) /* healthy paranoia */
|
|
|
|
pp->state = adma_state_mmio;
|
|
|
|
adma_reinit_engine(ap);
|
2007-08-03 15:10:07 +00:00
|
|
|
|
2008-04-07 13:47:16 +00:00
|
|
|
return ata_sff_prereset(link, deadline);
|
2007-08-03 15:10:07 +00:00
|
|
|
}
|
|
|
|
|
2005-10-10 21:53:58 +00:00
|
|
|
static int adma_fill_sg(struct ata_queued_cmd *qc)
|
|
|
|
{
|
2005-10-19 02:14:54 +00:00
|
|
|
struct scatterlist *sg;
|
2005-10-10 21:53:58 +00:00
|
|
|
struct ata_port *ap = qc->ap;
|
|
|
|
struct adma_port_priv *pp = ap->private_data;
|
2007-10-18 20:21:18 +00:00
|
|
|
u8 *buf = pp->pkt, *last_buf = NULL;
|
2005-10-19 02:14:54 +00:00
|
|
|
int i = (2 + buf[3]) * 8;
|
2005-10-10 21:53:58 +00:00
|
|
|
u8 pFLAGS = pORD | ((qc->tf.flags & ATA_TFLAG_WRITE) ? pDIRO : 0);
|
2007-12-05 07:43:11 +00:00
|
|
|
unsigned int si;
|
2005-10-10 21:53:58 +00:00
|
|
|
|
2007-12-05 07:43:11 +00:00
|
|
|
for_each_sg(qc->sg, sg, qc->n_elem, si) {
|
2005-10-10 21:53:58 +00:00
|
|
|
u32 addr;
|
|
|
|
u32 len;
|
|
|
|
|
|
|
|
addr = (u32)sg_dma_address(sg);
|
|
|
|
*(__le32 *)(buf + i) = cpu_to_le32(addr);
|
|
|
|
i += 4;
|
|
|
|
|
|
|
|
len = sg_dma_len(sg) >> 3;
|
|
|
|
*(__le32 *)(buf + i) = cpu_to_le32(len);
|
|
|
|
i += 4;
|
|
|
|
|
2007-10-18 20:21:18 +00:00
|
|
|
last_buf = &buf[i];
|
2005-10-10 21:53:58 +00:00
|
|
|
buf[i++] = pFLAGS;
|
|
|
|
buf[i++] = qc->dev->dma_mode & 0xf;
|
|
|
|
buf[i++] = 0; /* pPKLW */
|
|
|
|
buf[i++] = 0; /* reserved */
|
|
|
|
|
2007-10-26 04:03:37 +00:00
|
|
|
*(__le32 *)(buf + i) =
|
|
|
|
(pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4);
|
2005-10-10 21:53:58 +00:00
|
|
|
i += 4;
|
|
|
|
|
2006-03-21 15:54:24 +00:00
|
|
|
VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", i/4,
|
2005-10-10 21:53:58 +00:00
|
|
|
(unsigned long)addr, len);
|
|
|
|
}
|
2007-10-18 20:21:18 +00:00
|
|
|
|
|
|
|
if (likely(last_buf))
|
|
|
|
*last_buf |= pEND;
|
|
|
|
|
2005-10-10 21:53:58 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void adma_qc_prep(struct ata_queued_cmd *qc)
|
|
|
|
{
|
|
|
|
struct adma_port_priv *pp = qc->ap->private_data;
|
|
|
|
u8 *buf = pp->pkt;
|
|
|
|
u32 pkt_dma = (u32)pp->pkt_dma;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
|
|
|
adma_enter_reg_mode(qc->ap);
|
2010-05-10 19:41:40 +00:00
|
|
|
if (qc->tf.protocol != ATA_PROT_DMA)
|
2005-10-10 21:53:58 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
buf[i++] = 0; /* Response flags */
|
|
|
|
buf[i++] = 0; /* reserved */
|
|
|
|
buf[i++] = cVLD | cDAT | cIEN;
|
|
|
|
i++; /* cLEN, gets filled in below */
|
|
|
|
|
|
|
|
*(__le32 *)(buf+i) = cpu_to_le32(pkt_dma); /* cNCPB */
|
|
|
|
i += 4; /* cNCPB */
|
|
|
|
i += 4; /* cPRD, gets filled in below */
|
|
|
|
|
|
|
|
buf[i++] = 0; /* reserved */
|
|
|
|
buf[i++] = 0; /* reserved */
|
|
|
|
buf[i++] = 0; /* reserved */
|
|
|
|
buf[i++] = 0; /* reserved */
|
|
|
|
|
|
|
|
/* ATA registers; must be a multiple of 4 */
|
|
|
|
buf[i++] = qc->tf.device;
|
|
|
|
buf[i++] = ADMA_REGS_DEVICE;
|
|
|
|
if ((qc->tf.flags & ATA_TFLAG_LBA48)) {
|
|
|
|
buf[i++] = qc->tf.hob_nsect;
|
|
|
|
buf[i++] = ADMA_REGS_SECTOR_COUNT;
|
|
|
|
buf[i++] = qc->tf.hob_lbal;
|
|
|
|
buf[i++] = ADMA_REGS_LBA_LOW;
|
|
|
|
buf[i++] = qc->tf.hob_lbam;
|
|
|
|
buf[i++] = ADMA_REGS_LBA_MID;
|
|
|
|
buf[i++] = qc->tf.hob_lbah;
|
|
|
|
buf[i++] = ADMA_REGS_LBA_HIGH;
|
|
|
|
}
|
|
|
|
buf[i++] = qc->tf.nsect;
|
|
|
|
buf[i++] = ADMA_REGS_SECTOR_COUNT;
|
|
|
|
buf[i++] = qc->tf.lbal;
|
|
|
|
buf[i++] = ADMA_REGS_LBA_LOW;
|
|
|
|
buf[i++] = qc->tf.lbam;
|
|
|
|
buf[i++] = ADMA_REGS_LBA_MID;
|
|
|
|
buf[i++] = qc->tf.lbah;
|
|
|
|
buf[i++] = ADMA_REGS_LBA_HIGH;
|
|
|
|
buf[i++] = 0;
|
|
|
|
buf[i++] = ADMA_REGS_CONTROL;
|
|
|
|
buf[i++] = rIGN;
|
|
|
|
buf[i++] = 0;
|
|
|
|
buf[i++] = qc->tf.command;
|
|
|
|
buf[i++] = ADMA_REGS_COMMAND | rEND;
|
|
|
|
|
|
|
|
buf[3] = (i >> 3) - 2; /* cLEN */
|
|
|
|
*(__le32 *)(buf+8) = cpu_to_le32(pkt_dma + i); /* cPRD */
|
|
|
|
|
|
|
|
i = adma_fill_sg(qc);
|
|
|
|
wmb(); /* flush PRDs and pkt to memory */
|
|
|
|
#if 0
|
|
|
|
/* dump out CPB + PRDs for debug */
|
|
|
|
{
|
|
|
|
int j, len = 0;
|
|
|
|
static char obuf[2048];
|
|
|
|
for (j = 0; j < i; ++j) {
|
|
|
|
len += sprintf(obuf+len, "%02x ", buf[j]);
|
|
|
|
if ((j & 7) == 7) {
|
|
|
|
printk("%s\n", obuf);
|
|
|
|
len = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (len)
|
|
|
|
printk("%s\n", obuf);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void adma_packet_start(struct ata_queued_cmd *qc)
|
|
|
|
{
|
|
|
|
struct ata_port *ap = qc->ap;
|
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 14:44:08 +00:00
|
|
|
void __iomem *chan = ADMA_PORT_REGS(ap);
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
VPRINTK("ENTER, ap %p\n", ap);
|
|
|
|
|
|
|
|
/* fire up the ADMA engine */
|
2005-10-11 05:44:14 +00:00
|
|
|
writew(aPIOMD4 | aGO, chan + ADMA_CONTROL);
|
2005-10-10 21:53:58 +00:00
|
|
|
}
|
|
|
|
|
2006-01-23 04:09:36 +00:00
|
|
|
static unsigned int adma_qc_issue(struct ata_queued_cmd *qc)
|
2005-10-10 21:53:58 +00:00
|
|
|
{
|
|
|
|
struct adma_port_priv *pp = qc->ap->private_data;
|
|
|
|
|
|
|
|
switch (qc->tf.protocol) {
|
|
|
|
case ATA_PROT_DMA:
|
|
|
|
pp->state = adma_state_pkt;
|
|
|
|
adma_packet_start(qc);
|
|
|
|
return 0;
|
|
|
|
|
2007-12-18 21:34:43 +00:00
|
|
|
case ATAPI_PROT_DMA:
|
2005-10-10 21:53:58 +00:00
|
|
|
BUG();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pp->state = adma_state_mmio;
|
2008-04-07 13:47:16 +00:00
|
|
|
return ata_sff_qc_issue(qc);
|
2005-10-10 21:53:58 +00:00
|
|
|
}
|
|
|
|
|
2006-08-24 07:19:22 +00:00
|
|
|
static inline unsigned int adma_intr_pkt(struct ata_host *host)
|
2005-10-10 21:53:58 +00:00
|
|
|
{
|
|
|
|
unsigned int handled = 0, port_no;
|
|
|
|
|
2006-08-24 07:19:22 +00:00
|
|
|
for (port_no = 0; port_no < host->n_ports; ++port_no) {
|
|
|
|
struct ata_port *ap = host->ports[port_no];
|
2005-10-10 21:53:58 +00:00
|
|
|
struct adma_port_priv *pp;
|
|
|
|
struct ata_queued_cmd *qc;
|
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 14:44:08 +00:00
|
|
|
void __iomem *chan = ADMA_PORT_REGS(ap);
|
2005-10-30 09:44:42 +00:00
|
|
|
u8 status = readb(chan + ADMA_STATUS);
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
if (status == 0)
|
|
|
|
continue;
|
|
|
|
handled = 1;
|
|
|
|
adma_enter_reg_mode(ap);
|
|
|
|
pp = ap->private_data;
|
|
|
|
if (!pp || pp->state != adma_state_pkt)
|
|
|
|
continue;
|
2007-08-06 09:36:22 +00:00
|
|
|
qc = ata_qc_from_tag(ap, ap->link.active_tag);
|
2005-10-30 07:15:08 +00:00
|
|
|
if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
|
2007-08-03 15:10:07 +00:00
|
|
|
if (status & aPERR)
|
|
|
|
qc->err_mask |= AC_ERR_HOST_BUS;
|
|
|
|
else if ((status & (aPSD | aUIRQ)))
|
2005-12-05 07:38:02 +00:00
|
|
|
qc->err_mask |= AC_ERR_OTHER;
|
2007-08-03 15:10:07 +00:00
|
|
|
|
|
|
|
if (pp->pkt[0] & cATERR)
|
|
|
|
qc->err_mask |= AC_ERR_DEV;
|
2005-10-28 19:43:16 +00:00
|
|
|
else if (pp->pkt[0] != cDONE)
|
2005-12-05 07:38:02 +00:00
|
|
|
qc->err_mask |= AC_ERR_OTHER;
|
2005-10-30 09:44:42 +00:00
|
|
|
|
2007-08-03 15:10:07 +00:00
|
|
|
if (!qc->err_mask)
|
|
|
|
ata_qc_complete(qc);
|
|
|
|
else {
|
2007-08-06 09:36:22 +00:00
|
|
|
struct ata_eh_info *ehi = &ap->link.eh_info;
|
2007-08-03 15:10:07 +00:00
|
|
|
ata_ehi_clear_desc(ehi);
|
|
|
|
ata_ehi_push_desc(ehi,
|
|
|
|
"ADMA-status 0x%02X", status);
|
|
|
|
ata_ehi_push_desc(ehi,
|
|
|
|
"pkt[0] 0x%02X", pp->pkt[0]);
|
|
|
|
|
|
|
|
if (qc->err_mask == AC_ERR_DEV)
|
|
|
|
ata_port_abort(ap);
|
|
|
|
else
|
|
|
|
ata_port_freeze(ap);
|
|
|
|
}
|
2005-10-28 19:43:16 +00:00
|
|
|
}
|
2005-10-10 21:53:58 +00:00
|
|
|
}
|
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
2006-08-24 07:19:22 +00:00
|
|
|
static inline unsigned int adma_intr_mmio(struct ata_host *host)
|
2005-10-10 21:53:58 +00:00
|
|
|
{
|
|
|
|
unsigned int handled = 0, port_no;
|
|
|
|
|
2006-08-24 07:19:22 +00:00
|
|
|
for (port_no = 0; port_no < host->n_ports; ++port_no) {
|
2010-05-10 19:41:30 +00:00
|
|
|
struct ata_port *ap = host->ports[port_no];
|
|
|
|
struct adma_port_priv *pp = ap->private_data;
|
|
|
|
struct ata_queued_cmd *qc;
|
|
|
|
|
|
|
|
if (!pp || pp->state != adma_state_mmio)
|
|
|
|
continue;
|
|
|
|
qc = ata_qc_from_tag(ap, ap->link.active_tag);
|
|
|
|
if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
|
|
|
|
|
|
|
|
/* check main status, clearing INTRQ */
|
|
|
|
u8 status = ata_sff_check_status(ap);
|
|
|
|
if ((status & ATA_BUSY))
|
2005-10-10 21:53:58 +00:00
|
|
|
continue;
|
2010-05-10 19:41:30 +00:00
|
|
|
DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n",
|
|
|
|
ap->print_id, qc->tf.protocol, status);
|
|
|
|
|
|
|
|
/* complete taskfile transaction */
|
|
|
|
pp->state = adma_state_idle;
|
|
|
|
qc->err_mask |= ac_err_mask(status);
|
|
|
|
if (!qc->err_mask)
|
|
|
|
ata_qc_complete(qc);
|
|
|
|
else {
|
|
|
|
struct ata_eh_info *ehi = &ap->link.eh_info;
|
|
|
|
ata_ehi_clear_desc(ehi);
|
|
|
|
ata_ehi_push_desc(ehi, "status 0x%02X", status);
|
|
|
|
|
|
|
|
if (qc->err_mask == AC_ERR_DEV)
|
|
|
|
ata_port_abort(ap);
|
|
|
|
else
|
|
|
|
ata_port_freeze(ap);
|
2005-10-10 21:53:58 +00:00
|
|
|
}
|
2010-05-10 19:41:30 +00:00
|
|
|
handled = 1;
|
2005-10-10 21:53:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t adma_intr(int irq, void *dev_instance)
|
2005-10-10 21:53:58 +00:00
|
|
|
{
|
2006-08-24 07:19:22 +00:00
|
|
|
struct ata_host *host = dev_instance;
|
2005-10-10 21:53:58 +00:00
|
|
|
unsigned int handled = 0;
|
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
2006-08-24 07:19:22 +00:00
|
|
|
spin_lock(&host->lock);
|
|
|
|
handled = adma_intr_pkt(host) | adma_intr_mmio(host);
|
|
|
|
spin_unlock(&host->lock);
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
VPRINTK("EXIT\n");
|
|
|
|
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
}
|
|
|
|
|
2007-02-01 06:06:36 +00:00
|
|
|
static void adma_ata_setup_port(struct ata_ioports *port, void __iomem *base)
|
2005-10-10 21:53:58 +00:00
|
|
|
{
|
|
|
|
port->cmd_addr =
|
|
|
|
port->data_addr = base + 0x000;
|
|
|
|
port->error_addr =
|
|
|
|
port->feature_addr = base + 0x004;
|
|
|
|
port->nsect_addr = base + 0x008;
|
|
|
|
port->lbal_addr = base + 0x00c;
|
|
|
|
port->lbam_addr = base + 0x010;
|
|
|
|
port->lbah_addr = base + 0x014;
|
|
|
|
port->device_addr = base + 0x018;
|
|
|
|
port->status_addr =
|
|
|
|
port->command_addr = base + 0x01c;
|
|
|
|
port->altstatus_addr =
|
|
|
|
port->ctl_addr = base + 0x038;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int adma_port_start(struct ata_port *ap)
|
|
|
|
{
|
2006-08-24 07:19:22 +00:00
|
|
|
struct device *dev = ap->host->dev;
|
2005-10-10 21:53:58 +00:00
|
|
|
struct adma_port_priv *pp;
|
|
|
|
|
|
|
|
adma_enter_reg_mode(ap);
|
2007-01-20 07:00:28 +00:00
|
|
|
pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
|
2005-10-10 21:53:58 +00:00
|
|
|
if (!pp)
|
2007-01-20 07:00:28 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
pp->pkt = dmam_alloc_coherent(dev, ADMA_PKT_BYTES, &pp->pkt_dma,
|
|
|
|
GFP_KERNEL);
|
2005-10-10 21:53:58 +00:00
|
|
|
if (!pp->pkt)
|
2007-01-20 07:00:28 +00:00
|
|
|
return -ENOMEM;
|
2005-10-10 21:53:58 +00:00
|
|
|
/* paranoia? */
|
|
|
|
if ((pp->pkt_dma & 7) != 0) {
|
2007-10-26 04:03:37 +00:00
|
|
|
printk(KERN_ERR "bad alignment for pp->pkt_dma: %08x\n",
|
2005-10-10 21:53:58 +00:00
|
|
|
(u32)pp->pkt_dma);
|
2007-01-20 07:00:28 +00:00
|
|
|
return -ENOMEM;
|
2005-10-10 21:53:58 +00:00
|
|
|
}
|
|
|
|
memset(pp->pkt, 0, ADMA_PKT_BYTES);
|
|
|
|
ap->private_data = pp;
|
|
|
|
adma_reinit_engine(ap);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void adma_port_stop(struct ata_port *ap)
|
|
|
|
{
|
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 14:44:08 +00:00
|
|
|
adma_reset_engine(ap);
|
2005-10-10 21:53:58 +00: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 14:44:08 +00:00
|
|
|
static void adma_host_init(struct ata_host *host, unsigned int chip_id)
|
2005-10-10 21:53:58 +00:00
|
|
|
{
|
|
|
|
unsigned int port_no;
|
|
|
|
|
|
|
|
/* enable/lock aGO operation */
|
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 14:44:08 +00:00
|
|
|
writeb(7, host->iomap[ADMA_MMIO_BAR] + ADMA_MODE_LOCK);
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
/* reset the ADMA logic */
|
|
|
|
for (port_no = 0; port_no < ADMA_PORTS; ++port_no)
|
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 14:44:08 +00:00
|
|
|
adma_reset_engine(host->ports[port_no]);
|
2005-10-10 21:53:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2009-04-07 02:01:15 +00:00
|
|
|
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
|
2005-10-10 21:53:58 +00:00
|
|
|
if (rc) {
|
2011-04-15 22:51:58 +00:00
|
|
|
dev_err(&pdev->dev, "32-bit DMA enable failed\n");
|
2005-10-10 21:53:58 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2009-04-07 02:01:15 +00:00
|
|
|
rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
|
2005-10-10 21:53:58 +00:00
|
|
|
if (rc) {
|
2011-04-15 22:51:58 +00:00
|
|
|
dev_err(&pdev->dev, "32-bit consistent DMA enable failed\n");
|
2005-10-10 21:53:58 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int adma_ata_init_one(struct pci_dev *pdev,
|
2007-02-01 06:06:36 +00:00
|
|
|
const struct pci_device_id *ent)
|
2005-10-10 21:53:58 +00:00
|
|
|
{
|
|
|
|
unsigned int board_idx = (unsigned int) ent->driver_data;
|
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 14:44:08 +00:00
|
|
|
const struct ata_port_info *ppi[] = { &adma_port_info[board_idx], NULL };
|
|
|
|
struct ata_host *host;
|
|
|
|
void __iomem *mmio_base;
|
2005-10-10 21:53:58 +00:00
|
|
|
int rc, port_no;
|
|
|
|
|
2011-04-15 22:52:00 +00:00
|
|
|
ata_print_version_once(&pdev->dev, DRV_VERSION);
|
2005-10-10 21:53:58 +00: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 14:44:08 +00:00
|
|
|
/* alloc host */
|
|
|
|
host = ata_host_alloc_pinfo(&pdev->dev, ppi, ADMA_PORTS);
|
|
|
|
if (!host)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/* acquire resources and fill host */
|
2007-01-20 07:00:28 +00:00
|
|
|
rc = pcim_enable_device(pdev);
|
2005-10-10 21:53:58 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2007-01-20 07:00:28 +00:00
|
|
|
if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0)
|
|
|
|
return -ENODEV;
|
2005-10-10 21:53:58 +00:00
|
|
|
|
2007-02-01 06:06:36 +00:00
|
|
|
rc = pcim_iomap_regions(pdev, 1 << ADMA_MMIO_BAR, DRV_NAME);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
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 14:44:08 +00:00
|
|
|
host->iomap = pcim_iomap_table(pdev);
|
|
|
|
mmio_base = host->iomap[ADMA_MMIO_BAR];
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
rc = adma_set_dma_masks(pdev, mmio_base);
|
|
|
|
if (rc)
|
2007-01-20 07:00:28 +00:00
|
|
|
return rc;
|
2005-10-10 21:53:58 +00:00
|
|
|
|
2007-08-18 04:14:55 +00:00
|
|
|
for (port_no = 0; port_no < ADMA_PORTS; ++port_no) {
|
|
|
|
struct ata_port *ap = host->ports[port_no];
|
|
|
|
void __iomem *port_base = ADMA_ATA_REGS(mmio_base, port_no);
|
|
|
|
unsigned int offset = port_base - mmio_base;
|
|
|
|
|
|
|
|
adma_ata_setup_port(&ap->ioaddr, port_base);
|
|
|
|
|
|
|
|
ata_port_pbar_desc(ap, ADMA_MMIO_BAR, -1, "mmio");
|
|
|
|
ata_port_pbar_desc(ap, ADMA_MMIO_BAR, offset, "port");
|
|
|
|
}
|
2005-10-10 21:53:58 +00:00
|
|
|
|
|
|
|
/* initialize adapter */
|
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 14:44:08 +00:00
|
|
|
adma_host_init(host, board_idx);
|
2005-10-10 21:53:58 +00: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 14:44:08 +00:00
|
|
|
pci_set_master(pdev);
|
|
|
|
return ata_host_activate(host, pdev->irq, adma_intr, IRQF_SHARED,
|
|
|
|
&adma_ata_sht);
|
2005-10-10 21:53:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init adma_ata_init(void)
|
|
|
|
{
|
2006-08-10 09:13:18 +00:00
|
|
|
return pci_register_driver(&adma_ata_pci_driver);
|
2005-10-10 21:53:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit adma_ata_exit(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&adma_ata_pci_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Mark Lord");
|
|
|
|
MODULE_DESCRIPTION("Pacific Digital Corporation ADMA low-level driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DEVICE_TABLE(pci, adma_ata_pci_tbl);
|
|
|
|
MODULE_VERSION(DRV_VERSION);
|
|
|
|
|
|
|
|
module_init(adma_ata_init);
|
|
|
|
module_exit(adma_ata_exit);
|