aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-09-23 00:19:54 -0400
committerJeff Garzik <jeff@garzik.org>2007-10-12 14:55:44 -0400
commit633273a3ed1cf37ced90475b0f95cf81deab04f1 (patch)
tree5cd42191d1ea8d5ee84fb2f7c7660f124787d9e8 /drivers/ata/libata-core.c
parent3af9a77af9e2b72366363864bfcd3d51465ff98a (diff)
libata-pmp: hook PMP support and enable it
Hook PMP support into libata and enable it. Connect SCR and probing functions, and update ata_dev_classify() to detect PMP. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r--drivers/ata/libata-core.c111
1 files changed, 80 insertions, 31 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 9e7f55b71044..d3e78d97529d 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -670,29 +670,49 @@ static unsigned int ata_devchk(struct ata_port *ap, unsigned int device)
670 * None. 670 * None.
671 * 671 *
672 * RETURNS: 672 * RETURNS:
673 * Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, or %ATA_DEV_UNKNOWN 673 * Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP or
674 * the event of failure. 674 * %ATA_DEV_UNKNOWN the event of failure.
675 */ 675 */
676
677unsigned int ata_dev_classify(const struct ata_taskfile *tf) 676unsigned int ata_dev_classify(const struct ata_taskfile *tf)
678{ 677{
679 /* Apple's open source Darwin code hints that some devices only 678 /* Apple's open source Darwin code hints that some devices only
680 * put a proper signature into the LBA mid/high registers, 679 * put a proper signature into the LBA mid/high registers,
681 * So, we only check those. It's sufficient for uniqueness. 680 * So, we only check those. It's sufficient for uniqueness.
681 *
682 * ATA/ATAPI-7 (d1532v1r1: Feb. 19, 2003) specified separate
683 * signatures for ATA and ATAPI devices attached on SerialATA,
684 * 0x3c/0xc3 and 0x69/0x96 respectively. However, SerialATA
685 * spec has never mentioned about using different signatures
686 * for ATA/ATAPI devices. Then, Serial ATA II: Port
687 * Multiplier specification began to use 0x69/0x96 to identify
688 * port multpliers and 0x3c/0xc3 to identify SEMB device.
689 * ATA/ATAPI-7 dropped descriptions about 0x3c/0xc3 and
690 * 0x69/0x96 shortly and described them as reserved for
691 * SerialATA.
692 *
693 * We follow the current spec and consider that 0x69/0x96
694 * identifies a port multiplier and 0x3c/0xc3 a SEMB device.
682 */ 695 */
683 696 if ((tf->lbam == 0) && (tf->lbah == 0)) {
684 if (((tf->lbam == 0) && (tf->lbah == 0)) ||
685 ((tf->lbam == 0x3c) && (tf->lbah == 0xc3))) {
686 DPRINTK("found ATA device by sig\n"); 697 DPRINTK("found ATA device by sig\n");
687 return ATA_DEV_ATA; 698 return ATA_DEV_ATA;
688 } 699 }
689 700
690 if (((tf->lbam == 0x14) && (tf->lbah == 0xeb)) || 701 if ((tf->lbam == 0x14) && (tf->lbah == 0xeb)) {
691 ((tf->lbam == 0x69) && (tf->lbah == 0x96))) {
692 DPRINTK("found ATAPI device by sig\n"); 702 DPRINTK("found ATAPI device by sig\n");
693 return ATA_DEV_ATAPI; 703 return ATA_DEV_ATAPI;
694 } 704 }
695 705
706 if ((tf->lbam == 0x69) && (tf->lbah == 0x96)) {
707 DPRINTK("found PMP device by sig\n");
708 return ATA_DEV_PMP;
709 }
710
711 if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3)) {
712 printk("ata: SEMB device ignored\n");
713 return ATA_DEV_SEMB_UNSUP; /* not yet */
714 }
715
696 DPRINTK("unknown device\n"); 716 DPRINTK("unknown device\n");
697 return ATA_DEV_UNKNOWN; 717 return ATA_DEV_UNKNOWN;
698} 718}
@@ -3426,6 +3446,12 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline)
3426 (link->flags & ATA_LFLAG_HRST_TO_RESUME)) 3446 (link->flags & ATA_LFLAG_HRST_TO_RESUME))
3427 ehc->i.action |= ATA_EH_HARDRESET; 3447 ehc->i.action |= ATA_EH_HARDRESET;
3428 3448
3449 /* Some PMPs don't work with only SRST, force hardreset if PMP
3450 * is supported.
3451 */
3452 if (ap->flags & ATA_FLAG_PMP)
3453 ehc->i.action |= ATA_EH_HARDRESET;
3454
3429 /* if we're about to do hardreset, nothing more to do */ 3455 /* if we're about to do hardreset, nothing more to do */
3430 if (ehc->i.action & ATA_EH_HARDRESET) 3456 if (ehc->i.action & ATA_EH_HARDRESET)
3431 return 0; 3457 return 0;
@@ -3616,6 +3642,16 @@ int sata_std_hardreset(struct ata_link *link, unsigned int *class,
3616 /* wait a while before checking status, see SRST for more info */ 3642 /* wait a while before checking status, see SRST for more info */
3617 msleep(150); 3643 msleep(150);
3618 3644
3645 /* If PMP is supported, we have to do follow-up SRST. Note
3646 * that some PMPs don't send D2H Reg FIS after hardreset at
3647 * all if the first port is empty. Wait for it just for a
3648 * second and request follow-up SRST.
3649 */
3650 if (ap->flags & ATA_FLAG_PMP) {
3651 ata_wait_ready(ap, jiffies + HZ);
3652 return -EAGAIN;
3653 }
3654
3619 rc = ata_wait_ready(ap, deadline); 3655 rc = ata_wait_ready(ap, deadline);
3620 /* link occupied, -ENODEV too is an error */ 3656 /* link occupied, -ENODEV too is an error */
3621 if (rc) { 3657 if (rc) {
@@ -5966,22 +6002,26 @@ int sata_scr_valid(struct ata_link *link)
5966 * @val: Place to store read value 6002 * @val: Place to store read value
5967 * 6003 *
5968 * Read SCR register @reg of @link into *@val. This function is 6004 * Read SCR register @reg of @link into *@val. This function is
5969 * guaranteed to succeed if the cable type of the port is SATA 6005 * guaranteed to succeed if @link is ap->link, the cable type of
5970 * and the port implements ->scr_read. 6006 * the port is SATA and the port implements ->scr_read.
5971 * 6007 *
5972 * LOCKING: 6008 * LOCKING:
5973 * None. 6009 * None if @link is ap->link. Kernel thread context otherwise.
5974 * 6010 *
5975 * RETURNS: 6011 * RETURNS:
5976 * 0 on success, negative errno on failure. 6012 * 0 on success, negative errno on failure.
5977 */ 6013 */
5978int sata_scr_read(struct ata_link *link, int reg, u32 *val) 6014int sata_scr_read(struct ata_link *link, int reg, u32 *val)
5979{ 6015{
5980 struct ata_port *ap = link->ap; 6016 if (ata_is_host_link(link)) {
6017 struct ata_port *ap = link->ap;
5981 6018
5982 if (sata_scr_valid(link)) 6019 if (sata_scr_valid(link))
5983 return ap->ops->scr_read(ap, reg, val); 6020 return ap->ops->scr_read(ap, reg, val);
5984 return -EOPNOTSUPP; 6021 return -EOPNOTSUPP;
6022 }
6023
6024 return sata_pmp_scr_read(link, reg, val);
5985} 6025}
5986 6026
5987/** 6027/**
@@ -5991,22 +6031,26 @@ int sata_scr_read(struct ata_link *link, int reg, u32 *val)
5991 * @val: value to write 6031 * @val: value to write
5992 * 6032 *
5993 * Write @val to SCR register @reg of @link. This function is 6033 * Write @val to SCR register @reg of @link. This function is
5994 * guaranteed to succeed if the cable type of the port is SATA 6034 * guaranteed to succeed if @link is ap->link, the cable type of
5995 * and the port implements ->scr_read. 6035 * the port is SATA and the port implements ->scr_read.
5996 * 6036 *
5997 * LOCKING: 6037 * LOCKING:
5998 * None. 6038 * None if @link is ap->link. Kernel thread context otherwise.
5999 * 6039 *
6000 * RETURNS: 6040 * RETURNS:
6001 * 0 on success, negative errno on failure. 6041 * 0 on success, negative errno on failure.
6002 */ 6042 */
6003int sata_scr_write(struct ata_link *link, int reg, u32 val) 6043int sata_scr_write(struct ata_link *link, int reg, u32 val)
6004{ 6044{
6005 struct ata_port *ap = link->ap; 6045 if (ata_is_host_link(link)) {
6046 struct ata_port *ap = link->ap;
6006 6047
6007 if (sata_scr_valid(link)) 6048 if (sata_scr_valid(link))
6008 return ap->ops->scr_write(ap, reg, val); 6049 return ap->ops->scr_write(ap, reg, val);
6009 return -EOPNOTSUPP; 6050 return -EOPNOTSUPP;
6051 }
6052
6053 return sata_pmp_scr_write(link, reg, val);
6010} 6054}
6011 6055
6012/** 6056/**
@@ -6019,23 +6063,27 @@ int sata_scr_write(struct ata_link *link, int reg, u32 val)
6019 * function performs flush after writing to the register. 6063 * function performs flush after writing to the register.
6020 * 6064 *
6021 * LOCKING: 6065 * LOCKING:
6022 * None. 6066 * None if @link is ap->link. Kernel thread context otherwise.
6023 * 6067 *
6024 * RETURNS: 6068 * RETURNS:
6025 * 0 on success, negative errno on failure. 6069 * 0 on success, negative errno on failure.
6026 */ 6070 */
6027int sata_scr_write_flush(struct ata_link *link, int reg, u32 val) 6071int sata_scr_write_flush(struct ata_link *link, int reg, u32 val)
6028{ 6072{
6029 struct ata_port *ap = link->ap; 6073 if (ata_is_host_link(link)) {
6030 int rc; 6074 struct ata_port *ap = link->ap;
6075 int rc;
6031 6076
6032 if (sata_scr_valid(link)) { 6077 if (sata_scr_valid(link)) {
6033 rc = ap->ops->scr_write(ap, reg, val); 6078 rc = ap->ops->scr_write(ap, reg, val);
6034 if (rc == 0) 6079 if (rc == 0)
6035 rc = ap->ops->scr_read(ap, reg, &val); 6080 rc = ap->ops->scr_read(ap, reg, &val);
6036 return rc; 6081 return rc;
6082 }
6083 return -EOPNOTSUPP;
6037 } 6084 }
6038 return -EOPNOTSUPP; 6085
6086 return sata_pmp_scr_write(link, reg, val);
6039} 6087}
6040 6088
6041/** 6089/**
@@ -6424,6 +6472,7 @@ static void ata_host_release(struct device *gendev, void *res)
6424 if (ap->scsi_host) 6472 if (ap->scsi_host)
6425 scsi_host_put(ap->scsi_host); 6473 scsi_host_put(ap->scsi_host);
6426 6474
6475 kfree(ap->pmp_link);
6427 kfree(ap); 6476 kfree(ap);
6428 host->ports[i] = NULL; 6477 host->ports[i] = NULL;
6429 } 6478 }