2019-05-23 09:15:02 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* sata_qstor.c - Pacific Digital Corporation QStor SATA
|
|
|
|
*
|
|
|
|
* Maintained by: Mark Lord <mlord@pobox.com>
|
|
|
|
*
|
|
|
|
* Copyright 2005 Pacific Digital Corporation.
|
|
|
|
* (OSL/GPL code release authorized by Jalil Fadavi).
|
|
|
|
*
|
2005-08-29 00:18:39 +00:00
|
|
|
* libata documentation is available via 'make {ps|pdf}docs',
|
2017-05-14 14:52:56 +00:00
|
|
|
* as Documentation/driver-api/libata.rst
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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-04-16 22:20:36 +00:00
|
|
|
#include <linux/pci.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-04-16 22:20:36 +00:00
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <linux/libata.h>
|
|
|
|
|
|
|
|
#define DRV_NAME "sata_qstor"
|
2007-08-31 08:54:06 +00:00
|
|
|
#define DRV_VERSION "0.09"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
enum {
|
2007-02-01 06:06:36 +00:00
|
|
|
QS_MMIO_BAR = 4,
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
QS_PORTS = 4,
|
|
|
|
QS_MAX_PRD = LIBATA_MAX_PRD,
|
|
|
|
QS_CPB_ORDER = 6,
|
|
|
|
QS_CPB_BYTES = (1 << QS_CPB_ORDER),
|
|
|
|
QS_PRD_BYTES = QS_MAX_PRD * 16,
|
|
|
|
QS_PKT_BYTES = QS_CPB_BYTES + QS_PRD_BYTES,
|
|
|
|
|
|
|
|
/* global register offsets */
|
|
|
|
QS_HCF_CNFG3 = 0x0003, /* host configuration offset */
|
|
|
|
QS_HID_HPHY = 0x0004, /* host physical interface info */
|
|
|
|
QS_HCT_CTRL = 0x00e4, /* global interrupt mask offset */
|
|
|
|
QS_HST_SFF = 0x0100, /* host status fifo offset */
|
|
|
|
QS_HVS_SERD3 = 0x0393, /* PHY enable offset */
|
|
|
|
|
|
|
|
/* global control bits */
|
|
|
|
QS_HPHY_64BIT = (1 << 1), /* 64-bit bus detected */
|
|
|
|
QS_CNFG3_GSRST = 0x01, /* global chip reset */
|
|
|
|
QS_SERD3_PHY_ENA = 0xf0, /* PHY detection ENAble*/
|
|
|
|
|
|
|
|
/* per-channel register offsets */
|
|
|
|
QS_CCF_CPBA = 0x0710, /* chan CPB base address */
|
|
|
|
QS_CCF_CSEP = 0x0718, /* chan CPB separation factor */
|
|
|
|
QS_CFC_HUFT = 0x0800, /* host upstream fifo threshold */
|
|
|
|
QS_CFC_HDFT = 0x0804, /* host downstream fifo threshold */
|
|
|
|
QS_CFC_DUFT = 0x0808, /* dev upstream fifo threshold */
|
|
|
|
QS_CFC_DDFT = 0x080c, /* dev downstream fifo threshold */
|
|
|
|
QS_CCT_CTR0 = 0x0900, /* chan control-0 offset */
|
|
|
|
QS_CCT_CTR1 = 0x0901, /* chan control-1 offset */
|
|
|
|
QS_CCT_CFF = 0x0a00, /* chan command fifo offset */
|
|
|
|
|
|
|
|
/* channel control bits */
|
|
|
|
QS_CTR0_REG = (1 << 1), /* register mode (vs. pkt mode) */
|
|
|
|
QS_CTR0_CLER = (1 << 2), /* clear channel errors */
|
|
|
|
QS_CTR1_RDEV = (1 << 1), /* sata phy/comms reset */
|
|
|
|
QS_CTR1_RCHN = (1 << 4), /* reset channel logic */
|
|
|
|
QS_CCF_RUN_PKT = 0x107, /* RUN a new dma PKT */
|
|
|
|
|
|
|
|
/* pkt sub-field headers */
|
|
|
|
QS_HCB_HDR = 0x01, /* Host Control Block header */
|
|
|
|
QS_DCB_HDR = 0x02, /* Device Control Block header */
|
|
|
|
|
|
|
|
/* pkt HCB flag bits */
|
|
|
|
QS_HF_DIRO = (1 << 0), /* data DIRection Out */
|
|
|
|
QS_HF_DAT = (1 << 3), /* DATa pkt */
|
|
|
|
QS_HF_IEN = (1 << 4), /* Interrupt ENable */
|
|
|
|
QS_HF_VLD = (1 << 5), /* VaLiD pkt */
|
|
|
|
|
|
|
|
/* pkt DCB flag bits */
|
|
|
|
QS_DF_PORD = (1 << 2), /* Pio OR Dma */
|
|
|
|
QS_DF_ELBA = (1 << 3), /* Extended LBA (lba48) */
|
|
|
|
|
|
|
|
/* PCI device IDs */
|
|
|
|
board_2068_idx = 0, /* QStor 4-port SATA/RAID */
|
|
|
|
};
|
|
|
|
|
2005-10-21 05:46:02 +00:00
|
|
|
enum {
|
|
|
|
QS_DMA_BOUNDARY = ~0UL
|
|
|
|
};
|
|
|
|
|
2007-11-07 15:52:55 +00:00
|
|
|
typedef enum { qs_state_mmio, qs_state_pkt } qs_state_t;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
struct qs_port_priv {
|
|
|
|
u8 *pkt;
|
|
|
|
dma_addr_t pkt_dma;
|
|
|
|
qs_state_t state;
|
|
|
|
};
|
|
|
|
|
2008-07-31 08:02:40 +00:00
|
|
|
static int qs_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
|
|
|
|
static int qs_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
|
2007-10-26 04:03:37 +00:00
|
|
|
static int qs_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
|
2005-04-16 22:20:36 +00:00
|
|
|
static int qs_port_start(struct ata_port *ap);
|
2006-08-24 07:19:22 +00:00
|
|
|
static void qs_host_stop(struct ata_host *host);
|
2005-04-16 22:20:36 +00:00
|
|
|
static void qs_qc_prep(struct ata_queued_cmd *qc);
|
2006-01-23 04:09:36 +00:00
|
|
|
static unsigned int qs_qc_issue(struct ata_queued_cmd *qc);
|
2005-04-16 22:20:36 +00:00
|
|
|
static int qs_check_atapi_dma(struct ata_queued_cmd *qc);
|
2007-11-07 15:54:15 +00:00
|
|
|
static void qs_freeze(struct ata_port *ap);
|
|
|
|
static void qs_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 qs_prereset(struct ata_link *link, unsigned long deadline);
|
2007-11-07 15:54:15 +00:00
|
|
|
static void qs_error_handler(struct ata_port *ap);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-07 05:59:37 +00:00
|
|
|
static struct scsi_host_template qs_ata_sht = {
|
2008-03-25 03:22:49 +00:00
|
|
|
ATA_BASE_SHT(DRV_NAME),
|
2005-04-16 22:20:36 +00:00
|
|
|
.sg_tablesize = QS_MAX_PRD,
|
|
|
|
.dma_boundary = QS_DMA_BOUNDARY,
|
|
|
|
};
|
|
|
|
|
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 qs_ata_ops = {
|
|
|
|
.inherits = &ata_sff_port_ops,
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
.check_atapi_dma = qs_check_atapi_dma,
|
|
|
|
.qc_prep = qs_qc_prep,
|
|
|
|
.qc_issue = qs_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-11-07 15:54:15 +00:00
|
|
|
.freeze = qs_freeze,
|
|
|
|
.thaw = qs_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 = qs_prereset,
|
|
|
|
.softreset = ATA_OP_NULL,
|
2007-11-07 15:54:15 +00:00
|
|
|
.error_handler = qs_error_handler,
|
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
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
.scr_read = qs_scr_read,
|
|
|
|
.scr_write = qs_scr_write,
|
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-04-16 22:20:36 +00:00
|
|
|
.port_start = qs_port_start,
|
|
|
|
.host_stop = qs_host_stop,
|
|
|
|
};
|
|
|
|
|
2005-11-28 09:06:23 +00:00
|
|
|
static const struct ata_port_info qs_port_info[] = {
|
2005-04-16 22:20:36 +00:00
|
|
|
/* board_2068_idx */
|
|
|
|
{
|
2011-02-04 19:05:48 +00:00
|
|
|
.flags = ATA_FLAG_SATA | 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_UDMA6,
|
2005-04-16 22:20:36 +00:00
|
|
|
.port_ops = &qs_ata_ops,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2005-11-10 16:04:11 +00:00
|
|
|
static const struct pci_device_id qs_ata_pci_tbl[] = {
|
2006-09-29 00:21:59 +00:00
|
|
|
{ PCI_VDEVICE(PDC, 0x2068), board_2068_idx },
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
{ } /* terminate list */
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct pci_driver qs_ata_pci_driver = {
|
|
|
|
.name = DRV_NAME,
|
|
|
|
.id_table = qs_ata_pci_tbl,
|
|
|
|
.probe = qs_ata_init_one,
|
|
|
|
.remove = ata_pci_remove_one,
|
|
|
|
};
|
|
|
|
|
2007-02-01 06:06:36 +00:00
|
|
|
static void __iomem *qs_mmio_base(struct ata_host *host)
|
|
|
|
{
|
|
|
|
return host->iomap[QS_MMIO_BAR];
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int qs_check_atapi_dma(struct ata_queued_cmd *qc)
|
|
|
|
{
|
|
|
|
return 1; /* ATAPI DMA not supported */
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void qs_enter_reg_mode(struct ata_port *ap)
|
|
|
|
{
|
2007-02-01 06:06:36 +00:00
|
|
|
u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
|
2007-11-07 15:52:55 +00:00
|
|
|
struct qs_port_priv *pp = ap->private_data;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-11-07 15:52:55 +00:00
|
|
|
pp->state = qs_state_mmio;
|
2005-04-16 22:20:36 +00:00
|
|
|
writeb(QS_CTR0_REG, chan + QS_CCT_CTR0);
|
|
|
|
readb(chan + QS_CCT_CTR0); /* flush */
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void qs_reset_channel_logic(struct ata_port *ap)
|
|
|
|
{
|
2007-02-01 06:06:36 +00:00
|
|
|
u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
writeb(QS_CTR1_RCHN, chan + QS_CCT_CTR1);
|
|
|
|
readb(chan + QS_CCT_CTR0); /* flush */
|
|
|
|
qs_enter_reg_mode(ap);
|
|
|
|
}
|
|
|
|
|
2007-11-07 15:54:15 +00:00
|
|
|
static void qs_freeze(struct ata_port *ap)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-11-07 15:54:15 +00:00
|
|
|
u8 __iomem *mmio_base = qs_mmio_base(ap->host);
|
|
|
|
|
|
|
|
writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
|
|
|
|
qs_enter_reg_mode(ap);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-11-07 15:54:15 +00:00
|
|
|
static void qs_thaw(struct ata_port *ap)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-11-07 15:54:15 +00:00
|
|
|
u8 __iomem *mmio_base = qs_mmio_base(ap->host);
|
|
|
|
|
|
|
|
qs_enter_reg_mode(ap);
|
|
|
|
writeb(1, mmio_base + QS_HCT_CTRL); /* enable host interrupts */
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qs_prereset(struct ata_link *link, unsigned long deadline)
|
|
|
|
{
|
|
|
|
struct ata_port *ap = link->ap;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
qs_reset_channel_logic(ap);
|
2008-04-07 13:47:16 +00:00
|
|
|
return ata_sff_prereset(link, deadline);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-07-31 08:02:40 +00:00
|
|
|
static int qs_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
if (sc_reg > SCR_CONTROL)
|
2007-07-16 05:29:40 +00:00
|
|
|
return -EINVAL;
|
2008-07-31 08:02:40 +00:00
|
|
|
*val = readl(link->ap->ioaddr.scr_addr + (sc_reg * 8));
|
2007-07-16 05:29:40 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-11-07 15:54:15 +00:00
|
|
|
static void qs_error_handler(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
qs_enter_reg_mode(ap);
|
2010-05-10 19:41:39 +00:00
|
|
|
ata_sff_error_handler(ap);
|
2007-11-07 15:54:15 +00:00
|
|
|
}
|
|
|
|
|
2008-07-31 08:02:40 +00:00
|
|
|
static int qs_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
if (sc_reg > SCR_CONTROL)
|
2007-07-16 05:29:40 +00:00
|
|
|
return -EINVAL;
|
2008-07-31 08:02:40 +00:00
|
|
|
writel(val, link->ap->ioaddr.scr_addr + (sc_reg * 8));
|
2007-07-16 05:29:40 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-11-12 06:27:07 +00:00
|
|
|
static unsigned int qs_fill_sg(struct ata_queued_cmd *qc)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-10-05 11:13:30 +00:00
|
|
|
struct scatterlist *sg;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct ata_port *ap = qc->ap;
|
|
|
|
struct qs_port_priv *pp = ap->private_data;
|
|
|
|
u8 *prd = pp->pkt + QS_CPB_BYTES;
|
2007-12-05 07:43:11 +00:00
|
|
|
unsigned int si;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-12-05 07:43:11 +00:00
|
|
|
for_each_sg(qc->sg, sg, qc->n_elem, si) {
|
2005-04-16 22:20:36 +00:00
|
|
|
u64 addr;
|
|
|
|
u32 len;
|
|
|
|
|
|
|
|
addr = sg_dma_address(sg);
|
|
|
|
*(__le64 *)prd = cpu_to_le64(addr);
|
|
|
|
prd += sizeof(u64);
|
|
|
|
|
|
|
|
len = sg_dma_len(sg);
|
|
|
|
*(__le32 *)prd = cpu_to_le32(len);
|
|
|
|
prd += sizeof(u64);
|
|
|
|
|
2007-12-05 07:43:11 +00:00
|
|
|
VPRINTK("PRD[%u] = (0x%llX, 0x%X)\n", si,
|
2005-04-16 22:20:36 +00:00
|
|
|
(unsigned long long)addr, len);
|
|
|
|
}
|
2005-11-12 06:27:07 +00:00
|
|
|
|
2007-12-05 07:43:11 +00:00
|
|
|
return si;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void qs_qc_prep(struct ata_queued_cmd *qc)
|
|
|
|
{
|
|
|
|
struct qs_port_priv *pp = qc->ap->private_data;
|
|
|
|
u8 dflags = QS_DF_PORD, *buf = pp->pkt;
|
|
|
|
u8 hflags = QS_HF_DAT | QS_HF_IEN | QS_HF_VLD;
|
|
|
|
u64 addr;
|
2005-11-12 06:27:07 +00:00
|
|
|
unsigned int nelem;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
|
|
|
qs_enter_reg_mode(qc->ap);
|
2010-05-10 19:41:40 +00:00
|
|
|
if (qc->tf.protocol != ATA_PROT_DMA)
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
|
2005-11-12 06:27:07 +00:00
|
|
|
nelem = qs_fill_sg(qc);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if ((qc->tf.flags & ATA_TFLAG_WRITE))
|
|
|
|
hflags |= QS_HF_DIRO;
|
|
|
|
if ((qc->tf.flags & ATA_TFLAG_LBA48))
|
|
|
|
dflags |= QS_DF_ELBA;
|
|
|
|
|
|
|
|
/* host control block (HCB) */
|
|
|
|
buf[ 0] = QS_HCB_HDR;
|
|
|
|
buf[ 1] = hflags;
|
2007-01-03 08:30:39 +00:00
|
|
|
*(__le32 *)(&buf[ 4]) = cpu_to_le32(qc->nbytes);
|
2005-11-12 06:27:07 +00:00
|
|
|
*(__le32 *)(&buf[ 8]) = cpu_to_le32(nelem);
|
2005-04-16 22:20:36 +00:00
|
|
|
addr = ((u64)pp->pkt_dma) + QS_CPB_BYTES;
|
|
|
|
*(__le64 *)(&buf[16]) = cpu_to_le64(addr);
|
|
|
|
|
|
|
|
/* device control block (DCB) */
|
|
|
|
buf[24] = QS_DCB_HDR;
|
|
|
|
buf[28] = dflags;
|
|
|
|
|
|
|
|
/* frame information structure (FIS) */
|
2007-07-16 05:29:38 +00:00
|
|
|
ata_tf_to_fis(&qc->tf, 0, 1, &buf[32]);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void qs_packet_start(struct ata_queued_cmd *qc)
|
|
|
|
{
|
|
|
|
struct ata_port *ap = qc->ap;
|
2007-02-01 06:06:36 +00:00
|
|
|
u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
VPRINTK("ENTER, ap %p\n", ap);
|
|
|
|
|
|
|
|
writeb(QS_CTR0_CLER, chan + QS_CCT_CTR0);
|
|
|
|
wmb(); /* flush PRDs and pkt to memory */
|
|
|
|
writel(QS_CCF_RUN_PKT, chan + QS_CCT_CFF);
|
|
|
|
readl(chan + QS_CCT_CFF); /* flush */
|
|
|
|
}
|
|
|
|
|
2006-01-23 04:09:36 +00:00
|
|
|
static unsigned int qs_qc_issue(struct ata_queued_cmd *qc)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct qs_port_priv *pp = qc->ap->private_data;
|
|
|
|
|
|
|
|
switch (qc->tf.protocol) {
|
|
|
|
case ATA_PROT_DMA:
|
|
|
|
pp->state = qs_state_pkt;
|
|
|
|
qs_packet_start(qc);
|
|
|
|
return 0;
|
|
|
|
|
2007-12-18 21:34:43 +00:00
|
|
|
case ATAPI_PROT_DMA:
|
2005-04-16 22:20:36 +00:00
|
|
|
BUG();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pp->state = qs_state_mmio;
|
2008-04-07 13:47:16 +00:00
|
|
|
return ata_sff_qc_issue(qc);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-11-07 15:54:15 +00:00
|
|
|
static void qs_do_or_die(struct ata_queued_cmd *qc, u8 status)
|
|
|
|
{
|
|
|
|
qc->err_mask |= ac_err_mask(status);
|
|
|
|
|
|
|
|
if (!qc->err_mask) {
|
|
|
|
ata_qc_complete(qc);
|
|
|
|
} else {
|
|
|
|
struct ata_port *ap = qc->ap;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-24 07:19:22 +00:00
|
|
|
static inline unsigned int qs_intr_pkt(struct ata_host *host)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unsigned int handled = 0;
|
|
|
|
u8 sFFE;
|
2007-02-01 06:06:36 +00:00
|
|
|
u8 __iomem *mmio_base = qs_mmio_base(host);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
u32 sff0 = readl(mmio_base + QS_HST_SFF);
|
|
|
|
u32 sff1 = readl(mmio_base + QS_HST_SFF + 4);
|
|
|
|
u8 sEVLD = (sff1 >> 30) & 0x01; /* valid flag */
|
|
|
|
sFFE = sff1 >> 31; /* empty flag */
|
|
|
|
|
|
|
|
if (sEVLD) {
|
|
|
|
u8 sDST = sff0 >> 16; /* dev status */
|
|
|
|
u8 sHST = sff1 & 0x3f; /* host status */
|
|
|
|
unsigned int port_no = (sff1 >> 8) & 0x03;
|
2006-08-24 07:19:22 +00:00
|
|
|
struct ata_port *ap = host->ports[port_no];
|
2010-05-10 19:41:30 +00:00
|
|
|
struct qs_port_priv *pp = ap->private_data;
|
|
|
|
struct ata_queued_cmd *qc;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
DPRINTK("SFF=%08x%08x: sCHAN=%u sHST=%d sDST=%02x\n",
|
|
|
|
sff1, sff0, port_no, sHST, sDST);
|
|
|
|
handled = 1;
|
2010-05-10 19:41:30 +00:00
|
|
|
if (!pp || pp->state != qs_state_pkt)
|
|
|
|
continue;
|
|
|
|
qc = ata_qc_from_tag(ap, ap->link.active_tag);
|
|
|
|
if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
|
|
|
|
switch (sHST) {
|
|
|
|
case 0: /* successful CPB */
|
|
|
|
case 3: /* device error */
|
|
|
|
qs_enter_reg_mode(qc->ap);
|
|
|
|
qs_do_or_die(qc, sDST);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (!sFFE);
|
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
2006-08-24 07:19:22 +00:00
|
|
|
static inline unsigned int qs_intr_mmio(struct ata_host *host)
|
2005-04-16 22:20:36 +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 qs_port_priv *pp = ap->private_data;
|
|
|
|
struct ata_queued_cmd *qc;
|
|
|
|
|
|
|
|
qc = ata_qc_from_tag(ap, ap->link.active_tag);
|
|
|
|
if (!qc) {
|
|
|
|
/*
|
|
|
|
* The qstor hardware generates spurious
|
|
|
|
* interrupts from time to time when switching
|
|
|
|
* in and out of packet mode. There's no
|
|
|
|
* obvious way to know if we're here now due
|
|
|
|
* to that, so just ack the irq and pretend we
|
|
|
|
* knew it was ours.. (ugh). This does not
|
|
|
|
* affect packet mode.
|
|
|
|
*/
|
|
|
|
ata_sff_check_status(ap);
|
|
|
|
handled = 1;
|
|
|
|
continue;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2010-05-10 19:41:30 +00:00
|
|
|
|
|
|
|
if (!pp || pp->state != qs_state_mmio)
|
|
|
|
continue;
|
|
|
|
if (!(qc->tf.flags & ATA_TFLAG_POLLING))
|
2010-05-19 20:10:21 +00:00
|
|
|
handled |= ata_sff_port_intr(ap, qc);
|
2005-04-16 22:20:36 +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 qs_intr(int irq, void *dev_instance)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-08-24 07:19:22 +00:00
|
|
|
struct ata_host *host = dev_instance;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned int handled = 0;
|
2007-11-07 15:53:41 +00:00
|
|
|
unsigned long flags;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
2007-11-07 15:53:41 +00:00
|
|
|
spin_lock_irqsave(&host->lock, flags);
|
2006-08-24 07:19:22 +00:00
|
|
|
handled = qs_intr_pkt(host) | qs_intr_mmio(host);
|
2007-11-07 15:53:41 +00:00
|
|
|
spin_unlock_irqrestore(&host->lock, flags);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
VPRINTK("EXIT\n");
|
|
|
|
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
}
|
|
|
|
|
2007-02-01 06:06:36 +00:00
|
|
|
static void qs_ata_setup_port(struct ata_ioports *port, void __iomem *base)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
port->cmd_addr =
|
|
|
|
port->data_addr = base + 0x400;
|
|
|
|
port->error_addr =
|
|
|
|
port->feature_addr = base + 0x408; /* hob_feature = 0x409 */
|
|
|
|
port->nsect_addr = base + 0x410; /* hob_nsect = 0x411 */
|
|
|
|
port->lbal_addr = base + 0x418; /* hob_lbal = 0x419 */
|
|
|
|
port->lbam_addr = base + 0x420; /* hob_lbam = 0x421 */
|
|
|
|
port->lbah_addr = base + 0x428; /* hob_lbah = 0x429 */
|
|
|
|
port->device_addr = base + 0x430;
|
|
|
|
port->status_addr =
|
|
|
|
port->command_addr = base + 0x438;
|
|
|
|
port->altstatus_addr =
|
|
|
|
port->ctl_addr = base + 0x440;
|
|
|
|
port->scr_addr = base + 0xc00;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qs_port_start(struct ata_port *ap)
|
|
|
|
{
|
2006-08-24 07:19:22 +00:00
|
|
|
struct device *dev = ap->host->dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct qs_port_priv *pp;
|
2007-02-01 06:06:36 +00:00
|
|
|
void __iomem *mmio_base = qs_mmio_base(ap->host);
|
2005-04-16 22:20:36 +00:00
|
|
|
void __iomem *chan = mmio_base + (ap->port_no * 0x4000);
|
|
|
|
u64 addr;
|
|
|
|
|
2007-01-20 07:00:28 +00:00
|
|
|
pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
|
|
|
|
if (!pp)
|
|
|
|
return -ENOMEM;
|
|
|
|
pp->pkt = dmam_alloc_coherent(dev, QS_PKT_BYTES, &pp->pkt_dma,
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!pp->pkt)
|
|
|
|
return -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
ap->private_data = pp;
|
|
|
|
|
2007-11-07 15:52:55 +00:00
|
|
|
qs_enter_reg_mode(ap);
|
2005-04-16 22:20:36 +00:00
|
|
|
addr = (u64)pp->pkt_dma;
|
|
|
|
writel((u32) addr, chan + QS_CCF_CPBA);
|
|
|
|
writel((u32)(addr >> 32), chan + QS_CCF_CPBA + 4);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-08-24 07:19:22 +00:00
|
|
|
static void qs_host_stop(struct ata_host *host)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-02-01 06:06:36 +00:00
|
|
|
void __iomem *mmio_base = qs_mmio_base(host);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
|
|
|
|
writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */
|
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
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 qs_host_init(struct ata_host *host, unsigned int chip_id)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
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 *mmio_base = host->iomap[QS_MMIO_BAR];
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned int port_no;
|
|
|
|
|
|
|
|
writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
|
|
|
|
writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */
|
|
|
|
|
|
|
|
/* reset each channel in turn */
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
for (port_no = 0; port_no < host->n_ports; ++port_no) {
|
2005-04-16 22:20:36 +00:00
|
|
|
u8 __iomem *chan = mmio_base + (port_no * 0x4000);
|
|
|
|
writeb(QS_CTR1_RDEV|QS_CTR1_RCHN, chan + QS_CCT_CTR1);
|
|
|
|
writeb(QS_CTR0_REG, chan + QS_CCT_CTR0);
|
|
|
|
readb(chan + QS_CCT_CTR0); /* flush */
|
|
|
|
}
|
|
|
|
writeb(QS_SERD3_PHY_ENA, mmio_base + QS_HVS_SERD3); /* enable phy */
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
for (port_no = 0; port_no < host->n_ports; ++port_no) {
|
2005-04-16 22:20:36 +00:00
|
|
|
u8 __iomem *chan = mmio_base + (port_no * 0x4000);
|
|
|
|
/* set FIFO depths to same settings as Windows driver */
|
|
|
|
writew(32, chan + QS_CFC_HUFT);
|
|
|
|
writew(32, chan + QS_CFC_HDFT);
|
|
|
|
writew(10, chan + QS_CFC_DUFT);
|
|
|
|
writew( 8, chan + QS_CFC_DDFT);
|
|
|
|
/* set CPB size in bytes, as a power of two */
|
|
|
|
writeb(QS_CPB_ORDER, chan + QS_CCF_CSEP);
|
|
|
|
}
|
|
|
|
writeb(1, mmio_base + QS_HCT_CTRL); /* enable host interrupts */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The QStor understands 64-bit buses, and uses 64-bit fields
|
|
|
|
* for DMA pointers regardless of bus width. We just have to
|
|
|
|
* make sure our DMA masks are set appropriately for whatever
|
|
|
|
* bridge lies between us and the QStor, and then the DMA mapping
|
|
|
|
* code will ensure we only ever "see" appropriate buffer addresses.
|
|
|
|
* If we're 32-bit limited somewhere, then our 64-bit fields will
|
|
|
|
* just end up with zeros in the upper 32-bits, without any special
|
|
|
|
* logic required outside of this routine (below).
|
|
|
|
*/
|
|
|
|
static int qs_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
|
|
|
|
{
|
|
|
|
u32 bus_info = readl(mmio_base + QS_HID_HPHY);
|
2019-08-26 10:57:23 +00:00
|
|
|
int dma_bits = (bus_info & QS_HPHY_64BIT) ? 64 : 32;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(dma_bits));
|
|
|
|
if (rc)
|
|
|
|
dev_err(&pdev->dev, "%d-bit DMA enable failed\n", dma_bits);
|
|
|
|
return rc;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int qs_ata_init_one(struct pci_dev *pdev,
|
|
|
|
const struct pci_device_id *ent)
|
|
|
|
{
|
|
|
|
unsigned int board_idx = (unsigned int) ent->driver_data;
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
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[] = { &qs_port_info[board_idx], NULL };
|
|
|
|
struct ata_host *host;
|
2005-04-16 22:20:36 +00:00
|
|
|
int rc, port_no;
|
|
|
|
|
2011-04-15 22:52:00 +00:00
|
|
|
ata_print_version_once(&pdev->dev, DRV_VERSION);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
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, QS_PORTS);
|
|
|
|
if (!host)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/* acquire resources and fill host */
|
2007-01-20 07:00:28 +00:00
|
|
|
rc = pcim_enable_device(pdev);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2007-02-01 06:06:36 +00:00
|
|
|
if ((pci_resource_flags(pdev, QS_MMIO_BAR) & IORESOURCE_MEM) == 0)
|
2007-01-20 07:00:28 +00:00
|
|
|
return -ENODEV;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-02-01 06:06:36 +00:00
|
|
|
rc = pcim_iomap_regions(pdev, 1 << QS_MMIO_BAR, DRV_NAME);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
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);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
rc = qs_set_dma_masks(pdev, host->iomap[QS_MMIO_BAR]);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rc)
|
2007-01-20 07:00:28 +00:00
|
|
|
return rc;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
for (port_no = 0; port_no < host->n_ports; ++port_no) {
|
2007-08-18 04:14:55 +00:00
|
|
|
struct ata_port *ap = host->ports[port_no];
|
|
|
|
unsigned int offset = port_no * 0x4000;
|
|
|
|
void __iomem *chan = host->iomap[QS_MMIO_BAR] + offset;
|
|
|
|
|
|
|
|
qs_ata_setup_port(&ap->ioaddr, chan);
|
|
|
|
|
|
|
|
ata_port_pbar_desc(ap, QS_MMIO_BAR, -1, "mmio");
|
|
|
|
ata_port_pbar_desc(ap, QS_MMIO_BAR, offset, "port");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize adapter */
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
qs_host_init(host, board_idx);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
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, qs_intr, IRQF_SHARED,
|
|
|
|
&qs_ata_sht);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 05:43:05 +00:00
|
|
|
module_pci_driver(qs_ata_pci_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Mark Lord");
|
|
|
|
MODULE_DESCRIPTION("Pacific Digital Corporation QStor SATA low-level driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DEVICE_TABLE(pci, qs_ata_pci_tbl);
|
|
|
|
MODULE_VERSION(DRV_VERSION);
|