]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/scsi/sata_promise.h
2 * sata_promise.h - Promise SATA common definitions and inline funcs
4 * Copyright 2003-2004 Red Hat, Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 * libata documentation is available via 'make {ps|pdf}docs',
23 * as Documentation/DocBook/libata.*
27 #ifndef __SATA_PROMISE_H__
28 #define __SATA_PROMISE_H__
30 #include <linux/ata.h>
32 enum pdc_packet_bits
{
33 PDC_PKT_READ
= (1 << 2),
34 PDC_PKT_NODATA
= (1 << 3),
36 PDC_PKT_SIZEMASK
= (1 << 7) | (1 << 6) | (1 << 5),
37 PDC_PKT_CLEAR_BSY
= (1 << 4),
38 PDC_PKT_WAIT_DRDY
= (1 << 3) | (1 << 4),
39 PDC_LAST_REG
= (1 << 3),
41 PDC_REG_DEVCTL
= (1 << 3) | (1 << 2) | (1 << 1),
44 static inline unsigned int pdc_pkt_header(struct ata_taskfile
*tf
,
46 unsigned int devno
, u8
*buf
)
49 u32
*buf32
= (u32
*) buf
;
51 /* set control bits (byte 0), zero delay seq id (byte 3),
54 switch (tf
->protocol
) {
56 if (!(tf
->flags
& ATA_TFLAG_WRITE
))
57 buf32
[0] = cpu_to_le32(PDC_PKT_READ
);
63 buf32
[0] = cpu_to_le32(PDC_PKT_NODATA
);
71 buf32
[1] = cpu_to_le32(sg_table
); /* S/G table addr */
72 buf32
[2] = 0; /* no next-packet */
75 dev_reg
= ATA_DEVICE_OBS
;
77 dev_reg
= ATA_DEVICE_OBS
| ATA_DEV1
;
80 buf
[12] = (1 << 5) | PDC_PKT_CLEAR_BSY
| ATA_REG_DEVICE
;
83 /* device control register */
84 buf
[14] = (1 << 5) | PDC_REG_DEVCTL
;
87 return 16; /* offset of next byte */
90 static inline unsigned int pdc_pkt_footer(struct ata_taskfile
*tf
, u8
*buf
,
93 if (tf
->flags
& ATA_TFLAG_DEVICE
) {
94 buf
[i
++] = (1 << 5) | ATA_REG_DEVICE
;
95 buf
[i
++] = tf
->device
;
98 /* and finally the command itself; also includes end-of-pkt marker */
99 buf
[i
++] = (1 << 5) | PDC_LAST_REG
| ATA_REG_CMD
;
100 buf
[i
++] = tf
->command
;
105 static inline unsigned int pdc_prep_lba28(struct ata_taskfile
*tf
, u8
*buf
, unsigned int i
)
107 /* the "(1 << 5)" should be read "(count << 5)" */
109 /* ATA command block registers */
110 buf
[i
++] = (1 << 5) | ATA_REG_FEATURE
;
111 buf
[i
++] = tf
->feature
;
113 buf
[i
++] = (1 << 5) | ATA_REG_NSECT
;
114 buf
[i
++] = tf
->nsect
;
116 buf
[i
++] = (1 << 5) | ATA_REG_LBAL
;
119 buf
[i
++] = (1 << 5) | ATA_REG_LBAM
;
122 buf
[i
++] = (1 << 5) | ATA_REG_LBAH
;
128 static inline unsigned int pdc_prep_lba48(struct ata_taskfile
*tf
, u8
*buf
, unsigned int i
)
130 /* the "(2 << 5)" should be read "(count << 5)" */
132 /* ATA command block registers */
133 buf
[i
++] = (2 << 5) | ATA_REG_FEATURE
;
134 buf
[i
++] = tf
->hob_feature
;
135 buf
[i
++] = tf
->feature
;
137 buf
[i
++] = (2 << 5) | ATA_REG_NSECT
;
138 buf
[i
++] = tf
->hob_nsect
;
139 buf
[i
++] = tf
->nsect
;
141 buf
[i
++] = (2 << 5) | ATA_REG_LBAL
;
142 buf
[i
++] = tf
->hob_lbal
;
145 buf
[i
++] = (2 << 5) | ATA_REG_LBAM
;
146 buf
[i
++] = tf
->hob_lbam
;
149 buf
[i
++] = (2 << 5) | ATA_REG_LBAH
;
150 buf
[i
++] = tf
->hob_lbah
;
157 #endif /* __SATA_PROMISE_H__ */