diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/scsi/sata_promise.h |
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/scsi/sata_promise.h')
-rw-r--r-- | drivers/scsi/sata_promise.h | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/drivers/scsi/sata_promise.h b/drivers/scsi/sata_promise.h new file mode 100644 index 00000000000..6e7e96b9ee1 --- /dev/null +++ b/drivers/scsi/sata_promise.h | |||
@@ -0,0 +1,154 @@ | |||
1 | /* | ||
2 | * sata_promise.h - Promise SATA common definitions and inline funcs | ||
3 | * | ||
4 | * Copyright 2003-2004 Red Hat, Inc. | ||
5 | * | ||
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 | ||
9 | * by reference. | ||
10 | * | ||
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. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __SATA_PROMISE_H__ | ||
25 | #define __SATA_PROMISE_H__ | ||
26 | |||
27 | #include <linux/ata.h> | ||
28 | |||
29 | enum pdc_packet_bits { | ||
30 | PDC_PKT_READ = (1 << 2), | ||
31 | PDC_PKT_NODATA = (1 << 3), | ||
32 | |||
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), | ||
37 | |||
38 | PDC_REG_DEVCTL = (1 << 3) | (1 << 2) | (1 << 1), | ||
39 | }; | ||
40 | |||
41 | static inline unsigned int pdc_pkt_header(struct ata_taskfile *tf, | ||
42 | dma_addr_t sg_table, | ||
43 | unsigned int devno, u8 *buf) | ||
44 | { | ||
45 | u8 dev_reg; | ||
46 | u32 *buf32 = (u32 *) buf; | ||
47 | |||
48 | /* set control bits (byte 0), zero delay seq id (byte 3), | ||
49 | * and seq id (byte 2) | ||
50 | */ | ||
51 | switch (tf->protocol) { | ||
52 | case ATA_PROT_DMA: | ||
53 | if (!(tf->flags & ATA_TFLAG_WRITE)) | ||
54 | buf32[0] = cpu_to_le32(PDC_PKT_READ); | ||
55 | else | ||
56 | buf32[0] = 0; | ||
57 | break; | ||
58 | |||
59 | case ATA_PROT_NODATA: | ||
60 | buf32[0] = cpu_to_le32(PDC_PKT_NODATA); | ||
61 | break; | ||
62 | |||
63 | default: | ||
64 | BUG(); | ||
65 | break; | ||
66 | } | ||
67 | |||
68 | buf32[1] = cpu_to_le32(sg_table); /* S/G table addr */ | ||
69 | buf32[2] = 0; /* no next-packet */ | ||
70 | |||
71 | if (devno == 0) | ||
72 | dev_reg = ATA_DEVICE_OBS; | ||
73 | else | ||
74 | dev_reg = ATA_DEVICE_OBS | ATA_DEV1; | ||
75 | |||
76 | /* select device */ | ||
77 | buf[12] = (1 << 5) | PDC_PKT_CLEAR_BSY | ATA_REG_DEVICE; | ||
78 | buf[13] = dev_reg; | ||
79 | |||
80 | /* device control register */ | ||
81 | buf[14] = (1 << 5) | PDC_REG_DEVCTL; | ||
82 | buf[15] = tf->ctl; | ||
83 | |||
84 | return 16; /* offset of next byte */ | ||
85 | } | ||
86 | |||
87 | static inline unsigned int pdc_pkt_footer(struct ata_taskfile *tf, u8 *buf, | ||
88 | unsigned int i) | ||
89 | { | ||
90 | if (tf->flags & ATA_TFLAG_DEVICE) { | ||
91 | buf[i++] = (1 << 5) | ATA_REG_DEVICE; | ||
92 | buf[i++] = tf->device; | ||
93 | } | ||
94 | |||
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; | ||
98 | |||
99 | return i; | ||
100 | } | ||
101 | |||
102 | static inline unsigned int pdc_prep_lba28(struct ata_taskfile *tf, u8 *buf, unsigned int i) | ||
103 | { | ||
104 | /* the "(1 << 5)" should be read "(count << 5)" */ | ||
105 | |||
106 | /* ATA command block registers */ | ||
107 | buf[i++] = (1 << 5) | ATA_REG_FEATURE; | ||
108 | buf[i++] = tf->feature; | ||
109 | |||
110 | buf[i++] = (1 << 5) | ATA_REG_NSECT; | ||
111 | buf[i++] = tf->nsect; | ||
112 | |||
113 | buf[i++] = (1 << 5) | ATA_REG_LBAL; | ||
114 | buf[i++] = tf->lbal; | ||
115 | |||
116 | buf[i++] = (1 << 5) | ATA_REG_LBAM; | ||
117 | buf[i++] = tf->lbam; | ||
118 | |||
119 | buf[i++] = (1 << 5) | ATA_REG_LBAH; | ||
120 | buf[i++] = tf->lbah; | ||
121 | |||
122 | return i; | ||
123 | } | ||
124 | |||
125 | static inline unsigned int pdc_prep_lba48(struct ata_taskfile *tf, u8 *buf, unsigned int i) | ||
126 | { | ||
127 | /* the "(2 << 5)" should be read "(count << 5)" */ | ||
128 | |||
129 | /* ATA command block registers */ | ||
130 | buf[i++] = (2 << 5) | ATA_REG_FEATURE; | ||
131 | buf[i++] = tf->hob_feature; | ||
132 | buf[i++] = tf->feature; | ||
133 | |||
134 | buf[i++] = (2 << 5) | ATA_REG_NSECT; | ||
135 | buf[i++] = tf->hob_nsect; | ||
136 | buf[i++] = tf->nsect; | ||
137 | |||
138 | buf[i++] = (2 << 5) | ATA_REG_LBAL; | ||
139 | buf[i++] = tf->hob_lbal; | ||
140 | buf[i++] = tf->lbal; | ||
141 | |||
142 | buf[i++] = (2 << 5) | ATA_REG_LBAM; | ||
143 | buf[i++] = tf->hob_lbam; | ||
144 | buf[i++] = tf->lbam; | ||
145 | |||
146 | buf[i++] = (2 << 5) | ATA_REG_LBAH; | ||
147 | buf[i++] = tf->hob_lbah; | ||
148 | buf[i++] = tf->lbah; | ||
149 | |||
150 | return i; | ||
151 | } | ||
152 | |||
153 | |||
154 | #endif /* __SATA_PROMISE_H__ */ | ||