2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* ahci.c - AHCI SATA support
|
|
|
|
*
|
2005-08-28 17:18:39 -07:00
|
|
|
* Maintained by: Jeff Garzik <jgarzik@pobox.com>
|
|
|
|
* Please ALWAYS copy linux-ide@vger.kernel.org
|
|
|
|
* on emails.
|
|
|
|
*
|
|
|
|
* Copyright 2004-2005 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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.*
|
|
|
|
*
|
|
|
|
* AHCI hardware documentation:
|
2005-04-16 15:20:36 -07:00
|
|
|
* http://www.intel.com/technology/serialata/pdf/rev1_0.pdf
|
2005-08-28 17:18:39 -07:00
|
|
|
* http://www.intel.com/technology/serialata/pdf/rev1_1.pdf
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/interrupt.h>
|
2005-04-08 00:53:06 -07:00
|
|
|
#include <linux/dma-mapping.h>
|
2005-10-30 12:39:11 -07:00
|
|
|
#include <linux/device.h>
|
2007-10-24 22:59:16 -07:00
|
|
|
#include <linux/dmi.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 01:04:11 -07:00
|
|
|
#include <linux/gfp.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <scsi/scsi_host.h>
|
2005-11-06 22:59:37 -07:00
|
|
|
#include <scsi/scsi_cmnd.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/libata.h>
|
|
|
|
|
|
|
|
#define DRV_NAME "ahci"
|
2007-09-22 21:19:54 -07:00
|
|
|
#define DRV_VERSION "3.0"
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-10-13 12:38:36 -07:00
|
|
|
/* Enclosure Management Control */
|
|
|
|
#define EM_CTRL_MSG_TYPE 0x000f0000
|
|
|
|
|
|
|
|
/* Enclosure Management LED Message Type */
|
|
|
|
#define EM_MSG_LED_HBA_PORT 0x0000000f
|
|
|
|
#define EM_MSG_LED_PMP_SLOT 0x0000ff00
|
|
|
|
#define EM_MSG_LED_VALUE 0xffff0000
|
|
|
|
#define EM_MSG_LED_VALUE_ACTIVITY 0x00070000
|
|
|
|
#define EM_MSG_LED_VALUE_OFF 0xfff80000
|
|
|
|
#define EM_MSG_LED_VALUE_ON 0x00010000
|
|
|
|
|
2008-03-09 18:25:25 -07:00
|
|
|
static int ahci_skip_host_reset;
|
2009-01-26 03:05:44 -07:00
|
|
|
static int ahci_ignore_sss;
|
|
|
|
|
2008-03-09 18:25:25 -07:00
|
|
|
module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444);
|
|
|
|
MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)");
|
|
|
|
|
2009-01-26 03:05:44 -07:00
|
|
|
module_param_named(ignore_sss, ahci_ignore_sss, int, 0444);
|
|
|
|
MODULE_PARM_DESC(ignore_sss, "Ignore staggered spinup flag (0=don't ignore, 1=ignore)");
|
|
|
|
|
2007-10-24 22:33:26 -07:00
|
|
|
static int ahci_enable_alpm(struct ata_port *ap,
|
|
|
|
enum link_pm policy);
|
|
|
|
static void ahci_disable_alpm(struct ata_port *ap);
|
2008-06-03 10:33:55 -07:00
|
|
|
static ssize_t ahci_led_show(struct ata_port *ap, char *buf);
|
|
|
|
static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
|
|
|
|
size_t size);
|
|
|
|
static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
|
|
|
|
ssize_t size);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
enum {
|
|
|
|
AHCI_PCI_BAR = 5,
|
2006-11-08 23:08:40 -07:00
|
|
|
AHCI_MAX_PORTS = 32,
|
2005-04-16 15:20:36 -07:00
|
|
|
AHCI_MAX_SG = 168, /* hardware max is 64K */
|
|
|
|
AHCI_DMA_BOUNDARY = 0xffffffff,
|
2006-05-15 05:03:55 -07:00
|
|
|
AHCI_MAX_CMDS = 32,
|
2006-05-15 05:03:50 -07:00
|
|
|
AHCI_CMD_SZ = 32,
|
2006-05-15 05:03:55 -07:00
|
|
|
AHCI_CMD_SLOT_SZ = AHCI_MAX_CMDS * AHCI_CMD_SZ,
|
2005-04-16 15:20:36 -07:00
|
|
|
AHCI_RX_FIS_SZ = 256,
|
2005-06-03 22:13:15 -07:00
|
|
|
AHCI_CMD_TBL_CDB = 0x40,
|
2006-05-15 05:03:50 -07:00
|
|
|
AHCI_CMD_TBL_HDR_SZ = 0x80,
|
|
|
|
AHCI_CMD_TBL_SZ = AHCI_CMD_TBL_HDR_SZ + (AHCI_MAX_SG * 16),
|
|
|
|
AHCI_CMD_TBL_AR_SZ = AHCI_CMD_TBL_SZ * AHCI_MAX_CMDS,
|
|
|
|
AHCI_PORT_PRIV_DMA_SZ = AHCI_CMD_SLOT_SZ + AHCI_CMD_TBL_AR_SZ +
|
2005-04-16 15:20:36 -07:00
|
|
|
AHCI_RX_FIS_SZ,
|
2009-12-09 02:23:04 -07:00
|
|
|
AHCI_PORT_PRIV_FBS_DMA_SZ = AHCI_CMD_SLOT_SZ +
|
|
|
|
AHCI_CMD_TBL_AR_SZ +
|
|
|
|
(AHCI_RX_FIS_SZ * 16),
|
2005-04-16 15:20:36 -07:00
|
|
|
AHCI_IRQ_ON_SG = (1 << 31),
|
|
|
|
AHCI_CMD_ATAPI = (1 << 5),
|
|
|
|
AHCI_CMD_WRITE = (1 << 6),
|
2006-03-11 19:25:27 -07:00
|
|
|
AHCI_CMD_PREFETCH = (1 << 7),
|
2006-01-23 05:38:44 -07:00
|
|
|
AHCI_CMD_RESET = (1 << 8),
|
|
|
|
AHCI_CMD_CLR_BUSY = (1 << 10),
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
RX_FIS_D2H_REG = 0x40, /* offset of D2H Register FIS data */
|
2007-01-25 03:16:28 -07:00
|
|
|
RX_FIS_SDB = 0x58, /* offset of SDB FIS data */
|
2006-05-15 04:58:29 -07:00
|
|
|
RX_FIS_UNK = 0x60, /* offset of Unknown FIS data */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
board_ahci = 0,
|
2007-09-02 20:44:57 -07:00
|
|
|
board_ahci_vt8251 = 1,
|
|
|
|
board_ahci_ign_iferr = 2,
|
|
|
|
board_ahci_sb600 = 3,
|
|
|
|
board_ahci_mv = 4,
|
2008-12-29 19:53:41 -07:00
|
|
|
board_ahci_sb700 = 5, /* for SB700 and SB800 */
|
2008-06-09 08:13:04 -07:00
|
|
|
board_ahci_mcp65 = 6,
|
2008-06-18 17:56:58 -07:00
|
|
|
board_ahci_nopmp = 7,
|
2009-04-08 14:25:31 -07:00
|
|
|
board_ahci_yesncq = 8,
|
2009-11-15 18:56:05 -07:00
|
|
|
board_ahci_nosntf = 9,
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* global controller registers */
|
|
|
|
HOST_CAP = 0x00, /* host capabilities */
|
|
|
|
HOST_CTL = 0x04, /* global host control */
|
|
|
|
HOST_IRQ_STAT = 0x08, /* interrupt status */
|
|
|
|
HOST_PORTS_IMPL = 0x0c, /* bitmap of implemented ports */
|
|
|
|
HOST_VERSION = 0x10, /* AHCI spec. version compliancy */
|
2008-06-03 10:33:55 -07:00
|
|
|
HOST_EM_LOC = 0x1c, /* Enclosure Management location */
|
|
|
|
HOST_EM_CTL = 0x20, /* Enclosure Management Control */
|
2009-09-20 16:02:31 -07:00
|
|
|
HOST_CAP2 = 0x24, /* host capabilities, extended */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* HOST_CTL bits */
|
|
|
|
HOST_RESET = (1 << 0), /* reset controller; self-clear */
|
|
|
|
HOST_IRQ_EN = (1 << 1), /* global IRQ enable */
|
|
|
|
HOST_AHCI_EN = (1 << 31), /* AHCI enabled */
|
|
|
|
|
|
|
|
/* HOST_CAP bits */
|
2009-09-20 16:02:31 -07:00
|
|
|
HOST_CAP_SXS = (1 << 5), /* Supports External SATA */
|
2008-06-03 10:33:55 -07:00
|
|
|
HOST_CAP_EMS = (1 << 6), /* Enclosure Management support */
|
2009-09-20 16:02:31 -07:00
|
|
|
HOST_CAP_CCC = (1 << 7), /* Command Completion Coalescing */
|
|
|
|
HOST_CAP_PART = (1 << 13), /* Partial state capable */
|
|
|
|
HOST_CAP_SSC = (1 << 14), /* Slumber state capable */
|
|
|
|
HOST_CAP_PIO_MULTI = (1 << 15), /* PIO multiple DRQ support */
|
|
|
|
HOST_CAP_FBS = (1 << 16), /* FIS-based switching support */
|
2007-09-22 21:19:54 -07:00
|
|
|
HOST_CAP_PMP = (1 << 17), /* Port Multiplier support */
|
2009-09-20 16:02:31 -07:00
|
|
|
HOST_CAP_ONLY = (1 << 18), /* Supports AHCI mode only */
|
2006-01-23 05:38:44 -07:00
|
|
|
HOST_CAP_CLO = (1 << 24), /* Command List Override support */
|
2009-09-20 16:02:31 -07:00
|
|
|
HOST_CAP_LED = (1 << 25), /* Supports activity LED */
|
2007-10-24 22:33:26 -07:00
|
|
|
HOST_CAP_ALPM = (1 << 26), /* Aggressive Link PM support */
|
2006-07-25 23:59:26 -07:00
|
|
|
HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */
|
2009-09-20 16:02:31 -07:00
|
|
|
HOST_CAP_MPS = (1 << 28), /* Mechanical presence switch */
|
2007-07-15 22:29:40 -07:00
|
|
|
HOST_CAP_SNTF = (1 << 29), /* SNotification register */
|
2006-05-15 05:03:52 -07:00
|
|
|
HOST_CAP_NCQ = (1 << 30), /* Native Command Queueing */
|
2006-05-15 05:03:50 -07:00
|
|
|
HOST_CAP_64 = (1 << 31), /* PCI DAC (64-bit DMA) support */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-09-20 16:02:31 -07:00
|
|
|
/* HOST_CAP2 bits */
|
|
|
|
HOST_CAP2_BOH = (1 << 0), /* BIOS/OS handoff supported */
|
|
|
|
HOST_CAP2_NVMHCI = (1 << 1), /* NVMHCI supported */
|
|
|
|
HOST_CAP2_APST = (1 << 2), /* Automatic partial to slumber */
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* registers for each SATA port */
|
|
|
|
PORT_LST_ADDR = 0x00, /* command list DMA addr */
|
|
|
|
PORT_LST_ADDR_HI = 0x04, /* command list DMA addr hi */
|
|
|
|
PORT_FIS_ADDR = 0x08, /* FIS rx buf addr */
|
|
|
|
PORT_FIS_ADDR_HI = 0x0c, /* FIS rx buf addr hi */
|
|
|
|
PORT_IRQ_STAT = 0x10, /* interrupt status */
|
|
|
|
PORT_IRQ_MASK = 0x14, /* interrupt enable/disable mask */
|
|
|
|
PORT_CMD = 0x18, /* port command */
|
|
|
|
PORT_TFDATA = 0x20, /* taskfile data */
|
|
|
|
PORT_SIG = 0x24, /* device TF signature */
|
|
|
|
PORT_CMD_ISSUE = 0x38, /* command issue */
|
|
|
|
PORT_SCR_STAT = 0x28, /* SATA phy register: SStatus */
|
|
|
|
PORT_SCR_CTL = 0x2c, /* SATA phy register: SControl */
|
|
|
|
PORT_SCR_ERR = 0x30, /* SATA phy register: SError */
|
|
|
|
PORT_SCR_ACT = 0x34, /* SATA phy register: SActive */
|
2007-07-15 22:29:40 -07:00
|
|
|
PORT_SCR_NTF = 0x3c, /* SATA phy register: SNotification */
|
2009-12-09 02:23:04 -07:00
|
|
|
PORT_FBS = 0x40, /* FIS-based Switching */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* PORT_IRQ_{STAT,MASK} bits */
|
|
|
|
PORT_IRQ_COLD_PRES = (1 << 31), /* cold presence detect */
|
|
|
|
PORT_IRQ_TF_ERR = (1 << 30), /* task file error */
|
|
|
|
PORT_IRQ_HBUS_ERR = (1 << 29), /* host bus fatal error */
|
|
|
|
PORT_IRQ_HBUS_DATA_ERR = (1 << 28), /* host bus data error */
|
|
|
|
PORT_IRQ_IF_ERR = (1 << 27), /* interface fatal error */
|
|
|
|
PORT_IRQ_IF_NONFATAL = (1 << 26), /* interface non-fatal error */
|
|
|
|
PORT_IRQ_OVERFLOW = (1 << 24), /* xfer exhausted available S/G */
|
|
|
|
PORT_IRQ_BAD_PMP = (1 << 23), /* incorrect port multiplier */
|
|
|
|
|
|
|
|
PORT_IRQ_PHYRDY = (1 << 22), /* PhyRdy changed */
|
|
|
|
PORT_IRQ_DEV_ILCK = (1 << 7), /* device interlock */
|
|
|
|
PORT_IRQ_CONNECT = (1 << 6), /* port connect change status */
|
|
|
|
PORT_IRQ_SG_DONE = (1 << 5), /* descriptor processed */
|
|
|
|
PORT_IRQ_UNK_FIS = (1 << 4), /* unknown FIS rx'd */
|
|
|
|
PORT_IRQ_SDB_FIS = (1 << 3), /* Set Device Bits FIS rx'd */
|
|
|
|
PORT_IRQ_DMAS_FIS = (1 << 2), /* DMA Setup FIS rx'd */
|
|
|
|
PORT_IRQ_PIOS_FIS = (1 << 1), /* PIO Setup FIS rx'd */
|
|
|
|
PORT_IRQ_D2H_REG_FIS = (1 << 0), /* D2H Register FIS rx'd */
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
PORT_IRQ_FREEZE = PORT_IRQ_HBUS_ERR |
|
|
|
|
PORT_IRQ_IF_ERR |
|
|
|
|
PORT_IRQ_CONNECT |
|
2006-05-31 02:28:18 -07:00
|
|
|
PORT_IRQ_PHYRDY |
|
2007-09-22 21:19:54 -07:00
|
|
|
PORT_IRQ_UNK_FIS |
|
|
|
|
PORT_IRQ_BAD_PMP,
|
2006-05-15 04:58:29 -07:00
|
|
|
PORT_IRQ_ERROR = PORT_IRQ_FREEZE |
|
|
|
|
PORT_IRQ_TF_ERR |
|
|
|
|
PORT_IRQ_HBUS_DATA_ERR,
|
|
|
|
DEF_PORT_IRQ = PORT_IRQ_ERROR | PORT_IRQ_SG_DONE |
|
|
|
|
PORT_IRQ_SDB_FIS | PORT_IRQ_DMAS_FIS |
|
|
|
|
PORT_IRQ_PIOS_FIS | PORT_IRQ_D2H_REG_FIS,
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* PORT_CMD bits */
|
2007-10-24 22:33:26 -07:00
|
|
|
PORT_CMD_ASP = (1 << 27), /* Aggressive Slumber/Partial */
|
|
|
|
PORT_CMD_ALPE = (1 << 26), /* Aggressive Link PM enable */
|
2005-11-11 23:32:19 -07:00
|
|
|
PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */
|
2009-12-09 02:23:04 -07:00
|
|
|
PORT_CMD_FBSCP = (1 << 22), /* FBS Capable Port */
|
2007-09-22 21:19:54 -07:00
|
|
|
PORT_CMD_PMP = (1 << 17), /* PMP attached */
|
2005-04-16 15:20:36 -07:00
|
|
|
PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */
|
|
|
|
PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */
|
|
|
|
PORT_CMD_FIS_RX = (1 << 4), /* Enable FIS receive DMA engine */
|
2006-01-23 05:38:44 -07:00
|
|
|
PORT_CMD_CLO = (1 << 3), /* Command list override */
|
2005-04-16 15:20:36 -07:00
|
|
|
PORT_CMD_POWER_ON = (1 << 2), /* Power up device */
|
|
|
|
PORT_CMD_SPIN_UP = (1 << 1), /* Spin up device */
|
|
|
|
PORT_CMD_START = (1 << 0), /* Enable port DMA engine */
|
|
|
|
|
2006-07-25 23:59:26 -07:00
|
|
|
PORT_CMD_ICC_MASK = (0xf << 28), /* i/f ICC state mask */
|
2005-04-16 15:20:36 -07:00
|
|
|
PORT_CMD_ICC_ACTIVE = (0x1 << 28), /* Put i/f in active state */
|
|
|
|
PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */
|
|
|
|
PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */
|
2005-06-03 21:50:22 -07:00
|
|
|
|
2009-12-09 02:23:04 -07:00
|
|
|
PORT_FBS_DWE_OFFSET = 16, /* FBS device with error offset */
|
|
|
|
PORT_FBS_ADO_OFFSET = 12, /* FBS active dev optimization offset */
|
|
|
|
PORT_FBS_DEV_OFFSET = 8, /* FBS device to issue offset */
|
|
|
|
PORT_FBS_DEV_MASK = (0xf << PORT_FBS_DEV_OFFSET), /* FBS.DEV */
|
|
|
|
PORT_FBS_SDE = (1 << 2), /* FBS single device error */
|
|
|
|
PORT_FBS_DEC = (1 << 1), /* FBS device error clear */
|
|
|
|
PORT_FBS_EN = (1 << 0), /* Enable FBS */
|
|
|
|
|
2007-09-22 21:19:55 -07:00
|
|
|
/* hpriv->flags bits */
|
|
|
|
AHCI_HFLAG_NO_NCQ = (1 << 0),
|
|
|
|
AHCI_HFLAG_IGN_IRQ_IF_ERR = (1 << 1), /* ignore IRQ_IF_ERR */
|
|
|
|
AHCI_HFLAG_IGN_SERR_INTERNAL = (1 << 2), /* ignore SERR_INTERNAL */
|
|
|
|
AHCI_HFLAG_32BIT_ONLY = (1 << 3), /* force 32bit */
|
|
|
|
AHCI_HFLAG_MV_PATA = (1 << 4), /* PATA port */
|
|
|
|
AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */
|
2007-09-22 21:19:55 -07:00
|
|
|
AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */
|
2007-10-24 22:33:26 -07:00
|
|
|
AHCI_HFLAG_NO_HOTPLUG = (1 << 7), /* ignore PxSERR.DIAG.N */
|
2008-02-28 13:43:48 -07:00
|
|
|
AHCI_HFLAG_SECT255 = (1 << 8), /* max 255 sectors */
|
2008-06-09 08:13:04 -07:00
|
|
|
AHCI_HFLAG_YES_NCQ = (1 << 9), /* force NCQ cap on */
|
2009-05-30 04:50:12 -07:00
|
|
|
AHCI_HFLAG_NO_SUSPEND = (1 << 10), /* don't suspend */
|
2009-08-03 22:30:08 -07:00
|
|
|
AHCI_HFLAG_SRST_TOUT_IS_OFFLINE = (1 << 11), /* treat SRST timeout as
|
|
|
|
link offline */
|
2009-11-15 18:56:05 -07:00
|
|
|
AHCI_HFLAG_NO_SNTF = (1 << 12), /* no sntf */
|
2007-09-22 21:19:55 -07:00
|
|
|
|
2006-04-17 05:17:59 -07:00
|
|
|
/* ap->flags bits */
|
2007-04-22 10:41:05 -07:00
|
|
|
|
|
|
|
AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
|
|
|
|
ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
|
2007-10-24 22:33:26 -07:00
|
|
|
ATA_FLAG_ACPI_SATA | ATA_FLAG_AN |
|
|
|
|
ATA_FLAG_IPM,
|
2007-12-05 23:09:43 -07:00
|
|
|
|
|
|
|
ICH_MAP = 0x90, /* ICH MAP register */
|
2008-06-03 10:33:55 -07:00
|
|
|
|
2009-05-11 18:57:41 -07:00
|
|
|
/* em constants */
|
|
|
|
EM_MAX_SLOTS = 8,
|
|
|
|
EM_MAX_RETRY = 5,
|
|
|
|
|
2008-06-03 10:33:55 -07:00
|
|
|
/* em_ctl bits */
|
|
|
|
EM_CTL_RST = (1 << 9), /* Reset */
|
|
|
|
EM_CTL_TM = (1 << 8), /* Transmit Message */
|
|
|
|
EM_CTL_ALHD = (1 << 26), /* Activity LED */
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ahci_cmd_hdr {
|
2007-12-30 02:32:22 -07:00
|
|
|
__le32 opts;
|
|
|
|
__le32 status;
|
|
|
|
__le32 tbl_addr;
|
|
|
|
__le32 tbl_addr_hi;
|
|
|
|
__le32 reserved[4];
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ahci_sg {
|
2007-12-30 02:32:22 -07:00
|
|
|
__le32 addr;
|
|
|
|
__le32 addr_hi;
|
|
|
|
__le32 reserved;
|
|
|
|
__le32 flags_size;
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
2008-06-03 10:33:55 -07:00
|
|
|
struct ahci_em_priv {
|
|
|
|
enum sw_activity blink_policy;
|
|
|
|
struct timer_list timer;
|
|
|
|
unsigned long saved_activity;
|
|
|
|
unsigned long activity;
|
|
|
|
unsigned long led_state;
|
|
|
|
};
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ahci_host_priv {
|
2010-03-03 10:17:34 -07:00
|
|
|
void __iomem * mmio; /* bus-independant mem map */
|
2007-09-22 21:19:55 -07:00
|
|
|
unsigned int flags; /* AHCI_HFLAG_* */
|
2007-03-18 06:15:33 -07:00
|
|
|
u32 cap; /* cap to use */
|
2009-09-20 16:02:31 -07:00
|
|
|
u32 cap2; /* cap2 to use */
|
2007-03-18 06:15:33 -07:00
|
|
|
u32 port_map; /* port map to use */
|
|
|
|
u32 saved_cap; /* saved initial cap */
|
2009-09-20 16:02:31 -07:00
|
|
|
u32 saved_cap2; /* saved initial cap2 */
|
2007-03-18 06:15:33 -07:00
|
|
|
u32 saved_port_map; /* saved initial port_map */
|
2008-06-03 10:33:55 -07:00
|
|
|
u32 em_loc; /* enclosure management location */
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ahci_port_priv {
|
2007-09-22 21:19:54 -07:00
|
|
|
struct ata_link *active_link;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ahci_cmd_hdr *cmd_slot;
|
|
|
|
dma_addr_t cmd_slot_dma;
|
|
|
|
void *cmd_tbl;
|
|
|
|
dma_addr_t cmd_tbl_dma;
|
|
|
|
void *rx_fis;
|
|
|
|
dma_addr_t rx_fis_dma;
|
2007-01-25 03:16:28 -07:00
|
|
|
/* for NCQ spurious interrupt analysis */
|
|
|
|
unsigned int ncq_saw_d2h:1;
|
|
|
|
unsigned int ncq_saw_dmas:1;
|
2007-02-26 21:24:19 -07:00
|
|
|
unsigned int ncq_saw_sdb:1;
|
2007-08-09 14:23:41 -07:00
|
|
|
u32 intr_mask; /* interrupts to enable */
|
2009-12-09 02:23:04 -07:00
|
|
|
bool fbs_supported; /* set iff FBS is supported */
|
|
|
|
bool fbs_enabled; /* set iff FBS is enabled */
|
|
|
|
int fbs_last_dev; /* save FBS.DEV of last FIS */
|
2009-05-11 18:57:41 -07:00
|
|
|
/* enclosure management info per PM slot */
|
|
|
|
struct ahci_em_priv em_priv[EM_MAX_SLOTS];
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
2008-07-31 01:02:40 -07:00
|
|
|
static int ahci_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
|
|
|
|
static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
|
2007-10-19 03:42:56 -07:00
|
|
|
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
|
2006-01-22 21:09:36 -07:00
|
|
|
static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc);
|
2008-04-07 06:47:20 -07:00
|
|
|
static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc);
|
2005-04-16 15:20:36 -07:00
|
|
|
static int ahci_port_start(struct ata_port *ap);
|
|
|
|
static void ahci_port_stop(struct ata_port *ap);
|
2009-12-09 02:23:04 -07:00
|
|
|
static int ahci_pmp_qc_defer(struct ata_queued_cmd *qc);
|
2005-04-16 15:20:36 -07:00
|
|
|
static void ahci_qc_prep(struct ata_queued_cmd *qc);
|
2006-05-15 04:58:29 -07:00
|
|
|
static void ahci_freeze(struct ata_port *ap);
|
|
|
|
static void ahci_thaw(struct ata_port *ap);
|
2009-12-09 02:23:04 -07:00
|
|
|
static void ahci_enable_fbs(struct ata_port *ap);
|
|
|
|
static void ahci_disable_fbs(struct ata_port *ap);
|
2007-09-22 21:19:54 -07:00
|
|
|
static void ahci_pmp_attach(struct ata_port *ap);
|
|
|
|
static void ahci_pmp_detach(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-24 20:22:50 -07:00
|
|
|
static int ahci_softreset(struct ata_link *link, unsigned int *class,
|
|
|
|
unsigned long deadline);
|
2008-06-10 00:52:04 -07:00
|
|
|
static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
|
|
|
|
unsigned long deadline);
|
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-24 20:22:50 -07:00
|
|
|
static int ahci_hardreset(struct ata_link *link, unsigned int *class,
|
|
|
|
unsigned long deadline);
|
|
|
|
static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
|
|
|
|
unsigned long deadline);
|
|
|
|
static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
|
|
|
|
unsigned long deadline);
|
|
|
|
static void ahci_postreset(struct ata_link *link, unsigned int *class);
|
2006-05-15 04:58:29 -07:00
|
|
|
static void ahci_error_handler(struct ata_port *ap);
|
|
|
|
static void ahci_post_internal_cmd(struct ata_queued_cmd *qc);
|
2007-05-26 17:46:51 -07:00
|
|
|
static int ahci_port_resume(struct ata_port *ap);
|
2008-02-28 13:43:48 -07:00
|
|
|
static void ahci_dev_config(struct ata_device *dev);
|
2007-05-28 05:33:01 -07:00
|
|
|
static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
|
|
|
|
u32 opts);
|
2007-03-02 01:31:26 -07:00
|
|
|
#ifdef CONFIG_PM
|
2006-07-25 23:59:26 -07:00
|
|
|
static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg);
|
|
|
|
static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
|
|
|
|
static int ahci_pci_device_resume(struct pci_dev *pdev);
|
2007-03-02 01:31:26 -07:00
|
|
|
#endif
|
2008-06-03 10:33:55 -07:00
|
|
|
static ssize_t ahci_activity_show(struct ata_device *dev, char *buf);
|
|
|
|
static ssize_t ahci_activity_store(struct ata_device *dev,
|
|
|
|
enum sw_activity val);
|
|
|
|
static void ahci_init_sw_activity(struct ata_link *link);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-07-17 11:13:47 -07:00
|
|
|
static ssize_t ahci_show_host_caps(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2009-09-20 16:02:31 -07:00
|
|
|
static ssize_t ahci_show_host_cap2(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2009-07-17 11:13:47 -07:00
|
|
|
static ssize_t ahci_show_host_version(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
|
|
|
static ssize_t ahci_show_port_cmd(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
|
|
|
|
2010-01-19 22:03:39 -07:00
|
|
|
static DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL);
|
|
|
|
static DEVICE_ATTR(ahci_host_cap2, S_IRUGO, ahci_show_host_cap2, NULL);
|
|
|
|
static DEVICE_ATTR(ahci_host_version, S_IRUGO, ahci_show_host_version, NULL);
|
|
|
|
static DEVICE_ATTR(ahci_port_cmd, S_IRUGO, ahci_show_port_cmd, NULL);
|
2009-07-17 11:13:47 -07:00
|
|
|
|
2008-02-21 16:13:36 -07:00
|
|
|
static struct device_attribute *ahci_shost_attrs[] = {
|
|
|
|
&dev_attr_link_power_management_policy,
|
2008-06-03 10:33:55 -07:00
|
|
|
&dev_attr_em_message_type,
|
|
|
|
&dev_attr_em_message,
|
2009-07-17 11:13:47 -07:00
|
|
|
&dev_attr_ahci_host_caps,
|
2009-09-20 16:02:31 -07:00
|
|
|
&dev_attr_ahci_host_cap2,
|
2009-07-17 11:13:47 -07:00
|
|
|
&dev_attr_ahci_host_version,
|
|
|
|
&dev_attr_ahci_port_cmd,
|
2008-06-03 10:33:55 -07:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct device_attribute *ahci_sdev_attrs[] = {
|
|
|
|
&dev_attr_sw_activity,
|
2008-09-21 02:54:08 -07:00
|
|
|
&dev_attr_unload_heads,
|
2007-10-24 22:33:26 -07:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2005-11-06 22:59:37 -07:00
|
|
|
static struct scsi_host_template ahci_sht = {
|
2008-03-24 20:22:49 -07:00
|
|
|
ATA_NCQ_SHT(DRV_NAME),
|
2006-05-15 05:03:55 -07:00
|
|
|
.can_queue = AHCI_MAX_CMDS - 1,
|
2005-04-16 15:20:36 -07:00
|
|
|
.sg_tablesize = AHCI_MAX_SG,
|
|
|
|
.dma_boundary = AHCI_DMA_BOUNDARY,
|
2007-10-24 22:33:26 -07:00
|
|
|
.shost_attrs = ahci_shost_attrs,
|
2008-06-03 10:33:55 -07:00
|
|
|
.sdev_attrs = ahci_sdev_attrs,
|
2005-04-16 15:20:36 -07: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-24 20:22:49 -07:00
|
|
|
static struct ata_port_operations ahci_ops = {
|
|
|
|
.inherits = &sata_pmp_port_ops,
|
|
|
|
|
2009-12-09 02:23:04 -07:00
|
|
|
.qc_defer = ahci_pmp_qc_defer,
|
2005-04-16 15:20:36 -07:00
|
|
|
.qc_prep = ahci_qc_prep,
|
|
|
|
.qc_issue = ahci_qc_issue,
|
2008-04-07 06:47:20 -07:00
|
|
|
.qc_fill_rtf = ahci_qc_fill_rtf,
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
.freeze = ahci_freeze,
|
|
|
|
.thaw = ahci_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-24 20:22:50 -07:00
|
|
|
.softreset = ahci_softreset,
|
|
|
|
.hardreset = ahci_hardreset,
|
|
|
|
.postreset = ahci_postreset,
|
2008-04-07 06:47:22 -07:00
|
|
|
.pmp_softreset = ahci_softreset,
|
2006-05-15 04:58:29 -07:00
|
|
|
.error_handler = ahci_error_handler,
|
|
|
|
.post_internal_cmd = ahci_post_internal_cmd,
|
2008-03-24 20:22:48 -07:00
|
|
|
.dev_config = ahci_dev_config,
|
|
|
|
|
2006-11-01 02:00:24 -07:00
|
|
|
.scr_read = ahci_scr_read,
|
|
|
|
.scr_write = ahci_scr_write,
|
2007-09-22 21:19:54 -07:00
|
|
|
.pmp_attach = ahci_pmp_attach,
|
|
|
|
.pmp_detach = ahci_pmp_detach,
|
|
|
|
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 20:22:49 -07:00
|
|
|
.enable_pm = ahci_enable_alpm,
|
|
|
|
.disable_pm = ahci_disable_alpm,
|
2008-06-03 10:33:55 -07:00
|
|
|
.em_show = ahci_led_show,
|
|
|
|
.em_store = ahci_led_store,
|
|
|
|
.sw_activity_show = ahci_activity_show,
|
|
|
|
.sw_activity_store = ahci_activity_store,
|
2007-03-02 01:31:26 -07:00
|
|
|
#ifdef CONFIG_PM
|
2006-11-01 02:00:24 -07:00
|
|
|
.port_suspend = ahci_port_suspend,
|
|
|
|
.port_resume = ahci_port_resume,
|
2007-03-02 01:31:26 -07:00
|
|
|
#endif
|
2006-11-01 02:00:24 -07:00
|
|
|
.port_start = ahci_port_start,
|
|
|
|
.port_stop = ahci_port_stop,
|
|
|
|
};
|
|
|
|
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 20:22:49 -07:00
|
|
|
static struct ata_port_operations ahci_vt8251_ops = {
|
|
|
|
.inherits = &ahci_ops,
|
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-24 20:22:50 -07:00
|
|
|
.hardreset = ahci_vt8251_hardreset,
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 20:22:49 -07:00
|
|
|
};
|
2007-10-24 22:59:16 -07: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-24 20:22:49 -07:00
|
|
|
static struct ata_port_operations ahci_p5wdh_ops = {
|
|
|
|
.inherits = &ahci_ops,
|
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-24 20:22:50 -07:00
|
|
|
.hardreset = ahci_p5wdh_hardreset,
|
2007-10-24 22:59:16 -07:00
|
|
|
};
|
|
|
|
|
2008-06-10 00:52:04 -07:00
|
|
|
static struct ata_port_operations ahci_sb600_ops = {
|
|
|
|
.inherits = &ahci_ops,
|
|
|
|
.softreset = ahci_sb600_softreset,
|
|
|
|
.pmp_softreset = ahci_sb600_softreset,
|
|
|
|
};
|
|
|
|
|
2007-09-22 21:19:55 -07:00
|
|
|
#define AHCI_HFLAGS(flags) .private_data = (void *)(flags)
|
|
|
|
|
2005-11-28 02:06:23 -07:00
|
|
|
static const struct ata_port_info ahci_port_info[] = {
|
2009-04-07 23:00:13 -07:00
|
|
|
[board_ahci] =
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2007-04-22 10:41:05 -07:00
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 13:38:24 -07:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-07-07 22:13:16 -07:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2005-04-16 15:20:36 -07:00
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2009-04-07 23:00:13 -07:00
|
|
|
[board_ahci_vt8251] =
|
2006-04-17 05:17:59 -07:00
|
|
|
{
|
2007-09-22 21:19:55 -07:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_PMP),
|
2007-09-22 21:19:55 -07:00
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 13:38:24 -07:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-07-07 22:13:16 -07:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2006-11-01 02:00:24 -07:00
|
|
|
.port_ops = &ahci_vt8251_ops,
|
2006-04-17 05:17:59 -07:00
|
|
|
},
|
2009-04-07 23:00:13 -07:00
|
|
|
[board_ahci_ign_iferr] =
|
2006-11-28 19:33:14 -07:00
|
|
|
{
|
2007-09-22 21:19:55 -07:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_IGN_IRQ_IF_ERR),
|
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 13:38:24 -07:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-07-07 22:13:16 -07:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2006-11-28 19:33:14 -07:00
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2009-04-07 23:00:13 -07:00
|
|
|
[board_ahci_sb600] =
|
2007-03-27 03:33:05 -07:00
|
|
|
{
|
2007-09-22 21:19:55 -07:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL |
|
2009-10-03 02:27:29 -07:00
|
|
|
AHCI_HFLAG_NO_MSI | AHCI_HFLAG_SECT255 |
|
|
|
|
AHCI_HFLAG_32BIT_ONLY),
|
2007-09-22 21:19:55 -07:00
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 13:38:24 -07:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-07-07 22:13:16 -07:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2008-06-10 00:52:04 -07:00
|
|
|
.port_ops = &ahci_sb600_ops,
|
2007-03-27 03:33:05 -07:00
|
|
|
},
|
2009-04-07 23:00:13 -07:00
|
|
|
[board_ahci_mv] =
|
2007-07-07 23:29:42 -07:00
|
|
|
{
|
2007-09-22 21:19:55 -07:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_MSI |
|
2008-08-29 07:03:59 -07:00
|
|
|
AHCI_HFLAG_MV_PATA | AHCI_HFLAG_NO_PMP),
|
2007-07-07 23:29:42 -07:00
|
|
|
.flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
|
2007-09-22 21:19:55 -07:00
|
|
|
ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA,
|
2009-03-14 13:38:24 -07:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-07-07 23:29:42 -07:00
|
|
|
.udma_mask = ATA_UDMA6,
|
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2009-04-07 23:00:13 -07:00
|
|
|
[board_ahci_sb700] = /* for SB700 and SB800 */
|
2008-02-22 06:00:31 -07:00
|
|
|
{
|
2008-06-10 00:52:04 -07:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL),
|
2008-02-22 06:00:31 -07:00
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 13:38:24 -07:00
|
|
|
.pio_mask = ATA_PIO4,
|
2008-02-22 06:00:31 -07:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2008-06-10 00:52:04 -07:00
|
|
|
.port_ops = &ahci_sb600_ops,
|
2008-02-22 06:00:31 -07:00
|
|
|
},
|
2009-04-07 23:00:13 -07:00
|
|
|
[board_ahci_mcp65] =
|
2008-06-09 08:13:04 -07:00
|
|
|
{
|
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_YES_NCQ),
|
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 13:38:24 -07:00
|
|
|
.pio_mask = ATA_PIO4,
|
2008-06-09 08:13:04 -07:00
|
|
|
.udma_mask = ATA_UDMA6,
|
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2009-04-07 23:00:13 -07:00
|
|
|
[board_ahci_nopmp] =
|
2008-06-18 17:56:58 -07:00
|
|
|
{
|
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_NO_PMP),
|
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 13:38:24 -07:00
|
|
|
.pio_mask = ATA_PIO4,
|
2008-06-18 17:56:58 -07:00
|
|
|
.udma_mask = ATA_UDMA6,
|
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2009-11-15 18:56:05 -07:00
|
|
|
[board_ahci_yesncq] =
|
2009-04-08 14:25:31 -07:00
|
|
|
{
|
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_YES_NCQ),
|
|
|
|
.flags = AHCI_FLAG_COMMON,
|
|
|
|
.pio_mask = ATA_PIO4,
|
|
|
|
.udma_mask = ATA_UDMA6,
|
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2009-11-15 18:56:05 -07:00
|
|
|
[board_ahci_nosntf] =
|
|
|
|
{
|
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_NO_SNTF),
|
|
|
|
.flags = AHCI_FLAG_COMMON,
|
|
|
|
.pio_mask = ATA_PIO4,
|
|
|
|
.udma_mask = ATA_UDMA6,
|
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
2005-11-10 09:04:11 -07:00
|
|
|
static const struct pci_device_id ahci_pci_tbl[] = {
|
2006-06-22 20:05:36 -07:00
|
|
|
/* Intel */
|
2006-09-27 19:20:11 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x2652), board_ahci }, /* ICH6 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2653), board_ahci }, /* ICH6M */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x27c1), board_ahci }, /* ICH7 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x27c5), board_ahci }, /* ICH7M */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x27c3), board_ahci }, /* ICH7R */
|
2007-01-22 23:13:39 -07:00
|
|
|
{ PCI_VDEVICE(AL, 0x5288), board_ahci_ign_iferr }, /* ULi M5288 */
|
2006-09-27 19:20:11 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x2681), board_ahci }, /* ESB2 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2682), board_ahci }, /* ESB2 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2683), board_ahci }, /* ESB2 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x27c6), board_ahci }, /* ICH7-M DH */
|
2007-09-02 20:44:57 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x2821), board_ahci }, /* ICH8 */
|
2009-11-15 18:56:05 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x2822), board_ahci_nosntf }, /* ICH8 */
|
2007-09-02 20:44:57 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x2824), board_ahci }, /* ICH8 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2829), board_ahci }, /* ICH8M */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x282a), board_ahci }, /* ICH8M */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2922), board_ahci }, /* ICH9 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2923), board_ahci }, /* ICH9 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2924), board_ahci }, /* ICH9 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2925), board_ahci }, /* ICH9 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2927), board_ahci }, /* ICH9 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2929), board_ahci }, /* ICH9M */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x292a), board_ahci }, /* ICH9M */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x292b), board_ahci }, /* ICH9M */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x292c), board_ahci }, /* ICH9M */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x292f), board_ahci }, /* ICH9M */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x294d), board_ahci }, /* ICH9 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x294e), board_ahci }, /* ICH9M */
|
2007-09-20 14:35:00 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x502a), board_ahci }, /* Tolapai */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x502b), board_ahci }, /* Tolapai */
|
2008-01-28 18:34:14 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3a05), board_ahci }, /* ICH10 */
|
2009-06-26 08:44:11 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3a22), board_ahci }, /* ICH10 */
|
2008-01-28 18:34:14 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3a25), board_ahci }, /* ICH10 */
|
2009-07-22 13:15:56 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b22), board_ahci }, /* PCH AHCI */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b23), board_ahci }, /* PCH AHCI */
|
2008-08-11 17:03:09 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b24), board_ahci }, /* PCH RAID */
|
2008-08-27 16:47:22 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b25), board_ahci }, /* PCH RAID */
|
2009-07-22 13:15:56 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b29), board_ahci }, /* PCH AHCI */
|
2008-08-11 17:03:09 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */
|
2008-08-27 16:47:22 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */
|
2009-07-22 13:15:56 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */
|
2010-01-12 18:00:18 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT AHCI */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x1c05), board_ahci }, /* CPT RAID */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x1c06), board_ahci }, /* CPT RAID */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x1c07), board_ahci }, /* CPT RAID */
|
2006-06-22 20:05:36 -07:00
|
|
|
|
2007-02-26 04:24:03 -07:00
|
|
|
/* JMicron 360/1/3/5/6, match class to avoid IDE function */
|
|
|
|
{ PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci_ign_iferr },
|
2006-06-22 20:05:36 -07:00
|
|
|
|
|
|
|
/* ATI */
|
2007-04-11 03:23:14 -07:00
|
|
|
{ PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */
|
2008-02-22 06:00:31 -07:00
|
|
|
{ PCI_VDEVICE(ATI, 0x4390), board_ahci_sb700 }, /* ATI SB700/800 */
|
|
|
|
{ PCI_VDEVICE(ATI, 0x4391), board_ahci_sb700 }, /* ATI SB700/800 */
|
|
|
|
{ PCI_VDEVICE(ATI, 0x4392), board_ahci_sb700 }, /* ATI SB700/800 */
|
|
|
|
{ PCI_VDEVICE(ATI, 0x4393), board_ahci_sb700 }, /* ATI SB700/800 */
|
|
|
|
{ PCI_VDEVICE(ATI, 0x4394), board_ahci_sb700 }, /* ATI SB700/800 */
|
|
|
|
{ PCI_VDEVICE(ATI, 0x4395), board_ahci_sb700 }, /* ATI SB700/800 */
|
2006-06-22 20:05:36 -07:00
|
|
|
|
2009-07-28 20:34:49 -07:00
|
|
|
/* AMD */
|
2009-10-12 20:14:00 -07:00
|
|
|
{ PCI_VDEVICE(AMD, 0x7800), board_ahci }, /* AMD Hudson-2 */
|
2009-07-28 20:34:49 -07:00
|
|
|
/* AMD is using RAID class only for ahci controllers */
|
|
|
|
{ PCI_VENDOR_ID_AMD, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
PCI_CLASS_STORAGE_RAID << 8, 0xffffff, board_ahci },
|
|
|
|
|
2006-06-22 20:05:36 -07:00
|
|
|
/* VIA */
|
2006-09-27 19:20:11 -07:00
|
|
|
{ PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */
|
2007-04-11 01:27:14 -07:00
|
|
|
{ PCI_VDEVICE(VIA, 0x6287), board_ahci_vt8251 }, /* VIA VT8251 */
|
2006-06-22 20:05:36 -07:00
|
|
|
|
|
|
|
/* NVIDIA */
|
2008-06-09 08:13:04 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x044c), board_ahci_mcp65 }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x044d), board_ahci_mcp65 }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x044e), board_ahci_mcp65 }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x044f), board_ahci_mcp65 }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x045c), board_ahci_mcp65 }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x045d), board_ahci_mcp65 }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x045e), board_ahci_mcp65 }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x045f), board_ahci_mcp65 }, /* MCP65 */
|
2009-04-08 14:25:31 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0550), board_ahci_yesncq }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0551), board_ahci_yesncq }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0552), board_ahci_yesncq }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0553), board_ahci_yesncq }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0554), board_ahci_yesncq }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0555), board_ahci_yesncq }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0556), board_ahci_yesncq }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0557), board_ahci_yesncq }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0558), board_ahci_yesncq }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0559), board_ahci_yesncq }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x055a), board_ahci_yesncq }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x055b), board_ahci_yesncq }, /* MCP67 */
|
2009-10-15 01:34:56 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0580), board_ahci_yesncq }, /* Linux ID */
|
2010-03-10 19:37:16 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0581), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0582), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0583), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0584), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0585), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0586), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0587), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0588), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0589), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x058a), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x058b), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x058c), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x058d), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x058e), board_ahci_yesncq }, /* Linux ID */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x058f), board_ahci_yesncq }, /* Linux ID */
|
2009-04-08 14:25:31 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f0), board_ahci_yesncq }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f1), board_ahci_yesncq }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f2), board_ahci_yesncq }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f3), board_ahci_yesncq }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f4), board_ahci_yesncq }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f5), board_ahci_yesncq }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f6), board_ahci_yesncq }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f7), board_ahci_yesncq }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f8), board_ahci_yesncq }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f9), board_ahci_yesncq }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07fa), board_ahci_yesncq }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07fb), board_ahci_yesncq }, /* MCP73 */
|
2007-06-07 03:05:12 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad0), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad1), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad2), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad3), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad4), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad5), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad6), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad7), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad8), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad9), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ada), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0adb), board_ahci }, /* MCP77 */
|
2007-12-03 07:20:37 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ab4), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ab5), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ab6), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ab7), board_ahci }, /* MCP79 */
|
2007-09-23 19:16:25 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ab8), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ab9), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0aba), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0abb), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0abc), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */
|
2009-02-27 01:58:41 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0d84), board_ahci }, /* MCP89 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0d85), board_ahci }, /* MCP89 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0d86), board_ahci }, /* MCP89 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0d87), board_ahci }, /* MCP89 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0d88), board_ahci }, /* MCP89 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0d89), board_ahci }, /* MCP89 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0d8a), board_ahci }, /* MCP89 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0d8b), board_ahci }, /* MCP89 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0d8c), board_ahci }, /* MCP89 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0d8d), board_ahci }, /* MCP89 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0d8e), board_ahci }, /* MCP89 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0d8f), board_ahci }, /* MCP89 */
|
2006-06-22 20:05:36 -07:00
|
|
|
|
2006-07-29 01:10:14 -07:00
|
|
|
/* SiS */
|
2008-07-31 20:51:43 -07:00
|
|
|
{ PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */
|
|
|
|
{ PCI_VDEVICE(SI, 0x1185), board_ahci }, /* SiS 968 */
|
|
|
|
{ PCI_VDEVICE(SI, 0x0186), board_ahci }, /* SiS 968 */
|
2006-07-29 01:10:14 -07:00
|
|
|
|
2007-07-07 23:29:42 -07:00
|
|
|
/* Marvell */
|
|
|
|
{ PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */
|
2008-03-13 15:22:24 -07:00
|
|
|
{ PCI_VDEVICE(MARVELL, 0x6121), board_ahci_mv }, /* 6121 */
|
2007-07-07 23:29:42 -07:00
|
|
|
|
2008-10-22 20:08:16 -07:00
|
|
|
/* Promise */
|
|
|
|
{ PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */
|
|
|
|
|
2006-11-01 03:10:42 -07:00
|
|
|
/* Generic, PCI class code for AHCI */
|
|
|
|
{ PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
|
2007-01-09 03:32:51 -07:00
|
|
|
PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci },
|
2006-11-01 03:10:42 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
{ } /* terminate list */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static struct pci_driver ahci_pci_driver = {
|
|
|
|
.name = DRV_NAME,
|
|
|
|
.id_table = ahci_pci_tbl,
|
|
|
|
.probe = ahci_init_one,
|
2007-01-20 00:00:28 -07:00
|
|
|
.remove = ata_pci_remove_one,
|
2007-03-02 01:31:26 -07:00
|
|
|
#ifdef CONFIG_PM
|
2006-07-25 23:59:26 -07:00
|
|
|
.suspend = ahci_pci_device_suspend,
|
|
|
|
.resume = ahci_pci_device_resume,
|
2007-03-02 01:31:26 -07:00
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
2008-06-03 10:33:55 -07:00
|
|
|
static int ahci_em_messages = 1;
|
|
|
|
module_param(ahci_em_messages, int, 0444);
|
|
|
|
/* add other LED protocol types when they become supported */
|
|
|
|
MODULE_PARM_DESC(ahci_em_messages,
|
|
|
|
"Set AHCI Enclosure Management Message type (0 = disabled, 1 = LED");
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-09-03 06:48:34 -07:00
|
|
|
#if defined(CONFIG_PATA_MARVELL) || defined(CONFIG_PATA_MARVELL_MODULE)
|
|
|
|
static int marvell_enable;
|
|
|
|
#else
|
|
|
|
static int marvell_enable = 1;
|
|
|
|
#endif
|
|
|
|
module_param(marvell_enable, int, 0644);
|
|
|
|
MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)");
|
|
|
|
|
|
|
|
|
2006-11-01 20:17:23 -07:00
|
|
|
static inline int ahci_nr_ports(u32 cap)
|
|
|
|
{
|
|
|
|
return (cap & 0x1f) + 1;
|
|
|
|
}
|
|
|
|
|
2007-05-28 05:33:01 -07:00
|
|
|
static inline void __iomem *__ahci_port_base(struct ata_host *host,
|
|
|
|
unsigned int port_no)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2010-03-03 10:17:34 -07:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
|
|
|
void __iomem *mmio = hpriv->mmio;
|
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 07:44:08 -07:00
|
|
|
|
2007-05-28 05:33:01 -07:00
|
|
|
return mmio + 0x100 + (port_no * 0x80);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __iomem *ahci_port_base(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
return __ahci_port_base(ap->host, ap->port_no);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2008-01-05 07:11:57 -07:00
|
|
|
static void ahci_enable_ahci(void __iomem *mmio)
|
|
|
|
{
|
2008-04-23 04:52:58 -07:00
|
|
|
int i;
|
2008-01-05 07:11:57 -07:00
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
/* turn on AHCI_EN */
|
|
|
|
tmp = readl(mmio + HOST_CTL);
|
2008-04-23 04:52:58 -07:00
|
|
|
if (tmp & HOST_AHCI_EN)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Some controllers need AHCI_EN to be written multiple times.
|
|
|
|
* Try a few times before giving up.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < 5; i++) {
|
2008-01-05 07:11:57 -07:00
|
|
|
tmp |= HOST_AHCI_EN;
|
|
|
|
writel(tmp, mmio + HOST_CTL);
|
|
|
|
tmp = readl(mmio + HOST_CTL); /* flush && sanity check */
|
2008-04-23 04:52:58 -07:00
|
|
|
if (tmp & HOST_AHCI_EN)
|
|
|
|
return;
|
|
|
|
msleep(10);
|
2008-01-05 07:11:57 -07:00
|
|
|
}
|
2008-04-23 04:52:58 -07:00
|
|
|
|
|
|
|
WARN_ON(1);
|
2008-01-05 07:11:57 -07:00
|
|
|
}
|
|
|
|
|
2009-07-17 11:13:47 -07:00
|
|
|
static ssize_t ahci_show_host_caps(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(dev);
|
|
|
|
struct ata_port *ap = ata_shost_to_port(shost);
|
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
|
|
|
|
return sprintf(buf, "%x\n", hpriv->cap);
|
|
|
|
}
|
|
|
|
|
2009-09-20 16:02:31 -07:00
|
|
|
static ssize_t ahci_show_host_cap2(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(dev);
|
|
|
|
struct ata_port *ap = ata_shost_to_port(shost);
|
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
|
|
|
|
return sprintf(buf, "%x\n", hpriv->cap2);
|
|
|
|
}
|
|
|
|
|
2009-07-17 11:13:47 -07:00
|
|
|
static ssize_t ahci_show_host_version(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(dev);
|
|
|
|
struct ata_port *ap = ata_shost_to_port(shost);
|
2010-03-03 10:17:34 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
void __iomem *mmio = hpriv->mmio;
|
2009-07-17 11:13:47 -07:00
|
|
|
|
|
|
|
return sprintf(buf, "%x\n", readl(mmio + HOST_VERSION));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t ahci_show_port_cmd(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(dev);
|
|
|
|
struct ata_port *ap = ata_shost_to_port(shost);
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
|
|
|
|
return sprintf(buf, "%x\n", readl(port_mmio + PORT_CMD));
|
|
|
|
}
|
|
|
|
|
2007-03-18 06:15:33 -07:00
|
|
|
/**
|
|
|
|
* ahci_save_initial_config - Save and fixup initial config values
|
2010-03-03 10:17:37 -07:00
|
|
|
* @dev: target AHCI device
|
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 07:44:08 -07:00
|
|
|
* @hpriv: host private area to store config values
|
2010-03-03 10:17:36 -07:00
|
|
|
* @force_port_map: force port map to a specified value
|
|
|
|
* @mask_port_map: mask out particular bits from port map
|
2007-03-18 06:15:33 -07:00
|
|
|
*
|
|
|
|
* Some registers containing configuration info might be setup by
|
|
|
|
* BIOS and might be cleared on reset. This function saves the
|
|
|
|
* initial values of those registers into @hpriv such that they
|
|
|
|
* can be restored after controller reset.
|
|
|
|
*
|
|
|
|
* If inconsistent, config values are fixed up by this function.
|
|
|
|
*
|
|
|
|
* LOCKING:
|
|
|
|
* None.
|
|
|
|
*/
|
2010-03-03 10:17:37 -07:00
|
|
|
static void ahci_save_initial_config(struct device *dev,
|
2010-03-03 10:17:36 -07:00
|
|
|
struct ahci_host_priv *hpriv,
|
|
|
|
unsigned int force_port_map,
|
|
|
|
unsigned int mask_port_map)
|
2007-03-18 06:15:33 -07:00
|
|
|
{
|
2010-03-03 10:17:34 -07:00
|
|
|
void __iomem *mmio = hpriv->mmio;
|
2009-09-20 16:02:31 -07:00
|
|
|
u32 cap, cap2, vers, port_map;
|
2007-03-18 06:26:53 -07:00
|
|
|
int i;
|
2007-03-18 06:15:33 -07:00
|
|
|
|
2008-01-05 07:11:57 -07:00
|
|
|
/* make sure AHCI mode is enabled before accessing CAP */
|
|
|
|
ahci_enable_ahci(mmio);
|
|
|
|
|
2007-03-18 06:15:33 -07:00
|
|
|
/* Values prefixed with saved_ are written back to host after
|
|
|
|
* reset. Values without are used for driver operation.
|
|
|
|
*/
|
|
|
|
hpriv->saved_cap = cap = readl(mmio + HOST_CAP);
|
|
|
|
hpriv->saved_port_map = port_map = readl(mmio + HOST_PORTS_IMPL);
|
|
|
|
|
2009-09-20 16:02:31 -07:00
|
|
|
/* CAP2 register is only defined for AHCI 1.2 and later */
|
|
|
|
vers = readl(mmio + HOST_VERSION);
|
|
|
|
if ((vers >> 16) > 1 ||
|
|
|
|
((vers >> 16) == 1 && (vers & 0xFFFF) >= 0x200))
|
|
|
|
hpriv->saved_cap2 = cap2 = readl(mmio + HOST_CAP2);
|
|
|
|
else
|
|
|
|
hpriv->saved_cap2 = cap2 = 0;
|
|
|
|
|
2007-07-15 22:29:40 -07:00
|
|
|
/* some chips have errata preventing 64bit use */
|
2007-09-22 21:19:55 -07:00
|
|
|
if ((cap & HOST_CAP_64) && (hpriv->flags & AHCI_HFLAG_32BIT_ONLY)) {
|
2010-03-03 10:17:37 -07:00
|
|
|
dev_printk(KERN_INFO, dev,
|
2007-05-18 07:23:19 -07:00
|
|
|
"controller can't do 64bit DMA, forcing 32bit\n");
|
|
|
|
cap &= ~HOST_CAP_64;
|
|
|
|
}
|
|
|
|
|
2007-09-22 21:19:55 -07:00
|
|
|
if ((cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_NO_NCQ)) {
|
2010-03-03 10:17:37 -07:00
|
|
|
dev_printk(KERN_INFO, dev,
|
2007-07-15 22:29:40 -07:00
|
|
|
"controller can't do NCQ, turning off CAP_NCQ\n");
|
|
|
|
cap &= ~HOST_CAP_NCQ;
|
|
|
|
}
|
|
|
|
|
2008-06-09 08:13:04 -07:00
|
|
|
if (!(cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_YES_NCQ)) {
|
2010-03-03 10:17:37 -07:00
|
|
|
dev_printk(KERN_INFO, dev,
|
2008-06-09 08:13:04 -07:00
|
|
|
"controller can do NCQ, turning on CAP_NCQ\n");
|
|
|
|
cap |= HOST_CAP_NCQ;
|
|
|
|
}
|
|
|
|
|
2008-03-09 13:42:40 -07:00
|
|
|
if ((cap & HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) {
|
2010-03-03 10:17:37 -07:00
|
|
|
dev_printk(KERN_INFO, dev,
|
2007-09-22 21:19:55 -07:00
|
|
|
"controller can't do PMP, turning off CAP_PMP\n");
|
|
|
|
cap &= ~HOST_CAP_PMP;
|
|
|
|
}
|
|
|
|
|
2009-11-15 18:56:05 -07:00
|
|
|
if ((cap & HOST_CAP_SNTF) && (hpriv->flags & AHCI_HFLAG_NO_SNTF)) {
|
2010-03-03 10:17:37 -07:00
|
|
|
dev_printk(KERN_INFO, dev,
|
2009-11-15 18:56:05 -07:00
|
|
|
"controller can't do SNTF, turning off CAP_SNTF\n");
|
|
|
|
cap &= ~HOST_CAP_SNTF;
|
|
|
|
}
|
|
|
|
|
2010-03-03 10:17:36 -07:00
|
|
|
if (force_port_map && port_map != force_port_map) {
|
2010-03-03 10:17:37 -07:00
|
|
|
dev_printk(KERN_INFO, dev, "forcing port_map 0x%x -> 0x%x\n",
|
2010-03-03 10:17:36 -07:00
|
|
|
port_map, force_port_map);
|
|
|
|
port_map = force_port_map;
|
2008-06-16 20:46:30 -07:00
|
|
|
}
|
|
|
|
|
2010-03-03 10:17:36 -07:00
|
|
|
if (mask_port_map) {
|
2010-03-03 10:17:37 -07:00
|
|
|
dev_printk(KERN_ERR, dev, "masking port_map 0x%x -> 0x%x\n",
|
2008-03-13 15:22:24 -07:00
|
|
|
port_map,
|
2010-03-03 10:17:36 -07:00
|
|
|
port_map & mask_port_map);
|
|
|
|
port_map &= mask_port_map;
|
2007-07-07 23:29:42 -07:00
|
|
|
}
|
|
|
|
|
2007-03-18 06:26:53 -07:00
|
|
|
/* cross check port_map and cap.n_ports */
|
2007-09-02 20:44:57 -07:00
|
|
|
if (port_map) {
|
2008-02-05 23:13:51 -07:00
|
|
|
int map_ports = 0;
|
2007-03-18 06:26:53 -07:00
|
|
|
|
2008-02-05 23:13:51 -07:00
|
|
|
for (i = 0; i < AHCI_MAX_PORTS; i++)
|
|
|
|
if (port_map & (1 << i))
|
|
|
|
map_ports++;
|
2007-03-18 06:26:53 -07:00
|
|
|
|
2008-02-05 23:13:51 -07:00
|
|
|
/* If PI has more ports than n_ports, whine, clear
|
|
|
|
* port_map and let it be generated from n_ports.
|
2007-03-18 06:26:53 -07:00
|
|
|
*/
|
2008-02-05 23:13:51 -07:00
|
|
|
if (map_ports > ahci_nr_ports(cap)) {
|
2010-03-03 10:17:37 -07:00
|
|
|
dev_printk(KERN_WARNING, dev,
|
2008-02-05 23:13:51 -07:00
|
|
|
"implemented port map (0x%x) contains more "
|
|
|
|
"ports than nr_ports (%u), using nr_ports\n",
|
|
|
|
port_map, ahci_nr_ports(cap));
|
2007-09-02 20:44:57 -07:00
|
|
|
port_map = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fabricate port_map from cap.nr_ports */
|
|
|
|
if (!port_map) {
|
2007-03-18 06:26:53 -07:00
|
|
|
port_map = (1 << ahci_nr_ports(cap)) - 1;
|
2010-03-03 10:17:37 -07:00
|
|
|
dev_printk(KERN_WARNING, dev,
|
2007-09-02 20:44:57 -07:00
|
|
|
"forcing PORTS_IMPL to 0x%x\n", port_map);
|
|
|
|
|
|
|
|
/* write the fixed up value to the PI register */
|
|
|
|
hpriv->saved_port_map = port_map;
|
2007-03-18 06:26:53 -07:00
|
|
|
}
|
|
|
|
|
2007-03-18 06:15:33 -07:00
|
|
|
/* record values to use during operation */
|
|
|
|
hpriv->cap = cap;
|
2009-09-20 16:02:31 -07:00
|
|
|
hpriv->cap2 = cap2;
|
2007-03-18 06:15:33 -07:00
|
|
|
hpriv->port_map = port_map;
|
|
|
|
}
|
|
|
|
|
2010-03-03 10:17:36 -07:00
|
|
|
static void ahci_pci_save_initial_config(struct pci_dev *pdev,
|
|
|
|
struct ahci_host_priv *hpriv)
|
|
|
|
{
|
|
|
|
unsigned int force_port_map = 0;
|
|
|
|
unsigned int mask_port_map = 0;
|
|
|
|
|
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_JMICRON && pdev->device == 0x2361) {
|
|
|
|
dev_info(&pdev->dev, "JMB361 has only one port\n");
|
|
|
|
force_port_map = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Temporary Marvell 6145 hack: PATA port presence
|
|
|
|
* is asserted through the standard AHCI port
|
|
|
|
* presence register, as bit 4 (counting from 0)
|
|
|
|
*/
|
|
|
|
if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
|
|
|
|
if (pdev->device == 0x6121)
|
|
|
|
mask_port_map = 0x3;
|
|
|
|
else
|
|
|
|
mask_port_map = 0xf;
|
|
|
|
dev_info(&pdev->dev,
|
|
|
|
"Disabling your PATA port. Use the boot option 'ahci.marvell_enable=0' to avoid this.\n");
|
|
|
|
}
|
|
|
|
|
2010-03-03 10:17:37 -07:00
|
|
|
ahci_save_initial_config(&pdev->dev, hpriv, force_port_map,
|
|
|
|
mask_port_map);
|
2010-03-03 10:17:36 -07:00
|
|
|
}
|
|
|
|
|
2007-03-18 06:15:33 -07:00
|
|
|
/**
|
|
|
|
* ahci_restore_initial_config - Restore initial config
|
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 07:44:08 -07:00
|
|
|
* @host: target ATA host
|
2007-03-18 06:15:33 -07:00
|
|
|
*
|
|
|
|
* Restore initial config stored by ahci_save_initial_config().
|
|
|
|
*
|
|
|
|
* LOCKING:
|
|
|
|
* None.
|
|
|
|
*/
|
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 07:44:08 -07:00
|
|
|
static void ahci_restore_initial_config(struct ata_host *host)
|
2007-03-18 06:15:33 -07: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 07:44:08 -07:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
2010-03-03 10:17:34 -07:00
|
|
|
void __iomem *mmio = hpriv->mmio;
|
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 07:44:08 -07:00
|
|
|
|
2007-03-18 06:15:33 -07:00
|
|
|
writel(hpriv->saved_cap, mmio + HOST_CAP);
|
2009-09-20 16:02:31 -07:00
|
|
|
if (hpriv->saved_cap2)
|
|
|
|
writel(hpriv->saved_cap2, mmio + HOST_CAP2);
|
2007-03-18 06:15:33 -07:00
|
|
|
writel(hpriv->saved_port_map, mmio + HOST_PORTS_IMPL);
|
|
|
|
(void) readl(mmio + HOST_PORTS_IMPL); /* flush */
|
|
|
|
}
|
|
|
|
|
2007-07-15 22:29:40 -07:00
|
|
|
static unsigned ahci_scr_offset(struct ata_port *ap, unsigned int sc_reg)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2007-07-15 22:29:40 -07:00
|
|
|
static const int offset[] = {
|
|
|
|
[SCR_STATUS] = PORT_SCR_STAT,
|
|
|
|
[SCR_CONTROL] = PORT_SCR_CTL,
|
|
|
|
[SCR_ERROR] = PORT_SCR_ERR,
|
|
|
|
[SCR_ACTIVE] = PORT_SCR_ACT,
|
|
|
|
[SCR_NOTIFICATION] = PORT_SCR_NTF,
|
|
|
|
};
|
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-07-15 22:29:40 -07:00
|
|
|
if (sc_reg < ARRAY_SIZE(offset) &&
|
|
|
|
(sc_reg != SCR_NOTIFICATION || (hpriv->cap & HOST_CAP_SNTF)))
|
|
|
|
return offset[sc_reg];
|
2007-07-15 22:29:40 -07:00
|
|
|
return 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2008-07-31 01:02:40 -07:00
|
|
|
static int ahci_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2008-07-31 01:02:40 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(link->ap);
|
|
|
|
int offset = ahci_scr_offset(link->ap, sc_reg);
|
2007-07-15 22:29:40 -07:00
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
*val = readl(port_mmio + offset);
|
|
|
|
return 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2007-07-15 22:29:40 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-07-31 01:02:40 -07:00
|
|
|
static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
|
2007-07-15 22:29:40 -07:00
|
|
|
{
|
2008-07-31 01:02:40 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(link->ap);
|
|
|
|
int offset = ahci_scr_offset(link->ap, sc_reg);
|
2007-07-15 22:29:40 -07:00
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
writel(val, port_mmio + offset);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
2005-04-16 15:20:36 -07: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 07:44:08 -07:00
|
|
|
static void ahci_start_engine(struct ata_port *ap)
|
2005-12-19 06:36:34 -07: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 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2005-12-19 06:36:34 -07:00
|
|
|
u32 tmp;
|
|
|
|
|
2006-07-25 23:59:25 -07:00
|
|
|
/* start DMA */
|
2006-07-25 23:59:26 -07:00
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
2005-12-19 06:36:34 -07:00
|
|
|
tmp |= PORT_CMD_START;
|
|
|
|
writel(tmp, port_mmio + PORT_CMD);
|
|
|
|
readl(port_mmio + PORT_CMD); /* flush */
|
|
|
|
}
|
|
|
|
|
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 07:44:08 -07:00
|
|
|
static int ahci_stop_engine(struct ata_port *ap)
|
2006-07-25 23:59:25 -07: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 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-07-25 23:59:25 -07:00
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
|
|
|
|
2006-07-25 23:59:25 -07:00
|
|
|
/* check if the HBA is idle */
|
2006-07-25 23:59:25 -07:00
|
|
|
if ((tmp & (PORT_CMD_START | PORT_CMD_LIST_ON)) == 0)
|
|
|
|
return 0;
|
|
|
|
|
2006-07-25 23:59:25 -07:00
|
|
|
/* setting HBA to idle */
|
2006-07-25 23:59:25 -07:00
|
|
|
tmp &= ~PORT_CMD_START;
|
|
|
|
writel(tmp, port_mmio + PORT_CMD);
|
|
|
|
|
2006-07-25 23:59:25 -07:00
|
|
|
/* wait for engine to stop. This could be as long as 500 msec */
|
2006-07-25 23:59:25 -07:00
|
|
|
tmp = ata_wait_register(port_mmio + PORT_CMD,
|
2007-10-19 03:42:56 -07:00
|
|
|
PORT_CMD_LIST_ON, PORT_CMD_LIST_ON, 1, 500);
|
2006-07-25 23:59:25 -07:00
|
|
|
if (tmp & PORT_CMD_LIST_ON)
|
2006-07-25 23:59:25 -07:00
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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 07:44:08 -07:00
|
|
|
static void ahci_start_fis_rx(struct ata_port *ap)
|
2006-07-25 23:59:26 -07: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 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2006-07-25 23:59:26 -07:00
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
/* set FIS registers */
|
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 07:44:08 -07:00
|
|
|
if (hpriv->cap & HOST_CAP_64)
|
|
|
|
writel((pp->cmd_slot_dma >> 16) >> 16,
|
|
|
|
port_mmio + PORT_LST_ADDR_HI);
|
|
|
|
writel(pp->cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR);
|
2006-07-25 23:59:26 -07: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 07:44:08 -07:00
|
|
|
if (hpriv->cap & HOST_CAP_64)
|
|
|
|
writel((pp->rx_fis_dma >> 16) >> 16,
|
|
|
|
port_mmio + PORT_FIS_ADDR_HI);
|
|
|
|
writel(pp->rx_fis_dma & 0xffffffff, port_mmio + PORT_FIS_ADDR);
|
2006-07-25 23:59:26 -07:00
|
|
|
|
|
|
|
/* enable FIS reception */
|
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
|
|
|
tmp |= PORT_CMD_FIS_RX;
|
|
|
|
writel(tmp, port_mmio + PORT_CMD);
|
|
|
|
|
|
|
|
/* flush */
|
|
|
|
readl(port_mmio + PORT_CMD);
|
|
|
|
}
|
|
|
|
|
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 07:44:08 -07:00
|
|
|
static int ahci_stop_fis_rx(struct ata_port *ap)
|
2006-07-25 23:59:26 -07: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 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
/* disable FIS reception */
|
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
|
|
|
tmp &= ~PORT_CMD_FIS_RX;
|
|
|
|
writel(tmp, port_mmio + PORT_CMD);
|
|
|
|
|
|
|
|
/* wait for completion, spec says 500ms, give it 1000 */
|
|
|
|
tmp = ata_wait_register(port_mmio + PORT_CMD, PORT_CMD_FIS_ON,
|
|
|
|
PORT_CMD_FIS_ON, 10, 1000);
|
|
|
|
if (tmp & PORT_CMD_FIS_ON)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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 07:44:08 -07:00
|
|
|
static void ahci_power_up(struct ata_port *ap)
|
2006-07-25 23:59:26 -07: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 07:44:08 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
u32 cmd;
|
|
|
|
|
|
|
|
cmd = readl(port_mmio + PORT_CMD) & ~PORT_CMD_ICC_MASK;
|
|
|
|
|
|
|
|
/* spin up device */
|
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 07:44:08 -07:00
|
|
|
if (hpriv->cap & HOST_CAP_SSS) {
|
2006-07-25 23:59:26 -07:00
|
|
|
cmd |= PORT_CMD_SPIN_UP;
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wake up link */
|
|
|
|
writel(cmd | PORT_CMD_ICC_ACTIVE, port_mmio + PORT_CMD);
|
|
|
|
}
|
|
|
|
|
2007-10-24 22:33:26 -07:00
|
|
|
static void ahci_disable_alpm(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
u32 cmd;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
|
|
|
|
/* IPM bits should be disabled by libata-core */
|
|
|
|
/* get the existing command bits */
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
|
|
|
|
/* disable ALPM and ASP */
|
|
|
|
cmd &= ~PORT_CMD_ASP;
|
|
|
|
cmd &= ~PORT_CMD_ALPE;
|
|
|
|
|
|
|
|
/* force the interface back to active */
|
|
|
|
cmd |= PORT_CMD_ICC_ACTIVE;
|
|
|
|
|
|
|
|
/* write out new cmd value */
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
|
|
|
|
/* wait 10ms to be sure we've come out of any low power state */
|
|
|
|
msleep(10);
|
|
|
|
|
|
|
|
/* clear out any PhyRdy stuff from interrupt status */
|
|
|
|
writel(PORT_IRQ_PHYRDY, port_mmio + PORT_IRQ_STAT);
|
|
|
|
|
|
|
|
/* go ahead and clean out PhyRdy Change from Serror too */
|
2008-07-31 01:02:40 -07:00
|
|
|
ahci_scr_write(&ap->link, SCR_ERROR, ((1 << 16) | (1 << 18)));
|
2007-10-24 22:33:26 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear flag to indicate that we should ignore all PhyRdy
|
|
|
|
* state changes
|
|
|
|
*/
|
|
|
|
hpriv->flags &= ~AHCI_HFLAG_NO_HOTPLUG;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable interrupts on Phy Ready.
|
|
|
|
*/
|
|
|
|
pp->intr_mask |= PORT_IRQ_PHYRDY;
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* don't change the link pm policy - we can be called
|
|
|
|
* just to turn of link pm temporarily
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ahci_enable_alpm(struct ata_port *ap,
|
|
|
|
enum link_pm policy)
|
|
|
|
{
|
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
u32 cmd;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
u32 asp;
|
|
|
|
|
|
|
|
/* Make sure the host is capable of link power management */
|
|
|
|
if (!(hpriv->cap & HOST_CAP_ALPM))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (policy) {
|
|
|
|
case MAX_PERFORMANCE:
|
|
|
|
case NOT_AVAILABLE:
|
|
|
|
/*
|
|
|
|
* if we came here with NOT_AVAILABLE,
|
|
|
|
* it just means this is the first time we
|
|
|
|
* have tried to enable - default to max performance,
|
|
|
|
* and let the user go to lower power modes on request.
|
|
|
|
*/
|
|
|
|
ahci_disable_alpm(ap);
|
|
|
|
return 0;
|
|
|
|
case MIN_POWER:
|
|
|
|
/* configure HBA to enter SLUMBER */
|
|
|
|
asp = PORT_CMD_ASP;
|
|
|
|
break;
|
|
|
|
case MEDIUM_POWER:
|
|
|
|
/* configure HBA to enter PARTIAL */
|
|
|
|
asp = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable interrupts on Phy Ready. This keeps us from
|
|
|
|
* getting woken up due to spurious phy ready interrupts
|
|
|
|
* TBD - Hot plug should be done via polling now, is
|
|
|
|
* that even supported?
|
|
|
|
*/
|
|
|
|
pp->intr_mask &= ~PORT_IRQ_PHYRDY;
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set a flag to indicate that we should ignore all PhyRdy
|
|
|
|
* state changes since these can happen now whenever we
|
|
|
|
* change link state
|
|
|
|
*/
|
|
|
|
hpriv->flags |= AHCI_HFLAG_NO_HOTPLUG;
|
|
|
|
|
|
|
|
/* get the existing command bits */
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set ASP based on Policy
|
|
|
|
*/
|
|
|
|
cmd |= asp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setting this bit will instruct the HBA to aggressively
|
|
|
|
* enter a lower power link state when it's appropriate and
|
|
|
|
* based on the value set above for ASP
|
|
|
|
*/
|
|
|
|
cmd |= PORT_CMD_ALPE;
|
|
|
|
|
|
|
|
/* write out new cmd value */
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
|
|
|
|
/* IPM bits should be set by libata-core */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-03-02 01:31:26 -07:00
|
|
|
#ifdef CONFIG_PM
|
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 07:44:08 -07:00
|
|
|
static void ahci_power_down(struct ata_port *ap)
|
2006-07-25 23:59:26 -07: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 07:44:08 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
u32 cmd, scontrol;
|
|
|
|
|
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 07:44:08 -07:00
|
|
|
if (!(hpriv->cap & HOST_CAP_SSS))
|
2007-01-20 10:10:11 -07:00
|
|
|
return;
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2007-01-20 10:10:11 -07:00
|
|
|
/* put device into listen mode, first set PxSCTL.DET to 0 */
|
|
|
|
scontrol = readl(port_mmio + PORT_SCR_CTL);
|
|
|
|
scontrol &= ~0xf;
|
|
|
|
writel(scontrol, port_mmio + PORT_SCR_CTL);
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2007-01-20 10:10:11 -07:00
|
|
|
/* then set PxCMD.SUD to 0 */
|
|
|
|
cmd = readl(port_mmio + PORT_CMD) & ~PORT_CMD_ICC_MASK;
|
|
|
|
cmd &= ~PORT_CMD_SPIN_UP;
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
2006-07-25 23:59:26 -07:00
|
|
|
}
|
2007-03-02 01:31:26 -07:00
|
|
|
#endif
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2007-05-26 17:46:51 -07:00
|
|
|
static void ahci_start_port(struct ata_port *ap)
|
2006-07-25 23:59:26 -07:00
|
|
|
{
|
2008-06-03 10:33:55 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
struct ata_link *link;
|
|
|
|
struct ahci_em_priv *emp;
|
2009-04-03 13:36:41 -07:00
|
|
|
ssize_t rc;
|
|
|
|
int i;
|
2008-06-03 10:33:55 -07:00
|
|
|
|
2006-07-25 23:59:26 -07:00
|
|
|
/* enable FIS reception */
|
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 07:44:08 -07:00
|
|
|
ahci_start_fis_rx(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
|
|
|
|
/* enable DMA */
|
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 07:44:08 -07:00
|
|
|
ahci_start_engine(ap);
|
2008-06-03 10:33:55 -07:00
|
|
|
|
|
|
|
/* turn on LEDs */
|
|
|
|
if (ap->flags & ATA_FLAG_EM) {
|
2008-11-03 04:03:17 -07:00
|
|
|
ata_for_each_link(link, ap, EDGE) {
|
2008-06-03 10:33:55 -07:00
|
|
|
emp = &pp->em_priv[link->pmp];
|
2009-04-03 13:36:41 -07:00
|
|
|
|
|
|
|
/* EM Transmit bit maybe busy during init */
|
2009-05-11 18:57:41 -07:00
|
|
|
for (i = 0; i < EM_MAX_RETRY; i++) {
|
2009-04-03 13:36:41 -07:00
|
|
|
rc = ahci_transmit_led_message(ap,
|
|
|
|
emp->led_state,
|
|
|
|
4);
|
|
|
|
if (rc == -EBUSY)
|
2009-05-11 18:57:41 -07:00
|
|
|
msleep(1);
|
2009-04-03 13:36:41 -07:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2008-06-03 10:33:55 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ap->flags & ATA_FLAG_SW_ACTIVITY)
|
2008-11-03 04:03:17 -07:00
|
|
|
ata_for_each_link(link, ap, EDGE)
|
2008-06-03 10:33:55 -07:00
|
|
|
ahci_init_sw_activity(link);
|
|
|
|
|
2006-07-25 23:59:26 -07: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 07:44:08 -07:00
|
|
|
static int ahci_deinit_port(struct ata_port *ap, const char **emsg)
|
2006-07-25 23:59:26 -07:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* disable DMA */
|
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 07:44:08 -07:00
|
|
|
rc = ahci_stop_engine(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
if (rc) {
|
|
|
|
*emsg = "failed to stop engine";
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disable FIS reception */
|
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 07:44:08 -07:00
|
|
|
rc = ahci_stop_fis_rx(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
if (rc) {
|
|
|
|
*emsg = "failed stop FIS RX";
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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 07:44:08 -07:00
|
|
|
static int ahci_reset_controller(struct ata_host *host)
|
2006-07-25 23:59:26 -07:00
|
|
|
{
|
2007-11-19 00:03:44 -07:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
2010-03-03 10:17:34 -07:00
|
|
|
void __iomem *mmio = hpriv->mmio;
|
2007-03-18 06:15:33 -07:00
|
|
|
u32 tmp;
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2007-09-25 21:02:41 -07:00
|
|
|
/* we must be in AHCI mode, before using anything
|
|
|
|
* AHCI-specific, such as HOST_RESET.
|
|
|
|
*/
|
2008-01-05 07:11:57 -07:00
|
|
|
ahci_enable_ahci(mmio);
|
2007-09-25 21:02:41 -07:00
|
|
|
|
|
|
|
/* global controller reset */
|
2008-03-09 18:25:25 -07:00
|
|
|
if (!ahci_skip_host_reset) {
|
|
|
|
tmp = readl(mmio + HOST_CTL);
|
|
|
|
if ((tmp & HOST_RESET) == 0) {
|
|
|
|
writel(tmp | HOST_RESET, mmio + HOST_CTL);
|
|
|
|
readl(mmio + HOST_CTL); /* flush */
|
|
|
|
}
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2008-07-03 22:32:17 -07:00
|
|
|
/*
|
|
|
|
* to perform host reset, OS should set HOST_RESET
|
|
|
|
* and poll until this bit is read to be "0".
|
|
|
|
* reset must complete within 1 second, or
|
2008-03-09 18:25:25 -07:00
|
|
|
* the hardware should be considered fried.
|
|
|
|
*/
|
2008-07-03 22:32:17 -07:00
|
|
|
tmp = ata_wait_register(mmio + HOST_CTL, HOST_RESET,
|
|
|
|
HOST_RESET, 10, 1000);
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2008-03-09 18:25:25 -07:00
|
|
|
if (tmp & HOST_RESET) {
|
|
|
|
dev_printk(KERN_ERR, host->dev,
|
|
|
|
"controller reset failed (0x%x)\n", tmp);
|
|
|
|
return -EIO;
|
|
|
|
}
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2008-03-09 18:25:25 -07:00
|
|
|
/* turn on AHCI mode */
|
|
|
|
ahci_enable_ahci(mmio);
|
2006-11-01 20:17:23 -07:00
|
|
|
|
2008-03-09 18:25:25 -07:00
|
|
|
/* Some registers might be cleared on reset. Restore
|
|
|
|
* initial values.
|
|
|
|
*/
|
|
|
|
ahci_restore_initial_config(host);
|
|
|
|
} else
|
|
|
|
dev_printk(KERN_INFO, host->dev,
|
|
|
|
"skipping global host reset\n");
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2010-03-03 10:17:39 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ahci_pci_reset_controller(struct ata_host *host)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = to_pci_dev(host->dev);
|
|
|
|
|
|
|
|
ahci_reset_controller(host);
|
|
|
|
|
2006-07-25 23:59:26 -07:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
|
2010-03-03 10:17:39 -07:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
2006-07-25 23:59:26 -07:00
|
|
|
u16 tmp16;
|
|
|
|
|
|
|
|
/* configure PCS */
|
|
|
|
pci_read_config_word(pdev, 0x92, &tmp16);
|
2007-11-19 00:03:44 -07:00
|
|
|
if ((tmp16 & hpriv->port_map) != hpriv->port_map) {
|
|
|
|
tmp16 |= hpriv->port_map;
|
|
|
|
pci_write_config_word(pdev, 0x92, tmp16);
|
|
|
|
}
|
2006-07-25 23:59:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-03 10:33:55 -07:00
|
|
|
static void ahci_sw_activity(struct ata_link *link)
|
|
|
|
{
|
|
|
|
struct ata_port *ap = link->ap;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
|
|
|
|
|
|
|
|
if (!(link->flags & ATA_LFLAG_SW_ACTIVITY))
|
|
|
|
return;
|
|
|
|
|
|
|
|
emp->activity++;
|
|
|
|
if (!timer_pending(&emp->timer))
|
|
|
|
mod_timer(&emp->timer, jiffies + msecs_to_jiffies(10));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_sw_activity_blink(unsigned long arg)
|
|
|
|
{
|
|
|
|
struct ata_link *link = (struct ata_link *)arg;
|
|
|
|
struct ata_port *ap = link->ap;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
|
|
|
|
unsigned long led_message = emp->led_state;
|
|
|
|
u32 activity_led_state;
|
2008-10-16 07:26:19 -07:00
|
|
|
unsigned long flags;
|
2008-06-03 10:33:55 -07:00
|
|
|
|
2008-10-13 12:38:36 -07:00
|
|
|
led_message &= EM_MSG_LED_VALUE;
|
2008-06-03 10:33:55 -07:00
|
|
|
led_message |= ap->port_no | (link->pmp << 8);
|
|
|
|
|
|
|
|
/* check to see if we've had activity. If so,
|
|
|
|
* toggle state of LED and reset timer. If not,
|
|
|
|
* turn LED to desired idle state.
|
|
|
|
*/
|
2008-10-16 07:26:19 -07:00
|
|
|
spin_lock_irqsave(ap->lock, flags);
|
2008-06-03 10:33:55 -07:00
|
|
|
if (emp->saved_activity != emp->activity) {
|
|
|
|
emp->saved_activity = emp->activity;
|
|
|
|
/* get the current LED state */
|
2008-10-13 12:38:36 -07:00
|
|
|
activity_led_state = led_message & EM_MSG_LED_VALUE_ON;
|
2008-06-03 10:33:55 -07:00
|
|
|
|
|
|
|
if (activity_led_state)
|
|
|
|
activity_led_state = 0;
|
|
|
|
else
|
|
|
|
activity_led_state = 1;
|
|
|
|
|
|
|
|
/* clear old state */
|
2008-10-13 12:38:36 -07:00
|
|
|
led_message &= ~EM_MSG_LED_VALUE_ACTIVITY;
|
2008-06-03 10:33:55 -07:00
|
|
|
|
|
|
|
/* toggle state */
|
|
|
|
led_message |= (activity_led_state << 16);
|
|
|
|
mod_timer(&emp->timer, jiffies + msecs_to_jiffies(100));
|
|
|
|
} else {
|
|
|
|
/* switch to idle */
|
2008-10-13 12:38:36 -07:00
|
|
|
led_message &= ~EM_MSG_LED_VALUE_ACTIVITY;
|
2008-06-03 10:33:55 -07:00
|
|
|
if (emp->blink_policy == BLINK_OFF)
|
|
|
|
led_message |= (1 << 16);
|
|
|
|
}
|
2008-10-16 07:26:19 -07:00
|
|
|
spin_unlock_irqrestore(ap->lock, flags);
|
2008-06-03 10:33:55 -07:00
|
|
|
ahci_transmit_led_message(ap, led_message, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_init_sw_activity(struct ata_link *link)
|
|
|
|
{
|
|
|
|
struct ata_port *ap = link->ap;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
|
|
|
|
|
|
|
|
/* init activity stats, setup timer */
|
|
|
|
emp->saved_activity = emp->activity = 0;
|
|
|
|
setup_timer(&emp->timer, ahci_sw_activity_blink, (unsigned long)link);
|
|
|
|
|
|
|
|
/* check our blink policy and set flag for link if it's enabled */
|
|
|
|
if (emp->blink_policy)
|
|
|
|
link->flags |= ATA_LFLAG_SW_ACTIVITY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ahci_reset_em(struct ata_host *host)
|
|
|
|
{
|
2010-03-03 10:17:34 -07:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
|
|
|
void __iomem *mmio = hpriv->mmio;
|
2008-06-03 10:33:55 -07:00
|
|
|
u32 em_ctl;
|
|
|
|
|
|
|
|
em_ctl = readl(mmio + HOST_EM_CTL);
|
|
|
|
if ((em_ctl & EM_CTL_TM) || (em_ctl & EM_CTL_RST))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
writel(em_ctl | EM_CTL_RST, mmio + HOST_EM_CTL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
|
|
|
|
ssize_t size)
|
|
|
|
{
|
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2010-03-03 10:17:34 -07:00
|
|
|
void __iomem *mmio = hpriv->mmio;
|
2008-06-03 10:33:55 -07:00
|
|
|
u32 em_ctl;
|
|
|
|
u32 message[] = {0, 0};
|
2008-07-25 10:56:36 -07:00
|
|
|
unsigned long flags;
|
2008-06-03 10:33:55 -07:00
|
|
|
int pmp;
|
|
|
|
struct ahci_em_priv *emp;
|
|
|
|
|
|
|
|
/* get the slot number from the message */
|
2008-10-13 12:38:36 -07:00
|
|
|
pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
|
2009-05-11 18:57:41 -07:00
|
|
|
if (pmp < EM_MAX_SLOTS)
|
2008-06-03 10:33:55 -07:00
|
|
|
emp = &pp->em_priv[pmp];
|
|
|
|
else
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
spin_lock_irqsave(ap->lock, flags);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if we are still busy transmitting a previous message,
|
|
|
|
* do not allow
|
|
|
|
*/
|
|
|
|
em_ctl = readl(mmio + HOST_EM_CTL);
|
|
|
|
if (em_ctl & EM_CTL_TM) {
|
|
|
|
spin_unlock_irqrestore(ap->lock, flags);
|
2009-04-03 13:36:41 -07:00
|
|
|
return -EBUSY;
|
2008-06-03 10:33:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* create message header - this is all zero except for
|
|
|
|
* the message size, which is 4 bytes.
|
|
|
|
*/
|
|
|
|
message[0] |= (4 << 8);
|
|
|
|
|
|
|
|
/* ignore 0:4 of byte zero, fill in port info yourself */
|
2008-10-13 12:38:36 -07:00
|
|
|
message[1] = ((state & ~EM_MSG_LED_HBA_PORT) | ap->port_no);
|
2008-06-03 10:33:55 -07:00
|
|
|
|
|
|
|
/* write message to EM_LOC */
|
|
|
|
writel(message[0], mmio + hpriv->em_loc);
|
|
|
|
writel(message[1], mmio + hpriv->em_loc+4);
|
|
|
|
|
|
|
|
/* save off new led state for port/slot */
|
2009-03-20 12:14:23 -07:00
|
|
|
emp->led_state = state;
|
2008-06-03 10:33:55 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* tell hardware to transmit the message
|
|
|
|
*/
|
|
|
|
writel(em_ctl | EM_CTL_TM, mmio + HOST_EM_CTL);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(ap->lock, flags);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t ahci_led_show(struct ata_port *ap, char *buf)
|
|
|
|
{
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
struct ata_link *link;
|
|
|
|
struct ahci_em_priv *emp;
|
|
|
|
int rc = 0;
|
|
|
|
|
2008-11-03 04:03:17 -07:00
|
|
|
ata_for_each_link(link, ap, EDGE) {
|
2008-06-03 10:33:55 -07:00
|
|
|
emp = &pp->em_priv[link->pmp];
|
|
|
|
rc += sprintf(buf, "%lx\n", emp->led_state);
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
|
|
|
|
size_t size)
|
|
|
|
{
|
|
|
|
int state;
|
|
|
|
int pmp;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
struct ahci_em_priv *emp;
|
|
|
|
|
|
|
|
state = simple_strtoul(buf, NULL, 0);
|
|
|
|
|
|
|
|
/* get the slot number from the message */
|
2008-10-13 12:38:36 -07:00
|
|
|
pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
|
2009-05-11 18:57:41 -07:00
|
|
|
if (pmp < EM_MAX_SLOTS)
|
2008-06-03 10:33:55 -07:00
|
|
|
emp = &pp->em_priv[pmp];
|
|
|
|
else
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* mask off the activity bits if we are in sw_activity
|
|
|
|
* mode, user should turn off sw_activity before setting
|
|
|
|
* activity led through em_message
|
|
|
|
*/
|
|
|
|
if (emp->blink_policy)
|
2008-10-13 12:38:36 -07:00
|
|
|
state &= ~EM_MSG_LED_VALUE_ACTIVITY;
|
2008-06-03 10:33:55 -07:00
|
|
|
|
|
|
|
return ahci_transmit_led_message(ap, state, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t ahci_activity_store(struct ata_device *dev, enum sw_activity val)
|
|
|
|
{
|
|
|
|
struct ata_link *link = dev->link;
|
|
|
|
struct ata_port *ap = link->ap;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
|
|
|
|
u32 port_led_state = emp->led_state;
|
|
|
|
|
|
|
|
/* save the desired Activity LED behavior */
|
|
|
|
if (val == OFF) {
|
|
|
|
/* clear LFLAG */
|
|
|
|
link->flags &= ~(ATA_LFLAG_SW_ACTIVITY);
|
|
|
|
|
|
|
|
/* set the LED to OFF */
|
2008-10-13 12:38:36 -07:00
|
|
|
port_led_state &= EM_MSG_LED_VALUE_OFF;
|
2008-06-03 10:33:55 -07:00
|
|
|
port_led_state |= (ap->port_no | (link->pmp << 8));
|
|
|
|
ahci_transmit_led_message(ap, port_led_state, 4);
|
|
|
|
} else {
|
|
|
|
link->flags |= ATA_LFLAG_SW_ACTIVITY;
|
|
|
|
if (val == BLINK_OFF) {
|
|
|
|
/* set LED to ON for idle */
|
2008-10-13 12:38:36 -07:00
|
|
|
port_led_state &= EM_MSG_LED_VALUE_OFF;
|
2008-06-03 10:33:55 -07:00
|
|
|
port_led_state |= (ap->port_no | (link->pmp << 8));
|
2008-10-13 12:38:36 -07:00
|
|
|
port_led_state |= EM_MSG_LED_VALUE_ON; /* check this */
|
2008-06-03 10:33:55 -07:00
|
|
|
ahci_transmit_led_message(ap, port_led_state, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
emp->blink_policy = val;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t ahci_activity_show(struct ata_device *dev, char *buf)
|
|
|
|
{
|
|
|
|
struct ata_link *link = dev->link;
|
|
|
|
struct ata_port *ap = link->ap;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
|
|
|
|
|
|
|
|
/* display the saved value of activity behavior for this
|
|
|
|
* disk.
|
|
|
|
*/
|
|
|
|
return sprintf(buf, "%d\n", emp->blink_policy);
|
|
|
|
}
|
|
|
|
|
2010-03-03 10:17:40 -07:00
|
|
|
static void ahci_port_init(struct device *dev, struct ata_port *ap,
|
2007-05-28 04:45:27 -07:00
|
|
|
int port_no, void __iomem *mmio,
|
|
|
|
void __iomem *port_mmio)
|
|
|
|
{
|
|
|
|
const char *emsg = NULL;
|
|
|
|
int rc;
|
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
/* make sure port is not active */
|
|
|
|
rc = ahci_deinit_port(ap, &emsg);
|
|
|
|
if (rc)
|
2010-03-03 10:17:40 -07:00
|
|
|
dev_warn(dev, "%s (%d)\n", emsg, rc);
|
2007-05-28 04:45:27 -07:00
|
|
|
|
|
|
|
/* clear SError */
|
|
|
|
tmp = readl(port_mmio + PORT_SCR_ERR);
|
|
|
|
VPRINTK("PORT_SCR_ERR 0x%x\n", tmp);
|
|
|
|
writel(tmp, port_mmio + PORT_SCR_ERR);
|
|
|
|
|
|
|
|
/* clear port IRQ */
|
|
|
|
tmp = readl(port_mmio + PORT_IRQ_STAT);
|
|
|
|
VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp);
|
|
|
|
if (tmp)
|
|
|
|
writel(tmp, port_mmio + PORT_IRQ_STAT);
|
|
|
|
|
|
|
|
writel(1 << port_no, mmio + HOST_IRQ_STAT);
|
|
|
|
}
|
|
|
|
|
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 07:44:08 -07:00
|
|
|
static void ahci_init_controller(struct ata_host *host)
|
2006-07-25 23:59:26 -07:00
|
|
|
{
|
2007-09-22 21:19:55 -07:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
2010-03-03 10:17:34 -07:00
|
|
|
void __iomem *mmio = hpriv->mmio;
|
2007-05-28 04:45:27 -07:00
|
|
|
int i;
|
2007-07-07 23:29:42 -07:00
|
|
|
void __iomem *port_mmio;
|
2006-07-25 23:59:26 -07:00
|
|
|
u32 tmp;
|
2010-03-03 10:17:42 -07:00
|
|
|
|
|
|
|
for (i = 0; i < host->n_ports; i++) {
|
|
|
|
struct ata_port *ap = host->ports[i];
|
|
|
|
|
|
|
|
port_mmio = ahci_port_base(ap);
|
|
|
|
if (ata_port_is_dummy(ap))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ahci_port_init(host->dev, ap, i, mmio, port_mmio);
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = readl(mmio + HOST_CTL);
|
|
|
|
VPRINTK("HOST_CTL 0x%x\n", tmp);
|
|
|
|
writel(tmp | HOST_IRQ_EN, mmio + HOST_CTL);
|
|
|
|
tmp = readl(mmio + HOST_CTL);
|
|
|
|
VPRINTK("HOST_CTL 0x%x\n", tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_pci_init_controller(struct ata_host *host)
|
|
|
|
{
|
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
|
|
|
struct pci_dev *pdev = to_pci_dev(host->dev);
|
|
|
|
void __iomem *port_mmio;
|
|
|
|
u32 tmp;
|
2008-03-13 15:22:24 -07:00
|
|
|
int mv;
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2007-09-22 21:19:55 -07:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
|
2008-03-13 15:22:24 -07:00
|
|
|
if (pdev->device == 0x6121)
|
|
|
|
mv = 2;
|
|
|
|
else
|
|
|
|
mv = 4;
|
|
|
|
port_mmio = __ahci_port_base(host, mv);
|
2007-07-07 23:29:42 -07:00
|
|
|
|
|
|
|
writel(0, port_mmio + PORT_IRQ_MASK);
|
|
|
|
|
|
|
|
/* clear port IRQ */
|
|
|
|
tmp = readl(port_mmio + PORT_IRQ_STAT);
|
|
|
|
VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp);
|
|
|
|
if (tmp)
|
|
|
|
writel(tmp, port_mmio + PORT_IRQ_STAT);
|
|
|
|
}
|
|
|
|
|
2010-03-03 10:17:42 -07:00
|
|
|
ahci_init_controller(host);
|
2006-07-25 23:59:26 -07:00
|
|
|
}
|
|
|
|
|
2008-02-28 13:43:48 -07:00
|
|
|
static void ahci_dev_config(struct ata_device *dev)
|
|
|
|
{
|
|
|
|
struct ahci_host_priv *hpriv = dev->link->ap->host->private_data;
|
|
|
|
|
2008-03-24 19:40:40 -07:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_SECT255) {
|
2008-02-28 13:43:48 -07:00
|
|
|
dev->max_sectors = 255;
|
2008-03-24 19:40:40 -07:00
|
|
|
ata_dev_printk(dev, KERN_INFO,
|
|
|
|
"SB600 AHCI: limiting to 255 sectors per cmd\n");
|
|
|
|
}
|
2008-02-28 13:43:48 -07:00
|
|
|
}
|
|
|
|
|
2005-12-19 06:37:17 -07:00
|
|
|
static unsigned int ahci_dev_classify(struct ata_port *ap)
|
2005-04-16 15:20:36 -07: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 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ata_taskfile tf;
|
2005-12-19 06:37:17 -07:00
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
tmp = readl(port_mmio + PORT_SIG);
|
|
|
|
tf.lbah = (tmp >> 24) & 0xff;
|
|
|
|
tf.lbam = (tmp >> 16) & 0xff;
|
|
|
|
tf.lbal = (tmp >> 8) & 0xff;
|
|
|
|
tf.nsect = (tmp) & 0xff;
|
|
|
|
|
|
|
|
return ata_dev_classify(&tf);
|
|
|
|
}
|
|
|
|
|
2006-05-15 05:03:55 -07:00
|
|
|
static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
|
|
|
|
u32 opts)
|
2006-02-10 01:25:47 -07:00
|
|
|
{
|
2006-05-15 05:03:55 -07:00
|
|
|
dma_addr_t cmd_tbl_dma;
|
|
|
|
|
|
|
|
cmd_tbl_dma = pp->cmd_tbl_dma + tag * AHCI_CMD_TBL_SZ;
|
|
|
|
|
|
|
|
pp->cmd_slot[tag].opts = cpu_to_le32(opts);
|
|
|
|
pp->cmd_slot[tag].status = 0;
|
|
|
|
pp->cmd_slot[tag].tbl_addr = cpu_to_le32(cmd_tbl_dma & 0xffffffff);
|
|
|
|
pp->cmd_slot[tag].tbl_addr_hi = cpu_to_le32((cmd_tbl_dma >> 16) >> 16);
|
2006-02-10 01:25:47 -07:00
|
|
|
}
|
|
|
|
|
2009-08-07 00:05:52 -07:00
|
|
|
static int ahci_kick_engine(struct ata_port *ap)
|
2006-03-22 05:07:03 -07:00
|
|
|
{
|
2008-04-07 06:47:21 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-08-24 00:19:22 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2008-04-07 06:47:21 -07:00
|
|
|
u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
|
2006-04-17 05:17:59 -07:00
|
|
|
u32 tmp;
|
2007-07-15 22:29:39 -07:00
|
|
|
int busy, rc;
|
2006-04-17 05:17:59 -07:00
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
/* stop engine */
|
|
|
|
rc = ahci_stop_engine(ap);
|
|
|
|
if (rc)
|
|
|
|
goto out_restart;
|
|
|
|
|
2009-08-07 00:05:52 -07:00
|
|
|
/* need to do CLO?
|
|
|
|
* always do CLO if PMP is attached (AHCI-1.3 9.2)
|
|
|
|
*/
|
|
|
|
busy = status & (ATA_BUSY | ATA_DRQ);
|
|
|
|
if (!busy && !sata_pmp_attached(ap)) {
|
2007-07-15 22:29:39 -07:00
|
|
|
rc = 0;
|
|
|
|
goto out_restart;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(hpriv->cap & HOST_CAP_CLO)) {
|
|
|
|
rc = -EOPNOTSUPP;
|
|
|
|
goto out_restart;
|
|
|
|
}
|
2006-04-17 05:17:59 -07:00
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
/* perform CLO */
|
2006-04-17 05:17:59 -07:00
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
|
|
|
tmp |= PORT_CMD_CLO;
|
|
|
|
writel(tmp, port_mmio + PORT_CMD);
|
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
rc = 0;
|
2006-04-17 05:17:59 -07:00
|
|
|
tmp = ata_wait_register(port_mmio + PORT_CMD,
|
|
|
|
PORT_CMD_CLO, PORT_CMD_CLO, 1, 500);
|
|
|
|
if (tmp & PORT_CMD_CLO)
|
2007-07-15 22:29:39 -07:00
|
|
|
rc = -EIO;
|
2006-04-17 05:17:59 -07:00
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
/* restart engine */
|
|
|
|
out_restart:
|
|
|
|
ahci_start_engine(ap);
|
|
|
|
return rc;
|
2006-04-17 05:17:59 -07:00
|
|
|
}
|
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
|
|
|
|
struct ata_taskfile *tf, int is_cmd, u16 flags,
|
|
|
|
unsigned long timeout_msec)
|
2006-04-17 05:17:59 -07:00
|
|
|
{
|
2007-07-15 22:29:39 -07:00
|
|
|
const u32 cmd_fis_len = 5; /* five dwords */
|
2006-03-22 05:07:03 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_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 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-07-15 22:29:39 -07:00
|
|
|
u8 *fis = pp->cmd_tbl;
|
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
/* prep the command */
|
|
|
|
ata_tf_to_fis(tf, pmp, is_cmd, fis);
|
|
|
|
ahci_fill_cmd_slot(pp, 0, cmd_fis_len | flags | (pmp << 12));
|
|
|
|
|
|
|
|
/* issue & wait */
|
|
|
|
writel(1, port_mmio + PORT_CMD_ISSUE);
|
|
|
|
|
|
|
|
if (timeout_msec) {
|
|
|
|
tmp = ata_wait_register(port_mmio + PORT_CMD_ISSUE, 0x1, 0x1,
|
|
|
|
1, timeout_msec);
|
|
|
|
if (tmp & 0x1) {
|
2009-08-07 00:05:52 -07:00
|
|
|
ahci_kick_engine(ap);
|
2007-07-15 22:29:39 -07:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
readl(port_mmio + PORT_CMD_ISSUE); /* flush */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-10 00:52:04 -07:00
|
|
|
static int ahci_do_softreset(struct ata_link *link, unsigned int *class,
|
|
|
|
int pmp, unsigned long deadline,
|
|
|
|
int (*check_ready)(struct ata_link *link))
|
2007-07-15 22:29:39 -07:00
|
|
|
{
|
2007-08-06 02:36:23 -07:00
|
|
|
struct ata_port *ap = link->ap;
|
2009-08-03 22:30:08 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2006-03-22 05:07:03 -07:00
|
|
|
const char *reason = NULL;
|
2007-07-15 22:29:38 -07:00
|
|
|
unsigned long now, msecs;
|
2006-03-22 05:07:03 -07:00
|
|
|
struct ata_taskfile tf;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
DPRINTK("ENTER\n");
|
|
|
|
|
|
|
|
/* prepare for SRST (AHCI-1.1 10.4.1) */
|
2009-08-07 00:05:52 -07:00
|
|
|
rc = ahci_kick_engine(ap);
|
2007-12-05 23:02:48 -07:00
|
|
|
if (rc && rc != -EOPNOTSUPP)
|
2007-08-06 02:36:23 -07:00
|
|
|
ata_link_printk(link, KERN_WARNING,
|
2007-12-05 23:02:48 -07:00
|
|
|
"failed to reset engine (errno=%d)\n", rc);
|
2006-03-22 05:07:03 -07:00
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
ata_tf_init(link->device, &tf);
|
2006-03-22 05:07:03 -07:00
|
|
|
|
|
|
|
/* issue the first D2H Register FIS */
|
2007-07-15 22:29:38 -07:00
|
|
|
msecs = 0;
|
|
|
|
now = jiffies;
|
|
|
|
if (time_after(now, deadline))
|
|
|
|
msecs = jiffies_to_msecs(deadline - now);
|
|
|
|
|
2006-03-22 05:07:03 -07:00
|
|
|
tf.ctl |= ATA_SRST;
|
2007-07-15 22:29:39 -07:00
|
|
|
if (ahci_exec_polled_cmd(ap, pmp, &tf, 0,
|
2007-07-15 22:29:39 -07:00
|
|
|
AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY, msecs)) {
|
2006-03-22 05:07:03 -07:00
|
|
|
rc = -EIO;
|
|
|
|
reason = "1st FIS failed";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* spec says at least 5us, but be generous and sleep for 1ms */
|
|
|
|
msleep(1);
|
|
|
|
|
|
|
|
/* issue the second D2H Register FIS */
|
|
|
|
tf.ctl &= ~ATA_SRST;
|
2007-07-15 22:29:39 -07:00
|
|
|
ahci_exec_polled_cmd(ap, pmp, &tf, 0, 0, 0);
|
2006-03-22 05:07:03 -07:00
|
|
|
|
2008-04-07 06:47:19 -07:00
|
|
|
/* wait for link to become ready */
|
2008-06-10 00:52:04 -07:00
|
|
|
rc = ata_wait_after_reset(link, deadline, check_ready);
|
2009-08-03 22:30:08 -07:00
|
|
|
if (rc == -EBUSY && hpriv->flags & AHCI_HFLAG_SRST_TOUT_IS_OFFLINE) {
|
|
|
|
/*
|
|
|
|
* Workaround for cases where link online status can't
|
|
|
|
* be trusted. Treat device readiness timeout as link
|
|
|
|
* offline.
|
|
|
|
*/
|
|
|
|
ata_link_printk(link, KERN_INFO,
|
|
|
|
"device not ready, treating as offline\n");
|
|
|
|
*class = ATA_DEV_NONE;
|
|
|
|
} else if (rc) {
|
|
|
|
/* link occupied, -ENODEV too is an error */
|
2007-02-02 00:50:52 -07:00
|
|
|
reason = "device not ready";
|
|
|
|
goto fail;
|
2009-08-03 22:30:08 -07:00
|
|
|
} else
|
|
|
|
*class = ahci_dev_classify(ap);
|
2006-03-22 05:07:03 -07:00
|
|
|
|
|
|
|
DPRINTK("EXIT, class=%u\n", *class);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
2007-08-06 02:36:23 -07:00
|
|
|
ata_link_printk(link, KERN_ERR, "softreset failed (%s)\n", reason);
|
2006-03-22 05:07:03 -07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2008-06-10 00:52:04 -07:00
|
|
|
static int ahci_check_ready(struct ata_link *link)
|
|
|
|
{
|
|
|
|
void __iomem *port_mmio = ahci_port_base(link->ap);
|
|
|
|
u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
|
|
|
|
|
|
|
|
return ata_check_ready(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ahci_softreset(struct ata_link *link, unsigned int *class,
|
|
|
|
unsigned long deadline)
|
|
|
|
{
|
|
|
|
int pmp = sata_srst_pmp(link);
|
|
|
|
|
|
|
|
DPRINTK("ENTER\n");
|
|
|
|
|
|
|
|
return ahci_do_softreset(link, class, pmp, deadline, ahci_check_ready);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ahci_sb600_check_ready(struct ata_link *link)
|
|
|
|
{
|
|
|
|
void __iomem *port_mmio = ahci_port_base(link->ap);
|
|
|
|
u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
|
|
|
|
u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There is no need to check TFDATA if BAD PMP is found due to HW bug,
|
|
|
|
* which can save timeout delay.
|
|
|
|
*/
|
|
|
|
if (irq_status & PORT_IRQ_BAD_PMP)
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
return ata_check_ready(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
|
|
|
|
unsigned long deadline)
|
|
|
|
{
|
|
|
|
struct ata_port *ap = link->ap;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
int pmp = sata_srst_pmp(link);
|
|
|
|
int rc;
|
|
|
|
u32 irq_sts;
|
|
|
|
|
|
|
|
DPRINTK("ENTER\n");
|
|
|
|
|
|
|
|
rc = ahci_do_softreset(link, class, pmp, deadline,
|
|
|
|
ahci_sb600_check_ready);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Soft reset fails on some ATI chips with IPMS set when PMP
|
|
|
|
* is enabled but SATA HDD/ODD is connected to SATA port,
|
|
|
|
* do soft reset again to port 0.
|
|
|
|
*/
|
|
|
|
if (rc == -EIO) {
|
|
|
|
irq_sts = readl(port_mmio + PORT_IRQ_STAT);
|
|
|
|
if (irq_sts & PORT_IRQ_BAD_PMP) {
|
|
|
|
ata_link_printk(link, KERN_WARNING,
|
2009-08-04 19:10:41 -07:00
|
|
|
"applying SB600 PMP SRST workaround "
|
|
|
|
"and retrying\n");
|
2008-06-10 00:52:04 -07:00
|
|
|
rc = ahci_do_softreset(link, class, 0, deadline,
|
|
|
|
ahci_check_ready);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
static int ahci_hardreset(struct ata_link *link, unsigned int *class,
|
libata: add deadline support to prereset and reset methods
Add @deadline to prereset and reset methods and make them honor it.
ata_wait_ready() which directly takes @deadline is implemented to be
used as the wait function. This patch is in preparation for EH timing
improvements.
* ata_wait_ready() never does busy sleep. It's only used from EH and
no wait in EH is that urgent. This function also prints 'be
patient' message automatically after 5 secs of waiting if more than
3 secs is remaining till deadline.
* ata_bus_post_reset() now fails with error code if any of its wait
fails. This is important because earlier reset tries will have
shorter timeout than the spec requires. If a device fails to
respond before the short timeout, reset should be retried with
longer timeout rather than silently ignoring the device.
There are three behavior differences.
1. Timeout is applied to both devices at once, not separately. This
is more consistent with what the spec says.
2. When a device passes devchk but fails to become ready before
deadline. Previouly, post_reset would just succeed and let
device classification remove the device. New code fails the
reset thus causing reset retry. After a few times, EH will give
up disabling the port.
3. When slave device passes devchk but fails to become accessible
(TF-wise) after reset. Original code disables dev1 after 30s
timeout and continues as if the device doesn't exist, while the
patched code fails reset. When this happens, new code fails
reset on whole port rather than proceeding with only the primary
device.
If the failing device is suffering transient problems, new code
retries reset which is a better behavior. If the failing device is
actually broken, the net effect is identical to it, but not to the
other device sharing the channel. In the previous code, reset would
have succeeded after 30s thus detecting the working one. In the new
code, reset fails and whole port gets disabled. IMO, it's a
pathological case anyway (broken device sharing bus with working
one) and doesn't really matter.
* ata_bus_softreset() is changed to return error code from
ata_bus_post_reset(). It used to return 0 unconditionally.
* Spin up waiting is to be removed and not converted to honor
deadline.
* To be on the safe side, deadline is set to 40s for the time being.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-02-02 00:50:52 -07:00
|
|
|
unsigned long deadline)
|
2005-12-19 06:37:17 -07:00
|
|
|
{
|
2008-04-07 06:47:19 -07:00
|
|
|
const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context);
|
2007-08-06 02:36:23 -07:00
|
|
|
struct ata_port *ap = link->ap;
|
2006-05-31 02:28:18 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
|
|
|
|
struct ata_taskfile tf;
|
2008-04-07 06:47:19 -07:00
|
|
|
bool online;
|
2006-02-11 00:26:02 -07:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
DPRINTK("ENTER\n");
|
2005-04-16 15:20:36 -07: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 07:44:08 -07:00
|
|
|
ahci_stop_engine(ap);
|
2006-05-31 02:28:18 -07:00
|
|
|
|
|
|
|
/* clear D2H reception area to properly wait for D2H FIS */
|
2007-08-06 02:36:23 -07:00
|
|
|
ata_tf_init(link->device, &tf);
|
2007-01-25 23:37:20 -07:00
|
|
|
tf.command = 0x80;
|
2007-07-15 22:29:38 -07:00
|
|
|
ata_tf_to_fis(&tf, 0, 0, d2h_fis);
|
2006-05-31 02:28:18 -07:00
|
|
|
|
2008-04-07 06:47:19 -07:00
|
|
|
rc = sata_link_hardreset(link, timing, deadline, &online,
|
|
|
|
ahci_check_ready);
|
2006-05-31 02:28:18 -07: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 07:44:08 -07:00
|
|
|
ahci_start_engine(ap);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-04-07 06:47:19 -07:00
|
|
|
if (online)
|
2006-02-11 00:26:02 -07:00
|
|
|
*class = ahci_dev_classify(ap);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-02-11 00:26:02 -07:00
|
|
|
DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
|
libata: add deadline support to prereset and reset methods
Add @deadline to prereset and reset methods and make them honor it.
ata_wait_ready() which directly takes @deadline is implemented to be
used as the wait function. This patch is in preparation for EH timing
improvements.
* ata_wait_ready() never does busy sleep. It's only used from EH and
no wait in EH is that urgent. This function also prints 'be
patient' message automatically after 5 secs of waiting if more than
3 secs is remaining till deadline.
* ata_bus_post_reset() now fails with error code if any of its wait
fails. This is important because earlier reset tries will have
shorter timeout than the spec requires. If a device fails to
respond before the short timeout, reset should be retried with
longer timeout rather than silently ignoring the device.
There are three behavior differences.
1. Timeout is applied to both devices at once, not separately. This
is more consistent with what the spec says.
2. When a device passes devchk but fails to become ready before
deadline. Previouly, post_reset would just succeed and let
device classification remove the device. New code fails the
reset thus causing reset retry. After a few times, EH will give
up disabling the port.
3. When slave device passes devchk but fails to become accessible
(TF-wise) after reset. Original code disables dev1 after 30s
timeout and continues as if the device doesn't exist, while the
patched code fails reset. When this happens, new code fails
reset on whole port rather than proceeding with only the primary
device.
If the failing device is suffering transient problems, new code
retries reset which is a better behavior. If the failing device is
actually broken, the net effect is identical to it, but not to the
other device sharing the channel. In the previous code, reset would
have succeeded after 30s thus detecting the working one. In the new
code, reset fails and whole port gets disabled. IMO, it's a
pathological case anyway (broken device sharing bus with working
one) and doesn't really matter.
* ata_bus_softreset() is changed to return error code from
ata_bus_post_reset(). It used to return 0 unconditionally.
* Spin up waiting is to be removed and not converted to honor
deadline.
* To be on the safe side, deadline is set to 40s for the time being.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-02-02 00:50:52 -07:00
|
|
|
unsigned long deadline)
|
2006-11-01 02:00:24 -07:00
|
|
|
{
|
2007-08-06 02:36:23 -07:00
|
|
|
struct ata_port *ap = link->ap;
|
2008-04-07 06:47:19 -07:00
|
|
|
bool online;
|
2006-11-01 02:00:24 -07:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
DPRINTK("ENTER\n");
|
|
|
|
|
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 07:44:08 -07:00
|
|
|
ahci_stop_engine(ap);
|
2006-11-01 02:00:24 -07:00
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context),
|
2008-04-07 06:47:19 -07:00
|
|
|
deadline, &online, NULL);
|
2006-11-01 02:00:24 -07: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 07:44:08 -07:00
|
|
|
ahci_start_engine(ap);
|
2006-11-01 02:00:24 -07:00
|
|
|
|
|
|
|
DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class);
|
|
|
|
|
|
|
|
/* vt8251 doesn't clear BSY on signature FIS reception,
|
|
|
|
* request follow-up softreset.
|
|
|
|
*/
|
2008-04-07 06:47:19 -07:00
|
|
|
return online ? -EAGAIN : rc;
|
2006-11-01 02:00:24 -07:00
|
|
|
}
|
|
|
|
|
2007-10-24 22:59:16 -07:00
|
|
|
static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
|
|
|
|
unsigned long deadline)
|
|
|
|
{
|
|
|
|
struct ata_port *ap = link->ap;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
|
|
|
|
struct ata_taskfile tf;
|
2008-04-07 06:47:19 -07:00
|
|
|
bool online;
|
2007-10-24 22:59:16 -07:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
ahci_stop_engine(ap);
|
|
|
|
|
|
|
|
/* clear D2H reception area to properly wait for D2H FIS */
|
|
|
|
ata_tf_init(link->device, &tf);
|
|
|
|
tf.command = 0x80;
|
|
|
|
ata_tf_to_fis(&tf, 0, 0, d2h_fis);
|
|
|
|
|
|
|
|
rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context),
|
2008-04-07 06:47:19 -07:00
|
|
|
deadline, &online, NULL);
|
2007-10-24 22:59:16 -07:00
|
|
|
|
|
|
|
ahci_start_engine(ap);
|
|
|
|
|
|
|
|
/* The pseudo configuration device on SIMG4726 attached to
|
|
|
|
* ASUS P5W-DH Deluxe doesn't send signature FIS after
|
|
|
|
* hardreset if no device is attached to the first downstream
|
|
|
|
* port && the pseudo device locks up on SRST w/ PMP==0. To
|
|
|
|
* work around this, wait for !BSY only briefly. If BSY isn't
|
|
|
|
* cleared, perform CLO and proceed to IDENTIFY (achieved by
|
|
|
|
* ATA_LFLAG_NO_SRST and ATA_LFLAG_ASSUME_ATA).
|
|
|
|
*
|
|
|
|
* Wait for two seconds. Devices attached to downstream port
|
|
|
|
* which can't process the following IDENTIFY after this will
|
|
|
|
* have to be reset again. For most cases, this should
|
|
|
|
* suffice while making probing snappish enough.
|
|
|
|
*/
|
2008-04-07 06:47:19 -07:00
|
|
|
if (online) {
|
|
|
|
rc = ata_wait_after_reset(link, jiffies + 2 * HZ,
|
|
|
|
ahci_check_ready);
|
|
|
|
if (rc)
|
2009-08-07 00:05:52 -07:00
|
|
|
ahci_kick_engine(ap);
|
2008-04-07 06:47:19 -07:00
|
|
|
}
|
|
|
|
return rc;
|
2007-10-24 22:59:16 -07:00
|
|
|
}
|
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
static void ahci_postreset(struct ata_link *link, unsigned int *class)
|
2006-02-11 00:26:02 -07:00
|
|
|
{
|
2007-08-06 02:36:23 -07:00
|
|
|
struct ata_port *ap = link->ap;
|
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 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-02-11 00:26:02 -07:00
|
|
|
u32 new_tmp, tmp;
|
|
|
|
|
2008-04-07 06:47:18 -07:00
|
|
|
ata_std_postreset(link, class);
|
2005-11-11 23:32:19 -07:00
|
|
|
|
|
|
|
/* Make sure port's ATAPI bit is set appropriately */
|
|
|
|
new_tmp = tmp = readl(port_mmio + PORT_CMD);
|
2006-02-11 00:26:02 -07:00
|
|
|
if (*class == ATA_DEV_ATAPI)
|
2005-11-11 23:32:19 -07:00
|
|
|
new_tmp |= PORT_CMD_ATAPI;
|
|
|
|
else
|
|
|
|
new_tmp &= ~PORT_CMD_ATAPI;
|
|
|
|
if (new_tmp != tmp) {
|
|
|
|
writel(new_tmp, port_mmio + PORT_CMD);
|
|
|
|
readl(port_mmio + PORT_CMD); /* flush */
|
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2006-05-15 05:03:55 -07:00
|
|
|
static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2005-10-05 04:13:30 -07:00
|
|
|
struct scatterlist *sg;
|
2007-12-05 00:43:11 -07:00
|
|
|
struct ahci_sg *ahci_sg = cmd_tbl + AHCI_CMD_TBL_HDR_SZ;
|
|
|
|
unsigned int si;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Next, the S/G list.
|
|
|
|
*/
|
2007-12-05 00:43:11 -07:00
|
|
|
for_each_sg(qc->sg, sg, qc->n_elem, si) {
|
2005-10-05 04:13:30 -07:00
|
|
|
dma_addr_t addr = sg_dma_address(sg);
|
|
|
|
u32 sg_len = sg_dma_len(sg);
|
|
|
|
|
2007-12-05 00:43:11 -07:00
|
|
|
ahci_sg[si].addr = cpu_to_le32(addr & 0xffffffff);
|
|
|
|
ahci_sg[si].addr_hi = cpu_to_le32((addr >> 16) >> 16);
|
|
|
|
ahci_sg[si].flags_size = cpu_to_le32(sg_len - 1);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2005-11-11 23:27:07 -07:00
|
|
|
|
2007-12-05 00:43:11 -07:00
|
|
|
return si;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2009-12-09 02:23:04 -07:00
|
|
|
static int ahci_pmp_qc_defer(struct ata_queued_cmd *qc)
|
|
|
|
{
|
|
|
|
struct ata_port *ap = qc->ap;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
|
|
|
|
if (!sata_pmp_attached(ap) || pp->fbs_enabled)
|
|
|
|
return ata_std_qc_defer(qc);
|
|
|
|
else
|
|
|
|
return sata_pmp_qc_defer_cmd_switch(qc);
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
static void ahci_qc_prep(struct ata_queued_cmd *qc)
|
|
|
|
{
|
2005-06-03 22:13:15 -07:00
|
|
|
struct ata_port *ap = qc->ap;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-11-27 03:28:53 -07:00
|
|
|
int is_atapi = ata_is_atapi(qc->tf.protocol);
|
2006-05-15 05:03:55 -07:00
|
|
|
void *cmd_tbl;
|
2005-04-16 15:20:36 -07:00
|
|
|
u32 opts;
|
|
|
|
const u32 cmd_fis_len = 5; /* five dwords */
|
2005-11-11 23:27:07 -07:00
|
|
|
unsigned int n_elem;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in command table information. First, the header,
|
|
|
|
* a SATA Register - Host to Device command FIS.
|
|
|
|
*/
|
2006-05-15 05:03:55 -07:00
|
|
|
cmd_tbl = pp->cmd_tbl + qc->tag * AHCI_CMD_TBL_SZ;
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, cmd_tbl);
|
2006-02-10 01:25:47 -07:00
|
|
|
if (is_atapi) {
|
2006-05-15 05:03:55 -07:00
|
|
|
memset(cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32);
|
|
|
|
memcpy(cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, qc->dev->cdb_len);
|
2005-06-03 22:13:15 -07:00
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-02-10 01:25:47 -07:00
|
|
|
n_elem = 0;
|
|
|
|
if (qc->flags & ATA_QCFLAG_DMAMAP)
|
2006-05-15 05:03:55 -07:00
|
|
|
n_elem = ahci_fill_sg(qc, cmd_tbl);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-02-10 01:25:47 -07:00
|
|
|
/*
|
|
|
|
* Fill in command slot information.
|
|
|
|
*/
|
2007-09-22 21:19:54 -07:00
|
|
|
opts = cmd_fis_len | n_elem << 16 | (qc->dev->link->pmp << 12);
|
2006-02-10 01:25:47 -07:00
|
|
|
if (qc->tf.flags & ATA_TFLAG_WRITE)
|
|
|
|
opts |= AHCI_CMD_WRITE;
|
|
|
|
if (is_atapi)
|
2006-03-11 19:25:27 -07:00
|
|
|
opts |= AHCI_CMD_ATAPI | AHCI_CMD_PREFETCH;
|
2005-11-11 23:27:07 -07:00
|
|
|
|
2006-05-15 05:03:55 -07:00
|
|
|
ahci_fill_cmd_slot(pp, qc->tag, opts);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2009-12-09 02:23:04 -07:00
|
|
|
static void ahci_fbs_dec_intr(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
u32 fbs = readl(port_mmio + PORT_FBS);
|
|
|
|
int retries = 3;
|
|
|
|
|
|
|
|
DPRINTK("ENTER\n");
|
|
|
|
BUG_ON(!pp->fbs_enabled);
|
|
|
|
|
|
|
|
/* time to wait for DEC is not specified by AHCI spec,
|
|
|
|
* add a retry loop for safety.
|
|
|
|
*/
|
|
|
|
writel(fbs | PORT_FBS_DEC, port_mmio + PORT_FBS);
|
|
|
|
fbs = readl(port_mmio + PORT_FBS);
|
|
|
|
while ((fbs & PORT_FBS_DEC) && retries--) {
|
|
|
|
udelay(1);
|
|
|
|
fbs = readl(port_mmio + PORT_FBS);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fbs & PORT_FBS_DEC)
|
|
|
|
dev_printk(KERN_ERR, ap->host->dev,
|
|
|
|
"failed to clear device error\n");
|
|
|
|
}
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2007-09-22 21:19:55 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2006-05-15 04:58:29 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-09-22 21:19:54 -07:00
|
|
|
struct ata_eh_info *host_ehi = &ap->link.eh_info;
|
|
|
|
struct ata_link *link = NULL;
|
|
|
|
struct ata_queued_cmd *active_qc;
|
|
|
|
struct ata_eh_info *active_ehi;
|
2009-12-09 02:23:04 -07:00
|
|
|
bool fbs_need_dec = false;
|
2006-05-15 04:58:29 -07:00
|
|
|
u32 serror;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-12-09 02:23:04 -07:00
|
|
|
/* determine active link with error */
|
|
|
|
if (pp->fbs_enabled) {
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
u32 fbs = readl(port_mmio + PORT_FBS);
|
|
|
|
int pmp = fbs >> PORT_FBS_DWE_OFFSET;
|
|
|
|
|
|
|
|
if ((fbs & PORT_FBS_SDE) && (pmp < ap->nr_pmp_links) &&
|
|
|
|
ata_link_online(&ap->pmp_link[pmp])) {
|
|
|
|
link = &ap->pmp_link[pmp];
|
|
|
|
fbs_need_dec = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else
|
|
|
|
ata_for_each_link(link, ap, EDGE)
|
|
|
|
if (ata_link_active(link))
|
|
|
|
break;
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
if (!link)
|
|
|
|
link = &ap->link;
|
|
|
|
|
|
|
|
active_qc = ata_qc_from_tag(ap, link->active_tag);
|
|
|
|
active_ehi = &link->eh_info;
|
|
|
|
|
|
|
|
/* record irq stat */
|
|
|
|
ata_ehi_clear_desc(host_ehi);
|
|
|
|
ata_ehi_push_desc(host_ehi, "irq_stat 0x%08x", irq_stat);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
/* AHCI needs SError cleared; otherwise, it might lock up */
|
2008-07-31 01:02:40 -07:00
|
|
|
ahci_scr_read(&ap->link, SCR_ERROR, &serror);
|
|
|
|
ahci_scr_write(&ap->link, SCR_ERROR, serror);
|
2007-09-22 21:19:54 -07:00
|
|
|
host_ehi->serror |= serror;
|
2006-05-15 04:58:29 -07:00
|
|
|
|
2006-11-28 19:33:14 -07:00
|
|
|
/* some controllers set IRQ_IF_ERR on device errors, ignore it */
|
2007-09-22 21:19:55 -07:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_IGN_IRQ_IF_ERR)
|
2006-11-28 19:33:14 -07:00
|
|
|
irq_stat &= ~PORT_IRQ_IF_ERR;
|
|
|
|
|
2007-03-27 03:33:05 -07:00
|
|
|
if (irq_stat & PORT_IRQ_TF_ERR) {
|
2007-09-22 21:19:54 -07:00
|
|
|
/* If qc is active, charge it; otherwise, the active
|
|
|
|
* link. There's no active qc on NCQ errors. It will
|
|
|
|
* be determined by EH by reading log page 10h.
|
|
|
|
*/
|
|
|
|
if (active_qc)
|
|
|
|
active_qc->err_mask |= AC_ERR_DEV;
|
|
|
|
else
|
|
|
|
active_ehi->err_mask |= AC_ERR_DEV;
|
|
|
|
|
2007-09-22 21:19:55 -07:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_IGN_SERR_INTERNAL)
|
2007-09-22 21:19:54 -07:00
|
|
|
host_ehi->serror &= ~SERR_INTERNAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (irq_stat & PORT_IRQ_UNK_FIS) {
|
|
|
|
u32 *unk = (u32 *)(pp->rx_fis + RX_FIS_UNK);
|
|
|
|
|
|
|
|
active_ehi->err_mask |= AC_ERR_HSM;
|
libata: prefer hardreset
When both soft and hard resets are available, libata preferred
softreset till now. The logic behind it was to be softer to devices;
however, this doesn't really help much. Rationales for the change:
* BIOS may freeze lock certain things during boot and softreset can't
unlock those. This by itself is okay but during operation PHY event
or other error conditions can trigger hardreset and the device may
end up with different configuration.
For example, after a hardreset, previously unlockable HPA can be
unlocked resulting in different device size and thus revalidation
failure. Similar condition can occur during or after resume.
* Certain ATAPI devices require hardreset to recover after certain
error conditions. On PATA, this is done by issuing the DEVICE RESET
command. On SATA, COMRESET has equivalent effect. The problem is
that DEVICE RESET needs its own execution protocol.
For SFF controllers with bare TF access, it can be easily
implemented but more advanced controllers (e.g. ahci and sata_sil24)
require specialized implementations. Simply using hardreset solves
the problem nicely.
* COMRESET initialization sequence is the norm in SATA land and many
SATA devices don't work properly if only SRST is used. For example,
some PMPs behave this way and libata works around by always issuing
hardreset if the host supports PMP.
Like the above example, libata has developed a number of mechanisms
aiming to promote softreset to hardreset if softreset is not going
to work. This approach is time consuming and error prone.
Also, note that, dependingon how you read the specs, it could be
argued that PMP fan-out ports require COMRESET to start operation.
In fact, all the PMPs on the market except one don't work properly
if COMRESET is not issued to fan-out ports after PMP reset.
* COMRESET is an integral part of SATA connection and any working
device should be able to handle COMRESET properly. After all, it's
the way to signal hardreset during reboot. This is the most used
and recommended (at least by the ahci spec) method of resetting
devices.
So, this patch makes libata prefer hardreset over softreset by making
the following changes.
* Rename ATA_EH_RESET_MASK to ATA_EH_RESET and use it whereever
ATA_EH_{SOFT|HARD}RESET used to be used. ATA_EH_{SOFT|HARD}RESET is
now only used to tell prereset whether soft or hard reset will be
issued.
* Strip out now unneeded promote-to-hardreset logics from
ata_eh_reset(), ata_std_prereset(), sata_pmp_std_prereset() and
other places.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-01-23 08:05:14 -07:00
|
|
|
active_ehi->action |= ATA_EH_RESET;
|
2007-09-22 21:19:54 -07:00
|
|
|
ata_ehi_push_desc(active_ehi,
|
|
|
|
"unknown FIS %08x %08x %08x %08x" ,
|
|
|
|
unk[0], unk[1], unk[2], unk[3]);
|
|
|
|
}
|
|
|
|
|
2008-04-07 06:47:22 -07:00
|
|
|
if (sata_pmp_attached(ap) && (irq_stat & PORT_IRQ_BAD_PMP)) {
|
2007-09-22 21:19:54 -07:00
|
|
|
active_ehi->err_mask |= AC_ERR_HSM;
|
libata: prefer hardreset
When both soft and hard resets are available, libata preferred
softreset till now. The logic behind it was to be softer to devices;
however, this doesn't really help much. Rationales for the change:
* BIOS may freeze lock certain things during boot and softreset can't
unlock those. This by itself is okay but during operation PHY event
or other error conditions can trigger hardreset and the device may
end up with different configuration.
For example, after a hardreset, previously unlockable HPA can be
unlocked resulting in different device size and thus revalidation
failure. Similar condition can occur during or after resume.
* Certain ATAPI devices require hardreset to recover after certain
error conditions. On PATA, this is done by issuing the DEVICE RESET
command. On SATA, COMRESET has equivalent effect. The problem is
that DEVICE RESET needs its own execution protocol.
For SFF controllers with bare TF access, it can be easily
implemented but more advanced controllers (e.g. ahci and sata_sil24)
require specialized implementations. Simply using hardreset solves
the problem nicely.
* COMRESET initialization sequence is the norm in SATA land and many
SATA devices don't work properly if only SRST is used. For example,
some PMPs behave this way and libata works around by always issuing
hardreset if the host supports PMP.
Like the above example, libata has developed a number of mechanisms
aiming to promote softreset to hardreset if softreset is not going
to work. This approach is time consuming and error prone.
Also, note that, dependingon how you read the specs, it could be
argued that PMP fan-out ports require COMRESET to start operation.
In fact, all the PMPs on the market except one don't work properly
if COMRESET is not issued to fan-out ports after PMP reset.
* COMRESET is an integral part of SATA connection and any working
device should be able to handle COMRESET properly. After all, it's
the way to signal hardreset during reboot. This is the most used
and recommended (at least by the ahci spec) method of resetting
devices.
So, this patch makes libata prefer hardreset over softreset by making
the following changes.
* Rename ATA_EH_RESET_MASK to ATA_EH_RESET and use it whereever
ATA_EH_{SOFT|HARD}RESET used to be used. ATA_EH_{SOFT|HARD}RESET is
now only used to tell prereset whether soft or hard reset will be
issued.
* Strip out now unneeded promote-to-hardreset logics from
ata_eh_reset(), ata_std_prereset(), sata_pmp_std_prereset() and
other places.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-01-23 08:05:14 -07:00
|
|
|
active_ehi->action |= ATA_EH_RESET;
|
2007-09-22 21:19:54 -07:00
|
|
|
ata_ehi_push_desc(active_ehi, "incorrect PMP");
|
2007-03-27 03:33:05 -07:00
|
|
|
}
|
2006-05-15 04:58:29 -07:00
|
|
|
|
|
|
|
if (irq_stat & (PORT_IRQ_HBUS_ERR | PORT_IRQ_HBUS_DATA_ERR)) {
|
2007-09-22 21:19:54 -07:00
|
|
|
host_ehi->err_mask |= AC_ERR_HOST_BUS;
|
libata: prefer hardreset
When both soft and hard resets are available, libata preferred
softreset till now. The logic behind it was to be softer to devices;
however, this doesn't really help much. Rationales for the change:
* BIOS may freeze lock certain things during boot and softreset can't
unlock those. This by itself is okay but during operation PHY event
or other error conditions can trigger hardreset and the device may
end up with different configuration.
For example, after a hardreset, previously unlockable HPA can be
unlocked resulting in different device size and thus revalidation
failure. Similar condition can occur during or after resume.
* Certain ATAPI devices require hardreset to recover after certain
error conditions. On PATA, this is done by issuing the DEVICE RESET
command. On SATA, COMRESET has equivalent effect. The problem is
that DEVICE RESET needs its own execution protocol.
For SFF controllers with bare TF access, it can be easily
implemented but more advanced controllers (e.g. ahci and sata_sil24)
require specialized implementations. Simply using hardreset solves
the problem nicely.
* COMRESET initialization sequence is the norm in SATA land and many
SATA devices don't work properly if only SRST is used. For example,
some PMPs behave this way and libata works around by always issuing
hardreset if the host supports PMP.
Like the above example, libata has developed a number of mechanisms
aiming to promote softreset to hardreset if softreset is not going
to work. This approach is time consuming and error prone.
Also, note that, dependingon how you read the specs, it could be
argued that PMP fan-out ports require COMRESET to start operation.
In fact, all the PMPs on the market except one don't work properly
if COMRESET is not issued to fan-out ports after PMP reset.
* COMRESET is an integral part of SATA connection and any working
device should be able to handle COMRESET properly. After all, it's
the way to signal hardreset during reboot. This is the most used
and recommended (at least by the ahci spec) method of resetting
devices.
So, this patch makes libata prefer hardreset over softreset by making
the following changes.
* Rename ATA_EH_RESET_MASK to ATA_EH_RESET and use it whereever
ATA_EH_{SOFT|HARD}RESET used to be used. ATA_EH_{SOFT|HARD}RESET is
now only used to tell prereset whether soft or hard reset will be
issued.
* Strip out now unneeded promote-to-hardreset logics from
ata_eh_reset(), ata_std_prereset(), sata_pmp_std_prereset() and
other places.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-01-23 08:05:14 -07:00
|
|
|
host_ehi->action |= ATA_EH_RESET;
|
2007-09-22 21:19:54 -07:00
|
|
|
ata_ehi_push_desc(host_ehi, "host bus error");
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
if (irq_stat & PORT_IRQ_IF_ERR) {
|
2009-12-09 02:23:04 -07:00
|
|
|
if (fbs_need_dec)
|
|
|
|
active_ehi->err_mask |= AC_ERR_DEV;
|
|
|
|
else {
|
|
|
|
host_ehi->err_mask |= AC_ERR_ATA_BUS;
|
|
|
|
host_ehi->action |= ATA_EH_RESET;
|
|
|
|
}
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
ata_ehi_push_desc(host_ehi, "interface fatal error");
|
2006-05-15 04:58:29 -07:00
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
if (irq_stat & (PORT_IRQ_CONNECT | PORT_IRQ_PHYRDY)) {
|
2007-09-22 21:19:54 -07:00
|
|
|
ata_ehi_hotplugged(host_ehi);
|
|
|
|
ata_ehi_push_desc(host_ehi, "%s",
|
|
|
|
irq_stat & PORT_IRQ_CONNECT ?
|
2006-05-15 04:58:29 -07:00
|
|
|
"connection status changed" : "PHY RDY changed");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* okay, let's hand over to EH */
|
2006-01-22 21:09:37 -07:00
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
if (irq_stat & PORT_IRQ_FREEZE)
|
|
|
|
ata_port_freeze(ap);
|
2009-12-09 02:23:04 -07:00
|
|
|
else if (fbs_need_dec) {
|
|
|
|
ata_link_abort(link);
|
|
|
|
ahci_fbs_dec_intr(ap);
|
|
|
|
} else
|
2006-05-15 04:58:29 -07:00
|
|
|
ata_port_abort(ap);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2007-05-26 17:46:51 -07:00
|
|
|
static void ahci_port_intr(struct ata_port *ap)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2008-04-07 06:47:21 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-08-06 02:36:22 -07:00
|
|
|
struct ata_eh_info *ehi = &ap->link.eh_info;
|
2007-01-25 03:16:28 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-10-08 23:02:23 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2007-10-08 23:06:48 -07:00
|
|
|
int resetting = !!(ap->pflags & ATA_PFLAG_RESETTING);
|
2010-03-16 03:08:55 -07:00
|
|
|
u32 status, qc_active = 0;
|
2007-12-06 20:46:23 -07:00
|
|
|
int rc;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
status = readl(port_mmio + PORT_IRQ_STAT);
|
|
|
|
writel(status, port_mmio + PORT_IRQ_STAT);
|
|
|
|
|
2007-10-08 23:06:48 -07:00
|
|
|
/* ignore BAD_PMP while resetting */
|
|
|
|
if (unlikely(resetting))
|
|
|
|
status &= ~PORT_IRQ_BAD_PMP;
|
|
|
|
|
2007-10-24 22:33:26 -07:00
|
|
|
/* If we are getting PhyRdy, this is
|
|
|
|
* just a power state change, we should
|
|
|
|
* clear out this, plus the PhyRdy/Comm
|
|
|
|
* Wake bits from Serror
|
|
|
|
*/
|
|
|
|
if ((hpriv->flags & AHCI_HFLAG_NO_HOTPLUG) &&
|
|
|
|
(status & PORT_IRQ_PHYRDY)) {
|
|
|
|
status &= ~PORT_IRQ_PHYRDY;
|
2008-07-31 01:02:40 -07:00
|
|
|
ahci_scr_write(&ap->link, SCR_ERROR, ((1 << 16) | (1 << 18)));
|
2007-10-24 22:33:26 -07:00
|
|
|
}
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
if (unlikely(status & PORT_IRQ_ERROR)) {
|
|
|
|
ahci_error_intr(ap, status);
|
|
|
|
return;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2007-08-15 01:11:25 -07:00
|
|
|
if (status & PORT_IRQ_SDB_FIS) {
|
2007-10-08 23:02:23 -07:00
|
|
|
/* If SNotification is available, leave notification
|
|
|
|
* handling to sata_async_notification(). If not,
|
|
|
|
* emulate it by snooping SDB FIS RX area.
|
|
|
|
*
|
|
|
|
* Snooping FIS RX area is probably cheaper than
|
|
|
|
* poking SNotification but some constrollers which
|
|
|
|
* implement SNotification, ICH9 for example, don't
|
|
|
|
* store AN SDB FIS into receive area.
|
2007-08-15 01:11:25 -07:00
|
|
|
*/
|
2007-10-08 23:02:23 -07:00
|
|
|
if (hpriv->cap & HOST_CAP_SNTF)
|
2007-09-22 21:14:13 -07:00
|
|
|
sata_async_notification(ap);
|
2007-10-08 23:02:23 -07:00
|
|
|
else {
|
|
|
|
/* If the 'N' bit in word 0 of the FIS is set,
|
|
|
|
* we just received asynchronous notification.
|
|
|
|
* Tell libata about it.
|
2009-12-09 02:23:04 -07:00
|
|
|
*
|
|
|
|
* Lack of SNotification should not appear in
|
|
|
|
* ahci 1.2, so the workaround is unnecessary
|
|
|
|
* when FBS is enabled.
|
2007-10-08 23:02:23 -07:00
|
|
|
*/
|
2009-12-09 02:23:04 -07:00
|
|
|
if (pp->fbs_enabled)
|
|
|
|
WARN_ON_ONCE(1);
|
|
|
|
else {
|
|
|
|
const __le32 *f = pp->rx_fis + RX_FIS_SDB;
|
|
|
|
u32 f0 = le32_to_cpu(f[0]);
|
|
|
|
if (f0 & (1 << 15))
|
|
|
|
sata_async_notification(ap);
|
|
|
|
}
|
2007-10-08 23:02:23 -07:00
|
|
|
}
|
2007-08-15 01:11:25 -07:00
|
|
|
}
|
|
|
|
|
2010-03-16 03:08:55 -07:00
|
|
|
/* pp->active_link is not reliable once FBS is enabled, both
|
|
|
|
* PORT_SCR_ACT and PORT_CMD_ISSUE should be checked because
|
|
|
|
* NCQ and non-NCQ commands may be in flight at the same time.
|
|
|
|
*/
|
|
|
|
if (pp->fbs_enabled) {
|
|
|
|
if (ap->qc_active) {
|
|
|
|
qc_active = readl(port_mmio + PORT_SCR_ACT);
|
|
|
|
qc_active |= readl(port_mmio + PORT_CMD_ISSUE);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* pp->active_link is valid iff any command is in flight */
|
|
|
|
if (ap->qc_active && pp->active_link->sactive)
|
|
|
|
qc_active = readl(port_mmio + PORT_SCR_ACT);
|
|
|
|
else
|
|
|
|
qc_active = readl(port_mmio + PORT_CMD_ISSUE);
|
|
|
|
}
|
2006-05-15 05:03:55 -07:00
|
|
|
|
2008-04-07 06:47:20 -07:00
|
|
|
rc = ata_qc_complete_multiple(ap, qc_active);
|
2007-10-08 23:06:48 -07:00
|
|
|
|
2007-12-06 20:46:23 -07:00
|
|
|
/* while resetting, invalid completions are expected */
|
|
|
|
if (unlikely(rc < 0 && !resetting)) {
|
2006-05-15 05:03:55 -07:00
|
|
|
ehi->err_mask |= AC_ERR_HSM;
|
libata: prefer hardreset
When both soft and hard resets are available, libata preferred
softreset till now. The logic behind it was to be softer to devices;
however, this doesn't really help much. Rationales for the change:
* BIOS may freeze lock certain things during boot and softreset can't
unlock those. This by itself is okay but during operation PHY event
or other error conditions can trigger hardreset and the device may
end up with different configuration.
For example, after a hardreset, previously unlockable HPA can be
unlocked resulting in different device size and thus revalidation
failure. Similar condition can occur during or after resume.
* Certain ATAPI devices require hardreset to recover after certain
error conditions. On PATA, this is done by issuing the DEVICE RESET
command. On SATA, COMRESET has equivalent effect. The problem is
that DEVICE RESET needs its own execution protocol.
For SFF controllers with bare TF access, it can be easily
implemented but more advanced controllers (e.g. ahci and sata_sil24)
require specialized implementations. Simply using hardreset solves
the problem nicely.
* COMRESET initialization sequence is the norm in SATA land and many
SATA devices don't work properly if only SRST is used. For example,
some PMPs behave this way and libata works around by always issuing
hardreset if the host supports PMP.
Like the above example, libata has developed a number of mechanisms
aiming to promote softreset to hardreset if softreset is not going
to work. This approach is time consuming and error prone.
Also, note that, dependingon how you read the specs, it could be
argued that PMP fan-out ports require COMRESET to start operation.
In fact, all the PMPs on the market except one don't work properly
if COMRESET is not issued to fan-out ports after PMP reset.
* COMRESET is an integral part of SATA connection and any working
device should be able to handle COMRESET properly. After all, it's
the way to signal hardreset during reboot. This is the most used
and recommended (at least by the ahci spec) method of resetting
devices.
So, this patch makes libata prefer hardreset over softreset by making
the following changes.
* Rename ATA_EH_RESET_MASK to ATA_EH_RESET and use it whereever
ATA_EH_{SOFT|HARD}RESET used to be used. ATA_EH_{SOFT|HARD}RESET is
now only used to tell prereset whether soft or hard reset will be
issued.
* Strip out now unneeded promote-to-hardreset logics from
ata_eh_reset(), ata_std_prereset(), sata_pmp_std_prereset() and
other places.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-01-23 08:05:14 -07:00
|
|
|
ehi->action |= ATA_EH_RESET;
|
2006-05-15 05:03:55 -07:00
|
|
|
ata_port_freeze(ap);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 06:55:46 -07:00
|
|
|
static irqreturn_t ahci_interrupt(int irq, void *dev_instance)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2006-08-24 00:19:22 -07:00
|
|
|
struct ata_host *host = dev_instance;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ahci_host_priv *hpriv;
|
|
|
|
unsigned int i, handled = 0;
|
2005-08-30 02:18:18 -07:00
|
|
|
void __iomem *mmio;
|
2008-07-04 21:10:50 -07:00
|
|
|
u32 irq_stat, irq_masked;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
2006-08-24 00:19:22 -07:00
|
|
|
hpriv = host->private_data;
|
2010-03-03 10:17:34 -07:00
|
|
|
mmio = hpriv->mmio;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* sigh. 0xffffffff is a valid return from h/w */
|
|
|
|
irq_stat = readl(mmio + HOST_IRQ_STAT);
|
|
|
|
if (!irq_stat)
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
2008-07-04 21:10:50 -07:00
|
|
|
irq_masked = irq_stat & hpriv->port_map;
|
|
|
|
|
2007-10-19 03:42:56 -07:00
|
|
|
spin_lock(&host->lock);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-10-19 03:42:56 -07:00
|
|
|
for (i = 0; i < host->n_ports; i++) {
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ata_port *ap;
|
|
|
|
|
2008-07-04 21:10:50 -07:00
|
|
|
if (!(irq_masked & (1 << i)))
|
2005-10-04 23:58:32 -07:00
|
|
|
continue;
|
|
|
|
|
2006-08-24 00:19:22 -07:00
|
|
|
ap = host->ports[i];
|
2005-10-04 23:58:32 -07:00
|
|
|
if (ap) {
|
2007-05-26 17:46:51 -07:00
|
|
|
ahci_port_intr(ap);
|
2005-10-04 23:58:32 -07:00
|
|
|
VPRINTK("port %u\n", i);
|
|
|
|
} else {
|
|
|
|
VPRINTK("port %u (no irq)\n", i);
|
2006-03-10 20:47:54 -07:00
|
|
|
if (ata_ratelimit())
|
2006-08-24 00:19:22 -07:00
|
|
|
dev_printk(KERN_WARNING, host->dev,
|
2005-10-30 12:39:11 -07:00
|
|
|
"interrupt on disabled port %u\n", i);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2005-10-04 23:58:32 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
handled = 1;
|
|
|
|
}
|
|
|
|
|
2008-07-04 21:10:50 -07:00
|
|
|
/* HOST_IRQ_STAT behaves as level triggered latch meaning that
|
|
|
|
* it should be cleared after all the port events are cleared;
|
|
|
|
* otherwise, it will raise a spurious interrupt after each
|
|
|
|
* valid one. Please read section 10.6.2 of ahci 1.1 for more
|
|
|
|
* information.
|
|
|
|
*
|
|
|
|
* Also, use the unmasked value to clear interrupt as spurious
|
|
|
|
* pending event on a dummy port might cause screaming IRQ.
|
|
|
|
*/
|
2008-06-27 09:49:02 -07:00
|
|
|
writel(irq_stat, mmio + HOST_IRQ_STAT);
|
|
|
|
|
2006-08-24 00:19:22 -07:00
|
|
|
spin_unlock(&host->lock);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
VPRINTK("EXIT\n");
|
|
|
|
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
}
|
|
|
|
|
2006-01-22 21:09:36 -07:00
|
|
|
static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
struct ata_port *ap = qc->ap;
|
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 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-09-22 21:19:54 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
|
|
|
|
/* Keep track of the currently active link. It will be used
|
|
|
|
* in completion path to determine whether NCQ phase is in
|
|
|
|
* progress.
|
|
|
|
*/
|
|
|
|
pp->active_link = qc->dev->link;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-05-15 05:03:55 -07:00
|
|
|
if (qc->tf.protocol == ATA_PROT_NCQ)
|
|
|
|
writel(1 << qc->tag, port_mmio + PORT_SCR_ACT);
|
2009-12-09 02:23:04 -07:00
|
|
|
|
|
|
|
if (pp->fbs_enabled && pp->fbs_last_dev != qc->dev->link->pmp) {
|
|
|
|
u32 fbs = readl(port_mmio + PORT_FBS);
|
|
|
|
fbs &= ~(PORT_FBS_DEV_MASK | PORT_FBS_DEC);
|
|
|
|
fbs |= qc->dev->link->pmp << PORT_FBS_DEV_OFFSET;
|
|
|
|
writel(fbs, port_mmio + PORT_FBS);
|
|
|
|
pp->fbs_last_dev = qc->dev->link->pmp;
|
|
|
|
}
|
|
|
|
|
2006-05-15 05:03:55 -07:00
|
|
|
writel(1 << qc->tag, port_mmio + PORT_CMD_ISSUE);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-06-03 10:33:55 -07:00
|
|
|
ahci_sw_activity(qc->dev->link);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-07 06:47:20 -07:00
|
|
|
static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
|
|
|
|
{
|
|
|
|
struct ahci_port_priv *pp = qc->ap->private_data;
|
|
|
|
u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
|
|
|
|
|
2009-12-09 02:23:04 -07:00
|
|
|
if (pp->fbs_enabled)
|
|
|
|
d2h_fis += qc->dev->link->pmp * AHCI_RX_FIS_SZ;
|
|
|
|
|
2008-04-07 06:47:20 -07:00
|
|
|
ata_tf_from_fis(d2h_fis, &qc->result_tf);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
static void ahci_freeze(struct ata_port *ap)
|
|
|
|
{
|
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 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-05-15 04:58:29 -07:00
|
|
|
|
|
|
|
/* turn IRQ off */
|
|
|
|
writel(0, port_mmio + PORT_IRQ_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_thaw(struct ata_port *ap)
|
|
|
|
{
|
2010-03-03 10:17:34 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
void __iomem *mmio = hpriv->mmio;
|
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 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-05-15 04:58:29 -07:00
|
|
|
u32 tmp;
|
2007-08-09 14:23:41 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2006-05-15 04:58:29 -07:00
|
|
|
|
|
|
|
/* clear IRQ */
|
|
|
|
tmp = readl(port_mmio + PORT_IRQ_STAT);
|
|
|
|
writel(tmp, port_mmio + PORT_IRQ_STAT);
|
2007-01-26 19:04:26 -07:00
|
|
|
writel(1 << ap->port_no, mmio + HOST_IRQ_STAT);
|
2006-05-15 04:58:29 -07:00
|
|
|
|
2007-10-08 23:01:37 -07:00
|
|
|
/* turn IRQ back on */
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
2006-05-15 04:58:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_error_handler(struct ata_port *ap)
|
|
|
|
{
|
2006-06-28 09:29:30 -07:00
|
|
|
if (!(ap->pflags & ATA_PFLAG_FROZEN)) {
|
2006-05-15 04:58:29 -07:00
|
|
|
/* restart engine */
|
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 07:44:08 -07:00
|
|
|
ahci_stop_engine(ap);
|
|
|
|
ahci_start_engine(ap);
|
2006-05-15 04:58:29 -07:00
|
|
|
}
|
|
|
|
|
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-24 20:22:50 -07:00
|
|
|
sata_pmp_error_handler(ap);
|
2007-10-24 22:59:16 -07:00
|
|
|
}
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)
|
|
|
|
{
|
|
|
|
struct ata_port *ap = qc->ap;
|
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
/* make DMA engine forget about the failed command */
|
|
|
|
if (qc->flags & ATA_QCFLAG_FAILED)
|
2009-08-07 00:05:52 -07:00
|
|
|
ahci_kick_engine(ap);
|
2006-05-15 04:58:29 -07:00
|
|
|
}
|
|
|
|
|
2009-12-09 02:23:04 -07:00
|
|
|
static void ahci_enable_fbs(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
u32 fbs;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (!pp->fbs_supported)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fbs = readl(port_mmio + PORT_FBS);
|
|
|
|
if (fbs & PORT_FBS_EN) {
|
|
|
|
pp->fbs_enabled = true;
|
|
|
|
pp->fbs_last_dev = -1; /* initialization */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = ahci_stop_engine(ap);
|
|
|
|
if (rc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
writel(fbs | PORT_FBS_EN, port_mmio + PORT_FBS);
|
|
|
|
fbs = readl(port_mmio + PORT_FBS);
|
|
|
|
if (fbs & PORT_FBS_EN) {
|
|
|
|
dev_printk(KERN_INFO, ap->host->dev, "FBS is enabled.\n");
|
|
|
|
pp->fbs_enabled = true;
|
|
|
|
pp->fbs_last_dev = -1; /* initialization */
|
|
|
|
} else
|
|
|
|
dev_printk(KERN_ERR, ap->host->dev, "Failed to enable FBS\n");
|
|
|
|
|
|
|
|
ahci_start_engine(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_disable_fbs(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
u32 fbs;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (!pp->fbs_supported)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fbs = readl(port_mmio + PORT_FBS);
|
|
|
|
if ((fbs & PORT_FBS_EN) == 0) {
|
|
|
|
pp->fbs_enabled = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = ahci_stop_engine(ap);
|
|
|
|
if (rc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
writel(fbs & ~PORT_FBS_EN, port_mmio + PORT_FBS);
|
|
|
|
fbs = readl(port_mmio + PORT_FBS);
|
|
|
|
if (fbs & PORT_FBS_EN)
|
|
|
|
dev_printk(KERN_ERR, ap->host->dev, "Failed to disable FBS\n");
|
|
|
|
else {
|
|
|
|
dev_printk(KERN_INFO, ap->host->dev, "FBS is disabled.\n");
|
|
|
|
pp->fbs_enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ahci_start_engine(ap);
|
|
|
|
}
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
static void ahci_pmp_attach(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-10-08 23:01:37 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-09-22 21:19:54 -07:00
|
|
|
u32 cmd;
|
|
|
|
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
cmd |= PORT_CMD_PMP;
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
2007-10-08 23:01:37 -07:00
|
|
|
|
2009-12-09 02:23:04 -07:00
|
|
|
ahci_enable_fbs(ap);
|
|
|
|
|
2007-10-08 23:01:37 -07:00
|
|
|
pp->intr_mask |= PORT_IRQ_BAD_PMP;
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
2007-09-22 21:19:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_pmp_detach(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-10-08 23:01:37 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-09-22 21:19:54 -07:00
|
|
|
u32 cmd;
|
|
|
|
|
2009-12-09 02:23:04 -07:00
|
|
|
ahci_disable_fbs(ap);
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
cmd &= ~PORT_CMD_PMP;
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
2007-10-08 23:01:37 -07:00
|
|
|
|
|
|
|
pp->intr_mask &= ~PORT_IRQ_BAD_PMP;
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
2007-09-22 21:19:54 -07:00
|
|
|
}
|
|
|
|
|
2007-07-17 12:48:48 -07:00
|
|
|
static int ahci_port_resume(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
ahci_power_up(ap);
|
|
|
|
ahci_start_port(ap);
|
|
|
|
|
2008-04-07 06:47:22 -07:00
|
|
|
if (sata_pmp_attached(ap))
|
2007-09-22 21:19:54 -07:00
|
|
|
ahci_pmp_attach(ap);
|
|
|
|
else
|
|
|
|
ahci_pmp_detach(ap);
|
|
|
|
|
2007-07-17 12:48:48 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-03-02 01:31:26 -07:00
|
|
|
#ifdef CONFIG_PM
|
2006-07-25 23:59:26 -07:00
|
|
|
static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
|
|
|
|
{
|
|
|
|
const char *emsg = NULL;
|
|
|
|
int 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 07:44:08 -07:00
|
|
|
rc = ahci_deinit_port(ap, &emsg);
|
2006-11-19 23:42:36 -07:00
|
|
|
if (rc == 0)
|
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 07:44:08 -07:00
|
|
|
ahci_power_down(ap);
|
2006-11-19 23:42:36 -07:00
|
|
|
else {
|
2006-07-25 23:59:26 -07:00
|
|
|
ata_port_printk(ap, KERN_ERR, "%s (%d)\n", emsg, rc);
|
2007-05-26 17:46:51 -07:00
|
|
|
ahci_start_port(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
|
|
|
|
{
|
2006-08-24 00:19:22 -07:00
|
|
|
struct ata_host *host = dev_get_drvdata(&pdev->dev);
|
2009-05-30 04:50:12 -07:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
2010-03-03 10:17:34 -07:00
|
|
|
void __iomem *mmio = hpriv->mmio;
|
2006-07-25 23:59:26 -07:00
|
|
|
u32 ctl;
|
|
|
|
|
2009-05-30 04:50:12 -07:00
|
|
|
if (mesg.event & PM_EVENT_SUSPEND &&
|
|
|
|
hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
|
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"BIOS update required for suspend/resume\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2008-02-23 11:13:25 -07:00
|
|
|
if (mesg.event & PM_EVENT_SLEEP) {
|
2006-07-25 23:59:26 -07:00
|
|
|
/* AHCI spec rev1.1 section 8.3.3:
|
|
|
|
* Software must disable interrupts prior to requesting a
|
|
|
|
* transition of the HBA to D3 state.
|
|
|
|
*/
|
|
|
|
ctl = readl(mmio + HOST_CTL);
|
|
|
|
ctl &= ~HOST_IRQ_EN;
|
|
|
|
writel(ctl, mmio + HOST_CTL);
|
|
|
|
readl(mmio + HOST_CTL); /* flush */
|
|
|
|
}
|
|
|
|
|
|
|
|
return ata_pci_device_suspend(pdev, mesg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ahci_pci_device_resume(struct pci_dev *pdev)
|
|
|
|
{
|
2006-08-24 00:19:22 -07:00
|
|
|
struct ata_host *host = dev_get_drvdata(&pdev->dev);
|
2006-07-25 23:59:26 -07:00
|
|
|
int rc;
|
|
|
|
|
2006-12-26 03:39:50 -07:00
|
|
|
rc = ata_pci_device_do_resume(pdev);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
2006-07-25 23:59:26 -07:00
|
|
|
|
|
|
|
if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
|
2010-03-03 10:17:39 -07:00
|
|
|
rc = ahci_pci_reset_controller(host);
|
2006-07-25 23:59:26 -07:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2010-03-03 10:17:42 -07:00
|
|
|
ahci_pci_init_controller(host);
|
2006-07-25 23:59:26 -07:00
|
|
|
}
|
|
|
|
|
2006-08-24 00:19:22 -07:00
|
|
|
ata_host_resume(host);
|
2006-07-25 23:59:26 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-03-02 01:31:26 -07:00
|
|
|
#endif
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2006-07-25 23:59:25 -07:00
|
|
|
static int ahci_port_start(struct ata_port *ap)
|
|
|
|
{
|
2009-12-09 02:23:04 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2006-08-24 00:19:22 -07:00
|
|
|
struct device *dev = ap->host->dev;
|
2006-07-25 23:59:25 -07:00
|
|
|
struct ahci_port_priv *pp;
|
|
|
|
void *mem;
|
|
|
|
dma_addr_t mem_dma;
|
2009-12-09 02:23:04 -07:00
|
|
|
size_t dma_sz, rx_fis_sz;
|
2006-07-25 23:59:25 -07:00
|
|
|
|
2007-01-20 00:00:28 -07:00
|
|
|
pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
|
2006-07-25 23:59:25 -07:00
|
|
|
if (!pp)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2009-12-09 02:23:04 -07:00
|
|
|
/* check FBS capability */
|
|
|
|
if ((hpriv->cap & HOST_CAP_FBS) && sata_pmp_supported(ap)) {
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
u32 cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
if (cmd & PORT_CMD_FBSCP)
|
|
|
|
pp->fbs_supported = true;
|
|
|
|
else
|
|
|
|
dev_printk(KERN_WARNING, dev,
|
|
|
|
"The port is not capable of FBS\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pp->fbs_supported) {
|
|
|
|
dma_sz = AHCI_PORT_PRIV_FBS_DMA_SZ;
|
|
|
|
rx_fis_sz = AHCI_RX_FIS_SZ * 16;
|
|
|
|
} else {
|
|
|
|
dma_sz = AHCI_PORT_PRIV_DMA_SZ;
|
|
|
|
rx_fis_sz = AHCI_RX_FIS_SZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
mem = dmam_alloc_coherent(dev, dma_sz, &mem_dma, GFP_KERNEL);
|
2007-01-20 00:00:28 -07:00
|
|
|
if (!mem)
|
2006-07-25 23:59:25 -07:00
|
|
|
return -ENOMEM;
|
2009-12-09 02:23:04 -07:00
|
|
|
memset(mem, 0, dma_sz);
|
2006-07-25 23:59:25 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First item in chunk of DMA memory: 32-slot command table,
|
|
|
|
* 32 bytes each in size
|
|
|
|
*/
|
|
|
|
pp->cmd_slot = mem;
|
|
|
|
pp->cmd_slot_dma = mem_dma;
|
|
|
|
|
|
|
|
mem += AHCI_CMD_SLOT_SZ;
|
|
|
|
mem_dma += AHCI_CMD_SLOT_SZ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Second item: Received-FIS area
|
|
|
|
*/
|
|
|
|
pp->rx_fis = mem;
|
|
|
|
pp->rx_fis_dma = mem_dma;
|
|
|
|
|
2009-12-09 02:23:04 -07:00
|
|
|
mem += rx_fis_sz;
|
|
|
|
mem_dma += rx_fis_sz;
|
2006-07-25 23:59:25 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Third item: data area for storing a single command
|
|
|
|
* and its scatter-gather table
|
|
|
|
*/
|
|
|
|
pp->cmd_tbl = mem;
|
|
|
|
pp->cmd_tbl_dma = mem_dma;
|
|
|
|
|
2007-08-09 14:23:41 -07:00
|
|
|
/*
|
2007-10-19 03:42:56 -07:00
|
|
|
* Save off initial list of interrupts to be enabled.
|
|
|
|
* This could be changed later
|
|
|
|
*/
|
2007-08-09 14:23:41 -07:00
|
|
|
pp->intr_mask = DEF_PORT_IRQ;
|
|
|
|
|
2006-07-25 23:59:25 -07:00
|
|
|
ap->private_data = pp;
|
|
|
|
|
2007-05-26 17:46:51 -07:00
|
|
|
/* engage engines, captain */
|
|
|
|
return ahci_port_resume(ap);
|
2006-07-25 23:59:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_port_stop(struct ata_port *ap)
|
|
|
|
{
|
2006-07-25 23:59:26 -07:00
|
|
|
const char *emsg = NULL;
|
|
|
|
int rc;
|
2006-07-25 23:59:25 -07:00
|
|
|
|
2006-07-25 23:59:26 -07:00
|
|
|
/* de-initialize port */
|
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 07:44:08 -07:00
|
|
|
rc = ahci_deinit_port(ap, &emsg);
|
2006-07-25 23:59:26 -07:00
|
|
|
if (rc)
|
|
|
|
ata_port_printk(ap, KERN_WARNING, "%s (%d)\n", emsg, rc);
|
2006-07-25 23:59:25 -07: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 07:44:08 -07:00
|
|
|
static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (using_dac &&
|
2009-04-06 19:01:13 -07:00
|
|
|
!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
|
|
|
|
rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
|
2005-04-16 15:20:36 -07:00
|
|
|
if (rc) {
|
2009-04-06 19:01:15 -07:00
|
|
|
rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
|
2005-04-16 15:20:36 -07:00
|
|
|
if (rc) {
|
2005-10-30 12:39:11 -07:00
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"64-bit DMA enable failed\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2009-04-06 19:01:15 -07:00
|
|
|
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
|
2005-04-16 15:20:36 -07:00
|
|
|
if (rc) {
|
2005-10-30 12:39:11 -07:00
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"32-bit DMA enable failed\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
return rc;
|
|
|
|
}
|
2009-04-06 19:01:15 -07:00
|
|
|
rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
|
2005-04-16 15:20:36 -07:00
|
|
|
if (rc) {
|
2005-10-30 12:39:11 -07:00
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"32-bit consistent DMA enable failed\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-03 10:17:43 -07:00
|
|
|
static void ahci_print_info(struct ata_host *host, const char *scc_s)
|
2005-04-16 15:20:36 -07: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 07:44:08 -07:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
2010-03-03 10:17:34 -07:00
|
|
|
void __iomem *mmio = hpriv->mmio;
|
2009-09-20 16:02:31 -07:00
|
|
|
u32 vers, cap, cap2, impl, speed;
|
2005-04-16 15:20:36 -07:00
|
|
|
const char *speed_s;
|
|
|
|
|
|
|
|
vers = readl(mmio + HOST_VERSION);
|
|
|
|
cap = hpriv->cap;
|
2009-09-20 16:02:31 -07:00
|
|
|
cap2 = hpriv->cap2;
|
2005-04-16 15:20:36 -07:00
|
|
|
impl = hpriv->port_map;
|
|
|
|
|
|
|
|
speed = (cap >> 20) & 0xf;
|
|
|
|
if (speed == 1)
|
|
|
|
speed_s = "1.5";
|
|
|
|
else if (speed == 2)
|
|
|
|
speed_s = "3";
|
2008-12-29 20:00:37 -07:00
|
|
|
else if (speed == 3)
|
|
|
|
speed_s = "6";
|
2005-04-16 15:20:36 -07:00
|
|
|
else
|
|
|
|
speed_s = "?";
|
|
|
|
|
2010-03-03 10:17:43 -07:00
|
|
|
dev_info(host->dev,
|
2005-10-30 12:39:11 -07:00
|
|
|
"AHCI %02x%02x.%02x%02x "
|
2005-04-16 15:20:36 -07:00
|
|
|
"%u slots %u ports %s Gbps 0x%x impl %s mode\n"
|
2007-10-19 03:42:56 -07:00
|
|
|
,
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-10-19 03:42:56 -07:00
|
|
|
(vers >> 24) & 0xff,
|
|
|
|
(vers >> 16) & 0xff,
|
|
|
|
(vers >> 8) & 0xff,
|
|
|
|
vers & 0xff,
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
((cap >> 8) & 0x1f) + 1,
|
|
|
|
(cap & 0x1f) + 1,
|
|
|
|
speed_s,
|
|
|
|
impl,
|
|
|
|
scc_s);
|
|
|
|
|
2010-03-03 10:17:43 -07:00
|
|
|
dev_info(host->dev,
|
2005-10-30 12:39:11 -07:00
|
|
|
"flags: "
|
2007-07-15 22:29:40 -07:00
|
|
|
"%s%s%s%s%s%s%s"
|
2008-06-03 10:33:55 -07:00
|
|
|
"%s%s%s%s%s%s%s"
|
2009-09-20 16:02:31 -07:00
|
|
|
"%s%s%s%s%s%s\n"
|
2007-10-19 03:42:56 -07:00
|
|
|
,
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-09-20 16:02:31 -07:00
|
|
|
cap & HOST_CAP_64 ? "64bit " : "",
|
|
|
|
cap & HOST_CAP_NCQ ? "ncq " : "",
|
|
|
|
cap & HOST_CAP_SNTF ? "sntf " : "",
|
|
|
|
cap & HOST_CAP_MPS ? "ilck " : "",
|
|
|
|
cap & HOST_CAP_SSS ? "stag " : "",
|
|
|
|
cap & HOST_CAP_ALPM ? "pm " : "",
|
|
|
|
cap & HOST_CAP_LED ? "led " : "",
|
|
|
|
cap & HOST_CAP_CLO ? "clo " : "",
|
|
|
|
cap & HOST_CAP_ONLY ? "only " : "",
|
|
|
|
cap & HOST_CAP_PMP ? "pmp " : "",
|
|
|
|
cap & HOST_CAP_FBS ? "fbs " : "",
|
|
|
|
cap & HOST_CAP_PIO_MULTI ? "pio " : "",
|
|
|
|
cap & HOST_CAP_SSC ? "slum " : "",
|
|
|
|
cap & HOST_CAP_PART ? "part " : "",
|
|
|
|
cap & HOST_CAP_CCC ? "ccc " : "",
|
|
|
|
cap & HOST_CAP_EMS ? "ems " : "",
|
|
|
|
cap & HOST_CAP_SXS ? "sxs " : "",
|
|
|
|
cap2 & HOST_CAP2_APST ? "apst " : "",
|
|
|
|
cap2 & HOST_CAP2_NVMHCI ? "nvmp " : "",
|
|
|
|
cap2 & HOST_CAP2_BOH ? "boh " : ""
|
2005-04-16 15:20:36 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2010-03-03 10:17:43 -07:00
|
|
|
static void ahci_pci_print_info(struct ata_host *host)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = to_pci_dev(host->dev);
|
|
|
|
u16 cc;
|
|
|
|
const char *scc_s;
|
|
|
|
|
|
|
|
pci_read_config_word(pdev, 0x0a, &cc);
|
|
|
|
if (cc == PCI_CLASS_STORAGE_IDE)
|
|
|
|
scc_s = "IDE";
|
|
|
|
else if (cc == PCI_CLASS_STORAGE_SATA)
|
|
|
|
scc_s = "SATA";
|
|
|
|
else if (cc == PCI_CLASS_STORAGE_RAID)
|
|
|
|
scc_s = "RAID";
|
|
|
|
else
|
|
|
|
scc_s = "unknown";
|
|
|
|
|
|
|
|
ahci_print_info(host, scc_s);
|
|
|
|
}
|
|
|
|
|
2007-10-24 22:59:16 -07:00
|
|
|
/* On ASUS P5W DH Deluxe, the second port of PCI device 00:1f.2 is
|
|
|
|
* hardwired to on-board SIMG 4726. The chipset is ICH8 and doesn't
|
|
|
|
* support PMP and the 4726 either directly exports the device
|
|
|
|
* attached to the first downstream port or acts as a hardware storage
|
|
|
|
* controller and emulate a single ATA device (can be RAID 0/1 or some
|
|
|
|
* other configuration).
|
|
|
|
*
|
|
|
|
* When there's no device attached to the first downstream port of the
|
|
|
|
* 4726, "Config Disk" appears, which is a pseudo ATA device to
|
|
|
|
* configure the 4726. However, ATA emulation of the device is very
|
|
|
|
* lame. It doesn't send signature D2H Reg FIS after the initial
|
|
|
|
* hardreset, pukes on SRST w/ PMP==0 and has bunch of other issues.
|
|
|
|
*
|
|
|
|
* The following function works around the problem by always using
|
|
|
|
* hardreset on the port and not depending on receiving signature FIS
|
|
|
|
* afterward. If signature FIS isn't received soon, ATA class is
|
|
|
|
* assumed without follow-up softreset.
|
|
|
|
*/
|
|
|
|
static void ahci_p5wdh_workaround(struct ata_host *host)
|
|
|
|
{
|
|
|
|
static struct dmi_system_id sysids[] = {
|
|
|
|
{
|
|
|
|
.ident = "P5W DH Deluxe",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR,
|
|
|
|
"ASUSTEK COMPUTER INC"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "P5W DH Deluxe"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
struct pci_dev *pdev = to_pci_dev(host->dev);
|
|
|
|
|
|
|
|
if (pdev->bus->number == 0 && pdev->devfn == PCI_DEVFN(0x1f, 2) &&
|
|
|
|
dmi_check_system(sysids)) {
|
|
|
|
struct ata_port *ap = host->ports[1];
|
|
|
|
|
|
|
|
dev_printk(KERN_INFO, &pdev->dev, "enabling ASUS P5W DH "
|
|
|
|
"Deluxe on-board SIMG4726 workaround\n");
|
|
|
|
|
|
|
|
ap->ops = &ahci_p5wdh_ops;
|
|
|
|
ap->link.flags |= ATA_LFLAG_NO_SRST | ATA_LFLAG_ASSUME_ATA;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-03 02:27:29 -07:00
|
|
|
/* only some SB600 ahci controllers can do 64bit DMA */
|
|
|
|
static bool ahci_sb600_enable_64bit(struct pci_dev *pdev)
|
2009-05-27 00:04:43 -07:00
|
|
|
{
|
|
|
|
static const struct dmi_system_id sysids[] = {
|
2009-08-16 05:04:02 -07:00
|
|
|
/*
|
|
|
|
* The oldest version known to be broken is 0901 and
|
|
|
|
* working is 1501 which was released on 2007-10-26.
|
2009-10-03 02:27:29 -07:00
|
|
|
* Enable 64bit DMA on 1501 and anything newer.
|
|
|
|
*
|
2009-08-16 05:04:02 -07:00
|
|
|
* Please read bko#9412 for more info.
|
|
|
|
*/
|
2009-05-27 00:04:43 -07:00
|
|
|
{
|
|
|
|
.ident = "ASUS M2A-VM",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BOARD_VENDOR,
|
|
|
|
"ASUSTeK Computer INC."),
|
|
|
|
DMI_MATCH(DMI_BOARD_NAME, "M2A-VM"),
|
|
|
|
},
|
2009-08-16 05:04:02 -07:00
|
|
|
.driver_data = "20071026", /* yyyymmdd */
|
2009-05-27 00:04:43 -07:00
|
|
|
},
|
2009-11-03 02:06:48 -07:00
|
|
|
/*
|
|
|
|
* All BIOS versions for the MSI K9A2 Platinum (MS-7376)
|
|
|
|
* support 64bit DMA.
|
|
|
|
*
|
|
|
|
* BIOS versions earlier than 1.5 had the Manufacturer DMI
|
|
|
|
* fields as "MICRO-STAR INTERANTIONAL CO.,LTD".
|
|
|
|
* This spelling mistake was fixed in BIOS version 1.5, so
|
|
|
|
* 1.5 and later have the Manufacturer as
|
|
|
|
* "MICRO-STAR INTERNATIONAL CO.,LTD".
|
|
|
|
* So try to match on DMI_BOARD_VENDOR of "MICRO-STAR INTER".
|
|
|
|
*
|
|
|
|
* BIOS versions earlier than 1.9 had a Board Product Name
|
|
|
|
* DMI field of "MS-7376". This was changed to be
|
|
|
|
* "K9A2 Platinum (MS-7376)" in version 1.9, but we can still
|
|
|
|
* match on DMI_BOARD_NAME of "MS-7376".
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
.ident = "MSI K9A2 Platinum",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BOARD_VENDOR,
|
|
|
|
"MICRO-STAR INTER"),
|
|
|
|
DMI_MATCH(DMI_BOARD_NAME, "MS-7376"),
|
|
|
|
},
|
|
|
|
},
|
2009-05-27 00:04:43 -07:00
|
|
|
{ }
|
|
|
|
};
|
2009-08-16 05:04:02 -07:00
|
|
|
const struct dmi_system_id *match;
|
2009-10-03 02:27:29 -07:00
|
|
|
int year, month, date;
|
|
|
|
char buf[9];
|
2009-05-27 00:04:43 -07:00
|
|
|
|
2009-08-16 05:04:02 -07:00
|
|
|
match = dmi_first_match(sysids);
|
2009-05-27 00:04:43 -07:00
|
|
|
if (pdev->bus->number != 0 || pdev->devfn != PCI_DEVFN(0x12, 0) ||
|
2009-08-16 05:04:02 -07:00
|
|
|
!match)
|
2009-05-27 00:04:43 -07:00
|
|
|
return false;
|
|
|
|
|
2009-11-03 02:06:48 -07:00
|
|
|
if (!match->driver_data)
|
|
|
|
goto enable_64bit;
|
|
|
|
|
2009-10-03 02:27:29 -07:00
|
|
|
dmi_get_date(DMI_BIOS_DATE, &year, &month, &date);
|
|
|
|
snprintf(buf, sizeof(buf), "%04d%02d%02d", year, month, date);
|
2009-08-16 05:04:02 -07:00
|
|
|
|
2009-11-03 02:06:48 -07:00
|
|
|
if (strcmp(buf, match->driver_data) >= 0)
|
|
|
|
goto enable_64bit;
|
|
|
|
else {
|
2009-08-16 05:04:02 -07:00
|
|
|
dev_printk(KERN_WARNING, &pdev->dev, "%s: BIOS too old, "
|
|
|
|
"forcing 32bit DMA, update BIOS\n", match->ident);
|
2009-10-03 02:27:29 -07:00
|
|
|
return false;
|
|
|
|
}
|
2009-11-03 02:06:48 -07:00
|
|
|
|
|
|
|
enable_64bit:
|
|
|
|
dev_printk(KERN_WARNING, &pdev->dev, "%s: enabling 64bit DMA\n",
|
|
|
|
match->ident);
|
|
|
|
return true;
|
2009-05-27 00:04:43 -07:00
|
|
|
}
|
|
|
|
|
2009-01-19 12:57:36 -07:00
|
|
|
static bool ahci_broken_system_poweroff(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
static const struct dmi_system_id broken_systems[] = {
|
|
|
|
{
|
|
|
|
.ident = "HP Compaq nx6310",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6310"),
|
|
|
|
},
|
|
|
|
/* PCI slot number of the controller */
|
|
|
|
.driver_data = (void *)0x1FUL,
|
|
|
|
},
|
2009-03-19 16:06:46 -07:00
|
|
|
{
|
|
|
|
.ident = "HP Compaq 6720s",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6720s"),
|
|
|
|
},
|
|
|
|
/* PCI slot number of the controller */
|
|
|
|
.driver_data = (void *)0x1FUL,
|
|
|
|
},
|
2009-01-19 12:57:36 -07:00
|
|
|
|
|
|
|
{ } /* terminate list */
|
|
|
|
};
|
|
|
|
const struct dmi_system_id *dmi = dmi_first_match(broken_systems);
|
|
|
|
|
|
|
|
if (dmi) {
|
|
|
|
unsigned long slot = (unsigned long)dmi->driver_data;
|
|
|
|
/* apply the quirk only to on-board controllers */
|
|
|
|
return slot == PCI_SLOT(pdev->devfn);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-05-30 04:50:12 -07:00
|
|
|
static bool ahci_broken_suspend(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
static const struct dmi_system_id sysids[] = {
|
|
|
|
/*
|
|
|
|
* On HP dv[4-6] and HDX18 with earlier BIOSen, link
|
|
|
|
* to the harddisk doesn't become online after
|
|
|
|
* resuming from STR. Warn and fail suspend.
|
2010-03-15 17:50:26 -07:00
|
|
|
*
|
|
|
|
* http://bugzilla.kernel.org/show_bug.cgi?id=12276
|
|
|
|
*
|
|
|
|
* Use dates instead of versions to match as HP is
|
|
|
|
* apparently recycling both product and version
|
|
|
|
* strings.
|
|
|
|
*
|
|
|
|
* http://bugzilla.kernel.org/show_bug.cgi?id=15462
|
2009-05-30 04:50:12 -07:00
|
|
|
*/
|
|
|
|
{
|
|
|
|
.ident = "dv4",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME,
|
|
|
|
"HP Pavilion dv4 Notebook PC"),
|
|
|
|
},
|
2010-03-15 17:50:26 -07:00
|
|
|
.driver_data = "20090105", /* F.30 */
|
2009-05-30 04:50:12 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.ident = "dv5",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME,
|
|
|
|
"HP Pavilion dv5 Notebook PC"),
|
|
|
|
},
|
2010-03-15 17:50:26 -07:00
|
|
|
.driver_data = "20090506", /* F.16 */
|
2009-05-30 04:50:12 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.ident = "dv6",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME,
|
|
|
|
"HP Pavilion dv6 Notebook PC"),
|
|
|
|
},
|
2010-03-15 17:50:26 -07:00
|
|
|
.driver_data = "20090423", /* F.21 */
|
2009-05-30 04:50:12 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.ident = "HDX18",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME,
|
|
|
|
"HP HDX18 Notebook PC"),
|
|
|
|
},
|
2010-03-15 17:50:26 -07:00
|
|
|
.driver_data = "20090430", /* F.23 */
|
2009-05-30 04:50:12 -07:00
|
|
|
},
|
2010-01-28 00:04:15 -07:00
|
|
|
/*
|
|
|
|
* Acer eMachines G725 has the same problem. BIOS
|
|
|
|
* V1.03 is known to be broken. V3.04 is known to
|
|
|
|
* work. Inbetween, there are V1.06, V2.06 and V3.03
|
|
|
|
* that we don't have much idea about. For now,
|
|
|
|
* blacklist anything older than V3.04.
|
2010-03-15 17:50:26 -07:00
|
|
|
*
|
|
|
|
* http://bugzilla.kernel.org/show_bug.cgi?id=15104
|
2010-01-28 00:04:15 -07:00
|
|
|
*/
|
|
|
|
{
|
|
|
|
.ident = "G725",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "eMachines"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "eMachines G725"),
|
|
|
|
},
|
2010-03-15 17:50:26 -07:00
|
|
|
.driver_data = "20091216", /* V3.04 */
|
2010-01-28 00:04:15 -07:00
|
|
|
},
|
2009-05-30 04:50:12 -07:00
|
|
|
{ } /* terminate list */
|
|
|
|
};
|
|
|
|
const struct dmi_system_id *dmi = dmi_first_match(sysids);
|
2010-03-15 17:50:26 -07:00
|
|
|
int year, month, date;
|
|
|
|
char buf[9];
|
2009-05-30 04:50:12 -07:00
|
|
|
|
|
|
|
if (!dmi || pdev->bus->number || pdev->devfn != PCI_DEVFN(0x1f, 2))
|
|
|
|
return false;
|
|
|
|
|
2010-03-15 17:50:26 -07:00
|
|
|
dmi_get_date(DMI_BIOS_DATE, &year, &month, &date);
|
|
|
|
snprintf(buf, sizeof(buf), "%04d%02d%02d", year, month, date);
|
2009-05-30 04:50:12 -07:00
|
|
|
|
2010-03-15 17:50:26 -07:00
|
|
|
return strcmp(buf, dmi->driver_data) < 0;
|
2009-05-30 04:50:12 -07:00
|
|
|
}
|
|
|
|
|
2009-08-03 22:30:08 -07:00
|
|
|
static bool ahci_broken_online(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
#define ENCODE_BUSDEVFN(bus, slot, func) \
|
|
|
|
(void *)(unsigned long)(((bus) << 8) | PCI_DEVFN((slot), (func)))
|
|
|
|
static const struct dmi_system_id sysids[] = {
|
|
|
|
/*
|
|
|
|
* There are several gigabyte boards which use
|
|
|
|
* SIMG5723s configured as hardware RAID. Certain
|
|
|
|
* 5723 firmware revisions shipped there keep the link
|
|
|
|
* online but fail to answer properly to SRST or
|
|
|
|
* IDENTIFY when no device is attached downstream
|
|
|
|
* causing libata to retry quite a few times leading
|
|
|
|
* to excessive detection delay.
|
|
|
|
*
|
|
|
|
* As these firmwares respond to the second reset try
|
|
|
|
* with invalid device signature, considering unknown
|
|
|
|
* sig as offline works around the problem acceptably.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
.ident = "EP45-DQ6",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BOARD_VENDOR,
|
|
|
|
"Gigabyte Technology Co., Ltd."),
|
|
|
|
DMI_MATCH(DMI_BOARD_NAME, "EP45-DQ6"),
|
|
|
|
},
|
|
|
|
.driver_data = ENCODE_BUSDEVFN(0x0a, 0x00, 0),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.ident = "EP45-DS5",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BOARD_VENDOR,
|
|
|
|
"Gigabyte Technology Co., Ltd."),
|
|
|
|
DMI_MATCH(DMI_BOARD_NAME, "EP45-DS5"),
|
|
|
|
},
|
|
|
|
.driver_data = ENCODE_BUSDEVFN(0x03, 0x00, 0),
|
|
|
|
},
|
|
|
|
{ } /* terminate list */
|
|
|
|
};
|
|
|
|
#undef ENCODE_BUSDEVFN
|
|
|
|
const struct dmi_system_id *dmi = dmi_first_match(sysids);
|
|
|
|
unsigned int val;
|
|
|
|
|
|
|
|
if (!dmi)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
val = (unsigned long)dmi->driver_data;
|
|
|
|
|
|
|
|
return pdev->bus->number == (val >> 8) && pdev->devfn == (val & 0xff);
|
|
|
|
}
|
|
|
|
|
2009-10-08 20:41:47 -07:00
|
|
|
#ifdef CONFIG_ATA_ACPI
|
2009-09-15 12:18:03 -07:00
|
|
|
static void ahci_gtf_filter_workaround(struct ata_host *host)
|
|
|
|
{
|
|
|
|
static const struct dmi_system_id sysids[] = {
|
|
|
|
/*
|
|
|
|
* Aspire 3810T issues a bunch of SATA enable commands
|
|
|
|
* via _GTF including an invalid one and one which is
|
|
|
|
* rejected by the device. Among the successful ones
|
|
|
|
* is FPDMA non-zero offset enable which when enabled
|
|
|
|
* only on the drive side leads to NCQ command
|
|
|
|
* failures. Filter it out.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
.ident = "Aspire 3810T",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3810T"),
|
|
|
|
},
|
|
|
|
.driver_data = (void *)ATA_ACPI_FILTER_FPDMA_OFFSET,
|
|
|
|
},
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
const struct dmi_system_id *dmi = dmi_first_match(sysids);
|
|
|
|
unsigned int filter;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!dmi)
|
|
|
|
return;
|
|
|
|
|
|
|
|
filter = (unsigned long)dmi->driver_data;
|
|
|
|
dev_printk(KERN_INFO, host->dev,
|
|
|
|
"applying extra ACPI _GTF filter 0x%x for %s\n",
|
|
|
|
filter, dmi->ident);
|
|
|
|
|
|
|
|
for (i = 0; i < host->n_ports; i++) {
|
|
|
|
struct ata_port *ap = host->ports[i];
|
|
|
|
struct ata_link *link;
|
|
|
|
struct ata_device *dev;
|
|
|
|
|
|
|
|
ata_for_each_link(link, ap, EDGE)
|
|
|
|
ata_for_each_dev(dev, link, ALL)
|
|
|
|
dev->gtf_filter |= filter;
|
|
|
|
}
|
|
|
|
}
|
2009-10-08 20:41:47 -07:00
|
|
|
#else
|
|
|
|
static inline void ahci_gtf_filter_workaround(struct ata_host *host)
|
|
|
|
{}
|
|
|
|
#endif
|
2009-09-15 12:18:03 -07:00
|
|
|
|
2007-01-20 00:00:28 -07:00
|
|
|
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
static int printed_version;
|
2008-06-09 08:13:04 -07:00
|
|
|
unsigned int board_id = ent->driver_data;
|
|
|
|
struct ata_port_info pi = ahci_port_info[board_id];
|
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 07:44:08 -07:00
|
|
|
const struct ata_port_info *ppi[] = { &pi, NULL };
|
2007-01-20 00:00:28 -07:00
|
|
|
struct device *dev = &pdev->dev;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ahci_host_priv *hpriv;
|
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 07:44:08 -07:00
|
|
|
struct ata_host *host;
|
2008-02-05 23:13:51 -07:00
|
|
|
int n_ports, i, rc;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
2006-05-15 05:03:55 -07:00
|
|
|
WARN_ON(ATA_MAX_QUEUE > AHCI_MAX_CMDS);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
if (!printed_version++)
|
2005-10-30 12:39:11 -07:00
|
|
|
dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-09-03 06:48:34 -07:00
|
|
|
/* The AHCI driver can only drive the SATA ports, the PATA driver
|
|
|
|
can drive them all so if both drivers are selected make sure
|
|
|
|
AHCI stays out of the way */
|
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_MARVELL && !marvell_enable)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2009-11-21 18:07:41 -07:00
|
|
|
/* Promise's PDC42819 is a SAS/SATA controller that has an AHCI mode.
|
|
|
|
* At the moment, we can only use the AHCI mode. Let the users know
|
|
|
|
* that for SAS drives they're out of luck.
|
|
|
|
*/
|
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_PROMISE)
|
|
|
|
dev_printk(KERN_INFO, &pdev->dev, "PDC42819 "
|
|
|
|
"can only drive SATA devices with this driver\n");
|
|
|
|
|
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 07:44:08 -07:00
|
|
|
/* acquire resources */
|
2007-01-20 00:00:28 -07:00
|
|
|
rc = pcim_enable_device(pdev);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2008-03-11 03:52:31 -07:00
|
|
|
/* AHCI controllers often implement SFF compatible interface.
|
|
|
|
* Grab all PCI BARs just in case.
|
|
|
|
*/
|
|
|
|
rc = pcim_iomap_regions_request_all(pdev, 1 << AHCI_PCI_BAR, DRV_NAME);
|
2007-01-31 23:06:36 -07:00
|
|
|
if (rc == -EBUSY)
|
2007-01-20 00:00:28 -07:00
|
|
|
pcim_pin_device(pdev);
|
2007-01-31 23:06:36 -07:00
|
|
|
if (rc)
|
2007-01-20 00:00:28 -07:00
|
|
|
return rc;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-12-05 23:09:43 -07:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
|
|
|
|
(pdev->device == 0x2652 || pdev->device == 0x2653)) {
|
|
|
|
u8 map;
|
|
|
|
|
|
|
|
/* ICH6s share the same PCI ID for both piix and ahci
|
|
|
|
* modes. Enabling ahci mode while MAP indicates
|
|
|
|
* combined mode is a bad idea. Yield to ata_piix.
|
|
|
|
*/
|
|
|
|
pci_read_config_byte(pdev, ICH_MAP, &map);
|
|
|
|
if (map & 0x3) {
|
|
|
|
dev_printk(KERN_INFO, &pdev->dev, "controller is in "
|
|
|
|
"combined mode, can't enable AHCI mode\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-20 00:00:28 -07:00
|
|
|
hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
|
|
|
|
if (!hpriv)
|
|
|
|
return -ENOMEM;
|
2007-09-22 21:19:55 -07:00
|
|
|
hpriv->flags |= (unsigned long)pi.private_data;
|
|
|
|
|
2008-06-09 08:13:04 -07:00
|
|
|
/* MCP65 revision A1 and A2 can't do MSI */
|
|
|
|
if (board_id == board_ahci_mcp65 &&
|
|
|
|
(pdev->revision == 0xa1 || pdev->revision == 0xa2))
|
|
|
|
hpriv->flags |= AHCI_HFLAG_NO_MSI;
|
|
|
|
|
2008-12-29 19:53:41 -07:00
|
|
|
/* SB800 does NOT need the workaround to ignore SERR_INTERNAL */
|
|
|
|
if (board_id == board_ahci_sb700 && pdev->revision >= 0x40)
|
|
|
|
hpriv->flags &= ~AHCI_HFLAG_IGN_SERR_INTERNAL;
|
|
|
|
|
2009-10-03 02:27:29 -07:00
|
|
|
/* only some SB600s can do 64bit DMA */
|
|
|
|
if (ahci_sb600_enable_64bit(pdev))
|
|
|
|
hpriv->flags &= ~AHCI_HFLAG_32BIT_ONLY;
|
2009-05-27 00:04:43 -07:00
|
|
|
|
2009-09-16 08:34:39 -07:00
|
|
|
if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev))
|
|
|
|
pci_intx(pdev, 1);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-03-03 10:17:34 -07:00
|
|
|
hpriv->mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
|
|
|
|
|
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 07:44:08 -07:00
|
|
|
/* save initial config */
|
2010-03-03 10:17:36 -07:00
|
|
|
ahci_pci_save_initial_config(pdev, hpriv);
|
2005-04-16 15:20:36 -07: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 07:44:08 -07:00
|
|
|
/* prepare host */
|
2010-01-26 21:33:23 -07:00
|
|
|
if (hpriv->cap & HOST_CAP_NCQ) {
|
|
|
|
pi.flags |= ATA_FLAG_NCQ;
|
|
|
|
/* Auto-activate optimization is supposed to be supported on
|
|
|
|
all AHCI controllers indicating NCQ support, but it seems
|
|
|
|
to be broken at least on some NVIDIA MCP79 chipsets.
|
|
|
|
Until we get info on which NVIDIA chipsets don't have this
|
|
|
|
issue, if any, disable AA on all NVIDIA AHCIs. */
|
|
|
|
if (pdev->vendor != PCI_VENDOR_ID_NVIDIA)
|
|
|
|
pi.flags |= ATA_FLAG_FPDMA_AA;
|
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
if (hpriv->cap & HOST_CAP_PMP)
|
|
|
|
pi.flags |= ATA_FLAG_PMP;
|
|
|
|
|
2008-06-03 10:33:55 -07:00
|
|
|
if (ahci_em_messages && (hpriv->cap & HOST_CAP_EMS)) {
|
|
|
|
u8 messages;
|
2010-03-03 10:17:34 -07:00
|
|
|
void __iomem *mmio = hpriv->mmio;
|
2008-06-03 10:33:55 -07:00
|
|
|
u32 em_loc = readl(mmio + HOST_EM_LOC);
|
|
|
|
u32 em_ctl = readl(mmio + HOST_EM_CTL);
|
|
|
|
|
2008-10-13 12:38:36 -07:00
|
|
|
messages = (em_ctl & EM_CTRL_MSG_TYPE) >> 16;
|
2008-06-03 10:33:55 -07:00
|
|
|
|
|
|
|
/* we only support LED message type right now */
|
|
|
|
if ((messages & 0x01) && (ahci_em_messages == 1)) {
|
|
|
|
/* store em_loc */
|
|
|
|
hpriv->em_loc = ((em_loc >> 16) * 4);
|
|
|
|
pi.flags |= ATA_FLAG_EM;
|
|
|
|
if (!(em_ctl & EM_CTL_ALHD))
|
|
|
|
pi.flags |= ATA_FLAG_SW_ACTIVITY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-19 12:57:36 -07:00
|
|
|
if (ahci_broken_system_poweroff(pdev)) {
|
|
|
|
pi.flags |= ATA_FLAG_NO_POWEROFF_SPINDOWN;
|
|
|
|
dev_info(&pdev->dev,
|
|
|
|
"quirky BIOS, skipping spindown on poweroff\n");
|
|
|
|
}
|
|
|
|
|
2009-05-30 04:50:12 -07:00
|
|
|
if (ahci_broken_suspend(pdev)) {
|
|
|
|
hpriv->flags |= AHCI_HFLAG_NO_SUSPEND;
|
|
|
|
dev_printk(KERN_WARNING, &pdev->dev,
|
|
|
|
"BIOS update required for suspend/resume\n");
|
|
|
|
}
|
|
|
|
|
2009-08-03 22:30:08 -07:00
|
|
|
if (ahci_broken_online(pdev)) {
|
|
|
|
hpriv->flags |= AHCI_HFLAG_SRST_TOUT_IS_OFFLINE;
|
|
|
|
dev_info(&pdev->dev,
|
|
|
|
"online status unreliable, applying workaround\n");
|
|
|
|
}
|
|
|
|
|
2008-02-05 23:13:51 -07:00
|
|
|
/* CAP.NP sometimes indicate the index of the last enabled
|
|
|
|
* port, at other times, that of the last possible port, so
|
|
|
|
* determining the maximum port number requires looking at
|
|
|
|
* both CAP.NP and port_map.
|
|
|
|
*/
|
|
|
|
n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
|
|
|
|
|
|
|
|
host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
|
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 07:44:08 -07:00
|
|
|
if (!host)
|
|
|
|
return -ENOMEM;
|
|
|
|
host->private_data = hpriv;
|
|
|
|
|
2009-01-26 03:05:44 -07:00
|
|
|
if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)
|
2009-01-09 16:54:07 -07:00
|
|
|
host->flags |= ATA_HOST_PARALLEL_SCAN;
|
2009-01-26 03:05:44 -07:00
|
|
|
else
|
|
|
|
printk(KERN_INFO "ahci: SSS flag set, parallel bus scan disabled\n");
|
2009-01-09 16:54:07 -07:00
|
|
|
|
2008-06-03 10:33:55 -07:00
|
|
|
if (pi.flags & ATA_FLAG_EM)
|
|
|
|
ahci_reset_em(host);
|
|
|
|
|
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 07:44:08 -07:00
|
|
|
for (i = 0; i < host->n_ports; i++) {
|
2007-05-28 05:33:01 -07:00
|
|
|
struct ata_port *ap = host->ports[i];
|
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 07:44:08 -07:00
|
|
|
|
2007-08-17 21:14:55 -07:00
|
|
|
ata_port_pbar_desc(ap, AHCI_PCI_BAR, -1, "abar");
|
|
|
|
ata_port_pbar_desc(ap, AHCI_PCI_BAR,
|
|
|
|
0x100 + ap->port_no * 0x80, "port");
|
|
|
|
|
2007-10-24 22:33:26 -07:00
|
|
|
/* set initial link pm policy */
|
|
|
|
ap->pm_policy = NOT_AVAILABLE;
|
|
|
|
|
2008-06-03 10:33:55 -07:00
|
|
|
/* set enclosure management message type */
|
|
|
|
if (ap->flags & ATA_FLAG_EM)
|
|
|
|
ap->em_message_type = ahci_em_messages;
|
|
|
|
|
|
|
|
|
2007-05-28 05:33:01 -07:00
|
|
|
/* disabled/not-implemented port */
|
2008-04-07 06:47:21 -07:00
|
|
|
if (!(hpriv->port_map & (1 << i)))
|
2007-05-28 05:33:01 -07:00
|
|
|
ap->ops = &ata_dummy_port_ops;
|
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 07:44:08 -07:00
|
|
|
}
|
2007-03-18 06:15:33 -07:00
|
|
|
|
2007-10-24 22:59:16 -07:00
|
|
|
/* apply workaround for ASUS P5W DH Deluxe mainboard */
|
|
|
|
ahci_p5wdh_workaround(host);
|
|
|
|
|
2009-09-15 12:18:03 -07:00
|
|
|
/* apply gtf filter quirk */
|
|
|
|
ahci_gtf_filter_workaround(host);
|
|
|
|
|
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 07:44:08 -07:00
|
|
|
/* initialize adapter */
|
|
|
|
rc = ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (rc)
|
2007-01-20 00:00:28 -07:00
|
|
|
return rc;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-03-03 10:17:39 -07:00
|
|
|
rc = ahci_pci_reset_controller(host);
|
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 07:44:08 -07:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-03-03 10:17:42 -07:00
|
|
|
ahci_pci_init_controller(host);
|
2010-03-03 10:17:43 -07:00
|
|
|
ahci_pci_print_info(host);
|
2005-04-16 15:20:36 -07: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 07:44:08 -07:00
|
|
|
pci_set_master(pdev);
|
|
|
|
return ata_host_activate(host, pdev->irq, ahci_interrupt, IRQF_SHARED,
|
|
|
|
&ahci_sht);
|
2005-05-12 12:03:42 -07:00
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
static int __init ahci_init(void)
|
|
|
|
{
|
2006-08-10 02:13:18 -07:00
|
|
|
return pci_register_driver(&ahci_pci_driver);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit ahci_exit(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&ahci_pci_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Jeff Garzik");
|
|
|
|
MODULE_DESCRIPTION("AHCI SATA low-level driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DEVICE_TABLE(pci, ahci_pci_tbl);
|
2005-08-22 23:53:51 -07:00
|
|
|
MODULE_VERSION(DRV_VERSION);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
module_init(ahci_init);
|
|
|
|
module_exit(ahci_exit);
|