1 /*        $NetBSD: satapmpreg.h,v 1.6 2012/07/31 15:50:34 bouyer Exp $          */
2 
3 /*-
4  * Copyright (c) 2004 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Frank van der Linden of Wasabi Systems, Inc.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _DEV_ATA_SATAPMPREG_H_
33 #define   _DEV_ATA_SATAPMPREG_H_
34 
35 /*
36  * Global port multiplier registers, accessed through the control port.
37  */
38 
39 #define PMP_GSCR_ID 0x00                /* product and vendor id */
40 #define   PMP_ID_DEV(x)       ((x) >> 16)
41 #define             PMP_ID_VEND(x)      ((x) & 0xffff)
42 #define PMP_GSCR_REV          0x01                /* revision */
43 #define             PMP_REV_SPEC_10               0x02
44 #define             PMP_REV_SPEC_11               0x04
45 #define             PMP_REV_LEVEL(x)    (((x) >> 8) & 0xff)
46 #define PMP_GSCR_INF          0x02                /* info */
47 #define             PMP_INF_NPORTS(x)   ((x) & 0xf)
48 #define PMP_GSCR_ERR          0x20                /* error bit for each port */
49 #define             PMP_ERR(p)                    ((1) << (p))
50 #define PMP_GSCR_ERREN        0x21                /* error bit enable for each port */
51 #define             PMP_ERREN(p)                  ((1) << (p))
52 #define PMP_GSCR_FEAT         0x40                /* features */
53 #define   PMP_FEAT_BIST                 0x01
54 #define   PMP_FEAT_PMREQ                0x01
55 #define             PMP_FEAT_SCC                  0x04
56 #define             PMP_FEAT_ASYNC                0x08
57 #define PMP_GSCR_FEATEN       0x60                /* feature enable, bits as above */
58 
59 #define PMP_GSCR_VENDSTART 0x80                   /* start of vendor unique registers */
60 
61 #define PMP_GSCR_NREGS        256
62 
63 /*
64  * Port status and control registers (per port)
65  */
66 #define PMP_PSCR_SStatus      0x00
67 #define PMP_PSCR_SError                 0x01
68 #define PMP_PSCR_SControl     0x02
69 #define PMP_PSCR_SActive      0x03
70 
71 /*
72  * Control port as defined in the spec.
73  */
74 #define PMP_PORT_CTL                    0x0f
75 
76 /*
77  * Device commands for port multipliers
78  */
79 #define PMPC_READ_PORT                  0xe4
80 #define PMPC_WRITE_PORT                 0xe8
81 
82 /* max number of drives (last one being the PM itself */
83 #define PMP_MAX_DRIVES                  16
84 
85 #endif /* _DEV_ATA_SATAPMPREG_H_ */
86