2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* ahci.c - AHCI SATA support
|
|
|
|
*
|
2005-08-29 00:18:39 +00: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 22:20:36 +00:00
|
|
|
* http://www.intel.com/technology/serialata/pdf/rev1_0.pdf
|
2005-08-29 00:18:39 +00:00
|
|
|
* http://www.intel.com/technology/serialata/pdf/rev1_1.pdf
|
2005-04-16 22:20:36 +00: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 07:53:06 +00:00
|
|
|
#include <linux/dma-mapping.h>
|
2005-10-30 19:39:11 +00:00
|
|
|
#include <linux/device.h>
|
2007-10-25 05:59:16 +00:00
|
|
|
#include <linux/dmi.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <scsi/scsi_host.h>
|
2005-11-07 05:59:37 +00:00
|
|
|
#include <scsi/scsi_cmnd.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/libata.h>
|
|
|
|
|
|
|
|
#define DRV_NAME "ahci"
|
2007-09-23 04:19:54 +00:00
|
|
|
#define DRV_VERSION "3.0"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-13 19:38:36 +00: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-10 01:25:25 +00:00
|
|
|
static int ahci_skip_host_reset;
|
2009-01-26 10:05:44 +00:00
|
|
|
static int ahci_ignore_sss;
|
|
|
|
|
2008-03-10 01:25:25 +00: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 10:05:44 +00: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-25 05:33:26 +00: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 17:33:55 +00: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 22:20:36 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
AHCI_PCI_BAR = 5,
|
2006-11-09 06:08:40 +00:00
|
|
|
AHCI_MAX_PORTS = 32,
|
2005-04-16 22:20:36 +00:00
|
|
|
AHCI_MAX_SG = 168, /* hardware max is 64K */
|
|
|
|
AHCI_DMA_BOUNDARY = 0xffffffff,
|
2006-05-15 12:03:55 +00:00
|
|
|
AHCI_MAX_CMDS = 32,
|
2006-05-15 12:03:50 +00:00
|
|
|
AHCI_CMD_SZ = 32,
|
2006-05-15 12:03:55 +00:00
|
|
|
AHCI_CMD_SLOT_SZ = AHCI_MAX_CMDS * AHCI_CMD_SZ,
|
2005-04-16 22:20:36 +00:00
|
|
|
AHCI_RX_FIS_SZ = 256,
|
2005-06-04 05:13:15 +00:00
|
|
|
AHCI_CMD_TBL_CDB = 0x40,
|
2006-05-15 12:03:50 +00: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 22:20:36 +00:00
|
|
|
AHCI_RX_FIS_SZ,
|
|
|
|
AHCI_IRQ_ON_SG = (1 << 31),
|
|
|
|
AHCI_CMD_ATAPI = (1 << 5),
|
|
|
|
AHCI_CMD_WRITE = (1 << 6),
|
2006-03-12 02:25:27 +00:00
|
|
|
AHCI_CMD_PREFETCH = (1 << 7),
|
2006-01-23 12:38:44 +00:00
|
|
|
AHCI_CMD_RESET = (1 << 8),
|
|
|
|
AHCI_CMD_CLR_BUSY = (1 << 10),
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
RX_FIS_D2H_REG = 0x40, /* offset of D2H Register FIS data */
|
2007-01-25 10:16:28 +00:00
|
|
|
RX_FIS_SDB = 0x58, /* offset of SDB FIS data */
|
2006-05-15 11:58:29 +00:00
|
|
|
RX_FIS_UNK = 0x60, /* offset of Unknown FIS data */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
board_ahci = 0,
|
2007-09-03 03:44:57 +00:00
|
|
|
board_ahci_vt8251 = 1,
|
|
|
|
board_ahci_ign_iferr = 2,
|
|
|
|
board_ahci_sb600 = 3,
|
|
|
|
board_ahci_mv = 4,
|
2008-12-30 02:53:41 +00:00
|
|
|
board_ahci_sb700 = 5, /* for SB700 and SB800 */
|
2008-06-09 15:13:04 +00:00
|
|
|
board_ahci_mcp65 = 6,
|
2008-06-19 00:56:58 +00:00
|
|
|
board_ahci_nopmp = 7,
|
2009-04-08 21:25:31 +00:00
|
|
|
board_ahci_yesncq = 8,
|
2005-04-16 22:20:36 +00: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 17:33:55 +00:00
|
|
|
HOST_EM_LOC = 0x1c, /* Enclosure Management location */
|
|
|
|
HOST_EM_CTL = 0x20, /* Enclosure Management Control */
|
2009-09-20 23:02:31 +00:00
|
|
|
HOST_CAP2 = 0x24, /* host capabilities, extended */
|
2005-04-16 22:20:36 +00: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 23:02:31 +00:00
|
|
|
HOST_CAP_SXS = (1 << 5), /* Supports External SATA */
|
2008-06-03 17:33:55 +00:00
|
|
|
HOST_CAP_EMS = (1 << 6), /* Enclosure Management support */
|
2009-09-20 23:02:31 +00: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-23 04:19:54 +00:00
|
|
|
HOST_CAP_PMP = (1 << 17), /* Port Multiplier support */
|
2009-09-20 23:02:31 +00:00
|
|
|
HOST_CAP_ONLY = (1 << 18), /* Supports AHCI mode only */
|
2006-01-23 12:38:44 +00:00
|
|
|
HOST_CAP_CLO = (1 << 24), /* Command List Override support */
|
2009-09-20 23:02:31 +00:00
|
|
|
HOST_CAP_LED = (1 << 25), /* Supports activity LED */
|
2007-10-25 05:33:26 +00:00
|
|
|
HOST_CAP_ALPM = (1 << 26), /* Aggressive Link PM support */
|
2006-07-26 06:59:26 +00:00
|
|
|
HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */
|
2009-09-20 23:02:31 +00:00
|
|
|
HOST_CAP_MPS = (1 << 28), /* Mechanical presence switch */
|
2007-07-16 05:29:40 +00:00
|
|
|
HOST_CAP_SNTF = (1 << 29), /* SNotification register */
|
2006-05-15 12:03:52 +00:00
|
|
|
HOST_CAP_NCQ = (1 << 30), /* Native Command Queueing */
|
2006-05-15 12:03:50 +00:00
|
|
|
HOST_CAP_64 = (1 << 31), /* PCI DAC (64-bit DMA) support */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-09-20 23:02:31 +00: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 22:20:36 +00: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-16 05:29:40 +00:00
|
|
|
PORT_SCR_NTF = 0x3c, /* SATA phy register: SNotification */
|
2005-04-16 22:20:36 +00: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 11:58:29 +00:00
|
|
|
PORT_IRQ_FREEZE = PORT_IRQ_HBUS_ERR |
|
|
|
|
PORT_IRQ_IF_ERR |
|
|
|
|
PORT_IRQ_CONNECT |
|
2006-05-31 09:28:18 +00:00
|
|
|
PORT_IRQ_PHYRDY |
|
2007-09-23 04:19:54 +00:00
|
|
|
PORT_IRQ_UNK_FIS |
|
|
|
|
PORT_IRQ_BAD_PMP,
|
2006-05-15 11:58:29 +00: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 22:20:36 +00:00
|
|
|
|
|
|
|
/* PORT_CMD bits */
|
2007-10-25 05:33:26 +00:00
|
|
|
PORT_CMD_ASP = (1 << 27), /* Aggressive Slumber/Partial */
|
|
|
|
PORT_CMD_ALPE = (1 << 26), /* Aggressive Link PM enable */
|
2005-11-12 06:32:19 +00:00
|
|
|
PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */
|
2007-09-23 04:19:54 +00:00
|
|
|
PORT_CMD_PMP = (1 << 17), /* PMP attached */
|
2005-04-16 22:20:36 +00: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 12:38:44 +00:00
|
|
|
PORT_CMD_CLO = (1 << 3), /* Command list override */
|
2005-04-16 22:20:36 +00: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-26 06:59:26 +00:00
|
|
|
PORT_CMD_ICC_MASK = (0xf << 28), /* i/f ICC state mask */
|
2005-04-16 22:20:36 +00: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-04 04:50:22 +00:00
|
|
|
|
2007-09-23 04:19:55 +00: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-23 04:19:55 +00:00
|
|
|
AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */
|
2007-10-25 05:33:26 +00:00
|
|
|
AHCI_HFLAG_NO_HOTPLUG = (1 << 7), /* ignore PxSERR.DIAG.N */
|
2008-02-28 20:43:48 +00:00
|
|
|
AHCI_HFLAG_SECT255 = (1 << 8), /* max 255 sectors */
|
2008-06-09 15:13:04 +00:00
|
|
|
AHCI_HFLAG_YES_NCQ = (1 << 9), /* force NCQ cap on */
|
2009-05-30 11:50:12 +00:00
|
|
|
AHCI_HFLAG_NO_SUSPEND = (1 << 10), /* don't suspend */
|
2009-08-04 05:30:08 +00:00
|
|
|
AHCI_HFLAG_SRST_TOUT_IS_OFFLINE = (1 << 11), /* treat SRST timeout as
|
|
|
|
link offline */
|
2007-09-23 04:19:55 +00:00
|
|
|
|
2006-04-17 12:17:59 +00:00
|
|
|
/* ap->flags bits */
|
2007-04-22 17:41:05 +00:00
|
|
|
|
|
|
|
AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
|
|
|
|
ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
|
2007-10-25 05:33:26 +00:00
|
|
|
ATA_FLAG_ACPI_SATA | ATA_FLAG_AN |
|
|
|
|
ATA_FLAG_IPM,
|
2007-12-06 06:09:43 +00:00
|
|
|
|
|
|
|
ICH_MAP = 0x90, /* ICH MAP register */
|
2008-06-03 17:33:55 +00:00
|
|
|
|
2009-05-12 01:57:41 +00:00
|
|
|
/* em constants */
|
|
|
|
EM_MAX_SLOTS = 8,
|
|
|
|
EM_MAX_RETRY = 5,
|
|
|
|
|
2008-06-03 17:33:55 +00: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 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ahci_cmd_hdr {
|
2007-12-30 09:32:22 +00:00
|
|
|
__le32 opts;
|
|
|
|
__le32 status;
|
|
|
|
__le32 tbl_addr;
|
|
|
|
__le32 tbl_addr_hi;
|
|
|
|
__le32 reserved[4];
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ahci_sg {
|
2007-12-30 09:32:22 +00:00
|
|
|
__le32 addr;
|
|
|
|
__le32 addr_hi;
|
|
|
|
__le32 reserved;
|
|
|
|
__le32 flags_size;
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2008-06-03 17:33:55 +00: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 22:20:36 +00:00
|
|
|
struct ahci_host_priv {
|
2007-09-23 04:19:55 +00:00
|
|
|
unsigned int flags; /* AHCI_HFLAG_* */
|
2007-03-18 13:15:33 +00:00
|
|
|
u32 cap; /* cap to use */
|
2009-09-20 23:02:31 +00:00
|
|
|
u32 cap2; /* cap2 to use */
|
2007-03-18 13:15:33 +00:00
|
|
|
u32 port_map; /* port map to use */
|
|
|
|
u32 saved_cap; /* saved initial cap */
|
2009-09-20 23:02:31 +00:00
|
|
|
u32 saved_cap2; /* saved initial cap2 */
|
2007-03-18 13:15:33 +00:00
|
|
|
u32 saved_port_map; /* saved initial port_map */
|
2008-06-03 17:33:55 +00:00
|
|
|
u32 em_loc; /* enclosure management location */
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ahci_port_priv {
|
2007-09-23 04:19:54 +00:00
|
|
|
struct ata_link *active_link;
|
2005-04-16 22:20:36 +00: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 10:16:28 +00:00
|
|
|
/* for NCQ spurious interrupt analysis */
|
|
|
|
unsigned int ncq_saw_d2h:1;
|
|
|
|
unsigned int ncq_saw_dmas:1;
|
2007-02-27 04:24:19 +00:00
|
|
|
unsigned int ncq_saw_sdb:1;
|
2007-08-09 21:23:41 +00:00
|
|
|
u32 intr_mask; /* interrupts to enable */
|
2009-05-12 01:57:41 +00:00
|
|
|
/* enclosure management info per PM slot */
|
|
|
|
struct ahci_em_priv em_priv[EM_MAX_SLOTS];
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2008-07-31 08:02:40 +00: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 10:42:56 +00:00
|
|
|
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
|
2006-01-23 04:09:36 +00:00
|
|
|
static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc);
|
2008-04-07 13:47:20 +00:00
|
|
|
static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc);
|
2005-04-16 22:20:36 +00:00
|
|
|
static int ahci_port_start(struct ata_port *ap);
|
|
|
|
static void ahci_port_stop(struct ata_port *ap);
|
|
|
|
static void ahci_qc_prep(struct ata_queued_cmd *qc);
|
2006-05-15 11:58:29 +00:00
|
|
|
static void ahci_freeze(struct ata_port *ap);
|
|
|
|
static void ahci_thaw(struct ata_port *ap);
|
2007-09-23 04:19:54 +00: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-25 03:22:50 +00:00
|
|
|
static int ahci_softreset(struct ata_link *link, unsigned int *class,
|
|
|
|
unsigned long deadline);
|
2008-06-10 07:52:04 +00: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-25 03:22:50 +00: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 11:58:29 +00:00
|
|
|
static void ahci_error_handler(struct ata_port *ap);
|
|
|
|
static void ahci_post_internal_cmd(struct ata_queued_cmd *qc);
|
2007-05-27 00:46:51 +00:00
|
|
|
static int ahci_port_resume(struct ata_port *ap);
|
2008-02-28 20:43:48 +00:00
|
|
|
static void ahci_dev_config(struct ata_device *dev);
|
2007-05-28 12:33:01 +00:00
|
|
|
static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
|
|
|
|
u32 opts);
|
2007-03-02 08:31:26 +00:00
|
|
|
#ifdef CONFIG_PM
|
2006-07-26 06:59:26 +00: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 08:31:26 +00:00
|
|
|
#endif
|
2008-06-03 17:33:55 +00: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 22:20:36 +00:00
|
|
|
|
2009-07-17 18:13:47 +00:00
|
|
|
static ssize_t ahci_show_host_caps(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2009-09-20 23:02:31 +00:00
|
|
|
static ssize_t ahci_show_host_cap2(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf);
|
2009-07-17 18:13:47 +00: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);
|
|
|
|
|
|
|
|
DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL);
|
2009-09-20 23:02:31 +00:00
|
|
|
DEVICE_ATTR(ahci_host_cap2, S_IRUGO, ahci_show_host_cap2, NULL);
|
2009-07-17 18:13:47 +00:00
|
|
|
DEVICE_ATTR(ahci_host_version, S_IRUGO, ahci_show_host_version, NULL);
|
|
|
|
DEVICE_ATTR(ahci_port_cmd, S_IRUGO, ahci_show_port_cmd, NULL);
|
|
|
|
|
2008-02-21 23:13:36 +00:00
|
|
|
static struct device_attribute *ahci_shost_attrs[] = {
|
|
|
|
&dev_attr_link_power_management_policy,
|
2008-06-03 17:33:55 +00:00
|
|
|
&dev_attr_em_message_type,
|
|
|
|
&dev_attr_em_message,
|
2009-07-17 18:13:47 +00:00
|
|
|
&dev_attr_ahci_host_caps,
|
2009-09-20 23:02:31 +00:00
|
|
|
&dev_attr_ahci_host_cap2,
|
2009-07-17 18:13:47 +00:00
|
|
|
&dev_attr_ahci_host_version,
|
|
|
|
&dev_attr_ahci_port_cmd,
|
2008-06-03 17:33:55 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct device_attribute *ahci_sdev_attrs[] = {
|
|
|
|
&dev_attr_sw_activity,
|
2008-09-21 09:54:08 +00:00
|
|
|
&dev_attr_unload_heads,
|
2007-10-25 05:33:26 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2005-11-07 05:59:37 +00:00
|
|
|
static struct scsi_host_template ahci_sht = {
|
2008-03-25 03:22:49 +00:00
|
|
|
ATA_NCQ_SHT(DRV_NAME),
|
2006-05-15 12:03:55 +00:00
|
|
|
.can_queue = AHCI_MAX_CMDS - 1,
|
2005-04-16 22:20:36 +00:00
|
|
|
.sg_tablesize = AHCI_MAX_SG,
|
|
|
|
.dma_boundary = AHCI_DMA_BOUNDARY,
|
2007-10-25 05:33:26 +00:00
|
|
|
.shost_attrs = ahci_shost_attrs,
|
2008-06-03 17:33:55 +00:00
|
|
|
.sdev_attrs = ahci_sdev_attrs,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-25 03:22:49 +00:00
|
|
|
static struct ata_port_operations ahci_ops = {
|
|
|
|
.inherits = &sata_pmp_port_ops,
|
|
|
|
|
2007-09-23 04:19:54 +00:00
|
|
|
.qc_defer = sata_pmp_qc_defer_cmd_switch,
|
2005-04-16 22:20:36 +00:00
|
|
|
.qc_prep = ahci_qc_prep,
|
|
|
|
.qc_issue = ahci_qc_issue,
|
2008-04-07 13:47:20 +00:00
|
|
|
.qc_fill_rtf = ahci_qc_fill_rtf,
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-05-15 11:58:29 +00: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-25 03:22:50 +00:00
|
|
|
.softreset = ahci_softreset,
|
|
|
|
.hardreset = ahci_hardreset,
|
|
|
|
.postreset = ahci_postreset,
|
2008-04-07 13:47:22 +00:00
|
|
|
.pmp_softreset = ahci_softreset,
|
2006-05-15 11:58:29 +00:00
|
|
|
.error_handler = ahci_error_handler,
|
|
|
|
.post_internal_cmd = ahci_post_internal_cmd,
|
2008-03-25 03:22:48 +00:00
|
|
|
.dev_config = ahci_dev_config,
|
|
|
|
|
2006-11-01 09:00:24 +00:00
|
|
|
.scr_read = ahci_scr_read,
|
|
|
|
.scr_write = ahci_scr_write,
|
2007-09-23 04:19:54 +00: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-25 03:22:49 +00:00
|
|
|
.enable_pm = ahci_enable_alpm,
|
|
|
|
.disable_pm = ahci_disable_alpm,
|
2008-06-03 17:33:55 +00: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 08:31:26 +00:00
|
|
|
#ifdef CONFIG_PM
|
2006-11-01 09:00:24 +00:00
|
|
|
.port_suspend = ahci_port_suspend,
|
|
|
|
.port_resume = ahci_port_resume,
|
2007-03-02 08:31:26 +00:00
|
|
|
#endif
|
2006-11-01 09:00:24 +00: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-25 03:22:49 +00: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-25 03:22:50 +00: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-25 03:22:49 +00:00
|
|
|
};
|
2007-10-25 05:59:16 +00:00
|
|
|
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-25 03:22:49 +00:00
|
|
|
static struct ata_port_operations 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-25 03:22:50 +00:00
|
|
|
.hardreset = ahci_p5wdh_hardreset,
|
2007-10-25 05:59:16 +00:00
|
|
|
};
|
|
|
|
|
2008-06-10 07:52:04 +00:00
|
|
|
static struct ata_port_operations ahci_sb600_ops = {
|
|
|
|
.inherits = &ahci_ops,
|
|
|
|
.softreset = ahci_sb600_softreset,
|
|
|
|
.pmp_softreset = ahci_sb600_softreset,
|
|
|
|
};
|
|
|
|
|
2007-09-23 04:19:55 +00:00
|
|
|
#define AHCI_HFLAGS(flags) .private_data = (void *)(flags)
|
|
|
|
|
2005-11-28 09:06:23 +00:00
|
|
|
static const struct ata_port_info ahci_port_info[] = {
|
2009-04-08 06:00:13 +00:00
|
|
|
[board_ahci] =
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-04-22 17:41:05 +00:00
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 20:38:24 +00:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-07-08 05:13:16 +00:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2005-04-16 22:20:36 +00:00
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2009-04-08 06:00:13 +00:00
|
|
|
[board_ahci_vt8251] =
|
2006-04-17 12:17:59 +00:00
|
|
|
{
|
2007-09-23 04:19:55 +00:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_PMP),
|
2007-09-23 04:19:55 +00:00
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 20:38:24 +00:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-07-08 05:13:16 +00:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2006-11-01 09:00:24 +00:00
|
|
|
.port_ops = &ahci_vt8251_ops,
|
2006-04-17 12:17:59 +00:00
|
|
|
},
|
2009-04-08 06:00:13 +00:00
|
|
|
[board_ahci_ign_iferr] =
|
2006-11-29 02:33:14 +00:00
|
|
|
{
|
2007-09-23 04:19:55 +00:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_IGN_IRQ_IF_ERR),
|
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 20:38:24 +00:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-07-08 05:13:16 +00:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2006-11-29 02:33:14 +00:00
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2009-04-08 06:00:13 +00:00
|
|
|
[board_ahci_sb600] =
|
2007-03-27 10:33:05 +00:00
|
|
|
{
|
2007-09-23 04:19:55 +00:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL |
|
2009-10-03 09:27:29 +00:00
|
|
|
AHCI_HFLAG_NO_MSI | AHCI_HFLAG_SECT255 |
|
|
|
|
AHCI_HFLAG_32BIT_ONLY),
|
2007-09-23 04:19:55 +00:00
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 20:38:24 +00:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-07-08 05:13:16 +00:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2008-06-10 07:52:04 +00:00
|
|
|
.port_ops = &ahci_sb600_ops,
|
2007-03-27 10:33:05 +00:00
|
|
|
},
|
2009-04-08 06:00:13 +00:00
|
|
|
[board_ahci_mv] =
|
2007-07-08 06:29:42 +00:00
|
|
|
{
|
2007-09-23 04:19:55 +00:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_MSI |
|
2008-08-29 14:03:59 +00:00
|
|
|
AHCI_HFLAG_MV_PATA | AHCI_HFLAG_NO_PMP),
|
2007-07-08 06:29:42 +00:00
|
|
|
.flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
|
2007-09-23 04:19:55 +00:00
|
|
|
ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA,
|
2009-03-14 20:38:24 +00:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-07-08 06:29:42 +00:00
|
|
|
.udma_mask = ATA_UDMA6,
|
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2009-04-08 06:00:13 +00:00
|
|
|
[board_ahci_sb700] = /* for SB700 and SB800 */
|
2008-02-22 13:00:31 +00:00
|
|
|
{
|
2008-06-10 07:52:04 +00:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL),
|
2008-02-22 13:00:31 +00:00
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 20:38:24 +00:00
|
|
|
.pio_mask = ATA_PIO4,
|
2008-02-22 13:00:31 +00:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2008-06-10 07:52:04 +00:00
|
|
|
.port_ops = &ahci_sb600_ops,
|
2008-02-22 13:00:31 +00:00
|
|
|
},
|
2009-04-08 06:00:13 +00:00
|
|
|
[board_ahci_mcp65] =
|
2008-06-09 15:13:04 +00:00
|
|
|
{
|
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_YES_NCQ),
|
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 20:38:24 +00:00
|
|
|
.pio_mask = ATA_PIO4,
|
2008-06-09 15:13:04 +00:00
|
|
|
.udma_mask = ATA_UDMA6,
|
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2009-04-08 06:00:13 +00:00
|
|
|
[board_ahci_nopmp] =
|
2008-06-19 00:56:58 +00:00
|
|
|
{
|
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_NO_PMP),
|
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2009-03-14 20:38:24 +00:00
|
|
|
.pio_mask = ATA_PIO4,
|
2008-06-19 00:56:58 +00:00
|
|
|
.udma_mask = ATA_UDMA6,
|
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2009-04-08 21:25:31 +00:00
|
|
|
/* board_ahci_yesncq */
|
|
|
|
{
|
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_YES_NCQ),
|
|
|
|
.flags = AHCI_FLAG_COMMON,
|
|
|
|
.pio_mask = ATA_PIO4,
|
|
|
|
.udma_mask = ATA_UDMA6,
|
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2005-11-10 16:04:11 +00:00
|
|
|
static const struct pci_device_id ahci_pci_tbl[] = {
|
2006-06-23 03:05:36 +00:00
|
|
|
/* Intel */
|
2006-09-28 02:20:11 +00: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-23 06:13:39 +00:00
|
|
|
{ PCI_VDEVICE(AL, 0x5288), board_ahci_ign_iferr }, /* ULi M5288 */
|
2006-09-28 02:20:11 +00: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-03 03:44:57 +00:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x2821), board_ahci }, /* ICH8 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* ICH8 */
|
|
|
|
{ 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 21:35:00 +00:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x502a), board_ahci }, /* Tolapai */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x502b), board_ahci }, /* Tolapai */
|
2008-01-29 01:34:14 +00:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3a05), board_ahci }, /* ICH10 */
|
2009-06-26 15:44:11 +00:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3a22), board_ahci }, /* ICH10 */
|
2008-01-29 01:34:14 +00:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3a25), board_ahci }, /* ICH10 */
|
2009-07-22 20:15:56 +00:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b22), board_ahci }, /* PCH AHCI */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b23), board_ahci }, /* PCH AHCI */
|
2008-08-12 00:03:09 +00:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b24), board_ahci }, /* PCH RAID */
|
2008-08-27 23:47:22 +00:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b25), board_ahci }, /* PCH RAID */
|
2009-07-22 20:15:56 +00:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b29), board_ahci }, /* PCH AHCI */
|
2008-08-12 00:03:09 +00:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */
|
2008-08-27 23:47:22 +00:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */
|
2009-07-22 20:15:56 +00:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */
|
2006-06-23 03:05:36 +00:00
|
|
|
|
2007-02-26 11:24:03 +00: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-23 03:05:36 +00:00
|
|
|
|
|
|
|
/* ATI */
|
2007-04-11 10:23:14 +00:00
|
|
|
{ PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */
|
2008-02-22 13:00:31 +00: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-23 03:05:36 +00:00
|
|
|
|
2009-07-29 03:34:49 +00:00
|
|
|
/* AMD */
|
|
|
|
{ PCI_VDEVICE(AMD, 0x7800), board_ahci }, /* AMD SB900 */
|
|
|
|
/* 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-23 03:05:36 +00:00
|
|
|
/* VIA */
|
2006-09-28 02:20:11 +00:00
|
|
|
{ PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */
|
2007-04-11 08:27:14 +00:00
|
|
|
{ PCI_VDEVICE(VIA, 0x6287), board_ahci_vt8251 }, /* VIA VT8251 */
|
2006-06-23 03:05:36 +00:00
|
|
|
|
|
|
|
/* NVIDIA */
|
2008-06-09 15:13:04 +00: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 21:25:31 +00: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 */
|
|
|
|
{ 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 10:05:12 +00: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 14:20:37 +00: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-24 02:16:25 +00: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 08:58:41 +00: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-23 03:05:36 +00:00
|
|
|
|
2006-07-29 08:10:14 +00:00
|
|
|
/* SiS */
|
2008-08-01 03:51:43 +00: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 08:10:14 +00:00
|
|
|
|
2007-07-08 06:29:42 +00:00
|
|
|
/* Marvell */
|
|
|
|
{ PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */
|
2008-03-13 22:22:24 +00:00
|
|
|
{ PCI_VDEVICE(MARVELL, 0x6121), board_ahci_mv }, /* 6121 */
|
2007-07-08 06:29:42 +00:00
|
|
|
|
2008-10-23 03:08:16 +00:00
|
|
|
/* Promise */
|
|
|
|
{ PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */
|
|
|
|
|
2006-11-01 10:10:42 +00:00
|
|
|
/* Generic, PCI class code for AHCI */
|
|
|
|
{ PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
|
2007-01-09 10:32:51 +00:00
|
|
|
PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci },
|
2006-11-01 10:10:42 +00:00
|
|
|
|
2005-04-16 22:20:36 +00: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 07:00:28 +00:00
|
|
|
.remove = ata_pci_remove_one,
|
2007-03-02 08:31:26 +00:00
|
|
|
#ifdef CONFIG_PM
|
2006-07-26 06:59:26 +00:00
|
|
|
.suspend = ahci_pci_device_suspend,
|
|
|
|
.resume = ahci_pci_device_resume,
|
2007-03-02 08:31:26 +00:00
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2008-06-03 17:33:55 +00: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 22:20:36 +00:00
|
|
|
|
2008-09-03 13:48:34 +00: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-02 03:17:23 +00:00
|
|
|
static inline int ahci_nr_ports(u32 cap)
|
|
|
|
{
|
|
|
|
return (cap & 0x1f) + 1;
|
|
|
|
}
|
|
|
|
|
2007-05-28 12:33:01 +00:00
|
|
|
static inline void __iomem *__ahci_port_base(struct ata_host *host,
|
|
|
|
unsigned int port_no)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-05-28 12:33:01 +00:00
|
|
|
void __iomem *mmio = host->iomap[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 14:44:08 +00:00
|
|
|
|
2007-05-28 12:33:01 +00: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 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-01-05 14:11:57 +00:00
|
|
|
static void ahci_enable_ahci(void __iomem *mmio)
|
|
|
|
{
|
2008-04-23 11:52:58 +00:00
|
|
|
int i;
|
2008-01-05 14:11:57 +00:00
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
/* turn on AHCI_EN */
|
|
|
|
tmp = readl(mmio + HOST_CTL);
|
2008-04-23 11:52:58 +00: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 14:11:57 +00:00
|
|
|
tmp |= HOST_AHCI_EN;
|
|
|
|
writel(tmp, mmio + HOST_CTL);
|
|
|
|
tmp = readl(mmio + HOST_CTL); /* flush && sanity check */
|
2008-04-23 11:52:58 +00:00
|
|
|
if (tmp & HOST_AHCI_EN)
|
|
|
|
return;
|
|
|
|
msleep(10);
|
2008-01-05 14:11:57 +00:00
|
|
|
}
|
2008-04-23 11:52:58 +00:00
|
|
|
|
|
|
|
WARN_ON(1);
|
2008-01-05 14:11:57 +00:00
|
|
|
}
|
|
|
|
|
2009-07-17 18:13:47 +00: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 23:02:31 +00: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 18:13:47 +00: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);
|
|
|
|
void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
|
|
|
|
|
|
|
|
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 13:15:33 +00:00
|
|
|
/**
|
|
|
|
* ahci_save_initial_config - Save and fixup initial config values
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
* @pdev: target PCI device
|
|
|
|
* @hpriv: host private area to store config values
|
2007-03-18 13:15:33 +00: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.
|
|
|
|
*/
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
static void ahci_save_initial_config(struct pci_dev *pdev,
|
|
|
|
struct ahci_host_priv *hpriv)
|
2007-03-18 13:15:33 +00:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
|
2009-09-20 23:02:31 +00:00
|
|
|
u32 cap, cap2, vers, port_map;
|
2007-03-18 13:26:53 +00:00
|
|
|
int i;
|
2008-03-13 22:22:24 +00:00
|
|
|
int mv;
|
2007-03-18 13:15:33 +00:00
|
|
|
|
2008-01-05 14:11:57 +00:00
|
|
|
/* make sure AHCI mode is enabled before accessing CAP */
|
|
|
|
ahci_enable_ahci(mmio);
|
|
|
|
|
2007-03-18 13:15:33 +00: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 23:02:31 +00: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-16 05:29:40 +00:00
|
|
|
/* some chips have errata preventing 64bit use */
|
2007-09-23 04:19:55 +00:00
|
|
|
if ((cap & HOST_CAP_64) && (hpriv->flags & AHCI_HFLAG_32BIT_ONLY)) {
|
2007-05-18 14:23:19 +00:00
|
|
|
dev_printk(KERN_INFO, &pdev->dev,
|
|
|
|
"controller can't do 64bit DMA, forcing 32bit\n");
|
|
|
|
cap &= ~HOST_CAP_64;
|
|
|
|
}
|
|
|
|
|
2007-09-23 04:19:55 +00:00
|
|
|
if ((cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_NO_NCQ)) {
|
2007-07-16 05:29:40 +00:00
|
|
|
dev_printk(KERN_INFO, &pdev->dev,
|
|
|
|
"controller can't do NCQ, turning off CAP_NCQ\n");
|
|
|
|
cap &= ~HOST_CAP_NCQ;
|
|
|
|
}
|
|
|
|
|
2008-06-09 15:13:04 +00:00
|
|
|
if (!(cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_YES_NCQ)) {
|
|
|
|
dev_printk(KERN_INFO, &pdev->dev,
|
|
|
|
"controller can do NCQ, turning on CAP_NCQ\n");
|
|
|
|
cap |= HOST_CAP_NCQ;
|
|
|
|
}
|
|
|
|
|
2008-03-09 20:42:40 +00:00
|
|
|
if ((cap & HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) {
|
2007-09-23 04:19:55 +00:00
|
|
|
dev_printk(KERN_INFO, &pdev->dev,
|
|
|
|
"controller can't do PMP, turning off CAP_PMP\n");
|
|
|
|
cap &= ~HOST_CAP_PMP;
|
|
|
|
}
|
|
|
|
|
2008-06-17 03:46:30 +00:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_JMICRON && pdev->device == 0x2361 &&
|
|
|
|
port_map != 1) {
|
|
|
|
dev_printk(KERN_INFO, &pdev->dev,
|
|
|
|
"JMB361 has only one port, port_map 0x%x -> 0x%x\n",
|
|
|
|
port_map, 1);
|
|
|
|
port_map = 1;
|
|
|
|
}
|
|
|
|
|
2007-07-08 06:29:42 +00:00
|
|
|
/*
|
|
|
|
* Temporary Marvell 6145 hack: PATA port presence
|
|
|
|
* is asserted through the standard AHCI port
|
|
|
|
* presence register, as bit 4 (counting from 0)
|
|
|
|
*/
|
2007-09-23 04:19:55 +00:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
|
2008-03-13 22:22:24 +00:00
|
|
|
if (pdev->device == 0x6121)
|
|
|
|
mv = 0x3;
|
|
|
|
else
|
|
|
|
mv = 0xf;
|
2007-07-08 06:29:42 +00:00
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"MV_AHCI HACK: port_map %x -> %x\n",
|
2008-03-13 22:22:24 +00:00
|
|
|
port_map,
|
|
|
|
port_map & mv);
|
2008-09-03 13:48:34 +00:00
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"Disabling your PATA port. Use the boot option 'ahci.marvell_enable=0' to avoid this.\n");
|
2007-07-08 06:29:42 +00:00
|
|
|
|
2008-03-13 22:22:24 +00:00
|
|
|
port_map &= mv;
|
2007-07-08 06:29:42 +00:00
|
|
|
}
|
|
|
|
|
2007-03-18 13:26:53 +00:00
|
|
|
/* cross check port_map and cap.n_ports */
|
2007-09-03 03:44:57 +00:00
|
|
|
if (port_map) {
|
2008-02-06 06:13:51 +00:00
|
|
|
int map_ports = 0;
|
2007-03-18 13:26:53 +00:00
|
|
|
|
2008-02-06 06:13:51 +00:00
|
|
|
for (i = 0; i < AHCI_MAX_PORTS; i++)
|
|
|
|
if (port_map & (1 << i))
|
|
|
|
map_ports++;
|
2007-03-18 13:26:53 +00:00
|
|
|
|
2008-02-06 06:13:51 +00:00
|
|
|
/* If PI has more ports than n_ports, whine, clear
|
|
|
|
* port_map and let it be generated from n_ports.
|
2007-03-18 13:26:53 +00:00
|
|
|
*/
|
2008-02-06 06:13:51 +00:00
|
|
|
if (map_ports > ahci_nr_ports(cap)) {
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
dev_printk(KERN_WARNING, &pdev->dev,
|
2008-02-06 06:13:51 +00: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-03 03:44:57 +00:00
|
|
|
port_map = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fabricate port_map from cap.nr_ports */
|
|
|
|
if (!port_map) {
|
2007-03-18 13:26:53 +00:00
|
|
|
port_map = (1 << ahci_nr_ports(cap)) - 1;
|
2007-09-03 03:44:57 +00:00
|
|
|
dev_printk(KERN_WARNING, &pdev->dev,
|
|
|
|
"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 13:26:53 +00:00
|
|
|
}
|
|
|
|
|
2007-03-18 13:15:33 +00:00
|
|
|
/* record values to use during operation */
|
|
|
|
hpriv->cap = cap;
|
2009-09-20 23:02:31 +00:00
|
|
|
hpriv->cap2 = cap2;
|
2007-03-18 13:15:33 +00:00
|
|
|
hpriv->port_map = port_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 14:44:08 +00:00
|
|
|
* @host: target ATA host
|
2007-03-18 13:15:33 +00: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 14:44:08 +00:00
|
|
|
static void ahci_restore_initial_config(struct ata_host *host)
|
2007-03-18 13:15:33 +00:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
|
|
|
void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
|
|
|
|
|
2007-03-18 13:15:33 +00:00
|
|
|
writel(hpriv->saved_cap, mmio + HOST_CAP);
|
2009-09-20 23:02:31 +00:00
|
|
|
if (hpriv->saved_cap2)
|
|
|
|
writel(hpriv->saved_cap2, mmio + HOST_CAP2);
|
2007-03-18 13:15:33 +00:00
|
|
|
writel(hpriv->saved_port_map, mmio + HOST_PORTS_IMPL);
|
|
|
|
(void) readl(mmio + HOST_PORTS_IMPL); /* flush */
|
|
|
|
}
|
|
|
|
|
2007-07-16 05:29:40 +00:00
|
|
|
static unsigned ahci_scr_offset(struct ata_port *ap, unsigned int sc_reg)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-07-16 05:29:40 +00: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 22:20:36 +00:00
|
|
|
|
2007-07-16 05:29:40 +00:00
|
|
|
if (sc_reg < ARRAY_SIZE(offset) &&
|
|
|
|
(sc_reg != SCR_NOTIFICATION || (hpriv->cap & HOST_CAP_SNTF)))
|
|
|
|
return offset[sc_reg];
|
2007-07-16 05:29:40 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-07-31 08:02:40 +00:00
|
|
|
static int ahci_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-07-31 08:02:40 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(link->ap);
|
|
|
|
int offset = ahci_scr_offset(link->ap, sc_reg);
|
2007-07-16 05:29:40 +00:00
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
*val = readl(port_mmio + offset);
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2007-07-16 05:29:40 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-07-31 08:02:40 +00:00
|
|
|
static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
|
2007-07-16 05:29:40 +00:00
|
|
|
{
|
2008-07-31 08:02:40 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(link->ap);
|
|
|
|
int offset = ahci_scr_offset(link->ap, sc_reg);
|
2007-07-16 05:29:40 +00:00
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
writel(val, port_mmio + offset);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
static void ahci_start_engine(struct ata_port *ap)
|
2005-12-19 13:36:34 +00:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2005-12-19 13:36:34 +00:00
|
|
|
u32 tmp;
|
|
|
|
|
2006-07-26 06:59:25 +00:00
|
|
|
/* start DMA */
|
2006-07-26 06:59:26 +00:00
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
2005-12-19 13:36:34 +00: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 14:44:08 +00:00
|
|
|
static int ahci_stop_engine(struct ata_port *ap)
|
2006-07-26 06:59:25 +00:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-07-26 06:59:25 +00:00
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
|
|
|
|
2006-07-26 06:59:25 +00:00
|
|
|
/* check if the HBA is idle */
|
2006-07-26 06:59:25 +00:00
|
|
|
if ((tmp & (PORT_CMD_START | PORT_CMD_LIST_ON)) == 0)
|
|
|
|
return 0;
|
|
|
|
|
2006-07-26 06:59:25 +00:00
|
|
|
/* setting HBA to idle */
|
2006-07-26 06:59:25 +00:00
|
|
|
tmp &= ~PORT_CMD_START;
|
|
|
|
writel(tmp, port_mmio + PORT_CMD);
|
|
|
|
|
2006-07-26 06:59:25 +00:00
|
|
|
/* wait for engine to stop. This could be as long as 500 msec */
|
2006-07-26 06:59:25 +00:00
|
|
|
tmp = ata_wait_register(port_mmio + PORT_CMD,
|
2007-10-19 10:42:56 +00:00
|
|
|
PORT_CMD_LIST_ON, PORT_CMD_LIST_ON, 1, 500);
|
2006-07-26 06:59:25 +00:00
|
|
|
if (tmp & PORT_CMD_LIST_ON)
|
2006-07-26 06:59:25 +00: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 14:44:08 +00:00
|
|
|
static void ahci_start_fis_rx(struct ata_port *ap)
|
2006-07-26 06:59:26 +00:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
void __iomem *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-26 06:59:26 +00: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 14:44:08 +00: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-26 06:59:26 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
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-26 06:59:26 +00: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 14:44:08 +00:00
|
|
|
static int ahci_stop_fis_rx(struct ata_port *ap)
|
2006-07-26 06:59:26 +00:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-07-26 06:59:26 +00: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 14:44:08 +00:00
|
|
|
static void ahci_power_up(struct ata_port *ap)
|
2006-07-26 06:59:26 +00:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-07-26 06:59:26 +00: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 14:44:08 +00:00
|
|
|
if (hpriv->cap & HOST_CAP_SSS) {
|
2006-07-26 06:59:26 +00: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-25 05:33:26 +00: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 08:02:40 +00:00
|
|
|
ahci_scr_write(&ap->link, SCR_ERROR, ((1 << 16) | (1 << 18)));
|
2007-10-25 05:33:26 +00: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 08:31:26 +00: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 14:44:08 +00:00
|
|
|
static void ahci_power_down(struct ata_port *ap)
|
2006-07-26 06:59:26 +00:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-07-26 06:59:26 +00: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 14:44:08 +00:00
|
|
|
if (!(hpriv->cap & HOST_CAP_SSS))
|
2007-01-20 17:10:11 +00:00
|
|
|
return;
|
2006-07-26 06:59:26 +00:00
|
|
|
|
2007-01-20 17:10:11 +00: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-26 06:59:26 +00:00
|
|
|
|
2007-01-20 17:10:11 +00: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-26 06:59:26 +00:00
|
|
|
}
|
2007-03-02 08:31:26 +00:00
|
|
|
#endif
|
2006-07-26 06:59:26 +00:00
|
|
|
|
2007-05-27 00:46:51 +00:00
|
|
|
static void ahci_start_port(struct ata_port *ap)
|
2006-07-26 06:59:26 +00:00
|
|
|
{
|
2008-06-03 17:33:55 +00:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
struct ata_link *link;
|
|
|
|
struct ahci_em_priv *emp;
|
2009-04-03 20:36:41 +00:00
|
|
|
ssize_t rc;
|
|
|
|
int i;
|
2008-06-03 17:33:55 +00:00
|
|
|
|
2006-07-26 06:59:26 +00: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 14:44:08 +00:00
|
|
|
ahci_start_fis_rx(ap);
|
2006-07-26 06:59:26 +00: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 14:44:08 +00:00
|
|
|
ahci_start_engine(ap);
|
2008-06-03 17:33:55 +00:00
|
|
|
|
|
|
|
/* turn on LEDs */
|
|
|
|
if (ap->flags & ATA_FLAG_EM) {
|
2008-11-03 11:03:17 +00:00
|
|
|
ata_for_each_link(link, ap, EDGE) {
|
2008-06-03 17:33:55 +00:00
|
|
|
emp = &pp->em_priv[link->pmp];
|
2009-04-03 20:36:41 +00:00
|
|
|
|
|
|
|
/* EM Transmit bit maybe busy during init */
|
2009-05-12 01:57:41 +00:00
|
|
|
for (i = 0; i < EM_MAX_RETRY; i++) {
|
2009-04-03 20:36:41 +00:00
|
|
|
rc = ahci_transmit_led_message(ap,
|
|
|
|
emp->led_state,
|
|
|
|
4);
|
|
|
|
if (rc == -EBUSY)
|
2009-05-12 01:57:41 +00:00
|
|
|
msleep(1);
|
2009-04-03 20:36:41 +00:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2008-06-03 17:33:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ap->flags & ATA_FLAG_SW_ACTIVITY)
|
2008-11-03 11:03:17 +00:00
|
|
|
ata_for_each_link(link, ap, EDGE)
|
2008-06-03 17:33:55 +00:00
|
|
|
ahci_init_sw_activity(link);
|
|
|
|
|
2006-07-26 06:59:26 +00:00
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
static int ahci_deinit_port(struct ata_port *ap, const char **emsg)
|
2006-07-26 06:59:26 +00: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 14:44:08 +00:00
|
|
|
rc = ahci_stop_engine(ap);
|
2006-07-26 06:59:26 +00: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 14:44:08 +00:00
|
|
|
rc = ahci_stop_fis_rx(ap);
|
2006-07-26 06:59:26 +00: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 14:44:08 +00:00
|
|
|
static int ahci_reset_controller(struct ata_host *host)
|
2006-07-26 06:59:26 +00:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
struct pci_dev *pdev = to_pci_dev(host->dev);
|
2007-11-19 07:03:44 +00:00
|
|
|
struct ahci_host_priv *hpriv = host->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 14:44:08 +00:00
|
|
|
void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
|
2007-03-18 13:15:33 +00:00
|
|
|
u32 tmp;
|
2006-07-26 06:59:26 +00:00
|
|
|
|
2007-09-26 04:02:41 +00:00
|
|
|
/* we must be in AHCI mode, before using anything
|
|
|
|
* AHCI-specific, such as HOST_RESET.
|
|
|
|
*/
|
2008-01-05 14:11:57 +00:00
|
|
|
ahci_enable_ahci(mmio);
|
2007-09-26 04:02:41 +00:00
|
|
|
|
|
|
|
/* global controller reset */
|
2008-03-10 01:25:25 +00: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-26 06:59:26 +00:00
|
|
|
|
2008-07-04 05:32:17 +00: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-10 01:25:25 +00:00
|
|
|
* the hardware should be considered fried.
|
|
|
|
*/
|
2008-07-04 05:32:17 +00:00
|
|
|
tmp = ata_wait_register(mmio + HOST_CTL, HOST_RESET,
|
|
|
|
HOST_RESET, 10, 1000);
|
2006-07-26 06:59:26 +00:00
|
|
|
|
2008-03-10 01:25:25 +00:00
|
|
|
if (tmp & HOST_RESET) {
|
|
|
|
dev_printk(KERN_ERR, host->dev,
|
|
|
|
"controller reset failed (0x%x)\n", tmp);
|
|
|
|
return -EIO;
|
|
|
|
}
|
2006-07-26 06:59:26 +00:00
|
|
|
|
2008-03-10 01:25:25 +00:00
|
|
|
/* turn on AHCI mode */
|
|
|
|
ahci_enable_ahci(mmio);
|
2006-11-02 03:17:23 +00:00
|
|
|
|
2008-03-10 01:25:25 +00: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-26 06:59:26 +00:00
|
|
|
|
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
|
|
|
|
u16 tmp16;
|
|
|
|
|
|
|
|
/* configure PCS */
|
|
|
|
pci_read_config_word(pdev, 0x92, &tmp16);
|
2007-11-19 07:03:44 +00:00
|
|
|
if ((tmp16 & hpriv->port_map) != hpriv->port_map) {
|
|
|
|
tmp16 |= hpriv->port_map;
|
|
|
|
pci_write_config_word(pdev, 0x92, tmp16);
|
|
|
|
}
|
2006-07-26 06:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-03 17:33:55 +00: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 14:26:19 +00:00
|
|
|
unsigned long flags;
|
2008-06-03 17:33:55 +00:00
|
|
|
|
2008-10-13 19:38:36 +00:00
|
|
|
led_message &= EM_MSG_LED_VALUE;
|
2008-06-03 17:33:55 +00: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 14:26:19 +00:00
|
|
|
spin_lock_irqsave(ap->lock, flags);
|
2008-06-03 17:33:55 +00:00
|
|
|
if (emp->saved_activity != emp->activity) {
|
|
|
|
emp->saved_activity = emp->activity;
|
|
|
|
/* get the current LED state */
|
2008-10-13 19:38:36 +00:00
|
|
|
activity_led_state = led_message & EM_MSG_LED_VALUE_ON;
|
2008-06-03 17:33:55 +00:00
|
|
|
|
|
|
|
if (activity_led_state)
|
|
|
|
activity_led_state = 0;
|
|
|
|
else
|
|
|
|
activity_led_state = 1;
|
|
|
|
|
|
|
|
/* clear old state */
|
2008-10-13 19:38:36 +00:00
|
|
|
led_message &= ~EM_MSG_LED_VALUE_ACTIVITY;
|
2008-06-03 17:33:55 +00: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 19:38:36 +00:00
|
|
|
led_message &= ~EM_MSG_LED_VALUE_ACTIVITY;
|
2008-06-03 17:33:55 +00:00
|
|
|
if (emp->blink_policy == BLINK_OFF)
|
|
|
|
led_message |= (1 << 16);
|
|
|
|
}
|
2008-10-16 14:26:19 +00:00
|
|
|
spin_unlock_irqrestore(ap->lock, flags);
|
2008-06-03 17:33:55 +00: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)
|
|
|
|
{
|
|
|
|
void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
|
|
|
|
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;
|
|
|
|
void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
|
|
|
|
u32 em_ctl;
|
|
|
|
u32 message[] = {0, 0};
|
2008-07-25 17:56:36 +00:00
|
|
|
unsigned long flags;
|
2008-06-03 17:33:55 +00:00
|
|
|
int pmp;
|
|
|
|
struct ahci_em_priv *emp;
|
|
|
|
|
|
|
|
/* get the slot number from the message */
|
2008-10-13 19:38:36 +00:00
|
|
|
pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
|
2009-05-12 01:57:41 +00:00
|
|
|
if (pmp < EM_MAX_SLOTS)
|
2008-06-03 17:33:55 +00: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 20:36:41 +00:00
|
|
|
return -EBUSY;
|
2008-06-03 17:33:55 +00: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 19:38:36 +00:00
|
|
|
message[1] = ((state & ~EM_MSG_LED_HBA_PORT) | ap->port_no);
|
2008-06-03 17:33:55 +00: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 19:14:23 +00:00
|
|
|
emp->led_state = state;
|
2008-06-03 17:33:55 +00: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 11:03:17 +00:00
|
|
|
ata_for_each_link(link, ap, EDGE) {
|
2008-06-03 17:33:55 +00: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 19:38:36 +00:00
|
|
|
pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
|
2009-05-12 01:57:41 +00:00
|
|
|
if (pmp < EM_MAX_SLOTS)
|
2008-06-03 17:33:55 +00: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 19:38:36 +00:00
|
|
|
state &= ~EM_MSG_LED_VALUE_ACTIVITY;
|
2008-06-03 17:33:55 +00: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 19:38:36 +00:00
|
|
|
port_led_state &= EM_MSG_LED_VALUE_OFF;
|
2008-06-03 17:33:55 +00: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 19:38:36 +00:00
|
|
|
port_led_state &= EM_MSG_LED_VALUE_OFF;
|
2008-06-03 17:33:55 +00:00
|
|
|
port_led_state |= (ap->port_no | (link->pmp << 8));
|
2008-10-13 19:38:36 +00:00
|
|
|
port_led_state |= EM_MSG_LED_VALUE_ON; /* check this */
|
2008-06-03 17:33:55 +00: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);
|
|
|
|
}
|
|
|
|
|
2007-05-28 11:45:27 +00:00
|
|
|
static void ahci_port_init(struct pci_dev *pdev, struct ata_port *ap,
|
|
|
|
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)
|
|
|
|
dev_printk(KERN_WARNING, &pdev->dev,
|
|
|
|
"%s (%d)\n", emsg, rc);
|
|
|
|
|
|
|
|
/* 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 14:44:08 +00:00
|
|
|
static void ahci_init_controller(struct ata_host *host)
|
2006-07-26 06:59:26 +00:00
|
|
|
{
|
2007-09-23 04:19:55 +00:00
|
|
|
struct ahci_host_priv *hpriv = host->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 14:44:08 +00:00
|
|
|
struct pci_dev *pdev = to_pci_dev(host->dev);
|
|
|
|
void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
|
2007-05-28 11:45:27 +00:00
|
|
|
int i;
|
2007-07-08 06:29:42 +00:00
|
|
|
void __iomem *port_mmio;
|
2006-07-26 06:59:26 +00:00
|
|
|
u32 tmp;
|
2008-03-13 22:22:24 +00:00
|
|
|
int mv;
|
2006-07-26 06:59:26 +00:00
|
|
|
|
2007-09-23 04:19:55 +00:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
|
2008-03-13 22:22:24 +00:00
|
|
|
if (pdev->device == 0x6121)
|
|
|
|
mv = 2;
|
|
|
|
else
|
|
|
|
mv = 4;
|
|
|
|
port_mmio = __ahci_port_base(host, mv);
|
2007-07-08 06:29:42 +00: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);
|
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
for (i = 0; i < host->n_ports; i++) {
|
|
|
|
struct ata_port *ap = host->ports[i];
|
2006-07-26 06:59:26 +00:00
|
|
|
|
2007-07-08 06:29:42 +00:00
|
|
|
port_mmio = ahci_port_base(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 14:44:08 +00:00
|
|
|
if (ata_port_is_dummy(ap))
|
2006-07-26 06:59:26 +00:00
|
|
|
continue;
|
|
|
|
|
2007-05-28 11:45:27 +00:00
|
|
|
ahci_port_init(pdev, ap, i, mmio, port_mmio);
|
2006-07-26 06:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2008-02-28 20:43:48 +00:00
|
|
|
static void ahci_dev_config(struct ata_device *dev)
|
|
|
|
{
|
|
|
|
struct ahci_host_priv *hpriv = dev->link->ap->host->private_data;
|
|
|
|
|
2008-03-25 02:40:40 +00:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_SECT255) {
|
2008-02-28 20:43:48 +00:00
|
|
|
dev->max_sectors = 255;
|
2008-03-25 02:40:40 +00:00
|
|
|
ata_dev_printk(dev, KERN_INFO,
|
|
|
|
"SB600 AHCI: limiting to 255 sectors per cmd\n");
|
|
|
|
}
|
2008-02-28 20:43:48 +00:00
|
|
|
}
|
|
|
|
|
2005-12-19 13:37:17 +00:00
|
|
|
static unsigned int ahci_dev_classify(struct ata_port *ap)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2005-04-16 22:20:36 +00:00
|
|
|
struct ata_taskfile tf;
|
2005-12-19 13:37:17 +00: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 12:03:55 +00:00
|
|
|
static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
|
|
|
|
u32 opts)
|
2006-02-10 08:25:47 +00:00
|
|
|
{
|
2006-05-15 12:03:55 +00: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 08:25:47 +00:00
|
|
|
}
|
|
|
|
|
2009-08-07 07:05:52 +00:00
|
|
|
static int ahci_kick_engine(struct ata_port *ap)
|
2006-03-22 12:07:03 +00:00
|
|
|
{
|
2008-04-07 13:47:21 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-08-24 07:19:22 +00:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2008-04-07 13:47:21 +00:00
|
|
|
u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
|
2006-04-17 12:17:59 +00:00
|
|
|
u32 tmp;
|
2007-07-16 05:29:39 +00:00
|
|
|
int busy, rc;
|
2006-04-17 12:17:59 +00:00
|
|
|
|
2007-07-16 05:29:39 +00:00
|
|
|
/* stop engine */
|
|
|
|
rc = ahci_stop_engine(ap);
|
|
|
|
if (rc)
|
|
|
|
goto out_restart;
|
|
|
|
|
2009-08-07 07:05:52 +00: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-16 05:29:39 +00:00
|
|
|
rc = 0;
|
|
|
|
goto out_restart;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(hpriv->cap & HOST_CAP_CLO)) {
|
|
|
|
rc = -EOPNOTSUPP;
|
|
|
|
goto out_restart;
|
|
|
|
}
|
2006-04-17 12:17:59 +00:00
|
|
|
|
2007-07-16 05:29:39 +00:00
|
|
|
/* perform CLO */
|
2006-04-17 12:17:59 +00:00
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
|
|
|
tmp |= PORT_CMD_CLO;
|
|
|
|
writel(tmp, port_mmio + PORT_CMD);
|
|
|
|
|
2007-07-16 05:29:39 +00:00
|
|
|
rc = 0;
|
2006-04-17 12:17:59 +00:00
|
|
|
tmp = ata_wait_register(port_mmio + PORT_CMD,
|
|
|
|
PORT_CMD_CLO, PORT_CMD_CLO, 1, 500);
|
|
|
|
if (tmp & PORT_CMD_CLO)
|
2007-07-16 05:29:39 +00:00
|
|
|
rc = -EIO;
|
2006-04-17 12:17:59 +00:00
|
|
|
|
2007-07-16 05:29:39 +00:00
|
|
|
/* restart engine */
|
|
|
|
out_restart:
|
|
|
|
ahci_start_engine(ap);
|
|
|
|
return rc;
|
2006-04-17 12:17:59 +00:00
|
|
|
}
|
|
|
|
|
2007-07-16 05:29:39 +00: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 12:17:59 +00:00
|
|
|
{
|
2007-07-16 05:29:39 +00:00
|
|
|
const u32 cmd_fis_len = 5; /* five dwords */
|
2006-03-22 12:07:03 +00: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 14:44:08 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-07-16 05:29:39 +00: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 07:05:52 +00:00
|
|
|
ahci_kick_engine(ap);
|
2007-07-16 05:29:39 +00:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
readl(port_mmio + PORT_CMD_ISSUE); /* flush */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-10 07:52:04 +00: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-16 05:29:39 +00:00
|
|
|
{
|
2007-08-06 09:36:23 +00:00
|
|
|
struct ata_port *ap = link->ap;
|
2009-08-04 05:30:08 +00:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2006-03-22 12:07:03 +00:00
|
|
|
const char *reason = NULL;
|
2007-07-16 05:29:38 +00:00
|
|
|
unsigned long now, msecs;
|
2006-03-22 12:07:03 +00:00
|
|
|
struct ata_taskfile tf;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
DPRINTK("ENTER\n");
|
|
|
|
|
|
|
|
/* prepare for SRST (AHCI-1.1 10.4.1) */
|
2009-08-07 07:05:52 +00:00
|
|
|
rc = ahci_kick_engine(ap);
|
2007-12-06 06:02:48 +00:00
|
|
|
if (rc && rc != -EOPNOTSUPP)
|
2007-08-06 09:36:23 +00:00
|
|
|
ata_link_printk(link, KERN_WARNING,
|
2007-12-06 06:02:48 +00:00
|
|
|
"failed to reset engine (errno=%d)\n", rc);
|
2006-03-22 12:07:03 +00:00
|
|
|
|
2007-08-06 09:36:23 +00:00
|
|
|
ata_tf_init(link->device, &tf);
|
2006-03-22 12:07:03 +00:00
|
|
|
|
|
|
|
/* issue the first D2H Register FIS */
|
2007-07-16 05:29:38 +00:00
|
|
|
msecs = 0;
|
|
|
|
now = jiffies;
|
|
|
|
if (time_after(now, deadline))
|
|
|
|
msecs = jiffies_to_msecs(deadline - now);
|
|
|
|
|
2006-03-22 12:07:03 +00:00
|
|
|
tf.ctl |= ATA_SRST;
|
2007-07-16 05:29:39 +00:00
|
|
|
if (ahci_exec_polled_cmd(ap, pmp, &tf, 0,
|
2007-07-16 05:29:39 +00:00
|
|
|
AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY, msecs)) {
|
2006-03-22 12:07:03 +00: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-16 05:29:39 +00:00
|
|
|
ahci_exec_polled_cmd(ap, pmp, &tf, 0, 0, 0);
|
2006-03-22 12:07:03 +00:00
|
|
|
|
2008-04-07 13:47:19 +00:00
|
|
|
/* wait for link to become ready */
|
2008-06-10 07:52:04 +00:00
|
|
|
rc = ata_wait_after_reset(link, deadline, check_ready);
|
2009-08-04 05:30:08 +00: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 07:50:52 +00:00
|
|
|
reason = "device not ready";
|
|
|
|
goto fail;
|
2009-08-04 05:30:08 +00:00
|
|
|
} else
|
|
|
|
*class = ahci_dev_classify(ap);
|
2006-03-22 12:07:03 +00:00
|
|
|
|
|
|
|
DPRINTK("EXIT, class=%u\n", *class);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
2007-08-06 09:36:23 +00:00
|
|
|
ata_link_printk(link, KERN_ERR, "softreset failed (%s)\n", reason);
|
2006-03-22 12:07:03 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2008-06-10 07:52:04 +00: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-05 02:10:41 +00:00
|
|
|
"applying SB600 PMP SRST workaround "
|
|
|
|
"and retrying\n");
|
2008-06-10 07:52:04 +00:00
|
|
|
rc = ahci_do_softreset(link, class, 0, deadline,
|
|
|
|
ahci_check_ready);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-08-06 09:36:23 +00: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 07:50:52 +00:00
|
|
|
unsigned long deadline)
|
2005-12-19 13:37:17 +00:00
|
|
|
{
|
2008-04-07 13:47:19 +00:00
|
|
|
const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context);
|
2007-08-06 09:36:23 +00:00
|
|
|
struct ata_port *ap = link->ap;
|
2006-05-31 09:28:18 +00: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 13:47:19 +00:00
|
|
|
bool online;
|
2006-02-11 07:26:02 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
DPRINTK("ENTER\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
ahci_stop_engine(ap);
|
2006-05-31 09:28:18 +00:00
|
|
|
|
|
|
|
/* clear D2H reception area to properly wait for D2H FIS */
|
2007-08-06 09:36:23 +00:00
|
|
|
ata_tf_init(link->device, &tf);
|
2007-01-26 06:37:20 +00:00
|
|
|
tf.command = 0x80;
|
2007-07-16 05:29:38 +00:00
|
|
|
ata_tf_to_fis(&tf, 0, 0, d2h_fis);
|
2006-05-31 09:28:18 +00:00
|
|
|
|
2008-04-07 13:47:19 +00:00
|
|
|
rc = sata_link_hardreset(link, timing, deadline, &online,
|
|
|
|
ahci_check_ready);
|
2006-05-31 09:28:18 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
ahci_start_engine(ap);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-04-07 13:47:19 +00:00
|
|
|
if (online)
|
2006-02-11 07:26:02 +00:00
|
|
|
*class = ahci_dev_classify(ap);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-02-11 07:26:02 +00:00
|
|
|
DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-08-06 09:36:23 +00: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 07:50:52 +00:00
|
|
|
unsigned long deadline)
|
2006-11-01 09:00:24 +00:00
|
|
|
{
|
2007-08-06 09:36:23 +00:00
|
|
|
struct ata_port *ap = link->ap;
|
2008-04-07 13:47:19 +00:00
|
|
|
bool online;
|
2006-11-01 09:00:24 +00: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 14:44:08 +00:00
|
|
|
ahci_stop_engine(ap);
|
2006-11-01 09:00:24 +00:00
|
|
|
|
2007-08-06 09:36:23 +00:00
|
|
|
rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context),
|
2008-04-07 13:47:19 +00:00
|
|
|
deadline, &online, NULL);
|
2006-11-01 09:00:24 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
ahci_start_engine(ap);
|
2006-11-01 09:00:24 +00: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 13:47:19 +00:00
|
|
|
return online ? -EAGAIN : rc;
|
2006-11-01 09:00:24 +00:00
|
|
|
}
|
|
|
|
|
2007-10-25 05:59:16 +00: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 13:47:19 +00:00
|
|
|
bool online;
|
2007-10-25 05:59:16 +00: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 13:47:19 +00:00
|
|
|
deadline, &online, NULL);
|
2007-10-25 05:59:16 +00: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 13:47:19 +00:00
|
|
|
if (online) {
|
|
|
|
rc = ata_wait_after_reset(link, jiffies + 2 * HZ,
|
|
|
|
ahci_check_ready);
|
|
|
|
if (rc)
|
2009-08-07 07:05:52 +00:00
|
|
|
ahci_kick_engine(ap);
|
2008-04-07 13:47:19 +00:00
|
|
|
}
|
|
|
|
return rc;
|
2007-10-25 05:59:16 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 09:36:23 +00:00
|
|
|
static void ahci_postreset(struct ata_link *link, unsigned int *class)
|
2006-02-11 07:26:02 +00:00
|
|
|
{
|
2007-08-06 09:36:23 +00: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 14:44:08 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-02-11 07:26:02 +00:00
|
|
|
u32 new_tmp, tmp;
|
|
|
|
|
2008-04-07 13:47:18 +00:00
|
|
|
ata_std_postreset(link, class);
|
2005-11-12 06:32:19 +00:00
|
|
|
|
|
|
|
/* Make sure port's ATAPI bit is set appropriately */
|
|
|
|
new_tmp = tmp = readl(port_mmio + PORT_CMD);
|
2006-02-11 07:26:02 +00:00
|
|
|
if (*class == ATA_DEV_ATAPI)
|
2005-11-12 06:32:19 +00: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 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-05-15 12:03:55 +00:00
|
|
|
static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-10-05 11:13:30 +00:00
|
|
|
struct scatterlist *sg;
|
2007-12-05 07:43:11 +00:00
|
|
|
struct ahci_sg *ahci_sg = cmd_tbl + AHCI_CMD_TBL_HDR_SZ;
|
|
|
|
unsigned int si;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Next, the S/G list.
|
|
|
|
*/
|
2007-12-05 07:43:11 +00:00
|
|
|
for_each_sg(qc->sg, sg, qc->n_elem, si) {
|
2005-10-05 11:13:30 +00:00
|
|
|
dma_addr_t addr = sg_dma_address(sg);
|
|
|
|
u32 sg_len = sg_dma_len(sg);
|
|
|
|
|
2007-12-05 07:43:11 +00: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 22:20:36 +00:00
|
|
|
}
|
2005-11-12 06:27:07 +00:00
|
|
|
|
2007-12-05 07:43:11 +00:00
|
|
|
return si;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_qc_prep(struct ata_queued_cmd *qc)
|
|
|
|
{
|
2005-06-04 05:13:15 +00:00
|
|
|
struct ata_port *ap = qc->ap;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-11-27 10:28:53 +00:00
|
|
|
int is_atapi = ata_is_atapi(qc->tf.protocol);
|
2006-05-15 12:03:55 +00:00
|
|
|
void *cmd_tbl;
|
2005-04-16 22:20:36 +00:00
|
|
|
u32 opts;
|
|
|
|
const u32 cmd_fis_len = 5; /* five dwords */
|
2005-11-12 06:27:07 +00:00
|
|
|
unsigned int n_elem;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in command table information. First, the header,
|
|
|
|
* a SATA Register - Host to Device command FIS.
|
|
|
|
*/
|
2006-05-15 12:03:55 +00:00
|
|
|
cmd_tbl = pp->cmd_tbl + qc->tag * AHCI_CMD_TBL_SZ;
|
|
|
|
|
2007-09-23 04:19:54 +00:00
|
|
|
ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, cmd_tbl);
|
2006-02-10 08:25:47 +00:00
|
|
|
if (is_atapi) {
|
2006-05-15 12:03:55 +00: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-04 05:13:15 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-02-10 08:25:47 +00:00
|
|
|
n_elem = 0;
|
|
|
|
if (qc->flags & ATA_QCFLAG_DMAMAP)
|
2006-05-15 12:03:55 +00:00
|
|
|
n_elem = ahci_fill_sg(qc, cmd_tbl);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-02-10 08:25:47 +00:00
|
|
|
/*
|
|
|
|
* Fill in command slot information.
|
|
|
|
*/
|
2007-09-23 04:19:54 +00:00
|
|
|
opts = cmd_fis_len | n_elem << 16 | (qc->dev->link->pmp << 12);
|
2006-02-10 08:25:47 +00:00
|
|
|
if (qc->tf.flags & ATA_TFLAG_WRITE)
|
|
|
|
opts |= AHCI_CMD_WRITE;
|
|
|
|
if (is_atapi)
|
2006-03-12 02:25:27 +00:00
|
|
|
opts |= AHCI_CMD_ATAPI | AHCI_CMD_PREFETCH;
|
2005-11-12 06:27:07 +00:00
|
|
|
|
2006-05-15 12:03:55 +00:00
|
|
|
ahci_fill_cmd_slot(pp, qc->tag, opts);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-05-15 11:58:29 +00:00
|
|
|
static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-09-23 04:19:55 +00:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2006-05-15 11:58:29 +00:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-09-23 04:19:54 +00: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;
|
2006-05-15 11:58:29 +00:00
|
|
|
u32 serror;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-09-23 04:19:54 +00:00
|
|
|
/* determine active link */
|
2008-11-03 11:03:17 +00:00
|
|
|
ata_for_each_link(link, ap, EDGE)
|
2007-09-23 04:19:54 +00:00
|
|
|
if (ata_link_active(link))
|
|
|
|
break;
|
|
|
|
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 22:20:36 +00:00
|
|
|
|
2006-05-15 11:58:29 +00:00
|
|
|
/* AHCI needs SError cleared; otherwise, it might lock up */
|
2008-07-31 08:02:40 +00:00
|
|
|
ahci_scr_read(&ap->link, SCR_ERROR, &serror);
|
|
|
|
ahci_scr_write(&ap->link, SCR_ERROR, serror);
|
2007-09-23 04:19:54 +00:00
|
|
|
host_ehi->serror |= serror;
|
2006-05-15 11:58:29 +00:00
|
|
|
|
2006-11-29 02:33:14 +00:00
|
|
|
/* some controllers set IRQ_IF_ERR on device errors, ignore it */
|
2007-09-23 04:19:55 +00:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_IGN_IRQ_IF_ERR)
|
2006-11-29 02:33:14 +00:00
|
|
|
irq_stat &= ~PORT_IRQ_IF_ERR;
|
|
|
|
|
2007-03-27 10:33:05 +00:00
|
|
|
if (irq_stat & PORT_IRQ_TF_ERR) {
|
2007-09-23 04:19:54 +00: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-23 04:19:55 +00:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_IGN_SERR_INTERNAL)
|
2007-09-23 04:19:54 +00: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 15:05:14 +00:00
|
|
|
active_ehi->action |= ATA_EH_RESET;
|
2007-09-23 04:19:54 +00:00
|
|
|
ata_ehi_push_desc(active_ehi,
|
|
|
|
"unknown FIS %08x %08x %08x %08x" ,
|
|
|
|
unk[0], unk[1], unk[2], unk[3]);
|
|
|
|
}
|
|
|
|
|
2008-04-07 13:47:22 +00:00
|
|
|
if (sata_pmp_attached(ap) && (irq_stat & PORT_IRQ_BAD_PMP)) {
|
2007-09-23 04:19:54 +00: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 15:05:14 +00:00
|
|
|
active_ehi->action |= ATA_EH_RESET;
|
2007-09-23 04:19:54 +00:00
|
|
|
ata_ehi_push_desc(active_ehi, "incorrect PMP");
|
2007-03-27 10:33:05 +00:00
|
|
|
}
|
2006-05-15 11:58:29 +00:00
|
|
|
|
|
|
|
if (irq_stat & (PORT_IRQ_HBUS_ERR | PORT_IRQ_HBUS_DATA_ERR)) {
|
2007-09-23 04:19:54 +00: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 15:05:14 +00:00
|
|
|
host_ehi->action |= ATA_EH_RESET;
|
2007-09-23 04:19:54 +00:00
|
|
|
ata_ehi_push_desc(host_ehi, "host bus error");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-05-15 11:58:29 +00:00
|
|
|
if (irq_stat & PORT_IRQ_IF_ERR) {
|
2007-09-23 04:19:54 +00:00
|
|
|
host_ehi->err_mask |= AC_ERR_ATA_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 15:05:14 +00:00
|
|
|
host_ehi->action |= ATA_EH_RESET;
|
2007-09-23 04:19:54 +00:00
|
|
|
ata_ehi_push_desc(host_ehi, "interface fatal error");
|
2006-05-15 11:58:29 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-05-15 11:58:29 +00:00
|
|
|
if (irq_stat & (PORT_IRQ_CONNECT | PORT_IRQ_PHYRDY)) {
|
2007-09-23 04:19:54 +00:00
|
|
|
ata_ehi_hotplugged(host_ehi);
|
|
|
|
ata_ehi_push_desc(host_ehi, "%s",
|
|
|
|
irq_stat & PORT_IRQ_CONNECT ?
|
2006-05-15 11:58:29 +00:00
|
|
|
"connection status changed" : "PHY RDY changed");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* okay, let's hand over to EH */
|
2006-01-23 04:09:37 +00:00
|
|
|
|
2006-05-15 11:58:29 +00:00
|
|
|
if (irq_stat & PORT_IRQ_FREEZE)
|
|
|
|
ata_port_freeze(ap);
|
|
|
|
else
|
|
|
|
ata_port_abort(ap);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-05-27 00:46:51 +00:00
|
|
|
static void ahci_port_intr(struct ata_port *ap)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-04-07 13:47:21 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-08-06 09:36:22 +00:00
|
|
|
struct ata_eh_info *ehi = &ap->link.eh_info;
|
2007-01-25 10:16:28 +00:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-10-09 06:02:23 +00:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2007-10-09 06:06:48 +00:00
|
|
|
int resetting = !!(ap->pflags & ATA_PFLAG_RESETTING);
|
2006-05-15 12:03:55 +00:00
|
|
|
u32 status, qc_active;
|
2007-12-07 03:46:23 +00:00
|
|
|
int rc;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
status = readl(port_mmio + PORT_IRQ_STAT);
|
|
|
|
writel(status, port_mmio + PORT_IRQ_STAT);
|
|
|
|
|
2007-10-09 06:06:48 +00:00
|
|
|
/* ignore BAD_PMP while resetting */
|
|
|
|
if (unlikely(resetting))
|
|
|
|
status &= ~PORT_IRQ_BAD_PMP;
|
|
|
|
|
2007-10-25 05:33:26 +00: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 08:02:40 +00:00
|
|
|
ahci_scr_write(&ap->link, SCR_ERROR, ((1 << 16) | (1 << 18)));
|
2007-10-25 05:33:26 +00:00
|
|
|
}
|
|
|
|
|
2006-05-15 11:58:29 +00:00
|
|
|
if (unlikely(status & PORT_IRQ_ERROR)) {
|
|
|
|
ahci_error_intr(ap, status);
|
|
|
|
return;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-08-15 08:11:25 +00:00
|
|
|
if (status & PORT_IRQ_SDB_FIS) {
|
2007-10-09 06:02:23 +00: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 08:11:25 +00:00
|
|
|
*/
|
2007-10-09 06:02:23 +00:00
|
|
|
if (hpriv->cap & HOST_CAP_SNTF)
|
2007-09-23 04:14:13 +00:00
|
|
|
sata_async_notification(ap);
|
2007-10-09 06:02:23 +00:00
|
|
|
else {
|
|
|
|
/* If the 'N' bit in word 0 of the FIS is set,
|
|
|
|
* we just received asynchronous notification.
|
|
|
|
* Tell libata about it.
|
|
|
|
*/
|
|
|
|
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-08-15 08:11:25 +00:00
|
|
|
}
|
|
|
|
|
2007-09-23 04:19:54 +00:00
|
|
|
/* pp->active_link is valid iff any command is in flight */
|
|
|
|
if (ap->qc_active && pp->active_link->sactive)
|
2006-05-15 12:03:55 +00:00
|
|
|
qc_active = readl(port_mmio + PORT_SCR_ACT);
|
|
|
|
else
|
|
|
|
qc_active = readl(port_mmio + PORT_CMD_ISSUE);
|
|
|
|
|
2008-04-07 13:47:20 +00:00
|
|
|
rc = ata_qc_complete_multiple(ap, qc_active);
|
2007-10-09 06:06:48 +00:00
|
|
|
|
2007-12-07 03:46:23 +00:00
|
|
|
/* while resetting, invalid completions are expected */
|
|
|
|
if (unlikely(rc < 0 && !resetting)) {
|
2006-05-15 12:03:55 +00: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 15:05:14 +00:00
|
|
|
ehi->action |= ATA_EH_RESET;
|
2006-05-15 12:03:55 +00:00
|
|
|
ata_port_freeze(ap);
|
2005-04-16 22:20:36 +00: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 13:55:46 +00:00
|
|
|
static irqreturn_t ahci_interrupt(int irq, void *dev_instance)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-08-24 07:19:22 +00:00
|
|
|
struct ata_host *host = dev_instance;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct ahci_host_priv *hpriv;
|
|
|
|
unsigned int i, handled = 0;
|
2005-08-30 09:18:18 +00:00
|
|
|
void __iomem *mmio;
|
2008-07-05 04:10:50 +00:00
|
|
|
u32 irq_stat, irq_masked;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
2006-08-24 07:19:22 +00:00
|
|
|
hpriv = host->private_data;
|
2007-02-01 06:06:36 +00:00
|
|
|
mmio = host->iomap[AHCI_PCI_BAR];
|
2005-04-16 22:20:36 +00: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-05 04:10:50 +00:00
|
|
|
irq_masked = irq_stat & hpriv->port_map;
|
|
|
|
|
2007-10-19 10:42:56 +00:00
|
|
|
spin_lock(&host->lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-10-19 10:42:56 +00:00
|
|
|
for (i = 0; i < host->n_ports; i++) {
|
2005-04-16 22:20:36 +00:00
|
|
|
struct ata_port *ap;
|
|
|
|
|
2008-07-05 04:10:50 +00:00
|
|
|
if (!(irq_masked & (1 << i)))
|
2005-10-05 06:58:32 +00:00
|
|
|
continue;
|
|
|
|
|
2006-08-24 07:19:22 +00:00
|
|
|
ap = host->ports[i];
|
2005-10-05 06:58:32 +00:00
|
|
|
if (ap) {
|
2007-05-27 00:46:51 +00:00
|
|
|
ahci_port_intr(ap);
|
2005-10-05 06:58:32 +00:00
|
|
|
VPRINTK("port %u\n", i);
|
|
|
|
} else {
|
|
|
|
VPRINTK("port %u (no irq)\n", i);
|
2006-03-11 03:47:54 +00:00
|
|
|
if (ata_ratelimit())
|
2006-08-24 07:19:22 +00:00
|
|
|
dev_printk(KERN_WARNING, host->dev,
|
2005-10-30 19:39:11 +00:00
|
|
|
"interrupt on disabled port %u\n", i);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2005-10-05 06:58:32 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
handled = 1;
|
|
|
|
}
|
|
|
|
|
2008-07-05 04:10:50 +00: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 16:49:02 +00:00
|
|
|
writel(irq_stat, mmio + HOST_IRQ_STAT);
|
|
|
|
|
2006-08-24 07:19:22 +00:00
|
|
|
spin_unlock(&host->lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
VPRINTK("EXIT\n");
|
|
|
|
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
}
|
|
|
|
|
2006-01-23 04:09:36 +00:00
|
|
|
static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
|
2005-04-16 22:20:36 +00: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 14:44:08 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-09-23 04:19:54 +00: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 22:20:36 +00:00
|
|
|
|
2006-05-15 12:03:55 +00:00
|
|
|
if (qc->tf.protocol == ATA_PROT_NCQ)
|
|
|
|
writel(1 << qc->tag, port_mmio + PORT_SCR_ACT);
|
|
|
|
writel(1 << qc->tag, port_mmio + PORT_CMD_ISSUE);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-06-03 17:33:55 +00:00
|
|
|
ahci_sw_activity(qc->dev->link);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-07 13:47:20 +00: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;
|
|
|
|
|
|
|
|
ata_tf_from_fis(d2h_fis, &qc->result_tf);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-05-15 11:58:29 +00: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 14:44:08 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-05-15 11:58:29 +00:00
|
|
|
|
|
|
|
/* turn IRQ off */
|
|
|
|
writel(0, port_mmio + PORT_IRQ_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_thaw(struct ata_port *ap)
|
|
|
|
{
|
2007-02-01 06:06:36 +00:00
|
|
|
void __iomem *mmio = ap->host->iomap[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 14:44:08 +00:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-05-15 11:58:29 +00:00
|
|
|
u32 tmp;
|
2007-08-09 21:23:41 +00:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2006-05-15 11:58:29 +00:00
|
|
|
|
|
|
|
/* clear IRQ */
|
|
|
|
tmp = readl(port_mmio + PORT_IRQ_STAT);
|
|
|
|
writel(tmp, port_mmio + PORT_IRQ_STAT);
|
2007-01-27 02:04:26 +00:00
|
|
|
writel(1 << ap->port_no, mmio + HOST_IRQ_STAT);
|
2006-05-15 11:58:29 +00:00
|
|
|
|
2007-10-09 06:01:37 +00:00
|
|
|
/* turn IRQ back on */
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
2006-05-15 11:58:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_error_handler(struct ata_port *ap)
|
|
|
|
{
|
2006-06-28 16:29:30 +00:00
|
|
|
if (!(ap->pflags & ATA_PFLAG_FROZEN)) {
|
2006-05-15 11:58:29 +00: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 14:44:08 +00:00
|
|
|
ahci_stop_engine(ap);
|
|
|
|
ahci_start_engine(ap);
|
2006-05-15 11:58:29 +00: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-25 03:22:50 +00:00
|
|
|
sata_pmp_error_handler(ap);
|
2007-10-25 05:59:16 +00:00
|
|
|
}
|
|
|
|
|
2006-05-15 11:58:29 +00:00
|
|
|
static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)
|
|
|
|
{
|
|
|
|
struct ata_port *ap = qc->ap;
|
|
|
|
|
2007-07-16 05:29:39 +00:00
|
|
|
/* make DMA engine forget about the failed command */
|
|
|
|
if (qc->flags & ATA_QCFLAG_FAILED)
|
2009-08-07 07:05:52 +00:00
|
|
|
ahci_kick_engine(ap);
|
2006-05-15 11:58:29 +00:00
|
|
|
}
|
|
|
|
|
2007-09-23 04:19:54 +00:00
|
|
|
static void ahci_pmp_attach(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-10-09 06:01:37 +00:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-09-23 04:19:54 +00:00
|
|
|
u32 cmd;
|
|
|
|
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
cmd |= PORT_CMD_PMP;
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
2007-10-09 06:01:37 +00:00
|
|
|
|
|
|
|
pp->intr_mask |= PORT_IRQ_BAD_PMP;
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
2007-09-23 04:19:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_pmp_detach(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-10-09 06:01:37 +00:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-09-23 04:19:54 +00:00
|
|
|
u32 cmd;
|
|
|
|
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
cmd &= ~PORT_CMD_PMP;
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
2007-10-09 06:01:37 +00:00
|
|
|
|
|
|
|
pp->intr_mask &= ~PORT_IRQ_BAD_PMP;
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
2007-09-23 04:19:54 +00:00
|
|
|
}
|
|
|
|
|
2007-07-17 19:48:48 +00:00
|
|
|
static int ahci_port_resume(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
ahci_power_up(ap);
|
|
|
|
ahci_start_port(ap);
|
|
|
|
|
2008-04-07 13:47:22 +00:00
|
|
|
if (sata_pmp_attached(ap))
|
2007-09-23 04:19:54 +00:00
|
|
|
ahci_pmp_attach(ap);
|
|
|
|
else
|
|
|
|
ahci_pmp_detach(ap);
|
|
|
|
|
2007-07-17 19:48:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-03-02 08:31:26 +00:00
|
|
|
#ifdef CONFIG_PM
|
2006-07-26 06:59:26 +00: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 14:44:08 +00:00
|
|
|
rc = ahci_deinit_port(ap, &emsg);
|
2006-11-20 06:42:36 +00: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 14:44:08 +00:00
|
|
|
ahci_power_down(ap);
|
2006-11-20 06:42:36 +00:00
|
|
|
else {
|
2006-07-26 06:59:26 +00:00
|
|
|
ata_port_printk(ap, KERN_ERR, "%s (%d)\n", emsg, rc);
|
2007-05-27 00:46:51 +00:00
|
|
|
ahci_start_port(ap);
|
2006-07-26 06:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
|
|
|
|
{
|
2006-08-24 07:19:22 +00:00
|
|
|
struct ata_host *host = dev_get_drvdata(&pdev->dev);
|
2009-05-30 11:50:12 +00:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
2007-02-01 06:06:36 +00:00
|
|
|
void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
|
2006-07-26 06:59:26 +00:00
|
|
|
u32 ctl;
|
|
|
|
|
2009-05-30 11:50:12 +00: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 18:13:25 +00:00
|
|
|
if (mesg.event & PM_EVENT_SLEEP) {
|
2006-07-26 06:59:26 +00: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 07:19:22 +00:00
|
|
|
struct ata_host *host = dev_get_drvdata(&pdev->dev);
|
2006-07-26 06:59:26 +00:00
|
|
|
int rc;
|
|
|
|
|
2006-12-26 10:39:50 +00:00
|
|
|
rc = ata_pci_device_do_resume(pdev);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
2006-07-26 06:59:26 +00:00
|
|
|
|
|
|
|
if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
rc = ahci_reset_controller(host);
|
2006-07-26 06:59:26 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
ahci_init_controller(host);
|
2006-07-26 06:59:26 +00:00
|
|
|
}
|
|
|
|
|
2006-08-24 07:19:22 +00:00
|
|
|
ata_host_resume(host);
|
2006-07-26 06:59:26 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-03-02 08:31:26 +00:00
|
|
|
#endif
|
2006-07-26 06:59:26 +00:00
|
|
|
|
2006-07-26 06:59:25 +00:00
|
|
|
static int ahci_port_start(struct ata_port *ap)
|
|
|
|
{
|
2006-08-24 07:19:22 +00:00
|
|
|
struct device *dev = ap->host->dev;
|
2006-07-26 06:59:25 +00:00
|
|
|
struct ahci_port_priv *pp;
|
|
|
|
void *mem;
|
|
|
|
dma_addr_t mem_dma;
|
|
|
|
|
2007-01-20 07:00:28 +00:00
|
|
|
pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
|
2006-07-26 06:59:25 +00:00
|
|
|
if (!pp)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2007-01-20 07:00:28 +00:00
|
|
|
mem = dmam_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma,
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!mem)
|
2006-07-26 06:59:25 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
|
|
|
mem += AHCI_RX_FIS_SZ;
|
|
|
|
mem_dma += AHCI_RX_FIS_SZ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 21:23:41 +00:00
|
|
|
/*
|
2007-10-19 10:42:56 +00:00
|
|
|
* Save off initial list of interrupts to be enabled.
|
|
|
|
* This could be changed later
|
|
|
|
*/
|
2007-08-09 21:23:41 +00:00
|
|
|
pp->intr_mask = DEF_PORT_IRQ;
|
|
|
|
|
2006-07-26 06:59:25 +00:00
|
|
|
ap->private_data = pp;
|
|
|
|
|
2007-05-27 00:46:51 +00:00
|
|
|
/* engage engines, captain */
|
|
|
|
return ahci_port_resume(ap);
|
2006-07-26 06:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_port_stop(struct ata_port *ap)
|
|
|
|
{
|
2006-07-26 06:59:26 +00:00
|
|
|
const char *emsg = NULL;
|
|
|
|
int rc;
|
2006-07-26 06:59:25 +00:00
|
|
|
|
2006-07-26 06:59:26 +00: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 14:44:08 +00:00
|
|
|
rc = ahci_deinit_port(ap, &emsg);
|
2006-07-26 06:59:26 +00:00
|
|
|
if (rc)
|
|
|
|
ata_port_printk(ap, KERN_WARNING, "%s (%d)\n", emsg, rc);
|
2006-07-26 06:59:25 +00:00
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (using_dac &&
|
2009-04-07 02:01:13 +00:00
|
|
|
!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
|
|
|
|
rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rc) {
|
2009-04-07 02:01:15 +00:00
|
|
|
rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rc) {
|
2005-10-30 19:39:11 +00:00
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"64-bit DMA enable failed\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2009-04-07 02:01:15 +00:00
|
|
|
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rc) {
|
2005-10-30 19:39:11 +00:00
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"32-bit DMA enable failed\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2009-04-07 02:01:15 +00:00
|
|
|
rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rc) {
|
2005-10-30 19:39:11 +00:00
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"32-bit consistent DMA enable failed\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
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 14:44:08 +00:00
|
|
|
static void ahci_print_info(struct ata_host *host)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
|
|
|
struct pci_dev *pdev = to_pci_dev(host->dev);
|
|
|
|
void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
|
2009-09-20 23:02:31 +00:00
|
|
|
u32 vers, cap, cap2, impl, speed;
|
2005-04-16 22:20:36 +00:00
|
|
|
const char *speed_s;
|
|
|
|
u16 cc;
|
|
|
|
const char *scc_s;
|
|
|
|
|
|
|
|
vers = readl(mmio + HOST_VERSION);
|
|
|
|
cap = hpriv->cap;
|
2009-09-20 23:02:31 +00:00
|
|
|
cap2 = hpriv->cap2;
|
2005-04-16 22:20:36 +00: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-30 03:00:37 +00:00
|
|
|
else if (speed == 3)
|
|
|
|
speed_s = "6";
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
|
|
|
speed_s = "?";
|
|
|
|
|
|
|
|
pci_read_config_word(pdev, 0x0a, &cc);
|
2007-01-09 10:32:51 +00:00
|
|
|
if (cc == PCI_CLASS_STORAGE_IDE)
|
2005-04-16 22:20:36 +00:00
|
|
|
scc_s = "IDE";
|
2007-01-09 10:32:51 +00:00
|
|
|
else if (cc == PCI_CLASS_STORAGE_SATA)
|
2005-04-16 22:20:36 +00:00
|
|
|
scc_s = "SATA";
|
2007-01-09 10:32:51 +00:00
|
|
|
else if (cc == PCI_CLASS_STORAGE_RAID)
|
2005-04-16 22:20:36 +00:00
|
|
|
scc_s = "RAID";
|
|
|
|
else
|
|
|
|
scc_s = "unknown";
|
|
|
|
|
2005-10-30 19:39:11 +00:00
|
|
|
dev_printk(KERN_INFO, &pdev->dev,
|
|
|
|
"AHCI %02x%02x.%02x%02x "
|
2005-04-16 22:20:36 +00:00
|
|
|
"%u slots %u ports %s Gbps 0x%x impl %s mode\n"
|
2007-10-19 10:42:56 +00:00
|
|
|
,
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-10-19 10:42:56 +00:00
|
|
|
(vers >> 24) & 0xff,
|
|
|
|
(vers >> 16) & 0xff,
|
|
|
|
(vers >> 8) & 0xff,
|
|
|
|
vers & 0xff,
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
((cap >> 8) & 0x1f) + 1,
|
|
|
|
(cap & 0x1f) + 1,
|
|
|
|
speed_s,
|
|
|
|
impl,
|
|
|
|
scc_s);
|
|
|
|
|
2005-10-30 19:39:11 +00:00
|
|
|
dev_printk(KERN_INFO, &pdev->dev,
|
|
|
|
"flags: "
|
2007-07-16 05:29:40 +00:00
|
|
|
"%s%s%s%s%s%s%s"
|
2008-06-03 17:33:55 +00:00
|
|
|
"%s%s%s%s%s%s%s"
|
2009-09-20 23:02:31 +00:00
|
|
|
"%s%s%s%s%s%s\n"
|
2007-10-19 10:42:56 +00:00
|
|
|
,
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-09-20 23:02:31 +00: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 22:20:36 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2007-10-25 05:59:16 +00: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 09:27:29 +00:00
|
|
|
/* only some SB600 ahci controllers can do 64bit DMA */
|
|
|
|
static bool ahci_sb600_enable_64bit(struct pci_dev *pdev)
|
2009-05-27 07:04:43 +00:00
|
|
|
{
|
|
|
|
static const struct dmi_system_id sysids[] = {
|
2009-08-16 12:04:02 +00:00
|
|
|
/*
|
|
|
|
* The oldest version known to be broken is 0901 and
|
|
|
|
* working is 1501 which was released on 2007-10-26.
|
2009-10-03 09:27:29 +00:00
|
|
|
* Enable 64bit DMA on 1501 and anything newer.
|
|
|
|
*
|
2009-08-16 12:04:02 +00:00
|
|
|
* Please read bko#9412 for more info.
|
|
|
|
*/
|
2009-05-27 07:04:43 +00:00
|
|
|
{
|
|
|
|
.ident = "ASUS M2A-VM",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BOARD_VENDOR,
|
|
|
|
"ASUSTeK Computer INC."),
|
|
|
|
DMI_MATCH(DMI_BOARD_NAME, "M2A-VM"),
|
|
|
|
},
|
2009-08-16 12:04:02 +00:00
|
|
|
.driver_data = "20071026", /* yyyymmdd */
|
2009-05-27 07:04:43 +00:00
|
|
|
},
|
|
|
|
{ }
|
|
|
|
};
|
2009-08-16 12:04:02 +00:00
|
|
|
const struct dmi_system_id *match;
|
2009-10-03 09:27:29 +00:00
|
|
|
int year, month, date;
|
|
|
|
char buf[9];
|
2009-05-27 07:04:43 +00:00
|
|
|
|
2009-08-16 12:04:02 +00:00
|
|
|
match = dmi_first_match(sysids);
|
2009-05-27 07:04:43 +00:00
|
|
|
if (pdev->bus->number != 0 || pdev->devfn != PCI_DEVFN(0x12, 0) ||
|
2009-08-16 12:04:02 +00:00
|
|
|
!match)
|
2009-05-27 07:04:43 +00:00
|
|
|
return false;
|
|
|
|
|
2009-10-03 09:27:29 +00:00
|
|
|
dmi_get_date(DMI_BIOS_DATE, &year, &month, &date);
|
|
|
|
snprintf(buf, sizeof(buf), "%04d%02d%02d", year, month, date);
|
2009-08-16 12:04:02 +00:00
|
|
|
|
2009-10-03 09:27:29 +00:00
|
|
|
if (strcmp(buf, match->driver_data) >= 0) {
|
|
|
|
dev_printk(KERN_WARNING, &pdev->dev, "%s: enabling 64bit DMA\n",
|
|
|
|
match->ident);
|
|
|
|
return true;
|
|
|
|
} else {
|
2009-08-16 12:04:02 +00:00
|
|
|
dev_printk(KERN_WARNING, &pdev->dev, "%s: BIOS too old, "
|
|
|
|
"forcing 32bit DMA, update BIOS\n", match->ident);
|
2009-10-03 09:27:29 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-05-27 07:04:43 +00:00
|
|
|
}
|
|
|
|
|
2009-01-19 19:57:36 +00: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 23:06:46 +00: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 19:57:36 +00: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 11:50:12 +00: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.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
.ident = "dv4",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME,
|
|
|
|
"HP Pavilion dv4 Notebook PC"),
|
|
|
|
},
|
|
|
|
.driver_data = "F.30", /* cutoff BIOS version */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.ident = "dv5",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME,
|
|
|
|
"HP Pavilion dv5 Notebook PC"),
|
|
|
|
},
|
|
|
|
.driver_data = "F.16", /* cutoff BIOS version */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.ident = "dv6",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME,
|
|
|
|
"HP Pavilion dv6 Notebook PC"),
|
|
|
|
},
|
|
|
|
.driver_data = "F.21", /* cutoff BIOS version */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.ident = "HDX18",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME,
|
|
|
|
"HP HDX18 Notebook PC"),
|
|
|
|
},
|
|
|
|
.driver_data = "F.23", /* cutoff BIOS version */
|
|
|
|
},
|
|
|
|
{ } /* terminate list */
|
|
|
|
};
|
|
|
|
const struct dmi_system_id *dmi = dmi_first_match(sysids);
|
|
|
|
const char *ver;
|
|
|
|
|
|
|
|
if (!dmi || pdev->bus->number || pdev->devfn != PCI_DEVFN(0x1f, 2))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ver = dmi_get_system_info(DMI_BIOS_VERSION);
|
|
|
|
|
|
|
|
return !ver || strcmp(ver, dmi->driver_data) < 0;
|
|
|
|
}
|
|
|
|
|
2009-08-04 05:30:08 +00: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);
|
|
|
|
}
|
|
|
|
|
2007-01-20 07:00:28 +00:00
|
|
|
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
static int printed_version;
|
2008-06-09 15:13:04 +00: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 14:44:08 +00:00
|
|
|
const struct ata_port_info *ppi[] = { &pi, NULL };
|
2007-01-20 07:00:28 +00:00
|
|
|
struct device *dev = &pdev->dev;
|
2005-04-16 22:20:36 +00: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 14:44:08 +00:00
|
|
|
struct ata_host *host;
|
2008-02-06 06:13:51 +00:00
|
|
|
int n_ports, i, rc;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
2006-05-15 12:03:55 +00:00
|
|
|
WARN_ON(ATA_MAX_QUEUE > AHCI_MAX_CMDS);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!printed_version++)
|
2005-10-30 19:39:11 +00:00
|
|
|
dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-09-03 13:48:34 +00: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;
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
/* acquire resources */
|
2007-01-20 07:00:28 +00:00
|
|
|
rc = pcim_enable_device(pdev);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2008-03-11 10:52:31 +00: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-02-01 06:06:36 +00:00
|
|
|
if (rc == -EBUSY)
|
2007-01-20 07:00:28 +00:00
|
|
|
pcim_pin_device(pdev);
|
2007-02-01 06:06:36 +00:00
|
|
|
if (rc)
|
2007-01-20 07:00:28 +00:00
|
|
|
return rc;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-12-06 06:09:43 +00: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 07:00:28 +00:00
|
|
|
hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
|
|
|
|
if (!hpriv)
|
|
|
|
return -ENOMEM;
|
2007-09-23 04:19:55 +00:00
|
|
|
hpriv->flags |= (unsigned long)pi.private_data;
|
|
|
|
|
2008-06-09 15:13:04 +00: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-30 02:53:41 +00: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 09:27:29 +00:00
|
|
|
/* only some SB600s can do 64bit DMA */
|
|
|
|
if (ahci_sb600_enable_64bit(pdev))
|
|
|
|
hpriv->flags &= ~AHCI_HFLAG_32BIT_ONLY;
|
2009-05-27 07:04:43 +00:00
|
|
|
|
2009-09-16 15:34:39 +00:00
|
|
|
if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev))
|
|
|
|
pci_intx(pdev, 1);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
/* save initial config */
|
2007-09-23 04:19:55 +00:00
|
|
|
ahci_save_initial_config(pdev, hpriv);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
/* prepare host */
|
2007-07-16 05:29:40 +00:00
|
|
|
if (hpriv->cap & HOST_CAP_NCQ)
|
2009-07-27 01:24:35 +00:00
|
|
|
pi.flags |= ATA_FLAG_NCQ | ATA_FLAG_FPDMA_AA;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-09-23 04:19:54 +00:00
|
|
|
if (hpriv->cap & HOST_CAP_PMP)
|
|
|
|
pi.flags |= ATA_FLAG_PMP;
|
|
|
|
|
2008-06-03 17:33:55 +00:00
|
|
|
if (ahci_em_messages && (hpriv->cap & HOST_CAP_EMS)) {
|
|
|
|
u8 messages;
|
|
|
|
void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
|
|
|
|
u32 em_loc = readl(mmio + HOST_EM_LOC);
|
|
|
|
u32 em_ctl = readl(mmio + HOST_EM_CTL);
|
|
|
|
|
2008-10-13 19:38:36 +00:00
|
|
|
messages = (em_ctl & EM_CTRL_MSG_TYPE) >> 16;
|
2008-06-03 17:33:55 +00: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 19:57:36 +00: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 11:50:12 +00: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-04 05:30:08 +00: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-06 06:13:51 +00: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 14:44:08 +00:00
|
|
|
if (!host)
|
|
|
|
return -ENOMEM;
|
|
|
|
host->iomap = pcim_iomap_table(pdev);
|
|
|
|
host->private_data = hpriv;
|
|
|
|
|
2009-01-26 10:05:44 +00:00
|
|
|
if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)
|
2009-01-09 23:54:07 +00:00
|
|
|
host->flags |= ATA_HOST_PARALLEL_SCAN;
|
2009-01-26 10:05:44 +00:00
|
|
|
else
|
|
|
|
printk(KERN_INFO "ahci: SSS flag set, parallel bus scan disabled\n");
|
2009-01-09 23:54:07 +00:00
|
|
|
|
2008-06-03 17:33:55 +00: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 14:44:08 +00:00
|
|
|
for (i = 0; i < host->n_ports; i++) {
|
2007-05-28 12:33:01 +00: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 14:44:08 +00:00
|
|
|
|
2007-08-18 04:14:55 +00: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-25 05:33:26 +00:00
|
|
|
/* set initial link pm policy */
|
|
|
|
ap->pm_policy = NOT_AVAILABLE;
|
|
|
|
|
2008-06-03 17:33:55 +00:00
|
|
|
/* set enclosure management message type */
|
|
|
|
if (ap->flags & ATA_FLAG_EM)
|
|
|
|
ap->em_message_type = ahci_em_messages;
|
|
|
|
|
|
|
|
|
2007-05-28 12:33:01 +00:00
|
|
|
/* disabled/not-implemented port */
|
2008-04-07 13:47:21 +00:00
|
|
|
if (!(hpriv->port_map & (1 << i)))
|
2007-05-28 12:33:01 +00: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 14:44:08 +00:00
|
|
|
}
|
2007-03-18 13:15:33 +00:00
|
|
|
|
2007-10-25 05:59:16 +00:00
|
|
|
/* apply workaround for ASUS P5W DH Deluxe mainboard */
|
|
|
|
ahci_p5wdh_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 14:44:08 +00:00
|
|
|
/* initialize adapter */
|
|
|
|
rc = ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rc)
|
2007-01-20 07:00:28 +00:00
|
|
|
return rc;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
rc = ahci_reset_controller(host);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
ahci_init_controller(host);
|
|
|
|
ahci_print_info(host);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
pci_set_master(pdev);
|
|
|
|
return ata_host_activate(host, pdev->irq, ahci_interrupt, IRQF_SHARED,
|
|
|
|
&ahci_sht);
|
2005-05-12 19:03:42 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static int __init ahci_init(void)
|
|
|
|
{
|
2006-08-10 09:13:18 +00:00
|
|
|
return pci_register_driver(&ahci_pci_driver);
|
2005-04-16 22:20:36 +00: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-23 06:53:51 +00:00
|
|
|
MODULE_VERSION(DRV_VERSION);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
module_init(ahci_init);
|
|
|
|
module_exit(ahci_exit);
|