2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* ahci.c - AHCI SATA support
|
|
|
|
*
|
2005-08-28 17:18:39 -07:00
|
|
|
* Maintained by: Jeff Garzik <jgarzik@pobox.com>
|
|
|
|
* Please ALWAYS copy linux-ide@vger.kernel.org
|
|
|
|
* on emails.
|
|
|
|
*
|
|
|
|
* Copyright 2004-2005 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* libata documentation is available via 'make {ps|pdf}docs',
|
|
|
|
* as Documentation/DocBook/libata.*
|
|
|
|
*
|
|
|
|
* AHCI hardware documentation:
|
2005-04-16 15:20:36 -07:00
|
|
|
* http://www.intel.com/technology/serialata/pdf/rev1_0.pdf
|
2005-08-28 17:18:39 -07:00
|
|
|
* http://www.intel.com/technology/serialata/pdf/rev1_1.pdf
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/interrupt.h>
|
2005-04-08 00:53:06 -07:00
|
|
|
#include <linux/dma-mapping.h>
|
2005-10-30 12:39:11 -07:00
|
|
|
#include <linux/device.h>
|
2007-10-24 22:59:16 -07:00
|
|
|
#include <linux/dmi.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <scsi/scsi_host.h>
|
2005-11-06 22:59:37 -07:00
|
|
|
#include <scsi/scsi_cmnd.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/libata.h>
|
|
|
|
|
|
|
|
#define DRV_NAME "ahci"
|
2007-09-22 21:19:54 -07:00
|
|
|
#define DRV_VERSION "3.0"
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-03-09 18:25:25 -07:00
|
|
|
static int ahci_skip_host_reset;
|
|
|
|
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)");
|
|
|
|
|
2007-10-24 22:33:26 -07:00
|
|
|
static int ahci_enable_alpm(struct ata_port *ap,
|
|
|
|
enum link_pm policy);
|
|
|
|
static void ahci_disable_alpm(struct ata_port *ap);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
enum {
|
|
|
|
AHCI_PCI_BAR = 5,
|
2006-11-08 23:08:40 -07:00
|
|
|
AHCI_MAX_PORTS = 32,
|
2005-04-16 15:20:36 -07:00
|
|
|
AHCI_MAX_SG = 168, /* hardware max is 64K */
|
|
|
|
AHCI_DMA_BOUNDARY = 0xffffffff,
|
2006-05-15 05:03:55 -07:00
|
|
|
AHCI_MAX_CMDS = 32,
|
2006-05-15 05:03:50 -07:00
|
|
|
AHCI_CMD_SZ = 32,
|
2006-05-15 05:03:55 -07:00
|
|
|
AHCI_CMD_SLOT_SZ = AHCI_MAX_CMDS * AHCI_CMD_SZ,
|
2005-04-16 15:20:36 -07:00
|
|
|
AHCI_RX_FIS_SZ = 256,
|
2005-06-03 22:13:15 -07:00
|
|
|
AHCI_CMD_TBL_CDB = 0x40,
|
2006-05-15 05:03:50 -07:00
|
|
|
AHCI_CMD_TBL_HDR_SZ = 0x80,
|
|
|
|
AHCI_CMD_TBL_SZ = AHCI_CMD_TBL_HDR_SZ + (AHCI_MAX_SG * 16),
|
|
|
|
AHCI_CMD_TBL_AR_SZ = AHCI_CMD_TBL_SZ * AHCI_MAX_CMDS,
|
|
|
|
AHCI_PORT_PRIV_DMA_SZ = AHCI_CMD_SLOT_SZ + AHCI_CMD_TBL_AR_SZ +
|
2005-04-16 15:20:36 -07:00
|
|
|
AHCI_RX_FIS_SZ,
|
|
|
|
AHCI_IRQ_ON_SG = (1 << 31),
|
|
|
|
AHCI_CMD_ATAPI = (1 << 5),
|
|
|
|
AHCI_CMD_WRITE = (1 << 6),
|
2006-03-11 19:25:27 -07:00
|
|
|
AHCI_CMD_PREFETCH = (1 << 7),
|
2006-01-23 05:38:44 -07:00
|
|
|
AHCI_CMD_RESET = (1 << 8),
|
|
|
|
AHCI_CMD_CLR_BUSY = (1 << 10),
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
RX_FIS_D2H_REG = 0x40, /* offset of D2H Register FIS data */
|
2007-01-25 03:16:28 -07:00
|
|
|
RX_FIS_SDB = 0x58, /* offset of SDB FIS data */
|
2006-05-15 04:58:29 -07:00
|
|
|
RX_FIS_UNK = 0x60, /* offset of Unknown FIS data */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
board_ahci = 0,
|
2007-09-02 20:44:57 -07:00
|
|
|
board_ahci_vt8251 = 1,
|
|
|
|
board_ahci_ign_iferr = 2,
|
|
|
|
board_ahci_sb600 = 3,
|
|
|
|
board_ahci_mv = 4,
|
2008-02-22 06:00:31 -07:00
|
|
|
board_ahci_sb700 = 5,
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* global controller registers */
|
|
|
|
HOST_CAP = 0x00, /* host capabilities */
|
|
|
|
HOST_CTL = 0x04, /* global host control */
|
|
|
|
HOST_IRQ_STAT = 0x08, /* interrupt status */
|
|
|
|
HOST_PORTS_IMPL = 0x0c, /* bitmap of implemented ports */
|
|
|
|
HOST_VERSION = 0x10, /* AHCI spec. version compliancy */
|
|
|
|
|
|
|
|
/* 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 */
|
2006-07-25 23:59:26 -07:00
|
|
|
HOST_CAP_SSC = (1 << 14), /* Slumber capable */
|
2007-09-22 21:19:54 -07:00
|
|
|
HOST_CAP_PMP = (1 << 17), /* Port Multiplier support */
|
2006-01-23 05:38:44 -07:00
|
|
|
HOST_CAP_CLO = (1 << 24), /* Command List Override support */
|
2007-10-24 22:33:26 -07:00
|
|
|
HOST_CAP_ALPM = (1 << 26), /* Aggressive Link PM support */
|
2006-07-25 23:59:26 -07:00
|
|
|
HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */
|
2007-07-15 22:29:40 -07:00
|
|
|
HOST_CAP_SNTF = (1 << 29), /* SNotification register */
|
2006-05-15 05:03:52 -07:00
|
|
|
HOST_CAP_NCQ = (1 << 30), /* Native Command Queueing */
|
2006-05-15 05:03:50 -07:00
|
|
|
HOST_CAP_64 = (1 << 31), /* PCI DAC (64-bit DMA) support */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* registers for each SATA port */
|
|
|
|
PORT_LST_ADDR = 0x00, /* command list DMA addr */
|
|
|
|
PORT_LST_ADDR_HI = 0x04, /* command list DMA addr hi */
|
|
|
|
PORT_FIS_ADDR = 0x08, /* FIS rx buf addr */
|
|
|
|
PORT_FIS_ADDR_HI = 0x0c, /* FIS rx buf addr hi */
|
|
|
|
PORT_IRQ_STAT = 0x10, /* interrupt status */
|
|
|
|
PORT_IRQ_MASK = 0x14, /* interrupt enable/disable mask */
|
|
|
|
PORT_CMD = 0x18, /* port command */
|
|
|
|
PORT_TFDATA = 0x20, /* taskfile data */
|
|
|
|
PORT_SIG = 0x24, /* device TF signature */
|
|
|
|
PORT_CMD_ISSUE = 0x38, /* command issue */
|
|
|
|
PORT_SCR_STAT = 0x28, /* SATA phy register: SStatus */
|
|
|
|
PORT_SCR_CTL = 0x2c, /* SATA phy register: SControl */
|
|
|
|
PORT_SCR_ERR = 0x30, /* SATA phy register: SError */
|
|
|
|
PORT_SCR_ACT = 0x34, /* SATA phy register: SActive */
|
2007-07-15 22:29:40 -07:00
|
|
|
PORT_SCR_NTF = 0x3c, /* SATA phy register: SNotification */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* PORT_IRQ_{STAT,MASK} bits */
|
|
|
|
PORT_IRQ_COLD_PRES = (1 << 31), /* cold presence detect */
|
|
|
|
PORT_IRQ_TF_ERR = (1 << 30), /* task file error */
|
|
|
|
PORT_IRQ_HBUS_ERR = (1 << 29), /* host bus fatal error */
|
|
|
|
PORT_IRQ_HBUS_DATA_ERR = (1 << 28), /* host bus data error */
|
|
|
|
PORT_IRQ_IF_ERR = (1 << 27), /* interface fatal error */
|
|
|
|
PORT_IRQ_IF_NONFATAL = (1 << 26), /* interface non-fatal error */
|
|
|
|
PORT_IRQ_OVERFLOW = (1 << 24), /* xfer exhausted available S/G */
|
|
|
|
PORT_IRQ_BAD_PMP = (1 << 23), /* incorrect port multiplier */
|
|
|
|
|
|
|
|
PORT_IRQ_PHYRDY = (1 << 22), /* PhyRdy changed */
|
|
|
|
PORT_IRQ_DEV_ILCK = (1 << 7), /* device interlock */
|
|
|
|
PORT_IRQ_CONNECT = (1 << 6), /* port connect change status */
|
|
|
|
PORT_IRQ_SG_DONE = (1 << 5), /* descriptor processed */
|
|
|
|
PORT_IRQ_UNK_FIS = (1 << 4), /* unknown FIS rx'd */
|
|
|
|
PORT_IRQ_SDB_FIS = (1 << 3), /* Set Device Bits FIS rx'd */
|
|
|
|
PORT_IRQ_DMAS_FIS = (1 << 2), /* DMA Setup FIS rx'd */
|
|
|
|
PORT_IRQ_PIOS_FIS = (1 << 1), /* PIO Setup FIS rx'd */
|
|
|
|
PORT_IRQ_D2H_REG_FIS = (1 << 0), /* D2H Register FIS rx'd */
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
PORT_IRQ_FREEZE = PORT_IRQ_HBUS_ERR |
|
|
|
|
PORT_IRQ_IF_ERR |
|
|
|
|
PORT_IRQ_CONNECT |
|
2006-05-31 02:28:18 -07:00
|
|
|
PORT_IRQ_PHYRDY |
|
2007-09-22 21:19:54 -07:00
|
|
|
PORT_IRQ_UNK_FIS |
|
|
|
|
PORT_IRQ_BAD_PMP,
|
2006-05-15 04:58:29 -07:00
|
|
|
PORT_IRQ_ERROR = PORT_IRQ_FREEZE |
|
|
|
|
PORT_IRQ_TF_ERR |
|
|
|
|
PORT_IRQ_HBUS_DATA_ERR,
|
|
|
|
DEF_PORT_IRQ = PORT_IRQ_ERROR | PORT_IRQ_SG_DONE |
|
|
|
|
PORT_IRQ_SDB_FIS | PORT_IRQ_DMAS_FIS |
|
|
|
|
PORT_IRQ_PIOS_FIS | PORT_IRQ_D2H_REG_FIS,
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* PORT_CMD bits */
|
2007-10-24 22:33:26 -07:00
|
|
|
PORT_CMD_ASP = (1 << 27), /* Aggressive Slumber/Partial */
|
|
|
|
PORT_CMD_ALPE = (1 << 26), /* Aggressive Link PM enable */
|
2005-11-11 23:32:19 -07:00
|
|
|
PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */
|
2007-09-22 21:19:54 -07:00
|
|
|
PORT_CMD_PMP = (1 << 17), /* PMP attached */
|
2005-04-16 15:20:36 -07:00
|
|
|
PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */
|
|
|
|
PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */
|
|
|
|
PORT_CMD_FIS_RX = (1 << 4), /* Enable FIS receive DMA engine */
|
2006-01-23 05:38:44 -07:00
|
|
|
PORT_CMD_CLO = (1 << 3), /* Command list override */
|
2005-04-16 15:20:36 -07:00
|
|
|
PORT_CMD_POWER_ON = (1 << 2), /* Power up device */
|
|
|
|
PORT_CMD_SPIN_UP = (1 << 1), /* Spin up device */
|
|
|
|
PORT_CMD_START = (1 << 0), /* Enable port DMA engine */
|
|
|
|
|
2006-07-25 23:59:26 -07:00
|
|
|
PORT_CMD_ICC_MASK = (0xf << 28), /* i/f ICC state mask */
|
2005-04-16 15:20:36 -07:00
|
|
|
PORT_CMD_ICC_ACTIVE = (0x1 << 28), /* Put i/f in active state */
|
|
|
|
PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */
|
|
|
|
PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */
|
2005-06-03 21:50:22 -07:00
|
|
|
|
2007-09-22 21:19:55 -07:00
|
|
|
/* hpriv->flags bits */
|
|
|
|
AHCI_HFLAG_NO_NCQ = (1 << 0),
|
|
|
|
AHCI_HFLAG_IGN_IRQ_IF_ERR = (1 << 1), /* ignore IRQ_IF_ERR */
|
|
|
|
AHCI_HFLAG_IGN_SERR_INTERNAL = (1 << 2), /* ignore SERR_INTERNAL */
|
|
|
|
AHCI_HFLAG_32BIT_ONLY = (1 << 3), /* force 32bit */
|
|
|
|
AHCI_HFLAG_MV_PATA = (1 << 4), /* PATA port */
|
|
|
|
AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */
|
2007-09-22 21:19:55 -07:00
|
|
|
AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */
|
2007-10-24 22:33:26 -07:00
|
|
|
AHCI_HFLAG_NO_HOTPLUG = (1 << 7), /* ignore PxSERR.DIAG.N */
|
2008-02-28 13:43:48 -07:00
|
|
|
AHCI_HFLAG_SECT255 = (1 << 8), /* max 255 sectors */
|
2007-09-22 21:19:55 -07:00
|
|
|
|
2006-04-17 05:17:59 -07:00
|
|
|
/* ap->flags bits */
|
2007-04-22 10:41:05 -07:00
|
|
|
|
|
|
|
AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
|
|
|
|
ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
|
2007-10-24 22:33:26 -07:00
|
|
|
ATA_FLAG_ACPI_SATA | ATA_FLAG_AN |
|
|
|
|
ATA_FLAG_IPM,
|
2007-12-05 23:09:43 -07:00
|
|
|
|
|
|
|
ICH_MAP = 0x90, /* ICH MAP register */
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ahci_cmd_hdr {
|
2007-12-30 02:32:22 -07:00
|
|
|
__le32 opts;
|
|
|
|
__le32 status;
|
|
|
|
__le32 tbl_addr;
|
|
|
|
__le32 tbl_addr_hi;
|
|
|
|
__le32 reserved[4];
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ahci_sg {
|
2007-12-30 02:32:22 -07:00
|
|
|
__le32 addr;
|
|
|
|
__le32 addr_hi;
|
|
|
|
__le32 reserved;
|
|
|
|
__le32 flags_size;
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ahci_host_priv {
|
2007-09-22 21:19:55 -07:00
|
|
|
unsigned int flags; /* AHCI_HFLAG_* */
|
2007-03-18 06:15:33 -07:00
|
|
|
u32 cap; /* cap to use */
|
|
|
|
u32 port_map; /* port map to use */
|
|
|
|
u32 saved_cap; /* saved initial cap */
|
|
|
|
u32 saved_port_map; /* saved initial port_map */
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ahci_port_priv {
|
2007-09-22 21:19:54 -07:00
|
|
|
struct ata_link *active_link;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ahci_cmd_hdr *cmd_slot;
|
|
|
|
dma_addr_t cmd_slot_dma;
|
|
|
|
void *cmd_tbl;
|
|
|
|
dma_addr_t cmd_tbl_dma;
|
|
|
|
void *rx_fis;
|
|
|
|
dma_addr_t rx_fis_dma;
|
2007-01-25 03:16:28 -07:00
|
|
|
/* for NCQ spurious interrupt analysis */
|
|
|
|
unsigned int ncq_saw_d2h:1;
|
|
|
|
unsigned int ncq_saw_dmas:1;
|
2007-02-26 21:24:19 -07:00
|
|
|
unsigned int ncq_saw_sdb:1;
|
2007-08-09 14:23:41 -07:00
|
|
|
u32 intr_mask; /* interrupts to enable */
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
2007-07-15 22:29:40 -07:00
|
|
|
static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val);
|
|
|
|
static int ahci_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val);
|
2007-10-19 03:42:56 -07:00
|
|
|
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
|
2006-01-22 21:09:36 -07:00
|
|
|
static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc);
|
2005-04-16 15:20:36 -07:00
|
|
|
static int ahci_port_start(struct ata_port *ap);
|
|
|
|
static void ahci_port_stop(struct ata_port *ap);
|
|
|
|
static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
|
|
|
|
static void ahci_qc_prep(struct ata_queued_cmd *qc);
|
|
|
|
static u8 ahci_check_status(struct ata_port *ap);
|
2006-05-15 04:58:29 -07:00
|
|
|
static void ahci_freeze(struct ata_port *ap);
|
|
|
|
static void ahci_thaw(struct ata_port *ap);
|
2007-09-22 21:19:54 -07:00
|
|
|
static void ahci_pmp_attach(struct ata_port *ap);
|
|
|
|
static void ahci_pmp_detach(struct ata_port *ap);
|
2006-05-15 04:58:29 -07:00
|
|
|
static void ahci_error_handler(struct ata_port *ap);
|
2006-11-01 02:00:24 -07:00
|
|
|
static void ahci_vt8251_error_handler(struct ata_port *ap);
|
2007-10-24 22:59:16 -07:00
|
|
|
static void ahci_p5wdh_error_handler(struct ata_port *ap);
|
2006-05-15 04:58:29 -07:00
|
|
|
static void ahci_post_internal_cmd(struct ata_queued_cmd *qc);
|
2007-05-26 17:46:51 -07:00
|
|
|
static int ahci_port_resume(struct ata_port *ap);
|
2008-02-28 13:43:48 -07:00
|
|
|
static void ahci_dev_config(struct ata_device *dev);
|
2007-05-28 05:33:01 -07:00
|
|
|
static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl);
|
|
|
|
static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
|
|
|
|
u32 opts);
|
2007-03-02 01:31:26 -07:00
|
|
|
#ifdef CONFIG_PM
|
2006-07-25 23:59:26 -07:00
|
|
|
static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg);
|
|
|
|
static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
|
|
|
|
static int ahci_pci_device_resume(struct pci_dev *pdev);
|
2007-03-02 01:31:26 -07:00
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-10-24 22:33:26 -07:00
|
|
|
static struct class_device_attribute *ahci_shost_attrs[] = {
|
|
|
|
&class_device_attr_link_power_management_policy,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2005-11-06 22:59:37 -07:00
|
|
|
static struct scsi_host_template ahci_sht = {
|
2008-03-24 20:22:49 -07:00
|
|
|
ATA_NCQ_SHT(DRV_NAME),
|
2006-05-15 05:03:55 -07:00
|
|
|
.can_queue = AHCI_MAX_CMDS - 1,
|
2005-04-16 15:20:36 -07:00
|
|
|
.sg_tablesize = AHCI_MAX_SG,
|
|
|
|
.dma_boundary = AHCI_DMA_BOUNDARY,
|
2007-10-24 22:33:26 -07:00
|
|
|
.shost_attrs = ahci_shost_attrs,
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
2005-10-22 11:27:05 -07:00
|
|
|
static const struct ata_port_operations ahci_ops = {
|
2005-04-16 15:20:36 -07:00
|
|
|
.check_status = ahci_check_status,
|
|
|
|
.check_altstatus = ahci_check_status,
|
|
|
|
.dev_select = ata_noop_dev_select,
|
|
|
|
|
2008-02-28 13:43:48 -07:00
|
|
|
.dev_config = ahci_dev_config,
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
.tf_read = ahci_tf_read,
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
.qc_defer = sata_pmp_qc_defer_cmd_switch,
|
2005-04-16 15:20:36 -07:00
|
|
|
.qc_prep = ahci_qc_prep,
|
|
|
|
.qc_issue = ahci_qc_issue,
|
|
|
|
|
2008-03-24 20:22:47 -07:00
|
|
|
.irq_clear = ata_noop_irq_clear,
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
.scr_read = ahci_scr_read,
|
|
|
|
.scr_write = ahci_scr_write,
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
.freeze = ahci_freeze,
|
|
|
|
.thaw = ahci_thaw,
|
|
|
|
|
|
|
|
.error_handler = ahci_error_handler,
|
|
|
|
.post_internal_cmd = ahci_post_internal_cmd,
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
.pmp_attach = ahci_pmp_attach,
|
|
|
|
.pmp_detach = ahci_pmp_detach,
|
|
|
|
|
2007-03-02 01:31:26 -07:00
|
|
|
#ifdef CONFIG_PM
|
2006-07-25 23:59:26 -07:00
|
|
|
.port_suspend = ahci_port_suspend,
|
|
|
|
.port_resume = ahci_port_resume,
|
2007-03-02 01:31:26 -07:00
|
|
|
#endif
|
2007-10-24 22:33:26 -07:00
|
|
|
.enable_pm = ahci_enable_alpm,
|
|
|
|
.disable_pm = ahci_disable_alpm,
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
.port_start = ahci_port_start,
|
|
|
|
.port_stop = ahci_port_stop,
|
|
|
|
};
|
|
|
|
|
2006-11-01 02:00:24 -07:00
|
|
|
static const struct ata_port_operations ahci_vt8251_ops = {
|
|
|
|
.check_status = ahci_check_status,
|
|
|
|
.check_altstatus = ahci_check_status,
|
|
|
|
.dev_select = ata_noop_dev_select,
|
|
|
|
|
2008-03-24 20:22:48 -07:00
|
|
|
.dev_config = ahci_dev_config,
|
|
|
|
|
2006-11-01 02:00:24 -07:00
|
|
|
.tf_read = ahci_tf_read,
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
.qc_defer = sata_pmp_qc_defer_cmd_switch,
|
2006-11-01 02:00:24 -07:00
|
|
|
.qc_prep = ahci_qc_prep,
|
|
|
|
.qc_issue = ahci_qc_issue,
|
|
|
|
|
2008-03-24 20:22:47 -07:00
|
|
|
.irq_clear = ata_noop_irq_clear,
|
2006-11-01 02:00:24 -07:00
|
|
|
|
|
|
|
.scr_read = ahci_scr_read,
|
|
|
|
.scr_write = ahci_scr_write,
|
|
|
|
|
|
|
|
.freeze = ahci_freeze,
|
|
|
|
.thaw = ahci_thaw,
|
|
|
|
|
|
|
|
.error_handler = ahci_vt8251_error_handler,
|
|
|
|
.post_internal_cmd = ahci_post_internal_cmd,
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
.pmp_attach = ahci_pmp_attach,
|
|
|
|
.pmp_detach = ahci_pmp_detach,
|
|
|
|
|
2007-03-02 01:31:26 -07:00
|
|
|
#ifdef CONFIG_PM
|
2006-11-01 02:00:24 -07:00
|
|
|
.port_suspend = ahci_port_suspend,
|
|
|
|
.port_resume = ahci_port_resume,
|
2007-03-02 01:31:26 -07:00
|
|
|
#endif
|
2008-03-24 20:22:48 -07:00
|
|
|
.enable_pm = ahci_enable_alpm,
|
|
|
|
.disable_pm = ahci_disable_alpm,
|
2006-11-01 02:00:24 -07:00
|
|
|
|
|
|
|
.port_start = ahci_port_start,
|
|
|
|
.port_stop = ahci_port_stop,
|
|
|
|
};
|
|
|
|
|
2007-10-24 22:59:16 -07:00
|
|
|
static const struct ata_port_operations ahci_p5wdh_ops = {
|
|
|
|
.check_status = ahci_check_status,
|
|
|
|
.check_altstatus = ahci_check_status,
|
|
|
|
.dev_select = ata_noop_dev_select,
|
|
|
|
|
2008-03-24 20:22:48 -07:00
|
|
|
.dev_config = ahci_dev_config,
|
|
|
|
|
2007-10-24 22:59:16 -07:00
|
|
|
.tf_read = ahci_tf_read,
|
|
|
|
|
|
|
|
.qc_defer = sata_pmp_qc_defer_cmd_switch,
|
|
|
|
.qc_prep = ahci_qc_prep,
|
|
|
|
.qc_issue = ahci_qc_issue,
|
|
|
|
|
2008-03-24 20:22:47 -07:00
|
|
|
.irq_clear = ata_noop_irq_clear,
|
2007-10-24 22:59:16 -07:00
|
|
|
|
|
|
|
.scr_read = ahci_scr_read,
|
|
|
|
.scr_write = ahci_scr_write,
|
|
|
|
|
|
|
|
.freeze = ahci_freeze,
|
|
|
|
.thaw = ahci_thaw,
|
|
|
|
|
|
|
|
.error_handler = ahci_p5wdh_error_handler,
|
|
|
|
.post_internal_cmd = ahci_post_internal_cmd,
|
|
|
|
|
|
|
|
.pmp_attach = ahci_pmp_attach,
|
|
|
|
.pmp_detach = ahci_pmp_detach,
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
.port_suspend = ahci_port_suspend,
|
|
|
|
.port_resume = ahci_port_resume,
|
|
|
|
#endif
|
2008-03-24 20:22:48 -07:00
|
|
|
.enable_pm = ahci_enable_alpm,
|
|
|
|
.disable_pm = ahci_disable_alpm,
|
2007-10-24 22:59:16 -07:00
|
|
|
|
|
|
|
.port_start = ahci_port_start,
|
|
|
|
.port_stop = ahci_port_stop,
|
|
|
|
};
|
|
|
|
|
2007-09-22 21:19:55 -07:00
|
|
|
#define AHCI_HFLAGS(flags) .private_data = (void *)(flags)
|
|
|
|
|
2005-11-28 02:06:23 -07:00
|
|
|
static const struct ata_port_info ahci_port_info[] = {
|
2005-04-16 15:20:36 -07:00
|
|
|
/* board_ahci */
|
|
|
|
{
|
2007-04-22 10:41:05 -07:00
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2005-09-01 18:53:34 -07:00
|
|
|
.pio_mask = 0x1f, /* pio0-4 */
|
2007-07-07 22:13:16 -07:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2005-04-16 15:20:36 -07:00
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2006-04-17 05:17:59 -07:00
|
|
|
/* board_ahci_vt8251 */
|
|
|
|
{
|
2007-09-22 21:19:55 -07:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_PMP),
|
2007-09-22 21:19:55 -07:00
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2006-04-17 05:17:59 -07:00
|
|
|
.pio_mask = 0x1f, /* pio0-4 */
|
2007-07-07 22:13:16 -07:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2006-11-01 02:00:24 -07:00
|
|
|
.port_ops = &ahci_vt8251_ops,
|
2006-04-17 05:17:59 -07:00
|
|
|
},
|
2006-11-28 19:33:14 -07:00
|
|
|
/* board_ahci_ign_iferr */
|
|
|
|
{
|
2007-09-22 21:19:55 -07:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_IGN_IRQ_IF_ERR),
|
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2006-11-28 19:33:14 -07:00
|
|
|
.pio_mask = 0x1f, /* pio0-4 */
|
2007-07-07 22:13:16 -07:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2006-11-28 19:33:14 -07:00
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2007-03-27 03:33:05 -07:00
|
|
|
/* board_ahci_sb600 */
|
|
|
|
{
|
2007-09-22 21:19:55 -07:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL |
|
2008-03-24 19:40:40 -07:00
|
|
|
AHCI_HFLAG_32BIT_ONLY |
|
2008-02-28 13:43:48 -07:00
|
|
|
AHCI_HFLAG_SECT255 | AHCI_HFLAG_NO_PMP),
|
2007-09-22 21:19:55 -07:00
|
|
|
.flags = AHCI_FLAG_COMMON,
|
2007-03-27 03:33:05 -07:00
|
|
|
.pio_mask = 0x1f, /* pio0-4 */
|
2007-07-07 22:13:16 -07:00
|
|
|
.udma_mask = ATA_UDMA6,
|
2007-03-27 03:33:05 -07:00
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2007-07-07 23:29:42 -07:00
|
|
|
/* board_ahci_mv */
|
|
|
|
{
|
2007-09-22 21:19:55 -07:00
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_MSI |
|
|
|
|
AHCI_HFLAG_MV_PATA),
|
2007-07-07 23:29:42 -07:00
|
|
|
.flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
|
2007-09-22 21:19:55 -07:00
|
|
|
ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA,
|
2007-07-07 23:29:42 -07:00
|
|
|
.pio_mask = 0x1f, /* pio0-4 */
|
|
|
|
.udma_mask = ATA_UDMA6,
|
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2008-02-22 06:00:31 -07:00
|
|
|
/* board_ahci_sb700 */
|
|
|
|
{
|
|
|
|
AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL |
|
|
|
|
AHCI_HFLAG_NO_PMP),
|
|
|
|
.flags = AHCI_FLAG_COMMON,
|
|
|
|
.pio_mask = 0x1f, /* pio0-4 */
|
|
|
|
.udma_mask = ATA_UDMA6,
|
|
|
|
.port_ops = &ahci_ops,
|
|
|
|
},
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
2005-11-10 09:04:11 -07:00
|
|
|
static const struct pci_device_id ahci_pci_tbl[] = {
|
2006-06-22 20:05:36 -07:00
|
|
|
/* Intel */
|
2006-09-27 19:20:11 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x2652), board_ahci }, /* ICH6 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2653), board_ahci }, /* ICH6M */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x27c1), board_ahci }, /* ICH7 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x27c5), board_ahci }, /* ICH7M */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x27c3), board_ahci }, /* ICH7R */
|
2007-01-22 23:13:39 -07:00
|
|
|
{ PCI_VDEVICE(AL, 0x5288), board_ahci_ign_iferr }, /* ULi M5288 */
|
2006-09-27 19:20:11 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x2681), board_ahci }, /* ESB2 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2682), board_ahci }, /* ESB2 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x2683), board_ahci }, /* ESB2 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x27c6), board_ahci }, /* ICH7-M DH */
|
2007-09-02 20:44:57 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x2821), board_ahci }, /* ICH8 */
|
|
|
|
{ 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 14:35:00 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x502a), board_ahci }, /* Tolapai */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x502b), board_ahci }, /* Tolapai */
|
2008-01-28 18:34:14 -07:00
|
|
|
{ PCI_VDEVICE(INTEL, 0x3a05), board_ahci }, /* ICH10 */
|
|
|
|
{ PCI_VDEVICE(INTEL, 0x3a25), board_ahci }, /* ICH10 */
|
2006-06-22 20:05:36 -07:00
|
|
|
|
2007-02-26 04:24:03 -07:00
|
|
|
/* JMicron 360/1/3/5/6, match class to avoid IDE function */
|
|
|
|
{ PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci_ign_iferr },
|
2006-06-22 20:05:36 -07:00
|
|
|
|
|
|
|
/* ATI */
|
2007-04-11 03:23:14 -07:00
|
|
|
{ PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */
|
2008-02-22 06:00:31 -07:00
|
|
|
{ PCI_VDEVICE(ATI, 0x4390), board_ahci_sb700 }, /* ATI SB700/800 */
|
|
|
|
{ PCI_VDEVICE(ATI, 0x4391), board_ahci_sb700 }, /* ATI SB700/800 */
|
|
|
|
{ PCI_VDEVICE(ATI, 0x4392), board_ahci_sb700 }, /* ATI SB700/800 */
|
|
|
|
{ PCI_VDEVICE(ATI, 0x4393), board_ahci_sb700 }, /* ATI SB700/800 */
|
|
|
|
{ PCI_VDEVICE(ATI, 0x4394), board_ahci_sb700 }, /* ATI SB700/800 */
|
|
|
|
{ PCI_VDEVICE(ATI, 0x4395), board_ahci_sb700 }, /* ATI SB700/800 */
|
2006-06-22 20:05:36 -07:00
|
|
|
|
|
|
|
/* VIA */
|
2006-09-27 19:20:11 -07:00
|
|
|
{ PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */
|
2007-04-11 01:27:14 -07:00
|
|
|
{ PCI_VDEVICE(VIA, 0x6287), board_ahci_vt8251 }, /* VIA VT8251 */
|
2006-06-22 20:05:36 -07:00
|
|
|
|
|
|
|
/* NVIDIA */
|
2006-09-27 19:20:11 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x044c), board_ahci }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x044d), board_ahci }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x044e), board_ahci }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x044f), board_ahci }, /* MCP65 */
|
2006-12-20 12:18:00 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x045c), board_ahci }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x045d), board_ahci }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x045e), board_ahci }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x045f), board_ahci }, /* MCP65 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0550), board_ahci }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0551), board_ahci }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0552), board_ahci }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0553), board_ahci }, /* MCP67 */
|
2006-11-02 15:59:46 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0554), board_ahci }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0555), board_ahci }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0556), board_ahci }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0557), board_ahci }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0558), board_ahci }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0559), board_ahci }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x055a), board_ahci }, /* MCP67 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x055b), board_ahci }, /* MCP67 */
|
2007-06-07 03:05:12 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f0), board_ahci }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f1), board_ahci }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f2), board_ahci }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f3), board_ahci }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f4), board_ahci }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f5), board_ahci }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f6), board_ahci }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f7), board_ahci }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f8), board_ahci }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07f9), board_ahci }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07fa), board_ahci }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x07fb), board_ahci }, /* MCP73 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad0), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad1), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad2), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad3), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad4), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad5), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad6), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad7), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad8), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ad9), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ada), board_ahci }, /* MCP77 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0adb), board_ahci }, /* MCP77 */
|
2007-12-03 07:20:37 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ab4), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ab5), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ab6), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ab7), board_ahci }, /* MCP79 */
|
2007-09-23 19:16:25 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ab8), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0ab9), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0aba), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0abb), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0abc), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */
|
2008-03-06 06:22:41 -07:00
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0bc8), board_ahci }, /* MCP7B */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0bc9), board_ahci }, /* MCP7B */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0bca), board_ahci }, /* MCP7B */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0bcb), board_ahci }, /* MCP7B */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0bcc), board_ahci }, /* MCP7B */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0bcd), board_ahci }, /* MCP7B */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0bce), board_ahci }, /* MCP7B */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0bcf), board_ahci }, /* MCP7B */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0bd0), board_ahci }, /* MCP7B */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0bd1), board_ahci }, /* MCP7B */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0bd2), board_ahci }, /* MCP7B */
|
|
|
|
{ PCI_VDEVICE(NVIDIA, 0x0bd3), board_ahci }, /* MCP7B */
|
2006-06-22 20:05:36 -07:00
|
|
|
|
2006-07-29 01:10:14 -07:00
|
|
|
/* SiS */
|
2006-09-27 19:20:11 -07:00
|
|
|
{ PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */
|
|
|
|
{ PCI_VDEVICE(SI, 0x1185), board_ahci }, /* SiS 966 */
|
|
|
|
{ PCI_VDEVICE(SI, 0x0186), board_ahci }, /* SiS 968 */
|
2006-07-29 01:10:14 -07:00
|
|
|
|
2007-07-07 23:29:42 -07:00
|
|
|
/* Marvell */
|
|
|
|
{ PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */
|
2008-03-13 15:22:24 -07:00
|
|
|
{ PCI_VDEVICE(MARVELL, 0x6121), board_ahci_mv }, /* 6121 */
|
2007-07-07 23:29:42 -07:00
|
|
|
|
2006-11-01 03:10:42 -07:00
|
|
|
/* Generic, PCI class code for AHCI */
|
|
|
|
{ PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
|
2007-01-09 03:32:51 -07:00
|
|
|
PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci },
|
2006-11-01 03:10:42 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
{ } /* terminate list */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static struct pci_driver ahci_pci_driver = {
|
|
|
|
.name = DRV_NAME,
|
|
|
|
.id_table = ahci_pci_tbl,
|
|
|
|
.probe = ahci_init_one,
|
2007-01-20 00:00:28 -07:00
|
|
|
.remove = ata_pci_remove_one,
|
2007-03-02 01:31:26 -07:00
|
|
|
#ifdef CONFIG_PM
|
2006-07-25 23:59:26 -07:00
|
|
|
.suspend = ahci_pci_device_suspend,
|
|
|
|
.resume = ahci_pci_device_resume,
|
2007-03-02 01:31:26 -07:00
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-11-01 20:17:23 -07:00
|
|
|
static inline int ahci_nr_ports(u32 cap)
|
|
|
|
{
|
|
|
|
return (cap & 0x1f) + 1;
|
|
|
|
}
|
|
|
|
|
2007-05-28 05:33:01 -07:00
|
|
|
static inline void __iomem *__ahci_port_base(struct ata_host *host,
|
|
|
|
unsigned int port_no)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2007-05-28 05:33:01 -07: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 07:44:08 -07:00
|
|
|
|
2007-05-28 05:33:01 -07:00
|
|
|
return mmio + 0x100 + (port_no * 0x80);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __iomem *ahci_port_base(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
return __ahci_port_base(ap->host, ap->port_no);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2008-01-05 07:11:57 -07:00
|
|
|
static void ahci_enable_ahci(void __iomem *mmio)
|
|
|
|
{
|
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
/* turn on AHCI_EN */
|
|
|
|
tmp = readl(mmio + HOST_CTL);
|
|
|
|
if (!(tmp & HOST_AHCI_EN)) {
|
|
|
|
tmp |= HOST_AHCI_EN;
|
|
|
|
writel(tmp, mmio + HOST_CTL);
|
|
|
|
tmp = readl(mmio + HOST_CTL); /* flush && sanity check */
|
|
|
|
WARN_ON(!(tmp & HOST_AHCI_EN));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-18 06:15:33 -07: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 07:44:08 -07:00
|
|
|
* @pdev: target PCI device
|
|
|
|
* @hpriv: host private area to store config values
|
2007-03-18 06:15:33 -07:00
|
|
|
*
|
|
|
|
* Some registers containing configuration info might be setup by
|
|
|
|
* BIOS and might be cleared on reset. This function saves the
|
|
|
|
* initial values of those registers into @hpriv such that they
|
|
|
|
* can be restored after controller reset.
|
|
|
|
*
|
|
|
|
* If inconsistent, config values are fixed up by this function.
|
|
|
|
*
|
|
|
|
* LOCKING:
|
|
|
|
* None.
|
|
|
|
*/
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
static void ahci_save_initial_config(struct pci_dev *pdev,
|
|
|
|
struct ahci_host_priv *hpriv)
|
2007-03-18 06:15:33 -07:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
|
2007-03-18 06:15:33 -07:00
|
|
|
u32 cap, port_map;
|
2007-03-18 06:26:53 -07:00
|
|
|
int i;
|
2008-03-13 15:22:24 -07:00
|
|
|
int mv;
|
2007-03-18 06:15:33 -07:00
|
|
|
|
2008-01-05 07:11:57 -07:00
|
|
|
/* make sure AHCI mode is enabled before accessing CAP */
|
|
|
|
ahci_enable_ahci(mmio);
|
|
|
|
|
2007-03-18 06:15:33 -07:00
|
|
|
/* Values prefixed with saved_ are written back to host after
|
|
|
|
* reset. Values without are used for driver operation.
|
|
|
|
*/
|
|
|
|
hpriv->saved_cap = cap = readl(mmio + HOST_CAP);
|
|
|
|
hpriv->saved_port_map = port_map = readl(mmio + HOST_PORTS_IMPL);
|
|
|
|
|
2007-07-15 22:29:40 -07:00
|
|
|
/* some chips have errata preventing 64bit use */
|
2007-09-22 21:19:55 -07:00
|
|
|
if ((cap & HOST_CAP_64) && (hpriv->flags & AHCI_HFLAG_32BIT_ONLY)) {
|
2007-05-18 07:23:19 -07:00
|
|
|
dev_printk(KERN_INFO, &pdev->dev,
|
|
|
|
"controller can't do 64bit DMA, forcing 32bit\n");
|
|
|
|
cap &= ~HOST_CAP_64;
|
|
|
|
}
|
|
|
|
|
2007-09-22 21:19:55 -07:00
|
|
|
if ((cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_NO_NCQ)) {
|
2007-07-15 22:29:40 -07:00
|
|
|
dev_printk(KERN_INFO, &pdev->dev,
|
|
|
|
"controller can't do NCQ, turning off CAP_NCQ\n");
|
|
|
|
cap &= ~HOST_CAP_NCQ;
|
|
|
|
}
|
|
|
|
|
2008-03-09 13:42:40 -07:00
|
|
|
if ((cap & HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) {
|
2007-09-22 21:19:55 -07:00
|
|
|
dev_printk(KERN_INFO, &pdev->dev,
|
|
|
|
"controller can't do PMP, turning off CAP_PMP\n");
|
|
|
|
cap &= ~HOST_CAP_PMP;
|
|
|
|
}
|
|
|
|
|
2007-07-07 23:29:42 -07: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-22 21:19:55 -07:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
|
2008-03-13 15:22:24 -07:00
|
|
|
if (pdev->device == 0x6121)
|
|
|
|
mv = 0x3;
|
|
|
|
else
|
|
|
|
mv = 0xf;
|
2007-07-07 23:29:42 -07:00
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"MV_AHCI HACK: port_map %x -> %x\n",
|
2008-03-13 15:22:24 -07:00
|
|
|
port_map,
|
|
|
|
port_map & mv);
|
2007-07-07 23:29:42 -07:00
|
|
|
|
2008-03-13 15:22:24 -07:00
|
|
|
port_map &= mv;
|
2007-07-07 23:29:42 -07:00
|
|
|
}
|
|
|
|
|
2007-03-18 06:26:53 -07:00
|
|
|
/* cross check port_map and cap.n_ports */
|
2007-09-02 20:44:57 -07:00
|
|
|
if (port_map) {
|
2008-02-05 23:13:51 -07:00
|
|
|
int map_ports = 0;
|
2007-03-18 06:26:53 -07:00
|
|
|
|
2008-02-05 23:13:51 -07:00
|
|
|
for (i = 0; i < AHCI_MAX_PORTS; i++)
|
|
|
|
if (port_map & (1 << i))
|
|
|
|
map_ports++;
|
2007-03-18 06:26:53 -07:00
|
|
|
|
2008-02-05 23:13:51 -07:00
|
|
|
/* If PI has more ports than n_ports, whine, clear
|
|
|
|
* port_map and let it be generated from n_ports.
|
2007-03-18 06:26:53 -07:00
|
|
|
*/
|
2008-02-05 23:13:51 -07:00
|
|
|
if (map_ports > ahci_nr_ports(cap)) {
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
dev_printk(KERN_WARNING, &pdev->dev,
|
2008-02-05 23:13:51 -07:00
|
|
|
"implemented port map (0x%x) contains more "
|
|
|
|
"ports than nr_ports (%u), using nr_ports\n",
|
|
|
|
port_map, ahci_nr_ports(cap));
|
2007-09-02 20:44:57 -07:00
|
|
|
port_map = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fabricate port_map from cap.nr_ports */
|
|
|
|
if (!port_map) {
|
2007-03-18 06:26:53 -07:00
|
|
|
port_map = (1 << ahci_nr_ports(cap)) - 1;
|
2007-09-02 20:44:57 -07: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 06:26:53 -07:00
|
|
|
}
|
|
|
|
|
2007-03-18 06:15:33 -07:00
|
|
|
/* record values to use during operation */
|
|
|
|
hpriv->cap = cap;
|
|
|
|
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 07:44:08 -07:00
|
|
|
* @host: target ATA host
|
2007-03-18 06:15:33 -07:00
|
|
|
*
|
|
|
|
* Restore initial config stored by ahci_save_initial_config().
|
|
|
|
*
|
|
|
|
* LOCKING:
|
|
|
|
* None.
|
|
|
|
*/
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
static void ahci_restore_initial_config(struct ata_host *host)
|
2007-03-18 06:15:33 -07:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
|
|
|
void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
|
|
|
|
|
2007-03-18 06:15:33 -07:00
|
|
|
writel(hpriv->saved_cap, mmio + HOST_CAP);
|
|
|
|
writel(hpriv->saved_port_map, mmio + HOST_PORTS_IMPL);
|
|
|
|
(void) readl(mmio + HOST_PORTS_IMPL); /* flush */
|
|
|
|
}
|
|
|
|
|
2007-07-15 22:29:40 -07:00
|
|
|
static unsigned ahci_scr_offset(struct ata_port *ap, unsigned int sc_reg)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2007-07-15 22:29:40 -07:00
|
|
|
static const int offset[] = {
|
|
|
|
[SCR_STATUS] = PORT_SCR_STAT,
|
|
|
|
[SCR_CONTROL] = PORT_SCR_CTL,
|
|
|
|
[SCR_ERROR] = PORT_SCR_ERR,
|
|
|
|
[SCR_ACTIVE] = PORT_SCR_ACT,
|
|
|
|
[SCR_NOTIFICATION] = PORT_SCR_NTF,
|
|
|
|
};
|
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-07-15 22:29:40 -07:00
|
|
|
if (sc_reg < ARRAY_SIZE(offset) &&
|
|
|
|
(sc_reg != SCR_NOTIFICATION || (hpriv->cap & HOST_CAP_SNTF)))
|
|
|
|
return offset[sc_reg];
|
2007-07-15 22:29:40 -07:00
|
|
|
return 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2007-07-15 22:29:40 -07:00
|
|
|
static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2007-07-15 22:29:40 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
int offset = ahci_scr_offset(ap, sc_reg);
|
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
*val = readl(port_mmio + offset);
|
|
|
|
return 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2007-07-15 22:29:40 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-07-15 22:29:40 -07:00
|
|
|
static int ahci_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val)
|
|
|
|
{
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
int offset = ahci_scr_offset(ap, sc_reg);
|
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
writel(val, port_mmio + offset);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
static void ahci_start_engine(struct ata_port *ap)
|
2005-12-19 06:36:34 -07:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2005-12-19 06:36:34 -07:00
|
|
|
u32 tmp;
|
|
|
|
|
2006-07-25 23:59:25 -07:00
|
|
|
/* start DMA */
|
2006-07-25 23:59:26 -07:00
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
2005-12-19 06:36:34 -07:00
|
|
|
tmp |= PORT_CMD_START;
|
|
|
|
writel(tmp, port_mmio + PORT_CMD);
|
|
|
|
readl(port_mmio + PORT_CMD); /* flush */
|
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
static int ahci_stop_engine(struct ata_port *ap)
|
2006-07-25 23:59:25 -07:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-07-25 23:59:25 -07:00
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
|
|
|
|
2006-07-25 23:59:25 -07:00
|
|
|
/* check if the HBA is idle */
|
2006-07-25 23:59:25 -07:00
|
|
|
if ((tmp & (PORT_CMD_START | PORT_CMD_LIST_ON)) == 0)
|
|
|
|
return 0;
|
|
|
|
|
2006-07-25 23:59:25 -07:00
|
|
|
/* setting HBA to idle */
|
2006-07-25 23:59:25 -07:00
|
|
|
tmp &= ~PORT_CMD_START;
|
|
|
|
writel(tmp, port_mmio + PORT_CMD);
|
|
|
|
|
2006-07-25 23:59:25 -07:00
|
|
|
/* wait for engine to stop. This could be as long as 500 msec */
|
2006-07-25 23:59:25 -07:00
|
|
|
tmp = ata_wait_register(port_mmio + PORT_CMD,
|
2007-10-19 03:42:56 -07:00
|
|
|
PORT_CMD_LIST_ON, PORT_CMD_LIST_ON, 1, 500);
|
2006-07-25 23:59:25 -07:00
|
|
|
if (tmp & PORT_CMD_LIST_ON)
|
2006-07-25 23:59:25 -07:00
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
static void ahci_start_fis_rx(struct ata_port *ap)
|
2006-07-25 23:59:26 -07:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2006-07-25 23:59:26 -07:00
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
/* set FIS registers */
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
if (hpriv->cap & HOST_CAP_64)
|
|
|
|
writel((pp->cmd_slot_dma >> 16) >> 16,
|
|
|
|
port_mmio + PORT_LST_ADDR_HI);
|
|
|
|
writel(pp->cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR);
|
2006-07-25 23:59:26 -07:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
if (hpriv->cap & HOST_CAP_64)
|
|
|
|
writel((pp->rx_fis_dma >> 16) >> 16,
|
|
|
|
port_mmio + PORT_FIS_ADDR_HI);
|
|
|
|
writel(pp->rx_fis_dma & 0xffffffff, port_mmio + PORT_FIS_ADDR);
|
2006-07-25 23:59:26 -07:00
|
|
|
|
|
|
|
/* enable FIS reception */
|
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
|
|
|
tmp |= PORT_CMD_FIS_RX;
|
|
|
|
writel(tmp, port_mmio + PORT_CMD);
|
|
|
|
|
|
|
|
/* flush */
|
|
|
|
readl(port_mmio + PORT_CMD);
|
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
static int ahci_stop_fis_rx(struct ata_port *ap)
|
2006-07-25 23:59:26 -07:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
/* disable FIS reception */
|
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
|
|
|
tmp &= ~PORT_CMD_FIS_RX;
|
|
|
|
writel(tmp, port_mmio + PORT_CMD);
|
|
|
|
|
|
|
|
/* wait for completion, spec says 500ms, give it 1000 */
|
|
|
|
tmp = ata_wait_register(port_mmio + PORT_CMD, PORT_CMD_FIS_ON,
|
|
|
|
PORT_CMD_FIS_ON, 10, 1000);
|
|
|
|
if (tmp & PORT_CMD_FIS_ON)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
static void ahci_power_up(struct ata_port *ap)
|
2006-07-25 23:59:26 -07:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
u32 cmd;
|
|
|
|
|
|
|
|
cmd = readl(port_mmio + PORT_CMD) & ~PORT_CMD_ICC_MASK;
|
|
|
|
|
|
|
|
/* spin up device */
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
if (hpriv->cap & HOST_CAP_SSS) {
|
2006-07-25 23:59:26 -07:00
|
|
|
cmd |= PORT_CMD_SPIN_UP;
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wake up link */
|
|
|
|
writel(cmd | PORT_CMD_ICC_ACTIVE, port_mmio + PORT_CMD);
|
|
|
|
}
|
|
|
|
|
2007-10-24 22:33:26 -07:00
|
|
|
static void ahci_disable_alpm(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
u32 cmd;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
|
|
|
|
/* IPM bits should be disabled by libata-core */
|
|
|
|
/* get the existing command bits */
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
|
|
|
|
/* disable ALPM and ASP */
|
|
|
|
cmd &= ~PORT_CMD_ASP;
|
|
|
|
cmd &= ~PORT_CMD_ALPE;
|
|
|
|
|
|
|
|
/* force the interface back to active */
|
|
|
|
cmd |= PORT_CMD_ICC_ACTIVE;
|
|
|
|
|
|
|
|
/* write out new cmd value */
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
|
|
|
|
/* wait 10ms to be sure we've come out of any low power state */
|
|
|
|
msleep(10);
|
|
|
|
|
|
|
|
/* clear out any PhyRdy stuff from interrupt status */
|
|
|
|
writel(PORT_IRQ_PHYRDY, port_mmio + PORT_IRQ_STAT);
|
|
|
|
|
|
|
|
/* go ahead and clean out PhyRdy Change from Serror too */
|
|
|
|
ahci_scr_write(ap, SCR_ERROR, ((1 << 16) | (1 << 18)));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear flag to indicate that we should ignore all PhyRdy
|
|
|
|
* state changes
|
|
|
|
*/
|
|
|
|
hpriv->flags &= ~AHCI_HFLAG_NO_HOTPLUG;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable interrupts on Phy Ready.
|
|
|
|
*/
|
|
|
|
pp->intr_mask |= PORT_IRQ_PHYRDY;
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* don't change the link pm policy - we can be called
|
|
|
|
* just to turn of link pm temporarily
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ahci_enable_alpm(struct ata_port *ap,
|
|
|
|
enum link_pm policy)
|
|
|
|
{
|
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
|
|
|
u32 cmd;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
u32 asp;
|
|
|
|
|
|
|
|
/* Make sure the host is capable of link power management */
|
|
|
|
if (!(hpriv->cap & HOST_CAP_ALPM))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (policy) {
|
|
|
|
case MAX_PERFORMANCE:
|
|
|
|
case NOT_AVAILABLE:
|
|
|
|
/*
|
|
|
|
* if we came here with NOT_AVAILABLE,
|
|
|
|
* it just means this is the first time we
|
|
|
|
* have tried to enable - default to max performance,
|
|
|
|
* and let the user go to lower power modes on request.
|
|
|
|
*/
|
|
|
|
ahci_disable_alpm(ap);
|
|
|
|
return 0;
|
|
|
|
case MIN_POWER:
|
|
|
|
/* configure HBA to enter SLUMBER */
|
|
|
|
asp = PORT_CMD_ASP;
|
|
|
|
break;
|
|
|
|
case MEDIUM_POWER:
|
|
|
|
/* configure HBA to enter PARTIAL */
|
|
|
|
asp = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable interrupts on Phy Ready. This keeps us from
|
|
|
|
* getting woken up due to spurious phy ready interrupts
|
|
|
|
* TBD - Hot plug should be done via polling now, is
|
|
|
|
* that even supported?
|
|
|
|
*/
|
|
|
|
pp->intr_mask &= ~PORT_IRQ_PHYRDY;
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set a flag to indicate that we should ignore all PhyRdy
|
|
|
|
* state changes since these can happen now whenever we
|
|
|
|
* change link state
|
|
|
|
*/
|
|
|
|
hpriv->flags |= AHCI_HFLAG_NO_HOTPLUG;
|
|
|
|
|
|
|
|
/* get the existing command bits */
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set ASP based on Policy
|
|
|
|
*/
|
|
|
|
cmd |= asp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setting this bit will instruct the HBA to aggressively
|
|
|
|
* enter a lower power link state when it's appropriate and
|
|
|
|
* based on the value set above for ASP
|
|
|
|
*/
|
|
|
|
cmd |= PORT_CMD_ALPE;
|
|
|
|
|
|
|
|
/* write out new cmd value */
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
|
|
|
|
/* IPM bits should be set by libata-core */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-03-02 01:31:26 -07:00
|
|
|
#ifdef CONFIG_PM
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
static void ahci_power_down(struct ata_port *ap)
|
2006-07-25 23:59:26 -07:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
u32 cmd, scontrol;
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
if (!(hpriv->cap & HOST_CAP_SSS))
|
2007-01-20 10:10:11 -07:00
|
|
|
return;
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2007-01-20 10:10:11 -07:00
|
|
|
/* put device into listen mode, first set PxSCTL.DET to 0 */
|
|
|
|
scontrol = readl(port_mmio + PORT_SCR_CTL);
|
|
|
|
scontrol &= ~0xf;
|
|
|
|
writel(scontrol, port_mmio + PORT_SCR_CTL);
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2007-01-20 10:10:11 -07:00
|
|
|
/* then set PxCMD.SUD to 0 */
|
|
|
|
cmd = readl(port_mmio + PORT_CMD) & ~PORT_CMD_ICC_MASK;
|
|
|
|
cmd &= ~PORT_CMD_SPIN_UP;
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
2006-07-25 23:59:26 -07:00
|
|
|
}
|
2007-03-02 01:31:26 -07:00
|
|
|
#endif
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2007-05-26 17:46:51 -07:00
|
|
|
static void ahci_start_port(struct ata_port *ap)
|
2006-07-25 23:59:26 -07:00
|
|
|
{
|
|
|
|
/* enable FIS reception */
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ahci_start_fis_rx(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
|
|
|
|
/* enable DMA */
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ahci_start_engine(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
static int ahci_deinit_port(struct ata_port *ap, const char **emsg)
|
2006-07-25 23:59:26 -07:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* disable DMA */
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
rc = ahci_stop_engine(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
if (rc) {
|
|
|
|
*emsg = "failed to stop engine";
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disable FIS reception */
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
rc = ahci_stop_fis_rx(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
if (rc) {
|
|
|
|
*emsg = "failed stop FIS RX";
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
static int ahci_reset_controller(struct ata_host *host)
|
2006-07-25 23:59:26 -07:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
struct pci_dev *pdev = to_pci_dev(host->dev);
|
2007-11-19 00:03:44 -07: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 07:44:08 -07:00
|
|
|
void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
|
2007-03-18 06:15:33 -07:00
|
|
|
u32 tmp;
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2007-09-25 21:02:41 -07:00
|
|
|
/* we must be in AHCI mode, before using anything
|
|
|
|
* AHCI-specific, such as HOST_RESET.
|
|
|
|
*/
|
2008-01-05 07:11:57 -07:00
|
|
|
ahci_enable_ahci(mmio);
|
2007-09-25 21:02:41 -07:00
|
|
|
|
|
|
|
/* global controller reset */
|
2008-03-09 18:25:25 -07:00
|
|
|
if (!ahci_skip_host_reset) {
|
|
|
|
tmp = readl(mmio + HOST_CTL);
|
|
|
|
if ((tmp & HOST_RESET) == 0) {
|
|
|
|
writel(tmp | HOST_RESET, mmio + HOST_CTL);
|
|
|
|
readl(mmio + HOST_CTL); /* flush */
|
|
|
|
}
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2008-03-09 18:25:25 -07:00
|
|
|
/* reset must complete within 1 second, or
|
|
|
|
* the hardware should be considered fried.
|
|
|
|
*/
|
|
|
|
ssleep(1);
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2008-03-09 18:25:25 -07:00
|
|
|
tmp = readl(mmio + HOST_CTL);
|
|
|
|
if (tmp & HOST_RESET) {
|
|
|
|
dev_printk(KERN_ERR, host->dev,
|
|
|
|
"controller reset failed (0x%x)\n", tmp);
|
|
|
|
return -EIO;
|
|
|
|
}
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2008-03-09 18:25:25 -07:00
|
|
|
/* turn on AHCI mode */
|
|
|
|
ahci_enable_ahci(mmio);
|
2006-11-01 20:17:23 -07:00
|
|
|
|
2008-03-09 18:25:25 -07:00
|
|
|
/* Some registers might be cleared on reset. Restore
|
|
|
|
* initial values.
|
|
|
|
*/
|
|
|
|
ahci_restore_initial_config(host);
|
|
|
|
} else
|
|
|
|
dev_printk(KERN_INFO, host->dev,
|
|
|
|
"skipping global host reset\n");
|
2006-07-25 23:59:26 -07:00
|
|
|
|
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
|
|
|
|
u16 tmp16;
|
|
|
|
|
|
|
|
/* configure PCS */
|
|
|
|
pci_read_config_word(pdev, 0x92, &tmp16);
|
2007-11-19 00:03:44 -07:00
|
|
|
if ((tmp16 & hpriv->port_map) != hpriv->port_map) {
|
|
|
|
tmp16 |= hpriv->port_map;
|
|
|
|
pci_write_config_word(pdev, 0x92, tmp16);
|
|
|
|
}
|
2006-07-25 23:59:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-05-28 04:45:27 -07: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 07:44:08 -07:00
|
|
|
static void ahci_init_controller(struct ata_host *host)
|
2006-07-25 23:59:26 -07:00
|
|
|
{
|
2007-09-22 21:19:55 -07:00
|
|
|
struct ahci_host_priv *hpriv = host->private_data;
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
struct pci_dev *pdev = to_pci_dev(host->dev);
|
|
|
|
void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
|
2007-05-28 04:45:27 -07:00
|
|
|
int i;
|
2007-07-07 23:29:42 -07:00
|
|
|
void __iomem *port_mmio;
|
2006-07-25 23:59:26 -07:00
|
|
|
u32 tmp;
|
2008-03-13 15:22:24 -07:00
|
|
|
int mv;
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2007-09-22 21:19:55 -07:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
|
2008-03-13 15:22:24 -07:00
|
|
|
if (pdev->device == 0x6121)
|
|
|
|
mv = 2;
|
|
|
|
else
|
|
|
|
mv = 4;
|
|
|
|
port_mmio = __ahci_port_base(host, mv);
|
2007-07-07 23:29:42 -07:00
|
|
|
|
|
|
|
writel(0, port_mmio + PORT_IRQ_MASK);
|
|
|
|
|
|
|
|
/* clear port IRQ */
|
|
|
|
tmp = readl(port_mmio + PORT_IRQ_STAT);
|
|
|
|
VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp);
|
|
|
|
if (tmp)
|
|
|
|
writel(tmp, port_mmio + PORT_IRQ_STAT);
|
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
for (i = 0; i < host->n_ports; i++) {
|
|
|
|
struct ata_port *ap = host->ports[i];
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2007-07-07 23:29:42 -07: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 07:44:08 -07:00
|
|
|
if (ata_port_is_dummy(ap))
|
2006-07-25 23:59:26 -07:00
|
|
|
continue;
|
|
|
|
|
2007-05-28 04:45:27 -07:00
|
|
|
ahci_port_init(pdev, ap, i, mmio, port_mmio);
|
2006-07-25 23:59:26 -07: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 13:43:48 -07:00
|
|
|
static void ahci_dev_config(struct ata_device *dev)
|
|
|
|
{
|
|
|
|
struct ahci_host_priv *hpriv = dev->link->ap->host->private_data;
|
|
|
|
|
2008-03-24 19:40:40 -07:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_SECT255) {
|
2008-02-28 13:43:48 -07:00
|
|
|
dev->max_sectors = 255;
|
2008-03-24 19:40:40 -07:00
|
|
|
ata_dev_printk(dev, KERN_INFO,
|
|
|
|
"SB600 AHCI: limiting to 255 sectors per cmd\n");
|
|
|
|
}
|
2008-02-28 13:43:48 -07:00
|
|
|
}
|
|
|
|
|
2005-12-19 06:37:17 -07:00
|
|
|
static unsigned int ahci_dev_classify(struct ata_port *ap)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ata_taskfile tf;
|
2005-12-19 06:37:17 -07:00
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
tmp = readl(port_mmio + PORT_SIG);
|
|
|
|
tf.lbah = (tmp >> 24) & 0xff;
|
|
|
|
tf.lbam = (tmp >> 16) & 0xff;
|
|
|
|
tf.lbal = (tmp >> 8) & 0xff;
|
|
|
|
tf.nsect = (tmp) & 0xff;
|
|
|
|
|
|
|
|
return ata_dev_classify(&tf);
|
|
|
|
}
|
|
|
|
|
2006-05-15 05:03:55 -07:00
|
|
|
static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
|
|
|
|
u32 opts)
|
2006-02-10 01:25:47 -07:00
|
|
|
{
|
2006-05-15 05:03:55 -07:00
|
|
|
dma_addr_t cmd_tbl_dma;
|
|
|
|
|
|
|
|
cmd_tbl_dma = pp->cmd_tbl_dma + tag * AHCI_CMD_TBL_SZ;
|
|
|
|
|
|
|
|
pp->cmd_slot[tag].opts = cpu_to_le32(opts);
|
|
|
|
pp->cmd_slot[tag].status = 0;
|
|
|
|
pp->cmd_slot[tag].tbl_addr = cpu_to_le32(cmd_tbl_dma & 0xffffffff);
|
|
|
|
pp->cmd_slot[tag].tbl_addr_hi = cpu_to_le32((cmd_tbl_dma >> 16) >> 16);
|
2006-02-10 01:25:47 -07:00
|
|
|
}
|
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
static int ahci_kick_engine(struct ata_port *ap, int force_restart)
|
2006-03-22 05:07:03 -07:00
|
|
|
{
|
2007-01-31 23:06:36 -07:00
|
|
|
void __iomem *port_mmio = ap->ioaddr.cmd_addr;
|
2006-08-24 00:19:22 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2006-04-17 05:17:59 -07:00
|
|
|
u32 tmp;
|
2007-07-15 22:29:39 -07:00
|
|
|
int busy, rc;
|
2006-04-17 05:17:59 -07:00
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
/* do we need to kick the port? */
|
|
|
|
busy = ahci_check_status(ap) & (ATA_BUSY | ATA_DRQ);
|
|
|
|
if (!busy && !force_restart)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* stop engine */
|
|
|
|
rc = ahci_stop_engine(ap);
|
|
|
|
if (rc)
|
|
|
|
goto out_restart;
|
|
|
|
|
|
|
|
/* need to do CLO? */
|
|
|
|
if (!busy) {
|
|
|
|
rc = 0;
|
|
|
|
goto out_restart;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(hpriv->cap & HOST_CAP_CLO)) {
|
|
|
|
rc = -EOPNOTSUPP;
|
|
|
|
goto out_restart;
|
|
|
|
}
|
2006-04-17 05:17:59 -07:00
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
/* perform CLO */
|
2006-04-17 05:17:59 -07:00
|
|
|
tmp = readl(port_mmio + PORT_CMD);
|
|
|
|
tmp |= PORT_CMD_CLO;
|
|
|
|
writel(tmp, port_mmio + PORT_CMD);
|
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
rc = 0;
|
2006-04-17 05:17:59 -07:00
|
|
|
tmp = ata_wait_register(port_mmio + PORT_CMD,
|
|
|
|
PORT_CMD_CLO, PORT_CMD_CLO, 1, 500);
|
|
|
|
if (tmp & PORT_CMD_CLO)
|
2007-07-15 22:29:39 -07:00
|
|
|
rc = -EIO;
|
2006-04-17 05:17:59 -07:00
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
/* restart engine */
|
|
|
|
out_restart:
|
|
|
|
ahci_start_engine(ap);
|
|
|
|
return rc;
|
2006-04-17 05:17:59 -07:00
|
|
|
}
|
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
|
|
|
|
struct ata_taskfile *tf, int is_cmd, u16 flags,
|
|
|
|
unsigned long timeout_msec)
|
2006-04-17 05:17:59 -07:00
|
|
|
{
|
2007-07-15 22:29:39 -07:00
|
|
|
const u32 cmd_fis_len = 5; /* five dwords */
|
2006-03-22 05:07:03 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-07-15 22:29:39 -07:00
|
|
|
u8 *fis = pp->cmd_tbl;
|
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
/* prep the command */
|
|
|
|
ata_tf_to_fis(tf, pmp, is_cmd, fis);
|
|
|
|
ahci_fill_cmd_slot(pp, 0, cmd_fis_len | flags | (pmp << 12));
|
|
|
|
|
|
|
|
/* issue & wait */
|
|
|
|
writel(1, port_mmio + PORT_CMD_ISSUE);
|
|
|
|
|
|
|
|
if (timeout_msec) {
|
|
|
|
tmp = ata_wait_register(port_mmio + PORT_CMD_ISSUE, 0x1, 0x1,
|
|
|
|
1, timeout_msec);
|
|
|
|
if (tmp & 0x1) {
|
|
|
|
ahci_kick_engine(ap, 1);
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
readl(port_mmio + PORT_CMD_ISSUE); /* flush */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
static int ahci_do_softreset(struct ata_link *link, unsigned int *class,
|
2007-07-15 22:29:39 -07:00
|
|
|
int pmp, unsigned long deadline)
|
2007-07-15 22:29:39 -07:00
|
|
|
{
|
2007-08-06 02:36:23 -07:00
|
|
|
struct ata_port *ap = link->ap;
|
2006-03-22 05:07:03 -07:00
|
|
|
const char *reason = NULL;
|
2007-07-15 22:29:38 -07:00
|
|
|
unsigned long now, msecs;
|
2006-03-22 05:07:03 -07:00
|
|
|
struct ata_taskfile tf;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
DPRINTK("ENTER\n");
|
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
if (ata_link_offline(link)) {
|
2006-04-02 09:58:06 -07:00
|
|
|
DPRINTK("PHY reports no device\n");
|
|
|
|
*class = ATA_DEV_NONE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-22 05:07:03 -07:00
|
|
|
/* prepare for SRST (AHCI-1.1 10.4.1) */
|
2007-07-15 22:29:39 -07:00
|
|
|
rc = ahci_kick_engine(ap, 1);
|
2007-12-05 23:02:48 -07:00
|
|
|
if (rc && rc != -EOPNOTSUPP)
|
2007-08-06 02:36:23 -07:00
|
|
|
ata_link_printk(link, KERN_WARNING,
|
2007-12-05 23:02:48 -07:00
|
|
|
"failed to reset engine (errno=%d)\n", rc);
|
2006-03-22 05:07:03 -07:00
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
ata_tf_init(link->device, &tf);
|
2006-03-22 05:07:03 -07:00
|
|
|
|
|
|
|
/* issue the first D2H Register FIS */
|
2007-07-15 22:29:38 -07:00
|
|
|
msecs = 0;
|
|
|
|
now = jiffies;
|
|
|
|
if (time_after(now, deadline))
|
|
|
|
msecs = jiffies_to_msecs(deadline - now);
|
|
|
|
|
2006-03-22 05:07:03 -07:00
|
|
|
tf.ctl |= ATA_SRST;
|
2007-07-15 22:29:39 -07:00
|
|
|
if (ahci_exec_polled_cmd(ap, pmp, &tf, 0,
|
2007-07-15 22:29:39 -07:00
|
|
|
AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY, msecs)) {
|
2006-03-22 05:07:03 -07:00
|
|
|
rc = -EIO;
|
|
|
|
reason = "1st FIS failed";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* spec says at least 5us, but be generous and sleep for 1ms */
|
|
|
|
msleep(1);
|
|
|
|
|
|
|
|
/* issue the second D2H Register FIS */
|
|
|
|
tf.ctl &= ~ATA_SRST;
|
2007-07-15 22:29:39 -07:00
|
|
|
ahci_exec_polled_cmd(ap, pmp, &tf, 0, 0, 0);
|
2006-03-22 05:07:03 -07:00
|
|
|
|
2007-10-16 14:21:24 -07:00
|
|
|
/* wait a while before checking status */
|
|
|
|
ata_wait_after_reset(ap, deadline);
|
2006-03-22 05:07:03 -07:00
|
|
|
|
2007-02-02 00:50:52 -07:00
|
|
|
rc = ata_wait_ready(ap, deadline);
|
|
|
|
/* link occupied, -ENODEV too is an error */
|
|
|
|
if (rc) {
|
|
|
|
reason = "device not ready";
|
|
|
|
goto fail;
|
2006-03-22 05:07:03 -07:00
|
|
|
}
|
2007-02-02 00:50:52 -07:00
|
|
|
*class = ahci_dev_classify(ap);
|
2006-03-22 05:07:03 -07:00
|
|
|
|
|
|
|
DPRINTK("EXIT, class=%u\n", *class);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
2007-08-06 02:36:23 -07:00
|
|
|
ata_link_printk(link, KERN_ERR, "softreset failed (%s)\n", reason);
|
2006-03-22 05:07:03 -07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
static int ahci_softreset(struct ata_link *link, unsigned int *class,
|
2007-07-15 22:29:39 -07:00
|
|
|
unsigned long deadline)
|
|
|
|
{
|
2007-09-22 21:19:54 -07:00
|
|
|
int pmp = 0;
|
|
|
|
|
|
|
|
if (link->ap->flags & ATA_FLAG_PMP)
|
|
|
|
pmp = SATA_PMP_CTRL_PORT;
|
|
|
|
|
|
|
|
return ahci_do_softreset(link, class, pmp, deadline);
|
2007-07-15 22:29:39 -07:00
|
|
|
}
|
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
static int ahci_hardreset(struct ata_link *link, unsigned int *class,
|
libata: add deadline support to prereset and reset methods
Add @deadline to prereset and reset methods and make them honor it.
ata_wait_ready() which directly takes @deadline is implemented to be
used as the wait function. This patch is in preparation for EH timing
improvements.
* ata_wait_ready() never does busy sleep. It's only used from EH and
no wait in EH is that urgent. This function also prints 'be
patient' message automatically after 5 secs of waiting if more than
3 secs is remaining till deadline.
* ata_bus_post_reset() now fails with error code if any of its wait
fails. This is important because earlier reset tries will have
shorter timeout than the spec requires. If a device fails to
respond before the short timeout, reset should be retried with
longer timeout rather than silently ignoring the device.
There are three behavior differences.
1. Timeout is applied to both devices at once, not separately. This
is more consistent with what the spec says.
2. When a device passes devchk but fails to become ready before
deadline. Previouly, post_reset would just succeed and let
device classification remove the device. New code fails the
reset thus causing reset retry. After a few times, EH will give
up disabling the port.
3. When slave device passes devchk but fails to become accessible
(TF-wise) after reset. Original code disables dev1 after 30s
timeout and continues as if the device doesn't exist, while the
patched code fails reset. When this happens, new code fails
reset on whole port rather than proceeding with only the primary
device.
If the failing device is suffering transient problems, new code
retries reset which is a better behavior. If the failing device is
actually broken, the net effect is identical to it, but not to the
other device sharing the channel. In the previous code, reset would
have succeeded after 30s thus detecting the working one. In the new
code, reset fails and whole port gets disabled. IMO, it's a
pathological case anyway (broken device sharing bus with working
one) and doesn't really matter.
* ata_bus_softreset() is changed to return error code from
ata_bus_post_reset(). It used to return 0 unconditionally.
* Spin up waiting is to be removed and not converted to honor
deadline.
* To be on the safe side, deadline is set to 40s for the time being.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-02-02 00:50:52 -07:00
|
|
|
unsigned long deadline)
|
2005-12-19 06:37:17 -07:00
|
|
|
{
|
2007-08-06 02:36:23 -07:00
|
|
|
struct ata_port *ap = link->ap;
|
2006-05-31 02:28:18 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
|
|
|
|
struct ata_taskfile tf;
|
2006-02-11 00:26:02 -07:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
DPRINTK("ENTER\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ahci_stop_engine(ap);
|
2006-05-31 02:28:18 -07:00
|
|
|
|
|
|
|
/* clear D2H reception area to properly wait for D2H FIS */
|
2007-08-06 02:36:23 -07:00
|
|
|
ata_tf_init(link->device, &tf);
|
2007-01-25 23:37:20 -07:00
|
|
|
tf.command = 0x80;
|
2007-07-15 22:29:38 -07:00
|
|
|
ata_tf_to_fis(&tf, 0, 0, d2h_fis);
|
2006-05-31 02:28:18 -07:00
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
rc = sata_std_hardreset(link, class, deadline);
|
2006-05-31 02:28:18 -07:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ahci_start_engine(ap);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
if (rc == 0 && ata_link_online(link))
|
2006-02-11 00:26:02 -07:00
|
|
|
*class = ahci_dev_classify(ap);
|
2007-09-22 21:19:54 -07:00
|
|
|
if (rc != -EAGAIN && *class == ATA_DEV_UNKNOWN)
|
2006-02-11 00:26:02 -07:00
|
|
|
*class = ATA_DEV_NONE;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-02-11 00:26:02 -07:00
|
|
|
DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
|
libata: add deadline support to prereset and reset methods
Add @deadline to prereset and reset methods and make them honor it.
ata_wait_ready() which directly takes @deadline is implemented to be
used as the wait function. This patch is in preparation for EH timing
improvements.
* ata_wait_ready() never does busy sleep. It's only used from EH and
no wait in EH is that urgent. This function also prints 'be
patient' message automatically after 5 secs of waiting if more than
3 secs is remaining till deadline.
* ata_bus_post_reset() now fails with error code if any of its wait
fails. This is important because earlier reset tries will have
shorter timeout than the spec requires. If a device fails to
respond before the short timeout, reset should be retried with
longer timeout rather than silently ignoring the device.
There are three behavior differences.
1. Timeout is applied to both devices at once, not separately. This
is more consistent with what the spec says.
2. When a device passes devchk but fails to become ready before
deadline. Previouly, post_reset would just succeed and let
device classification remove the device. New code fails the
reset thus causing reset retry. After a few times, EH will give
up disabling the port.
3. When slave device passes devchk but fails to become accessible
(TF-wise) after reset. Original code disables dev1 after 30s
timeout and continues as if the device doesn't exist, while the
patched code fails reset. When this happens, new code fails
reset on whole port rather than proceeding with only the primary
device.
If the failing device is suffering transient problems, new code
retries reset which is a better behavior. If the failing device is
actually broken, the net effect is identical to it, but not to the
other device sharing the channel. In the previous code, reset would
have succeeded after 30s thus detecting the working one. In the new
code, reset fails and whole port gets disabled. IMO, it's a
pathological case anyway (broken device sharing bus with working
one) and doesn't really matter.
* ata_bus_softreset() is changed to return error code from
ata_bus_post_reset(). It used to return 0 unconditionally.
* Spin up waiting is to be removed and not converted to honor
deadline.
* To be on the safe side, deadline is set to 40s for the time being.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-02-02 00:50:52 -07:00
|
|
|
unsigned long deadline)
|
2006-11-01 02:00:24 -07:00
|
|
|
{
|
2007-08-06 02:36:23 -07:00
|
|
|
struct ata_port *ap = link->ap;
|
2007-07-15 22:29:40 -07:00
|
|
|
u32 serror;
|
2006-11-01 02:00:24 -07:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
DPRINTK("ENTER\n");
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ahci_stop_engine(ap);
|
2006-11-01 02:00:24 -07:00
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context),
|
libata: add deadline support to prereset and reset methods
Add @deadline to prereset and reset methods and make them honor it.
ata_wait_ready() which directly takes @deadline is implemented to be
used as the wait function. This patch is in preparation for EH timing
improvements.
* ata_wait_ready() never does busy sleep. It's only used from EH and
no wait in EH is that urgent. This function also prints 'be
patient' message automatically after 5 secs of waiting if more than
3 secs is remaining till deadline.
* ata_bus_post_reset() now fails with error code if any of its wait
fails. This is important because earlier reset tries will have
shorter timeout than the spec requires. If a device fails to
respond before the short timeout, reset should be retried with
longer timeout rather than silently ignoring the device.
There are three behavior differences.
1. Timeout is applied to both devices at once, not separately. This
is more consistent with what the spec says.
2. When a device passes devchk but fails to become ready before
deadline. Previouly, post_reset would just succeed and let
device classification remove the device. New code fails the
reset thus causing reset retry. After a few times, EH will give
up disabling the port.
3. When slave device passes devchk but fails to become accessible
(TF-wise) after reset. Original code disables dev1 after 30s
timeout and continues as if the device doesn't exist, while the
patched code fails reset. When this happens, new code fails
reset on whole port rather than proceeding with only the primary
device.
If the failing device is suffering transient problems, new code
retries reset which is a better behavior. If the failing device is
actually broken, the net effect is identical to it, but not to the
other device sharing the channel. In the previous code, reset would
have succeeded after 30s thus detecting the working one. In the new
code, reset fails and whole port gets disabled. IMO, it's a
pathological case anyway (broken device sharing bus with working
one) and doesn't really matter.
* ata_bus_softreset() is changed to return error code from
ata_bus_post_reset(). It used to return 0 unconditionally.
* Spin up waiting is to be removed and not converted to honor
deadline.
* To be on the safe side, deadline is set to 40s for the time being.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-02-02 00:50:52 -07:00
|
|
|
deadline);
|
2006-11-01 02:00:24 -07:00
|
|
|
|
|
|
|
/* vt8251 needs SError cleared for the port to operate */
|
2007-07-15 22:29:40 -07:00
|
|
|
ahci_scr_read(ap, SCR_ERROR, &serror);
|
|
|
|
ahci_scr_write(ap, SCR_ERROR, serror);
|
2006-11-01 02:00:24 -07:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ahci_start_engine(ap);
|
2006-11-01 02:00:24 -07:00
|
|
|
|
|
|
|
DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class);
|
|
|
|
|
|
|
|
/* vt8251 doesn't clear BSY on signature FIS reception,
|
|
|
|
* request follow-up softreset.
|
|
|
|
*/
|
|
|
|
return rc ?: -EAGAIN;
|
|
|
|
}
|
|
|
|
|
2007-10-24 22:59:16 -07:00
|
|
|
static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
|
|
|
|
unsigned long deadline)
|
|
|
|
{
|
|
|
|
struct ata_port *ap = link->ap;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
|
|
|
|
struct ata_taskfile tf;
|
|
|
|
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),
|
|
|
|
deadline);
|
|
|
|
|
|
|
|
ahci_start_engine(ap);
|
|
|
|
|
|
|
|
if (rc || ata_link_offline(link))
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* spec mandates ">= 2ms" before checking status */
|
|
|
|
msleep(150);
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
rc = ata_wait_ready(ap, jiffies + 2 * HZ);
|
|
|
|
if (rc)
|
|
|
|
ahci_kick_engine(ap, 0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
static void ahci_postreset(struct ata_link *link, unsigned int *class)
|
2006-02-11 00:26:02 -07:00
|
|
|
{
|
2007-08-06 02:36:23 -07:00
|
|
|
struct ata_port *ap = link->ap;
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-02-11 00:26:02 -07:00
|
|
|
u32 new_tmp, tmp;
|
|
|
|
|
2007-08-06 02:36:23 -07:00
|
|
|
ata_std_postreset(link, class);
|
2005-11-11 23:32:19 -07:00
|
|
|
|
|
|
|
/* Make sure port's ATAPI bit is set appropriately */
|
|
|
|
new_tmp = tmp = readl(port_mmio + PORT_CMD);
|
2006-02-11 00:26:02 -07:00
|
|
|
if (*class == ATA_DEV_ATAPI)
|
2005-11-11 23:32:19 -07:00
|
|
|
new_tmp |= PORT_CMD_ATAPI;
|
|
|
|
else
|
|
|
|
new_tmp &= ~PORT_CMD_ATAPI;
|
|
|
|
if (new_tmp != tmp) {
|
|
|
|
writel(new_tmp, port_mmio + PORT_CMD);
|
|
|
|
readl(port_mmio + PORT_CMD); /* flush */
|
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
|
|
|
|
unsigned long deadline)
|
|
|
|
{
|
|
|
|
return ahci_do_softreset(link, class, link->pmp, deadline);
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
static u8 ahci_check_status(struct ata_port *ap)
|
|
|
|
{
|
2007-01-31 23:06:36 -07:00
|
|
|
void __iomem *mmio = ap->ioaddr.cmd_addr;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
return readl(mmio + PORT_TFDATA) & 0xFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
|
|
|
|
{
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
|
|
|
|
|
|
|
|
ata_tf_from_fis(d2h_fis, tf);
|
|
|
|
}
|
|
|
|
|
2006-05-15 05:03:55 -07:00
|
|
|
static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2005-10-05 04:13:30 -07:00
|
|
|
struct scatterlist *sg;
|
2007-12-05 00:43:11 -07:00
|
|
|
struct ahci_sg *ahci_sg = cmd_tbl + AHCI_CMD_TBL_HDR_SZ;
|
|
|
|
unsigned int si;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Next, the S/G list.
|
|
|
|
*/
|
2007-12-05 00:43:11 -07:00
|
|
|
for_each_sg(qc->sg, sg, qc->n_elem, si) {
|
2005-10-05 04:13:30 -07:00
|
|
|
dma_addr_t addr = sg_dma_address(sg);
|
|
|
|
u32 sg_len = sg_dma_len(sg);
|
|
|
|
|
2007-12-05 00:43:11 -07:00
|
|
|
ahci_sg[si].addr = cpu_to_le32(addr & 0xffffffff);
|
|
|
|
ahci_sg[si].addr_hi = cpu_to_le32((addr >> 16) >> 16);
|
|
|
|
ahci_sg[si].flags_size = cpu_to_le32(sg_len - 1);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2005-11-11 23:27:07 -07:00
|
|
|
|
2007-12-05 00:43:11 -07:00
|
|
|
return si;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_qc_prep(struct ata_queued_cmd *qc)
|
|
|
|
{
|
2005-06-03 22:13:15 -07:00
|
|
|
struct ata_port *ap = qc->ap;
|
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-11-27 03:28:53 -07:00
|
|
|
int is_atapi = ata_is_atapi(qc->tf.protocol);
|
2006-05-15 05:03:55 -07:00
|
|
|
void *cmd_tbl;
|
2005-04-16 15:20:36 -07:00
|
|
|
u32 opts;
|
|
|
|
const u32 cmd_fis_len = 5; /* five dwords */
|
2005-11-11 23:27:07 -07:00
|
|
|
unsigned int n_elem;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in command table information. First, the header,
|
|
|
|
* a SATA Register - Host to Device command FIS.
|
|
|
|
*/
|
2006-05-15 05:03:55 -07:00
|
|
|
cmd_tbl = pp->cmd_tbl + qc->tag * AHCI_CMD_TBL_SZ;
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, cmd_tbl);
|
2006-02-10 01:25:47 -07:00
|
|
|
if (is_atapi) {
|
2006-05-15 05:03:55 -07:00
|
|
|
memset(cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32);
|
|
|
|
memcpy(cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, qc->dev->cdb_len);
|
2005-06-03 22:13:15 -07:00
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-02-10 01:25:47 -07:00
|
|
|
n_elem = 0;
|
|
|
|
if (qc->flags & ATA_QCFLAG_DMAMAP)
|
2006-05-15 05:03:55 -07:00
|
|
|
n_elem = ahci_fill_sg(qc, cmd_tbl);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-02-10 01:25:47 -07:00
|
|
|
/*
|
|
|
|
* Fill in command slot information.
|
|
|
|
*/
|
2007-09-22 21:19:54 -07:00
|
|
|
opts = cmd_fis_len | n_elem << 16 | (qc->dev->link->pmp << 12);
|
2006-02-10 01:25:47 -07:00
|
|
|
if (qc->tf.flags & ATA_TFLAG_WRITE)
|
|
|
|
opts |= AHCI_CMD_WRITE;
|
|
|
|
if (is_atapi)
|
2006-03-11 19:25:27 -07:00
|
|
|
opts |= AHCI_CMD_ATAPI | AHCI_CMD_PREFETCH;
|
2005-11-11 23:27:07 -07:00
|
|
|
|
2006-05-15 05:03:55 -07:00
|
|
|
ahci_fill_cmd_slot(pp, qc->tag, opts);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2007-09-22 21:19:55 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2006-05-15 04:58:29 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-09-22 21:19:54 -07:00
|
|
|
struct ata_eh_info *host_ehi = &ap->link.eh_info;
|
|
|
|
struct ata_link *link = NULL;
|
|
|
|
struct ata_queued_cmd *active_qc;
|
|
|
|
struct ata_eh_info *active_ehi;
|
2006-05-15 04:58:29 -07:00
|
|
|
u32 serror;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
/* determine active link */
|
|
|
|
ata_port_for_each_link(link, ap)
|
|
|
|
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 15:20:36 -07:00
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
/* AHCI needs SError cleared; otherwise, it might lock up */
|
2007-07-15 22:29:40 -07:00
|
|
|
ahci_scr_read(ap, SCR_ERROR, &serror);
|
2006-05-15 04:58:29 -07:00
|
|
|
ahci_scr_write(ap, SCR_ERROR, serror);
|
2007-09-22 21:19:54 -07:00
|
|
|
host_ehi->serror |= serror;
|
2006-05-15 04:58:29 -07:00
|
|
|
|
2006-11-28 19:33:14 -07:00
|
|
|
/* some controllers set IRQ_IF_ERR on device errors, ignore it */
|
2007-09-22 21:19:55 -07:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_IGN_IRQ_IF_ERR)
|
2006-11-28 19:33:14 -07:00
|
|
|
irq_stat &= ~PORT_IRQ_IF_ERR;
|
|
|
|
|
2007-03-27 03:33:05 -07:00
|
|
|
if (irq_stat & PORT_IRQ_TF_ERR) {
|
2007-09-22 21:19:54 -07:00
|
|
|
/* If qc is active, charge it; otherwise, the active
|
|
|
|
* link. There's no active qc on NCQ errors. It will
|
|
|
|
* be determined by EH by reading log page 10h.
|
|
|
|
*/
|
|
|
|
if (active_qc)
|
|
|
|
active_qc->err_mask |= AC_ERR_DEV;
|
|
|
|
else
|
|
|
|
active_ehi->err_mask |= AC_ERR_DEV;
|
|
|
|
|
2007-09-22 21:19:55 -07:00
|
|
|
if (hpriv->flags & AHCI_HFLAG_IGN_SERR_INTERNAL)
|
2007-09-22 21:19:54 -07:00
|
|
|
host_ehi->serror &= ~SERR_INTERNAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (irq_stat & PORT_IRQ_UNK_FIS) {
|
|
|
|
u32 *unk = (u32 *)(pp->rx_fis + RX_FIS_UNK);
|
|
|
|
|
|
|
|
active_ehi->err_mask |= AC_ERR_HSM;
|
libata: prefer hardreset
When both soft and hard resets are available, libata preferred
softreset till now. The logic behind it was to be softer to devices;
however, this doesn't really help much. Rationales for the change:
* BIOS may freeze lock certain things during boot and softreset can't
unlock those. This by itself is okay but during operation PHY event
or other error conditions can trigger hardreset and the device may
end up with different configuration.
For example, after a hardreset, previously unlockable HPA can be
unlocked resulting in different device size and thus revalidation
failure. Similar condition can occur during or after resume.
* Certain ATAPI devices require hardreset to recover after certain
error conditions. On PATA, this is done by issuing the DEVICE RESET
command. On SATA, COMRESET has equivalent effect. The problem is
that DEVICE RESET needs its own execution protocol.
For SFF controllers with bare TF access, it can be easily
implemented but more advanced controllers (e.g. ahci and sata_sil24)
require specialized implementations. Simply using hardreset solves
the problem nicely.
* COMRESET initialization sequence is the norm in SATA land and many
SATA devices don't work properly if only SRST is used. For example,
some PMPs behave this way and libata works around by always issuing
hardreset if the host supports PMP.
Like the above example, libata has developed a number of mechanisms
aiming to promote softreset to hardreset if softreset is not going
to work. This approach is time consuming and error prone.
Also, note that, dependingon how you read the specs, it could be
argued that PMP fan-out ports require COMRESET to start operation.
In fact, all the PMPs on the market except one don't work properly
if COMRESET is not issued to fan-out ports after PMP reset.
* COMRESET is an integral part of SATA connection and any working
device should be able to handle COMRESET properly. After all, it's
the way to signal hardreset during reboot. This is the most used
and recommended (at least by the ahci spec) method of resetting
devices.
So, this patch makes libata prefer hardreset over softreset by making
the following changes.
* Rename ATA_EH_RESET_MASK to ATA_EH_RESET and use it whereever
ATA_EH_{SOFT|HARD}RESET used to be used. ATA_EH_{SOFT|HARD}RESET is
now only used to tell prereset whether soft or hard reset will be
issued.
* Strip out now unneeded promote-to-hardreset logics from
ata_eh_reset(), ata_std_prereset(), sata_pmp_std_prereset() and
other places.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-01-23 08:05:14 -07:00
|
|
|
active_ehi->action |= ATA_EH_RESET;
|
2007-09-22 21:19:54 -07:00
|
|
|
ata_ehi_push_desc(active_ehi,
|
|
|
|
"unknown FIS %08x %08x %08x %08x" ,
|
|
|
|
unk[0], unk[1], unk[2], unk[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ap->nr_pmp_links && (irq_stat & PORT_IRQ_BAD_PMP)) {
|
|
|
|
active_ehi->err_mask |= AC_ERR_HSM;
|
libata: prefer hardreset
When both soft and hard resets are available, libata preferred
softreset till now. The logic behind it was to be softer to devices;
however, this doesn't really help much. Rationales for the change:
* BIOS may freeze lock certain things during boot and softreset can't
unlock those. This by itself is okay but during operation PHY event
or other error conditions can trigger hardreset and the device may
end up with different configuration.
For example, after a hardreset, previously unlockable HPA can be
unlocked resulting in different device size and thus revalidation
failure. Similar condition can occur during or after resume.
* Certain ATAPI devices require hardreset to recover after certain
error conditions. On PATA, this is done by issuing the DEVICE RESET
command. On SATA, COMRESET has equivalent effect. The problem is
that DEVICE RESET needs its own execution protocol.
For SFF controllers with bare TF access, it can be easily
implemented but more advanced controllers (e.g. ahci and sata_sil24)
require specialized implementations. Simply using hardreset solves
the problem nicely.
* COMRESET initialization sequence is the norm in SATA land and many
SATA devices don't work properly if only SRST is used. For example,
some PMPs behave this way and libata works around by always issuing
hardreset if the host supports PMP.
Like the above example, libata has developed a number of mechanisms
aiming to promote softreset to hardreset if softreset is not going
to work. This approach is time consuming and error prone.
Also, note that, dependingon how you read the specs, it could be
argued that PMP fan-out ports require COMRESET to start operation.
In fact, all the PMPs on the market except one don't work properly
if COMRESET is not issued to fan-out ports after PMP reset.
* COMRESET is an integral part of SATA connection and any working
device should be able to handle COMRESET properly. After all, it's
the way to signal hardreset during reboot. This is the most used
and recommended (at least by the ahci spec) method of resetting
devices.
So, this patch makes libata prefer hardreset over softreset by making
the following changes.
* Rename ATA_EH_RESET_MASK to ATA_EH_RESET and use it whereever
ATA_EH_{SOFT|HARD}RESET used to be used. ATA_EH_{SOFT|HARD}RESET is
now only used to tell prereset whether soft or hard reset will be
issued.
* Strip out now unneeded promote-to-hardreset logics from
ata_eh_reset(), ata_std_prereset(), sata_pmp_std_prereset() and
other places.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-01-23 08:05:14 -07:00
|
|
|
active_ehi->action |= ATA_EH_RESET;
|
2007-09-22 21:19:54 -07:00
|
|
|
ata_ehi_push_desc(active_ehi, "incorrect PMP");
|
2007-03-27 03:33:05 -07:00
|
|
|
}
|
2006-05-15 04:58:29 -07:00
|
|
|
|
|
|
|
if (irq_stat & (PORT_IRQ_HBUS_ERR | PORT_IRQ_HBUS_DATA_ERR)) {
|
2007-09-22 21:19:54 -07:00
|
|
|
host_ehi->err_mask |= AC_ERR_HOST_BUS;
|
libata: prefer hardreset
When both soft and hard resets are available, libata preferred
softreset till now. The logic behind it was to be softer to devices;
however, this doesn't really help much. Rationales for the change:
* BIOS may freeze lock certain things during boot and softreset can't
unlock those. This by itself is okay but during operation PHY event
or other error conditions can trigger hardreset and the device may
end up with different configuration.
For example, after a hardreset, previously unlockable HPA can be
unlocked resulting in different device size and thus revalidation
failure. Similar condition can occur during or after resume.
* Certain ATAPI devices require hardreset to recover after certain
error conditions. On PATA, this is done by issuing the DEVICE RESET
command. On SATA, COMRESET has equivalent effect. The problem is
that DEVICE RESET needs its own execution protocol.
For SFF controllers with bare TF access, it can be easily
implemented but more advanced controllers (e.g. ahci and sata_sil24)
require specialized implementations. Simply using hardreset solves
the problem nicely.
* COMRESET initialization sequence is the norm in SATA land and many
SATA devices don't work properly if only SRST is used. For example,
some PMPs behave this way and libata works around by always issuing
hardreset if the host supports PMP.
Like the above example, libata has developed a number of mechanisms
aiming to promote softreset to hardreset if softreset is not going
to work. This approach is time consuming and error prone.
Also, note that, dependingon how you read the specs, it could be
argued that PMP fan-out ports require COMRESET to start operation.
In fact, all the PMPs on the market except one don't work properly
if COMRESET is not issued to fan-out ports after PMP reset.
* COMRESET is an integral part of SATA connection and any working
device should be able to handle COMRESET properly. After all, it's
the way to signal hardreset during reboot. This is the most used
and recommended (at least by the ahci spec) method of resetting
devices.
So, this patch makes libata prefer hardreset over softreset by making
the following changes.
* Rename ATA_EH_RESET_MASK to ATA_EH_RESET and use it whereever
ATA_EH_{SOFT|HARD}RESET used to be used. ATA_EH_{SOFT|HARD}RESET is
now only used to tell prereset whether soft or hard reset will be
issued.
* Strip out now unneeded promote-to-hardreset logics from
ata_eh_reset(), ata_std_prereset(), sata_pmp_std_prereset() and
other places.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-01-23 08:05:14 -07:00
|
|
|
host_ehi->action |= ATA_EH_RESET;
|
2007-09-22 21:19:54 -07:00
|
|
|
ata_ehi_push_desc(host_ehi, "host bus error");
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
if (irq_stat & PORT_IRQ_IF_ERR) {
|
2007-09-22 21:19:54 -07: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 08:05:14 -07:00
|
|
|
host_ehi->action |= ATA_EH_RESET;
|
2007-09-22 21:19:54 -07:00
|
|
|
ata_ehi_push_desc(host_ehi, "interface fatal error");
|
2006-05-15 04:58:29 -07:00
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
if (irq_stat & (PORT_IRQ_CONNECT | PORT_IRQ_PHYRDY)) {
|
2007-09-22 21:19:54 -07:00
|
|
|
ata_ehi_hotplugged(host_ehi);
|
|
|
|
ata_ehi_push_desc(host_ehi, "%s",
|
|
|
|
irq_stat & PORT_IRQ_CONNECT ?
|
2006-05-15 04:58:29 -07:00
|
|
|
"connection status changed" : "PHY RDY changed");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* okay, let's hand over to EH */
|
2006-01-22 21:09:37 -07:00
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
if (irq_stat & PORT_IRQ_FREEZE)
|
|
|
|
ata_port_freeze(ap);
|
|
|
|
else
|
|
|
|
ata_port_abort(ap);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2007-05-26 17:46:51 -07:00
|
|
|
static void ahci_port_intr(struct ata_port *ap)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ap->ioaddr.cmd_addr;
|
2007-08-06 02:36:22 -07:00
|
|
|
struct ata_eh_info *ehi = &ap->link.eh_info;
|
2007-01-25 03:16:28 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-10-08 23:02:23 -07:00
|
|
|
struct ahci_host_priv *hpriv = ap->host->private_data;
|
2007-10-08 23:06:48 -07:00
|
|
|
int resetting = !!(ap->pflags & ATA_PFLAG_RESETTING);
|
2006-05-15 05:03:55 -07:00
|
|
|
u32 status, qc_active;
|
2007-12-06 20:46:23 -07:00
|
|
|
int rc;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
status = readl(port_mmio + PORT_IRQ_STAT);
|
|
|
|
writel(status, port_mmio + PORT_IRQ_STAT);
|
|
|
|
|
2007-10-08 23:06:48 -07:00
|
|
|
/* ignore BAD_PMP while resetting */
|
|
|
|
if (unlikely(resetting))
|
|
|
|
status &= ~PORT_IRQ_BAD_PMP;
|
|
|
|
|
2007-10-24 22:33:26 -07:00
|
|
|
/* If we are getting PhyRdy, this is
|
|
|
|
* just a power state change, we should
|
|
|
|
* clear out this, plus the PhyRdy/Comm
|
|
|
|
* Wake bits from Serror
|
|
|
|
*/
|
|
|
|
if ((hpriv->flags & AHCI_HFLAG_NO_HOTPLUG) &&
|
|
|
|
(status & PORT_IRQ_PHYRDY)) {
|
|
|
|
status &= ~PORT_IRQ_PHYRDY;
|
|
|
|
ahci_scr_write(ap, SCR_ERROR, ((1 << 16) | (1 << 18)));
|
|
|
|
}
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
if (unlikely(status & PORT_IRQ_ERROR)) {
|
|
|
|
ahci_error_intr(ap, status);
|
|
|
|
return;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2007-08-15 01:11:25 -07:00
|
|
|
if (status & PORT_IRQ_SDB_FIS) {
|
2007-10-08 23:02:23 -07:00
|
|
|
/* If SNotification is available, leave notification
|
|
|
|
* handling to sata_async_notification(). If not,
|
|
|
|
* emulate it by snooping SDB FIS RX area.
|
|
|
|
*
|
|
|
|
* Snooping FIS RX area is probably cheaper than
|
|
|
|
* poking SNotification but some constrollers which
|
|
|
|
* implement SNotification, ICH9 for example, don't
|
|
|
|
* store AN SDB FIS into receive area.
|
2007-08-15 01:11:25 -07:00
|
|
|
*/
|
2007-10-08 23:02:23 -07:00
|
|
|
if (hpriv->cap & HOST_CAP_SNTF)
|
2007-09-22 21:14:13 -07:00
|
|
|
sata_async_notification(ap);
|
2007-10-08 23:02:23 -07:00
|
|
|
else {
|
|
|
|
/* If the 'N' bit in word 0 of the FIS is set,
|
|
|
|
* we just received asynchronous notification.
|
|
|
|
* Tell libata about it.
|
|
|
|
*/
|
|
|
|
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 01:11:25 -07:00
|
|
|
}
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
/* pp->active_link is valid iff any command is in flight */
|
|
|
|
if (ap->qc_active && pp->active_link->sactive)
|
2006-05-15 05:03:55 -07:00
|
|
|
qc_active = readl(port_mmio + PORT_SCR_ACT);
|
|
|
|
else
|
|
|
|
qc_active = readl(port_mmio + PORT_CMD_ISSUE);
|
|
|
|
|
|
|
|
rc = ata_qc_complete_multiple(ap, qc_active, NULL);
|
2007-10-08 23:06:48 -07:00
|
|
|
|
2007-12-06 20:46:23 -07:00
|
|
|
/* while resetting, invalid completions are expected */
|
|
|
|
if (unlikely(rc < 0 && !resetting)) {
|
2006-05-15 05:03:55 -07:00
|
|
|
ehi->err_mask |= AC_ERR_HSM;
|
libata: prefer hardreset
When both soft and hard resets are available, libata preferred
softreset till now. The logic behind it was to be softer to devices;
however, this doesn't really help much. Rationales for the change:
* BIOS may freeze lock certain things during boot and softreset can't
unlock those. This by itself is okay but during operation PHY event
or other error conditions can trigger hardreset and the device may
end up with different configuration.
For example, after a hardreset, previously unlockable HPA can be
unlocked resulting in different device size and thus revalidation
failure. Similar condition can occur during or after resume.
* Certain ATAPI devices require hardreset to recover after certain
error conditions. On PATA, this is done by issuing the DEVICE RESET
command. On SATA, COMRESET has equivalent effect. The problem is
that DEVICE RESET needs its own execution protocol.
For SFF controllers with bare TF access, it can be easily
implemented but more advanced controllers (e.g. ahci and sata_sil24)
require specialized implementations. Simply using hardreset solves
the problem nicely.
* COMRESET initialization sequence is the norm in SATA land and many
SATA devices don't work properly if only SRST is used. For example,
some PMPs behave this way and libata works around by always issuing
hardreset if the host supports PMP.
Like the above example, libata has developed a number of mechanisms
aiming to promote softreset to hardreset if softreset is not going
to work. This approach is time consuming and error prone.
Also, note that, dependingon how you read the specs, it could be
argued that PMP fan-out ports require COMRESET to start operation.
In fact, all the PMPs on the market except one don't work properly
if COMRESET is not issued to fan-out ports after PMP reset.
* COMRESET is an integral part of SATA connection and any working
device should be able to handle COMRESET properly. After all, it's
the way to signal hardreset during reboot. This is the most used
and recommended (at least by the ahci spec) method of resetting
devices.
So, this patch makes libata prefer hardreset over softreset by making
the following changes.
* Rename ATA_EH_RESET_MASK to ATA_EH_RESET and use it whereever
ATA_EH_{SOFT|HARD}RESET used to be used. ATA_EH_{SOFT|HARD}RESET is
now only used to tell prereset whether soft or hard reset will be
issued.
* Strip out now unneeded promote-to-hardreset logics from
ata_eh_reset(), ata_std_prereset(), sata_pmp_std_prereset() and
other places.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-01-23 08:05:14 -07:00
|
|
|
ehi->action |= ATA_EH_RESET;
|
2006-05-15 05:03:55 -07:00
|
|
|
ata_port_freeze(ap);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 06:55:46 -07:00
|
|
|
static irqreturn_t ahci_interrupt(int irq, void *dev_instance)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2006-08-24 00:19:22 -07:00
|
|
|
struct ata_host *host = dev_instance;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ahci_host_priv *hpriv;
|
|
|
|
unsigned int i, handled = 0;
|
2005-08-30 02:18:18 -07:00
|
|
|
void __iomem *mmio;
|
2005-04-16 15:20:36 -07:00
|
|
|
u32 irq_stat, irq_ack = 0;
|
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
2006-08-24 00:19:22 -07:00
|
|
|
hpriv = host->private_data;
|
2007-01-31 23:06:36 -07:00
|
|
|
mmio = host->iomap[AHCI_PCI_BAR];
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* sigh. 0xffffffff is a valid return from h/w */
|
|
|
|
irq_stat = readl(mmio + HOST_IRQ_STAT);
|
|
|
|
irq_stat &= hpriv->port_map;
|
|
|
|
if (!irq_stat)
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
2007-10-19 03:42:56 -07:00
|
|
|
spin_lock(&host->lock);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-10-19 03:42:56 -07:00
|
|
|
for (i = 0; i < host->n_ports; i++) {
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ata_port *ap;
|
|
|
|
|
2005-10-04 23:58:32 -07:00
|
|
|
if (!(irq_stat & (1 << i)))
|
|
|
|
continue;
|
|
|
|
|
2006-08-24 00:19:22 -07:00
|
|
|
ap = host->ports[i];
|
2005-10-04 23:58:32 -07:00
|
|
|
if (ap) {
|
2007-05-26 17:46:51 -07:00
|
|
|
ahci_port_intr(ap);
|
2005-10-04 23:58:32 -07:00
|
|
|
VPRINTK("port %u\n", i);
|
|
|
|
} else {
|
|
|
|
VPRINTK("port %u (no irq)\n", i);
|
2006-03-10 20:47:54 -07:00
|
|
|
if (ata_ratelimit())
|
2006-08-24 00:19:22 -07:00
|
|
|
dev_printk(KERN_WARNING, host->dev,
|
2005-10-30 12:39:11 -07:00
|
|
|
"interrupt on disabled port %u\n", i);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2005-10-04 23:58:32 -07:00
|
|
|
|
|
|
|
irq_ack |= (1 << i);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (irq_ack) {
|
|
|
|
writel(irq_ack, mmio + HOST_IRQ_STAT);
|
|
|
|
handled = 1;
|
|
|
|
}
|
|
|
|
|
2006-08-24 00:19:22 -07:00
|
|
|
spin_unlock(&host->lock);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
VPRINTK("EXIT\n");
|
|
|
|
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
}
|
|
|
|
|
2006-01-22 21:09:36 -07:00
|
|
|
static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
struct ata_port *ap = qc->ap;
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-09-22 21:19:54 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
|
|
|
|
|
|
|
/* Keep track of the currently active link. It will be used
|
|
|
|
* in completion path to determine whether NCQ phase is in
|
|
|
|
* progress.
|
|
|
|
*/
|
|
|
|
pp->active_link = qc->dev->link;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-05-15 05:03:55 -07:00
|
|
|
if (qc->tf.protocol == ATA_PROT_NCQ)
|
|
|
|
writel(1 << qc->tag, port_mmio + PORT_SCR_ACT);
|
|
|
|
writel(1 << qc->tag, port_mmio + PORT_CMD_ISSUE);
|
2005-04-16 15:20:36 -07:00
|
|
|
readl(port_mmio + PORT_CMD_ISSUE); /* flush */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
static void ahci_freeze(struct ata_port *ap)
|
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-05-15 04:58:29 -07:00
|
|
|
|
|
|
|
/* turn IRQ off */
|
|
|
|
writel(0, port_mmio + PORT_IRQ_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_thaw(struct ata_port *ap)
|
|
|
|
{
|
2007-01-31 23:06:36 -07: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 07:44:08 -07:00
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2006-05-15 04:58:29 -07:00
|
|
|
u32 tmp;
|
2007-08-09 14:23:41 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2006-05-15 04:58:29 -07:00
|
|
|
|
|
|
|
/* clear IRQ */
|
|
|
|
tmp = readl(port_mmio + PORT_IRQ_STAT);
|
|
|
|
writel(tmp, port_mmio + PORT_IRQ_STAT);
|
2007-01-26 19:04:26 -07:00
|
|
|
writel(1 << ap->port_no, mmio + HOST_IRQ_STAT);
|
2006-05-15 04:58:29 -07:00
|
|
|
|
2007-10-08 23:01:37 -07:00
|
|
|
/* turn IRQ back on */
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
2006-05-15 04:58:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_error_handler(struct ata_port *ap)
|
|
|
|
{
|
2006-06-28 09:29:30 -07:00
|
|
|
if (!(ap->pflags & ATA_PFLAG_FROZEN)) {
|
2006-05-15 04:58:29 -07:00
|
|
|
/* restart engine */
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ahci_stop_engine(ap);
|
|
|
|
ahci_start_engine(ap);
|
2006-05-15 04:58:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* perform recovery */
|
2007-09-22 21:19:54 -07:00
|
|
|
sata_pmp_do_eh(ap, ata_std_prereset, ahci_softreset,
|
|
|
|
ahci_hardreset, ahci_postreset,
|
|
|
|
sata_pmp_std_prereset, ahci_pmp_softreset,
|
|
|
|
sata_pmp_std_hardreset, sata_pmp_std_postreset);
|
2006-05-15 04:58:29 -07:00
|
|
|
}
|
|
|
|
|
2006-11-01 02:00:24 -07:00
|
|
|
static void ahci_vt8251_error_handler(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
if (!(ap->pflags & ATA_PFLAG_FROZEN)) {
|
|
|
|
/* restart engine */
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ahci_stop_engine(ap);
|
|
|
|
ahci_start_engine(ap);
|
2006-11-01 02:00:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* perform recovery */
|
|
|
|
ata_do_eh(ap, ata_std_prereset, ahci_softreset, ahci_vt8251_hardreset,
|
|
|
|
ahci_postreset);
|
|
|
|
}
|
|
|
|
|
2007-10-24 22:59:16 -07:00
|
|
|
static void ahci_p5wdh_error_handler(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
if (!(ap->pflags & ATA_PFLAG_FROZEN)) {
|
|
|
|
/* restart engine */
|
|
|
|
ahci_stop_engine(ap);
|
|
|
|
ahci_start_engine(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* perform recovery */
|
|
|
|
ata_do_eh(ap, ata_std_prereset, ahci_softreset, ahci_p5wdh_hardreset,
|
|
|
|
ahci_postreset);
|
|
|
|
}
|
|
|
|
|
2006-05-15 04:58:29 -07:00
|
|
|
static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)
|
|
|
|
{
|
|
|
|
struct ata_port *ap = qc->ap;
|
|
|
|
|
2007-07-15 22:29:39 -07:00
|
|
|
/* make DMA engine forget about the failed command */
|
|
|
|
if (qc->flags & ATA_QCFLAG_FAILED)
|
|
|
|
ahci_kick_engine(ap, 1);
|
2006-05-15 04:58:29 -07:00
|
|
|
}
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
static void ahci_pmp_attach(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-10-08 23:01:37 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-09-22 21:19:54 -07:00
|
|
|
u32 cmd;
|
|
|
|
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
cmd |= PORT_CMD_PMP;
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
2007-10-08 23:01:37 -07:00
|
|
|
|
|
|
|
pp->intr_mask |= PORT_IRQ_BAD_PMP;
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
2007-09-22 21:19:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_pmp_detach(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
void __iomem *port_mmio = ahci_port_base(ap);
|
2007-10-08 23:01:37 -07:00
|
|
|
struct ahci_port_priv *pp = ap->private_data;
|
2007-09-22 21:19:54 -07:00
|
|
|
u32 cmd;
|
|
|
|
|
|
|
|
cmd = readl(port_mmio + PORT_CMD);
|
|
|
|
cmd &= ~PORT_CMD_PMP;
|
|
|
|
writel(cmd, port_mmio + PORT_CMD);
|
2007-10-08 23:01:37 -07:00
|
|
|
|
|
|
|
pp->intr_mask &= ~PORT_IRQ_BAD_PMP;
|
|
|
|
writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
|
2007-09-22 21:19:54 -07:00
|
|
|
}
|
|
|
|
|
2007-07-17 12:48:48 -07:00
|
|
|
static int ahci_port_resume(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
ahci_power_up(ap);
|
|
|
|
ahci_start_port(ap);
|
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
if (ap->nr_pmp_links)
|
|
|
|
ahci_pmp_attach(ap);
|
|
|
|
else
|
|
|
|
ahci_pmp_detach(ap);
|
|
|
|
|
2007-07-17 12:48:48 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-03-02 01:31:26 -07:00
|
|
|
#ifdef CONFIG_PM
|
2006-07-25 23:59:26 -07:00
|
|
|
static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
|
|
|
|
{
|
|
|
|
const char *emsg = NULL;
|
|
|
|
int rc;
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
rc = ahci_deinit_port(ap, &emsg);
|
2006-11-19 23:42:36 -07:00
|
|
|
if (rc == 0)
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ahci_power_down(ap);
|
2006-11-19 23:42:36 -07:00
|
|
|
else {
|
2006-07-25 23:59:26 -07:00
|
|
|
ata_port_printk(ap, KERN_ERR, "%s (%d)\n", emsg, rc);
|
2007-05-26 17:46:51 -07:00
|
|
|
ahci_start_port(ap);
|
2006-07-25 23:59:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
|
|
|
|
{
|
2006-08-24 00:19:22 -07:00
|
|
|
struct ata_host *host = dev_get_drvdata(&pdev->dev);
|
2007-01-31 23:06:36 -07:00
|
|
|
void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
|
2006-07-25 23:59:26 -07:00
|
|
|
u32 ctl;
|
|
|
|
|
2008-02-23 11:13:25 -07:00
|
|
|
if (mesg.event & PM_EVENT_SLEEP) {
|
2006-07-25 23:59:26 -07:00
|
|
|
/* AHCI spec rev1.1 section 8.3.3:
|
|
|
|
* Software must disable interrupts prior to requesting a
|
|
|
|
* transition of the HBA to D3 state.
|
|
|
|
*/
|
|
|
|
ctl = readl(mmio + HOST_CTL);
|
|
|
|
ctl &= ~HOST_IRQ_EN;
|
|
|
|
writel(ctl, mmio + HOST_CTL);
|
|
|
|
readl(mmio + HOST_CTL); /* flush */
|
|
|
|
}
|
|
|
|
|
|
|
|
return ata_pci_device_suspend(pdev, mesg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ahci_pci_device_resume(struct pci_dev *pdev)
|
|
|
|
{
|
2006-08-24 00:19:22 -07:00
|
|
|
struct ata_host *host = dev_get_drvdata(&pdev->dev);
|
2006-07-25 23:59:26 -07:00
|
|
|
int rc;
|
|
|
|
|
2006-12-26 03:39:50 -07:00
|
|
|
rc = ata_pci_device_do_resume(pdev);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
2006-07-25 23:59:26 -07:00
|
|
|
|
|
|
|
if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
rc = ahci_reset_controller(host);
|
2006-07-25 23:59:26 -07: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 07:44:08 -07:00
|
|
|
ahci_init_controller(host);
|
2006-07-25 23:59:26 -07:00
|
|
|
}
|
|
|
|
|
2006-08-24 00:19:22 -07:00
|
|
|
ata_host_resume(host);
|
2006-07-25 23:59:26 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-03-02 01:31:26 -07:00
|
|
|
#endif
|
2006-07-25 23:59:26 -07:00
|
|
|
|
2006-07-25 23:59:25 -07:00
|
|
|
static int ahci_port_start(struct ata_port *ap)
|
|
|
|
{
|
2006-08-24 00:19:22 -07:00
|
|
|
struct device *dev = ap->host->dev;
|
2006-07-25 23:59:25 -07:00
|
|
|
struct ahci_port_priv *pp;
|
|
|
|
void *mem;
|
|
|
|
dma_addr_t mem_dma;
|
|
|
|
|
2007-01-20 00:00:28 -07:00
|
|
|
pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
|
2006-07-25 23:59:25 -07:00
|
|
|
if (!pp)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2007-01-20 00:00:28 -07:00
|
|
|
mem = dmam_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma,
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!mem)
|
2006-07-25 23:59:25 -07: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 14:23:41 -07:00
|
|
|
/*
|
2007-10-19 03:42:56 -07:00
|
|
|
* Save off initial list of interrupts to be enabled.
|
|
|
|
* This could be changed later
|
|
|
|
*/
|
2007-08-09 14:23:41 -07:00
|
|
|
pp->intr_mask = DEF_PORT_IRQ;
|
|
|
|
|
2006-07-25 23:59:25 -07:00
|
|
|
ap->private_data = pp;
|
|
|
|
|
2007-05-26 17:46:51 -07:00
|
|
|
/* engage engines, captain */
|
|
|
|
return ahci_port_resume(ap);
|
2006-07-25 23:59:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ahci_port_stop(struct ata_port *ap)
|
|
|
|
{
|
2006-07-25 23:59:26 -07:00
|
|
|
const char *emsg = NULL;
|
|
|
|
int rc;
|
2006-07-25 23:59:25 -07:00
|
|
|
|
2006-07-25 23:59:26 -07:00
|
|
|
/* de-initialize port */
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
rc = ahci_deinit_port(ap, &emsg);
|
2006-07-25 23:59:26 -07:00
|
|
|
if (rc)
|
|
|
|
ata_port_printk(ap, KERN_WARNING, "%s (%d)\n", emsg, rc);
|
2006-07-25 23:59:25 -07:00
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (using_dac &&
|
|
|
|
!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
|
|
|
|
rc = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
|
|
|
|
if (rc) {
|
|
|
|
rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
|
|
|
|
if (rc) {
|
2005-10-30 12:39:11 -07:00
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"64-bit DMA enable failed\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
|
|
|
|
if (rc) {
|
2005-10-30 12:39:11 -07:00
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"32-bit DMA enable failed\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
|
|
|
|
if (rc) {
|
2005-10-30 12:39:11 -07:00
|
|
|
dev_printk(KERN_ERR, &pdev->dev,
|
|
|
|
"32-bit consistent DMA enable failed\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
static void ahci_print_info(struct ata_host *host)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
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];
|
2005-04-16 15:20:36 -07:00
|
|
|
u32 vers, cap, impl, speed;
|
|
|
|
const char *speed_s;
|
|
|
|
u16 cc;
|
|
|
|
const char *scc_s;
|
|
|
|
|
|
|
|
vers = readl(mmio + HOST_VERSION);
|
|
|
|
cap = hpriv->cap;
|
|
|
|
impl = hpriv->port_map;
|
|
|
|
|
|
|
|
speed = (cap >> 20) & 0xf;
|
|
|
|
if (speed == 1)
|
|
|
|
speed_s = "1.5";
|
|
|
|
else if (speed == 2)
|
|
|
|
speed_s = "3";
|
|
|
|
else
|
|
|
|
speed_s = "?";
|
|
|
|
|
|
|
|
pci_read_config_word(pdev, 0x0a, &cc);
|
2007-01-09 03:32:51 -07:00
|
|
|
if (cc == PCI_CLASS_STORAGE_IDE)
|
2005-04-16 15:20:36 -07:00
|
|
|
scc_s = "IDE";
|
2007-01-09 03:32:51 -07:00
|
|
|
else if (cc == PCI_CLASS_STORAGE_SATA)
|
2005-04-16 15:20:36 -07:00
|
|
|
scc_s = "SATA";
|
2007-01-09 03:32:51 -07:00
|
|
|
else if (cc == PCI_CLASS_STORAGE_RAID)
|
2005-04-16 15:20:36 -07:00
|
|
|
scc_s = "RAID";
|
|
|
|
else
|
|
|
|
scc_s = "unknown";
|
|
|
|
|
2005-10-30 12:39:11 -07:00
|
|
|
dev_printk(KERN_INFO, &pdev->dev,
|
|
|
|
"AHCI %02x%02x.%02x%02x "
|
2005-04-16 15:20:36 -07:00
|
|
|
"%u slots %u ports %s Gbps 0x%x impl %s mode\n"
|
2007-10-19 03:42:56 -07:00
|
|
|
,
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-10-19 03:42:56 -07:00
|
|
|
(vers >> 24) & 0xff,
|
|
|
|
(vers >> 16) & 0xff,
|
|
|
|
(vers >> 8) & 0xff,
|
|
|
|
vers & 0xff,
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
((cap >> 8) & 0x1f) + 1,
|
|
|
|
(cap & 0x1f) + 1,
|
|
|
|
speed_s,
|
|
|
|
impl,
|
|
|
|
scc_s);
|
|
|
|
|
2005-10-30 12:39:11 -07:00
|
|
|
dev_printk(KERN_INFO, &pdev->dev,
|
|
|
|
"flags: "
|
2007-07-15 22:29:40 -07:00
|
|
|
"%s%s%s%s%s%s%s"
|
|
|
|
"%s%s%s%s%s%s%s\n"
|
2007-10-19 03:42:56 -07:00
|
|
|
,
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
cap & (1 << 31) ? "64bit " : "",
|
|
|
|
cap & (1 << 30) ? "ncq " : "",
|
2007-07-15 22:29:40 -07:00
|
|
|
cap & (1 << 29) ? "sntf " : "",
|
2005-04-16 15:20:36 -07:00
|
|
|
cap & (1 << 28) ? "ilck " : "",
|
|
|
|
cap & (1 << 27) ? "stag " : "",
|
|
|
|
cap & (1 << 26) ? "pm " : "",
|
|
|
|
cap & (1 << 25) ? "led " : "",
|
|
|
|
|
|
|
|
cap & (1 << 24) ? "clo " : "",
|
|
|
|
cap & (1 << 19) ? "nz " : "",
|
|
|
|
cap & (1 << 18) ? "only " : "",
|
|
|
|
cap & (1 << 17) ? "pmp " : "",
|
|
|
|
cap & (1 << 15) ? "pio " : "",
|
|
|
|
cap & (1 << 14) ? "slum " : "",
|
|
|
|
cap & (1 << 13) ? "part " : ""
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2007-10-24 22:59:16 -07:00
|
|
|
/* On ASUS P5W DH Deluxe, the second port of PCI device 00:1f.2 is
|
|
|
|
* hardwired to on-board SIMG 4726. The chipset is ICH8 and doesn't
|
|
|
|
* support PMP and the 4726 either directly exports the device
|
|
|
|
* attached to the first downstream port or acts as a hardware storage
|
|
|
|
* controller and emulate a single ATA device (can be RAID 0/1 or some
|
|
|
|
* other configuration).
|
|
|
|
*
|
|
|
|
* When there's no device attached to the first downstream port of the
|
|
|
|
* 4726, "Config Disk" appears, which is a pseudo ATA device to
|
|
|
|
* configure the 4726. However, ATA emulation of the device is very
|
|
|
|
* lame. It doesn't send signature D2H Reg FIS after the initial
|
|
|
|
* hardreset, pukes on SRST w/ PMP==0 and has bunch of other issues.
|
|
|
|
*
|
|
|
|
* The following function works around the problem by always using
|
|
|
|
* hardreset on the port and not depending on receiving signature FIS
|
|
|
|
* afterward. If signature FIS isn't received soon, ATA class is
|
|
|
|
* assumed without follow-up softreset.
|
|
|
|
*/
|
|
|
|
static void ahci_p5wdh_workaround(struct ata_host *host)
|
|
|
|
{
|
|
|
|
static struct dmi_system_id sysids[] = {
|
|
|
|
{
|
|
|
|
.ident = "P5W DH Deluxe",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR,
|
|
|
|
"ASUSTEK COMPUTER INC"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "P5W DH Deluxe"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
struct pci_dev *pdev = to_pci_dev(host->dev);
|
|
|
|
|
|
|
|
if (pdev->bus->number == 0 && pdev->devfn == PCI_DEVFN(0x1f, 2) &&
|
|
|
|
dmi_check_system(sysids)) {
|
|
|
|
struct ata_port *ap = host->ports[1];
|
|
|
|
|
|
|
|
dev_printk(KERN_INFO, &pdev->dev, "enabling ASUS P5W DH "
|
|
|
|
"Deluxe on-board SIMG4726 workaround\n");
|
|
|
|
|
|
|
|
ap->ops = &ahci_p5wdh_ops;
|
|
|
|
ap->link.flags |= ATA_LFLAG_NO_SRST | ATA_LFLAG_ASSUME_ATA;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-20 00:00:28 -07:00
|
|
|
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
static int printed_version;
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
struct ata_port_info pi = ahci_port_info[ent->driver_data];
|
|
|
|
const struct ata_port_info *ppi[] = { &pi, NULL };
|
2007-01-20 00:00:28 -07:00
|
|
|
struct device *dev = &pdev->dev;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct ahci_host_priv *hpriv;
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
struct ata_host *host;
|
2008-02-05 23:13:51 -07:00
|
|
|
int n_ports, i, rc;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
VPRINTK("ENTER\n");
|
|
|
|
|
2006-05-15 05:03:55 -07:00
|
|
|
WARN_ON(ATA_MAX_QUEUE > AHCI_MAX_CMDS);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
if (!printed_version++)
|
2005-10-30 12:39:11 -07:00
|
|
|
dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
|
2005-04-16 15:20:36 -07:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
/* acquire resources */
|
2007-01-20 00:00:28 -07:00
|
|
|
rc = pcim_enable_device(pdev);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2008-03-11 03:52:31 -07:00
|
|
|
/* AHCI controllers often implement SFF compatible interface.
|
|
|
|
* Grab all PCI BARs just in case.
|
|
|
|
*/
|
|
|
|
rc = pcim_iomap_regions_request_all(pdev, 1 << AHCI_PCI_BAR, DRV_NAME);
|
2007-01-31 23:06:36 -07:00
|
|
|
if (rc == -EBUSY)
|
2007-01-20 00:00:28 -07:00
|
|
|
pcim_pin_device(pdev);
|
2007-01-31 23:06:36 -07:00
|
|
|
if (rc)
|
2007-01-20 00:00:28 -07:00
|
|
|
return rc;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-12-05 23:09:43 -07:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
|
|
|
|
(pdev->device == 0x2652 || pdev->device == 0x2653)) {
|
|
|
|
u8 map;
|
|
|
|
|
|
|
|
/* ICH6s share the same PCI ID for both piix and ahci
|
|
|
|
* modes. Enabling ahci mode while MAP indicates
|
|
|
|
* combined mode is a bad idea. Yield to ata_piix.
|
|
|
|
*/
|
|
|
|
pci_read_config_byte(pdev, ICH_MAP, &map);
|
|
|
|
if (map & 0x3) {
|
|
|
|
dev_printk(KERN_INFO, &pdev->dev, "controller is in "
|
|
|
|
"combined mode, can't enable AHCI mode\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-20 00:00:28 -07:00
|
|
|
hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
|
|
|
|
if (!hpriv)
|
|
|
|
return -ENOMEM;
|
2007-09-22 21:19:55 -07:00
|
|
|
hpriv->flags |= (unsigned long)pi.private_data;
|
|
|
|
|
|
|
|
if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev))
|
|
|
|
pci_intx(pdev, 1);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
/* save initial config */
|
2007-09-22 21:19:55 -07:00
|
|
|
ahci_save_initial_config(pdev, hpriv);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
/* prepare host */
|
2007-07-15 22:29:40 -07:00
|
|
|
if (hpriv->cap & HOST_CAP_NCQ)
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
pi.flags |= ATA_FLAG_NCQ;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-09-22 21:19:54 -07:00
|
|
|
if (hpriv->cap & HOST_CAP_PMP)
|
|
|
|
pi.flags |= ATA_FLAG_PMP;
|
|
|
|
|
2008-02-05 23:13:51 -07:00
|
|
|
/* CAP.NP sometimes indicate the index of the last enabled
|
|
|
|
* port, at other times, that of the last possible port, so
|
|
|
|
* determining the maximum port number requires looking at
|
|
|
|
* both CAP.NP and port_map.
|
|
|
|
*/
|
|
|
|
n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
|
|
|
|
|
|
|
|
host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
if (!host)
|
|
|
|
return -ENOMEM;
|
|
|
|
host->iomap = pcim_iomap_table(pdev);
|
|
|
|
host->private_data = hpriv;
|
|
|
|
|
|
|
|
for (i = 0; i < host->n_ports; i++) {
|
2007-05-28 05:33:01 -07:00
|
|
|
struct ata_port *ap = host->ports[i];
|
|
|
|
void __iomem *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 07:44:08 -07:00
|
|
|
|
2007-08-17 21:14:55 -07:00
|
|
|
ata_port_pbar_desc(ap, AHCI_PCI_BAR, -1, "abar");
|
|
|
|
ata_port_pbar_desc(ap, AHCI_PCI_BAR,
|
|
|
|
0x100 + ap->port_no * 0x80, "port");
|
|
|
|
|
2007-10-24 22:33:26 -07:00
|
|
|
/* set initial link pm policy */
|
|
|
|
ap->pm_policy = NOT_AVAILABLE;
|
|
|
|
|
2007-05-28 05:33:01 -07:00
|
|
|
/* standard SATA port setup */
|
2007-07-15 22:29:40 -07:00
|
|
|
if (hpriv->port_map & (1 << i))
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ap->ioaddr.cmd_addr = port_mmio;
|
2007-05-28 05:33:01 -07:00
|
|
|
|
|
|
|
/* disabled/not-implemented port */
|
|
|
|
else
|
|
|
|
ap->ops = &ata_dummy_port_ops;
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
}
|
2007-03-18 06:15:33 -07:00
|
|
|
|
2007-10-24 22:59:16 -07:00
|
|
|
/* apply workaround for ASUS P5W DH Deluxe mainboard */
|
|
|
|
ahci_p5wdh_workaround(host);
|
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
/* initialize adapter */
|
|
|
|
rc = ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (rc)
|
2007-01-20 00:00:28 -07:00
|
|
|
return rc;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
rc = ahci_reset_controller(host);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
ahci_init_controller(host);
|
|
|
|
ahci_print_info(host);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
libata: convert the remaining SATA drivers to new init model
Convert ahci, sata_sil, sata_sil24, sata_svw, sata_qstor, sata_mv,
sata_sx4, sata_vsc and sata_inic162x to new init model.
Now that host and ap are available during intialization, functions are
converted to take either host or ap instead of low level parameters
which were inevitable for functions shared between init and other
paths. This simplifies code quite a bit.
* init_one()'s now follow more consistent init order
* ahci_setup_port() and ahci_host_init() collapsed into
ahci_init_one() for init order consistency
* sata_vsc uses port_info instead of setting fields manually
* in sata_svw, k2_board_info converted to port_info (info is now in
port flags). port number is honored now.
Tested on ICH7/8 AHCI, jmb360, sil3112, 3114, 3124 and 3132.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 07:44:08 -07:00
|
|
|
pci_set_master(pdev);
|
|
|
|
return ata_host_activate(host, pdev->irq, ahci_interrupt, IRQF_SHARED,
|
|
|
|
&ahci_sht);
|
2005-05-12 12:03:42 -07:00
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
static int __init ahci_init(void)
|
|
|
|
{
|
2006-08-10 02:13:18 -07:00
|
|
|
return pci_register_driver(&ahci_pci_driver);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit ahci_exit(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&ahci_pci_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Jeff Garzik");
|
|
|
|
MODULE_DESCRIPTION("AHCI SATA low-level driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DEVICE_TABLE(pci, ahci_pci_tbl);
|
2005-08-22 23:53:51 -07:00
|
|
|
MODULE_VERSION(DRV_VERSION);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
module_init(ahci_init);
|
|
|
|
module_exit(ahci_exit);
|