2 * sata_promise.h - Promise SATA common definitions and inline funcs
4 * Copyright 2003-2004 Red Hat, Inc.
6 * The contents of this file are subject to the Open
7 * Software License version 1.1 that can be found at
8 * http://www.opensource.org/licenses/osl-1.1.txt and is included herein
11 * Alternatively, the contents of this file may be used under the terms
12 * of the GNU General Public License version 2 (the "GPL") as distributed
13 * in the kernel source COPYING file, in which case the provisions of
14 * the GPL are applicable instead of the above. If you wish to allow
15 * the use of your version of this file only under the terms of the
16 * GPL and not to allow others to use your version of this file under
17 * the OSL, indicate your decision by deleting the provisions above and
18 * replace them with the notice and other provisions required by the GPL.
19 * If you do not delete the provisions above, a recipient may use your
20 * version of this file under either the OSL or the GPL.
24 #ifndef __SATA_PROMISE_H__
25 #define __SATA_PROMISE_H__
27 #include <linux/ata.h>
29 enum pdc_packet_bits {
30 PDC_PKT_READ = (1 << 2),
31 PDC_PKT_NODATA = (1 << 3),
33 PDC_PKT_SIZEMASK = (1 << 7) | (1 << 6) | (1 << 5),
34 PDC_PKT_CLEAR_BSY = (1 << 4),
35 PDC_PKT_WAIT_DRDY = (1 << 3) | (1 << 4),
36 PDC_LAST_REG = (1 << 3),
38 PDC_REG_DEVCTL = (1 << 3) | (1 << 2) | (1 << 1),
41 static inline unsigned int pdc_pkt_header(struct ata_taskfile *tf,
43 unsigned int devno, u8 *buf)
46 u32 *buf32 = (u32 *) buf;
48 /* set control bits (byte 0), zero delay seq id (byte 3),
51 switch (tf->protocol) {
53 if (!(tf->flags & ATA_TFLAG_WRITE))
54 buf32[0] = cpu_to_le32(PDC_PKT_READ);
60 buf32[0] = cpu_to_le32(PDC_PKT_NODATA);
68 buf32[1] = cpu_to_le32(sg_table); /* S/G table addr */
69 buf32[2] = 0; /* no next-packet */
72 dev_reg = ATA_DEVICE_OBS;
74 dev_reg = ATA_DEVICE_OBS | ATA_DEV1;
77 buf[12] = (1 << 5) | PDC_PKT_CLEAR_BSY | ATA_REG_DEVICE;
80 /* device control register */
81 buf[14] = (1 << 5) | PDC_REG_DEVCTL;
84 return 16; /* offset of next byte */
87 static inline unsigned int pdc_pkt_footer(struct ata_taskfile *tf, u8 *buf,
90 if (tf->flags & ATA_TFLAG_DEVICE) {
91 buf[i++] = (1 << 5) | ATA_REG_DEVICE;
92 buf[i++] = tf->device;
95 /* and finally the command itself; also includes end-of-pkt marker */
96 buf[i++] = (1 << 5) | PDC_LAST_REG | ATA_REG_CMD;
97 buf[i++] = tf->command;
102 static inline unsigned int pdc_prep_lba28(struct ata_taskfile *tf, u8 *buf, unsigned int i)
104 /* the "(1 << 5)" should be read "(count << 5)" */
106 /* ATA command block registers */
107 buf[i++] = (1 << 5) | ATA_REG_FEATURE;
108 buf[i++] = tf->feature;
110 buf[i++] = (1 << 5) | ATA_REG_NSECT;
111 buf[i++] = tf->nsect;
113 buf[i++] = (1 << 5) | ATA_REG_LBAL;
116 buf[i++] = (1 << 5) | ATA_REG_LBAM;
119 buf[i++] = (1 << 5) | ATA_REG_LBAH;
125 static inline unsigned int pdc_prep_lba48(struct ata_taskfile *tf, u8 *buf, unsigned int i)
127 /* the "(2 << 5)" should be read "(count << 5)" */
129 /* ATA command block registers */
130 buf[i++] = (2 << 5) | ATA_REG_FEATURE;
131 buf[i++] = tf->hob_feature;
132 buf[i++] = tf->feature;
134 buf[i++] = (2 << 5) | ATA_REG_NSECT;
135 buf[i++] = tf->hob_nsect;
136 buf[i++] = tf->nsect;
138 buf[i++] = (2 << 5) | ATA_REG_LBAL;
139 buf[i++] = tf->hob_lbal;
142 buf[i++] = (2 << 5) | ATA_REG_LBAM;
143 buf[i++] = tf->hob_lbam;
146 buf[i++] = (2 << 5) | ATA_REG_LBAH;
147 buf[i++] = tf->hob_lbah;
154 #endif /* __SATA_PROMISE_H__ */