diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-10 11:22:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-10 11:22:33 -0500 |
commit | 1542dec1c9109fdcd1c53460f064096f24fc49d2 (patch) | |
tree | 6b100234ff75d462817b948772f5f62aebcf0503 /drivers/ata | |
parent | facc7a96d443d84060a8679c3fcc51d20d4981c3 (diff) | |
parent | 2ad2c320a107aceeba984f97ab2a60064101f5d5 (diff) |
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev:
pata_platform: Remove CONFIG_HAVE_PATA_PLATFORM's dependencies.
pata_hpt37x: actually limit HPT370 to UltraDMA/66
pata_hpt3x2n: coding style cleanup
pata_hpt37x: coding style cleanup
pata_hpt366: coding style cleanup
pata_hpt3x2n: calculate average f_CNT
pata_hpt3x2n: clarify about HPT371N support
pata_hpt{37x|3x2n}: SATA mode filtering
[libata] avoid needlessly passing around ptr to SCSI completion func
[libata] new driver acard_ahci, for ATP8620 host controller
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/Kconfig | 28 | ||||
-rw-r--r-- | drivers/ata/Makefile | 1 | ||||
-rw-r--r-- | drivers/ata/acard-ahci.c | 528 | ||||
-rw-r--r-- | drivers/ata/ahci.h | 3 | ||||
-rw-r--r-- | drivers/ata/libahci.c | 11 | ||||
-rw-r--r-- | drivers/ata/libata-scsi.c | 60 | ||||
-rw-r--r-- | drivers/ata/pata_hpt366.c | 51 | ||||
-rw-r--r-- | drivers/ata/pata_hpt37x.c | 236 | ||||
-rw-r--r-- | drivers/ata/pata_hpt3x2n.c | 150 |
9 files changed, 856 insertions, 212 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 36e2319264bd..c6b298d4c136 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -2,6 +2,14 @@ | |||
2 | # SATA/PATA driver configuration | 2 | # SATA/PATA driver configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | config HAVE_PATA_PLATFORM | ||
6 | bool | ||
7 | help | ||
8 | This is an internal configuration node for any machine that | ||
9 | uses pata-platform driver to enable the relevant driver in the | ||
10 | configuration structure without having to submit endless patches | ||
11 | to update the PATA_PLATFORM entry. | ||
12 | |||
5 | menuconfig ATA | 13 | menuconfig ATA |
6 | tristate "Serial ATA and Parallel ATA drivers" | 14 | tristate "Serial ATA and Parallel ATA drivers" |
7 | depends on HAS_IOMEM | 15 | depends on HAS_IOMEM |
@@ -90,6 +98,14 @@ config SATA_INIC162X | |||
90 | help | 98 | help |
91 | This option enables support for Initio 162x Serial ATA. | 99 | This option enables support for Initio 162x Serial ATA. |
92 | 100 | ||
101 | config SATA_ACARD_AHCI | ||
102 | tristate "ACard AHCI variant (ATP 8620)" | ||
103 | depends on PCI | ||
104 | help | ||
105 | This option enables support for Acard. | ||
106 | |||
107 | If unsure, say N. | ||
108 | |||
93 | config SATA_SIL24 | 109 | config SATA_SIL24 |
94 | tristate "Silicon Image 3124/3132 SATA support" | 110 | tristate "Silicon Image 3124/3132 SATA support" |
95 | depends on PCI | 111 | depends on PCI |
@@ -400,11 +416,11 @@ config PATA_HPT37X | |||
400 | If unsure, say N. | 416 | If unsure, say N. |
401 | 417 | ||
402 | config PATA_HPT3X2N | 418 | config PATA_HPT3X2N |
403 | tristate "HPT 372N/302N PATA support" | 419 | tristate "HPT 371N/372N/302N PATA support" |
404 | depends on PCI | 420 | depends on PCI |
405 | help | 421 | help |
406 | This option enables support for the N variant HPT PATA | 422 | This option enables support for the N variant HPT PATA |
407 | controllers via the new ATA layer | 423 | controllers via the new ATA layer. |
408 | 424 | ||
409 | If unsure, say N. | 425 | If unsure, say N. |
410 | 426 | ||
@@ -765,14 +781,6 @@ config PATA_PCMCIA | |||
765 | 781 | ||
766 | If unsure, say N. | 782 | If unsure, say N. |
767 | 783 | ||
768 | config HAVE_PATA_PLATFORM | ||
769 | bool | ||
770 | help | ||
771 | This is an internal configuration node for any machine that | ||
772 | uses pata-platform driver to enable the relevant driver in the | ||
773 | configuration structure without having to submit endless patches | ||
774 | to update the PATA_PLATFORM entry. | ||
775 | |||
776 | config PATA_PLATFORM | 784 | config PATA_PLATFORM |
777 | tristate "Generic platform device PATA support" | 785 | tristate "Generic platform device PATA support" |
778 | depends on EMBEDDED || PPC || HAVE_PATA_PLATFORM | 786 | depends on EMBEDDED || PPC || HAVE_PATA_PLATFORM |
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index 2b67c900a459..27291aad6ca7 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile | |||
@@ -3,6 +3,7 @@ obj-$(CONFIG_ATA) += libata.o | |||
3 | 3 | ||
4 | # non-SFF interface | 4 | # non-SFF interface |
5 | obj-$(CONFIG_SATA_AHCI) += ahci.o libahci.o | 5 | obj-$(CONFIG_SATA_AHCI) += ahci.o libahci.o |
6 | obj-$(CONFIG_SATA_ACARD_AHCI) += acard-ahci.o libahci.o | ||
6 | obj-$(CONFIG_SATA_AHCI_PLATFORM) += ahci_platform.o libahci.o | 7 | obj-$(CONFIG_SATA_AHCI_PLATFORM) += ahci_platform.o libahci.o |
7 | obj-$(CONFIG_SATA_FSL) += sata_fsl.o | 8 | obj-$(CONFIG_SATA_FSL) += sata_fsl.o |
8 | obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o | 9 | obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o |
diff --git a/drivers/ata/acard-ahci.c b/drivers/ata/acard-ahci.c new file mode 100644 index 000000000000..339c210f03a6 --- /dev/null +++ b/drivers/ata/acard-ahci.c | |||
@@ -0,0 +1,528 @@ | |||
1 | |||
2 | /* | ||
3 | * acard-ahci.c - ACard AHCI SATA support | ||
4 | * | ||
5 | * Maintained by: Jeff Garzik <jgarzik@pobox.com> | ||
6 | * Please ALWAYS copy linux-ide@vger.kernel.org | ||
7 | * on emails. | ||
8 | * | ||
9 | * Copyright 2010 Red Hat, Inc. | ||
10 | * | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2, or (at your option) | ||
15 | * any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; see the file COPYING. If not, write to | ||
24 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * | ||
27 | * libata documentation is available via 'make {ps|pdf}docs', | ||
28 | * as Documentation/DocBook/libata.* | ||
29 | * | ||
30 | * AHCI hardware documentation: | ||
31 | * http://www.intel.com/technology/serialata/pdf/rev1_0.pdf | ||
32 | * http://www.intel.com/technology/serialata/pdf/rev1_1.pdf | ||
33 | * | ||
34 | */ | ||
35 | |||
36 | #include <linux/kernel.h> | ||
37 | #include <linux/module.h> | ||
38 | #include <linux/pci.h> | ||
39 | #include <linux/init.h> | ||
40 | #include <linux/blkdev.h> | ||
41 | #include <linux/delay.h> | ||
42 | #include <linux/interrupt.h> | ||
43 | #include <linux/dma-mapping.h> | ||
44 | #include <linux/device.h> | ||
45 | #include <linux/dmi.h> | ||
46 | #include <linux/gfp.h> | ||
47 | #include <scsi/scsi_host.h> | ||
48 | #include <scsi/scsi_cmnd.h> | ||
49 | #include <linux/libata.h> | ||
50 | #include "ahci.h" | ||
51 | |||
52 | #define DRV_NAME "acard-ahci" | ||
53 | #define DRV_VERSION "1.0" | ||
54 | |||
55 | /* | ||
56 | Received FIS structure limited to 80h. | ||
57 | */ | ||
58 | |||
59 | #define ACARD_AHCI_RX_FIS_SZ 128 | ||
60 | |||
61 | enum { | ||
62 | AHCI_PCI_BAR = 5, | ||
63 | }; | ||
64 | |||
65 | enum board_ids { | ||
66 | board_acard_ahci, | ||
67 | }; | ||
68 | |||
69 | struct acard_sg { | ||
70 | __le32 addr; | ||
71 | __le32 addr_hi; | ||
72 | __le32 reserved; | ||
73 | __le32 size; /* bit 31 (EOT) max==0x10000 (64k) */ | ||
74 | }; | ||
75 | |||
76 | static void acard_ahci_qc_prep(struct ata_queued_cmd *qc); | ||
77 | static bool acard_ahci_qc_fill_rtf(struct ata_queued_cmd *qc); | ||
78 | static int acard_ahci_port_start(struct ata_port *ap); | ||
79 | static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | ||
80 | |||
81 | #ifdef CONFIG_PM | ||
82 | static int acard_ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); | ||
83 | static int acard_ahci_pci_device_resume(struct pci_dev *pdev); | ||
84 | #endif | ||
85 | |||
86 | static struct scsi_host_template acard_ahci_sht = { | ||
87 | AHCI_SHT("acard-ahci"), | ||
88 | }; | ||
89 | |||
90 | static struct ata_port_operations acard_ops = { | ||
91 | .inherits = &ahci_ops, | ||
92 | .qc_prep = acard_ahci_qc_prep, | ||
93 | .qc_fill_rtf = acard_ahci_qc_fill_rtf, | ||
94 | .port_start = acard_ahci_port_start, | ||
95 | }; | ||
96 | |||
97 | #define AHCI_HFLAGS(flags) .private_data = (void *)(flags) | ||
98 | |||
99 | static const struct ata_port_info acard_ahci_port_info[] = { | ||
100 | [board_acard_ahci] = | ||
101 | { | ||
102 | AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ), | ||
103 | .flags = AHCI_FLAG_COMMON, | ||
104 | .pio_mask = ATA_PIO4, | ||
105 | .udma_mask = ATA_UDMA6, | ||
106 | .port_ops = &acard_ops, | ||
107 | }, | ||
108 | }; | ||
109 | |||
110 | static const struct pci_device_id acard_ahci_pci_tbl[] = { | ||
111 | /* ACard */ | ||
112 | { PCI_VDEVICE(ARTOP, 0x000d), board_acard_ahci }, /* ATP8620 */ | ||
113 | |||
114 | { } /* terminate list */ | ||
115 | }; | ||
116 | |||
117 | static struct pci_driver acard_ahci_pci_driver = { | ||
118 | .name = DRV_NAME, | ||
119 | .id_table = acard_ahci_pci_tbl, | ||
120 | .probe = acard_ahci_init_one, | ||
121 | .remove = ata_pci_remove_one, | ||
122 | #ifdef CONFIG_PM | ||
123 | .suspend = acard_ahci_pci_device_suspend, | ||
124 | .resume = acard_ahci_pci_device_resume, | ||
125 | #endif | ||
126 | }; | ||
127 | |||
128 | #ifdef CONFIG_PM | ||
129 | static int acard_ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) | ||
130 | { | ||
131 | struct ata_host *host = dev_get_drvdata(&pdev->dev); | ||
132 | struct ahci_host_priv *hpriv = host->private_data; | ||
133 | void __iomem *mmio = hpriv->mmio; | ||
134 | u32 ctl; | ||
135 | |||
136 | if (mesg.event & PM_EVENT_SUSPEND && | ||
137 | hpriv->flags & AHCI_HFLAG_NO_SUSPEND) { | ||
138 | dev_printk(KERN_ERR, &pdev->dev, | ||
139 | "BIOS update required for suspend/resume\n"); | ||
140 | return -EIO; | ||
141 | } | ||
142 | |||
143 | if (mesg.event & PM_EVENT_SLEEP) { | ||
144 | /* AHCI spec rev1.1 section 8.3.3: | ||
145 | * Software must disable interrupts prior to requesting a | ||
146 | * transition of the HBA to D3 state. | ||
147 | */ | ||
148 | ctl = readl(mmio + HOST_CTL); | ||
149 | ctl &= ~HOST_IRQ_EN; | ||
150 | writel(ctl, mmio + HOST_CTL); | ||
151 | readl(mmio + HOST_CTL); /* flush */ | ||
152 | } | ||
153 | |||
154 | return ata_pci_device_suspend(pdev, mesg); | ||
155 | } | ||
156 | |||
157 | static int acard_ahci_pci_device_resume(struct pci_dev *pdev) | ||
158 | { | ||
159 | struct ata_host *host = dev_get_drvdata(&pdev->dev); | ||
160 | int rc; | ||
161 | |||
162 | rc = ata_pci_device_do_resume(pdev); | ||
163 | if (rc) | ||
164 | return rc; | ||
165 | |||
166 | if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { | ||
167 | rc = ahci_reset_controller(host); | ||
168 | if (rc) | ||
169 | return rc; | ||
170 | |||
171 | ahci_init_controller(host); | ||
172 | } | ||
173 | |||
174 | ata_host_resume(host); | ||
175 | |||
176 | return 0; | ||
177 | } | ||
178 | #endif | ||
179 | |||
180 | static int acard_ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac) | ||
181 | { | ||
182 | int rc; | ||
183 | |||
184 | if (using_dac && | ||
185 | !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { | ||
186 | rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); | ||
187 | if (rc) { | ||
188 | rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); | ||
189 | if (rc) { | ||
190 | dev_printk(KERN_ERR, &pdev->dev, | ||
191 | "64-bit DMA enable failed\n"); | ||
192 | return rc; | ||
193 | } | ||
194 | } | ||
195 | } else { | ||
196 | rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); | ||
197 | if (rc) { | ||
198 | dev_printk(KERN_ERR, &pdev->dev, | ||
199 | "32-bit DMA enable failed\n"); | ||
200 | return rc; | ||
201 | } | ||
202 | rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); | ||
203 | if (rc) { | ||
204 | dev_printk(KERN_ERR, &pdev->dev, | ||
205 | "32-bit consistent DMA enable failed\n"); | ||
206 | return rc; | ||
207 | } | ||
208 | } | ||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | static void acard_ahci_pci_print_info(struct ata_host *host) | ||
213 | { | ||
214 | struct pci_dev *pdev = to_pci_dev(host->dev); | ||
215 | u16 cc; | ||
216 | const char *scc_s; | ||
217 | |||
218 | pci_read_config_word(pdev, 0x0a, &cc); | ||
219 | if (cc == PCI_CLASS_STORAGE_IDE) | ||
220 | scc_s = "IDE"; | ||
221 | else if (cc == PCI_CLASS_STORAGE_SATA) | ||
222 | scc_s = "SATA"; | ||
223 | else if (cc == PCI_CLASS_STORAGE_RAID) | ||
224 | scc_s = "RAID"; | ||
225 | else | ||
226 | scc_s = "unknown"; | ||
227 | |||
228 | ahci_print_info(host, scc_s); | ||
229 | } | ||
230 | |||
231 | static unsigned int acard_ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl) | ||
232 | { | ||
233 | struct scatterlist *sg; | ||
234 | struct acard_sg *acard_sg = cmd_tbl + AHCI_CMD_TBL_HDR_SZ; | ||
235 | unsigned int si, last_si = 0; | ||
236 | |||
237 | VPRINTK("ENTER\n"); | ||
238 | |||
239 | /* | ||
240 | * Next, the S/G list. | ||
241 | */ | ||
242 | for_each_sg(qc->sg, sg, qc->n_elem, si) { | ||
243 | dma_addr_t addr = sg_dma_address(sg); | ||
244 | u32 sg_len = sg_dma_len(sg); | ||
245 | |||
246 | /* | ||
247 | * ACard note: | ||
248 | * We must set an end-of-table (EOT) bit, | ||
249 | * and the segment cannot exceed 64k (0x10000) | ||
250 | */ | ||
251 | acard_sg[si].addr = cpu_to_le32(addr & 0xffffffff); | ||
252 | acard_sg[si].addr_hi = cpu_to_le32((addr >> 16) >> 16); | ||
253 | acard_sg[si].size = cpu_to_le32(sg_len); | ||
254 | last_si = si; | ||
255 | } | ||
256 | |||
257 | acard_sg[last_si].size |= cpu_to_le32(1 << 31); /* set EOT */ | ||
258 | |||
259 | return si; | ||
260 | } | ||
261 | |||
262 | static void acard_ahci_qc_prep(struct ata_queued_cmd *qc) | ||
263 | { | ||
264 | struct ata_port *ap = qc->ap; | ||
265 | struct ahci_port_priv *pp = ap->private_data; | ||
266 | int is_atapi = ata_is_atapi(qc->tf.protocol); | ||
267 | void *cmd_tbl; | ||
268 | u32 opts; | ||
269 | const u32 cmd_fis_len = 5; /* five dwords */ | ||
270 | unsigned int n_elem; | ||
271 | |||
272 | /* | ||
273 | * Fill in command table information. First, the header, | ||
274 | * a SATA Register - Host to Device command FIS. | ||
275 | */ | ||
276 | cmd_tbl = pp->cmd_tbl + qc->tag * AHCI_CMD_TBL_SZ; | ||
277 | |||
278 | ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, cmd_tbl); | ||
279 | if (is_atapi) { | ||
280 | memset(cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32); | ||
281 | memcpy(cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, qc->dev->cdb_len); | ||
282 | } | ||
283 | |||
284 | n_elem = 0; | ||
285 | if (qc->flags & ATA_QCFLAG_DMAMAP) | ||
286 | n_elem = acard_ahci_fill_sg(qc, cmd_tbl); | ||
287 | |||
288 | /* | ||
289 | * Fill in command slot information. | ||
290 | * | ||
291 | * ACard note: prd table length not filled in | ||
292 | */ | ||
293 | opts = cmd_fis_len | (qc->dev->link->pmp << 12); | ||
294 | if (qc->tf.flags & ATA_TFLAG_WRITE) | ||
295 | opts |= AHCI_CMD_WRITE; | ||
296 | if (is_atapi) | ||
297 | opts |= AHCI_CMD_ATAPI | AHCI_CMD_PREFETCH; | ||
298 | |||
299 | ahci_fill_cmd_slot(pp, qc->tag, opts); | ||
300 | } | ||
301 | |||
302 | static bool acard_ahci_qc_fill_rtf(struct ata_queued_cmd *qc) | ||
303 | { | ||
304 | struct ahci_port_priv *pp = qc->ap->private_data; | ||
305 | u8 *rx_fis = pp->rx_fis; | ||
306 | |||
307 | if (pp->fbs_enabled) | ||
308 | rx_fis += qc->dev->link->pmp * ACARD_AHCI_RX_FIS_SZ; | ||
309 | |||
310 | /* | ||
311 | * After a successful execution of an ATA PIO data-in command, | ||
312 | * the device doesn't send D2H Reg FIS to update the TF and | ||
313 | * the host should take TF and E_Status from the preceding PIO | ||
314 | * Setup FIS. | ||
315 | */ | ||
316 | if (qc->tf.protocol == ATA_PROT_PIO && qc->dma_dir == DMA_FROM_DEVICE && | ||
317 | !(qc->flags & ATA_QCFLAG_FAILED)) { | ||
318 | ata_tf_from_fis(rx_fis + RX_FIS_PIO_SETUP, &qc->result_tf); | ||
319 | qc->result_tf.command = (rx_fis + RX_FIS_PIO_SETUP)[15]; | ||
320 | } else | ||
321 | ata_tf_from_fis(rx_fis + RX_FIS_D2H_REG, &qc->result_tf); | ||
322 | |||
323 | return true; | ||
324 | } | ||
325 | |||
326 | static int acard_ahci_port_start(struct ata_port *ap) | ||
327 | { | ||
328 | struct ahci_host_priv *hpriv = ap->host->private_data; | ||
329 | struct device *dev = ap->host->dev; | ||
330 | struct ahci_port_priv *pp; | ||
331 | void *mem; | ||
332 | dma_addr_t mem_dma; | ||
333 | size_t dma_sz, rx_fis_sz; | ||
334 | |||
335 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); | ||
336 | if (!pp) | ||
337 | return -ENOMEM; | ||
338 | |||
339 | /* check FBS capability */ | ||
340 | if ((hpriv->cap & HOST_CAP_FBS) && sata_pmp_supported(ap)) { | ||
341 | void __iomem *port_mmio = ahci_port_base(ap); | ||
342 | u32 cmd = readl(port_mmio + PORT_CMD); | ||
343 | if (cmd & PORT_CMD_FBSCP) | ||
344 | pp->fbs_supported = true; | ||
345 | else if (hpriv->flags & AHCI_HFLAG_YES_FBS) { | ||
346 | dev_printk(KERN_INFO, dev, | ||
347 | "port %d can do FBS, forcing FBSCP\n", | ||
348 | ap->port_no); | ||
349 | pp->fbs_supported = true; | ||
350 | } else | ||
351 | dev_printk(KERN_WARNING, dev, | ||
352 | "port %d is not capable of FBS\n", | ||
353 | ap->port_no); | ||
354 | } | ||
355 | |||
356 | if (pp->fbs_supported) { | ||
357 | dma_sz = AHCI_PORT_PRIV_FBS_DMA_SZ; | ||
358 | rx_fis_sz = ACARD_AHCI_RX_FIS_SZ * 16; | ||
359 | } else { | ||
360 | dma_sz = AHCI_PORT_PRIV_DMA_SZ; | ||
361 | rx_fis_sz = ACARD_AHCI_RX_FIS_SZ; | ||
362 | } | ||
363 | |||
364 | mem = dmam_alloc_coherent(dev, dma_sz, &mem_dma, GFP_KERNEL); | ||
365 | if (!mem) | ||
366 | return -ENOMEM; | ||
367 | memset(mem, 0, dma_sz); | ||
368 | |||
369 | /* | ||
370 | * First item in chunk of DMA memory: 32-slot command table, | ||
371 | * 32 bytes each in size | ||
372 | */ | ||
373 | pp->cmd_slot = mem; | ||
374 | pp->cmd_slot_dma = mem_dma; | ||
375 | |||
376 | mem += AHCI_CMD_SLOT_SZ; | ||
377 | mem_dma += AHCI_CMD_SLOT_SZ; | ||
378 | |||
379 | /* | ||
380 | * Second item: Received-FIS area | ||
381 | */ | ||
382 | pp->rx_fis = mem; | ||
383 | pp->rx_fis_dma = mem_dma; | ||
384 | |||
385 | mem += rx_fis_sz; | ||
386 | mem_dma += rx_fis_sz; | ||
387 | |||
388 | /* | ||
389 | * Third item: data area for storing a single command | ||
390 | * and its scatter-gather table | ||
391 | */ | ||
392 | pp->cmd_tbl = mem; | ||
393 | pp->cmd_tbl_dma = mem_dma; | ||
394 | |||
395 | /* | ||
396 | * Save off initial list of interrupts to be enabled. | ||
397 | * This could be changed later | ||
398 | */ | ||
399 | pp->intr_mask = DEF_PORT_IRQ; | ||
400 | |||
401 | ap->private_data = pp; | ||
402 | |||
403 | /* engage engines, captain */ | ||
404 | return ahci_port_resume(ap); | ||
405 | } | ||
406 | |||
407 | static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | ||
408 | { | ||
409 | static int printed_version; | ||
410 | unsigned int board_id = ent->driver_data; | ||
411 | struct ata_port_info pi = acard_ahci_port_info[board_id]; | ||
412 | const struct ata_port_info *ppi[] = { &pi, NULL }; | ||
413 | struct device *dev = &pdev->dev; | ||
414 | struct ahci_host_priv *hpriv; | ||
415 | struct ata_host *host; | ||
416 | int n_ports, i, rc; | ||
417 | |||
418 | VPRINTK("ENTER\n"); | ||
419 | |||
420 | WARN_ON(ATA_MAX_QUEUE > AHCI_MAX_CMDS); | ||
421 | |||
422 | if (!printed_version++) | ||
423 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | ||
424 | |||
425 | /* acquire resources */ | ||
426 | rc = pcim_enable_device(pdev); | ||
427 | if (rc) | ||
428 | return rc; | ||
429 | |||
430 | /* AHCI controllers often implement SFF compatible interface. | ||
431 | * Grab all PCI BARs just in case. | ||
432 | */ | ||
433 | rc = pcim_iomap_regions_request_all(pdev, 1 << AHCI_PCI_BAR, DRV_NAME); | ||
434 | if (rc == -EBUSY) | ||
435 | pcim_pin_device(pdev); | ||
436 | if (rc) | ||
437 | return rc; | ||
438 | |||
439 | hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); | ||
440 | if (!hpriv) | ||
441 | return -ENOMEM; | ||
442 | hpriv->flags |= (unsigned long)pi.private_data; | ||
443 | |||
444 | if (!(hpriv->flags & AHCI_HFLAG_NO_MSI)) | ||
445 | pci_enable_msi(pdev); | ||
446 | |||
447 | hpriv->mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; | ||
448 | |||
449 | /* save initial config */ | ||
450 | ahci_save_initial_config(&pdev->dev, hpriv, 0, 0); | ||
451 | |||
452 | /* prepare host */ | ||
453 | if (hpriv->cap & HOST_CAP_NCQ) | ||
454 | pi.flags |= ATA_FLAG_NCQ; | ||
455 | |||
456 | if (hpriv->cap & HOST_CAP_PMP) | ||
457 | pi.flags |= ATA_FLAG_PMP; | ||
458 | |||
459 | ahci_set_em_messages(hpriv, &pi); | ||
460 | |||
461 | /* CAP.NP sometimes indicate the index of the last enabled | ||
462 | * port, at other times, that of the last possible port, so | ||
463 | * determining the maximum port number requires looking at | ||
464 | * both CAP.NP and port_map. | ||
465 | */ | ||
466 | n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map)); | ||
467 | |||
468 | host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); | ||
469 | if (!host) | ||
470 | return -ENOMEM; | ||
471 | host->private_data = hpriv; | ||
472 | |||
473 | if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss) | ||
474 | host->flags |= ATA_HOST_PARALLEL_SCAN; | ||
475 | else | ||
476 | printk(KERN_INFO "ahci: SSS flag set, parallel bus scan disabled\n"); | ||
477 | |||
478 | for (i = 0; i < host->n_ports; i++) { | ||
479 | struct ata_port *ap = host->ports[i]; | ||
480 | |||
481 | ata_port_pbar_desc(ap, AHCI_PCI_BAR, -1, "abar"); | ||
482 | ata_port_pbar_desc(ap, AHCI_PCI_BAR, | ||
483 | 0x100 + ap->port_no * 0x80, "port"); | ||
484 | |||
485 | /* set initial link pm policy */ | ||
486 | /* | ||
487 | ap->pm_policy = NOT_AVAILABLE; | ||
488 | */ | ||
489 | /* disabled/not-implemented port */ | ||
490 | if (!(hpriv->port_map & (1 << i))) | ||
491 | ap->ops = &ata_dummy_port_ops; | ||
492 | } | ||
493 | |||
494 | /* initialize adapter */ | ||
495 | rc = acard_ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64); | ||
496 | if (rc) | ||
497 | return rc; | ||
498 | |||
499 | rc = ahci_reset_controller(host); | ||
500 | if (rc) | ||
501 | return rc; | ||
502 | |||
503 | ahci_init_controller(host); | ||
504 | acard_ahci_pci_print_info(host); | ||
505 | |||
506 | pci_set_master(pdev); | ||
507 | return ata_host_activate(host, pdev->irq, ahci_interrupt, IRQF_SHARED, | ||
508 | &acard_ahci_sht); | ||
509 | } | ||
510 | |||
511 | static int __init acard_ahci_init(void) | ||
512 | { | ||
513 | return pci_register_driver(&acard_ahci_pci_driver); | ||
514 | } | ||
515 | |||
516 | static void __exit acard_ahci_exit(void) | ||
517 | { | ||
518 | pci_unregister_driver(&acard_ahci_pci_driver); | ||
519 | } | ||
520 | |||
521 | MODULE_AUTHOR("Jeff Garzik"); | ||
522 | MODULE_DESCRIPTION("ACard AHCI SATA low-level driver"); | ||
523 | MODULE_LICENSE("GPL"); | ||
524 | MODULE_DEVICE_TABLE(pci, acard_ahci_pci_tbl); | ||
525 | MODULE_VERSION(DRV_VERSION); | ||
526 | |||
527 | module_init(acard_ahci_init); | ||
528 | module_exit(acard_ahci_exit); | ||
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h index 329cbbb91284..3e606c34f57b 100644 --- a/drivers/ata/ahci.h +++ b/drivers/ata/ahci.h | |||
@@ -311,6 +311,8 @@ extern struct device_attribute *ahci_sdev_attrs[]; | |||
311 | 311 | ||
312 | extern struct ata_port_operations ahci_ops; | 312 | extern struct ata_port_operations ahci_ops; |
313 | 313 | ||
314 | void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag, | ||
315 | u32 opts); | ||
314 | void ahci_save_initial_config(struct device *dev, | 316 | void ahci_save_initial_config(struct device *dev, |
315 | struct ahci_host_priv *hpriv, | 317 | struct ahci_host_priv *hpriv, |
316 | unsigned int force_port_map, | 318 | unsigned int force_port_map, |
@@ -326,6 +328,7 @@ int ahci_stop_engine(struct ata_port *ap); | |||
326 | void ahci_start_engine(struct ata_port *ap); | 328 | void ahci_start_engine(struct ata_port *ap); |
327 | int ahci_check_ready(struct ata_link *link); | 329 | int ahci_check_ready(struct ata_link *link); |
328 | int ahci_kick_engine(struct ata_port *ap); | 330 | int ahci_kick_engine(struct ata_port *ap); |
331 | int ahci_port_resume(struct ata_port *ap); | ||
329 | void ahci_set_em_messages(struct ahci_host_priv *hpriv, | 332 | void ahci_set_em_messages(struct ahci_host_priv *hpriv, |
330 | struct ata_port_info *pi); | 333 | struct ata_port_info *pi); |
331 | int ahci_reset_em(struct ata_host *host); | 334 | int ahci_reset_em(struct ata_host *host); |
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index ebc08d65b3dd..26d452339e98 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c | |||
@@ -87,10 +87,7 @@ static int ahci_hardreset(struct ata_link *link, unsigned int *class, | |||
87 | static void ahci_postreset(struct ata_link *link, unsigned int *class); | 87 | static void ahci_postreset(struct ata_link *link, unsigned int *class); |
88 | static void ahci_error_handler(struct ata_port *ap); | 88 | static void ahci_error_handler(struct ata_port *ap); |
89 | static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); | 89 | static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); |
90 | static int ahci_port_resume(struct ata_port *ap); | ||
91 | static void ahci_dev_config(struct ata_device *dev); | 90 | static void ahci_dev_config(struct ata_device *dev); |
92 | static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag, | ||
93 | u32 opts); | ||
94 | #ifdef CONFIG_PM | 91 | #ifdef CONFIG_PM |
95 | static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg); | 92 | static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg); |
96 | #endif | 93 | #endif |
@@ -1133,8 +1130,8 @@ static unsigned int ahci_dev_classify(struct ata_port *ap) | |||
1133 | return ata_dev_classify(&tf); | 1130 | return ata_dev_classify(&tf); |
1134 | } | 1131 | } |
1135 | 1132 | ||
1136 | static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag, | 1133 | void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag, |
1137 | u32 opts) | 1134 | u32 opts) |
1138 | { | 1135 | { |
1139 | dma_addr_t cmd_tbl_dma; | 1136 | dma_addr_t cmd_tbl_dma; |
1140 | 1137 | ||
@@ -1145,6 +1142,7 @@ static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag, | |||
1145 | pp->cmd_slot[tag].tbl_addr = cpu_to_le32(cmd_tbl_dma & 0xffffffff); | 1142 | pp->cmd_slot[tag].tbl_addr = cpu_to_le32(cmd_tbl_dma & 0xffffffff); |
1146 | pp->cmd_slot[tag].tbl_addr_hi = cpu_to_le32((cmd_tbl_dma >> 16) >> 16); | 1143 | pp->cmd_slot[tag].tbl_addr_hi = cpu_to_le32((cmd_tbl_dma >> 16) >> 16); |
1147 | } | 1144 | } |
1145 | EXPORT_SYMBOL_GPL(ahci_fill_cmd_slot); | ||
1148 | 1146 | ||
1149 | int ahci_kick_engine(struct ata_port *ap) | 1147 | int ahci_kick_engine(struct ata_port *ap) |
1150 | { | 1148 | { |
@@ -1918,7 +1916,7 @@ static void ahci_pmp_detach(struct ata_port *ap) | |||
1918 | writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); | 1916 | writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); |
1919 | } | 1917 | } |
1920 | 1918 | ||
1921 | static int ahci_port_resume(struct ata_port *ap) | 1919 | int ahci_port_resume(struct ata_port *ap) |
1922 | { | 1920 | { |
1923 | ahci_power_up(ap); | 1921 | ahci_power_up(ap); |
1924 | ahci_start_port(ap); | 1922 | ahci_start_port(ap); |
@@ -1930,6 +1928,7 @@ static int ahci_port_resume(struct ata_port *ap) | |||
1930 | 1928 | ||
1931 | return 0; | 1929 | return 0; |
1932 | } | 1930 | } |
1931 | EXPORT_SYMBOL_GPL(ahci_port_resume); | ||
1933 | 1932 | ||
1934 | #ifdef CONFIG_PM | 1933 | #ifdef CONFIG_PM |
1935 | static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg) | 1934 | static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg) |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 66aa4bee80a6..5defc74973d7 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -346,12 +346,11 @@ struct device_attribute *ata_common_sdev_attrs[] = { | |||
346 | }; | 346 | }; |
347 | EXPORT_SYMBOL_GPL(ata_common_sdev_attrs); | 347 | EXPORT_SYMBOL_GPL(ata_common_sdev_attrs); |
348 | 348 | ||
349 | static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, | 349 | static void ata_scsi_invalid_field(struct scsi_cmnd *cmd) |
350 | void (*done)(struct scsi_cmnd *)) | ||
351 | { | 350 | { |
352 | ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x24, 0x0); | 351 | ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x24, 0x0); |
353 | /* "Invalid field in cbd" */ | 352 | /* "Invalid field in cbd" */ |
354 | done(cmd); | 353 | cmd->scsi_done(cmd); |
355 | } | 354 | } |
356 | 355 | ||
357 | /** | 356 | /** |
@@ -719,7 +718,6 @@ EXPORT_SYMBOL_GPL(ata_scsi_ioctl); | |||
719 | * ata_scsi_qc_new - acquire new ata_queued_cmd reference | 718 | * ata_scsi_qc_new - acquire new ata_queued_cmd reference |
720 | * @dev: ATA device to which the new command is attached | 719 | * @dev: ATA device to which the new command is attached |
721 | * @cmd: SCSI command that originated this ATA command | 720 | * @cmd: SCSI command that originated this ATA command |
722 | * @done: SCSI command completion function | ||
723 | * | 721 | * |
724 | * Obtain a reference to an unused ata_queued_cmd structure, | 722 | * Obtain a reference to an unused ata_queued_cmd structure, |
725 | * which is the basic libata structure representing a single | 723 | * which is the basic libata structure representing a single |
@@ -736,21 +734,20 @@ EXPORT_SYMBOL_GPL(ata_scsi_ioctl); | |||
736 | * Command allocated, or %NULL if none available. | 734 | * Command allocated, or %NULL if none available. |
737 | */ | 735 | */ |
738 | static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev, | 736 | static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev, |
739 | struct scsi_cmnd *cmd, | 737 | struct scsi_cmnd *cmd) |
740 | void (*done)(struct scsi_cmnd *)) | ||
741 | { | 738 | { |
742 | struct ata_queued_cmd *qc; | 739 | struct ata_queued_cmd *qc; |
743 | 740 | ||
744 | qc = ata_qc_new_init(dev); | 741 | qc = ata_qc_new_init(dev); |
745 | if (qc) { | 742 | if (qc) { |
746 | qc->scsicmd = cmd; | 743 | qc->scsicmd = cmd; |
747 | qc->scsidone = done; | 744 | qc->scsidone = cmd->scsi_done; |
748 | 745 | ||
749 | qc->sg = scsi_sglist(cmd); | 746 | qc->sg = scsi_sglist(cmd); |
750 | qc->n_elem = scsi_sg_count(cmd); | 747 | qc->n_elem = scsi_sg_count(cmd); |
751 | } else { | 748 | } else { |
752 | cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1); | 749 | cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1); |
753 | done(cmd); | 750 | cmd->scsi_done(cmd); |
754 | } | 751 | } |
755 | 752 | ||
756 | return qc; | 753 | return qc; |
@@ -1735,7 +1732,6 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) | |||
1735 | * ata_scsi_translate - Translate then issue SCSI command to ATA device | 1732 | * ata_scsi_translate - Translate then issue SCSI command to ATA device |
1736 | * @dev: ATA device to which the command is addressed | 1733 | * @dev: ATA device to which the command is addressed |
1737 | * @cmd: SCSI command to execute | 1734 | * @cmd: SCSI command to execute |
1738 | * @done: SCSI command completion function | ||
1739 | * @xlat_func: Actor which translates @cmd to an ATA taskfile | 1735 | * @xlat_func: Actor which translates @cmd to an ATA taskfile |
1740 | * | 1736 | * |
1741 | * Our ->queuecommand() function has decided that the SCSI | 1737 | * Our ->queuecommand() function has decided that the SCSI |
@@ -1759,7 +1755,6 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) | |||
1759 | * needs to be deferred. | 1755 | * needs to be deferred. |
1760 | */ | 1756 | */ |
1761 | static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, | 1757 | static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, |
1762 | void (*done)(struct scsi_cmnd *), | ||
1763 | ata_xlat_func_t xlat_func) | 1758 | ata_xlat_func_t xlat_func) |
1764 | { | 1759 | { |
1765 | struct ata_port *ap = dev->link->ap; | 1760 | struct ata_port *ap = dev->link->ap; |
@@ -1768,7 +1763,7 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, | |||
1768 | 1763 | ||
1769 | VPRINTK("ENTER\n"); | 1764 | VPRINTK("ENTER\n"); |
1770 | 1765 | ||
1771 | qc = ata_scsi_qc_new(dev, cmd, done); | 1766 | qc = ata_scsi_qc_new(dev, cmd); |
1772 | if (!qc) | 1767 | if (!qc) |
1773 | goto err_mem; | 1768 | goto err_mem; |
1774 | 1769 | ||
@@ -1804,14 +1799,14 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, | |||
1804 | 1799 | ||
1805 | early_finish: | 1800 | early_finish: |
1806 | ata_qc_free(qc); | 1801 | ata_qc_free(qc); |
1807 | qc->scsidone(cmd); | 1802 | cmd->scsi_done(cmd); |
1808 | DPRINTK("EXIT - early finish (good or error)\n"); | 1803 | DPRINTK("EXIT - early finish (good or error)\n"); |
1809 | return 0; | 1804 | return 0; |
1810 | 1805 | ||
1811 | err_did: | 1806 | err_did: |
1812 | ata_qc_free(qc); | 1807 | ata_qc_free(qc); |
1813 | cmd->result = (DID_ERROR << 16); | 1808 | cmd->result = (DID_ERROR << 16); |
1814 | qc->scsidone(cmd); | 1809 | cmd->scsi_done(cmd); |
1815 | err_mem: | 1810 | err_mem: |
1816 | DPRINTK("EXIT - internal\n"); | 1811 | DPRINTK("EXIT - internal\n"); |
1817 | return 0; | 1812 | return 0; |
@@ -3116,7 +3111,6 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap, | |||
3116 | } | 3111 | } |
3117 | 3112 | ||
3118 | static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, | 3113 | static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, |
3119 | void (*done)(struct scsi_cmnd *), | ||
3120 | struct ata_device *dev) | 3114 | struct ata_device *dev) |
3121 | { | 3115 | { |
3122 | u8 scsi_op = scmd->cmnd[0]; | 3116 | u8 scsi_op = scmd->cmnd[0]; |
@@ -3150,9 +3144,9 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, | |||
3150 | } | 3144 | } |
3151 | 3145 | ||
3152 | if (xlat_func) | 3146 | if (xlat_func) |
3153 | rc = ata_scsi_translate(dev, scmd, done, xlat_func); | 3147 | rc = ata_scsi_translate(dev, scmd, xlat_func); |
3154 | else | 3148 | else |
3155 | ata_scsi_simulate(dev, scmd, done); | 3149 | ata_scsi_simulate(dev, scmd); |
3156 | 3150 | ||
3157 | return rc; | 3151 | return rc; |
3158 | 3152 | ||
@@ -3160,7 +3154,7 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, | |||
3160 | DPRINTK("bad CDB len=%u, scsi_op=0x%02x, max=%u\n", | 3154 | DPRINTK("bad CDB len=%u, scsi_op=0x%02x, max=%u\n", |
3161 | scmd->cmd_len, scsi_op, dev->cdb_len); | 3155 | scmd->cmd_len, scsi_op, dev->cdb_len); |
3162 | scmd->result = DID_ERROR << 16; | 3156 | scmd->result = DID_ERROR << 16; |
3163 | done(scmd); | 3157 | scmd->scsi_done(scmd); |
3164 | return 0; | 3158 | return 0; |
3165 | } | 3159 | } |
3166 | 3160 | ||
@@ -3199,7 +3193,7 @@ int ata_scsi_queuecmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd) | |||
3199 | 3193 | ||
3200 | dev = ata_scsi_find_dev(ap, scsidev); | 3194 | dev = ata_scsi_find_dev(ap, scsidev); |
3201 | if (likely(dev)) | 3195 | if (likely(dev)) |
3202 | rc = __ata_scsi_queuecmd(cmd, cmd->scsi_done, dev); | 3196 | rc = __ata_scsi_queuecmd(cmd, dev); |
3203 | else { | 3197 | else { |
3204 | cmd->result = (DID_BAD_TARGET << 16); | 3198 | cmd->result = (DID_BAD_TARGET << 16); |
3205 | cmd->scsi_done(cmd); | 3199 | cmd->scsi_done(cmd); |
@@ -3214,7 +3208,6 @@ int ata_scsi_queuecmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd) | |||
3214 | * ata_scsi_simulate - simulate SCSI command on ATA device | 3208 | * ata_scsi_simulate - simulate SCSI command on ATA device |
3215 | * @dev: the target device | 3209 | * @dev: the target device |
3216 | * @cmd: SCSI command being sent to device. | 3210 | * @cmd: SCSI command being sent to device. |
3217 | * @done: SCSI command completion function. | ||
3218 | * | 3211 | * |
3219 | * Interprets and directly executes a select list of SCSI commands | 3212 | * Interprets and directly executes a select list of SCSI commands |
3220 | * that can be handled internally. | 3213 | * that can be handled internally. |
@@ -3223,8 +3216,7 @@ int ata_scsi_queuecmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd) | |||
3223 | * spin_lock_irqsave(host lock) | 3216 | * spin_lock_irqsave(host lock) |
3224 | */ | 3217 | */ |
3225 | 3218 | ||
3226 | void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, | 3219 | void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd) |
3227 | void (*done)(struct scsi_cmnd *)) | ||
3228 | { | 3220 | { |
3229 | struct ata_scsi_args args; | 3221 | struct ata_scsi_args args; |
3230 | const u8 *scsicmd = cmd->cmnd; | 3222 | const u8 *scsicmd = cmd->cmnd; |
@@ -3233,17 +3225,17 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, | |||
3233 | args.dev = dev; | 3225 | args.dev = dev; |
3234 | args.id = dev->id; | 3226 | args.id = dev->id; |
3235 | args.cmd = cmd; | 3227 | args.cmd = cmd; |
3236 | args.done = done; | 3228 | args.done = cmd->scsi_done; |
3237 | 3229 | ||
3238 | switch(scsicmd[0]) { | 3230 | switch(scsicmd[0]) { |
3239 | /* TODO: worth improving? */ | 3231 | /* TODO: worth improving? */ |
3240 | case FORMAT_UNIT: | 3232 | case FORMAT_UNIT: |
3241 | ata_scsi_invalid_field(cmd, done); | 3233 | ata_scsi_invalid_field(cmd); |
3242 | break; | 3234 | break; |
3243 | 3235 | ||
3244 | case INQUIRY: | 3236 | case INQUIRY: |
3245 | if (scsicmd[1] & 2) /* is CmdDt set? */ | 3237 | if (scsicmd[1] & 2) /* is CmdDt set? */ |
3246 | ata_scsi_invalid_field(cmd, done); | 3238 | ata_scsi_invalid_field(cmd); |
3247 | else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */ | 3239 | else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */ |
3248 | ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std); | 3240 | ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std); |
3249 | else switch (scsicmd[2]) { | 3241 | else switch (scsicmd[2]) { |
@@ -3269,7 +3261,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, | |||
3269 | ata_scsi_rbuf_fill(&args, ata_scsiop_inq_b2); | 3261 | ata_scsi_rbuf_fill(&args, ata_scsiop_inq_b2); |
3270 | break; | 3262 | break; |
3271 | default: | 3263 | default: |
3272 | ata_scsi_invalid_field(cmd, done); | 3264 | ata_scsi_invalid_field(cmd); |
3273 | break; | 3265 | break; |
3274 | } | 3266 | } |
3275 | break; | 3267 | break; |
@@ -3281,7 +3273,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, | |||
3281 | 3273 | ||
3282 | case MODE_SELECT: /* unconditionally return */ | 3274 | case MODE_SELECT: /* unconditionally return */ |
3283 | case MODE_SELECT_10: /* bad-field-in-cdb */ | 3275 | case MODE_SELECT_10: /* bad-field-in-cdb */ |
3284 | ata_scsi_invalid_field(cmd, done); | 3276 | ata_scsi_invalid_field(cmd); |
3285 | break; | 3277 | break; |
3286 | 3278 | ||
3287 | case READ_CAPACITY: | 3279 | case READ_CAPACITY: |
@@ -3292,7 +3284,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, | |||
3292 | if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16) | 3284 | if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16) |
3293 | ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); | 3285 | ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); |
3294 | else | 3286 | else |
3295 | ata_scsi_invalid_field(cmd, done); | 3287 | ata_scsi_invalid_field(cmd); |
3296 | break; | 3288 | break; |
3297 | 3289 | ||
3298 | case REPORT_LUNS: | 3290 | case REPORT_LUNS: |
@@ -3302,7 +3294,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, | |||
3302 | case REQUEST_SENSE: | 3294 | case REQUEST_SENSE: |
3303 | ata_scsi_set_sense(cmd, 0, 0, 0); | 3295 | ata_scsi_set_sense(cmd, 0, 0, 0); |
3304 | cmd->result = (DRIVER_SENSE << 24); | 3296 | cmd->result = (DRIVER_SENSE << 24); |
3305 | done(cmd); | 3297 | cmd->scsi_done(cmd); |
3306 | break; | 3298 | break; |
3307 | 3299 | ||
3308 | /* if we reach this, then writeback caching is disabled, | 3300 | /* if we reach this, then writeback caching is disabled, |
@@ -3324,14 +3316,14 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, | |||
3324 | if ((tmp8 == 0x4) && (!scsicmd[3]) && (!scsicmd[4])) | 3316 | if ((tmp8 == 0x4) && (!scsicmd[3]) && (!scsicmd[4])) |
3325 | ata_scsi_rbuf_fill(&args, ata_scsiop_noop); | 3317 | ata_scsi_rbuf_fill(&args, ata_scsiop_noop); |
3326 | else | 3318 | else |
3327 | ata_scsi_invalid_field(cmd, done); | 3319 | ata_scsi_invalid_field(cmd); |
3328 | break; | 3320 | break; |
3329 | 3321 | ||
3330 | /* all other commands */ | 3322 | /* all other commands */ |
3331 | default: | 3323 | default: |
3332 | ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x20, 0x0); | 3324 | ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x20, 0x0); |
3333 | /* "Invalid command operation code" */ | 3325 | /* "Invalid command operation code" */ |
3334 | done(cmd); | 3326 | cmd->scsi_done(cmd); |
3335 | break; | 3327 | break; |
3336 | } | 3328 | } |
3337 | } | 3329 | } |
@@ -3858,7 +3850,6 @@ EXPORT_SYMBOL_GPL(ata_sas_slave_configure); | |||
3858 | /** | 3850 | /** |
3859 | * ata_sas_queuecmd - Issue SCSI cdb to libata-managed device | 3851 | * ata_sas_queuecmd - Issue SCSI cdb to libata-managed device |
3860 | * @cmd: SCSI command to be sent | 3852 | * @cmd: SCSI command to be sent |
3861 | * @done: Completion function, called when command is complete | ||
3862 | * @ap: ATA port to which the command is being sent | 3853 | * @ap: ATA port to which the command is being sent |
3863 | * | 3854 | * |
3864 | * RETURNS: | 3855 | * RETURNS: |
@@ -3866,18 +3857,17 @@ EXPORT_SYMBOL_GPL(ata_sas_slave_configure); | |||
3866 | * 0 otherwise. | 3857 | * 0 otherwise. |
3867 | */ | 3858 | */ |
3868 | 3859 | ||
3869 | int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), | 3860 | int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap) |
3870 | struct ata_port *ap) | ||
3871 | { | 3861 | { |
3872 | int rc = 0; | 3862 | int rc = 0; |
3873 | 3863 | ||
3874 | ata_scsi_dump_cdb(ap, cmd); | 3864 | ata_scsi_dump_cdb(ap, cmd); |
3875 | 3865 | ||
3876 | if (likely(ata_dev_enabled(ap->link.device))) | 3866 | if (likely(ata_dev_enabled(ap->link.device))) |
3877 | rc = __ata_scsi_queuecmd(cmd, done, ap->link.device); | 3867 | rc = __ata_scsi_queuecmd(cmd, ap->link.device); |
3878 | else { | 3868 | else { |
3879 | cmd->result = (DID_BAD_TARGET << 16); | 3869 | cmd->result = (DID_BAD_TARGET << 16); |
3880 | done(cmd); | 3870 | cmd->scsi_done(cmd); |
3881 | } | 3871 | } |
3882 | return rc; | 3872 | return rc; |
3883 | } | 3873 | } |
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c index 7688868557b9..d7e57db36bc8 100644 --- a/drivers/ata/pata_hpt366.c +++ b/drivers/ata/pata_hpt366.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/libata.h> | 25 | #include <linux/libata.h> |
26 | 26 | ||
27 | #define DRV_NAME "pata_hpt366" | 27 | #define DRV_NAME "pata_hpt366" |
28 | #define DRV_VERSION "0.6.8" | 28 | #define DRV_VERSION "0.6.9" |
29 | 29 | ||
30 | struct hpt_clock { | 30 | struct hpt_clock { |
31 | u8 xfer_mode; | 31 | u8 xfer_mode; |
@@ -110,18 +110,23 @@ static const struct hpt_clock hpt366_25[] = { | |||
110 | { 0, 0x01208585 } | 110 | { 0, 0x01208585 } |
111 | }; | 111 | }; |
112 | 112 | ||
113 | static const char *bad_ata33[] = { | 113 | static const char * const bad_ata33[] = { |
114 | "Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3", "Maxtor 90845U3", "Maxtor 90650U2", | 114 | "Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3", |
115 | "Maxtor 91360D8", "Maxtor 91190D7", "Maxtor 91020D6", "Maxtor 90845D5", "Maxtor 90680D4", "Maxtor 90510D3", "Maxtor 90340D2", | 115 | "Maxtor 90845U3", "Maxtor 90650U2", |
116 | "Maxtor 91152D8", "Maxtor 91008D7", "Maxtor 90845D6", "Maxtor 90840D6", "Maxtor 90720D5", "Maxtor 90648D5", "Maxtor 90576D4", | 116 | "Maxtor 91360D8", "Maxtor 91190D7", "Maxtor 91020D6", "Maxtor 90845D5", |
117 | "Maxtor 90680D4", "Maxtor 90510D3", "Maxtor 90340D2", | ||
118 | "Maxtor 91152D8", "Maxtor 91008D7", "Maxtor 90845D6", "Maxtor 90840D6", | ||
119 | "Maxtor 90720D5", "Maxtor 90648D5", "Maxtor 90576D4", | ||
117 | "Maxtor 90510D4", | 120 | "Maxtor 90510D4", |
118 | "Maxtor 90432D3", "Maxtor 90288D2", "Maxtor 90256D2", | 121 | "Maxtor 90432D3", "Maxtor 90288D2", "Maxtor 90256D2", |
119 | "Maxtor 91000D8", "Maxtor 90910D8", "Maxtor 90875D7", "Maxtor 90840D7", "Maxtor 90750D6", "Maxtor 90625D5", "Maxtor 90500D4", | 122 | "Maxtor 91000D8", "Maxtor 90910D8", "Maxtor 90875D7", "Maxtor 90840D7", |
120 | "Maxtor 91728D8", "Maxtor 91512D7", "Maxtor 91303D6", "Maxtor 91080D5", "Maxtor 90845D4", "Maxtor 90680D4", "Maxtor 90648D3", "Maxtor 90432D2", | 123 | "Maxtor 90750D6", "Maxtor 90625D5", "Maxtor 90500D4", |
124 | "Maxtor 91728D8", "Maxtor 91512D7", "Maxtor 91303D6", "Maxtor 91080D5", | ||
125 | "Maxtor 90845D4", "Maxtor 90680D4", "Maxtor 90648D3", "Maxtor 90432D2", | ||
121 | NULL | 126 | NULL |
122 | }; | 127 | }; |
123 | 128 | ||
124 | static const char *bad_ata66_4[] = { | 129 | static const char * const bad_ata66_4[] = { |
125 | "IBM-DTLA-307075", | 130 | "IBM-DTLA-307075", |
126 | "IBM-DTLA-307060", | 131 | "IBM-DTLA-307060", |
127 | "IBM-DTLA-307045", | 132 | "IBM-DTLA-307045", |
@@ -140,12 +145,13 @@ static const char *bad_ata66_4[] = { | |||
140 | NULL | 145 | NULL |
141 | }; | 146 | }; |
142 | 147 | ||
143 | static const char *bad_ata66_3[] = { | 148 | static const char * const bad_ata66_3[] = { |
144 | "WDC AC310200R", | 149 | "WDC AC310200R", |
145 | NULL | 150 | NULL |
146 | }; | 151 | }; |
147 | 152 | ||
148 | static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, const char *list[]) | 153 | static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, |
154 | const char * const list[]) | ||
149 | { | 155 | { |
150 | unsigned char model_num[ATA_ID_PROD_LEN + 1]; | 156 | unsigned char model_num[ATA_ID_PROD_LEN + 1]; |
151 | int i = 0; | 157 | int i = 0; |
@@ -288,6 +294,7 @@ static struct ata_port_operations hpt366_port_ops = { | |||
288 | static void hpt36x_init_chipset(struct pci_dev *dev) | 294 | static void hpt36x_init_chipset(struct pci_dev *dev) |
289 | { | 295 | { |
290 | u8 drive_fast; | 296 | u8 drive_fast; |
297 | |||
291 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4)); | 298 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4)); |
292 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78); | 299 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78); |
293 | pci_write_config_byte(dev, PCI_MIN_GNT, 0x08); | 300 | pci_write_config_byte(dev, PCI_MIN_GNT, 0x08); |
@@ -349,16 +356,16 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
349 | 356 | ||
350 | /* PCI clocking determines the ATA timing values to use */ | 357 | /* PCI clocking determines the ATA timing values to use */ |
351 | /* info_hpt366 is safe against re-entry so we can scribble on it */ | 358 | /* info_hpt366 is safe against re-entry so we can scribble on it */ |
352 | switch((reg1 & 0x700) >> 8) { | 359 | switch ((reg1 & 0x700) >> 8) { |
353 | case 9: | 360 | case 9: |
354 | hpriv = &hpt366_40; | 361 | hpriv = &hpt366_40; |
355 | break; | 362 | break; |
356 | case 5: | 363 | case 5: |
357 | hpriv = &hpt366_25; | 364 | hpriv = &hpt366_25; |
358 | break; | 365 | break; |
359 | default: | 366 | default: |
360 | hpriv = &hpt366_33; | 367 | hpriv = &hpt366_33; |
361 | break; | 368 | break; |
362 | } | 369 | } |
363 | /* Now kick off ATA set up */ | 370 | /* Now kick off ATA set up */ |
364 | return ata_pci_bmdma_init_one(dev, ppi, &hpt36x_sht, hpriv, 0); | 371 | return ata_pci_bmdma_init_one(dev, ppi, &hpt36x_sht, hpriv, 0); |
@@ -385,9 +392,9 @@ static const struct pci_device_id hpt36x[] = { | |||
385 | }; | 392 | }; |
386 | 393 | ||
387 | static struct pci_driver hpt36x_pci_driver = { | 394 | static struct pci_driver hpt36x_pci_driver = { |
388 | .name = DRV_NAME, | 395 | .name = DRV_NAME, |
389 | .id_table = hpt36x, | 396 | .id_table = hpt36x, |
390 | .probe = hpt36x_init_one, | 397 | .probe = hpt36x_init_one, |
391 | .remove = ata_pci_remove_one, | 398 | .remove = ata_pci_remove_one, |
392 | #ifdef CONFIG_PM | 399 | #ifdef CONFIG_PM |
393 | .suspend = ata_pci_device_suspend, | 400 | .suspend = ata_pci_device_suspend, |
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index 9ae4c0830577..efdd18bc8663 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> | 8 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> |
9 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. | 9 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. |
10 | * Portions Copyright (C) 2003 Red Hat Inc | 10 | * Portions Copyright (C) 2003 Red Hat Inc |
11 | * Portions Copyright (C) 2005-2009 MontaVista Software, Inc. | 11 | * Portions Copyright (C) 2005-2010 MontaVista Software, Inc. |
12 | * | 12 | * |
13 | * TODO | 13 | * TODO |
14 | * Look into engine reset on timeout errors. Should not be required. | 14 | * Look into engine reset on timeout errors. Should not be required. |
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/libata.h> | 24 | #include <linux/libata.h> |
25 | 25 | ||
26 | #define DRV_NAME "pata_hpt37x" | 26 | #define DRV_NAME "pata_hpt37x" |
27 | #define DRV_VERSION "0.6.15" | 27 | #define DRV_VERSION "0.6.18" |
28 | 28 | ||
29 | struct hpt_clock { | 29 | struct hpt_clock { |
30 | u8 xfer_speed; | 30 | u8 xfer_speed; |
@@ -210,7 +210,7 @@ static u32 hpt37x_find_mode(struct ata_port *ap, int speed) | |||
210 | { | 210 | { |
211 | struct hpt_clock *clocks = ap->host->private_data; | 211 | struct hpt_clock *clocks = ap->host->private_data; |
212 | 212 | ||
213 | while(clocks->xfer_speed) { | 213 | while (clocks->xfer_speed) { |
214 | if (clocks->xfer_speed == speed) | 214 | if (clocks->xfer_speed == speed) |
215 | return clocks->timing; | 215 | return clocks->timing; |
216 | clocks++; | 216 | clocks++; |
@@ -219,7 +219,8 @@ static u32 hpt37x_find_mode(struct ata_port *ap, int speed) | |||
219 | return 0xffffffffU; /* silence compiler warning */ | 219 | return 0xffffffffU; /* silence compiler warning */ |
220 | } | 220 | } |
221 | 221 | ||
222 | static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, const char *list[]) | 222 | static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, |
223 | const char * const list[]) | ||
223 | { | 224 | { |
224 | unsigned char model_num[ATA_ID_PROD_LEN + 1]; | 225 | unsigned char model_num[ATA_ID_PROD_LEN + 1]; |
225 | int i = 0; | 226 | int i = 0; |
@@ -237,18 +238,23 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, cons | |||
237 | return 0; | 238 | return 0; |
238 | } | 239 | } |
239 | 240 | ||
240 | static const char *bad_ata33[] = { | 241 | static const char * const bad_ata33[] = { |
241 | "Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3", "Maxtor 90845U3", "Maxtor 90650U2", | 242 | "Maxtor 92720U8", "Maxtor 92040U6", "Maxtor 91360U4", "Maxtor 91020U3", |
242 | "Maxtor 91360D8", "Maxtor 91190D7", "Maxtor 91020D6", "Maxtor 90845D5", "Maxtor 90680D4", "Maxtor 90510D3", "Maxtor 90340D2", | 243 | "Maxtor 90845U3", "Maxtor 90650U2", |
243 | "Maxtor 91152D8", "Maxtor 91008D7", "Maxtor 90845D6", "Maxtor 90840D6", "Maxtor 90720D5", "Maxtor 90648D5", "Maxtor 90576D4", | 244 | "Maxtor 91360D8", "Maxtor 91190D7", "Maxtor 91020D6", "Maxtor 90845D5", |
245 | "Maxtor 90680D4", "Maxtor 90510D3", "Maxtor 90340D2", | ||
246 | "Maxtor 91152D8", "Maxtor 91008D7", "Maxtor 90845D6", "Maxtor 90840D6", | ||
247 | "Maxtor 90720D5", "Maxtor 90648D5", "Maxtor 90576D4", | ||
244 | "Maxtor 90510D4", | 248 | "Maxtor 90510D4", |
245 | "Maxtor 90432D3", "Maxtor 90288D2", "Maxtor 90256D2", | 249 | "Maxtor 90432D3", "Maxtor 90288D2", "Maxtor 90256D2", |
246 | "Maxtor 91000D8", "Maxtor 90910D8", "Maxtor 90875D7", "Maxtor 90840D7", "Maxtor 90750D6", "Maxtor 90625D5", "Maxtor 90500D4", | 250 | "Maxtor 91000D8", "Maxtor 90910D8", "Maxtor 90875D7", "Maxtor 90840D7", |
247 | "Maxtor 91728D8", "Maxtor 91512D7", "Maxtor 91303D6", "Maxtor 91080D5", "Maxtor 90845D4", "Maxtor 90680D4", "Maxtor 90648D3", "Maxtor 90432D2", | 251 | "Maxtor 90750D6", "Maxtor 90625D5", "Maxtor 90500D4", |
252 | "Maxtor 91728D8", "Maxtor 91512D7", "Maxtor 91303D6", "Maxtor 91080D5", | ||
253 | "Maxtor 90845D4", "Maxtor 90680D4", "Maxtor 90648D3", "Maxtor 90432D2", | ||
248 | NULL | 254 | NULL |
249 | }; | 255 | }; |
250 | 256 | ||
251 | static const char *bad_ata100_5[] = { | 257 | static const char * const bad_ata100_5[] = { |
252 | "IBM-DTLA-307075", | 258 | "IBM-DTLA-307075", |
253 | "IBM-DTLA-307060", | 259 | "IBM-DTLA-307060", |
254 | "IBM-DTLA-307045", | 260 | "IBM-DTLA-307045", |
@@ -302,6 +308,22 @@ static unsigned long hpt370a_filter(struct ata_device *adev, unsigned long mask) | |||
302 | } | 308 | } |
303 | 309 | ||
304 | /** | 310 | /** |
311 | * hpt372_filter - mode selection filter | ||
312 | * @adev: ATA device | ||
313 | * @mask: mode mask | ||
314 | * | ||
315 | * The Marvell bridge chips used on the HighPoint SATA cards do not seem | ||
316 | * to support the UltraDMA modes 1, 2, and 3 as well as any MWDMA modes... | ||
317 | */ | ||
318 | static unsigned long hpt372_filter(struct ata_device *adev, unsigned long mask) | ||
319 | { | ||
320 | if (ata_id_is_sata(adev->id)) | ||
321 | mask &= ~((0xE << ATA_SHIFT_UDMA) | ATA_MASK_MWDMA); | ||
322 | |||
323 | return mask; | ||
324 | } | ||
325 | |||
326 | /** | ||
305 | * hpt37x_cable_detect - Detect the cable type | 327 | * hpt37x_cable_detect - Detect the cable type |
306 | * @ap: ATA port to detect on | 328 | * @ap: ATA port to detect on |
307 | * | 329 | * |
@@ -373,6 +395,7 @@ static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline) | |||
373 | { 0x50, 1, 0x04, 0x04 }, | 395 | { 0x50, 1, 0x04, 0x04 }, |
374 | { 0x54, 1, 0x04, 0x04 } | 396 | { 0x54, 1, 0x04, 0x04 } |
375 | }; | 397 | }; |
398 | |||
376 | if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no])) | 399 | if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no])) |
377 | return -ENOENT; | 400 | return -ENOENT; |
378 | 401 | ||
@@ -586,11 +609,11 @@ static struct ata_port_operations hpt370a_port_ops = { | |||
586 | }; | 609 | }; |
587 | 610 | ||
588 | /* | 611 | /* |
589 | * Configuration for HPT372, HPT371, HPT302. Slightly different PIO | 612 | * Configuration for HPT371 and HPT302. Slightly different PIO and DMA |
590 | * and DMA mode setting functionality. | 613 | * mode setting functionality. |
591 | */ | 614 | */ |
592 | 615 | ||
593 | static struct ata_port_operations hpt372_port_ops = { | 616 | static struct ata_port_operations hpt302_port_ops = { |
594 | .inherits = &ata_bmdma_port_ops, | 617 | .inherits = &ata_bmdma_port_ops, |
595 | 618 | ||
596 | .bmdma_stop = hpt37x_bmdma_stop, | 619 | .bmdma_stop = hpt37x_bmdma_stop, |
@@ -602,7 +625,17 @@ static struct ata_port_operations hpt372_port_ops = { | |||
602 | }; | 625 | }; |
603 | 626 | ||
604 | /* | 627 | /* |
605 | * Configuration for HPT374. Mode setting works like 372 and friends | 628 | * Configuration for HPT372. Mode setting works like 371 and 302 |
629 | * but we have a mode filter. | ||
630 | */ | ||
631 | |||
632 | static struct ata_port_operations hpt372_port_ops = { | ||
633 | .inherits = &hpt302_port_ops, | ||
634 | .mode_filter = hpt372_filter, | ||
635 | }; | ||
636 | |||
637 | /* | ||
638 | * Configuration for HPT374. Mode setting and filtering works like 372 | ||
606 | * but we have a different cable detection procedure for function 1. | 639 | * but we have a different cable detection procedure for function 1. |
607 | */ | 640 | */ |
608 | 641 | ||
@@ -647,12 +680,12 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev) | |||
647 | u32 reg5c; | 680 | u32 reg5c; |
648 | int tries; | 681 | int tries; |
649 | 682 | ||
650 | for(tries = 0; tries < 0x5000; tries++) { | 683 | for (tries = 0; tries < 0x5000; tries++) { |
651 | udelay(50); | 684 | udelay(50); |
652 | pci_read_config_byte(dev, 0x5b, ®5b); | 685 | pci_read_config_byte(dev, 0x5b, ®5b); |
653 | if (reg5b & 0x80) { | 686 | if (reg5b & 0x80) { |
654 | /* See if it stays set */ | 687 | /* See if it stays set */ |
655 | for(tries = 0; tries < 0x1000; tries ++) { | 688 | for (tries = 0; tries < 0x1000; tries++) { |
656 | pci_read_config_byte(dev, 0x5b, ®5b); | 689 | pci_read_config_byte(dev, 0x5b, ®5b); |
657 | /* Failed ? */ | 690 | /* Failed ? */ |
658 | if ((reg5b & 0x80) == 0) | 691 | if ((reg5b & 0x80) == 0) |
@@ -660,7 +693,7 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev) | |||
660 | } | 693 | } |
661 | /* Turn off tuning, we have the DPLL set */ | 694 | /* Turn off tuning, we have the DPLL set */ |
662 | pci_read_config_dword(dev, 0x5c, ®5c); | 695 | pci_read_config_dword(dev, 0x5c, ®5c); |
663 | pci_write_config_dword(dev, 0x5c, reg5c & ~ 0x100); | 696 | pci_write_config_dword(dev, 0x5c, reg5c & ~0x100); |
664 | return 1; | 697 | return 1; |
665 | } | 698 | } |
666 | } | 699 | } |
@@ -672,6 +705,7 @@ static u32 hpt374_read_freq(struct pci_dev *pdev) | |||
672 | { | 705 | { |
673 | u32 freq; | 706 | u32 freq; |
674 | unsigned long io_base = pci_resource_start(pdev, 4); | 707 | unsigned long io_base = pci_resource_start(pdev, 4); |
708 | |||
675 | if (PCI_FUNC(pdev->devfn) & 1) { | 709 | if (PCI_FUNC(pdev->devfn) & 1) { |
676 | struct pci_dev *pdev_0; | 710 | struct pci_dev *pdev_0; |
677 | 711 | ||
@@ -737,23 +771,23 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
737 | .udma_mask = ATA_UDMA5, | 771 | .udma_mask = ATA_UDMA5, |
738 | .port_ops = &hpt370a_port_ops | 772 | .port_ops = &hpt370a_port_ops |
739 | }; | 773 | }; |
740 | /* HPT370 - UDMA100 */ | 774 | /* HPT370 - UDMA66 */ |
741 | static const struct ata_port_info info_hpt370_33 = { | 775 | static const struct ata_port_info info_hpt370_33 = { |
742 | .flags = ATA_FLAG_SLAVE_POSS, | 776 | .flags = ATA_FLAG_SLAVE_POSS, |
743 | .pio_mask = ATA_PIO4, | 777 | .pio_mask = ATA_PIO4, |
744 | .mwdma_mask = ATA_MWDMA2, | 778 | .mwdma_mask = ATA_MWDMA2, |
745 | .udma_mask = ATA_UDMA5, | 779 | .udma_mask = ATA_UDMA4, |
746 | .port_ops = &hpt370_port_ops | 780 | .port_ops = &hpt370_port_ops |
747 | }; | 781 | }; |
748 | /* HPT370A - UDMA100 */ | 782 | /* HPT370A - UDMA66 */ |
749 | static const struct ata_port_info info_hpt370a_33 = { | 783 | static const struct ata_port_info info_hpt370a_33 = { |
750 | .flags = ATA_FLAG_SLAVE_POSS, | 784 | .flags = ATA_FLAG_SLAVE_POSS, |
751 | .pio_mask = ATA_PIO4, | 785 | .pio_mask = ATA_PIO4, |
752 | .mwdma_mask = ATA_MWDMA2, | 786 | .mwdma_mask = ATA_MWDMA2, |
753 | .udma_mask = ATA_UDMA5, | 787 | .udma_mask = ATA_UDMA4, |
754 | .port_ops = &hpt370a_port_ops | 788 | .port_ops = &hpt370a_port_ops |
755 | }; | 789 | }; |
756 | /* HPT371, 372 and friends - UDMA133 */ | 790 | /* HPT372 - UDMA133 */ |
757 | static const struct ata_port_info info_hpt372 = { | 791 | static const struct ata_port_info info_hpt372 = { |
758 | .flags = ATA_FLAG_SLAVE_POSS, | 792 | .flags = ATA_FLAG_SLAVE_POSS, |
759 | .pio_mask = ATA_PIO4, | 793 | .pio_mask = ATA_PIO4, |
@@ -761,6 +795,14 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
761 | .udma_mask = ATA_UDMA6, | 795 | .udma_mask = ATA_UDMA6, |
762 | .port_ops = &hpt372_port_ops | 796 | .port_ops = &hpt372_port_ops |
763 | }; | 797 | }; |
798 | /* HPT371, 302 - UDMA133 */ | ||
799 | static const struct ata_port_info info_hpt302 = { | ||
800 | .flags = ATA_FLAG_SLAVE_POSS, | ||
801 | .pio_mask = ATA_PIO4, | ||
802 | .mwdma_mask = ATA_MWDMA2, | ||
803 | .udma_mask = ATA_UDMA6, | ||
804 | .port_ops = &hpt302_port_ops | ||
805 | }; | ||
764 | /* HPT374 - UDMA100, function 1 uses different prereset method */ | 806 | /* HPT374 - UDMA100, function 1 uses different prereset method */ |
765 | static const struct ata_port_info info_hpt374_fn0 = { | 807 | static const struct ata_port_info info_hpt374_fn0 = { |
766 | .flags = ATA_FLAG_SLAVE_POSS, | 808 | .flags = ATA_FLAG_SLAVE_POSS, |
@@ -805,64 +847,68 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
805 | if (rev == 6) | 847 | if (rev == 6) |
806 | return -ENODEV; | 848 | return -ENODEV; |
807 | 849 | ||
808 | switch(rev) { | 850 | switch (rev) { |
809 | case 3: | 851 | case 3: |
810 | ppi[0] = &info_hpt370; | 852 | ppi[0] = &info_hpt370; |
811 | chip_table = &hpt370; | 853 | chip_table = &hpt370; |
812 | prefer_dpll = 0; | 854 | prefer_dpll = 0; |
813 | break; | 855 | break; |
814 | case 4: | 856 | case 4: |
815 | ppi[0] = &info_hpt370a; | 857 | ppi[0] = &info_hpt370a; |
816 | chip_table = &hpt370a; | 858 | chip_table = &hpt370a; |
817 | prefer_dpll = 0; | 859 | prefer_dpll = 0; |
818 | break; | 860 | break; |
819 | case 5: | 861 | case 5: |
820 | ppi[0] = &info_hpt372; | 862 | ppi[0] = &info_hpt372; |
821 | chip_table = &hpt372; | 863 | chip_table = &hpt372; |
822 | break; | 864 | break; |
823 | default: | 865 | default: |
824 | printk(KERN_ERR "pata_hpt37x: Unknown HPT366 " | 866 | printk(KERN_ERR "pata_hpt37x: Unknown HPT366 subtype, " |
825 | "subtype, please report (%d).\n", rev); | 867 | "please report (%d).\n", rev); |
826 | return -ENODEV; | 868 | return -ENODEV; |
827 | } | 869 | } |
828 | } else { | 870 | } else { |
829 | switch(dev->device) { | 871 | switch (dev->device) { |
830 | case PCI_DEVICE_ID_TTI_HPT372: | 872 | case PCI_DEVICE_ID_TTI_HPT372: |
831 | /* 372N if rev >= 2*/ | 873 | /* 372N if rev >= 2 */ |
832 | if (rev >= 2) | 874 | if (rev >= 2) |
833 | return -ENODEV; | 875 | return -ENODEV; |
834 | ppi[0] = &info_hpt372; | 876 | ppi[0] = &info_hpt372; |
835 | chip_table = &hpt372a; | 877 | chip_table = &hpt372a; |
836 | break; | 878 | break; |
837 | case PCI_DEVICE_ID_TTI_HPT302: | 879 | case PCI_DEVICE_ID_TTI_HPT302: |
838 | /* 302N if rev > 1 */ | 880 | /* 302N if rev > 1 */ |
839 | if (rev > 1) | 881 | if (rev > 1) |
840 | return -ENODEV; | 882 | return -ENODEV; |
841 | ppi[0] = &info_hpt372; | 883 | ppi[0] = &info_hpt302; |
842 | /* Check this */ | 884 | /* Check this */ |
843 | chip_table = &hpt302; | 885 | chip_table = &hpt302; |
844 | break; | 886 | break; |
845 | case PCI_DEVICE_ID_TTI_HPT371: | 887 | case PCI_DEVICE_ID_TTI_HPT371: |
846 | if (rev > 1) | 888 | if (rev > 1) |
847 | return -ENODEV; | 889 | return -ENODEV; |
848 | ppi[0] = &info_hpt372; | 890 | ppi[0] = &info_hpt302; |
849 | chip_table = &hpt371; | 891 | chip_table = &hpt371; |
850 | /* Single channel device, master is not present | 892 | /* |
851 | but the BIOS (or us for non x86) must mark it | 893 | * Single channel device, master is not present |
852 | absent */ | 894 | * but the BIOS (or us for non x86) must mark it |
853 | pci_read_config_byte(dev, 0x50, &mcr1); | 895 | * absent |
854 | mcr1 &= ~0x04; | 896 | */ |
855 | pci_write_config_byte(dev, 0x50, mcr1); | 897 | pci_read_config_byte(dev, 0x50, &mcr1); |
856 | break; | 898 | mcr1 &= ~0x04; |
857 | case PCI_DEVICE_ID_TTI_HPT374: | 899 | pci_write_config_byte(dev, 0x50, mcr1); |
858 | chip_table = &hpt374; | 900 | break; |
859 | if (!(PCI_FUNC(dev->devfn) & 1)) | 901 | case PCI_DEVICE_ID_TTI_HPT374: |
860 | *ppi = &info_hpt374_fn0; | 902 | chip_table = &hpt374; |
861 | else | 903 | if (!(PCI_FUNC(dev->devfn) & 1)) |
862 | *ppi = &info_hpt374_fn1; | 904 | *ppi = &info_hpt374_fn0; |
863 | break; | 905 | else |
864 | default: | 906 | *ppi = &info_hpt374_fn1; |
865 | printk(KERN_ERR "pata_hpt37x: PCI table is bogus please report (%d).\n", dev->device); | 907 | break; |
908 | default: | ||
909 | printk(KERN_ERR | ||
910 | "pata_hpt37x: PCI table is bogus, please report (%d).\n", | ||
911 | dev->device); | ||
866 | return -ENODEV; | 912 | return -ENODEV; |
867 | } | 913 | } |
868 | } | 914 | } |
@@ -893,9 +939,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
893 | if (chip_table == &hpt372a) | 939 | if (chip_table == &hpt372a) |
894 | outb(0x0e, iobase + 0x9c); | 940 | outb(0x0e, iobase + 0x9c); |
895 | 941 | ||
896 | /* Some devices do not let this value be accessed via PCI space | 942 | /* |
897 | according to the old driver. In addition we must use the value | 943 | * Some devices do not let this value be accessed via PCI space |
898 | from FN 0 on the HPT374 */ | 944 | * according to the old driver. In addition we must use the value |
945 | * from FN 0 on the HPT374. | ||
946 | */ | ||
899 | 947 | ||
900 | if (chip_table == &hpt374) { | 948 | if (chip_table == &hpt374) { |
901 | freq = hpt374_read_freq(dev); | 949 | freq = hpt374_read_freq(dev); |
@@ -909,10 +957,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
909 | u8 sr; | 957 | u8 sr; |
910 | u32 total = 0; | 958 | u32 total = 0; |
911 | 959 | ||
912 | printk(KERN_WARNING "pata_hpt37x: BIOS has not set timing clocks.\n"); | 960 | printk(KERN_WARNING |
961 | "pata_hpt37x: BIOS has not set timing clocks.\n"); | ||
913 | 962 | ||
914 | /* This is the process the HPT371 BIOS is reported to use */ | 963 | /* This is the process the HPT371 BIOS is reported to use */ |
915 | for(i = 0; i < 128; i++) { | 964 | for (i = 0; i < 128; i++) { |
916 | pci_read_config_byte(dev, 0x78, &sr); | 965 | pci_read_config_byte(dev, 0x78, &sr); |
917 | total += sr & 0x1FF; | 966 | total += sr & 0x1FF; |
918 | udelay(15); | 967 | udelay(15); |
@@ -947,17 +996,22 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
947 | 996 | ||
948 | /* Select the DPLL clock. */ | 997 | /* Select the DPLL clock. */ |
949 | pci_write_config_byte(dev, 0x5b, 0x21); | 998 | pci_write_config_byte(dev, 0x5b, 0x21); |
950 | pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low | 0x100); | 999 | pci_write_config_dword(dev, 0x5C, |
1000 | (f_high << 16) | f_low | 0x100); | ||
951 | 1001 | ||
952 | for(adjust = 0; adjust < 8; adjust++) { | 1002 | for (adjust = 0; adjust < 8; adjust++) { |
953 | if (hpt37x_calibrate_dpll(dev)) | 1003 | if (hpt37x_calibrate_dpll(dev)) |
954 | break; | 1004 | break; |
955 | /* See if it'll settle at a fractionally different clock */ | 1005 | /* |
1006 | * See if it'll settle at a fractionally | ||
1007 | * different clock | ||
1008 | */ | ||
956 | if (adjust & 1) | 1009 | if (adjust & 1) |
957 | f_low -= adjust >> 1; | 1010 | f_low -= adjust >> 1; |
958 | else | 1011 | else |
959 | f_high += adjust >> 1; | 1012 | f_high += adjust >> 1; |
960 | pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low | 0x100); | 1013 | pci_write_config_dword(dev, 0x5C, |
1014 | (f_high << 16) | f_low | 0x100); | ||
961 | } | 1015 | } |
962 | if (adjust == 8) { | 1016 | if (adjust == 8) { |
963 | printk(KERN_ERR "pata_hpt37x: DPLL did not stabilize!\n"); | 1017 | printk(KERN_ERR "pata_hpt37x: DPLL did not stabilize!\n"); |
@@ -976,7 +1030,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
976 | * Perform a final fixup. Note that we will have used the | 1030 | * Perform a final fixup. Note that we will have used the |
977 | * DPLL on the HPT372 which means we don't have to worry | 1031 | * DPLL on the HPT372 which means we don't have to worry |
978 | * about lack of UDMA133 support on lower clocks | 1032 | * about lack of UDMA133 support on lower clocks |
979 | */ | 1033 | */ |
980 | 1034 | ||
981 | if (clock_slot < 2 && ppi[0] == &info_hpt370) | 1035 | if (clock_slot < 2 && ppi[0] == &info_hpt370) |
982 | ppi[0] = &info_hpt370_33; | 1036 | ppi[0] = &info_hpt370_33; |
@@ -1001,9 +1055,9 @@ static const struct pci_device_id hpt37x[] = { | |||
1001 | }; | 1055 | }; |
1002 | 1056 | ||
1003 | static struct pci_driver hpt37x_pci_driver = { | 1057 | static struct pci_driver hpt37x_pci_driver = { |
1004 | .name = DRV_NAME, | 1058 | .name = DRV_NAME, |
1005 | .id_table = hpt37x, | 1059 | .id_table = hpt37x, |
1006 | .probe = hpt37x_init_one, | 1060 | .probe = hpt37x_init_one, |
1007 | .remove = ata_pci_remove_one | 1061 | .remove = ata_pci_remove_one |
1008 | }; | 1062 | }; |
1009 | 1063 | ||
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c index 32f3463216b8..d2239bbdb798 100644 --- a/drivers/ata/pata_hpt3x2n.c +++ b/drivers/ata/pata_hpt3x2n.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Libata driver for the highpoint 372N and 302N UDMA66 ATA controllers. | 2 | * Libata driver for the HighPoint 371N, 372N, and 302N UDMA66 ATA controllers. |
3 | * | 3 | * |
4 | * This driver is heavily based upon: | 4 | * This driver is heavily based upon: |
5 | * | 5 | * |
@@ -8,7 +8,7 @@ | |||
8 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> | 8 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> |
9 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. | 9 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. |
10 | * Portions Copyright (C) 2003 Red Hat Inc | 10 | * Portions Copyright (C) 2003 Red Hat Inc |
11 | * Portions Copyright (C) 2005-2009 MontaVista Software, Inc. | 11 | * Portions Copyright (C) 2005-2010 MontaVista Software, Inc. |
12 | * | 12 | * |
13 | * | 13 | * |
14 | * TODO | 14 | * TODO |
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/libata.h> | 25 | #include <linux/libata.h> |
26 | 26 | ||
27 | #define DRV_NAME "pata_hpt3x2n" | 27 | #define DRV_NAME "pata_hpt3x2n" |
28 | #define DRV_VERSION "0.3.10" | 28 | #define DRV_VERSION "0.3.13" |
29 | 29 | ||
30 | enum { | 30 | enum { |
31 | HPT_PCI_FAST = (1 << 31), | 31 | HPT_PCI_FAST = (1 << 31), |
@@ -103,7 +103,7 @@ static u32 hpt3x2n_find_mode(struct ata_port *ap, int speed) | |||
103 | { | 103 | { |
104 | struct hpt_clock *clocks = hpt3x2n_clocks; | 104 | struct hpt_clock *clocks = hpt3x2n_clocks; |
105 | 105 | ||
106 | while(clocks->xfer_speed) { | 106 | while (clocks->xfer_speed) { |
107 | if (clocks->xfer_speed == speed) | 107 | if (clocks->xfer_speed == speed) |
108 | return clocks->timing; | 108 | return clocks->timing; |
109 | clocks++; | 109 | clocks++; |
@@ -113,6 +113,22 @@ static u32 hpt3x2n_find_mode(struct ata_port *ap, int speed) | |||
113 | } | 113 | } |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * hpt372n_filter - mode selection filter | ||
117 | * @adev: ATA device | ||
118 | * @mask: mode mask | ||
119 | * | ||
120 | * The Marvell bridge chips used on the HighPoint SATA cards do not seem | ||
121 | * to support the UltraDMA modes 1, 2, and 3 as well as any MWDMA modes... | ||
122 | */ | ||
123 | static unsigned long hpt372n_filter(struct ata_device *adev, unsigned long mask) | ||
124 | { | ||
125 | if (ata_id_is_sata(adev->id)) | ||
126 | mask &= ~((0xE << ATA_SHIFT_UDMA) | ATA_MASK_MWDMA); | ||
127 | |||
128 | return mask; | ||
129 | } | ||
130 | |||
131 | /** | ||
116 | * hpt3x2n_cable_detect - Detect the cable type | 132 | * hpt3x2n_cable_detect - Detect the cable type |
117 | * @ap: ATA port to detect on | 133 | * @ap: ATA port to detect on |
118 | * | 134 | * |
@@ -153,6 +169,7 @@ static int hpt3x2n_pre_reset(struct ata_link *link, unsigned long deadline) | |||
153 | { | 169 | { |
154 | struct ata_port *ap = link->ap; | 170 | struct ata_port *ap = link->ap; |
155 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 171 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
172 | |||
156 | /* Reset the state machine */ | 173 | /* Reset the state machine */ |
157 | pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); | 174 | pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); |
158 | udelay(100); | 175 | udelay(100); |
@@ -328,10 +345,10 @@ static struct scsi_host_template hpt3x2n_sht = { | |||
328 | }; | 345 | }; |
329 | 346 | ||
330 | /* | 347 | /* |
331 | * Configuration for HPT3x2n. | 348 | * Configuration for HPT302N/371N. |
332 | */ | 349 | */ |
333 | 350 | ||
334 | static struct ata_port_operations hpt3x2n_port_ops = { | 351 | static struct ata_port_operations hpt3xxn_port_ops = { |
335 | .inherits = &ata_bmdma_port_ops, | 352 | .inherits = &ata_bmdma_port_ops, |
336 | 353 | ||
337 | .bmdma_stop = hpt3x2n_bmdma_stop, | 354 | .bmdma_stop = hpt3x2n_bmdma_stop, |
@@ -345,6 +362,15 @@ static struct ata_port_operations hpt3x2n_port_ops = { | |||
345 | .prereset = hpt3x2n_pre_reset, | 362 | .prereset = hpt3x2n_pre_reset, |
346 | }; | 363 | }; |
347 | 364 | ||
365 | /* | ||
366 | * Configuration for HPT372N. Same as 302N/371N but we have a mode filter. | ||
367 | */ | ||
368 | |||
369 | static struct ata_port_operations hpt372n_port_ops = { | ||
370 | .inherits = &hpt3xxn_port_ops, | ||
371 | .mode_filter = &hpt372n_filter, | ||
372 | }; | ||
373 | |||
348 | /** | 374 | /** |
349 | * hpt3xn_calibrate_dpll - Calibrate the DPLL loop | 375 | * hpt3xn_calibrate_dpll - Calibrate the DPLL loop |
350 | * @dev: PCI device | 376 | * @dev: PCI device |
@@ -359,12 +385,12 @@ static int hpt3xn_calibrate_dpll(struct pci_dev *dev) | |||
359 | u32 reg5c; | 385 | u32 reg5c; |
360 | int tries; | 386 | int tries; |
361 | 387 | ||
362 | for(tries = 0; tries < 0x5000; tries++) { | 388 | for (tries = 0; tries < 0x5000; tries++) { |
363 | udelay(50); | 389 | udelay(50); |
364 | pci_read_config_byte(dev, 0x5b, ®5b); | 390 | pci_read_config_byte(dev, 0x5b, ®5b); |
365 | if (reg5b & 0x80) { | 391 | if (reg5b & 0x80) { |
366 | /* See if it stays set */ | 392 | /* See if it stays set */ |
367 | for(tries = 0; tries < 0x1000; tries ++) { | 393 | for (tries = 0; tries < 0x1000; tries++) { |
368 | pci_read_config_byte(dev, 0x5b, ®5b); | 394 | pci_read_config_byte(dev, 0x5b, ®5b); |
369 | /* Failed ? */ | 395 | /* Failed ? */ |
370 | if ((reg5b & 0x80) == 0) | 396 | if ((reg5b & 0x80) == 0) |
@@ -372,7 +398,7 @@ static int hpt3xn_calibrate_dpll(struct pci_dev *dev) | |||
372 | } | 398 | } |
373 | /* Turn off tuning, we have the DPLL set */ | 399 | /* Turn off tuning, we have the DPLL set */ |
374 | pci_read_config_dword(dev, 0x5c, ®5c); | 400 | pci_read_config_dword(dev, 0x5c, ®5c); |
375 | pci_write_config_dword(dev, 0x5c, reg5c & ~ 0x100); | 401 | pci_write_config_dword(dev, 0x5c, reg5c & ~0x100); |
376 | return 1; | 402 | return 1; |
377 | } | 403 | } |
378 | } | 404 | } |
@@ -388,8 +414,19 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev) | |||
388 | 414 | ||
389 | fcnt = inl(iobase + 0x90); /* Not PCI readable for some chips */ | 415 | fcnt = inl(iobase + 0x90); /* Not PCI readable for some chips */ |
390 | if ((fcnt >> 12) != 0xABCDE) { | 416 | if ((fcnt >> 12) != 0xABCDE) { |
391 | printk(KERN_WARNING "hpt3xn: BIOS clock data not set.\n"); | 417 | int i; |
392 | return 33; /* Not BIOS set */ | 418 | u16 sr; |
419 | u32 total = 0; | ||
420 | |||
421 | printk(KERN_WARNING "pata_hpt3x2n: BIOS clock data not set.\n"); | ||
422 | |||
423 | /* This is the process the HPT371 BIOS is reported to use */ | ||
424 | for (i = 0; i < 128; i++) { | ||
425 | pci_read_config_word(pdev, 0x78, &sr); | ||
426 | total += sr & 0x1FF; | ||
427 | udelay(15); | ||
428 | } | ||
429 | fcnt = total / 128; | ||
393 | } | 430 | } |
394 | fcnt &= 0x1FF; | 431 | fcnt &= 0x1FF; |
395 | 432 | ||
@@ -431,21 +468,27 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev) | |||
431 | * HPT372N 9 (HPT372N) * UDMA133 | 468 | * HPT372N 9 (HPT372N) * UDMA133 |
432 | * | 469 | * |
433 | * (1) UDMA133 support depends on the bus clock | 470 | * (1) UDMA133 support depends on the bus clock |
434 | * | ||
435 | * To pin down HPT371N | ||
436 | */ | 471 | */ |
437 | 472 | ||
438 | static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 473 | static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
439 | { | 474 | { |
440 | /* HPT372N and friends - UDMA133 */ | 475 | /* HPT372N - UDMA133 */ |
441 | static const struct ata_port_info info = { | 476 | static const struct ata_port_info info_hpt372n = { |
477 | .flags = ATA_FLAG_SLAVE_POSS, | ||
478 | .pio_mask = ATA_PIO4, | ||
479 | .mwdma_mask = ATA_MWDMA2, | ||
480 | .udma_mask = ATA_UDMA6, | ||
481 | .port_ops = &hpt372n_port_ops | ||
482 | }; | ||
483 | /* HPT302N and HPT371N - UDMA133 */ | ||
484 | static const struct ata_port_info info_hpt3xxn = { | ||
442 | .flags = ATA_FLAG_SLAVE_POSS, | 485 | .flags = ATA_FLAG_SLAVE_POSS, |
443 | .pio_mask = ATA_PIO4, | 486 | .pio_mask = ATA_PIO4, |
444 | .mwdma_mask = ATA_MWDMA2, | 487 | .mwdma_mask = ATA_MWDMA2, |
445 | .udma_mask = ATA_UDMA6, | 488 | .udma_mask = ATA_UDMA6, |
446 | .port_ops = &hpt3x2n_port_ops | 489 | .port_ops = &hpt3xxn_port_ops |
447 | }; | 490 | }; |
448 | const struct ata_port_info *ppi[] = { &info, NULL }; | 491 | const struct ata_port_info *ppi[] = { &info_hpt3xxn, NULL }; |
449 | u8 rev = dev->revision; | 492 | u8 rev = dev->revision; |
450 | u8 irqmask; | 493 | u8 irqmask; |
451 | unsigned int pci_mhz; | 494 | unsigned int pci_mhz; |
@@ -459,30 +502,36 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
459 | if (rc) | 502 | if (rc) |
460 | return rc; | 503 | return rc; |
461 | 504 | ||
462 | switch(dev->device) { | 505 | switch (dev->device) { |
463 | case PCI_DEVICE_ID_TTI_HPT366: | 506 | case PCI_DEVICE_ID_TTI_HPT366: |
464 | if (rev < 6) | 507 | /* 372N if rev >= 6 */ |
465 | return -ENODEV; | 508 | if (rev < 6) |
466 | break; | ||
467 | case PCI_DEVICE_ID_TTI_HPT371: | ||
468 | if (rev < 2) | ||
469 | return -ENODEV; | ||
470 | /* 371N if rev > 1 */ | ||
471 | break; | ||
472 | case PCI_DEVICE_ID_TTI_HPT372: | ||
473 | /* 372N if rev >= 2*/ | ||
474 | if (rev < 2) | ||
475 | return -ENODEV; | ||
476 | break; | ||
477 | case PCI_DEVICE_ID_TTI_HPT302: | ||
478 | if (rev < 2) | ||
479 | return -ENODEV; | ||
480 | break; | ||
481 | case PCI_DEVICE_ID_TTI_HPT372N: | ||
482 | break; | ||
483 | default: | ||
484 | printk(KERN_ERR "pata_hpt3x2n: PCI table is bogus please report (%d).\n", dev->device); | ||
485 | return -ENODEV; | 509 | return -ENODEV; |
510 | goto hpt372n; | ||
511 | case PCI_DEVICE_ID_TTI_HPT371: | ||
512 | /* 371N if rev >= 2 */ | ||
513 | if (rev < 2) | ||
514 | return -ENODEV; | ||
515 | break; | ||
516 | case PCI_DEVICE_ID_TTI_HPT372: | ||
517 | /* 372N if rev >= 2 */ | ||
518 | if (rev < 2) | ||
519 | return -ENODEV; | ||
520 | goto hpt372n; | ||
521 | case PCI_DEVICE_ID_TTI_HPT302: | ||
522 | /* 302N if rev >= 2 */ | ||
523 | if (rev < 2) | ||
524 | return -ENODEV; | ||
525 | break; | ||
526 | case PCI_DEVICE_ID_TTI_HPT372N: | ||
527 | hpt372n: | ||
528 | ppi[0] = &info_hpt372n; | ||
529 | break; | ||
530 | default: | ||
531 | printk(KERN_ERR | ||
532 | "pata_hpt3x2n: PCI table is bogus please report (%d).\n", | ||
533 | dev->device); | ||
534 | return -ENODEV; | ||
486 | } | 535 | } |
487 | 536 | ||
488 | /* Ok so this is a chip we support */ | 537 | /* Ok so this is a chip we support */ |
@@ -509,8 +558,10 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
509 | pci_write_config_byte(dev, 0x50, mcr1); | 558 | pci_write_config_byte(dev, 0x50, mcr1); |
510 | } | 559 | } |
511 | 560 | ||
512 | /* Tune the PLL. HPT recommend using 75 for SATA, 66 for UDMA133 or | 561 | /* |
513 | 50 for UDMA100. Right now we always use 66 */ | 562 | * Tune the PLL. HPT recommend using 75 for SATA, 66 for UDMA133 or |
563 | * 50 for UDMA100. Right now we always use 66 | ||
564 | */ | ||
514 | 565 | ||
515 | pci_mhz = hpt3x2n_pci_clock(dev); | 566 | pci_mhz = hpt3x2n_pci_clock(dev); |
516 | 567 | ||
@@ -522,7 +573,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
522 | pci_write_config_byte(dev, 0x5B, 0x21); | 573 | pci_write_config_byte(dev, 0x5B, 0x21); |
523 | 574 | ||
524 | /* Unlike the 37x we don't try jiggling the frequency */ | 575 | /* Unlike the 37x we don't try jiggling the frequency */ |
525 | for(adjust = 0; adjust < 8; adjust++) { | 576 | for (adjust = 0; adjust < 8; adjust++) { |
526 | if (hpt3xn_calibrate_dpll(dev)) | 577 | if (hpt3xn_calibrate_dpll(dev)) |
527 | break; | 578 | break; |
528 | pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low); | 579 | pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low); |
@@ -534,8 +585,11 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
534 | 585 | ||
535 | printk(KERN_INFO "pata_hpt37x: bus clock %dMHz, using 66MHz DPLL.\n", | 586 | printk(KERN_INFO "pata_hpt37x: bus clock %dMHz, using 66MHz DPLL.\n", |
536 | pci_mhz); | 587 | pci_mhz); |
537 | /* Set our private data up. We only need a few flags so we use | 588 | |
538 | it directly */ | 589 | /* |
590 | * Set our private data up. We only need a few flags | ||
591 | * so we use it directly. | ||
592 | */ | ||
539 | if (pci_mhz > 60) | 593 | if (pci_mhz > 60) |
540 | hpriv = (void *)(PCI66 | USE_DPLL); | 594 | hpriv = (void *)(PCI66 | USE_DPLL); |
541 | 595 | ||
@@ -562,9 +616,9 @@ static const struct pci_device_id hpt3x2n[] = { | |||
562 | }; | 616 | }; |
563 | 617 | ||
564 | static struct pci_driver hpt3x2n_pci_driver = { | 618 | static struct pci_driver hpt3x2n_pci_driver = { |
565 | .name = DRV_NAME, | 619 | .name = DRV_NAME, |
566 | .id_table = hpt3x2n, | 620 | .id_table = hpt3x2n, |
567 | .probe = hpt3x2n_init_one, | 621 | .probe = hpt3x2n_init_one, |
568 | .remove = ata_pci_remove_one | 622 | .remove = ata_pci_remove_one |
569 | }; | 623 | }; |
570 | 624 | ||
@@ -579,7 +633,7 @@ static void __exit hpt3x2n_exit(void) | |||
579 | } | 633 | } |
580 | 634 | ||
581 | MODULE_AUTHOR("Alan Cox"); | 635 | MODULE_AUTHOR("Alan Cox"); |
582 | MODULE_DESCRIPTION("low-level driver for the Highpoint HPT3x2n/30x"); | 636 | MODULE_DESCRIPTION("low-level driver for the Highpoint HPT3xxN"); |
583 | MODULE_LICENSE("GPL"); | 637 | MODULE_LICENSE("GPL"); |
584 | MODULE_DEVICE_TABLE(pci, hpt3x2n); | 638 | MODULE_DEVICE_TABLE(pci, hpt3x2n); |
585 | MODULE_VERSION(DRV_VERSION); | 639 | MODULE_VERSION(DRV_VERSION); |