diff options
Diffstat (limited to 'drivers/scsi/sata_sil.c')
-rw-r--r-- | drivers/scsi/sata_sil.c | 126 |
1 files changed, 50 insertions, 76 deletions
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index 9face3c6aa21..4f2a67ed39d8 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c | |||
@@ -49,24 +49,30 @@ | |||
49 | #define DRV_VERSION "0.9" | 49 | #define DRV_VERSION "0.9" |
50 | 50 | ||
51 | enum { | 51 | enum { |
52 | /* | ||
53 | * host flags | ||
54 | */ | ||
52 | SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29), | 55 | SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29), |
53 | SIL_FLAG_MOD15WRITE = (1 << 30), | 56 | SIL_FLAG_MOD15WRITE = (1 << 30), |
57 | SIL_DFL_HOST_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | ||
58 | ATA_FLAG_MMIO, | ||
54 | 59 | ||
60 | /* | ||
61 | * Controller IDs | ||
62 | */ | ||
55 | sil_3112 = 0, | 63 | sil_3112 = 0, |
56 | sil_3112_m15w = 1, | 64 | sil_3512 = 1, |
57 | sil_3512 = 2, | 65 | sil_3114 = 2, |
58 | sil_3114 = 3, | ||
59 | |||
60 | SIL_FIFO_R0 = 0x40, | ||
61 | SIL_FIFO_W0 = 0x41, | ||
62 | SIL_FIFO_R1 = 0x44, | ||
63 | SIL_FIFO_W1 = 0x45, | ||
64 | SIL_FIFO_R2 = 0x240, | ||
65 | SIL_FIFO_W2 = 0x241, | ||
66 | SIL_FIFO_R3 = 0x244, | ||
67 | SIL_FIFO_W3 = 0x245, | ||
68 | 66 | ||
67 | /* | ||
68 | * Register offsets | ||
69 | */ | ||
69 | SIL_SYSCFG = 0x48, | 70 | SIL_SYSCFG = 0x48, |
71 | |||
72 | /* | ||
73 | * Register bits | ||
74 | */ | ||
75 | /* SYSCFG */ | ||
70 | SIL_MASK_IDE0_INT = (1 << 22), | 76 | SIL_MASK_IDE0_INT = (1 << 22), |
71 | SIL_MASK_IDE1_INT = (1 << 23), | 77 | SIL_MASK_IDE1_INT = (1 << 23), |
72 | SIL_MASK_IDE2_INT = (1 << 24), | 78 | SIL_MASK_IDE2_INT = (1 << 24), |
@@ -75,9 +81,12 @@ enum { | |||
75 | SIL_MASK_4PORT = SIL_MASK_2PORT | | 81 | SIL_MASK_4PORT = SIL_MASK_2PORT | |
76 | SIL_MASK_IDE2_INT | SIL_MASK_IDE3_INT, | 82 | SIL_MASK_IDE2_INT | SIL_MASK_IDE3_INT, |
77 | 83 | ||
78 | SIL_IDE2_BMDMA = 0x200, | 84 | /* BMDMA/BMDMA2 */ |
79 | |||
80 | SIL_INTR_STEERING = (1 << 1), | 85 | SIL_INTR_STEERING = (1 << 1), |
86 | |||
87 | /* | ||
88 | * Others | ||
89 | */ | ||
81 | SIL_QUIRK_MOD15WRITE = (1 << 0), | 90 | SIL_QUIRK_MOD15WRITE = (1 << 0), |
82 | SIL_QUIRK_UDMA5MAX = (1 << 1), | 91 | SIL_QUIRK_UDMA5MAX = (1 << 1), |
83 | }; | 92 | }; |
@@ -90,13 +99,13 @@ static void sil_post_set_mode (struct ata_port *ap); | |||
90 | 99 | ||
91 | 100 | ||
92 | static const struct pci_device_id sil_pci_tbl[] = { | 101 | static const struct pci_device_id sil_pci_tbl[] = { |
93 | { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, | 102 | { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, |
94 | { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, | 103 | { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, |
95 | { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3512 }, | 104 | { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3512 }, |
96 | { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 }, | 105 | { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 }, |
97 | { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, | 106 | { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, |
98 | { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, | 107 | { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, |
99 | { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, | 108 | { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, |
100 | { } /* terminate list */ | 109 | { } /* terminate list */ |
101 | }; | 110 | }; |
102 | 111 | ||
@@ -137,11 +146,11 @@ static struct scsi_host_template sil_sht = { | |||
137 | .name = DRV_NAME, | 146 | .name = DRV_NAME, |
138 | .ioctl = ata_scsi_ioctl, | 147 | .ioctl = ata_scsi_ioctl, |
139 | .queuecommand = ata_scsi_queuecmd, | 148 | .queuecommand = ata_scsi_queuecmd, |
149 | .eh_timed_out = ata_scsi_timed_out, | ||
140 | .eh_strategy_handler = ata_scsi_error, | 150 | .eh_strategy_handler = ata_scsi_error, |
141 | .can_queue = ATA_DEF_QUEUE, | 151 | .can_queue = ATA_DEF_QUEUE, |
142 | .this_id = ATA_SHT_THIS_ID, | 152 | .this_id = ATA_SHT_THIS_ID, |
143 | .sg_tablesize = LIBATA_MAX_PRD, | 153 | .sg_tablesize = LIBATA_MAX_PRD, |
144 | .max_sectors = ATA_MAX_SECTORS, | ||
145 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, | 154 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, |
146 | .emulated = ATA_SHT_EMULATED, | 155 | .emulated = ATA_SHT_EMULATED, |
147 | .use_clustering = ATA_SHT_USE_CLUSTERING, | 156 | .use_clustering = ATA_SHT_USE_CLUSTERING, |
@@ -159,7 +168,7 @@ static const struct ata_port_operations sil_ops = { | |||
159 | .check_status = ata_check_status, | 168 | .check_status = ata_check_status, |
160 | .exec_command = ata_exec_command, | 169 | .exec_command = ata_exec_command, |
161 | .dev_select = ata_std_dev_select, | 170 | .dev_select = ata_std_dev_select, |
162 | .phy_reset = sata_phy_reset, | 171 | .probe_reset = ata_std_probe_reset, |
163 | .post_set_mode = sil_post_set_mode, | 172 | .post_set_mode = sil_post_set_mode, |
164 | .bmdma_setup = ata_bmdma_setup, | 173 | .bmdma_setup = ata_bmdma_setup, |
165 | .bmdma_start = ata_bmdma_start, | 174 | .bmdma_start = ata_bmdma_start, |
@@ -181,19 +190,7 @@ static const struct ata_port_info sil_port_info[] = { | |||
181 | /* sil_3112 */ | 190 | /* sil_3112 */ |
182 | { | 191 | { |
183 | .sht = &sil_sht, | 192 | .sht = &sil_sht, |
184 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 193 | .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_MOD15WRITE, |
185 | ATA_FLAG_SRST | ATA_FLAG_MMIO, | ||
186 | .pio_mask = 0x1f, /* pio0-4 */ | ||
187 | .mwdma_mask = 0x07, /* mwdma0-2 */ | ||
188 | .udma_mask = 0x3f, /* udma0-5 */ | ||
189 | .port_ops = &sil_ops, | ||
190 | }, | ||
191 | /* sil_3112_15w - keep it sync'd w/ sil_3112 */ | ||
192 | { | ||
193 | .sht = &sil_sht, | ||
194 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | ||
195 | ATA_FLAG_SRST | ATA_FLAG_MMIO | | ||
196 | SIL_FLAG_MOD15WRITE, | ||
197 | .pio_mask = 0x1f, /* pio0-4 */ | 194 | .pio_mask = 0x1f, /* pio0-4 */ |
198 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 195 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
199 | .udma_mask = 0x3f, /* udma0-5 */ | 196 | .udma_mask = 0x3f, /* udma0-5 */ |
@@ -202,9 +199,7 @@ static const struct ata_port_info sil_port_info[] = { | |||
202 | /* sil_3512 */ | 199 | /* sil_3512 */ |
203 | { | 200 | { |
204 | .sht = &sil_sht, | 201 | .sht = &sil_sht, |
205 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 202 | .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT, |
206 | ATA_FLAG_SRST | ATA_FLAG_MMIO | | ||
207 | SIL_FLAG_RERR_ON_DMA_ACT, | ||
208 | .pio_mask = 0x1f, /* pio0-4 */ | 203 | .pio_mask = 0x1f, /* pio0-4 */ |
209 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 204 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
210 | .udma_mask = 0x3f, /* udma0-5 */ | 205 | .udma_mask = 0x3f, /* udma0-5 */ |
@@ -213,9 +208,7 @@ static const struct ata_port_info sil_port_info[] = { | |||
213 | /* sil_3114 */ | 208 | /* sil_3114 */ |
214 | { | 209 | { |
215 | .sht = &sil_sht, | 210 | .sht = &sil_sht, |
216 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 211 | .host_flags = SIL_DFL_HOST_FLAGS | SIL_FLAG_RERR_ON_DMA_ACT, |
217 | ATA_FLAG_SRST | ATA_FLAG_MMIO | | ||
218 | SIL_FLAG_RERR_ON_DMA_ACT, | ||
219 | .pio_mask = 0x1f, /* pio0-4 */ | 212 | .pio_mask = 0x1f, /* pio0-4 */ |
220 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 213 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
221 | .udma_mask = 0x3f, /* udma0-5 */ | 214 | .udma_mask = 0x3f, /* udma0-5 */ |
@@ -229,16 +222,17 @@ static const struct { | |||
229 | unsigned long tf; /* ATA taskfile register block */ | 222 | unsigned long tf; /* ATA taskfile register block */ |
230 | unsigned long ctl; /* ATA control/altstatus register block */ | 223 | unsigned long ctl; /* ATA control/altstatus register block */ |
231 | unsigned long bmdma; /* DMA register block */ | 224 | unsigned long bmdma; /* DMA register block */ |
225 | unsigned long fifo_cfg; /* FIFO Valid Byte Count and Control */ | ||
232 | unsigned long scr; /* SATA control register block */ | 226 | unsigned long scr; /* SATA control register block */ |
233 | unsigned long sien; /* SATA Interrupt Enable register */ | 227 | unsigned long sien; /* SATA Interrupt Enable register */ |
234 | unsigned long xfer_mode;/* data transfer mode register */ | 228 | unsigned long xfer_mode;/* data transfer mode register */ |
235 | unsigned long sfis_cfg; /* SATA FIS reception config register */ | 229 | unsigned long sfis_cfg; /* SATA FIS reception config register */ |
236 | } sil_port[] = { | 230 | } sil_port[] = { |
237 | /* port 0 ... */ | 231 | /* port 0 ... */ |
238 | { 0x80, 0x8A, 0x00, 0x100, 0x148, 0xb4, 0x14c }, | 232 | { 0x80, 0x8A, 0x00, 0x40, 0x100, 0x148, 0xb4, 0x14c }, |
239 | { 0xC0, 0xCA, 0x08, 0x180, 0x1c8, 0xf4, 0x1cc }, | 233 | { 0xC0, 0xCA, 0x08, 0x44, 0x180, 0x1c8, 0xf4, 0x1cc }, |
240 | { 0x280, 0x28A, 0x200, 0x300, 0x348, 0x2b4, 0x34c }, | 234 | { 0x280, 0x28A, 0x200, 0x240, 0x300, 0x348, 0x2b4, 0x34c }, |
241 | { 0x2C0, 0x2CA, 0x208, 0x380, 0x3c8, 0x2f4, 0x3cc }, | 235 | { 0x2C0, 0x2CA, 0x208, 0x244, 0x380, 0x3c8, 0x2f4, 0x3cc }, |
242 | /* ... port 3 */ | 236 | /* ... port 3 */ |
243 | }; | 237 | }; |
244 | 238 | ||
@@ -354,22 +348,12 @@ static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) | |||
354 | static void sil_dev_config(struct ata_port *ap, struct ata_device *dev) | 348 | static void sil_dev_config(struct ata_port *ap, struct ata_device *dev) |
355 | { | 349 | { |
356 | unsigned int n, quirks = 0; | 350 | unsigned int n, quirks = 0; |
357 | unsigned char model_num[40]; | 351 | unsigned char model_num[41]; |
358 | const char *s; | ||
359 | unsigned int len; | ||
360 | 352 | ||
361 | ata_dev_id_string(dev->id, model_num, ATA_ID_PROD_OFS, | 353 | ata_id_c_string(dev->id, model_num, ATA_ID_PROD_OFS, sizeof(model_num)); |
362 | sizeof(model_num)); | ||
363 | s = &model_num[0]; | ||
364 | len = strnlen(s, sizeof(model_num)); | ||
365 | |||
366 | /* ATAPI specifies that empty space is blank-filled; remove blanks */ | ||
367 | while ((len > 0) && (s[len - 1] == ' ')) | ||
368 | len--; | ||
369 | 354 | ||
370 | for (n = 0; sil_blacklist[n].product; n++) | 355 | for (n = 0; sil_blacklist[n].product; n++) |
371 | if (!memcmp(sil_blacklist[n].product, s, | 356 | if (!strcmp(sil_blacklist[n].product, model_num)) { |
372 | strlen(sil_blacklist[n].product))) { | ||
373 | quirks = sil_blacklist[n].quirk; | 357 | quirks = sil_blacklist[n].quirk; |
374 | break; | 358 | break; |
375 | } | 359 | } |
@@ -380,16 +364,14 @@ static void sil_dev_config(struct ata_port *ap, struct ata_device *dev) | |||
380 | (quirks & SIL_QUIRK_MOD15WRITE))) { | 364 | (quirks & SIL_QUIRK_MOD15WRITE))) { |
381 | printk(KERN_INFO "ata%u(%u): applying Seagate errata fix (mod15write workaround)\n", | 365 | printk(KERN_INFO "ata%u(%u): applying Seagate errata fix (mod15write workaround)\n", |
382 | ap->id, dev->devno); | 366 | ap->id, dev->devno); |
383 | ap->host->max_sectors = 15; | 367 | dev->max_sectors = 15; |
384 | ap->host->hostt->max_sectors = 15; | ||
385 | dev->flags |= ATA_DFLAG_LOCK_SECTORS; | ||
386 | return; | 368 | return; |
387 | } | 369 | } |
388 | 370 | ||
389 | /* limit to udma5 */ | 371 | /* limit to udma5 */ |
390 | if (quirks & SIL_QUIRK_UDMA5MAX) { | 372 | if (quirks & SIL_QUIRK_UDMA5MAX) { |
391 | printk(KERN_INFO "ata%u(%u): applying Maxtor errata fix %s\n", | 373 | printk(KERN_INFO "ata%u(%u): applying Maxtor errata fix %s\n", |
392 | ap->id, dev->devno, s); | 374 | ap->id, dev->devno, model_num); |
393 | ap->udma_mask &= ATA_UDMA5; | 375 | ap->udma_mask &= ATA_UDMA5; |
394 | return; | 376 | return; |
395 | } | 377 | } |
@@ -431,13 +413,12 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
431 | if (rc) | 413 | if (rc) |
432 | goto err_out_regions; | 414 | goto err_out_regions; |
433 | 415 | ||
434 | probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); | 416 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); |
435 | if (probe_ent == NULL) { | 417 | if (probe_ent == NULL) { |
436 | rc = -ENOMEM; | 418 | rc = -ENOMEM; |
437 | goto err_out_regions; | 419 | goto err_out_regions; |
438 | } | 420 | } |
439 | 421 | ||
440 | memset(probe_ent, 0, sizeof(*probe_ent)); | ||
441 | INIT_LIST_HEAD(&probe_ent->node); | 422 | INIT_LIST_HEAD(&probe_ent->node); |
442 | probe_ent->dev = pci_dev_to_dev(pdev); | 423 | probe_ent->dev = pci_dev_to_dev(pdev); |
443 | probe_ent->port_ops = sil_port_info[ent->driver_data].port_ops; | 424 | probe_ent->port_ops = sil_port_info[ent->driver_data].port_ops; |
@@ -474,19 +455,12 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
474 | if (cls) { | 455 | if (cls) { |
475 | cls >>= 3; | 456 | cls >>= 3; |
476 | cls++; /* cls = (line_size/8)+1 */ | 457 | cls++; /* cls = (line_size/8)+1 */ |
477 | writeb(cls, mmio_base + SIL_FIFO_R0); | 458 | for (i = 0; i < probe_ent->n_ports; i++) |
478 | writeb(cls, mmio_base + SIL_FIFO_W0); | 459 | writew(cls << 8 | cls, |
479 | writeb(cls, mmio_base + SIL_FIFO_R1); | 460 | mmio_base + sil_port[i].fifo_cfg); |
480 | writeb(cls, mmio_base + SIL_FIFO_W1); | ||
481 | if (ent->driver_data == sil_3114) { | ||
482 | writeb(cls, mmio_base + SIL_FIFO_R2); | ||
483 | writeb(cls, mmio_base + SIL_FIFO_W2); | ||
484 | writeb(cls, mmio_base + SIL_FIFO_R3); | ||
485 | writeb(cls, mmio_base + SIL_FIFO_W3); | ||
486 | } | ||
487 | } else | 461 | } else |
488 | dev_printk(KERN_WARNING, &pdev->dev, | 462 | dev_printk(KERN_WARNING, &pdev->dev, |
489 | "cache line size not set. Driver may not function\n"); | 463 | "cache line size not set. Driver may not function\n"); |
490 | 464 | ||
491 | /* Apply R_ERR on DMA activate FIS errata workaround */ | 465 | /* Apply R_ERR on DMA activate FIS errata workaround */ |
492 | if (probe_ent->host_flags & SIL_FLAG_RERR_ON_DMA_ACT) { | 466 | if (probe_ent->host_flags & SIL_FLAG_RERR_ON_DMA_ACT) { |
@@ -509,10 +483,10 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
509 | irq_mask = SIL_MASK_4PORT; | 483 | irq_mask = SIL_MASK_4PORT; |
510 | 484 | ||
511 | /* flip the magic "make 4 ports work" bit */ | 485 | /* flip the magic "make 4 ports work" bit */ |
512 | tmp = readl(mmio_base + SIL_IDE2_BMDMA); | 486 | tmp = readl(mmio_base + sil_port[2].bmdma); |
513 | if ((tmp & SIL_INTR_STEERING) == 0) | 487 | if ((tmp & SIL_INTR_STEERING) == 0) |
514 | writel(tmp | SIL_INTR_STEERING, | 488 | writel(tmp | SIL_INTR_STEERING, |
515 | mmio_base + SIL_IDE2_BMDMA); | 489 | mmio_base + sil_port[2].bmdma); |
516 | 490 | ||
517 | } else { | 491 | } else { |
518 | irq_mask = SIL_MASK_2PORT; | 492 | irq_mask = SIL_MASK_2PORT; |