56 #include <linux/kernel.h>
58 #include <linux/module.h>
61 #include <asm/string.h>
71 #define DRV_VERSION __stringify(MAJ) "." __stringify(MIN) "." \
118 unsigned char phy_gen = SCIC_SDS_PARM_GEN2_SPEED;
130 "This field indicates length of the SAS/SATA cable between "
131 "host and device. If any bits > 15 are set (default) "
132 "indicates \"use platform defaults\"");
253 sas_phys[
i] = &isci_host->
phys[
i].sas_phy;
270 static void isci_unregister(
struct isci_host *isci_host)
279 shost = to_shost(isci_host);
287 int err, bar_num, bar_mask = 0;
293 "failed enable PCI device %s!\n",
299 bar_mask |= 1 << (bar_num * 2);
318 err = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(64));
320 err = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(32));
328 static int num_controllers(
struct pci_dev *pdev)
344 static int isci_setup_interrupts(
struct pci_dev *pdev)
346 int err,
i, num_msix;
347 struct isci_host *ihost;
356 for (i = 0; i < num_msix; i++)
363 for (i = 0; i < num_msix; i++) {
375 err = devm_request_irq(&pdev->
dev, msix->vector, isr, 0,
380 dev_info(&pdev->
dev,
"msix setup failed falling back to intx\n");
402 static void isci_user_parameters_get(
struct sci_user_parameters *
u)
407 struct sci_phy_user_params *u_phy = &u->phys[
i];
409 u_phy->max_speed_generation =
phy_gen;
412 u_phy->align_insertion_frequency = 0x7f;
413 u_phy->in_connection_align_insertion_frequency = 0xff;
414 u_phy->notify_enable_spin_up_insertion_frequency = 0x33;
425 static enum sci_status sci_user_parameters_set(
struct isci_host *ihost,
426 struct sci_user_parameters *sci_parms)
435 struct sci_phy_user_params *
u;
437 u = &sci_parms->phys[
index];
439 if (!((u->max_speed_generation <= SCIC_SDS_PARM_MAX_SPEED) &&
440 (u->max_speed_generation > SCIC_SDS_PARM_NO_SPEED)))
443 if (u->in_connection_align_insertion_frequency < 3)
446 if ((u->in_connection_align_insertion_frequency < 3) ||
447 (u->align_insertion_frequency == 0) ||
448 (u->notify_enable_spin_up_insertion_frequency == 0))
452 if ((sci_parms->stp_inactivity_timeout == 0) ||
453 (sci_parms->ssp_inactivity_timeout == 0) ||
454 (sci_parms->stp_max_occupancy_timeout == 0) ||
455 (sci_parms->ssp_max_occupancy_timeout == 0) ||
456 (sci_parms->no_outbound_task_timeout == 0))
464 static void sci_oem_defaults(
struct isci_host *ihost)
485 oem->
ports[i].phy_mask = 0;
490 user->phys[
i].max_speed_generation = SCIC_SDS_PARM_GEN2_SPEED;
493 user->phys[
i].align_insertion_frequency = 0x7f;
494 user->phys[
i].in_connection_align_insertion_frequency = 0xff;
495 user->phys[
i].notify_enable_spin_up_insertion_frequency = 0x33;
502 oem->
phys[
i].sas_address.low = 0x1 + ihost->
id;
503 oem->
phys[
i].sas_address.high = 0x5FCFFFFF;
506 user->stp_inactivity_timeout = 5;
507 user->ssp_inactivity_timeout = 5;
508 user->stp_max_occupancy_timeout = 5;
509 user->ssp_max_occupancy_timeout = 20;
510 user->no_outbound_task_timeout = 2;
513 static struct isci_host *isci_host_alloc(
struct pci_dev *pdev,
int id)
515 struct isci_orom *orom = to_pci_info(pdev)->orom;
516 struct sci_user_parameters sci_user_params;
518 struct isci_host *ihost;
531 ihost->
sas_ha.lldd_ha = ihost;
537 sci_oem_defaults(ihost);
538 isci_user_parameters_get(&sci_user_params);
539 if (sci_user_parameters_set(ihost, &sci_user_params)) {
541 "%s: sci_user_parameters_set failed\n", __func__);
548 dev_warn(&pdev->
dev,
"parsing firmware oem parameters failed\n");
552 oem_version = orom->
hdr.version;
557 dev_warn(&pdev->
dev,
"oem parameter validation failed\n");
574 INIT_LIST_HEAD(&idev->
node);
581 dev_info(&pdev->
dev,
"%sSCU controller %d: phy 3-0 cables: "
582 "{%s, %s, %s, %s}\n",
583 (is_cable_select_overridden() ?
"* " :
""), ihost->
id,
601 err = scsi_add_host(shost, &pdev->
dev);
605 err = isci_register_sas_ha(ihost);
607 goto err_shost_remove;
623 struct isci_host *isci_host;
626 char *
source =
"(platform)";
628 dev_info(&pdev->
dev,
"driver configured for rev: %d silicon\n",
634 pci_set_drvdata(pdev, pci_info);
642 for (i = 0; orom && i < num_controllers(pdev); i++) {
644 orom->
hdr.version)) {
646 "[%d]: invalid oem parameters detected, falling back to firmware\n", i);
653 source =
"(firmware)";
660 "Loading user firmware failed, using default "
663 "Default OEM configuration being used: 4 "
664 "narrow ports, and default SAS Addresses\n");
670 "OEM SAS parameters (version: %u.%u) loaded %s\n",
671 (orom->
hdr.version & 0xf0) >> 4,
672 (orom->
hdr.version & 0xf), source);
674 pci_info->
orom = orom;
676 err = isci_pci_init(pdev);
680 for (i = 0; i < num_controllers(pdev); i++) {
681 struct isci_host *
h = isci_host_alloc(pdev, i);
690 scsi_host_set_prot(to_shost(h),
697 err = isci_setup_interrupts(pdev);
708 isci_unregister(isci_host);
714 struct isci_host *ihost;
719 isci_unregister(ihost);
725 static int isci_suspend(
struct device *dev)
728 struct isci_host *ihost;
743 static int isci_resume(
struct device *dev)
746 struct isci_host *ihost;
755 "enabling device failure after resume(%d)\n", rc);
779 .id_table = isci_id_table,
780 .probe = isci_pci_probe,
783 .driver.pm = &isci_pm_ops,
787 static __init int isci_init(
void)
791 pr_info(
"%s: Intel(R) C600 SAS Controller Driver - version %s\n",
795 if (!isci_transport_template)
798 err = pci_register_driver(&isci_pci_driver);
805 static __exit void isci_exit(
void)