aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/Kconfig11
-rw-r--r--drivers/scsi/Makefile1
-rw-r--r--drivers/scsi/NCR5380.c9
-rw-r--r--drivers/scsi/NCR53c406a.c2
-rw-r--r--drivers/scsi/ahci.c104
-rw-r--r--drivers/scsi/ata_piix.c83
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c2
-rw-r--r--drivers/scsi/ibmvscsi/rpa_vscsi.c1
-rw-r--r--drivers/scsi/libata-core.c314
-rw-r--r--drivers/scsi/libata-scsi.c127
-rw-r--r--drivers/scsi/libata.h48
-rw-r--r--drivers/scsi/mesh.c6
-rw-r--r--drivers/scsi/sata_mv.c843
-rw-r--r--drivers/scsi/sata_nv.c71
-rw-r--r--drivers/scsi/sata_promise.c113
-rw-r--r--drivers/scsi/sata_promise.h31
-rw-r--r--drivers/scsi/sata_qstor.c53
-rw-r--r--drivers/scsi/sata_sil.c81
-rw-r--r--drivers/scsi/sata_sis.c35
-rw-r--r--drivers/scsi/sata_svw.c50
-rw-r--r--drivers/scsi/sata_sx4.c233
-rw-r--r--drivers/scsi/sata_uli.c39
-rw-r--r--drivers/scsi/sata_via.c64
-rw-r--r--drivers/scsi/sata_vsc.c36
24 files changed, 1834 insertions, 523 deletions
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index b3ae796eb624..2d21265e650b 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -256,7 +256,7 @@ config SCSI_DECNCR
256 256
257config SCSI_DECSII 257config SCSI_DECSII
258 tristate "DEC SII Scsi Driver" 258 tristate "DEC SII Scsi Driver"
259 depends on MACH_DECSTATION && SCSI && MIPS32 259 depends on MACH_DECSTATION && SCSI && 32BIT
260 260
261config BLK_DEV_3W_XXXX_RAID 261config BLK_DEV_3W_XXXX_RAID
262 tristate "3ware 5/6/7/8xxx ATA-RAID support" 262 tristate "3ware 5/6/7/8xxx ATA-RAID support"
@@ -465,6 +465,15 @@ config SCSI_ATA_PIIX
465 465
466 If unsure, say N. 466 If unsure, say N.
467 467
468config SCSI_SATA_MV
469 tristate "Marvell SATA support"
470 depends on SCSI_SATA && PCI && EXPERIMENTAL
471 help
472 This option enables support for the Marvell Serial ATA family.
473 Currently supports 88SX[56]0[48][01] chips.
474
475 If unsure, say N.
476
468config SCSI_SATA_NV 477config SCSI_SATA_NV
469 tristate "NVIDIA SATA support" 478 tristate "NVIDIA SATA support"
470 depends on SCSI_SATA && PCI && EXPERIMENTAL 479 depends on SCSI_SATA && PCI && EXPERIMENTAL
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 85f9e6bb34b9..4b4fd94c2674 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -134,6 +134,7 @@ obj-$(CONFIG_SCSI_SATA_SIS) += libata.o sata_sis.o
134obj-$(CONFIG_SCSI_SATA_SX4) += libata.o sata_sx4.o 134obj-$(CONFIG_SCSI_SATA_SX4) += libata.o sata_sx4.o
135obj-$(CONFIG_SCSI_SATA_NV) += libata.o sata_nv.o 135obj-$(CONFIG_SCSI_SATA_NV) += libata.o sata_nv.o
136obj-$(CONFIG_SCSI_SATA_ULI) += libata.o sata_uli.o 136obj-$(CONFIG_SCSI_SATA_ULI) += libata.o sata_uli.o
137obj-$(CONFIG_SCSI_SATA_MV) += libata.o sata_mv.o
137 138
138obj-$(CONFIG_ARM) += arm/ 139obj-$(CONFIG_ARM) += arm/
139 140
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index f8ec6fe7d858..d40ba0bd68a3 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -88,6 +88,13 @@
88 */ 88 */
89#include <scsi/scsi_dbg.h> 89#include <scsi/scsi_dbg.h>
90 90
91#ifndef NDEBUG
92#define NDEBUG 0
93#endif
94#ifndef NDEBUG
95#define NDEBUG_ABORT 0
96#endif
97
91#if (NDEBUG & NDEBUG_LISTS) 98#if (NDEBUG & NDEBUG_LISTS)
92#define LIST(x,y) {printk("LINE:%d Adding %p to %p\n", __LINE__, (void*)(x), (void*)(y)); if ((x)==(y)) udelay(5); } 99#define LIST(x,y) {printk("LINE:%d Adding %p to %p\n", __LINE__, (void*)(x), (void*)(y)); if ((x)==(y)) udelay(5); }
93#define REMOVE(w,x,y,z) {printk("LINE:%d Removing: %p->%p %p->%p \n", __LINE__, (void*)(w), (void*)(x), (void*)(y), (void*)(z)); if ((x)==(y)) udelay(5); } 100#define REMOVE(w,x,y,z) {printk("LINE:%d Removing: %p->%p %p->%p \n", __LINE__, (void*)(w), (void*)(x), (void*)(y), (void*)(z)); if ((x)==(y)) udelay(5); }
@@ -359,7 +366,7 @@ static struct {
359 {PHASE_UNKNOWN, "UNKNOWN"} 366 {PHASE_UNKNOWN, "UNKNOWN"}
360}; 367};
361 368
362#ifdef NDEBUG 369#if NDEBUG
363static struct { 370static struct {
364 unsigned char mask; 371 unsigned char mask;
365 const char *name; 372 const char *name;
diff --git a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c
index 79ae73b23680..e1f2246ee7cd 100644
--- a/drivers/scsi/NCR53c406a.c
+++ b/drivers/scsi/NCR53c406a.c
@@ -62,7 +62,7 @@
62 62
63#define SYNC_MODE 0 /* Synchronous transfer mode */ 63#define SYNC_MODE 0 /* Synchronous transfer mode */
64 64
65#if DEBUG 65#ifdef DEBUG
66#undef NCR53C406A_DEBUG 66#undef NCR53C406A_DEBUG
67#define NCR53C406A_DEBUG 1 67#define NCR53C406A_DEBUG 1
68#endif 68#endif
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index e3b9692b9688..320df6cd3def 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -1,26 +1,34 @@
1/* 1/*
2 * ahci.c - AHCI SATA support 2 * ahci.c - AHCI SATA support
3 * 3 *
4 * Copyright 2004 Red Hat, Inc. 4 * Maintained by: Jeff Garzik <jgarzik@pobox.com>
5 * Please ALWAYS copy linux-ide@vger.kernel.org
6 * on emails.
5 * 7 *
6 * The contents of this file are subject to the Open 8 * Copyright 2004-2005 Red Hat, Inc.
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 * 9 *
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 * 10 *
22 * Version 1.0 of the AHCI specification: 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; see the file COPYING. If not, write to
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 *
26 * libata documentation is available via 'make {ps|pdf}docs',
27 * as Documentation/DocBook/libata.*
28 *
29 * AHCI hardware documentation:
23 * http://www.intel.com/technology/serialata/pdf/rev1_0.pdf 30 * http://www.intel.com/technology/serialata/pdf/rev1_0.pdf
31 * http://www.intel.com/technology/serialata/pdf/rev1_1.pdf
24 * 32 *
25 */ 33 */
26 34
@@ -181,7 +189,6 @@ static void ahci_irq_clear(struct ata_port *ap);
181static void ahci_eng_timeout(struct ata_port *ap); 189static void ahci_eng_timeout(struct ata_port *ap);
182static int ahci_port_start(struct ata_port *ap); 190static int ahci_port_start(struct ata_port *ap);
183static void ahci_port_stop(struct ata_port *ap); 191static void ahci_port_stop(struct ata_port *ap);
184static void ahci_host_stop(struct ata_host_set *host_set);
185static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf); 192static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
186static void ahci_qc_prep(struct ata_queued_cmd *qc); 193static void ahci_qc_prep(struct ata_queued_cmd *qc);
187static u8 ahci_check_status(struct ata_port *ap); 194static u8 ahci_check_status(struct ata_port *ap);
@@ -234,7 +241,6 @@ static struct ata_port_operations ahci_ops = {
234 241
235 .port_start = ahci_port_start, 242 .port_start = ahci_port_start,
236 .port_stop = ahci_port_stop, 243 .port_stop = ahci_port_stop,
237 .host_stop = ahci_host_stop,
238}; 244};
239 245
240static struct ata_port_info ahci_port_info[] = { 246static struct ata_port_info ahci_port_info[] = {
@@ -244,7 +250,7 @@ static struct ata_port_info ahci_port_info[] = {
244 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 250 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
245 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO | 251 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
246 ATA_FLAG_PIO_DMA, 252 ATA_FLAG_PIO_DMA,
247 .pio_mask = 0x03, /* pio3-4 */ 253 .pio_mask = 0x1f, /* pio0-4 */
248 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 254 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
249 .port_ops = &ahci_ops, 255 .port_ops = &ahci_ops,
250 }, 256 },
@@ -269,6 +275,8 @@ static struct pci_device_id ahci_pci_tbl[] = {
269 board_ahci }, /* ESB2 */ 275 board_ahci }, /* ESB2 */
270 { PCI_VENDOR_ID_INTEL, 0x2683, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 276 { PCI_VENDOR_ID_INTEL, 0x2683, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
271 board_ahci }, /* ESB2 */ 277 board_ahci }, /* ESB2 */
278 { PCI_VENDOR_ID_INTEL, 0x27c6, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
279 board_ahci }, /* ICH7-M DH */
272 { } /* terminate list */ 280 { } /* terminate list */
273}; 281};
274 282
@@ -286,17 +294,9 @@ static inline unsigned long ahci_port_base_ul (unsigned long base, unsigned int
286 return base + 0x100 + (port * 0x80); 294 return base + 0x100 + (port * 0x80);
287} 295}
288 296
289static inline void *ahci_port_base (void *base, unsigned int port) 297static inline void __iomem *ahci_port_base (void __iomem *base, unsigned int port)
290{ 298{
291 return (void *) ahci_port_base_ul((unsigned long)base, port); 299 return (void __iomem *) ahci_port_base_ul((unsigned long)base, port);
292}
293
294static void ahci_host_stop(struct ata_host_set *host_set)
295{
296 struct ahci_host_priv *hpriv = host_set->private_data;
297 kfree(hpriv);
298
299 ata_host_stop(host_set);
300} 300}
301 301
302static int ahci_port_start(struct ata_port *ap) 302static int ahci_port_start(struct ata_port *ap)
@@ -304,8 +304,9 @@ static int ahci_port_start(struct ata_port *ap)
304 struct device *dev = ap->host_set->dev; 304 struct device *dev = ap->host_set->dev;
305 struct ahci_host_priv *hpriv = ap->host_set->private_data; 305 struct ahci_host_priv *hpriv = ap->host_set->private_data;
306 struct ahci_port_priv *pp; 306 struct ahci_port_priv *pp;
307 void *mem, *mmio = ap->host_set->mmio_base; 307 void __iomem *mmio = ap->host_set->mmio_base;
308 void *port_mmio = ahci_port_base(mmio, ap->port_no); 308 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
309 void *mem;
309 dma_addr_t mem_dma; 310 dma_addr_t mem_dma;
310 311
311 pp = kmalloc(sizeof(*pp), GFP_KERNEL); 312 pp = kmalloc(sizeof(*pp), GFP_KERNEL);
@@ -373,8 +374,8 @@ static void ahci_port_stop(struct ata_port *ap)
373{ 374{
374 struct device *dev = ap->host_set->dev; 375 struct device *dev = ap->host_set->dev;
375 struct ahci_port_priv *pp = ap->private_data; 376 struct ahci_port_priv *pp = ap->private_data;
376 void *mmio = ap->host_set->mmio_base; 377 void __iomem *mmio = ap->host_set->mmio_base;
377 void *port_mmio = ahci_port_base(mmio, ap->port_no); 378 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
378 u32 tmp; 379 u32 tmp;
379 380
380 tmp = readl(port_mmio + PORT_CMD); 381 tmp = readl(port_mmio + PORT_CMD);
@@ -536,8 +537,8 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
536 537
537static void ahci_intr_error(struct ata_port *ap, u32 irq_stat) 538static void ahci_intr_error(struct ata_port *ap, u32 irq_stat)
538{ 539{
539 void *mmio = ap->host_set->mmio_base; 540 void __iomem *mmio = ap->host_set->mmio_base;
540 void *port_mmio = ahci_port_base(mmio, ap->port_no); 541 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
541 u32 tmp; 542 u32 tmp;
542 int work; 543 int work;
543 544
@@ -584,12 +585,16 @@ static void ahci_intr_error(struct ata_port *ap, u32 irq_stat)
584 585
585static void ahci_eng_timeout(struct ata_port *ap) 586static void ahci_eng_timeout(struct ata_port *ap)
586{ 587{
587 void *mmio = ap->host_set->mmio_base; 588 struct ata_host_set *host_set = ap->host_set;
588 void *port_mmio = ahci_port_base(mmio, ap->port_no); 589 void __iomem *mmio = host_set->mmio_base;
590 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
589 struct ata_queued_cmd *qc; 591 struct ata_queued_cmd *qc;
592 unsigned long flags;
590 593
591 DPRINTK("ENTER\n"); 594 DPRINTK("ENTER\n");
592 595
596 spin_lock_irqsave(&host_set->lock, flags);
597
593 ahci_intr_error(ap, readl(port_mmio + PORT_IRQ_STAT)); 598 ahci_intr_error(ap, readl(port_mmio + PORT_IRQ_STAT));
594 599
595 qc = ata_qc_from_tag(ap, ap->active_tag); 600 qc = ata_qc_from_tag(ap, ap->active_tag);
@@ -607,12 +612,13 @@ static void ahci_eng_timeout(struct ata_port *ap)
607 ata_qc_complete(qc, ATA_ERR); 612 ata_qc_complete(qc, ATA_ERR);
608 } 613 }
609 614
615 spin_unlock_irqrestore(&host_set->lock, flags);
610} 616}
611 617
612static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) 618static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
613{ 619{
614 void *mmio = ap->host_set->mmio_base; 620 void __iomem *mmio = ap->host_set->mmio_base;
615 void *port_mmio = ahci_port_base(mmio, ap->port_no); 621 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
616 u32 status, serr, ci; 622 u32 status, serr, ci;
617 623
618 serr = readl(port_mmio + PORT_SCR_ERR); 624 serr = readl(port_mmio + PORT_SCR_ERR);
@@ -648,7 +654,7 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *
648 struct ata_host_set *host_set = dev_instance; 654 struct ata_host_set *host_set = dev_instance;
649 struct ahci_host_priv *hpriv; 655 struct ahci_host_priv *hpriv;
650 unsigned int i, handled = 0; 656 unsigned int i, handled = 0;
651 void *mmio; 657 void __iomem *mmio;
652 u32 irq_stat, irq_ack = 0; 658 u32 irq_stat, irq_ack = 0;
653 659
654 VPRINTK("ENTER\n"); 660 VPRINTK("ENTER\n");
@@ -694,10 +700,7 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *
694static int ahci_qc_issue(struct ata_queued_cmd *qc) 700static int ahci_qc_issue(struct ata_queued_cmd *qc)
695{ 701{
696 struct ata_port *ap = qc->ap; 702 struct ata_port *ap = qc->ap;
697 void *port_mmio = (void *) ap->ioaddr.cmd_addr; 703 void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
698
699 writel(1, port_mmio + PORT_SCR_ACT);
700 readl(port_mmio + PORT_SCR_ACT); /* flush */
701 704
702 writel(1, port_mmio + PORT_CMD_ISSUE); 705 writel(1, port_mmio + PORT_CMD_ISSUE);
703 readl(port_mmio + PORT_CMD_ISSUE); /* flush */ 706 readl(port_mmio + PORT_CMD_ISSUE); /* flush */
@@ -882,7 +885,7 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent)
882{ 885{
883 struct ahci_host_priv *hpriv = probe_ent->private_data; 886 struct ahci_host_priv *hpriv = probe_ent->private_data;
884 struct pci_dev *pdev = to_pci_dev(probe_ent->dev); 887 struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
885 void *mmio = probe_ent->mmio_base; 888 void __iomem *mmio = probe_ent->mmio_base;
886 u32 vers, cap, impl, speed; 889 u32 vers, cap, impl, speed;
887 const char *speed_s; 890 const char *speed_s;
888 u16 cc; 891 u16 cc;
@@ -955,7 +958,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
955 struct ata_probe_ent *probe_ent = NULL; 958 struct ata_probe_ent *probe_ent = NULL;
956 struct ahci_host_priv *hpriv; 959 struct ahci_host_priv *hpriv;
957 unsigned long base; 960 unsigned long base;
958 void *mmio_base; 961 void __iomem *mmio_base;
959 unsigned int board_idx = (unsigned int) ent->driver_data; 962 unsigned int board_idx = (unsigned int) ent->driver_data;
960 int have_msi, pci_dev_busy = 0; 963 int have_msi, pci_dev_busy = 0;
961 int rc; 964 int rc;
@@ -992,8 +995,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
992 probe_ent->dev = pci_dev_to_dev(pdev); 995 probe_ent->dev = pci_dev_to_dev(pdev);
993 INIT_LIST_HEAD(&probe_ent->node); 996 INIT_LIST_HEAD(&probe_ent->node);
994 997
995 mmio_base = ioremap(pci_resource_start(pdev, AHCI_PCI_BAR), 998 mmio_base = pci_iomap(pdev, AHCI_PCI_BAR, 0);
996 pci_resource_len(pdev, AHCI_PCI_BAR));
997 if (mmio_base == NULL) { 999 if (mmio_base == NULL) {
998 rc = -ENOMEM; 1000 rc = -ENOMEM;
999 goto err_out_free_ent; 1001 goto err_out_free_ent;
@@ -1037,7 +1039,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1037err_out_hpriv: 1039err_out_hpriv:
1038 kfree(hpriv); 1040 kfree(hpriv);
1039err_out_iounmap: 1041err_out_iounmap:
1040 iounmap(mmio_base); 1042 pci_iounmap(pdev, mmio_base);
1041err_out_free_ent: 1043err_out_free_ent:
1042 kfree(probe_ent); 1044 kfree(probe_ent);
1043err_out_msi: 1045err_out_msi:
@@ -1077,7 +1079,8 @@ static void ahci_remove_one (struct pci_dev *pdev)
1077 scsi_host_put(ap->host); 1079 scsi_host_put(ap->host);
1078 } 1080 }
1079 1081
1080 host_set->ops->host_stop(host_set); 1082 kfree(hpriv);
1083 pci_iounmap(pdev, host_set->mmio_base);
1081 kfree(host_set); 1084 kfree(host_set);
1082 1085
1083 if (have_msi) 1086 if (have_msi)
@@ -1094,7 +1097,6 @@ static int __init ahci_init(void)
1094 return pci_module_init(&ahci_pci_driver); 1097 return pci_module_init(&ahci_pci_driver);
1095} 1098}
1096 1099
1097
1098static void __exit ahci_exit(void) 1100static void __exit ahci_exit(void)
1099{ 1101{
1100 pci_unregister_driver(&ahci_pci_driver); 1102 pci_unregister_driver(&ahci_pci_driver);
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index d96ebf9d2228..deec0cef88d9 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -1,24 +1,42 @@
1/* 1/*
2 2 * ata_piix.c - Intel PATA/SATA controllers
3 ata_piix.c - Intel PATA/SATA controllers 3 *
4 4 * Maintained by: Jeff Garzik <jgarzik@pobox.com>
5 Maintained by: Jeff Garzik <jgarzik@pobox.com> 5 * Please ALWAYS copy linux-ide@vger.kernel.org
6 Please ALWAYS copy linux-ide@vger.kernel.org 6 * on emails.
7 on emails. 7 *
8 8 *
9 9 * Copyright 2003-2005 Red Hat Inc
10 Copyright 2003-2004 Red Hat Inc 10 * Copyright 2003-2005 Jeff Garzik
11 Copyright 2003-2004 Jeff Garzik 11 *
12 12 *
13 13 * Copyright header from piix.c:
14 Copyright header from piix.c: 14 *
15 15 * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer
16 Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer 16 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
17 Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> 17 * Copyright (C) 2003 Red Hat Inc <alan@redhat.com>
18 Copyright (C) 2003 Red Hat Inc <alan@redhat.com> 18 *
19 19 *
20 May be copied or modified under the terms of the GNU General Public License 20 * This program is free software; you can redistribute it and/or modify
21 21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2, or (at your option)
23 * any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; see the file COPYING. If not, write to
32 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
33 *
34 *
35 * libata documentation is available via 'make {ps|pdf}docs',
36 * as Documentation/DocBook/libata.*
37 *
38 * Hardware documentation available at http://developer.intel.com/
39 *
22 */ 40 */
23 41
24#include <linux/kernel.h> 42#include <linux/kernel.h>
@@ -565,8 +583,7 @@ static void pci_enable_intx(struct pci_dev *pdev)
565#define AHCI_ENABLE (1 << 31) 583#define AHCI_ENABLE (1 << 31)
566static int piix_disable_ahci(struct pci_dev *pdev) 584static int piix_disable_ahci(struct pci_dev *pdev)
567{ 585{
568 void *mmio; 586 void __iomem *mmio;
569 unsigned long addr;
570 u32 tmp; 587 u32 tmp;
571 int rc = 0; 588 int rc = 0;
572 589
@@ -574,11 +591,11 @@ static int piix_disable_ahci(struct pci_dev *pdev)
574 * works because this device is usually set up by BIOS. 591 * works because this device is usually set up by BIOS.
575 */ 592 */
576 593
577 addr = pci_resource_start(pdev, AHCI_PCI_BAR); 594 if (!pci_resource_start(pdev, AHCI_PCI_BAR) ||
578 if (!addr || !pci_resource_len(pdev, AHCI_PCI_BAR)) 595 !pci_resource_len(pdev, AHCI_PCI_BAR))
579 return 0; 596 return 0;
580 597
581 mmio = ioremap(addr, 64); 598 mmio = pci_iomap(pdev, AHCI_PCI_BAR, 64);
582 if (!mmio) 599 if (!mmio)
583 return -ENOMEM; 600 return -ENOMEM;
584 601
@@ -592,7 +609,7 @@ static int piix_disable_ahci(struct pci_dev *pdev)
592 rc = -EIO; 609 rc = -EIO;
593 } 610 }
594 611
595 iounmap(mmio); 612 pci_iounmap(pdev, mmio);
596 return rc; 613 return rc;
597} 614}
598 615
@@ -629,13 +646,13 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
629 port_info[1] = NULL; 646 port_info[1] = NULL;
630 647
631 if (port_info[0]->host_flags & PIIX_FLAG_AHCI) { 648 if (port_info[0]->host_flags & PIIX_FLAG_AHCI) {
632 u8 tmp; 649 u8 tmp;
633 pci_read_config_byte(pdev, PIIX_SCC, &tmp); 650 pci_read_config_byte(pdev, PIIX_SCC, &tmp);
634 if (tmp == PIIX_AHCI_DEVICE) { 651 if (tmp == PIIX_AHCI_DEVICE) {
635 int rc = piix_disable_ahci(pdev); 652 int rc = piix_disable_ahci(pdev);
636 if (rc) 653 if (rc)
637 return rc; 654 return rc;
638 } 655 }
639 } 656 }
640 657
641 if (port_info[0]->host_flags & PIIX_FLAG_COMBINED) { 658 if (port_info[0]->host_flags & PIIX_FLAG_COMBINED) {
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 1b911dadf64b..5b14934ba861 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1531,7 +1531,7 @@ static int ibmvscsi_remove(struct vio_dev *vdev)
1531 */ 1531 */
1532static struct vio_device_id ibmvscsi_device_table[] __devinitdata = { 1532static struct vio_device_id ibmvscsi_device_table[] __devinitdata = {
1533 {"vscsi", "IBM,v-scsi"}, 1533 {"vscsi", "IBM,v-scsi"},
1534 {0,} 1534 { "", "" }
1535}; 1535};
1536 1536
1537MODULE_DEVICE_TABLE(vio, ibmvscsi_device_table); 1537MODULE_DEVICE_TABLE(vio, ibmvscsi_device_table);
diff --git a/drivers/scsi/ibmvscsi/rpa_vscsi.c b/drivers/scsi/ibmvscsi/rpa_vscsi.c
index 035f615817d7..8bf5652f1060 100644
--- a/drivers/scsi/ibmvscsi/rpa_vscsi.c
+++ b/drivers/scsi/ibmvscsi/rpa_vscsi.c
@@ -28,6 +28,7 @@
28 */ 28 */
29 29
30#include <asm/vio.h> 30#include <asm/vio.h>
31#include <asm/prom.h>
31#include <asm/iommu.h> 32#include <asm/iommu.h>
32#include <asm/hvcall.h> 33#include <asm/hvcall.h>
33#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index f4e7dcb6492b..5cc53cd9323e 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1,25 +1,35 @@
1/* 1/*
2 libata-core.c - helper library for ATA 2 * libata-core.c - helper library for ATA
3 3 *
4 Copyright 2003-2004 Red Hat, Inc. All rights reserved. 4 * Maintained by: Jeff Garzik <jgarzik@pobox.com>
5 Copyright 2003-2004 Jeff Garzik 5 * Please ALWAYS copy linux-ide@vger.kernel.org
6 6 * on emails.
7 The contents of this file are subject to the Open 7 *
8 Software License version 1.1 that can be found at 8 * Copyright 2003-2004 Red Hat, Inc. All rights reserved.
9 http://www.opensource.org/licenses/osl-1.1.txt and is included herein 9 * Copyright 2003-2004 Jeff Garzik
10 by reference. 10 *
11 11 *
12 Alternatively, the contents of this file may be used under the terms 12 * This program is free software; you can redistribute it and/or modify
13 of the GNU General Public License version 2 (the "GPL") as distributed 13 * it under the terms of the GNU General Public License as published by
14 in the kernel source COPYING file, in which case the provisions of 14 * the Free Software Foundation; either version 2, or (at your option)
15 the GPL are applicable instead of the above. If you wish to allow 15 * any later version.
16 the use of your version of this file only under the terms of the 16 *
17 GPL and not to allow others to use your version of this file under 17 * This program is distributed in the hope that it will be useful,
18 the OSL, indicate your decision by deleting the provisions above and 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 replace them with the notice and other provisions required by the GPL. 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 If you do not delete the provisions above, a recipient may use your 20 * GNU General Public License for more details.
21 version of this file under either the OSL or the GPL. 21 *
22 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 * Hardware documentation available from http://www.t13.org/ and
31 * http://www.sata-io.org/
32 *
23 */ 33 */
24 34
25#include <linux/config.h> 35#include <linux/config.h>
@@ -65,6 +75,10 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc);
65static unsigned int ata_unique_id = 1; 75static unsigned int ata_unique_id = 1;
66static struct workqueue_struct *ata_wq; 76static struct workqueue_struct *ata_wq;
67 77
78int atapi_enabled = 0;
79module_param(atapi_enabled, int, 0444);
80MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)");
81
68MODULE_AUTHOR("Jeff Garzik"); 82MODULE_AUTHOR("Jeff Garzik");
69MODULE_DESCRIPTION("Library module for ATA devices"); 83MODULE_DESCRIPTION("Library module for ATA devices");
70MODULE_LICENSE("GPL"); 84MODULE_LICENSE("GPL");
@@ -1304,12 +1318,12 @@ static inline u8 ata_dev_knobble(struct ata_port *ap)
1304/** 1318/**
1305 * ata_dev_config - Run device specific handlers and check for 1319 * ata_dev_config - Run device specific handlers and check for
1306 * SATA->PATA bridges 1320 * SATA->PATA bridges
1307 * @ap: Bus 1321 * @ap: Bus
1308 * @i: Device 1322 * @i: Device
1309 * 1323 *
1310 * LOCKING: 1324 * LOCKING:
1311 */ 1325 */
1312 1326
1313void ata_dev_config(struct ata_port *ap, unsigned int i) 1327void ata_dev_config(struct ata_port *ap, unsigned int i)
1314{ 1328{
1315 /* limit bridge transfers to udma5, 200 sectors */ 1329 /* limit bridge transfers to udma5, 200 sectors */
@@ -2377,6 +2391,27 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
2377} 2391}
2378 2392
2379/** 2393/**
2394 * ata_poll_qc_complete - turn irq back on and finish qc
2395 * @qc: Command to complete
2396 * @drv_stat: ATA status register content
2397 *
2398 * LOCKING:
2399 * None. (grabs host lock)
2400 */
2401
2402void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
2403{
2404 struct ata_port *ap = qc->ap;
2405 unsigned long flags;
2406
2407 spin_lock_irqsave(&ap->host_set->lock, flags);
2408 ap->flags &= ~ATA_FLAG_NOINTR;
2409 ata_irq_on(ap);
2410 ata_qc_complete(qc, drv_stat);
2411 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2412}
2413
2414/**
2380 * ata_pio_poll - 2415 * ata_pio_poll -
2381 * @ap: 2416 * @ap:
2382 * 2417 *
@@ -2438,11 +2473,10 @@ static void ata_pio_complete (struct ata_port *ap)
2438 u8 drv_stat; 2473 u8 drv_stat;
2439 2474
2440 /* 2475 /*
2441 * This is purely hueristic. This is a fast path. 2476 * This is purely heuristic. This is a fast path. Sometimes when
2442 * Sometimes when we enter, BSY will be cleared in 2477 * we enter, BSY will be cleared in a chk-status or two. If not,
2443 * a chk-status or two. If not, the drive is probably seeking 2478 * the drive is probably seeking or something. Snooze for a couple
2444 * or something. Snooze for a couple msecs, then 2479 * msecs, then chk-status again. If still busy, fall back to
2445 * chk-status again. If still busy, fall back to
2446 * PIO_ST_POLL state. 2480 * PIO_ST_POLL state.
2447 */ 2481 */
2448 drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); 2482 drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10);
@@ -2467,9 +2501,7 @@ static void ata_pio_complete (struct ata_port *ap)
2467 2501
2468 ap->pio_task_state = PIO_ST_IDLE; 2502 ap->pio_task_state = PIO_ST_IDLE;
2469 2503
2470 ata_irq_on(ap); 2504 ata_poll_qc_complete(qc, drv_stat);
2471
2472 ata_qc_complete(qc, drv_stat);
2473} 2505}
2474 2506
2475 2507
@@ -2494,6 +2526,20 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
2494#endif /* __BIG_ENDIAN */ 2526#endif /* __BIG_ENDIAN */
2495} 2527}
2496 2528
2529/**
2530 * ata_mmio_data_xfer - Transfer data by MMIO
2531 * @ap: port to read/write
2532 * @buf: data buffer
2533 * @buflen: buffer length
2534 * @write_data: read/write
2535 *
2536 * Transfer data from/to the device data register by MMIO.
2537 *
2538 * LOCKING:
2539 * Inherited from caller.
2540 *
2541 */
2542
2497static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf, 2543static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf,
2498 unsigned int buflen, int write_data) 2544 unsigned int buflen, int write_data)
2499{ 2545{
@@ -2502,6 +2548,7 @@ static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf,
2502 u16 *buf16 = (u16 *) buf; 2548 u16 *buf16 = (u16 *) buf;
2503 void __iomem *mmio = (void __iomem *)ap->ioaddr.data_addr; 2549 void __iomem *mmio = (void __iomem *)ap->ioaddr.data_addr;
2504 2550
2551 /* Transfer multiple of 2 bytes */
2505 if (write_data) { 2552 if (write_data) {
2506 for (i = 0; i < words; i++) 2553 for (i = 0; i < words; i++)
2507 writew(le16_to_cpu(buf16[i]), mmio); 2554 writew(le16_to_cpu(buf16[i]), mmio);
@@ -2509,19 +2556,76 @@ static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf,
2509 for (i = 0; i < words; i++) 2556 for (i = 0; i < words; i++)
2510 buf16[i] = cpu_to_le16(readw(mmio)); 2557 buf16[i] = cpu_to_le16(readw(mmio));
2511 } 2558 }
2559
2560 /* Transfer trailing 1 byte, if any. */
2561 if (unlikely(buflen & 0x01)) {
2562 u16 align_buf[1] = { 0 };
2563 unsigned char *trailing_buf = buf + buflen - 1;
2564
2565 if (write_data) {
2566 memcpy(align_buf, trailing_buf, 1);
2567 writew(le16_to_cpu(align_buf[0]), mmio);
2568 } else {
2569 align_buf[0] = cpu_to_le16(readw(mmio));
2570 memcpy(trailing_buf, align_buf, 1);
2571 }
2572 }
2512} 2573}
2513 2574
2575/**
2576 * ata_pio_data_xfer - Transfer data by PIO
2577 * @ap: port to read/write
2578 * @buf: data buffer
2579 * @buflen: buffer length
2580 * @write_data: read/write
2581 *
2582 * Transfer data from/to the device data register by PIO.
2583 *
2584 * LOCKING:
2585 * Inherited from caller.
2586 *
2587 */
2588
2514static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf, 2589static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf,
2515 unsigned int buflen, int write_data) 2590 unsigned int buflen, int write_data)
2516{ 2591{
2517 unsigned int dwords = buflen >> 1; 2592 unsigned int words = buflen >> 1;
2518 2593
2594 /* Transfer multiple of 2 bytes */
2519 if (write_data) 2595 if (write_data)
2520 outsw(ap->ioaddr.data_addr, buf, dwords); 2596 outsw(ap->ioaddr.data_addr, buf, words);
2521 else 2597 else
2522 insw(ap->ioaddr.data_addr, buf, dwords); 2598 insw(ap->ioaddr.data_addr, buf, words);
2599
2600 /* Transfer trailing 1 byte, if any. */
2601 if (unlikely(buflen & 0x01)) {
2602 u16 align_buf[1] = { 0 };
2603 unsigned char *trailing_buf = buf + buflen - 1;
2604
2605 if (write_data) {
2606 memcpy(align_buf, trailing_buf, 1);
2607 outw(le16_to_cpu(align_buf[0]), ap->ioaddr.data_addr);
2608 } else {
2609 align_buf[0] = cpu_to_le16(inw(ap->ioaddr.data_addr));
2610 memcpy(trailing_buf, align_buf, 1);
2611 }
2612 }
2523} 2613}
2524 2614
2615/**
2616 * ata_data_xfer - Transfer data from/to the data register.
2617 * @ap: port to read/write
2618 * @buf: data buffer
2619 * @buflen: buffer length
2620 * @do_write: read/write
2621 *
2622 * Transfer data from/to the device data register.
2623 *
2624 * LOCKING:
2625 * Inherited from caller.
2626 *
2627 */
2628
2525static void ata_data_xfer(struct ata_port *ap, unsigned char *buf, 2629static void ata_data_xfer(struct ata_port *ap, unsigned char *buf,
2526 unsigned int buflen, int do_write) 2630 unsigned int buflen, int do_write)
2527{ 2631{
@@ -2531,6 +2635,16 @@ static void ata_data_xfer(struct ata_port *ap, unsigned char *buf,
2531 ata_pio_data_xfer(ap, buf, buflen, do_write); 2635 ata_pio_data_xfer(ap, buf, buflen, do_write);
2532} 2636}
2533 2637
2638/**
2639 * ata_pio_sector - Transfer ATA_SECT_SIZE (512 bytes) of data.
2640 * @qc: Command on going
2641 *
2642 * Transfer ATA_SECT_SIZE of data from/to the ATA device.
2643 *
2644 * LOCKING:
2645 * Inherited from caller.
2646 */
2647
2534static void ata_pio_sector(struct ata_queued_cmd *qc) 2648static void ata_pio_sector(struct ata_queued_cmd *qc)
2535{ 2649{
2536 int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); 2650 int do_write = (qc->tf.flags & ATA_TFLAG_WRITE);
@@ -2569,6 +2683,18 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
2569 kunmap(page); 2683 kunmap(page);
2570} 2684}
2571 2685
2686/**
2687 * __atapi_pio_bytes - Transfer data from/to the ATAPI device.
2688 * @qc: Command on going
2689 * @bytes: number of bytes
2690 *
2691 * Transfer Transfer data from/to the ATAPI device.
2692 *
2693 * LOCKING:
2694 * Inherited from caller.
2695 *
2696 */
2697
2572static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) 2698static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
2573{ 2699{
2574 int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); 2700 int do_write = (qc->tf.flags & ATA_TFLAG_WRITE);
@@ -2578,10 +2704,33 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
2578 unsigned char *buf; 2704 unsigned char *buf;
2579 unsigned int offset, count; 2705 unsigned int offset, count;
2580 2706
2581 if (qc->curbytes == qc->nbytes - bytes) 2707 if (qc->curbytes + bytes >= qc->nbytes)
2582 ap->pio_task_state = PIO_ST_LAST; 2708 ap->pio_task_state = PIO_ST_LAST;
2583 2709
2584next_sg: 2710next_sg:
2711 if (unlikely(qc->cursg >= qc->n_elem)) {
2712 /*
2713 * The end of qc->sg is reached and the device expects
2714 * more data to transfer. In order not to overrun qc->sg
2715 * and fulfill length specified in the byte count register,
2716 * - for read case, discard trailing data from the device
2717 * - for write case, padding zero data to the device
2718 */
2719 u16 pad_buf[1] = { 0 };
2720 unsigned int words = bytes >> 1;
2721 unsigned int i;
2722
2723 if (words) /* warning if bytes > 1 */
2724 printk(KERN_WARNING "ata%u: %u bytes trailing data\n",
2725 ap->id, bytes);
2726
2727 for (i = 0; i < words; i++)
2728 ata_data_xfer(ap, (unsigned char*)pad_buf, 2, do_write);
2729
2730 ap->pio_task_state = PIO_ST_LAST;
2731 return;
2732 }
2733
2585 sg = &qc->sg[qc->cursg]; 2734 sg = &qc->sg[qc->cursg];
2586 2735
2587 page = sg->page; 2736 page = sg->page;
@@ -2615,11 +2764,21 @@ next_sg:
2615 2764
2616 kunmap(page); 2765 kunmap(page);
2617 2766
2618 if (bytes) { 2767 if (bytes)
2619 goto next_sg; 2768 goto next_sg;
2620 }
2621} 2769}
2622 2770
2771/**
2772 * atapi_pio_bytes - Transfer data from/to the ATAPI device.
2773 * @qc: Command on going
2774 *
2775 * Transfer Transfer data from/to the ATAPI device.
2776 *
2777 * LOCKING:
2778 * Inherited from caller.
2779 *
2780 */
2781
2623static void atapi_pio_bytes(struct ata_queued_cmd *qc) 2782static void atapi_pio_bytes(struct ata_queued_cmd *qc)
2624{ 2783{
2625 struct ata_port *ap = qc->ap; 2784 struct ata_port *ap = qc->ap;
@@ -2692,9 +2851,7 @@ static void ata_pio_block(struct ata_port *ap)
2692 if ((status & ATA_DRQ) == 0) { 2851 if ((status & ATA_DRQ) == 0) {
2693 ap->pio_task_state = PIO_ST_IDLE; 2852 ap->pio_task_state = PIO_ST_IDLE;
2694 2853
2695 ata_irq_on(ap); 2854 ata_poll_qc_complete(qc, status);
2696
2697 ata_qc_complete(qc, status);
2698 return; 2855 return;
2699 } 2856 }
2700 2857
@@ -2724,9 +2881,7 @@ static void ata_pio_error(struct ata_port *ap)
2724 2881
2725 ap->pio_task_state = PIO_ST_IDLE; 2882 ap->pio_task_state = PIO_ST_IDLE;
2726 2883
2727 ata_irq_on(ap); 2884 ata_poll_qc_complete(qc, drv_stat | ATA_ERR);
2728
2729 ata_qc_complete(qc, drv_stat | ATA_ERR);
2730} 2885}
2731 2886
2732static void ata_pio_task(void *_data) 2887static void ata_pio_task(void *_data)
@@ -2832,8 +2987,10 @@ static void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
2832static void ata_qc_timeout(struct ata_queued_cmd *qc) 2987static void ata_qc_timeout(struct ata_queued_cmd *qc)
2833{ 2988{
2834 struct ata_port *ap = qc->ap; 2989 struct ata_port *ap = qc->ap;
2990 struct ata_host_set *host_set = ap->host_set;
2835 struct ata_device *dev = qc->dev; 2991 struct ata_device *dev = qc->dev;
2836 u8 host_stat = 0, drv_stat; 2992 u8 host_stat = 0, drv_stat;
2993 unsigned long flags;
2837 2994
2838 DPRINTK("ENTER\n"); 2995 DPRINTK("ENTER\n");
2839 2996
@@ -2844,7 +3001,9 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
2844 if (!(cmd->eh_eflags & SCSI_EH_CANCEL_CMD)) { 3001 if (!(cmd->eh_eflags & SCSI_EH_CANCEL_CMD)) {
2845 3002
2846 /* finish completing original command */ 3003 /* finish completing original command */
3004 spin_lock_irqsave(&host_set->lock, flags);
2847 __ata_qc_complete(qc); 3005 __ata_qc_complete(qc);
3006 spin_unlock_irqrestore(&host_set->lock, flags);
2848 3007
2849 atapi_request_sense(ap, dev, cmd); 3008 atapi_request_sense(ap, dev, cmd);
2850 3009
@@ -2855,6 +3014,8 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
2855 } 3014 }
2856 } 3015 }
2857 3016
3017 spin_lock_irqsave(&host_set->lock, flags);
3018
2858 /* hack alert! We cannot use the supplied completion 3019 /* hack alert! We cannot use the supplied completion
2859 * function from inside the ->eh_strategy_handler() thread. 3020 * function from inside the ->eh_strategy_handler() thread.
2860 * libata is the only user of ->eh_strategy_handler() in 3021 * libata is the only user of ->eh_strategy_handler() in
@@ -2870,7 +3031,7 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
2870 host_stat = ap->ops->bmdma_status(ap); 3031 host_stat = ap->ops->bmdma_status(ap);
2871 3032
2872 /* before we do anything else, clear DMA-Start bit */ 3033 /* before we do anything else, clear DMA-Start bit */
2873 ap->ops->bmdma_stop(ap); 3034 ap->ops->bmdma_stop(qc);
2874 3035
2875 /* fall through */ 3036 /* fall through */
2876 3037
@@ -2888,6 +3049,9 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
2888 ata_qc_complete(qc, drv_stat); 3049 ata_qc_complete(qc, drv_stat);
2889 break; 3050 break;
2890 } 3051 }
3052
3053 spin_unlock_irqrestore(&host_set->lock, flags);
3054
2891out: 3055out:
2892 DPRINTK("EXIT\n"); 3056 DPRINTK("EXIT\n");
2893} 3057}
@@ -3061,9 +3225,14 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
3061 if (likely(qc->flags & ATA_QCFLAG_DMAMAP)) 3225 if (likely(qc->flags & ATA_QCFLAG_DMAMAP))
3062 ata_sg_clean(qc); 3226 ata_sg_clean(qc);
3063 3227
3228 /* atapi: mark qc as inactive to prevent the interrupt handler
3229 * from completing the command twice later, before the error handler
3230 * is called. (when rc != 0 and atapi request sense is needed)
3231 */
3232 qc->flags &= ~ATA_QCFLAG_ACTIVE;
3233
3064 /* call completion callback */ 3234 /* call completion callback */
3065 rc = qc->complete_fn(qc, drv_stat); 3235 rc = qc->complete_fn(qc, drv_stat);
3066 qc->flags &= ~ATA_QCFLAG_ACTIVE;
3067 3236
3068 /* if callback indicates not to complete command (non-zero), 3237 /* if callback indicates not to complete command (non-zero),
3069 * return immediately 3238 * return immediately
@@ -3193,11 +3362,13 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc)
3193 break; 3362 break;
3194 3363
3195 case ATA_PROT_ATAPI_NODATA: 3364 case ATA_PROT_ATAPI_NODATA:
3365 ap->flags |= ATA_FLAG_NOINTR;
3196 ata_tf_to_host_nolock(ap, &qc->tf); 3366 ata_tf_to_host_nolock(ap, &qc->tf);
3197 queue_work(ata_wq, &ap->packet_task); 3367 queue_work(ata_wq, &ap->packet_task);
3198 break; 3368 break;
3199 3369
3200 case ATA_PROT_ATAPI_DMA: 3370 case ATA_PROT_ATAPI_DMA:
3371 ap->flags |= ATA_FLAG_NOINTR;
3201 ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ 3372 ap->ops->tf_load(ap, &qc->tf); /* load tf registers */
3202 ap->ops->bmdma_setup(qc); /* set up bmdma */ 3373 ap->ops->bmdma_setup(qc); /* set up bmdma */
3203 queue_work(ata_wq, &ap->packet_task); 3374 queue_work(ata_wq, &ap->packet_task);
@@ -3242,7 +3413,7 @@ static void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc)
3242} 3413}
3243 3414
3244/** 3415/**
3245 * ata_bmdma_start - Start a PCI IDE BMDMA transaction 3416 * ata_bmdma_start_mmio - Start a PCI IDE BMDMA transaction
3246 * @qc: Info associated with this ATA transaction. 3417 * @qc: Info associated with this ATA transaction.
3247 * 3418 *
3248 * LOCKING: 3419 * LOCKING:
@@ -3413,7 +3584,7 @@ u8 ata_bmdma_status(struct ata_port *ap)
3413 3584
3414/** 3585/**
3415 * ata_bmdma_stop - Stop PCI IDE BMDMA transfer 3586 * ata_bmdma_stop - Stop PCI IDE BMDMA transfer
3416 * @ap: Port associated with this ATA transaction. 3587 * @qc: Command we are ending DMA for
3417 * 3588 *
3418 * Clears the ATA_DMA_START flag in the dma control register 3589 * Clears the ATA_DMA_START flag in the dma control register
3419 * 3590 *
@@ -3423,8 +3594,9 @@ u8 ata_bmdma_status(struct ata_port *ap)
3423 * spin_lock_irqsave(host_set lock) 3594 * spin_lock_irqsave(host_set lock)
3424 */ 3595 */
3425 3596
3426void ata_bmdma_stop(struct ata_port *ap) 3597void ata_bmdma_stop(struct ata_queued_cmd *qc)
3427{ 3598{
3599 struct ata_port *ap = qc->ap;
3428 if (ap->flags & ATA_FLAG_MMIO) { 3600 if (ap->flags & ATA_FLAG_MMIO) {
3429 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr; 3601 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
3430 3602
@@ -3476,7 +3648,7 @@ inline unsigned int ata_host_intr (struct ata_port *ap,
3476 goto idle_irq; 3648 goto idle_irq;
3477 3649
3478 /* before we do anything else, clear DMA-Start bit */ 3650 /* before we do anything else, clear DMA-Start bit */
3479 ap->ops->bmdma_stop(ap); 3651 ap->ops->bmdma_stop(qc);
3480 3652
3481 /* fall through */ 3653 /* fall through */
3482 3654
@@ -3551,7 +3723,8 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
3551 struct ata_port *ap; 3723 struct ata_port *ap;
3552 3724
3553 ap = host_set->ports[i]; 3725 ap = host_set->ports[i];
3554 if (ap && (!(ap->flags & ATA_FLAG_PORT_DISABLED))) { 3726 if (ap &&
3727 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) {
3555 struct ata_queued_cmd *qc; 3728 struct ata_queued_cmd *qc;
3556 3729
3557 qc = ata_qc_from_tag(ap, ap->active_tag); 3730 qc = ata_qc_from_tag(ap, ap->active_tag);
@@ -3603,19 +3776,27 @@ static void atapi_packet_task(void *_data)
3603 /* send SCSI cdb */ 3776 /* send SCSI cdb */
3604 DPRINTK("send cdb\n"); 3777 DPRINTK("send cdb\n");
3605 assert(ap->cdb_len >= 12); 3778 assert(ap->cdb_len >= 12);
3606 ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1);
3607 3779
3608 /* if we are DMA'ing, irq handler takes over from here */ 3780 if (qc->tf.protocol == ATA_PROT_ATAPI_DMA ||
3609 if (qc->tf.protocol == ATA_PROT_ATAPI_DMA) 3781 qc->tf.protocol == ATA_PROT_ATAPI_NODATA) {
3610 ap->ops->bmdma_start(qc); /* initiate bmdma */ 3782 unsigned long flags;
3611 3783
3612 /* non-data commands are also handled via irq */ 3784 /* Once we're done issuing command and kicking bmdma,
3613 else if (qc->tf.protocol == ATA_PROT_ATAPI_NODATA) { 3785 * irq handler takes over. To not lose irq, we need
3614 /* do nothing */ 3786 * to clear NOINTR flag before sending cdb, but
3615 } 3787 * interrupt handler shouldn't be invoked before we're
3788 * finished. Hence, the following locking.
3789 */
3790 spin_lock_irqsave(&ap->host_set->lock, flags);
3791 ap->flags &= ~ATA_FLAG_NOINTR;
3792 ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1);
3793 if (qc->tf.protocol == ATA_PROT_ATAPI_DMA)
3794 ap->ops->bmdma_start(qc); /* initiate bmdma */
3795 spin_unlock_irqrestore(&ap->host_set->lock, flags);
3796 } else {
3797 ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1);
3616 3798
3617 /* PIO commands are handled by polling */ 3799 /* PIO commands are handled by polling */
3618 else {
3619 ap->pio_task_state = PIO_ST; 3800 ap->pio_task_state = PIO_ST;
3620 queue_work(ata_wq, &ap->pio_task); 3801 queue_work(ata_wq, &ap->pio_task);
3621 } 3802 }
@@ -3623,7 +3804,7 @@ static void atapi_packet_task(void *_data)
3623 return; 3804 return;
3624 3805
3625err_out: 3806err_out:
3626 ata_qc_complete(qc, ATA_ERR); 3807 ata_poll_qc_complete(qc, ATA_ERR);
3627} 3808}
3628 3809
3629 3810
@@ -4023,6 +4204,15 @@ ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port)
4023 4204
4024 4205
4025 4206
4207#ifdef CONFIG_PCI
4208
4209void ata_pci_host_stop (struct ata_host_set *host_set)
4210{
4211 struct pci_dev *pdev = to_pci_dev(host_set->dev);
4212
4213 pci_iounmap(pdev, host_set->mmio_base);
4214}
4215
4026/** 4216/**
4027 * ata_pci_init_native_mode - Initialize native-mode driver 4217 * ata_pci_init_native_mode - Initialize native-mode driver
4028 * @pdev: pci device to be initialized 4218 * @pdev: pci device to be initialized
@@ -4035,7 +4225,6 @@ ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port)
4035 * ata_probe_ent structure should then be freed with kfree(). 4225 * ata_probe_ent structure should then be freed with kfree().
4036 */ 4226 */
4037 4227
4038#ifdef CONFIG_PCI
4039struct ata_probe_ent * 4228struct ata_probe_ent *
4040ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port) 4229ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port)
4041{ 4230{
@@ -4418,6 +4607,7 @@ EXPORT_SYMBOL_GPL(ata_scsi_simulate);
4418 4607
4419#ifdef CONFIG_PCI 4608#ifdef CONFIG_PCI
4420EXPORT_SYMBOL_GPL(pci_test_config_bits); 4609EXPORT_SYMBOL_GPL(pci_test_config_bits);
4610EXPORT_SYMBOL_GPL(ata_pci_host_stop);
4421EXPORT_SYMBOL_GPL(ata_pci_init_native_mode); 4611EXPORT_SYMBOL_GPL(ata_pci_init_native_mode);
4422EXPORT_SYMBOL_GPL(ata_pci_init_one); 4612EXPORT_SYMBOL_GPL(ata_pci_init_one);
4423EXPORT_SYMBOL_GPL(ata_pci_remove_one); 4613EXPORT_SYMBOL_GPL(ata_pci_remove_one);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 6a75ec2187fd..104fd9a63e73 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -1,25 +1,36 @@
1/* 1/*
2 libata-scsi.c - helper library for ATA 2 * libata-scsi.c - helper library for ATA
3 3 *
4 Copyright 2003-2004 Red Hat, Inc. All rights reserved. 4 * Maintained by: Jeff Garzik <jgarzik@pobox.com>
5 Copyright 2003-2004 Jeff Garzik 5 * Please ALWAYS copy linux-ide@vger.kernel.org
6 6 * on emails.
7 The contents of this file are subject to the Open 7 *
8 Software License version 1.1 that can be found at 8 * Copyright 2003-2004 Red Hat, Inc. All rights reserved.
9 http://www.opensource.org/licenses/osl-1.1.txt and is included herein 9 * Copyright 2003-2004 Jeff Garzik
10 by reference. 10 *
11 11 *
12 Alternatively, the contents of this file may be used under the terms 12 * This program is free software; you can redistribute it and/or modify
13 of the GNU General Public License version 2 (the "GPL") as distributed 13 * it under the terms of the GNU General Public License as published by
14 in the kernel source COPYING file, in which case the provisions of 14 * the Free Software Foundation; either version 2, or (at your option)
15 the GPL are applicable instead of the above. If you wish to allow 15 * any later version.
16 the use of your version of this file only under the terms of the 16 *
17 GPL and not to allow others to use your version of this file under 17 * This program is distributed in the hope that it will be useful,
18 the OSL, indicate your decision by deleting the provisions above and 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 replace them with the notice and other provisions required by the GPL. 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 If you do not delete the provisions above, a recipient may use your 20 * GNU General Public License for more details.
21 version of this file under either the OSL or the GPL. 21 *
22 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 * Hardware documentation available from
31 * - http://www.t10.org/
32 * - http://www.t13.org/
33 *
23 */ 34 */
24 35
25#include <linux/kernel.h> 36#include <linux/kernel.h>
@@ -392,6 +403,60 @@ int ata_scsi_error(struct Scsi_Host *host)
392} 403}
393 404
394/** 405/**
406 * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command
407 * @qc: Storage for translated ATA taskfile
408 * @scsicmd: SCSI command to translate
409 *
410 * Sets up an ATA taskfile to issue STANDBY (to stop) or READ VERIFY
411 * (to start). Perhaps these commands should be preceded by
412 * CHECK POWER MODE to see what power mode the device is already in.
413 * [See SAT revision 5 at www.t10.org]
414 *
415 * LOCKING:
416 * spin_lock_irqsave(host_set lock)
417 *
418 * RETURNS:
419 * Zero on success, non-zero on error.
420 */
421
422static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc,
423 u8 *scsicmd)
424{
425 struct ata_taskfile *tf = &qc->tf;
426
427 tf->flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR;
428 tf->protocol = ATA_PROT_NODATA;
429 if (scsicmd[1] & 0x1) {
430 ; /* ignore IMMED bit, violates sat-r05 */
431 }
432 if (scsicmd[4] & 0x2)
433 return 1; /* LOEJ bit set not supported */
434 if (((scsicmd[4] >> 4) & 0xf) != 0)
435 return 1; /* power conditions not supported */
436 if (scsicmd[4] & 0x1) {
437 tf->nsect = 1; /* 1 sector, lba=0 */
438 tf->lbah = 0x0;
439 tf->lbam = 0x0;
440 tf->lbal = 0x0;
441 tf->device |= ATA_LBA;
442 tf->command = ATA_CMD_VERIFY; /* READ VERIFY */
443 } else {
444 tf->nsect = 0; /* time period value (0 implies now) */
445 tf->command = ATA_CMD_STANDBY;
446 /* Consider: ATA STANDBY IMMEDIATE command */
447 }
448 /*
449 * Standby and Idle condition timers could be implemented but that
450 * would require libata to implement the Power condition mode page
451 * and allow the user to change it. Changing mode pages requires
452 * MODE SELECT to be implemented.
453 */
454
455 return 0;
456}
457
458
459/**
395 * ata_scsi_flush_xlat - Translate SCSI SYNCHRONIZE CACHE command 460 * ata_scsi_flush_xlat - Translate SCSI SYNCHRONIZE CACHE command
396 * @qc: Storage for translated ATA taskfile 461 * @qc: Storage for translated ATA taskfile
397 * @scsicmd: SCSI command to translate (ignored) 462 * @scsicmd: SCSI command to translate (ignored)
@@ -576,11 +641,19 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
576 tf->lbah = scsicmd[3]; 641 tf->lbah = scsicmd[3];
577 642
578 VPRINTK("ten-byte command\n"); 643 VPRINTK("ten-byte command\n");
644 if (qc->nsect == 0) /* we don't support length==0 cmds */
645 return 1;
579 return 0; 646 return 0;
580 } 647 }
581 648
582 if (scsicmd[0] == READ_6 || scsicmd[0] == WRITE_6) { 649 if (scsicmd[0] == READ_6 || scsicmd[0] == WRITE_6) {
583 qc->nsect = tf->nsect = scsicmd[4]; 650 qc->nsect = tf->nsect = scsicmd[4];
651 if (!qc->nsect) {
652 qc->nsect = 256;
653 if (lba48)
654 tf->hob_nsect = 1;
655 }
656
584 tf->lbal = scsicmd[3]; 657 tf->lbal = scsicmd[3];
585 tf->lbam = scsicmd[2]; 658 tf->lbam = scsicmd[2];
586 tf->lbah = scsicmd[1] & 0x1f; /* mask out reserved bits */ 659 tf->lbah = scsicmd[1] & 0x1f; /* mask out reserved bits */
@@ -620,6 +693,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
620 tf->lbah = scsicmd[7]; 693 tf->lbah = scsicmd[7];
621 694
622 VPRINTK("sixteen-byte command\n"); 695 VPRINTK("sixteen-byte command\n");
696 if (qc->nsect == 0) /* we don't support length==0 cmds */
697 return 1;
623 return 0; 698 return 0;
624 } 699 }
625 700
@@ -1395,10 +1470,10 @@ ata_scsi_find_dev(struct ata_port *ap, struct scsi_device *scsidev)
1395 if (unlikely(!ata_dev_present(dev))) 1470 if (unlikely(!ata_dev_present(dev)))
1396 return NULL; 1471 return NULL;
1397 1472
1398#ifndef ATA_ENABLE_ATAPI 1473 if (!atapi_enabled) {
1399 if (unlikely(dev->class == ATA_DEV_ATAPI)) 1474 if (unlikely(dev->class == ATA_DEV_ATAPI))
1400 return NULL; 1475 return NULL;
1401#endif 1476 }
1402 1477
1403 return dev; 1478 return dev;
1404} 1479}
@@ -1435,6 +1510,8 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
1435 case VERIFY: 1510 case VERIFY:
1436 case VERIFY_16: 1511 case VERIFY_16:
1437 return ata_scsi_verify_xlat; 1512 return ata_scsi_verify_xlat;
1513 case START_STOP:
1514 return ata_scsi_start_stop_xlat;
1438 } 1515 }
1439 1516
1440 return NULL; 1517 return NULL;
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index 3e7f4843020f..d608b3a0f6fe 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -1,25 +1,28 @@
1/* 1/*
2 libata.h - helper library for ATA 2 * libata.h - helper library for ATA
3 3 *
4 Copyright 2003-2004 Red Hat, Inc. All rights reserved. 4 * Copyright 2003-2004 Red Hat, Inc. All rights reserved.
5 Copyright 2003-2004 Jeff Garzik 5 * Copyright 2003-2004 Jeff Garzik
6 6 *
7 The contents of this file are subject to the Open 7 *
8 Software License version 1.1 that can be found at 8 * This program is free software; you can redistribute it and/or modify
9 http://www.opensource.org/licenses/osl-1.1.txt and is included herein 9 * it under the terms of the GNU General Public License as published by
10 by reference. 10 * the Free Software Foundation; either version 2, or (at your option)
11 11 * any later version.
12 Alternatively, the contents of this file may be used under the terms 12 *
13 of the GNU General Public License version 2 (the "GPL") as distributed 13 * This program is distributed in the hope that it will be useful,
14 in the kernel source COPYING file, in which case the provisions of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 the GPL are applicable instead of the above. If you wish to allow 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 the use of your version of this file only under the terms of the 16 * GNU General Public License for more details.
17 GPL and not to allow others to use your version of this file under 17 *
18 the OSL, indicate your decision by deleting the provisions above and 18 * You should have received a copy of the GNU General Public License
19 replace them with the notice and other provisions required by the GPL. 19 * along with this program; see the file COPYING. If not, write to
20 If you do not delete the provisions above, a recipient may use your 20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 version of this file under either the OSL or the GPL. 21 *
22 22 *
23 * libata documentation is available via 'make {ps|pdf}docs',
24 * as Documentation/DocBook/libata.*
25 *
23 */ 26 */
24 27
25#ifndef __LIBATA_H__ 28#ifndef __LIBATA_H__
@@ -35,6 +38,7 @@ struct ata_scsi_args {
35}; 38};
36 39
37/* libata-core.c */ 40/* libata-core.c */
41extern int atapi_enabled;
38extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, 42extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
39 struct ata_device *dev); 43 struct ata_device *dev);
40extern void ata_qc_free(struct ata_queued_cmd *qc); 44extern void ata_qc_free(struct ata_queued_cmd *qc);
@@ -72,7 +76,7 @@ extern unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf,
72extern void ata_scsi_badcmd(struct scsi_cmnd *cmd, 76extern void ata_scsi_badcmd(struct scsi_cmnd *cmd,
73 void (*done)(struct scsi_cmnd *), 77 void (*done)(struct scsi_cmnd *),
74 u8 asc, u8 ascq); 78 u8 asc, u8 ascq);
75extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args, 79extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
76 unsigned int (*actor) (struct ata_scsi_args *args, 80 unsigned int (*actor) (struct ata_scsi_args *args,
77 u8 *rbuf, unsigned int buflen)); 81 u8 *rbuf, unsigned int buflen));
78 82
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
index ff1933298da6..a4857db4f9b8 100644
--- a/drivers/scsi/mesh.c
+++ b/drivers/scsi/mesh.c
@@ -1766,7 +1766,7 @@ static int mesh_suspend(struct macio_dev *mdev, pm_message_t state)
1766 struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev); 1766 struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev);
1767 unsigned long flags; 1767 unsigned long flags;
1768 1768
1769 if (state == mdev->ofdev.dev.power.power_state || state < 2) 1769 if (state.event == mdev->ofdev.dev.power.power_state.event || state.event < 2)
1770 return 0; 1770 return 0;
1771 1771
1772 scsi_block_requests(ms->host); 1772 scsi_block_requests(ms->host);
@@ -1791,7 +1791,7 @@ static int mesh_resume(struct macio_dev *mdev)
1791 struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev); 1791 struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev);
1792 unsigned long flags; 1792 unsigned long flags;
1793 1793
1794 if (mdev->ofdev.dev.power.power_state == 0) 1794 if (mdev->ofdev.dev.power.power_state.event == PM_EVENT_ON)
1795 return 0; 1795 return 0;
1796 1796
1797 set_mesh_power(ms, 1); 1797 set_mesh_power(ms, 1);
@@ -1802,7 +1802,7 @@ static int mesh_resume(struct macio_dev *mdev)
1802 enable_irq(ms->meshintr); 1802 enable_irq(ms->meshintr);
1803 scsi_unblock_requests(ms->host); 1803 scsi_unblock_requests(ms->host);
1804 1804
1805 mdev->ofdev.dev.power.power_state = 0; 1805 mdev->ofdev.dev.power.power_state.event = PM_EVENT_ON;
1806 1806
1807 return 0; 1807 return 0;
1808} 1808}
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
new file mode 100644
index 000000000000..f97e3afa97d9
--- /dev/null
+++ b/drivers/scsi/sata_mv.c
@@ -0,0 +1,843 @@
1/*
2 * sata_mv.c - Marvell SATA support
3 *
4 * Copyright 2005: EMC Corporation, all rights reserved.
5 *
6 * Please ALWAYS copy linux-ide@vger.kernel.org on emails.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
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.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/pci.h>
26#include <linux/init.h>
27#include <linux/blkdev.h>
28#include <linux/delay.h>
29#include <linux/interrupt.h>
30#include <linux/sched.h>
31#include <linux/dma-mapping.h>
32#include "scsi.h"
33#include <scsi/scsi_host.h>
34#include <linux/libata.h>
35#include <asm/io.h>
36
37#define DRV_NAME "sata_mv"
38#define DRV_VERSION "0.12"
39
40enum {
41 /* BAR's are enumerated in terms of pci_resource_start() terms */
42 MV_PRIMARY_BAR = 0, /* offset 0x10: memory space */
43 MV_IO_BAR = 2, /* offset 0x18: IO space */
44 MV_MISC_BAR = 3, /* offset 0x1c: FLASH, NVRAM, SRAM */
45
46 MV_MAJOR_REG_AREA_SZ = 0x10000, /* 64KB */
47 MV_MINOR_REG_AREA_SZ = 0x2000, /* 8KB */
48
49 MV_PCI_REG_BASE = 0,
50 MV_IRQ_COAL_REG_BASE = 0x18000, /* 6xxx part only */
51 MV_SATAHC0_REG_BASE = 0x20000,
52
53 MV_PCI_REG_SZ = MV_MAJOR_REG_AREA_SZ,
54 MV_SATAHC_REG_SZ = MV_MAJOR_REG_AREA_SZ,
55 MV_SATAHC_ARBTR_REG_SZ = MV_MINOR_REG_AREA_SZ, /* arbiter */
56 MV_PORT_REG_SZ = MV_MINOR_REG_AREA_SZ,
57
58 MV_Q_CT = 32,
59 MV_CRQB_SZ = 32,
60 MV_CRPB_SZ = 8,
61
62 MV_DMA_BOUNDARY = 0xffffffffU,
63 SATAHC_MASK = (~(MV_SATAHC_REG_SZ - 1)),
64
65 MV_PORTS_PER_HC = 4,
66 /* == (port / MV_PORTS_PER_HC) to determine HC from 0-7 port */
67 MV_PORT_HC_SHIFT = 2,
68 /* == (port % MV_PORTS_PER_HC) to determine port from 0-7 port */
69 MV_PORT_MASK = 3,
70
71 /* Host Flags */
72 MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */
73 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */
74 MV_FLAG_BDMA = (1 << 28), /* Basic DMA */
75
76 chip_504x = 0,
77 chip_508x = 1,
78 chip_604x = 2,
79 chip_608x = 3,
80
81 /* PCI interface registers */
82
83 PCI_MAIN_CMD_STS_OFS = 0xd30,
84 STOP_PCI_MASTER = (1 << 2),
85 PCI_MASTER_EMPTY = (1 << 3),
86 GLOB_SFT_RST = (1 << 4),
87
88 PCI_IRQ_CAUSE_OFS = 0x1d58,
89 PCI_IRQ_MASK_OFS = 0x1d5c,
90 PCI_UNMASK_ALL_IRQS = 0x7fffff, /* bits 22-0 */
91
92 HC_MAIN_IRQ_CAUSE_OFS = 0x1d60,
93 HC_MAIN_IRQ_MASK_OFS = 0x1d64,
94 PORT0_ERR = (1 << 0), /* shift by port # */
95 PORT0_DONE = (1 << 1), /* shift by port # */
96 HC0_IRQ_PEND = 0x1ff, /* bits 0-8 = HC0's ports */
97 HC_SHIFT = 9, /* bits 9-17 = HC1's ports */
98 PCI_ERR = (1 << 18),
99 TRAN_LO_DONE = (1 << 19), /* 6xxx: IRQ coalescing */
100 TRAN_HI_DONE = (1 << 20), /* 6xxx: IRQ coalescing */
101 PORTS_0_7_COAL_DONE = (1 << 21), /* 6xxx: IRQ coalescing */
102 GPIO_INT = (1 << 22),
103 SELF_INT = (1 << 23),
104 TWSI_INT = (1 << 24),
105 HC_MAIN_RSVD = (0x7f << 25), /* bits 31-25 */
106 HC_MAIN_MASKED_IRQS = (TRAN_LO_DONE | TRAN_HI_DONE |
107 PORTS_0_7_COAL_DONE | GPIO_INT | TWSI_INT |
108 HC_MAIN_RSVD),
109
110 /* SATAHC registers */
111 HC_CFG_OFS = 0,
112
113 HC_IRQ_CAUSE_OFS = 0x14,
114 CRBP_DMA_DONE = (1 << 0), /* shift by port # */
115 HC_IRQ_COAL = (1 << 4), /* IRQ coalescing */
116 DEV_IRQ = (1 << 8), /* shift by port # */
117
118 /* Shadow block registers */
119 SHD_PIO_DATA_OFS = 0x100,
120 SHD_FEA_ERR_OFS = 0x104,
121 SHD_SECT_CNT_OFS = 0x108,
122 SHD_LBA_L_OFS = 0x10C,
123 SHD_LBA_M_OFS = 0x110,
124 SHD_LBA_H_OFS = 0x114,
125 SHD_DEV_HD_OFS = 0x118,
126 SHD_CMD_STA_OFS = 0x11C,
127 SHD_CTL_AST_OFS = 0x120,
128
129 /* SATA registers */
130 SATA_STATUS_OFS = 0x300, /* ctrl, err regs follow status */
131 SATA_ACTIVE_OFS = 0x350,
132
133 /* Port registers */
134 EDMA_CFG_OFS = 0,
135
136 EDMA_ERR_IRQ_CAUSE_OFS = 0x8,
137 EDMA_ERR_IRQ_MASK_OFS = 0xc,
138 EDMA_ERR_D_PAR = (1 << 0),
139 EDMA_ERR_PRD_PAR = (1 << 1),
140 EDMA_ERR_DEV = (1 << 2),
141 EDMA_ERR_DEV_DCON = (1 << 3),
142 EDMA_ERR_DEV_CON = (1 << 4),
143 EDMA_ERR_SERR = (1 << 5),
144 EDMA_ERR_SELF_DIS = (1 << 7),
145 EDMA_ERR_BIST_ASYNC = (1 << 8),
146 EDMA_ERR_CRBQ_PAR = (1 << 9),
147 EDMA_ERR_CRPB_PAR = (1 << 10),
148 EDMA_ERR_INTRL_PAR = (1 << 11),
149 EDMA_ERR_IORDY = (1 << 12),
150 EDMA_ERR_LNK_CTRL_RX = (0xf << 13),
151 EDMA_ERR_LNK_CTRL_RX_2 = (1 << 15),
152 EDMA_ERR_LNK_DATA_RX = (0xf << 17),
153 EDMA_ERR_LNK_CTRL_TX = (0x1f << 21),
154 EDMA_ERR_LNK_DATA_TX = (0x1f << 26),
155 EDMA_ERR_TRANS_PROTO = (1 << 31),
156 EDMA_ERR_FATAL = (EDMA_ERR_D_PAR | EDMA_ERR_PRD_PAR |
157 EDMA_ERR_DEV_DCON | EDMA_ERR_CRBQ_PAR |
158 EDMA_ERR_CRPB_PAR | EDMA_ERR_INTRL_PAR |
159 EDMA_ERR_IORDY | EDMA_ERR_LNK_CTRL_RX_2 |
160 EDMA_ERR_LNK_DATA_RX |
161 EDMA_ERR_LNK_DATA_TX |
162 EDMA_ERR_TRANS_PROTO),
163
164 EDMA_CMD_OFS = 0x28,
165 EDMA_EN = (1 << 0),
166 EDMA_DS = (1 << 1),
167 ATA_RST = (1 << 2),
168
169 /* BDMA is 6xxx part only */
170 BDMA_CMD_OFS = 0x224,
171 BDMA_START = (1 << 0),
172
173 MV_UNDEF = 0,
174};
175
176struct mv_port_priv {
177
178};
179
180struct mv_host_priv {
181
182};
183
184static void mv_irq_clear(struct ata_port *ap);
185static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in);
186static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val);
187static void mv_phy_reset(struct ata_port *ap);
188static int mv_master_reset(void __iomem *mmio_base);
189static irqreturn_t mv_interrupt(int irq, void *dev_instance,
190 struct pt_regs *regs);
191static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
192
193static Scsi_Host_Template mv_sht = {
194 .module = THIS_MODULE,
195 .name = DRV_NAME,
196 .ioctl = ata_scsi_ioctl,
197 .queuecommand = ata_scsi_queuecmd,
198 .eh_strategy_handler = ata_scsi_error,
199 .can_queue = ATA_DEF_QUEUE,
200 .this_id = ATA_SHT_THIS_ID,
201 .sg_tablesize = MV_UNDEF,
202 .max_sectors = ATA_MAX_SECTORS,
203 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
204 .emulated = ATA_SHT_EMULATED,
205 .use_clustering = MV_UNDEF,
206 .proc_name = DRV_NAME,
207 .dma_boundary = MV_DMA_BOUNDARY,
208 .slave_configure = ata_scsi_slave_config,
209 .bios_param = ata_std_bios_param,
210 .ordered_flush = 1,
211};
212
213static struct ata_port_operations mv_ops = {
214 .port_disable = ata_port_disable,
215
216 .tf_load = ata_tf_load,
217 .tf_read = ata_tf_read,
218 .check_status = ata_check_status,
219 .exec_command = ata_exec_command,
220 .dev_select = ata_std_dev_select,
221
222 .phy_reset = mv_phy_reset,
223
224 .qc_prep = ata_qc_prep,
225 .qc_issue = ata_qc_issue_prot,
226
227 .eng_timeout = ata_eng_timeout,
228
229 .irq_handler = mv_interrupt,
230 .irq_clear = mv_irq_clear,
231
232 .scr_read = mv_scr_read,
233 .scr_write = mv_scr_write,
234
235 .port_start = ata_port_start,
236 .port_stop = ata_port_stop,
237 .host_stop = ata_host_stop,
238};
239
240static struct ata_port_info mv_port_info[] = {
241 { /* chip_504x */
242 .sht = &mv_sht,
243 .host_flags = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
244 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO),
245 .pio_mask = 0x1f, /* pio4-0 */
246 .udma_mask = 0, /* 0x7f (udma6-0 disabled for now) */
247 .port_ops = &mv_ops,
248 },
249 { /* chip_508x */
250 .sht = &mv_sht,
251 .host_flags = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
252 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
253 MV_FLAG_DUAL_HC),
254 .pio_mask = 0x1f, /* pio4-0 */
255 .udma_mask = 0, /* 0x7f (udma6-0 disabled for now) */
256 .port_ops = &mv_ops,
257 },
258 { /* chip_604x */
259 .sht = &mv_sht,
260 .host_flags = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
261 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
262 MV_FLAG_IRQ_COALESCE | MV_FLAG_BDMA),
263 .pio_mask = 0x1f, /* pio4-0 */
264 .udma_mask = 0, /* 0x7f (udma6-0 disabled for now) */
265 .port_ops = &mv_ops,
266 },
267 { /* chip_608x */
268 .sht = &mv_sht,
269 .host_flags = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
270 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
271 MV_FLAG_IRQ_COALESCE | MV_FLAG_DUAL_HC |
272 MV_FLAG_BDMA),
273 .pio_mask = 0x1f, /* pio4-0 */
274 .udma_mask = 0, /* 0x7f (udma6-0 disabled for now) */
275 .port_ops = &mv_ops,
276 },
277};
278
279static struct pci_device_id mv_pci_tbl[] = {
280 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5040), 0, 0, chip_504x},
281 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5041), 0, 0, chip_504x},
282 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5080), 0, 0, chip_508x},
283 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5081), 0, 0, chip_508x},
284
285 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6040), 0, 0, chip_604x},
286 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6041), 0, 0, chip_604x},
287 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6080), 0, 0, chip_608x},
288 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6081), 0, 0, chip_608x},
289 {} /* terminate list */
290};
291
292static struct pci_driver mv_pci_driver = {
293 .name = DRV_NAME,
294 .id_table = mv_pci_tbl,
295 .probe = mv_init_one,
296 .remove = ata_pci_remove_one,
297};
298
299/*
300 * Functions
301 */
302
303static inline void writelfl(unsigned long data, void __iomem *addr)
304{
305 writel(data, addr);
306 (void) readl(addr); /* flush to avoid PCI posted write */
307}
308
309static inline void __iomem *mv_port_addr_to_hc_base(void __iomem *port_mmio)
310{
311 return ((void __iomem *)((unsigned long)port_mmio &
312 (unsigned long)SATAHC_MASK));
313}
314
315static inline void __iomem *mv_hc_base(void __iomem *base, unsigned int hc)
316{
317 return (base + MV_SATAHC0_REG_BASE + (hc * MV_SATAHC_REG_SZ));
318}
319
320static inline void __iomem *mv_port_base(void __iomem *base, unsigned int port)
321{
322 return (mv_hc_base(base, port >> MV_PORT_HC_SHIFT) +
323 MV_SATAHC_ARBTR_REG_SZ +
324 ((port & MV_PORT_MASK) * MV_PORT_REG_SZ));
325}
326
327static inline void __iomem *mv_ap_base(struct ata_port *ap)
328{
329 return mv_port_base(ap->host_set->mmio_base, ap->port_no);
330}
331
332static inline int mv_get_hc_count(unsigned long flags)
333{
334 return ((flags & MV_FLAG_DUAL_HC) ? 2 : 1);
335}
336
337static inline int mv_is_edma_active(struct ata_port *ap)
338{
339 void __iomem *port_mmio = mv_ap_base(ap);
340 return (EDMA_EN & readl(port_mmio + EDMA_CMD_OFS));
341}
342
343static inline int mv_port_bdma_capable(struct ata_port *ap)
344{
345 return (ap->flags & MV_FLAG_BDMA);
346}
347
348static void mv_irq_clear(struct ata_port *ap)
349{
350}
351
352static unsigned int mv_scr_offset(unsigned int sc_reg_in)
353{
354 unsigned int ofs;
355
356 switch (sc_reg_in) {
357 case SCR_STATUS:
358 case SCR_CONTROL:
359 case SCR_ERROR:
360 ofs = SATA_STATUS_OFS + (sc_reg_in * sizeof(u32));
361 break;
362 case SCR_ACTIVE:
363 ofs = SATA_ACTIVE_OFS; /* active is not with the others */
364 break;
365 default:
366 ofs = 0xffffffffU;
367 break;
368 }
369 return ofs;
370}
371
372static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in)
373{
374 unsigned int ofs = mv_scr_offset(sc_reg_in);
375
376 if (0xffffffffU != ofs) {
377 return readl(mv_ap_base(ap) + ofs);
378 } else {
379 return (u32) ofs;
380 }
381}
382
383static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
384{
385 unsigned int ofs = mv_scr_offset(sc_reg_in);
386
387 if (0xffffffffU != ofs) {
388 writelfl(val, mv_ap_base(ap) + ofs);
389 }
390}
391
392static int mv_master_reset(void __iomem *mmio_base)
393{
394 void __iomem *reg = mmio_base + PCI_MAIN_CMD_STS_OFS;
395 int i, rc = 0;
396 u32 t;
397
398 VPRINTK("ENTER\n");
399
400 /* Following procedure defined in PCI "main command and status
401 * register" table.
402 */
403 t = readl(reg);
404 writel(t | STOP_PCI_MASTER, reg);
405
406 for (i = 0; i < 100; i++) {
407 msleep(10);
408 t = readl(reg);
409 if (PCI_MASTER_EMPTY & t) {
410 break;
411 }
412 }
413 if (!(PCI_MASTER_EMPTY & t)) {
414 printk(KERN_ERR DRV_NAME "PCI master won't flush\n");
415 rc = 1; /* broken HW? */
416 goto done;
417 }
418
419 /* set reset */
420 i = 5;
421 do {
422 writel(t | GLOB_SFT_RST, reg);
423 t = readl(reg);
424 udelay(1);
425 } while (!(GLOB_SFT_RST & t) && (i-- > 0));
426
427 if (!(GLOB_SFT_RST & t)) {
428 printk(KERN_ERR DRV_NAME "can't set global reset\n");
429 rc = 1; /* broken HW? */
430 goto done;
431 }
432
433 /* clear reset */
434 i = 5;
435 do {
436 writel(t & ~GLOB_SFT_RST, reg);
437 t = readl(reg);
438 udelay(1);
439 } while ((GLOB_SFT_RST & t) && (i-- > 0));
440
441 if (GLOB_SFT_RST & t) {
442 printk(KERN_ERR DRV_NAME "can't clear global reset\n");
443 rc = 1; /* broken HW? */
444 }
445
446 done:
447 VPRINTK("EXIT, rc = %i\n", rc);
448 return rc;
449}
450
451static void mv_err_intr(struct ata_port *ap)
452{
453 void __iomem *port_mmio;
454 u32 edma_err_cause, serr = 0;
455
456 /* bug here b/c we got an err int on a port we don't know about,
457 * so there's no way to clear it
458 */
459 BUG_ON(NULL == ap);
460 port_mmio = mv_ap_base(ap);
461
462 edma_err_cause = readl(port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
463
464 if (EDMA_ERR_SERR & edma_err_cause) {
465 serr = scr_read(ap, SCR_ERROR);
466 scr_write_flush(ap, SCR_ERROR, serr);
467 }
468 DPRINTK("port %u error; EDMA err cause: 0x%08x SERR: 0x%08x\n",
469 ap->port_no, edma_err_cause, serr);
470
471 /* Clear EDMA now that SERR cleanup done */
472 writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
473
474 /* check for fatal here and recover if needed */
475 if (EDMA_ERR_FATAL & edma_err_cause) {
476 mv_phy_reset(ap);
477 }
478}
479
480/* Handle any outstanding interrupts in a single SATAHC
481 */
482static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
483 unsigned int hc)
484{
485 void __iomem *mmio = host_set->mmio_base;
486 void __iomem *hc_mmio = mv_hc_base(mmio, hc);
487 struct ata_port *ap;
488 struct ata_queued_cmd *qc;
489 u32 hc_irq_cause;
490 int shift, port, port0, hard_port;
491 u8 ata_status;
492
493 if (hc == 0) {
494 port0 = 0;
495 } else {
496 port0 = MV_PORTS_PER_HC;
497 }
498
499 /* we'll need the HC success int register in most cases */
500 hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS);
501 if (hc_irq_cause) {
502 writelfl(0, hc_mmio + HC_IRQ_CAUSE_OFS);
503 }
504
505 VPRINTK("ENTER, hc%u relevant=0x%08x HC IRQ cause=0x%08x\n",
506 hc,relevant,hc_irq_cause);
507
508 for (port = port0; port < port0 + MV_PORTS_PER_HC; port++) {
509 ap = host_set->ports[port];
510 hard_port = port & MV_PORT_MASK; /* range 0-3 */
511 ata_status = 0xffU;
512
513 if (((CRBP_DMA_DONE | DEV_IRQ) << hard_port) & hc_irq_cause) {
514 BUG_ON(NULL == ap);
515 /* rcv'd new resp, basic DMA complete, or ATA IRQ */
516 /* This is needed to clear the ATA INTRQ.
517 * FIXME: don't read the status reg in EDMA mode!
518 */
519 ata_status = readb((void __iomem *)
520 ap->ioaddr.status_addr);
521 }
522
523 shift = port * 2;
524 if (port >= MV_PORTS_PER_HC) {
525 shift++; /* skip bit 8 in the HC Main IRQ reg */
526 }
527 if ((PORT0_ERR << shift) & relevant) {
528 mv_err_intr(ap);
529 /* FIXME: smart to OR in ATA_ERR? */
530 ata_status = readb((void __iomem *)
531 ap->ioaddr.status_addr) | ATA_ERR;
532 }
533
534 if (ap) {
535 qc = ata_qc_from_tag(ap, ap->active_tag);
536 if (NULL != qc) {
537 VPRINTK("port %u IRQ found for qc, "
538 "ata_status 0x%x\n", port,ata_status);
539 BUG_ON(0xffU == ata_status);
540 /* mark qc status appropriately */
541 ata_qc_complete(qc, ata_status);
542 }
543 }
544 }
545 VPRINTK("EXIT\n");
546}
547
548static irqreturn_t mv_interrupt(int irq, void *dev_instance,
549 struct pt_regs *regs)
550{
551 struct ata_host_set *host_set = dev_instance;
552 unsigned int hc, handled = 0, n_hcs;
553 void __iomem *mmio;
554 u32 irq_stat;
555
556 mmio = host_set->mmio_base;
557 irq_stat = readl(mmio + HC_MAIN_IRQ_CAUSE_OFS);
558 n_hcs = mv_get_hc_count(host_set->ports[0]->flags);
559
560 /* check the cases where we either have nothing pending or have read
561 * a bogus register value which can indicate HW removal or PCI fault
562 */
563 if (!irq_stat || (0xffffffffU == irq_stat)) {
564 return IRQ_NONE;
565 }
566
567 spin_lock(&host_set->lock);
568
569 for (hc = 0; hc < n_hcs; hc++) {
570 u32 relevant = irq_stat & (HC0_IRQ_PEND << (hc * HC_SHIFT));
571 if (relevant) {
572 mv_host_intr(host_set, relevant, hc);
573 handled = 1;
574 }
575 }
576 if (PCI_ERR & irq_stat) {
577 /* FIXME: these are all masked by default, but still need
578 * to recover from them properly.
579 */
580 }
581
582 spin_unlock(&host_set->lock);
583
584 return IRQ_RETVAL(handled);
585}
586
587static void mv_phy_reset(struct ata_port *ap)
588{
589 void __iomem *port_mmio = mv_ap_base(ap);
590 struct ata_taskfile tf;
591 struct ata_device *dev = &ap->device[0];
592 u32 edma = 0, bdma;
593
594 VPRINTK("ENTER, port %u, mmio 0x%p\n", ap->port_no, port_mmio);
595
596 edma = readl(port_mmio + EDMA_CMD_OFS);
597 if (EDMA_EN & edma) {
598 /* disable EDMA if active */
599 edma &= ~EDMA_EN;
600 writelfl(edma | EDMA_DS, port_mmio + EDMA_CMD_OFS);
601 udelay(1);
602 } else if (mv_port_bdma_capable(ap) &&
603 (bdma = readl(port_mmio + BDMA_CMD_OFS)) & BDMA_START) {
604 /* disable BDMA if active */
605 writelfl(bdma & ~BDMA_START, port_mmio + BDMA_CMD_OFS);
606 }
607
608 writelfl(edma | ATA_RST, port_mmio + EDMA_CMD_OFS);
609 udelay(25); /* allow reset propagation */
610
611 /* Spec never mentions clearing the bit. Marvell's driver does
612 * clear the bit, however.
613 */
614 writelfl(edma & ~ATA_RST, port_mmio + EDMA_CMD_OFS);
615
616 VPRINTK("Done. Now calling __sata_phy_reset()\n");
617
618 /* proceed to init communications via the scr_control reg */
619 __sata_phy_reset(ap);
620
621 if (ap->flags & ATA_FLAG_PORT_DISABLED) {
622 VPRINTK("Port disabled pre-sig. Exiting.\n");
623 return;
624 }
625
626 tf.lbah = readb((void __iomem *) ap->ioaddr.lbah_addr);
627 tf.lbam = readb((void __iomem *) ap->ioaddr.lbam_addr);
628 tf.lbal = readb((void __iomem *) ap->ioaddr.lbal_addr);
629 tf.nsect = readb((void __iomem *) ap->ioaddr.nsect_addr);
630
631 dev->class = ata_dev_classify(&tf);
632 if (!ata_dev_present(dev)) {
633 VPRINTK("Port disabled post-sig: No device present.\n");
634 ata_port_disable(ap);
635 }
636 VPRINTK("EXIT\n");
637}
638
639static void mv_port_init(struct ata_ioports *port, unsigned long base)
640{
641 /* PIO related setup */
642 port->data_addr = base + SHD_PIO_DATA_OFS;
643 port->error_addr = port->feature_addr = base + SHD_FEA_ERR_OFS;
644 port->nsect_addr = base + SHD_SECT_CNT_OFS;
645 port->lbal_addr = base + SHD_LBA_L_OFS;
646 port->lbam_addr = base + SHD_LBA_M_OFS;
647 port->lbah_addr = base + SHD_LBA_H_OFS;
648 port->device_addr = base + SHD_DEV_HD_OFS;
649 port->status_addr = port->command_addr = base + SHD_CMD_STA_OFS;
650 port->altstatus_addr = port->ctl_addr = base + SHD_CTL_AST_OFS;
651 /* unused */
652 port->cmd_addr = port->bmdma_addr = port->scr_addr = 0;
653
654 /* unmask all EDMA error interrupts */
655 writel(~0, (void __iomem *)base + EDMA_ERR_IRQ_MASK_OFS);
656
657 VPRINTK("EDMA cfg=0x%08x EDMA IRQ err cause/mask=0x%08x/0x%08x\n",
658 readl((void __iomem *)base + EDMA_CFG_OFS),
659 readl((void __iomem *)base + EDMA_ERR_IRQ_CAUSE_OFS),
660 readl((void __iomem *)base + EDMA_ERR_IRQ_MASK_OFS));
661}
662
663static int mv_host_init(struct ata_probe_ent *probe_ent)
664{
665 int rc = 0, n_hc, port, hc;
666 void __iomem *mmio = probe_ent->mmio_base;
667 void __iomem *port_mmio;
668
669 if (mv_master_reset(probe_ent->mmio_base)) {
670 rc = 1;
671 goto done;
672 }
673
674 n_hc = mv_get_hc_count(probe_ent->host_flags);
675 probe_ent->n_ports = MV_PORTS_PER_HC * n_hc;
676
677 for (port = 0; port < probe_ent->n_ports; port++) {
678 port_mmio = mv_port_base(mmio, port);
679 mv_port_init(&probe_ent->port[port], (unsigned long)port_mmio);
680 }
681
682 for (hc = 0; hc < n_hc; hc++) {
683 VPRINTK("HC%i: HC config=0x%08x HC IRQ cause=0x%08x\n", hc,
684 readl(mv_hc_base(mmio, hc) + HC_CFG_OFS),
685 readl(mv_hc_base(mmio, hc) + HC_IRQ_CAUSE_OFS));
686 }
687
688 writel(~HC_MAIN_MASKED_IRQS, mmio + HC_MAIN_IRQ_MASK_OFS);
689 writel(PCI_UNMASK_ALL_IRQS, mmio + PCI_IRQ_MASK_OFS);
690
691 VPRINTK("HC MAIN IRQ cause/mask=0x%08x/0x%08x "
692 "PCI int cause/mask=0x%08x/0x%08x\n",
693 readl(mmio + HC_MAIN_IRQ_CAUSE_OFS),
694 readl(mmio + HC_MAIN_IRQ_MASK_OFS),
695 readl(mmio + PCI_IRQ_CAUSE_OFS),
696 readl(mmio + PCI_IRQ_MASK_OFS));
697
698 done:
699 return rc;
700}
701
702/* move to PCI layer, integrate w/ MSI stuff */
703static void pci_intx(struct pci_dev *pdev, int enable)
704{
705 u16 pci_command, new;
706
707 pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
708
709 if (enable)
710 new = pci_command & ~PCI_COMMAND_INTX_DISABLE;
711 else
712 new = pci_command | PCI_COMMAND_INTX_DISABLE;
713
714 if (new != pci_command)
715 pci_write_config_word(pdev, PCI_COMMAND, pci_command);
716}
717
718static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
719{
720 static int printed_version = 0;
721 struct ata_probe_ent *probe_ent = NULL;
722 struct mv_host_priv *hpriv;
723 unsigned int board_idx = (unsigned int)ent->driver_data;
724 void __iomem *mmio_base;
725 int pci_dev_busy = 0;
726 int rc;
727
728 if (!printed_version++) {
729 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
730 }
731
732 VPRINTK("ENTER for PCI Bus:Slot.Func=%u:%u.%u\n", pdev->bus->number,
733 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
734
735 rc = pci_enable_device(pdev);
736 if (rc) {
737 return rc;
738 }
739
740 rc = pci_request_regions(pdev, DRV_NAME);
741 if (rc) {
742 pci_dev_busy = 1;
743 goto err_out;
744 }
745
746 pci_intx(pdev, 1);
747
748 probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
749 if (probe_ent == NULL) {
750 rc = -ENOMEM;
751 goto err_out_regions;
752 }
753
754 memset(probe_ent, 0, sizeof(*probe_ent));
755 probe_ent->dev = pci_dev_to_dev(pdev);
756 INIT_LIST_HEAD(&probe_ent->node);
757
758 mmio_base = ioremap_nocache(pci_resource_start(pdev, MV_PRIMARY_BAR),
759 pci_resource_len(pdev, MV_PRIMARY_BAR));
760 if (mmio_base == NULL) {
761 rc = -ENOMEM;
762 goto err_out_free_ent;
763 }
764
765 hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL);
766 if (!hpriv) {
767 rc = -ENOMEM;
768 goto err_out_iounmap;
769 }
770 memset(hpriv, 0, sizeof(*hpriv));
771
772 probe_ent->sht = mv_port_info[board_idx].sht;
773 probe_ent->host_flags = mv_port_info[board_idx].host_flags;
774 probe_ent->pio_mask = mv_port_info[board_idx].pio_mask;
775 probe_ent->udma_mask = mv_port_info[board_idx].udma_mask;
776 probe_ent->port_ops = mv_port_info[board_idx].port_ops;
777
778 probe_ent->irq = pdev->irq;
779 probe_ent->irq_flags = SA_SHIRQ;
780 probe_ent->mmio_base = mmio_base;
781 probe_ent->private_data = hpriv;
782
783 /* initialize adapter */
784 rc = mv_host_init(probe_ent);
785 if (rc) {
786 goto err_out_hpriv;
787 }
788/* mv_print_info(probe_ent); */
789
790 {
791 int b, w;
792 u32 dw[4]; /* hold a line of 16b */
793 VPRINTK("PCI config space:\n");
794 for (b = 0; b < 0x40; ) {
795 for (w = 0; w < 4; w++) {
796 (void) pci_read_config_dword(pdev,b,&dw[w]);
797 b += sizeof(*dw);
798 }
799 VPRINTK("%08x %08x %08x %08x\n",
800 dw[0],dw[1],dw[2],dw[3]);
801 }
802 }
803
804 /* FIXME: check ata_device_add return value */
805 ata_device_add(probe_ent);
806 kfree(probe_ent);
807
808 return 0;
809
810 err_out_hpriv:
811 kfree(hpriv);
812 err_out_iounmap:
813 iounmap(mmio_base);
814 err_out_free_ent:
815 kfree(probe_ent);
816 err_out_regions:
817 pci_release_regions(pdev);
818 err_out:
819 if (!pci_dev_busy) {
820 pci_disable_device(pdev);
821 }
822
823 return rc;
824}
825
826static int __init mv_init(void)
827{
828 return pci_module_init(&mv_pci_driver);
829}
830
831static void __exit mv_exit(void)
832{
833 pci_unregister_driver(&mv_pci_driver);
834}
835
836MODULE_AUTHOR("Brett Russ");
837MODULE_DESCRIPTION("SCSI low-level driver for Marvell SATA controllers");
838MODULE_LICENSE("GPL");
839MODULE_DEVICE_TABLE(pci, mv_pci_tbl);
840MODULE_VERSION(DRV_VERSION);
841
842module_init(mv_init);
843module_exit(mv_exit);
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index b0403ccd8a25..a1d62dee3be6 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -4,21 +4,37 @@
4 * Copyright 2004 NVIDIA Corp. All rights reserved. 4 * Copyright 2004 NVIDIA Corp. All rights reserved.
5 * Copyright 2004 Andrew Chew 5 * Copyright 2004 Andrew Chew
6 * 6 *
7 * The contents of this file are subject to the Open
8 * Software License version 1.1 that can be found at
9 * http://www.opensource.org/licenses/osl-1.1.txt and is included herein
10 * by reference.
11 * 7 *
12 * Alternatively, the contents of this file may be used under the terms 8 * This program is free software; you can redistribute it and/or modify
13 * of the GNU General Public License version 2 (the "GPL") as distributed 9 * it under the terms of the GNU General Public License as published by
14 * in the kernel source COPYING file, in which case the provisions of 10 * the Free Software Foundation; either version 2, or (at your option)
15 * the GPL are applicable instead of the above. If you wish to allow 11 * any later version.
16 * the use of your version of this file only under the terms of the 12 *
17 * GPL and not to allow others to use your version of this file under 13 * This program is distributed in the hope that it will be useful,
18 * the OSL, indicate your decision by deleting the provisions above and 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * replace them with the notice and other provisions required by the GPL. 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * If you do not delete the provisions above, a recipient may use your 16 * GNU General Public License for more details.
21 * version of this file under either the OSL or the GPL. 17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 *
23 * libata documentation is available via 'make {ps|pdf}docs',
24 * as Documentation/DocBook/libata.*
25 *
26 * No hardware documentation available outside of NVIDIA.
27 * This driver programs the NVIDIA SATA controller in a similar
28 * fashion as with other PCI IDE BMDMA controllers, with a few
29 * NV-specific details such as register offsets, SATA phy location,
30 * hotplug info, etc.
31 *
32 *
33 * 0.08
34 * - Added support for MCP51 and MCP55.
35 *
36 * 0.07
37 * - Added support for RAID class code.
22 * 38 *
23 * 0.06 39 * 0.06
24 * - Added generic SATA support by using a pci_device_id that filters on 40 * - Added generic SATA support by using a pci_device_id that filters on
@@ -48,7 +64,7 @@
48#include <linux/libata.h> 64#include <linux/libata.h>
49 65
50#define DRV_NAME "sata_nv" 66#define DRV_NAME "sata_nv"
51#define DRV_VERSION "0.6" 67#define DRV_VERSION "0.8"
52 68
53#define NV_PORTS 2 69#define NV_PORTS 2
54#define NV_PIO_MASK 0x1f 70#define NV_PIO_MASK 0x1f
@@ -116,7 +132,9 @@ enum nv_host_type
116 GENERIC, 132 GENERIC,
117 NFORCE2, 133 NFORCE2,
118 NFORCE3, 134 NFORCE3,
119 CK804 135 CK804,
136 MCP51,
137 MCP55
120}; 138};
121 139
122static struct pci_device_id nv_pci_tbl[] = { 140static struct pci_device_id nv_pci_tbl[] = {
@@ -134,9 +152,18 @@ static struct pci_device_id nv_pci_tbl[] = {
134 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 }, 152 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
135 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2, 153 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2,
136 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 }, 154 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
155 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA,
156 PCI_ANY_ID, PCI_ANY_ID, 0, 0, MCP51 },
157 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2,
158 PCI_ANY_ID, PCI_ANY_ID, 0, 0, MCP51 },
159 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA,
160 PCI_ANY_ID, PCI_ANY_ID, 0, 0, MCP55 },
137 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, 161 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
138 PCI_ANY_ID, PCI_ANY_ID, 162 PCI_ANY_ID, PCI_ANY_ID,
139 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC }, 163 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC },
164 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
165 PCI_ANY_ID, PCI_ANY_ID,
166 PCI_CLASS_STORAGE_RAID<<8, 0xffff00, GENERIC },
140 { 0, } /* terminate list */ 167 { 0, } /* terminate list */
141}; 168};
142 169
@@ -274,7 +301,8 @@ static irqreturn_t nv_interrupt (int irq, void *dev_instance,
274 struct ata_port *ap; 301 struct ata_port *ap;
275 302
276 ap = host_set->ports[i]; 303 ap = host_set->ports[i];
277 if (ap && (!(ap->flags & ATA_FLAG_PORT_DISABLED))) { 304 if (ap &&
305 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) {
278 struct ata_queued_cmd *qc; 306 struct ata_queued_cmd *qc;
279 307
280 qc = ata_qc_from_tag(ap, ap->active_tag); 308 qc = ata_qc_from_tag(ap, ap->active_tag);
@@ -323,6 +351,7 @@ static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
323static void nv_host_stop (struct ata_host_set *host_set) 351static void nv_host_stop (struct ata_host_set *host_set)
324{ 352{
325 struct nv_host *host = host_set->private_data; 353 struct nv_host *host = host_set->private_data;
354 struct pci_dev *pdev = to_pci_dev(host_set->dev);
326 355
327 // Disable hotplug event interrupts. 356 // Disable hotplug event interrupts.
328 if (host->host_desc->disable_hotplug) 357 if (host->host_desc->disable_hotplug)
@@ -330,7 +359,8 @@ static void nv_host_stop (struct ata_host_set *host_set)
330 359
331 kfree(host); 360 kfree(host);
332 361
333 ata_host_stop(host_set); 362 if (host_set->mmio_base)
363 pci_iounmap(pdev, host_set->mmio_base);
334} 364}
335 365
336static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 366static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -392,8 +422,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
392 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) { 422 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) {
393 unsigned long base; 423 unsigned long base;
394 424
395 probe_ent->mmio_base = ioremap(pci_resource_start(pdev, 5), 425 probe_ent->mmio_base = pci_iomap(pdev, 5, 0);
396 pci_resource_len(pdev, 5));
397 if (probe_ent->mmio_base == NULL) { 426 if (probe_ent->mmio_base == NULL) {
398 rc = -EIO; 427 rc = -EIO;
399 goto err_out_free_host; 428 goto err_out_free_host;
@@ -429,7 +458,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
429 458
430err_out_iounmap: 459err_out_iounmap:
431 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) 460 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
432 iounmap(probe_ent->mmio_base); 461 pci_iounmap(pdev, probe_ent->mmio_base);
433err_out_free_host: 462err_out_free_host:
434 kfree(host); 463 kfree(host);
435err_out_free_ent: 464err_out_free_ent:
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index 919fb314ad10..538ad727bd2e 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -7,21 +7,26 @@
7 * 7 *
8 * Copyright 2003-2004 Red Hat, Inc. 8 * Copyright 2003-2004 Red Hat, Inc.
9 * 9 *
10 * The contents of this file are subject to the Open
11 * Software License version 1.1 that can be found at
12 * http://www.opensource.org/licenses/osl-1.1.txt and is included herein
13 * by reference.
14 * 10 *
15 * Alternatively, the contents of this file may be used under the terms 11 * This program is free software; you can redistribute it and/or modify
16 * of the GNU General Public License version 2 (the "GPL") as distributed 12 * it under the terms of the GNU General Public License as published by
17 * in the kernel source COPYING file, in which case the provisions of 13 * the Free Software Foundation; either version 2, or (at your option)
18 * the GPL are applicable instead of the above. If you wish to allow 14 * any later version.
19 * the use of your version of this file only under the terms of the 15 *
20 * GPL and not to allow others to use your version of this file under 16 * This program is distributed in the hope that it will be useful,
21 * the OSL, indicate your decision by deleting the provisions above and 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * replace them with the notice and other provisions required by the GPL. 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * If you do not delete the provisions above, a recipient may use your 19 * GNU General Public License for more details.
24 * version of this file under either the OSL or the GPL. 20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; see the file COPYING. If not, write to
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 *
26 * libata documentation is available via 'make {ps|pdf}docs',
27 * as Documentation/DocBook/libata.*
28 *
29 * Hardware information only available under NDA.
25 * 30 *
26 */ 31 */
27 32
@@ -79,13 +84,15 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r
79static void pdc_eng_timeout(struct ata_port *ap); 84static void pdc_eng_timeout(struct ata_port *ap);
80static int pdc_port_start(struct ata_port *ap); 85static int pdc_port_start(struct ata_port *ap);
81static void pdc_port_stop(struct ata_port *ap); 86static void pdc_port_stop(struct ata_port *ap);
82static void pdc_phy_reset(struct ata_port *ap); 87static void pdc_pata_phy_reset(struct ata_port *ap);
88static void pdc_sata_phy_reset(struct ata_port *ap);
83static void pdc_qc_prep(struct ata_queued_cmd *qc); 89static void pdc_qc_prep(struct ata_queued_cmd *qc);
84static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf); 90static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf);
85static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf); 91static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf);
86static void pdc_irq_clear(struct ata_port *ap); 92static void pdc_irq_clear(struct ata_port *ap);
87static int pdc_qc_issue_prot(struct ata_queued_cmd *qc); 93static int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
88 94
95
89static Scsi_Host_Template pdc_ata_sht = { 96static Scsi_Host_Template pdc_ata_sht = {
90 .module = THIS_MODULE, 97 .module = THIS_MODULE,
91 .name = DRV_NAME, 98 .name = DRV_NAME,
@@ -106,24 +113,48 @@ static Scsi_Host_Template pdc_ata_sht = {
106 .ordered_flush = 1, 113 .ordered_flush = 1,
107}; 114};
108 115
109static struct ata_port_operations pdc_ata_ops = { 116static struct ata_port_operations pdc_sata_ops = {
110 .port_disable = ata_port_disable, 117 .port_disable = ata_port_disable,
111 .tf_load = pdc_tf_load_mmio, 118 .tf_load = pdc_tf_load_mmio,
112 .tf_read = ata_tf_read, 119 .tf_read = ata_tf_read,
113 .check_status = ata_check_status, 120 .check_status = ata_check_status,
114 .exec_command = pdc_exec_command_mmio, 121 .exec_command = pdc_exec_command_mmio,
115 .dev_select = ata_std_dev_select, 122 .dev_select = ata_std_dev_select,
116 .phy_reset = pdc_phy_reset, 123
124 .phy_reset = pdc_sata_phy_reset,
125
117 .qc_prep = pdc_qc_prep, 126 .qc_prep = pdc_qc_prep,
118 .qc_issue = pdc_qc_issue_prot, 127 .qc_issue = pdc_qc_issue_prot,
119 .eng_timeout = pdc_eng_timeout, 128 .eng_timeout = pdc_eng_timeout,
120 .irq_handler = pdc_interrupt, 129 .irq_handler = pdc_interrupt,
121 .irq_clear = pdc_irq_clear, 130 .irq_clear = pdc_irq_clear,
131
122 .scr_read = pdc_sata_scr_read, 132 .scr_read = pdc_sata_scr_read,
123 .scr_write = pdc_sata_scr_write, 133 .scr_write = pdc_sata_scr_write,
124 .port_start = pdc_port_start, 134 .port_start = pdc_port_start,
125 .port_stop = pdc_port_stop, 135 .port_stop = pdc_port_stop,
126 .host_stop = ata_host_stop, 136 .host_stop = ata_pci_host_stop,
137};
138
139static struct ata_port_operations pdc_pata_ops = {
140 .port_disable = ata_port_disable,
141 .tf_load = pdc_tf_load_mmio,
142 .tf_read = ata_tf_read,
143 .check_status = ata_check_status,
144 .exec_command = pdc_exec_command_mmio,
145 .dev_select = ata_std_dev_select,
146
147 .phy_reset = pdc_pata_phy_reset,
148
149 .qc_prep = pdc_qc_prep,
150 .qc_issue = pdc_qc_issue_prot,
151 .eng_timeout = pdc_eng_timeout,
152 .irq_handler = pdc_interrupt,
153 .irq_clear = pdc_irq_clear,
154
155 .port_start = pdc_port_start,
156 .port_stop = pdc_port_stop,
157 .host_stop = ata_pci_host_stop,
127}; 158};
128 159
129static struct ata_port_info pdc_port_info[] = { 160static struct ata_port_info pdc_port_info[] = {
@@ -135,7 +166,7 @@ static struct ata_port_info pdc_port_info[] = {
135 .pio_mask = 0x1f, /* pio0-4 */ 166 .pio_mask = 0x1f, /* pio0-4 */
136 .mwdma_mask = 0x07, /* mwdma0-2 */ 167 .mwdma_mask = 0x07, /* mwdma0-2 */
137 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 168 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
138 .port_ops = &pdc_ata_ops, 169 .port_ops = &pdc_sata_ops,
139 }, 170 },
140 171
141 /* board_20319 */ 172 /* board_20319 */
@@ -146,7 +177,7 @@ static struct ata_port_info pdc_port_info[] = {
146 .pio_mask = 0x1f, /* pio0-4 */ 177 .pio_mask = 0x1f, /* pio0-4 */
147 .mwdma_mask = 0x07, /* mwdma0-2 */ 178 .mwdma_mask = 0x07, /* mwdma0-2 */
148 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 179 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
149 .port_ops = &pdc_ata_ops, 180 .port_ops = &pdc_sata_ops,
150 }, 181 },
151 182
152 /* board_20619 */ 183 /* board_20619 */
@@ -157,7 +188,7 @@ static struct ata_port_info pdc_port_info[] = {
157 .pio_mask = 0x1f, /* pio0-4 */ 188 .pio_mask = 0x1f, /* pio0-4 */
158 .mwdma_mask = 0x07, /* mwdma0-2 */ 189 .mwdma_mask = 0x07, /* mwdma0-2 */
159 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 190 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
160 .port_ops = &pdc_ata_ops, 191 .port_ops = &pdc_pata_ops,
161 }, 192 },
162}; 193};
163 194
@@ -181,6 +212,10 @@ static struct pci_device_id pdc_ata_pci_tbl[] = {
181 board_20319 }, 212 board_20319 },
182 { PCI_VENDOR_ID_PROMISE, 0x3319, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 213 { PCI_VENDOR_ID_PROMISE, 0x3319, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
183 board_20319 }, 214 board_20319 },
215 { PCI_VENDOR_ID_PROMISE, 0x3519, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
216 board_20319 },
217 { PCI_VENDOR_ID_PROMISE, 0x3d17, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
218 board_20319 },
184 { PCI_VENDOR_ID_PROMISE, 0x3d18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 219 { PCI_VENDOR_ID_PROMISE, 0x3d18, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
185 board_20319 }, 220 board_20319 },
186 221
@@ -248,7 +283,7 @@ static void pdc_port_stop(struct ata_port *ap)
248 283
249static void pdc_reset_port(struct ata_port *ap) 284static void pdc_reset_port(struct ata_port *ap)
250{ 285{
251 void *mmio = (void *) ap->ioaddr.cmd_addr + PDC_CTLSTAT; 286 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_CTLSTAT;
252 unsigned int i; 287 unsigned int i;
253 u32 tmp; 288 u32 tmp;
254 289
@@ -268,12 +303,23 @@ static void pdc_reset_port(struct ata_port *ap)
268 readl(mmio); /* flush */ 303 readl(mmio); /* flush */
269} 304}
270 305
271static void pdc_phy_reset(struct ata_port *ap) 306static void pdc_sata_phy_reset(struct ata_port *ap)
272{ 307{
273 pdc_reset_port(ap); 308 pdc_reset_port(ap);
274 sata_phy_reset(ap); 309 sata_phy_reset(ap);
275} 310}
276 311
312static void pdc_pata_phy_reset(struct ata_port *ap)
313{
314 /* FIXME: add cable detect. Don't assume 40-pin cable */
315 ap->cbl = ATA_CBL_PATA40;
316 ap->udma_mask &= ATA_UDMA_MASK_40C;
317
318 pdc_reset_port(ap);
319 ata_port_probe(ap);
320 ata_bus_reset(ap);
321}
322
277static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) 323static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
278{ 324{
279 if (sc_reg > SCR_CONTROL) 325 if (sc_reg > SCR_CONTROL)
@@ -321,11 +367,15 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc)
321 367
322static void pdc_eng_timeout(struct ata_port *ap) 368static void pdc_eng_timeout(struct ata_port *ap)
323{ 369{
370 struct ata_host_set *host_set = ap->host_set;
324 u8 drv_stat; 371 u8 drv_stat;
325 struct ata_queued_cmd *qc; 372 struct ata_queued_cmd *qc;
373 unsigned long flags;
326 374
327 DPRINTK("ENTER\n"); 375 DPRINTK("ENTER\n");
328 376
377 spin_lock_irqsave(&host_set->lock, flags);
378
329 qc = ata_qc_from_tag(ap, ap->active_tag); 379 qc = ata_qc_from_tag(ap, ap->active_tag);
330 if (!qc) { 380 if (!qc) {
331 printk(KERN_ERR "ata%u: BUG: timeout without command\n", 381 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
@@ -359,6 +409,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
359 } 409 }
360 410
361out: 411out:
412 spin_unlock_irqrestore(&host_set->lock, flags);
362 DPRINTK("EXIT\n"); 413 DPRINTK("EXIT\n");
363} 414}
364 415
@@ -368,7 +419,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap,
368 u8 status; 419 u8 status;
369 unsigned int handled = 0, have_err = 0; 420 unsigned int handled = 0, have_err = 0;
370 u32 tmp; 421 u32 tmp;
371 void *mmio = (void *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; 422 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL;
372 423
373 tmp = readl(mmio); 424 tmp = readl(mmio);
374 if (tmp & PDC_ERR_MASK) { 425 if (tmp & PDC_ERR_MASK) {
@@ -397,7 +448,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap,
397static void pdc_irq_clear(struct ata_port *ap) 448static void pdc_irq_clear(struct ata_port *ap)
398{ 449{
399 struct ata_host_set *host_set = ap->host_set; 450 struct ata_host_set *host_set = ap->host_set;
400 void *mmio = host_set->mmio_base; 451 void __iomem *mmio = host_set->mmio_base;
401 452
402 readl(mmio + PDC_INT_SEQMASK); 453 readl(mmio + PDC_INT_SEQMASK);
403} 454}
@@ -409,7 +460,7 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r
409 u32 mask = 0; 460 u32 mask = 0;
410 unsigned int i, tmp; 461 unsigned int i, tmp;
411 unsigned int handled = 0; 462 unsigned int handled = 0;
412 void *mmio_base; 463 void __iomem *mmio_base;
413 464
414 VPRINTK("ENTER\n"); 465 VPRINTK("ENTER\n");
415 466
@@ -441,7 +492,8 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r
441 VPRINTK("port %u\n", i); 492 VPRINTK("port %u\n", i);
442 ap = host_set->ports[i]; 493 ap = host_set->ports[i];
443 tmp = mask & (1 << (i + 1)); 494 tmp = mask & (1 << (i + 1));
444 if (tmp && ap && (!(ap->flags & ATA_FLAG_PORT_DISABLED))) { 495 if (tmp && ap &&
496 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) {
445 struct ata_queued_cmd *qc; 497 struct ata_queued_cmd *qc;
446 498
447 qc = ata_qc_from_tag(ap, ap->active_tag); 499 qc = ata_qc_from_tag(ap, ap->active_tag);
@@ -530,7 +582,7 @@ static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base)
530 582
531static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) 583static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
532{ 584{
533 void *mmio = pe->mmio_base; 585 void __iomem *mmio = pe->mmio_base;
534 u32 tmp; 586 u32 tmp;
535 587
536 /* 588 /*
@@ -573,7 +625,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
573 static int printed_version; 625 static int printed_version;
574 struct ata_probe_ent *probe_ent = NULL; 626 struct ata_probe_ent *probe_ent = NULL;
575 unsigned long base; 627 unsigned long base;
576 void *mmio_base; 628 void __iomem *mmio_base;
577 unsigned int board_idx = (unsigned int) ent->driver_data; 629 unsigned int board_idx = (unsigned int) ent->driver_data;
578 int pci_dev_busy = 0; 630 int pci_dev_busy = 0;
579 int rc; 631 int rc;
@@ -612,8 +664,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
612 probe_ent->dev = pci_dev_to_dev(pdev); 664 probe_ent->dev = pci_dev_to_dev(pdev);
613 INIT_LIST_HEAD(&probe_ent->node); 665 INIT_LIST_HEAD(&probe_ent->node);
614 666
615 mmio_base = ioremap(pci_resource_start(pdev, 3), 667 mmio_base = pci_iomap(pdev, 3, 0);
616 pci_resource_len(pdev, 3));
617 if (mmio_base == NULL) { 668 if (mmio_base == NULL) {
618 rc = -ENOMEM; 669 rc = -ENOMEM;
619 goto err_out_free_ent; 670 goto err_out_free_ent;
diff --git a/drivers/scsi/sata_promise.h b/drivers/scsi/sata_promise.h
index 6e7e96b9ee13..6ee5e190262d 100644
--- a/drivers/scsi/sata_promise.h
+++ b/drivers/scsi/sata_promise.h
@@ -3,21 +3,24 @@
3 * 3 *
4 * Copyright 2003-2004 Red Hat, Inc. 4 * Copyright 2003-2004 Red Hat, Inc.
5 * 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 * 6 *
11 * Alternatively, the contents of this file may be used under the terms 7 * This program is free software; you can redistribute it and/or modify
12 * of the GNU General Public License version 2 (the "GPL") as distributed 8 * it under the terms of the GNU General Public License as published by
13 * in the kernel source COPYING file, in which case the provisions of 9 * the Free Software Foundation; either version 2, or (at your option)
14 * the GPL are applicable instead of the above. If you wish to allow 10 * any later version.
15 * the use of your version of this file only under the terms of the 11 *
16 * GPL and not to allow others to use your version of this file under 12 * This program is distributed in the hope that it will be useful,
17 * the OSL, indicate your decision by deleting the provisions above and 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * replace them with the notice and other provisions required by the GPL. 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * If you do not delete the provisions above, a recipient may use your 15 * GNU General Public License for more details.
20 * version of this file under either the OSL or the GPL. 16 *
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.
20 *
21 *
22 * libata documentation is available via 'make {ps|pdf}docs',
23 * as Documentation/DocBook/libata.*
21 * 24 *
22 */ 25 */
23 26
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index 1383e8a28d72..ffcdeb68641c 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -6,21 +6,24 @@
6 * Copyright 2005 Pacific Digital Corporation. 6 * Copyright 2005 Pacific Digital Corporation.
7 * (OSL/GPL code release authorized by Jalil Fadavi). 7 * (OSL/GPL code release authorized by Jalil Fadavi).
8 * 8 *
9 * The contents of this file are subject to the Open
10 * Software License version 1.1 that can be found at
11 * http://www.opensource.org/licenses/osl-1.1.txt and is included herein
12 * by reference.
13 * 9 *
14 * Alternatively, the contents of this file may be used under the terms 10 * This program is free software; you can redistribute it and/or modify
15 * of the GNU General Public License version 2 (the "GPL") as distributed 11 * it under the terms of the GNU General Public License as published by
16 * in the kernel source COPYING file, in which case the provisions of 12 * the Free Software Foundation; either version 2, or (at your option)
17 * the GPL are applicable instead of the above. If you wish to allow 13 * any later version.
18 * the use of your version of this file only under the terms of the 14 *
19 * GPL and not to allow others to use your version of this file under 15 * This program is distributed in the hope that it will be useful,
20 * the OSL, indicate your decision by deleting the provisions above and 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * replace them with the notice and other provisions required by the GPL. 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * If you do not delete the provisions above, a recipient may use your 18 * GNU General Public License for more details.
23 * version of this file under either the OSL or the GPL. 19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; see the file COPYING. If not, write to
22 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *
25 * libata documentation is available via 'make {ps|pdf}docs',
26 * as Documentation/DocBook/libata.*
24 * 27 *
25 */ 28 */
26 29
@@ -117,7 +120,7 @@ static void qs_phy_reset(struct ata_port *ap);
117static void qs_qc_prep(struct ata_queued_cmd *qc); 120static void qs_qc_prep(struct ata_queued_cmd *qc);
118static int qs_qc_issue(struct ata_queued_cmd *qc); 121static int qs_qc_issue(struct ata_queued_cmd *qc);
119static int qs_check_atapi_dma(struct ata_queued_cmd *qc); 122static int qs_check_atapi_dma(struct ata_queued_cmd *qc);
120static void qs_bmdma_stop(struct ata_port *ap); 123static void qs_bmdma_stop(struct ata_queued_cmd *qc);
121static u8 qs_bmdma_status(struct ata_port *ap); 124static u8 qs_bmdma_status(struct ata_port *ap);
122static void qs_irq_clear(struct ata_port *ap); 125static void qs_irq_clear(struct ata_port *ap);
123static void qs_eng_timeout(struct ata_port *ap); 126static void qs_eng_timeout(struct ata_port *ap);
@@ -198,7 +201,7 @@ static int qs_check_atapi_dma(struct ata_queued_cmd *qc)
198 return 1; /* ATAPI DMA not supported */ 201 return 1; /* ATAPI DMA not supported */
199} 202}
200 203
201static void qs_bmdma_stop(struct ata_port *ap) 204static void qs_bmdma_stop(struct ata_queued_cmd *qc)
202{ 205{
203 /* nothing */ 206 /* nothing */
204} 207}
@@ -386,7 +389,8 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set)
386 DPRINTK("SFF=%08x%08x: sCHAN=%u sHST=%d sDST=%02x\n", 389 DPRINTK("SFF=%08x%08x: sCHAN=%u sHST=%d sDST=%02x\n",
387 sff1, sff0, port_no, sHST, sDST); 390 sff1, sff0, port_no, sHST, sDST);
388 handled = 1; 391 handled = 1;
389 if (ap && (!(ap->flags & ATA_FLAG_PORT_DISABLED))) { 392 if (ap && !(ap->flags &
393 (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) {
390 struct ata_queued_cmd *qc; 394 struct ata_queued_cmd *qc;
391 struct qs_port_priv *pp = ap->private_data; 395 struct qs_port_priv *pp = ap->private_data;
392 if (!pp || pp->state != qs_state_pkt) 396 if (!pp || pp->state != qs_state_pkt)
@@ -417,7 +421,8 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set)
417 for (port_no = 0; port_no < host_set->n_ports; ++port_no) { 421 for (port_no = 0; port_no < host_set->n_ports; ++port_no) {
418 struct ata_port *ap; 422 struct ata_port *ap;
419 ap = host_set->ports[port_no]; 423 ap = host_set->ports[port_no];
420 if (ap && (!(ap->flags & ATA_FLAG_PORT_DISABLED))) { 424 if (ap &&
425 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) {
421 struct ata_queued_cmd *qc; 426 struct ata_queued_cmd *qc;
422 struct qs_port_priv *pp = ap->private_data; 427 struct qs_port_priv *pp = ap->private_data;
423 if (!pp || pp->state != qs_state_mmio) 428 if (!pp || pp->state != qs_state_mmio)
@@ -431,7 +436,7 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set)
431 continue; 436 continue;
432 DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", 437 DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n",
433 ap->id, qc->tf.protocol, status); 438 ap->id, qc->tf.protocol, status);
434 439
435 /* complete taskfile transaction */ 440 /* complete taskfile transaction */
436 pp->state = qs_state_idle; 441 pp->state = qs_state_idle;
437 ata_qc_complete(qc, status); 442 ata_qc_complete(qc, status);
@@ -489,7 +494,7 @@ static int qs_port_start(struct ata_port *ap)
489 if (rc) 494 if (rc)
490 return rc; 495 return rc;
491 qs_enter_reg_mode(ap); 496 qs_enter_reg_mode(ap);
492 pp = kcalloc(1, sizeof(*pp), GFP_KERNEL); 497 pp = kzalloc(sizeof(*pp), GFP_KERNEL);
493 if (!pp) { 498 if (!pp) {
494 rc = -ENOMEM; 499 rc = -ENOMEM;
495 goto err_out; 500 goto err_out;
@@ -533,11 +538,12 @@ static void qs_port_stop(struct ata_port *ap)
533static void qs_host_stop(struct ata_host_set *host_set) 538static void qs_host_stop(struct ata_host_set *host_set)
534{ 539{
535 void __iomem *mmio_base = host_set->mmio_base; 540 void __iomem *mmio_base = host_set->mmio_base;
541 struct pci_dev *pdev = to_pci_dev(host_set->dev);
536 542
537 writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */ 543 writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
538 writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */ 544 writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */
539 545
540 ata_host_stop(host_set); 546 pci_iounmap(pdev, mmio_base);
541} 547}
542 548
543static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe) 549static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
@@ -641,8 +647,7 @@ static int qs_ata_init_one(struct pci_dev *pdev,
641 goto err_out_regions; 647 goto err_out_regions;
642 } 648 }
643 649
644 mmio_base = ioremap(pci_resource_start(pdev, 4), 650 mmio_base = pci_iomap(pdev, 4, 0);
645 pci_resource_len(pdev, 4));
646 if (mmio_base == NULL) { 651 if (mmio_base == NULL) {
647 rc = -ENOMEM; 652 rc = -ENOMEM;
648 goto err_out_regions; 653 goto err_out_regions;
@@ -692,7 +697,7 @@ static int qs_ata_init_one(struct pci_dev *pdev,
692 return 0; 697 return 0;
693 698
694err_out_iounmap: 699err_out_iounmap:
695 iounmap(mmio_base); 700 pci_iounmap(pdev, mmio_base);
696err_out_regions: 701err_out_regions:
697 pci_release_regions(pdev); 702 pci_release_regions(pdev);
698err_out: 703err_out:
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index 49ed557a4b66..ba98a175ee3a 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -5,24 +5,32 @@
5 * Please ALWAYS copy linux-ide@vger.kernel.org 5 * Please ALWAYS copy linux-ide@vger.kernel.org
6 * on emails. 6 * on emails.
7 * 7 *
8 * Copyright 2003 Red Hat, Inc. 8 * Copyright 2003-2005 Red Hat, Inc.
9 * Copyright 2003 Benjamin Herrenschmidt 9 * Copyright 2003 Benjamin Herrenschmidt
10 * 10 *
11 * The contents of this file are subject to the Open
12 * Software License version 1.1 that can be found at
13 * http://www.opensource.org/licenses/osl-1.1.txt and is included herein
14 * by reference.
15 * 11 *
16 * Alternatively, the contents of this file may be used under the terms 12 * This program is free software; you can redistribute it and/or modify
17 * of the GNU General Public License version 2 (the "GPL") as distributed 13 * it under the terms of the GNU General Public License as published by
18 * in the kernel source COPYING file, in which case the provisions of 14 * the Free Software Foundation; either version 2, or (at your option)
19 * the GPL are applicable instead of the above. If you wish to allow 15 * any later version.
20 * the use of your version of this file only under the terms of the 16 *
21 * GPL and not to allow others to use your version of this file under 17 * This program is distributed in the hope that it will be useful,
22 * the OSL, indicate your decision by deleting the provisions above and 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * replace them with the notice and other provisions required by the GPL. 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * If you do not delete the provisions above, a recipient may use your 20 * GNU General Public License for more details.
25 * version of this file under either the OSL or the GPL. 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 * Documentation for SiI 3112:
31 * http://gkernel.sourceforge.net/specs/sii/3112A_SiI-DS-0095-B2.pdf.bz2
32 *
33 * Other errata and documentation available under NDA.
26 * 34 *
27 */ 35 */
28 36
@@ -41,8 +49,11 @@
41#define DRV_VERSION "0.9" 49#define DRV_VERSION "0.9"
42 50
43enum { 51enum {
52 SIL_FLAG_MOD15WRITE = (1 << 30),
53
44 sil_3112 = 0, 54 sil_3112 = 0,
45 sil_3114 = 1, 55 sil_3112_m15w = 1,
56 sil_3114 = 2,
46 57
47 SIL_FIFO_R0 = 0x40, 58 SIL_FIFO_R0 = 0x40,
48 SIL_FIFO_W0 = 0x41, 59 SIL_FIFO_W0 = 0x41,
@@ -75,14 +86,15 @@ static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg);
75static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); 86static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
76static void sil_post_set_mode (struct ata_port *ap); 87static void sil_post_set_mode (struct ata_port *ap);
77 88
89
78static struct pci_device_id sil_pci_tbl[] = { 90static struct pci_device_id sil_pci_tbl[] = {
79 { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, 91 { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
80 { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, 92 { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
81 { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, 93 { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
82 { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 }, 94 { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 },
83 { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, 95 { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
84 { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, 96 { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
85 { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, 97 { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
86 { } /* terminate list */ 98 { } /* terminate list */
87}; 99};
88 100
@@ -161,7 +173,7 @@ static struct ata_port_operations sil_ops = {
161 .scr_write = sil_scr_write, 173 .scr_write = sil_scr_write,
162 .port_start = ata_port_start, 174 .port_start = ata_port_start,
163 .port_stop = ata_port_stop, 175 .port_stop = ata_port_stop,
164 .host_stop = ata_host_stop, 176 .host_stop = ata_pci_host_stop,
165}; 177};
166 178
167static struct ata_port_info sil_port_info[] = { 179static struct ata_port_info sil_port_info[] = {
@@ -174,6 +186,16 @@ static struct ata_port_info sil_port_info[] = {
174 .mwdma_mask = 0x07, /* mwdma0-2 */ 186 .mwdma_mask = 0x07, /* mwdma0-2 */
175 .udma_mask = 0x3f, /* udma0-5 */ 187 .udma_mask = 0x3f, /* udma0-5 */
176 .port_ops = &sil_ops, 188 .port_ops = &sil_ops,
189 }, /* sil_3112_15w - keep it sync'd w/ sil_3112 */
190 {
191 .sht = &sil_sht,
192 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
193 ATA_FLAG_SRST | ATA_FLAG_MMIO |
194 SIL_FLAG_MOD15WRITE,
195 .pio_mask = 0x1f, /* pio0-4 */
196 .mwdma_mask = 0x07, /* mwdma0-2 */
197 .udma_mask = 0x3f, /* udma0-5 */
198 .port_ops = &sil_ops,
177 }, /* sil_3114 */ 199 }, /* sil_3114 */
178 { 200 {
179 .sht = &sil_sht, 201 .sht = &sil_sht,
@@ -210,6 +232,7 @@ MODULE_LICENSE("GPL");
210MODULE_DEVICE_TABLE(pci, sil_pci_tbl); 232MODULE_DEVICE_TABLE(pci, sil_pci_tbl);
211MODULE_VERSION(DRV_VERSION); 233MODULE_VERSION(DRV_VERSION);
212 234
235
213static unsigned char sil_get_device_cache_line(struct pci_dev *pdev) 236static unsigned char sil_get_device_cache_line(struct pci_dev *pdev)
214{ 237{
215 u8 cache_line = 0; 238 u8 cache_line = 0;
@@ -221,7 +244,8 @@ static void sil_post_set_mode (struct ata_port *ap)
221{ 244{
222 struct ata_host_set *host_set = ap->host_set; 245 struct ata_host_set *host_set = ap->host_set;
223 struct ata_device *dev; 246 struct ata_device *dev;
224 void *addr = host_set->mmio_base + sil_port[ap->port_no].xfer_mode; 247 void __iomem *addr =
248 host_set->mmio_base + sil_port[ap->port_no].xfer_mode;
225 u32 tmp, dev_mode[2]; 249 u32 tmp, dev_mode[2];
226 unsigned int i; 250 unsigned int i;
227 251
@@ -323,15 +347,15 @@ static void sil_dev_config(struct ata_port *ap, struct ata_device *dev)
323 while ((len > 0) && (s[len - 1] == ' ')) 347 while ((len > 0) && (s[len - 1] == ' '))
324 len--; 348 len--;
325 349
326 for (n = 0; sil_blacklist[n].product; n++) 350 for (n = 0; sil_blacklist[n].product; n++)
327 if (!memcmp(sil_blacklist[n].product, s, 351 if (!memcmp(sil_blacklist[n].product, s,
328 strlen(sil_blacklist[n].product))) { 352 strlen(sil_blacklist[n].product))) {
329 quirks = sil_blacklist[n].quirk; 353 quirks = sil_blacklist[n].quirk;
330 break; 354 break;
331 } 355 }
332 356
333 /* limit requests to 15 sectors */ 357 /* limit requests to 15 sectors */
334 if (quirks & SIL_QUIRK_MOD15WRITE) { 358 if ((ap->flags & SIL_FLAG_MOD15WRITE) && (quirks & SIL_QUIRK_MOD15WRITE)) {
335 printk(KERN_INFO "ata%u(%u): applying Seagate errata fix\n", 359 printk(KERN_INFO "ata%u(%u): applying Seagate errata fix\n",
336 ap->id, dev->devno); 360 ap->id, dev->devno);
337 ap->host->max_sectors = 15; 361 ap->host->max_sectors = 15;
@@ -354,7 +378,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
354 static int printed_version; 378 static int printed_version;
355 struct ata_probe_ent *probe_ent = NULL; 379 struct ata_probe_ent *probe_ent = NULL;
356 unsigned long base; 380 unsigned long base;
357 void *mmio_base; 381 void __iomem *mmio_base;
358 int rc; 382 int rc;
359 unsigned int i; 383 unsigned int i;
360 int pci_dev_busy = 0; 384 int pci_dev_busy = 0;
@@ -404,8 +428,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
404 probe_ent->irq_flags = SA_SHIRQ; 428 probe_ent->irq_flags = SA_SHIRQ;
405 probe_ent->host_flags = sil_port_info[ent->driver_data].host_flags; 429 probe_ent->host_flags = sil_port_info[ent->driver_data].host_flags;
406 430
407 mmio_base = ioremap(pci_resource_start(pdev, 5), 431 mmio_base = pci_iomap(pdev, 5, 0);
408 pci_resource_len(pdev, 5));
409 if (mmio_base == NULL) { 432 if (mmio_base == NULL) {
410 rc = -ENOMEM; 433 rc = -ENOMEM;
411 goto err_out_free_ent; 434 goto err_out_free_ent;
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c
index e418b89c6b9d..43af445b3ad2 100644
--- a/drivers/scsi/sata_sis.c
+++ b/drivers/scsi/sata_sis.c
@@ -7,21 +7,26 @@
7 * 7 *
8 * Copyright 2004 Uwe Koziolek 8 * Copyright 2004 Uwe Koziolek
9 * 9 *
10 * The contents of this file are subject to the Open
11 * Software License version 1.1 that can be found at
12 * http://www.opensource.org/licenses/osl-1.1.txt and is included herein
13 * by reference.
14 * 10 *
15 * Alternatively, the contents of this file may be used under the terms 11 * This program is free software; you can redistribute it and/or modify
16 * of the GNU General Public License version 2 (the "GPL") as distributed 12 * it under the terms of the GNU General Public License as published by
17 * in the kernel source COPYING file, in which case the provisions of 13 * the Free Software Foundation; either version 2, or (at your option)
18 * the GPL are applicable instead of the above. If you wish to allow 14 * any later version.
19 * the use of your version of this file only under the terms of the 15 *
20 * GPL and not to allow others to use your version of this file under 16 * This program is distributed in the hope that it will be useful,
21 * the OSL, indicate your decision by deleting the provisions above and 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * replace them with the notice and other provisions required by the GPL. 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * If you do not delete the provisions above, a recipient may use your 19 * GNU General Public License for more details.
24 * version of this file under either the OSL or the GPL. 20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; see the file COPYING. If not, write to
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 *
26 * libata documentation is available via 'make {ps|pdf}docs',
27 * as Documentation/DocBook/libata.*
28 *
29 * Hardware documentation available under NDA.
25 * 30 *
26 */ 31 */
27 32
@@ -234,7 +239,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
234 pci_read_config_dword(pdev, SIS_GENCTL, &genctl); 239 pci_read_config_dword(pdev, SIS_GENCTL, &genctl);
235 if ((genctl & GENCTL_IOMAPPED_SCR) == 0) 240 if ((genctl & GENCTL_IOMAPPED_SCR) == 0)
236 probe_ent->host_flags |= SIS_FLAG_CFGSCR; 241 probe_ent->host_flags |= SIS_FLAG_CFGSCR;
237 242
238 /* if hardware thinks SCRs are in IO space, but there are 243 /* if hardware thinks SCRs are in IO space, but there are
239 * no IO resources assigned, change to PCI cfg space. 244 * no IO resources assigned, change to PCI cfg space.
240 */ 245 */
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index 858e07185dbd..d89d968bedac 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -13,21 +13,26 @@
13 * This driver probably works with non-Apple versions of the 13 * This driver probably works with non-Apple versions of the
14 * Broadcom chipset... 14 * Broadcom chipset...
15 * 15 *
16 * The contents of this file are subject to the Open
17 * Software License version 1.1 that can be found at
18 * http://www.opensource.org/licenses/osl-1.1.txt and is included herein
19 * by reference.
20 * 16 *
21 * Alternatively, the contents of this file may be used under the terms 17 * This program is free software; you can redistribute it and/or modify
22 * of the GNU General Public License version 2 (the "GPL") as distributed 18 * it under the terms of the GNU General Public License as published by
23 * in the kernel source COPYING file, in which case the provisions of 19 * the Free Software Foundation; either version 2, or (at your option)
24 * the GPL are applicable instead of the above. If you wish to allow 20 * any later version.
25 * the use of your version of this file only under the terms of the 21 *
26 * GPL and not to allow others to use your version of this file under 22 * This program is distributed in the hope that it will be useful,
27 * the OSL, indicate your decision by deleting the provisions above and 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * replace them with the notice and other provisions required by the GPL. 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * If you do not delete the provisions above, a recipient may use your 25 * GNU General Public License for more details.
30 * version of this file under either the OSL or the GPL. 26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; see the file COPYING. If not, write to
29 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
30 *
31 *
32 * libata documentation is available via 'make {ps|pdf}docs',
33 * as Documentation/DocBook/libata.*
34 *
35 * Hardware documentation available under NDA.
31 * 36 *
32 */ 37 */
33 38
@@ -195,18 +200,18 @@ static void k2_bmdma_start_mmio (struct ata_queued_cmd *qc)
195 /* start host DMA transaction */ 200 /* start host DMA transaction */
196 dmactl = readb(mmio + ATA_DMA_CMD); 201 dmactl = readb(mmio + ATA_DMA_CMD);
197 writeb(dmactl | ATA_DMA_START, mmio + ATA_DMA_CMD); 202 writeb(dmactl | ATA_DMA_START, mmio + ATA_DMA_CMD);
198 /* There is a race condition in certain SATA controllers that can 203 /* There is a race condition in certain SATA controllers that can
199 be seen when the r/w command is given to the controller before the 204 be seen when the r/w command is given to the controller before the
200 host DMA is started. On a Read command, the controller would initiate 205 host DMA is started. On a Read command, the controller would initiate
201 the command to the drive even before it sees the DMA start. When there 206 the command to the drive even before it sees the DMA start. When there
202 are very fast drives connected to the controller, or when the data request 207 are very fast drives connected to the controller, or when the data request
203 hits in the drive cache, there is the possibility that the drive returns a part 208 hits in the drive cache, there is the possibility that the drive returns a part
204 or all of the requested data to the controller before the DMA start is issued. 209 or all of the requested data to the controller before the DMA start is issued.
205 In this case, the controller would become confused as to what to do with the data. 210 In this case, the controller would become confused as to what to do with the data.
206 In the worst case when all the data is returned back to the controller, the 211 In the worst case when all the data is returned back to the controller, the
207 controller could hang. In other cases it could return partial data returning 212 controller could hang. In other cases it could return partial data returning
208 in data corruption. This problem has been seen in PPC systems and can also appear 213 in data corruption. This problem has been seen in PPC systems and can also appear
209 on an system with very fast disks, where the SATA controller is sitting behind a 214 on an system with very fast disks, where the SATA controller is sitting behind a
210 number of bridges, and hence there is significant latency between the r/w command 215 number of bridges, and hence there is significant latency between the r/w command
211 and the start command. */ 216 and the start command. */
212 /* issue r/w command if the access is to ATA*/ 217 /* issue r/w command if the access is to ATA*/
@@ -214,7 +219,7 @@ static void k2_bmdma_start_mmio (struct ata_queued_cmd *qc)
214 ap->ops->exec_command(ap, &qc->tf); 219 ap->ops->exec_command(ap, &qc->tf);
215} 220}
216 221
217 222
218static u8 k2_stat_check_status(struct ata_port *ap) 223static u8 k2_stat_check_status(struct ata_port *ap)
219{ 224{
220 return readl((void *) ap->ioaddr.status_addr); 225 return readl((void *) ap->ioaddr.status_addr);
@@ -313,7 +318,7 @@ static struct ata_port_operations k2_sata_ops = {
313 .scr_write = k2_sata_scr_write, 318 .scr_write = k2_sata_scr_write,
314 .port_start = ata_port_start, 319 .port_start = ata_port_start,
315 .port_stop = ata_port_stop, 320 .port_stop = ata_port_stop,
316 .host_stop = ata_host_stop, 321 .host_stop = ata_pci_host_stop,
317}; 322};
318 323
319static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base) 324static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base)
@@ -341,7 +346,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
341 static int printed_version; 346 static int printed_version;
342 struct ata_probe_ent *probe_ent = NULL; 347 struct ata_probe_ent *probe_ent = NULL;
343 unsigned long base; 348 unsigned long base;
344 void *mmio_base; 349 void __iomem *mmio_base;
345 int pci_dev_busy = 0; 350 int pci_dev_busy = 0;
346 int rc; 351 int rc;
347 int i; 352 int i;
@@ -387,8 +392,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
387 probe_ent->dev = pci_dev_to_dev(pdev); 392 probe_ent->dev = pci_dev_to_dev(pdev);
388 INIT_LIST_HEAD(&probe_ent->node); 393 INIT_LIST_HEAD(&probe_ent->node);
389 394
390 mmio_base = ioremap(pci_resource_start(pdev, 5), 395 mmio_base = pci_iomap(pdev, 5, 0);
391 pci_resource_len(pdev, 5));
392 if (mmio_base == NULL) { 396 if (mmio_base == NULL) {
393 rc = -ENOMEM; 397 rc = -ENOMEM;
394 goto err_out_free_ent; 398 goto err_out_free_ent;
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index efd7d7a61135..540a85191172 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -7,21 +7,26 @@
7 * 7 *
8 * Copyright 2003-2004 Red Hat, Inc. 8 * Copyright 2003-2004 Red Hat, Inc.
9 * 9 *
10 * The contents of this file are subject to the Open
11 * Software License version 1.1 that can be found at
12 * http://www.opensource.org/licenses/osl-1.1.txt and is included herein
13 * by reference.
14 * 10 *
15 * Alternatively, the contents of this file may be used under the terms 11 * This program is free software; you can redistribute it and/or modify
16 * of the GNU General Public License version 2 (the "GPL") as distributed 12 * it under the terms of the GNU General Public License as published by
17 * in the kernel source COPYING file, in which case the provisions of 13 * the Free Software Foundation; either version 2, or (at your option)
18 * the GPL are applicable instead of the above. If you wish to allow 14 * any later version.
19 * the use of your version of this file only under the terms of the 15 *
20 * GPL and not to allow others to use your version of this file under 16 * This program is distributed in the hope that it will be useful,
21 * the OSL, indicate your decision by deleting the provisions above and 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * replace them with the notice and other provisions required by the GPL. 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * If you do not delete the provisions above, a recipient may use your 19 * GNU General Public License for more details.
24 * version of this file under either the OSL or the GPL. 20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; see the file COPYING. If not, write to
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 *
26 * libata documentation is available via 'make {ps|pdf}docs',
27 * as Documentation/DocBook/libata.*
28 *
29 * Hardware documentation available under NDA.
25 * 30 *
26 */ 31 */
27 32
@@ -94,7 +99,7 @@ enum {
94 PDC_DIMM1_CONTROL_OFFSET = 0x84, 99 PDC_DIMM1_CONTROL_OFFSET = 0x84,
95 PDC_SDRAM_CONTROL_OFFSET = 0x88, 100 PDC_SDRAM_CONTROL_OFFSET = 0x88,
96 PDC_I2C_WRITE = 0x00000000, 101 PDC_I2C_WRITE = 0x00000000,
97 PDC_I2C_READ = 0x00000040, 102 PDC_I2C_READ = 0x00000040,
98 PDC_I2C_START = 0x00000080, 103 PDC_I2C_START = 0x00000080,
99 PDC_I2C_MASK_INT = 0x00000020, 104 PDC_I2C_MASK_INT = 0x00000020,
100 PDC_I2C_COMPLETE = 0x00010000, 105 PDC_I2C_COMPLETE = 0x00010000,
@@ -105,16 +110,16 @@ enum {
105 PDC_DIMM_SPD_COLUMN_NUM = 4, 110 PDC_DIMM_SPD_COLUMN_NUM = 4,
106 PDC_DIMM_SPD_MODULE_ROW = 5, 111 PDC_DIMM_SPD_MODULE_ROW = 5,
107 PDC_DIMM_SPD_TYPE = 11, 112 PDC_DIMM_SPD_TYPE = 11,
108 PDC_DIMM_SPD_FRESH_RATE = 12, 113 PDC_DIMM_SPD_FRESH_RATE = 12,
109 PDC_DIMM_SPD_BANK_NUM = 17, 114 PDC_DIMM_SPD_BANK_NUM = 17,
110 PDC_DIMM_SPD_CAS_LATENCY = 18, 115 PDC_DIMM_SPD_CAS_LATENCY = 18,
111 PDC_DIMM_SPD_ATTRIBUTE = 21, 116 PDC_DIMM_SPD_ATTRIBUTE = 21,
112 PDC_DIMM_SPD_ROW_PRE_CHARGE = 27, 117 PDC_DIMM_SPD_ROW_PRE_CHARGE = 27,
113 PDC_DIMM_SPD_ROW_ACTIVE_DELAY = 28, 118 PDC_DIMM_SPD_ROW_ACTIVE_DELAY = 28,
114 PDC_DIMM_SPD_RAS_CAS_DELAY = 29, 119 PDC_DIMM_SPD_RAS_CAS_DELAY = 29,
115 PDC_DIMM_SPD_ACTIVE_PRECHARGE = 30, 120 PDC_DIMM_SPD_ACTIVE_PRECHARGE = 30,
116 PDC_DIMM_SPD_SYSTEM_FREQ = 126, 121 PDC_DIMM_SPD_SYSTEM_FREQ = 126,
117 PDC_CTL_STATUS = 0x08, 122 PDC_CTL_STATUS = 0x08,
118 PDC_DIMM_WINDOW_CTLR = 0x0C, 123 PDC_DIMM_WINDOW_CTLR = 0x0C,
119 PDC_TIME_CONTROL = 0x3C, 124 PDC_TIME_CONTROL = 0x3C,
120 PDC_TIME_PERIOD = 0x40, 125 PDC_TIME_PERIOD = 0x40,
@@ -157,15 +162,15 @@ static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf);
157static void pdc20621_host_stop(struct ata_host_set *host_set); 162static void pdc20621_host_stop(struct ata_host_set *host_set);
158static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe); 163static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe);
159static int pdc20621_detect_dimm(struct ata_probe_ent *pe); 164static int pdc20621_detect_dimm(struct ata_probe_ent *pe);
160static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, 165static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe,
161 u32 device, u32 subaddr, u32 *pdata); 166 u32 device, u32 subaddr, u32 *pdata);
162static int pdc20621_prog_dimm0(struct ata_probe_ent *pe); 167static int pdc20621_prog_dimm0(struct ata_probe_ent *pe);
163static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe); 168static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe);
164#ifdef ATA_VERBOSE_DEBUG 169#ifdef ATA_VERBOSE_DEBUG
165static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, 170static void pdc20621_get_from_dimm(struct ata_probe_ent *pe,
166 void *psource, u32 offset, u32 size); 171 void *psource, u32 offset, u32 size);
167#endif 172#endif
168static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, 173static void pdc20621_put_to_dimm(struct ata_probe_ent *pe,
169 void *psource, u32 offset, u32 size); 174 void *psource, u32 offset, u32 size);
170static void pdc20621_irq_clear(struct ata_port *ap); 175static void pdc20621_irq_clear(struct ata_port *ap);
171static int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc); 176static int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc);
@@ -240,13 +245,14 @@ static struct pci_driver pdc_sata_pci_driver = {
240 245
241static void pdc20621_host_stop(struct ata_host_set *host_set) 246static void pdc20621_host_stop(struct ata_host_set *host_set)
242{ 247{
248 struct pci_dev *pdev = to_pci_dev(host_set->dev);
243 struct pdc_host_priv *hpriv = host_set->private_data; 249 struct pdc_host_priv *hpriv = host_set->private_data;
244 void *dimm_mmio = hpriv->dimm_mmio; 250 void *dimm_mmio = hpriv->dimm_mmio;
245 251
246 iounmap(dimm_mmio); 252 pci_iounmap(pdev, dimm_mmio);
247 kfree(hpriv); 253 kfree(hpriv);
248 254
249 ata_host_stop(host_set); 255 pci_iounmap(pdev, host_set->mmio_base);
250} 256}
251 257
252static int pdc_port_start(struct ata_port *ap) 258static int pdc_port_start(struct ata_port *ap)
@@ -446,9 +452,9 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc)
446 struct scatterlist *sg = qc->sg; 452 struct scatterlist *sg = qc->sg;
447 struct ata_port *ap = qc->ap; 453 struct ata_port *ap = qc->ap;
448 struct pdc_port_priv *pp = ap->private_data; 454 struct pdc_port_priv *pp = ap->private_data;
449 void *mmio = ap->host_set->mmio_base; 455 void __iomem *mmio = ap->host_set->mmio_base;
450 struct pdc_host_priv *hpriv = ap->host_set->private_data; 456 struct pdc_host_priv *hpriv = ap->host_set->private_data;
451 void *dimm_mmio = hpriv->dimm_mmio; 457 void __iomem *dimm_mmio = hpriv->dimm_mmio;
452 unsigned int portno = ap->port_no; 458 unsigned int portno = ap->port_no;
453 unsigned int i, last, idx, total_len = 0, sgt_len; 459 unsigned int i, last, idx, total_len = 0, sgt_len;
454 u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ]; 460 u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ];
@@ -508,9 +514,9 @@ static void pdc20621_nodata_prep(struct ata_queued_cmd *qc)
508{ 514{
509 struct ata_port *ap = qc->ap; 515 struct ata_port *ap = qc->ap;
510 struct pdc_port_priv *pp = ap->private_data; 516 struct pdc_port_priv *pp = ap->private_data;
511 void *mmio = ap->host_set->mmio_base; 517 void __iomem *mmio = ap->host_set->mmio_base;
512 struct pdc_host_priv *hpriv = ap->host_set->private_data; 518 struct pdc_host_priv *hpriv = ap->host_set->private_data;
513 void *dimm_mmio = hpriv->dimm_mmio; 519 void __iomem *dimm_mmio = hpriv->dimm_mmio;
514 unsigned int portno = ap->port_no; 520 unsigned int portno = ap->port_no;
515 unsigned int i; 521 unsigned int i;
516 522
@@ -560,7 +566,7 @@ static void __pdc20621_push_hdma(struct ata_queued_cmd *qc,
560{ 566{
561 struct ata_port *ap = qc->ap; 567 struct ata_port *ap = qc->ap;
562 struct ata_host_set *host_set = ap->host_set; 568 struct ata_host_set *host_set = ap->host_set;
563 void *mmio = host_set->mmio_base; 569 void __iomem *mmio = host_set->mmio_base;
564 570
565 /* hard-code chip #0 */ 571 /* hard-code chip #0 */
566 mmio += PDC_CHIP0_OFS; 572 mmio += PDC_CHIP0_OFS;
@@ -634,7 +640,7 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc)
634 struct ata_port *ap = qc->ap; 640 struct ata_port *ap = qc->ap;
635 struct ata_host_set *host_set = ap->host_set; 641 struct ata_host_set *host_set = ap->host_set;
636 unsigned int port_no = ap->port_no; 642 unsigned int port_no = ap->port_no;
637 void *mmio = host_set->mmio_base; 643 void __iomem *mmio = host_set->mmio_base;
638 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); 644 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
639 u8 seq = (u8) (port_no + 1); 645 u8 seq = (u8) (port_no + 1);
640 unsigned int port_ofs; 646 unsigned int port_ofs;
@@ -694,7 +700,7 @@ static int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc)
694static inline unsigned int pdc20621_host_intr( struct ata_port *ap, 700static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
695 struct ata_queued_cmd *qc, 701 struct ata_queued_cmd *qc,
696 unsigned int doing_hdma, 702 unsigned int doing_hdma,
697 void *mmio) 703 void __iomem *mmio)
698{ 704{
699 unsigned int port_no = ap->port_no; 705 unsigned int port_no = ap->port_no;
700 unsigned int port_ofs = 706 unsigned int port_ofs =
@@ -773,7 +779,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
773static void pdc20621_irq_clear(struct ata_port *ap) 779static void pdc20621_irq_clear(struct ata_port *ap)
774{ 780{
775 struct ata_host_set *host_set = ap->host_set; 781 struct ata_host_set *host_set = ap->host_set;
776 void *mmio = host_set->mmio_base; 782 void __iomem *mmio = host_set->mmio_base;
777 783
778 mmio += PDC_CHIP0_OFS; 784 mmio += PDC_CHIP0_OFS;
779 785
@@ -787,7 +793,7 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
787 u32 mask = 0; 793 u32 mask = 0;
788 unsigned int i, tmp, port_no; 794 unsigned int i, tmp, port_no;
789 unsigned int handled = 0; 795 unsigned int handled = 0;
790 void *mmio_base; 796 void __iomem *mmio_base;
791 797
792 VPRINTK("ENTER\n"); 798 VPRINTK("ENTER\n");
793 799
@@ -825,7 +831,8 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
825 ap = host_set->ports[port_no]; 831 ap = host_set->ports[port_no];
826 tmp = mask & (1 << i); 832 tmp = mask & (1 << i);
827 VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp); 833 VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp);
828 if (tmp && ap && (!(ap->flags & ATA_FLAG_PORT_DISABLED))) { 834 if (tmp && ap &&
835 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) {
829 struct ata_queued_cmd *qc; 836 struct ata_queued_cmd *qc;
830 837
831 qc = ata_qc_from_tag(ap, ap->active_tag); 838 qc = ata_qc_from_tag(ap, ap->active_tag);
@@ -847,10 +854,14 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
847static void pdc_eng_timeout(struct ata_port *ap) 854static void pdc_eng_timeout(struct ata_port *ap)
848{ 855{
849 u8 drv_stat; 856 u8 drv_stat;
857 struct ata_host_set *host_set = ap->host_set;
850 struct ata_queued_cmd *qc; 858 struct ata_queued_cmd *qc;
859 unsigned long flags;
851 860
852 DPRINTK("ENTER\n"); 861 DPRINTK("ENTER\n");
853 862
863 spin_lock_irqsave(&host_set->lock, flags);
864
854 qc = ata_qc_from_tag(ap, ap->active_tag); 865 qc = ata_qc_from_tag(ap, ap->active_tag);
855 if (!qc) { 866 if (!qc) {
856 printk(KERN_ERR "ata%u: BUG: timeout without command\n", 867 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
@@ -884,6 +895,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
884 } 895 }
885 896
886out: 897out:
898 spin_unlock_irqrestore(&host_set->lock, flags);
887 DPRINTK("EXIT\n"); 899 DPRINTK("EXIT\n");
888} 900}
889 901
@@ -922,23 +934,23 @@ static void pdc_sata_setup_port(struct ata_ioports *port, unsigned long base)
922 934
923 935
924#ifdef ATA_VERBOSE_DEBUG 936#ifdef ATA_VERBOSE_DEBUG
925static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource, 937static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource,
926 u32 offset, u32 size) 938 u32 offset, u32 size)
927{ 939{
928 u32 window_size; 940 u32 window_size;
929 u16 idx; 941 u16 idx;
930 u8 page_mask; 942 u8 page_mask;
931 long dist; 943 long dist;
932 void *mmio = pe->mmio_base; 944 void __iomem *mmio = pe->mmio_base;
933 struct pdc_host_priv *hpriv = pe->private_data; 945 struct pdc_host_priv *hpriv = pe->private_data;
934 void *dimm_mmio = hpriv->dimm_mmio; 946 void __iomem *dimm_mmio = hpriv->dimm_mmio;
935 947
936 /* hard-code chip #0 */ 948 /* hard-code chip #0 */
937 mmio += PDC_CHIP0_OFS; 949 mmio += PDC_CHIP0_OFS;
938 950
939 page_mask = 0x00; 951 page_mask = 0x00;
940 window_size = 0x2000 * 4; /* 32K byte uchar size */ 952 window_size = 0x2000 * 4; /* 32K byte uchar size */
941 idx = (u16) (offset / window_size); 953 idx = (u16) (offset / window_size);
942 954
943 writel(0x01, mmio + PDC_GENERAL_CTLR); 955 writel(0x01, mmio + PDC_GENERAL_CTLR);
944 readl(mmio + PDC_GENERAL_CTLR); 956 readl(mmio + PDC_GENERAL_CTLR);
@@ -947,19 +959,19 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource,
947 959
948 offset -= (idx * window_size); 960 offset -= (idx * window_size);
949 idx++; 961 idx++;
950 dist = ((long) (window_size - (offset + size))) >= 0 ? size : 962 dist = ((long) (window_size - (offset + size))) >= 0 ? size :
951 (long) (window_size - offset); 963 (long) (window_size - offset);
952 memcpy_fromio((char *) psource, (char *) (dimm_mmio + offset / 4), 964 memcpy_fromio((char *) psource, (char *) (dimm_mmio + offset / 4),
953 dist); 965 dist);
954 966
955 psource += dist; 967 psource += dist;
956 size -= dist; 968 size -= dist;
957 for (; (long) size >= (long) window_size ;) { 969 for (; (long) size >= (long) window_size ;) {
958 writel(0x01, mmio + PDC_GENERAL_CTLR); 970 writel(0x01, mmio + PDC_GENERAL_CTLR);
959 readl(mmio + PDC_GENERAL_CTLR); 971 readl(mmio + PDC_GENERAL_CTLR);
960 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); 972 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR);
961 readl(mmio + PDC_DIMM_WINDOW_CTLR); 973 readl(mmio + PDC_DIMM_WINDOW_CTLR);
962 memcpy_fromio((char *) psource, (char *) (dimm_mmio), 974 memcpy_fromio((char *) psource, (char *) (dimm_mmio),
963 window_size / 4); 975 window_size / 4);
964 psource += window_size; 976 psource += window_size;
965 size -= window_size; 977 size -= window_size;
@@ -971,34 +983,34 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource,
971 readl(mmio + PDC_GENERAL_CTLR); 983 readl(mmio + PDC_GENERAL_CTLR);
972 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); 984 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR);
973 readl(mmio + PDC_DIMM_WINDOW_CTLR); 985 readl(mmio + PDC_DIMM_WINDOW_CTLR);
974 memcpy_fromio((char *) psource, (char *) (dimm_mmio), 986 memcpy_fromio((char *) psource, (char *) (dimm_mmio),
975 size / 4); 987 size / 4);
976 } 988 }
977} 989}
978#endif 990#endif
979 991
980 992
981static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource, 993static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
982 u32 offset, u32 size) 994 u32 offset, u32 size)
983{ 995{
984 u32 window_size; 996 u32 window_size;
985 u16 idx; 997 u16 idx;
986 u8 page_mask; 998 u8 page_mask;
987 long dist; 999 long dist;
988 void *mmio = pe->mmio_base; 1000 void __iomem *mmio = pe->mmio_base;
989 struct pdc_host_priv *hpriv = pe->private_data; 1001 struct pdc_host_priv *hpriv = pe->private_data;
990 void *dimm_mmio = hpriv->dimm_mmio; 1002 void __iomem *dimm_mmio = hpriv->dimm_mmio;
991 1003
992 /* hard-code chip #0 */ 1004 /* hard-code chip #0 */
993 mmio += PDC_CHIP0_OFS; 1005 mmio += PDC_CHIP0_OFS;
994 1006
995 page_mask = 0x00; 1007 page_mask = 0x00;
996 window_size = 0x2000 * 4; /* 32K byte uchar size */ 1008 window_size = 0x2000 * 4; /* 32K byte uchar size */
997 idx = (u16) (offset / window_size); 1009 idx = (u16) (offset / window_size);
998 1010
999 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); 1011 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR);
1000 readl(mmio + PDC_DIMM_WINDOW_CTLR); 1012 readl(mmio + PDC_DIMM_WINDOW_CTLR);
1001 offset -= (idx * window_size); 1013 offset -= (idx * window_size);
1002 idx++; 1014 idx++;
1003 dist = ((long)(s32)(window_size - (offset + size))) >= 0 ? size : 1015 dist = ((long)(s32)(window_size - (offset + size))) >= 0 ? size :
1004 (long) (window_size - offset); 1016 (long) (window_size - offset);
@@ -1006,12 +1018,12 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
1006 writel(0x01, mmio + PDC_GENERAL_CTLR); 1018 writel(0x01, mmio + PDC_GENERAL_CTLR);
1007 readl(mmio + PDC_GENERAL_CTLR); 1019 readl(mmio + PDC_GENERAL_CTLR);
1008 1020
1009 psource += dist; 1021 psource += dist;
1010 size -= dist; 1022 size -= dist;
1011 for (; (long) size >= (long) window_size ;) { 1023 for (; (long) size >= (long) window_size ;) {
1012 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); 1024 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR);
1013 readl(mmio + PDC_DIMM_WINDOW_CTLR); 1025 readl(mmio + PDC_DIMM_WINDOW_CTLR);
1014 memcpy_toio((char *) (dimm_mmio), (char *) psource, 1026 memcpy_toio((char *) (dimm_mmio), (char *) psource,
1015 window_size / 4); 1027 window_size / 4);
1016 writel(0x01, mmio + PDC_GENERAL_CTLR); 1028 writel(0x01, mmio + PDC_GENERAL_CTLR);
1017 readl(mmio + PDC_GENERAL_CTLR); 1029 readl(mmio + PDC_GENERAL_CTLR);
@@ -1019,7 +1031,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
1019 size -= window_size; 1031 size -= window_size;
1020 idx ++; 1032 idx ++;
1021 } 1033 }
1022 1034
1023 if (size) { 1035 if (size) {
1024 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); 1036 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR);
1025 readl(mmio + PDC_DIMM_WINDOW_CTLR); 1037 readl(mmio + PDC_DIMM_WINDOW_CTLR);
@@ -1030,12 +1042,12 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
1030} 1042}
1031 1043
1032 1044
1033static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device, 1045static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device,
1034 u32 subaddr, u32 *pdata) 1046 u32 subaddr, u32 *pdata)
1035{ 1047{
1036 void *mmio = pe->mmio_base; 1048 void __iomem *mmio = pe->mmio_base;
1037 u32 i2creg = 0; 1049 u32 i2creg = 0;
1038 u32 status; 1050 u32 status;
1039 u32 count =0; 1051 u32 count =0;
1040 1052
1041 /* hard-code chip #0 */ 1053 /* hard-code chip #0 */
@@ -1049,7 +1061,7 @@ static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device,
1049 readl(mmio + PDC_I2C_ADDR_DATA_OFFSET); 1061 readl(mmio + PDC_I2C_ADDR_DATA_OFFSET);
1050 1062
1051 /* Write Control to perform read operation, mask int */ 1063 /* Write Control to perform read operation, mask int */
1052 writel(PDC_I2C_READ | PDC_I2C_START | PDC_I2C_MASK_INT, 1064 writel(PDC_I2C_READ | PDC_I2C_START | PDC_I2C_MASK_INT,
1053 mmio + PDC_I2C_CONTROL_OFFSET); 1065 mmio + PDC_I2C_CONTROL_OFFSET);
1054 1066
1055 for (count = 0; count <= 1000; count ++) { 1067 for (count = 0; count <= 1000; count ++) {
@@ -1062,26 +1074,26 @@ static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device,
1062 } 1074 }
1063 1075
1064 *pdata = (status >> 8) & 0x000000ff; 1076 *pdata = (status >> 8) & 0x000000ff;
1065 return 1; 1077 return 1;
1066} 1078}
1067 1079
1068 1080
1069static int pdc20621_detect_dimm(struct ata_probe_ent *pe) 1081static int pdc20621_detect_dimm(struct ata_probe_ent *pe)
1070{ 1082{
1071 u32 data=0 ; 1083 u32 data=0 ;
1072 if (pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS, 1084 if (pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS,
1073 PDC_DIMM_SPD_SYSTEM_FREQ, &data)) { 1085 PDC_DIMM_SPD_SYSTEM_FREQ, &data)) {
1074 if (data == 100) 1086 if (data == 100)
1075 return 100; 1087 return 100;
1076 } else 1088 } else
1077 return 0; 1089 return 0;
1078 1090
1079 if (pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS, 9, &data)) { 1091 if (pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS, 9, &data)) {
1080 if(data <= 0x75) 1092 if(data <= 0x75)
1081 return 133; 1093 return 133;
1082 } else 1094 } else
1083 return 0; 1095 return 0;
1084 1096
1085 return 0; 1097 return 0;
1086} 1098}
1087 1099
@@ -1091,15 +1103,15 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
1091 u32 spd0[50]; 1103 u32 spd0[50];
1092 u32 data = 0; 1104 u32 data = 0;
1093 int size, i; 1105 int size, i;
1094 u8 bdimmsize; 1106 u8 bdimmsize;
1095 void *mmio = pe->mmio_base; 1107 void __iomem *mmio = pe->mmio_base;
1096 static const struct { 1108 static const struct {
1097 unsigned int reg; 1109 unsigned int reg;
1098 unsigned int ofs; 1110 unsigned int ofs;
1099 } pdc_i2c_read_data [] = { 1111 } pdc_i2c_read_data [] = {
1100 { PDC_DIMM_SPD_TYPE, 11 }, 1112 { PDC_DIMM_SPD_TYPE, 11 },
1101 { PDC_DIMM_SPD_FRESH_RATE, 12 }, 1113 { PDC_DIMM_SPD_FRESH_RATE, 12 },
1102 { PDC_DIMM_SPD_COLUMN_NUM, 4 }, 1114 { PDC_DIMM_SPD_COLUMN_NUM, 4 },
1103 { PDC_DIMM_SPD_ATTRIBUTE, 21 }, 1115 { PDC_DIMM_SPD_ATTRIBUTE, 21 },
1104 { PDC_DIMM_SPD_ROW_NUM, 3 }, 1116 { PDC_DIMM_SPD_ROW_NUM, 3 },
1105 { PDC_DIMM_SPD_BANK_NUM, 17 }, 1117 { PDC_DIMM_SPD_BANK_NUM, 17 },
@@ -1108,7 +1120,7 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
1108 { PDC_DIMM_SPD_ROW_ACTIVE_DELAY, 28 }, 1120 { PDC_DIMM_SPD_ROW_ACTIVE_DELAY, 28 },
1109 { PDC_DIMM_SPD_RAS_CAS_DELAY, 29 }, 1121 { PDC_DIMM_SPD_RAS_CAS_DELAY, 29 },
1110 { PDC_DIMM_SPD_ACTIVE_PRECHARGE, 30 }, 1122 { PDC_DIMM_SPD_ACTIVE_PRECHARGE, 30 },
1111 { PDC_DIMM_SPD_CAS_LATENCY, 18 }, 1123 { PDC_DIMM_SPD_CAS_LATENCY, 18 },
1112 }; 1124 };
1113 1125
1114 /* hard-code chip #0 */ 1126 /* hard-code chip #0 */
@@ -1116,17 +1128,17 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
1116 1128
1117 for(i=0; i<ARRAY_SIZE(pdc_i2c_read_data); i++) 1129 for(i=0; i<ARRAY_SIZE(pdc_i2c_read_data); i++)
1118 pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS, 1130 pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS,
1119 pdc_i2c_read_data[i].reg, 1131 pdc_i2c_read_data[i].reg,
1120 &spd0[pdc_i2c_read_data[i].ofs]); 1132 &spd0[pdc_i2c_read_data[i].ofs]);
1121 1133
1122 data |= (spd0[4] - 8) | ((spd0[21] != 0) << 3) | ((spd0[3]-11) << 4); 1134 data |= (spd0[4] - 8) | ((spd0[21] != 0) << 3) | ((spd0[3]-11) << 4);
1123 data |= ((spd0[17] / 4) << 6) | ((spd0[5] / 2) << 7) | 1135 data |= ((spd0[17] / 4) << 6) | ((spd0[5] / 2) << 7) |
1124 ((((spd0[27] + 9) / 10) - 1) << 8) ; 1136 ((((spd0[27] + 9) / 10) - 1) << 8) ;
1125 data |= (((((spd0[29] > spd0[28]) 1137 data |= (((((spd0[29] > spd0[28])
1126 ? spd0[29] : spd0[28]) + 9) / 10) - 1) << 10; 1138 ? spd0[29] : spd0[28]) + 9) / 10) - 1) << 10;
1127 data |= ((spd0[30] - spd0[29] + 9) / 10 - 2) << 12; 1139 data |= ((spd0[30] - spd0[29] + 9) / 10 - 2) << 12;
1128 1140
1129 if (spd0[18] & 0x08) 1141 if (spd0[18] & 0x08)
1130 data |= ((0x03) << 14); 1142 data |= ((0x03) << 14);
1131 else if (spd0[18] & 0x04) 1143 else if (spd0[18] & 0x04)
1132 data |= ((0x02) << 14); 1144 data |= ((0x02) << 14);
@@ -1135,7 +1147,7 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
1135 else 1147 else
1136 data |= (0 << 14); 1148 data |= (0 << 14);
1137 1149
1138 /* 1150 /*
1139 Calculate the size of bDIMMSize (power of 2) and 1151 Calculate the size of bDIMMSize (power of 2) and
1140 merge the DIMM size by program start/end address. 1152 merge the DIMM size by program start/end address.
1141 */ 1153 */
@@ -1145,9 +1157,9 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
1145 data |= (((size / 16) - 1) << 16); 1157 data |= (((size / 16) - 1) << 16);
1146 data |= (0 << 23); 1158 data |= (0 << 23);
1147 data |= 8; 1159 data |= 8;
1148 writel(data, mmio + PDC_DIMM0_CONTROL_OFFSET); 1160 writel(data, mmio + PDC_DIMM0_CONTROL_OFFSET);
1149 readl(mmio + PDC_DIMM0_CONTROL_OFFSET); 1161 readl(mmio + PDC_DIMM0_CONTROL_OFFSET);
1150 return size; 1162 return size;
1151} 1163}
1152 1164
1153 1165
@@ -1155,7 +1167,7 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe)
1155{ 1167{
1156 u32 data, spd0; 1168 u32 data, spd0;
1157 int error, i; 1169 int error, i;
1158 void *mmio = pe->mmio_base; 1170 void __iomem *mmio = pe->mmio_base;
1159 1171
1160 /* hard-code chip #0 */ 1172 /* hard-code chip #0 */
1161 mmio += PDC_CHIP0_OFS; 1173 mmio += PDC_CHIP0_OFS;
@@ -1167,12 +1179,12 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe)
1167 Refresh Enable (bit 17) 1179 Refresh Enable (bit 17)
1168 */ 1180 */
1169 1181
1170 data = 0x022259F1; 1182 data = 0x022259F1;
1171 writel(data, mmio + PDC_SDRAM_CONTROL_OFFSET); 1183 writel(data, mmio + PDC_SDRAM_CONTROL_OFFSET);
1172 readl(mmio + PDC_SDRAM_CONTROL_OFFSET); 1184 readl(mmio + PDC_SDRAM_CONTROL_OFFSET);
1173 1185
1174 /* Turn on for ECC */ 1186 /* Turn on for ECC */
1175 pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS, 1187 pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS,
1176 PDC_DIMM_SPD_TYPE, &spd0); 1188 PDC_DIMM_SPD_TYPE, &spd0);
1177 if (spd0 == 0x02) { 1189 if (spd0 == 0x02) {
1178 data |= (0x01 << 16); 1190 data |= (0x01 << 16);
@@ -1186,22 +1198,22 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe)
1186 data |= (1<<19); 1198 data |= (1<<19);
1187 writel(data, mmio + PDC_SDRAM_CONTROL_OFFSET); 1199 writel(data, mmio + PDC_SDRAM_CONTROL_OFFSET);
1188 1200
1189 error = 1; 1201 error = 1;
1190 for (i = 1; i <= 10; i++) { /* polling ~5 secs */ 1202 for (i = 1; i <= 10; i++) { /* polling ~5 secs */
1191 data = readl(mmio + PDC_SDRAM_CONTROL_OFFSET); 1203 data = readl(mmio + PDC_SDRAM_CONTROL_OFFSET);
1192 if (!(data & (1<<19))) { 1204 if (!(data & (1<<19))) {
1193 error = 0; 1205 error = 0;
1194 break; 1206 break;
1195 } 1207 }
1196 msleep(i*100); 1208 msleep(i*100);
1197 } 1209 }
1198 return error; 1210 return error;
1199} 1211}
1200 1212
1201 1213
1202static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe) 1214static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
1203{ 1215{
1204 int speed, size, length; 1216 int speed, size, length;
1205 u32 addr,spd0,pci_status; 1217 u32 addr,spd0,pci_status;
1206 u32 tmp=0; 1218 u32 tmp=0;
1207 u32 time_period=0; 1219 u32 time_period=0;
@@ -1209,7 +1221,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
1209 u32 ticks=0; 1221 u32 ticks=0;
1210 u32 clock=0; 1222 u32 clock=0;
1211 u32 fparam=0; 1223 u32 fparam=0;
1212 void *mmio = pe->mmio_base; 1224 void __iomem *mmio = pe->mmio_base;
1213 1225
1214 /* hard-code chip #0 */ 1226 /* hard-code chip #0 */
1215 mmio += PDC_CHIP0_OFS; 1227 mmio += PDC_CHIP0_OFS;
@@ -1228,7 +1240,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
1228 /* Wait 3 seconds */ 1240 /* Wait 3 seconds */
1229 msleep(3000); 1241 msleep(3000);
1230 1242
1231 /* 1243 /*
1232 When timer is enabled, counter is decreased every internal 1244 When timer is enabled, counter is decreased every internal
1233 clock cycle. 1245 clock cycle.
1234 */ 1246 */
@@ -1236,24 +1248,24 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
1236 tcount = readl(mmio + PDC_TIME_COUNTER); 1248 tcount = readl(mmio + PDC_TIME_COUNTER);
1237 VPRINTK("Time Counter Register (0x44): 0x%x\n", tcount); 1249 VPRINTK("Time Counter Register (0x44): 0x%x\n", tcount);
1238 1250
1239 /* 1251 /*
1240 If SX4 is on PCI-X bus, after 3 seconds, the timer counter 1252 If SX4 is on PCI-X bus, after 3 seconds, the timer counter
1241 register should be >= (0xffffffff - 3x10^8). 1253 register should be >= (0xffffffff - 3x10^8).
1242 */ 1254 */
1243 if(tcount >= PCI_X_TCOUNT) { 1255 if(tcount >= PCI_X_TCOUNT) {
1244 ticks = (time_period - tcount); 1256 ticks = (time_period - tcount);
1245 VPRINTK("Num counters 0x%x (%d)\n", ticks, ticks); 1257 VPRINTK("Num counters 0x%x (%d)\n", ticks, ticks);
1246 1258
1247 clock = (ticks / 300000); 1259 clock = (ticks / 300000);
1248 VPRINTK("10 * Internal clk = 0x%x (%d)\n", clock, clock); 1260 VPRINTK("10 * Internal clk = 0x%x (%d)\n", clock, clock);
1249 1261
1250 clock = (clock * 33); 1262 clock = (clock * 33);
1251 VPRINTK("10 * Internal clk * 33 = 0x%x (%d)\n", clock, clock); 1263 VPRINTK("10 * Internal clk * 33 = 0x%x (%d)\n", clock, clock);
1252 1264
1253 /* PLL F Param (bit 22:16) */ 1265 /* PLL F Param (bit 22:16) */
1254 fparam = (1400000 / clock) - 2; 1266 fparam = (1400000 / clock) - 2;
1255 VPRINTK("PLL F Param: 0x%x (%d)\n", fparam, fparam); 1267 VPRINTK("PLL F Param: 0x%x (%d)\n", fparam, fparam);
1256 1268
1257 /* OD param = 0x2 (bit 31:30), R param = 0x5 (bit 29:25) */ 1269 /* OD param = 0x2 (bit 31:30), R param = 0x5 (bit 29:25) */
1258 pci_status = (0x8a001824 | (fparam << 16)); 1270 pci_status = (0x8a001824 | (fparam << 16));
1259 } else 1271 } else
@@ -1264,21 +1276,21 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
1264 writel(pci_status, mmio + PDC_CTL_STATUS); 1276 writel(pci_status, mmio + PDC_CTL_STATUS);
1265 readl(mmio + PDC_CTL_STATUS); 1277 readl(mmio + PDC_CTL_STATUS);
1266 1278
1267 /* 1279 /*
1268 Read SPD of DIMM by I2C interface, 1280 Read SPD of DIMM by I2C interface,
1269 and program the DIMM Module Controller. 1281 and program the DIMM Module Controller.
1270 */ 1282 */
1271 if (!(speed = pdc20621_detect_dimm(pe))) { 1283 if (!(speed = pdc20621_detect_dimm(pe))) {
1272 printk(KERN_ERR "Detect Local DIMM Fail\n"); 1284 printk(KERN_ERR "Detect Local DIMM Fail\n");
1273 return 1; /* DIMM error */ 1285 return 1; /* DIMM error */
1274 } 1286 }
1275 VPRINTK("Local DIMM Speed = %d\n", speed); 1287 VPRINTK("Local DIMM Speed = %d\n", speed);
1276 1288
1277 /* Programming DIMM0 Module Control Register (index_CID0:80h) */ 1289 /* Programming DIMM0 Module Control Register (index_CID0:80h) */
1278 size = pdc20621_prog_dimm0(pe); 1290 size = pdc20621_prog_dimm0(pe);
1279 VPRINTK("Local DIMM Size = %dMB\n",size); 1291 VPRINTK("Local DIMM Size = %dMB\n",size);
1280 1292
1281 /* Programming DIMM Module Global Control Register (index_CID0:88h) */ 1293 /* Programming DIMM Module Global Control Register (index_CID0:88h) */
1282 if (pdc20621_prog_dimm_global(pe)) { 1294 if (pdc20621_prog_dimm_global(pe)) {
1283 printk(KERN_ERR "Programming DIMM Module Global Control Register Fail\n"); 1295 printk(KERN_ERR "Programming DIMM Module Global Control Register Fail\n");
1284 return 1; 1296 return 1;
@@ -1297,30 +1309,30 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
1297 1309
1298 pdc20621_put_to_dimm(pe, (void *) test_parttern1, 0x10040, 40); 1310 pdc20621_put_to_dimm(pe, (void *) test_parttern1, 0x10040, 40);
1299 pdc20621_get_from_dimm(pe, (void *) test_parttern2, 0x40, 40); 1311 pdc20621_get_from_dimm(pe, (void *) test_parttern2, 0x40, 40);
1300 printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], 1312 printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0],
1301 test_parttern2[1], &(test_parttern2[2])); 1313 test_parttern2[1], &(test_parttern2[2]));
1302 pdc20621_get_from_dimm(pe, (void *) test_parttern2, 0x10040, 1314 pdc20621_get_from_dimm(pe, (void *) test_parttern2, 0x10040,
1303 40); 1315 40);
1304 printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], 1316 printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0],
1305 test_parttern2[1], &(test_parttern2[2])); 1317 test_parttern2[1], &(test_parttern2[2]));
1306 1318
1307 pdc20621_put_to_dimm(pe, (void *) test_parttern1, 0x40, 40); 1319 pdc20621_put_to_dimm(pe, (void *) test_parttern1, 0x40, 40);
1308 pdc20621_get_from_dimm(pe, (void *) test_parttern2, 0x40, 40); 1320 pdc20621_get_from_dimm(pe, (void *) test_parttern2, 0x40, 40);
1309 printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], 1321 printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0],
1310 test_parttern2[1], &(test_parttern2[2])); 1322 test_parttern2[1], &(test_parttern2[2]));
1311 } 1323 }
1312#endif 1324#endif
1313 1325
1314 /* ECC initiliazation. */ 1326 /* ECC initiliazation. */
1315 1327
1316 pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS, 1328 pdc20621_i2c_read(pe, PDC_DIMM0_SPD_DEV_ADDRESS,
1317 PDC_DIMM_SPD_TYPE, &spd0); 1329 PDC_DIMM_SPD_TYPE, &spd0);
1318 if (spd0 == 0x02) { 1330 if (spd0 == 0x02) {
1319 VPRINTK("Start ECC initialization\n"); 1331 VPRINTK("Start ECC initialization\n");
1320 addr = 0; 1332 addr = 0;
1321 length = size * 1024 * 1024; 1333 length = size * 1024 * 1024;
1322 while (addr < length) { 1334 while (addr < length) {
1323 pdc20621_put_to_dimm(pe, (void *) &tmp, addr, 1335 pdc20621_put_to_dimm(pe, (void *) &tmp, addr,
1324 sizeof(u32)); 1336 sizeof(u32));
1325 addr += sizeof(u32); 1337 addr += sizeof(u32);
1326 } 1338 }
@@ -1333,7 +1345,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
1333static void pdc_20621_init(struct ata_probe_ent *pe) 1345static void pdc_20621_init(struct ata_probe_ent *pe)
1334{ 1346{
1335 u32 tmp; 1347 u32 tmp;
1336 void *mmio = pe->mmio_base; 1348 void __iomem *mmio = pe->mmio_base;
1337 1349
1338 /* hard-code chip #0 */ 1350 /* hard-code chip #0 */
1339 mmio += PDC_CHIP0_OFS; 1351 mmio += PDC_CHIP0_OFS;
@@ -1366,7 +1378,8 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
1366 static int printed_version; 1378 static int printed_version;
1367 struct ata_probe_ent *probe_ent = NULL; 1379 struct ata_probe_ent *probe_ent = NULL;
1368 unsigned long base; 1380 unsigned long base;
1369 void *mmio_base, *dimm_mmio = NULL; 1381 void __iomem *mmio_base;
1382 void __iomem *dimm_mmio = NULL;
1370 struct pdc_host_priv *hpriv = NULL; 1383 struct pdc_host_priv *hpriv = NULL;
1371 unsigned int board_idx = (unsigned int) ent->driver_data; 1384 unsigned int board_idx = (unsigned int) ent->driver_data;
1372 int pci_dev_busy = 0; 1385 int pci_dev_busy = 0;
@@ -1406,8 +1419,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
1406 probe_ent->dev = pci_dev_to_dev(pdev); 1419 probe_ent->dev = pci_dev_to_dev(pdev);
1407 INIT_LIST_HEAD(&probe_ent->node); 1420 INIT_LIST_HEAD(&probe_ent->node);
1408 1421
1409 mmio_base = ioremap(pci_resource_start(pdev, 3), 1422 mmio_base = pci_iomap(pdev, 3, 0);
1410 pci_resource_len(pdev, 3));
1411 if (mmio_base == NULL) { 1423 if (mmio_base == NULL) {
1412 rc = -ENOMEM; 1424 rc = -ENOMEM;
1413 goto err_out_free_ent; 1425 goto err_out_free_ent;
@@ -1421,8 +1433,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
1421 } 1433 }
1422 memset(hpriv, 0, sizeof(*hpriv)); 1434 memset(hpriv, 0, sizeof(*hpriv));
1423 1435
1424 dimm_mmio = ioremap(pci_resource_start(pdev, 4), 1436 dimm_mmio = pci_iomap(pdev, 4, 0);
1425 pci_resource_len(pdev, 4));
1426 if (!dimm_mmio) { 1437 if (!dimm_mmio) {
1427 kfree(hpriv); 1438 kfree(hpriv);
1428 rc = -ENOMEM; 1439 rc = -ENOMEM;
@@ -1469,9 +1480,9 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
1469 1480
1470err_out_iounmap_dimm: /* only get to this label if 20621 */ 1481err_out_iounmap_dimm: /* only get to this label if 20621 */
1471 kfree(hpriv); 1482 kfree(hpriv);
1472 iounmap(dimm_mmio); 1483 pci_iounmap(pdev, dimm_mmio);
1473err_out_iounmap: 1484err_out_iounmap:
1474 iounmap(mmio_base); 1485 pci_iounmap(pdev, mmio_base);
1475err_out_free_ent: 1486err_out_free_ent:
1476 kfree(probe_ent); 1487 kfree(probe_ent);
1477err_out_regions: 1488err_out_regions:
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index a71fb54eebd3..42e13ed8eb5b 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -1,21 +1,26 @@
1/* 1/*
2 * sata_uli.c - ULi Electronics SATA 2 * sata_uli.c - ULi Electronics SATA
3 * 3 *
4 * The contents of this file are subject to the Open
5 * Software License version 1.1 that can be found at
6 * http://www.opensource.org/licenses/osl-1.1.txt and is included herein
7 * by reference.
8 * 4 *
9 * Alternatively, the contents of this file may be used under the terms 5 * This program is free software; you can redistribute it and/or modify
10 * of the GNU General Public License version 2 (the "GPL") as distributed 6 * it under the terms of the GNU General Public License as published by
11 * in the kernel source COPYING file, in which case the provisions of 7 * the Free Software Foundation; either version 2, or (at your option)
12 * the GPL are applicable instead of the above. If you wish to allow 8 * any later version.
13 * the use of your version of this file only under the terms of the 9 *
14 * GPL and not to allow others to use your version of this file under 10 * This program is distributed in the hope that it will be useful,
15 * the OSL, indicate your decision by deleting the provisions above and 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * replace them with the notice and other provisions required by the GPL. 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * If you do not delete the provisions above, a recipient may use your 13 * GNU General Public License for more details.
18 * version of this file under either the OSL or the GPL. 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 *
20 * libata documentation is available via 'make {ps|pdf}docs',
21 * as Documentation/DocBook/libata.*
22 *
23 * Hardware documentation available under NDA.
19 * 24 *
20 */ 25 */
21 26
@@ -120,8 +125,8 @@ static struct ata_port_info uli_port_info = {
120 .sht = &uli_sht, 125 .sht = &uli_sht,
121 .host_flags = ATA_FLAG_SATA | ATA_FLAG_SATA_RESET | 126 .host_flags = ATA_FLAG_SATA | ATA_FLAG_SATA_RESET |
122 ATA_FLAG_NO_LEGACY, 127 ATA_FLAG_NO_LEGACY,
123 .pio_mask = 0x03, //support pio mode 4 (FIXME) 128 .pio_mask = 0x1f, /* pio0-4 */
124 .udma_mask = 0x7f, //support udma mode 6 129 .udma_mask = 0x7f, /* udma0-6 */
125 .port_ops = &uli_ops, 130 .port_ops = &uli_ops,
126}; 131};
127 132
@@ -214,7 +219,7 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
214 rc = -ENOMEM; 219 rc = -ENOMEM;
215 goto err_out_regions; 220 goto err_out_regions;
216 } 221 }
217 222
218 switch (board_idx) { 223 switch (board_idx) {
219 case uli_5287: 224 case uli_5287:
220 probe_ent->port[0].scr_addr = ULI5287_BASE; 225 probe_ent->port[0].scr_addr = ULI5287_BASE;
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
index f43183c19a12..128b996b07b7 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/scsi/sata_via.c
@@ -1,34 +1,38 @@
1/* 1/*
2 sata_via.c - VIA Serial ATA controllers 2 * sata_via.c - VIA Serial ATA controllers
3 3 *
4 Maintained by: Jeff Garzik <jgarzik@pobox.com> 4 * Maintained by: Jeff Garzik <jgarzik@pobox.com>
5 Please ALWAYS copy linux-ide@vger.kernel.org 5 * Please ALWAYS copy linux-ide@vger.kernel.org
6 on emails. 6 on emails.
7 7 *
8 Copyright 2003-2004 Red Hat, Inc. All rights reserved. 8 * Copyright 2003-2004 Red Hat, Inc. All rights reserved.
9 Copyright 2003-2004 Jeff Garzik 9 * Copyright 2003-2004 Jeff Garzik
10 10 *
11 The contents of this file are subject to the Open 11 *
12 Software License version 1.1 that can be found at 12 * This program is free software; you can redistribute it and/or modify
13 http://www.opensource.org/licenses/osl-1.1.txt and is included herein 13 * it under the terms of the GNU General Public License as published by
14 by reference. 14 * the Free Software Foundation; either version 2, or (at your option)
15 15 * any later version.
16 Alternatively, the contents of this file may be used under the terms 16 *
17 of the GNU General Public License version 2 (the "GPL") as distributed 17 * This program is distributed in the hope that it will be useful,
18 in the kernel source COPYING file, in which case the provisions of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 the GPL are applicable instead of the above. If you wish to allow 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 the use of your version of this file only under the terms of the 20 * GNU General Public License for more details.
21 GPL and not to allow others to use your version of this file under 21 *
22 the OSL, indicate your decision by deleting the provisions above and 22 * You should have received a copy of the GNU General Public License
23 replace them with the notice and other provisions required by the GPL. 23 * along with this program; see the file COPYING. If not, write to
24 If you do not delete the provisions above, a recipient may use your 24 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25 version of this file under either the OSL or the GPL. 25 *
26 26 *
27 ---------------------------------------------------------------------- 27 * libata documentation is available via 'make {ps|pdf}docs',
28 28 * as Documentation/DocBook/libata.*
29 To-do list: 29 *
30 * VT6421 PATA support 30 * Hardware documentation available under NDA.
31 31 *
32 *
33 * To-do list:
34 * - VT6421 PATA support
35 *
32 */ 36 */
33 37
34#include <linux/kernel.h> 38#include <linux/kernel.h>
@@ -347,7 +351,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
347 probe_ent = vt6420_init_probe_ent(pdev); 351 probe_ent = vt6420_init_probe_ent(pdev);
348 else 352 else
349 probe_ent = vt6421_init_probe_ent(pdev); 353 probe_ent = vt6421_init_probe_ent(pdev);
350 354
351 if (!probe_ent) { 355 if (!probe_ent) {
352 printk(KERN_ERR DRV_NAME "(%s): out of memory\n", 356 printk(KERN_ERR DRV_NAME "(%s): out of memory\n",
353 pci_name(pdev)); 357 pci_name(pdev));
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index c5e09dc6f3de..cf94e0158a8d 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -9,9 +9,29 @@
9 * 9 *
10 * Bits from Jeff Garzik, Copyright RedHat, Inc. 10 * Bits from Jeff Garzik, Copyright RedHat, Inc.
11 * 11 *
12 * This file is subject to the terms and conditions of the GNU General Public 12 *
13 * License. See the file "COPYING" in the main directory of this archive 13 * This program is free software; you can redistribute it and/or modify
14 * for more details. 14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
16 * any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; see the file COPYING. If not, write to
25 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 *
28 * libata documentation is available via 'make {ps|pdf}docs',
29 * as Documentation/DocBook/libata.*
30 *
31 * Vitesse hardware documentation presumably available under NDA.
32 * Intel 31244 (same hardware interface) documentation presumably
33 * available from http://developer.intel.com/
34 *
15 */ 35 */
16 36
17#include <linux/kernel.h> 37#include <linux/kernel.h>
@@ -173,7 +193,8 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
173 struct ata_port *ap; 193 struct ata_port *ap;
174 194
175 ap = host_set->ports[i]; 195 ap = host_set->ports[i];
176 if (ap && (!(ap->flags & ATA_FLAG_PORT_DISABLED))) { 196 if (ap && !(ap->flags &
197 (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) {
177 struct ata_queued_cmd *qc; 198 struct ata_queued_cmd *qc;
178 199
179 qc = ata_qc_from_tag(ap, ap->active_tag); 200 qc = ata_qc_from_tag(ap, ap->active_tag);
@@ -231,7 +252,7 @@ static struct ata_port_operations vsc_sata_ops = {
231 .scr_write = vsc_sata_scr_write, 252 .scr_write = vsc_sata_scr_write,
232 .port_start = ata_port_start, 253 .port_start = ata_port_start,
233 .port_stop = ata_port_stop, 254 .port_stop = ata_port_stop,
234 .host_stop = ata_host_stop, 255 .host_stop = ata_pci_host_stop,
235}; 256};
236 257
237static void __devinit vsc_sata_setup_port(struct ata_ioports *port, unsigned long base) 258static void __devinit vsc_sata_setup_port(struct ata_ioports *port, unsigned long base)
@@ -305,8 +326,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
305 probe_ent->dev = pci_dev_to_dev(pdev); 326 probe_ent->dev = pci_dev_to_dev(pdev);
306 INIT_LIST_HEAD(&probe_ent->node); 327 INIT_LIST_HEAD(&probe_ent->node);
307 328
308 mmio_base = ioremap(pci_resource_start(pdev, 0), 329 mmio_base = pci_iomap(pdev, 0, 0);
309 pci_resource_len(pdev, 0));
310 if (mmio_base == NULL) { 330 if (mmio_base == NULL) {
311 rc = -ENOMEM; 331 rc = -ENOMEM;
312 goto err_out_free_ent; 332 goto err_out_free_ent;
@@ -342,7 +362,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
342 362
343 pci_set_master(pdev); 363 pci_set_master(pdev);
344 364
345 /* 365 /*
346 * Config offset 0x98 is "Extended Control and Status Register 0" 366 * Config offset 0x98 is "Extended Control and Status Register 0"
347 * Default value is (1 << 28). All bits except bit 28 are reserved in 367 * Default value is (1 << 28). All bits except bit 28 are reserved in
348 * DPA mode. If bit 28 is set, LED 0 reflects all ports' activity. 368 * DPA mode. If bit 28 is set, LED 0 reflects all ports' activity.