aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_svw.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/sata_svw.c')
-rw-r--r--drivers/ata/sata_svw.c107
1 files changed, 50 insertions, 57 deletions
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index b121195cc598..cc07aac10e8c 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -56,7 +56,9 @@
56#define DRV_VERSION "2.1" 56#define DRV_VERSION "2.1"
57 57
58enum { 58enum {
59 K2_FLAG_NO_ATAPI_DMA = (1 << 29), 59 /* ap->flags bits */
60 K2_FLAG_SATA_8_PORTS = (1 << 24),
61 K2_FLAG_NO_ATAPI_DMA = (1 << 25),
60 62
61 /* Taskfile registers offsets */ 63 /* Taskfile registers offsets */
62 K2_SATA_TF_CMD_OFFSET = 0x00, 64 K2_SATA_TF_CMD_OFFSET = 0x00,
@@ -90,17 +92,6 @@ enum {
90 board_svw8 = 1, 92 board_svw8 = 1,
91}; 93};
92 94
93static const struct k2_board_info {
94 unsigned int n_ports;
95 unsigned long port_flags;
96} k2_board_info[] = {
97 /* board_svw4 */
98 { 4, K2_FLAG_NO_ATAPI_DMA },
99
100 /* board_svw8 */
101 { 8, K2_FLAG_NO_ATAPI_DMA },
102};
103
104static u8 k2_stat_check_status(struct ata_port *ap); 95static u8 k2_stat_check_status(struct ata_port *ap);
105 96
106 97
@@ -354,7 +345,6 @@ static const struct ata_port_operations k2_sata_ops = {
354 .thaw = ata_bmdma_thaw, 345 .thaw = ata_bmdma_thaw,
355 .error_handler = ata_bmdma_error_handler, 346 .error_handler = ata_bmdma_error_handler,
356 .post_internal_cmd = ata_bmdma_post_internal_cmd, 347 .post_internal_cmd = ata_bmdma_post_internal_cmd,
357 .irq_handler = ata_interrupt,
358 .irq_clear = ata_bmdma_irq_clear, 348 .irq_clear = ata_bmdma_irq_clear,
359 .irq_on = ata_irq_on, 349 .irq_on = ata_irq_on,
360 .irq_ack = ata_irq_ack, 350 .irq_ack = ata_irq_ack,
@@ -363,6 +353,28 @@ static const struct ata_port_operations k2_sata_ops = {
363 .port_start = ata_port_start, 353 .port_start = ata_port_start,
364}; 354};
365 355
356static const struct ata_port_info k2_port_info[] = {
357 /* board_svw4 */
358 {
359 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
360 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA,
361 .pio_mask = 0x1f,
362 .mwdma_mask = 0x07,
363 .udma_mask = 0x7f,
364 .port_ops = &k2_sata_ops,
365 },
366 /* board_svw8 */
367 {
368 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
369 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA |
370 K2_FLAG_SATA_8_PORTS,
371 .pio_mask = 0x1f,
372 .mwdma_mask = 0x07,
373 .udma_mask = 0x7f,
374 .port_ops = &k2_sata_ops,
375 },
376};
377
366static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base) 378static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base)
367{ 379{
368 port->cmd_addr = base + K2_SATA_TF_CMD_OFFSET; 380 port->cmd_addr = base + K2_SATA_TF_CMD_OFFSET;
@@ -386,17 +398,24 @@ static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base)
386static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 398static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
387{ 399{
388 static int printed_version; 400 static int printed_version;
389 struct device *dev = &pdev->dev; 401 const struct ata_port_info *ppi[] =
390 struct ata_probe_ent *probe_ent; 402 { &k2_port_info[ent->driver_data], NULL };
403 struct ata_host *host;
391 void __iomem *mmio_base; 404 void __iomem *mmio_base;
392 const struct k2_board_info *board_info = 405 int n_ports, i, rc;
393 &k2_board_info[ent->driver_data];
394 int rc;
395 int i;
396 406
397 if (!printed_version++) 407 if (!printed_version++)
398 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 408 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
399 409
410 /* allocate host */
411 n_ports = 4;
412 if (ppi[0]->flags & K2_FLAG_SATA_8_PORTS)
413 n_ports = 8;
414
415 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
416 if (!host)
417 return -ENOMEM;
418
400 /* 419 /*
401 * If this driver happens to only be useful on Apple's K2, then 420 * If this driver happens to only be useful on Apple's K2, then
402 * we should check that here as it has a normal Serverworks ID 421 * we should check that here as it has a normal Serverworks ID
@@ -404,6 +423,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
404 rc = pcim_enable_device(pdev); 423 rc = pcim_enable_device(pdev);
405 if (rc) 424 if (rc)
406 return rc; 425 return rc;
426
407 /* 427 /*
408 * Check if we have resources mapped at all (second function may 428 * Check if we have resources mapped at all (second function may
409 * have been disabled by firmware) 429 * have been disabled by firmware)
@@ -417,6 +437,15 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
417 pcim_pin_device(pdev); 437 pcim_pin_device(pdev);
418 if (rc) 438 if (rc)
419 return rc; 439 return rc;
440 host->iomap = pcim_iomap_table(pdev);
441 mmio_base = host->iomap[5];
442
443 /* different controllers have different number of ports - currently 4 or 8 */
444 /* All ports are on the same function. Multi-function device is no
445 * longer available. This should not be seen in any system. */
446 for (i = 0; i < host->n_ports; i++)
447 k2_sata_setup_port(&host->ports[i]->ioaddr,
448 mmio_base + i * K2_SATA_PORT_OFFSET);
420 449
421 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); 450 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
422 if (rc) 451 if (rc)
@@ -425,38 +454,6 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
425 if (rc) 454 if (rc)
426 return rc; 455 return rc;
427 456
428 probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL);
429 if (probe_ent == NULL)
430 return -ENOMEM;
431
432 probe_ent->dev = pci_dev_to_dev(pdev);
433 INIT_LIST_HEAD(&probe_ent->node);
434
435 probe_ent->sht = &k2_sata_sht;
436 probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
437 ATA_FLAG_MMIO | board_info->port_flags;
438 probe_ent->port_ops = &k2_sata_ops;
439 probe_ent->n_ports = 4;
440 probe_ent->irq = pdev->irq;
441 probe_ent->irq_flags = IRQF_SHARED;
442 probe_ent->iomap = pcim_iomap_table(pdev);
443
444 /* We don't care much about the PIO/UDMA masks, but the core won't like us
445 * if we don't fill these
446 */
447 probe_ent->pio_mask = 0x1f;
448 probe_ent->mwdma_mask = 0x7;
449 probe_ent->udma_mask = 0x7f;
450
451 mmio_base = probe_ent->iomap[5];
452
453 /* different controllers have different number of ports - currently 4 or 8 */
454 /* All ports are on the same function. Multi-function device is no
455 * longer available. This should not be seen in any system. */
456 for (i = 0; i < board_info->n_ports; i++)
457 k2_sata_setup_port(&probe_ent->port[i],
458 mmio_base + i * K2_SATA_PORT_OFFSET);
459
460 /* Clear a magic bit in SCR1 according to Darwin, those help 457 /* Clear a magic bit in SCR1 according to Darwin, those help
461 * some funky seagate drives (though so far, those were already 458 * some funky seagate drives (though so far, those were already
462 * set by the firmware on the machines I had access to) 459 * set by the firmware on the machines I had access to)
@@ -469,12 +466,8 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
469 writel(0x0, mmio_base + K2_SATA_SIM_OFFSET); 466 writel(0x0, mmio_base + K2_SATA_SIM_OFFSET);
470 467
471 pci_set_master(pdev); 468 pci_set_master(pdev);
472 469 return ata_host_activate(host, pdev->irq, ata_interrupt, IRQF_SHARED,
473 if (!ata_device_add(probe_ent)) 470 &k2_sata_sht);
474 return -ENODEV;
475
476 devm_kfree(dev, probe_ent);
477 return 0;
478} 471}
479 472
480/* 0x240 is device ID for Apple K2 device 473/* 0x240 is device ID for Apple K2 device