net: DCB: Validate DCB_ATTR_DCB_BUFFER argument
[linux/fpc-iii.git] / drivers / ata / sata_promise.h
blobc81db140aa251ebcc92a010e62a2abdfbd7900f4
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * sata_promise.h - Promise SATA common definitions and inline funcs
5 * Copyright 2003-2004 Red Hat, Inc.
7 * libata documentation is available via 'make {ps|pdf}docs',
8 * as Documentation/driver-api/libata.rst
9 */
11 #ifndef __SATA_PROMISE_H__
12 #define __SATA_PROMISE_H__
14 #include <linux/ata.h>
16 enum pdc_packet_bits {
17 PDC_PKT_READ = (1 << 2),
18 PDC_PKT_NODATA = (1 << 3),
20 PDC_PKT_SIZEMASK = (1 << 7) | (1 << 6) | (1 << 5),
21 PDC_PKT_CLEAR_BSY = (1 << 4),
22 PDC_PKT_WAIT_DRDY = (1 << 3) | (1 << 4),
23 PDC_LAST_REG = (1 << 3),
25 PDC_REG_DEVCTL = (1 << 3) | (1 << 2) | (1 << 1),
28 static inline unsigned int pdc_pkt_header(struct ata_taskfile *tf,
29 dma_addr_t sg_table,
30 unsigned int devno, u8 *buf)
32 u8 dev_reg;
33 __le32 *buf32 = (__le32 *) buf;
35 /* set control bits (byte 0), zero delay seq id (byte 3),
36 * and seq id (byte 2)
38 switch (tf->protocol) {
39 case ATA_PROT_DMA:
40 if (!(tf->flags & ATA_TFLAG_WRITE))
41 buf32[0] = cpu_to_le32(PDC_PKT_READ);
42 else
43 buf32[0] = 0;
44 break;
46 case ATA_PROT_NODATA:
47 buf32[0] = cpu_to_le32(PDC_PKT_NODATA);
48 break;
50 default:
51 BUG();
52 break;
55 buf32[1] = cpu_to_le32(sg_table); /* S/G table addr */
56 buf32[2] = 0; /* no next-packet */
58 if (devno == 0)
59 dev_reg = ATA_DEVICE_OBS;
60 else
61 dev_reg = ATA_DEVICE_OBS | ATA_DEV1;
63 /* select device */
64 buf[12] = (1 << 5) | PDC_PKT_CLEAR_BSY | ATA_REG_DEVICE;
65 buf[13] = dev_reg;
67 /* device control register */
68 buf[14] = (1 << 5) | PDC_REG_DEVCTL;
69 buf[15] = tf->ctl;
71 return 16; /* offset of next byte */
74 static inline unsigned int pdc_pkt_footer(struct ata_taskfile *tf, u8 *buf,
75 unsigned int i)
77 if (tf->flags & ATA_TFLAG_DEVICE) {
78 buf[i++] = (1 << 5) | ATA_REG_DEVICE;
79 buf[i++] = tf->device;
82 /* and finally the command itself; also includes end-of-pkt marker */
83 buf[i++] = (1 << 5) | PDC_LAST_REG | ATA_REG_CMD;
84 buf[i++] = tf->command;
86 return i;
89 static inline unsigned int pdc_prep_lba28(struct ata_taskfile *tf, u8 *buf, unsigned int i)
91 /* the "(1 << 5)" should be read "(count << 5)" */
93 /* ATA command block registers */
94 buf[i++] = (1 << 5) | ATA_REG_FEATURE;
95 buf[i++] = tf->feature;
97 buf[i++] = (1 << 5) | ATA_REG_NSECT;
98 buf[i++] = tf->nsect;
100 buf[i++] = (1 << 5) | ATA_REG_LBAL;
101 buf[i++] = tf->lbal;
103 buf[i++] = (1 << 5) | ATA_REG_LBAM;
104 buf[i++] = tf->lbam;
106 buf[i++] = (1 << 5) | ATA_REG_LBAH;
107 buf[i++] = tf->lbah;
109 return i;
112 static inline unsigned int pdc_prep_lba48(struct ata_taskfile *tf, u8 *buf, unsigned int i)
114 /* the "(2 << 5)" should be read "(count << 5)" */
116 /* ATA command block registers */
117 buf[i++] = (2 << 5) | ATA_REG_FEATURE;
118 buf[i++] = tf->hob_feature;
119 buf[i++] = tf->feature;
121 buf[i++] = (2 << 5) | ATA_REG_NSECT;
122 buf[i++] = tf->hob_nsect;
123 buf[i++] = tf->nsect;
125 buf[i++] = (2 << 5) | ATA_REG_LBAL;
126 buf[i++] = tf->hob_lbal;
127 buf[i++] = tf->lbal;
129 buf[i++] = (2 << 5) | ATA_REG_LBAM;
130 buf[i++] = tf->hob_lbam;
131 buf[i++] = tf->lbam;
133 buf[i++] = (2 << 5) | ATA_REG_LBAH;
134 buf[i++] = tf->hob_lbah;
135 buf[i++] = tf->lbah;
137 return i;
141 #endif /* __SATA_PROMISE_H__ */