Add common routines for SATA controllers. Right now, we have sata_speed(),

which reports the speed encoded in the SStatus register.
This commit is contained in:
thorpej 2004-05-28 23:26:27 +00:00
parent 521748fbfa
commit f2da431235
4 changed files with 132 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: files,v 1.673 2004/05/28 15:35:41 toshii Exp $
# $NetBSD: files,v 1.674 2004/05/28 23:26:27 thorpej Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@ -205,6 +205,7 @@ define audiobus { }
define midibus { }
define midisyn
define ata {[channel = -1]}
define sata
define scsi_core
define scsi {[channel = -1]}: scsi_core
define ata_hl {[drive = -1]}

View File

@ -1,4 +1,4 @@
# $NetBSD: files.ata,v 1.8 2003/10/08 20:58:00 bouyer Exp $
# $NetBSD: files.ata,v 1.9 2004/05/28 23:26:27 thorpej Exp $
#
# Config file and device description for machine-independent devices
# which attach to ATA busses. Included by ports that need it. Ports
@ -20,3 +20,6 @@ file dev/ata/ata_raid_promise.c ataraid
attach ld at ataraid with ld_ataraid
file dev/ata/ld_ataraid.c ld_ataraid
# Common SATA subroutines
file dev/ata/sata_subr.c sata

78
sys/dev/ata/sata_subr.c Normal file
View File

@ -0,0 +1,78 @@
/* $NetBSD: sata_subr.c,v 1.1 2004/05/28 23:26:27 thorpej Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe of Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Common functions for Serial ATA.
*/
#include <sys/param.h>
#include <dev/ata/satareg.h>
#include <dev/ata/satavar.h>
/*
* sata_speed:
*
* Return a string describing the port speed reported by
* the port's SStatus register.
*/
const char *
sata_speed(uint32_t sstatus)
{
static const char *sata_speedtab[] = {
"no negotiated speed",
"1.5Gb/s",
"3.0GB/s",
"<unknown 3>",
"<unknown 4>",
"<unknown 5>",
"<unknown 6>",
"<unknown 7>",
"<unknown 8>",
"<unknown 9>",
"<unknown 10>",
"<unknown 11>",
"<unknown 12>",
"<unknown 13>",
"<unknown 14>",
"<unknown 15>",
};
return (sata_speedtab[(sstatus & SStatus_SPD_mask) >>
SStatus_SPD_shift]);
}

48
sys/dev/ata/satavar.h Normal file
View File

@ -0,0 +1,48 @@
/* $NetBSD: satavar.h,v 1.1 2004/05/28 23:26:27 thorpej Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe of Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DEV_ATA_SATAVAR_H_
#define _DEV_ATA_SATAVAR_H_
/*
* Declaration of common data structures and functions for Serial ATA.
*/
const char *sata_speed(uint32_t);
#endif /* _DEV_ATA_SATAVAR_H_ */