aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/pm8001/pm8001_init.c
diff options
context:
space:
mode:
authorJames Bottomley <JBottomley@Odin.com>2015-11-12 07:06:18 -0500
committerJames Bottomley <JBottomley@Odin.com>2015-11-12 07:06:18 -0500
commitfebdfbd2137a5727f70dfbf920105c07e6c2a21e (patch)
tree9483a5493ad3e08626e1f53ded594f88a6f4e710 /drivers/scsi/pm8001/pm8001_init.c
parent0da39687a15403251bdfd1c6fb18025c0607326b (diff)
parent2c5d16d6a9e7218e57b716e4fd9d77c776d21471 (diff)
Merge tag '4.4-scsi-mkp' into misc
SCSI queue for 4.4. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/pm8001/pm8001_init.c')
-rw-r--r--drivers/scsi/pm8001/pm8001_init.c215
1 files changed, 202 insertions, 13 deletions
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index e64b8bfafd80..062ab34b86f8 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -58,6 +58,8 @@ static const struct pm8001_chip_info pm8001_chips[] = {
58 [chip_8076] = {0, 16, &pm8001_80xx_dispatch,}, 58 [chip_8076] = {0, 16, &pm8001_80xx_dispatch,},
59 [chip_8077] = {0, 16, &pm8001_80xx_dispatch,}, 59 [chip_8077] = {0, 16, &pm8001_80xx_dispatch,},
60 [chip_8006] = {0, 16, &pm8001_80xx_dispatch,}, 60 [chip_8006] = {0, 16, &pm8001_80xx_dispatch,},
61 [chip_8070] = {0, 8, &pm8001_80xx_dispatch,},
62 [chip_8072] = {0, 16, &pm8001_80xx_dispatch,},
61}; 63};
62static int pm8001_id; 64static int pm8001_id;
63 65
@@ -479,7 +481,8 @@ static struct pm8001_hba_info *pm8001_pci_alloc(struct pci_dev *pdev,
479 481
480#ifdef PM8001_USE_TASKLET 482#ifdef PM8001_USE_TASKLET
481 /* Tasklet for non msi-x interrupt handler */ 483 /* Tasklet for non msi-x interrupt handler */
482 if ((!pdev->msix_cap) || (pm8001_ha->chip_id == chip_8001)) 484 if ((!pdev->msix_cap || !pci_msi_enabled())
485 || (pm8001_ha->chip_id == chip_8001))
483 tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet, 486 tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet,
484 (unsigned long)&(pm8001_ha->irq_vector[0])); 487 (unsigned long)&(pm8001_ha->irq_vector[0]));
485 else 488 else
@@ -633,6 +636,11 @@ static void pm8001_init_sas_add(struct pm8001_hba_info *pm8001_ha)
633 payload.minor_function = 0; 636 payload.minor_function = 0;
634 payload.length = 128; 637 payload.length = 128;
635 } 638 }
639 } else if ((pm8001_ha->chip_id == chip_8070 ||
640 pm8001_ha->chip_id == chip_8072) &&
641 pm8001_ha->pdev->subsystem_vendor == PCI_VENDOR_ID_ATTO) {
642 payload.minor_function = 4;
643 payload.length = 4096;
636 } else { 644 } else {
637 payload.minor_function = 1; 645 payload.minor_function = 1;
638 payload.length = 4096; 646 payload.length = 4096;
@@ -659,6 +667,11 @@ static void pm8001_init_sas_add(struct pm8001_hba_info *pm8001_ha)
659 else if (deviceid == 0x0042) 667 else if (deviceid == 0x0042)
660 pm8001_ha->sas_addr[j] = 668 pm8001_ha->sas_addr[j] =
661 payload.func_specific[0x010 + i]; 669 payload.func_specific[0x010 + i];
670 } else if ((pm8001_ha->chip_id == chip_8070 ||
671 pm8001_ha->chip_id == chip_8072) &&
672 pm8001_ha->pdev->subsystem_vendor == PCI_VENDOR_ID_ATTO) {
673 pm8001_ha->sas_addr[j] =
674 payload.func_specific[0x010 + i];
662 } else 675 } else
663 pm8001_ha->sas_addr[j] = 676 pm8001_ha->sas_addr[j] =
664 payload.func_specific[0x804 + i]; 677 payload.func_specific[0x804 + i];
@@ -719,6 +732,153 @@ static int pm8001_get_phy_settings_info(struct pm8001_hba_info *pm8001_ha)
719 return 0; 732 return 0;
720} 733}
721 734
735struct pm8001_mpi3_phy_pg_trx_config {
736 u32 LaneLosCfg;
737 u32 LanePgaCfg1;
738 u32 LanePisoCfg1;
739 u32 LanePisoCfg2;
740 u32 LanePisoCfg3;
741 u32 LanePisoCfg4;
742 u32 LanePisoCfg5;
743 u32 LanePisoCfg6;
744 u32 LaneBctCtrl;
745};
746
747/**
748 * pm8001_get_internal_phy_settings : Retrieves the internal PHY settings
749 * @pm8001_ha : our adapter
750 * @phycfg : PHY config page to populate
751 */
752static
753void pm8001_get_internal_phy_settings(struct pm8001_hba_info *pm8001_ha,
754 struct pm8001_mpi3_phy_pg_trx_config *phycfg)
755{
756 phycfg->LaneLosCfg = 0x00000132;
757 phycfg->LanePgaCfg1 = 0x00203949;
758 phycfg->LanePisoCfg1 = 0x000000FF;
759 phycfg->LanePisoCfg2 = 0xFF000001;
760 phycfg->LanePisoCfg3 = 0xE7011300;
761 phycfg->LanePisoCfg4 = 0x631C40C0;
762 phycfg->LanePisoCfg5 = 0xF8102036;
763 phycfg->LanePisoCfg6 = 0xF74A1000;
764 phycfg->LaneBctCtrl = 0x00FB33F8;
765}
766
767/**
768 * pm8001_get_external_phy_settings : Retrieves the external PHY settings
769 * @pm8001_ha : our adapter
770 * @phycfg : PHY config page to populate
771 */
772static
773void pm8001_get_external_phy_settings(struct pm8001_hba_info *pm8001_ha,
774 struct pm8001_mpi3_phy_pg_trx_config *phycfg)
775{
776 phycfg->LaneLosCfg = 0x00000132;
777 phycfg->LanePgaCfg1 = 0x00203949;
778 phycfg->LanePisoCfg1 = 0x000000FF;
779 phycfg->LanePisoCfg2 = 0xFF000001;
780 phycfg->LanePisoCfg3 = 0xE7011300;
781 phycfg->LanePisoCfg4 = 0x63349140;
782 phycfg->LanePisoCfg5 = 0xF8102036;
783 phycfg->LanePisoCfg6 = 0xF80D9300;
784 phycfg->LaneBctCtrl = 0x00FB33F8;
785}
786
787/**
788 * pm8001_get_phy_mask : Retrieves the mask that denotes if a PHY is int/ext
789 * @pm8001_ha : our adapter
790 * @phymask : The PHY mask
791 */
792static
793void pm8001_get_phy_mask(struct pm8001_hba_info *pm8001_ha, int *phymask)
794{
795 switch (pm8001_ha->pdev->subsystem_device) {
796 case 0x0070: /* H1280 - 8 external 0 internal */
797 case 0x0072: /* H12F0 - 16 external 0 internal */
798 *phymask = 0x0000;
799 break;
800
801 case 0x0071: /* H1208 - 0 external 8 internal */
802 case 0x0073: /* H120F - 0 external 16 internal */
803 *phymask = 0xFFFF;
804 break;
805
806 case 0x0080: /* H1244 - 4 external 4 internal */
807 *phymask = 0x00F0;
808 break;
809
810 case 0x0081: /* H1248 - 4 external 8 internal */
811 *phymask = 0x0FF0;
812 break;
813
814 case 0x0082: /* H1288 - 8 external 8 internal */
815 *phymask = 0xFF00;
816 break;
817
818 default:
819 PM8001_INIT_DBG(pm8001_ha,
820 pm8001_printk("Unknown subsystem device=0x%.04x",
821 pm8001_ha->pdev->subsystem_device));
822 }
823}
824
825/**
826 * pm8001_set_phy_settings_ven_117c_12Gb : Configure ATTO 12Gb PHY settings
827 * @pm8001_ha : our adapter
828 */
829static
830int pm8001_set_phy_settings_ven_117c_12G(struct pm8001_hba_info *pm8001_ha)
831{
832 struct pm8001_mpi3_phy_pg_trx_config phycfg_int;
833 struct pm8001_mpi3_phy_pg_trx_config phycfg_ext;
834 int phymask = 0;
835 int i = 0;
836
837 memset(&phycfg_int, 0, sizeof(phycfg_int));
838 memset(&phycfg_ext, 0, sizeof(phycfg_ext));
839
840 pm8001_get_internal_phy_settings(pm8001_ha, &phycfg_int);
841 pm8001_get_external_phy_settings(pm8001_ha, &phycfg_ext);
842 pm8001_get_phy_mask(pm8001_ha, &phymask);
843
844 for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
845 if (phymask & (1 << i)) {/* Internal PHY */
846 pm8001_set_phy_profile_single(pm8001_ha, i,
847 sizeof(phycfg_int) / sizeof(u32),
848 (u32 *)&phycfg_int);
849
850 } else { /* External PHY */
851 pm8001_set_phy_profile_single(pm8001_ha, i,
852 sizeof(phycfg_ext) / sizeof(u32),
853 (u32 *)&phycfg_ext);
854 }
855 }
856
857 return 0;
858}
859
860/**
861 * pm8001_configure_phy_settings : Configures PHY settings based on vendor ID.
862 * @pm8001_ha : our hba.
863 */
864static int pm8001_configure_phy_settings(struct pm8001_hba_info *pm8001_ha)
865{
866 switch (pm8001_ha->pdev->subsystem_vendor) {
867 case PCI_VENDOR_ID_ATTO:
868 if (pm8001_ha->pdev->device == 0x0042) /* 6Gb */
869 return 0;
870 else
871 return pm8001_set_phy_settings_ven_117c_12G(pm8001_ha);
872
873 case PCI_VENDOR_ID_ADAPTEC2:
874 case 0:
875 return 0;
876
877 default:
878 return pm8001_get_phy_settings_info(pm8001_ha);
879 }
880}
881
722#ifdef PM8001_USE_MSIX 882#ifdef PM8001_USE_MSIX
723/** 883/**
724 * pm8001_setup_msix - enable MSI-X interrupt 884 * pm8001_setup_msix - enable MSI-X interrupt
@@ -791,7 +951,7 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
791 pdev = pm8001_ha->pdev; 951 pdev = pm8001_ha->pdev;
792 952
793#ifdef PM8001_USE_MSIX 953#ifdef PM8001_USE_MSIX
794 if (pdev->msix_cap) 954 if (pdev->msix_cap && pci_msi_enabled())
795 return pm8001_setup_msix(pm8001_ha); 955 return pm8001_setup_msix(pm8001_ha);
796 else { 956 else {
797 PM8001_INIT_DBG(pm8001_ha, 957 PM8001_INIT_DBG(pm8001_ha,
@@ -802,6 +962,8 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
802 962
803intx: 963intx:
804 /* initialize the INT-X interrupt */ 964 /* initialize the INT-X interrupt */
965 pm8001_ha->irq_vector[0].irq_id = 0;
966 pm8001_ha->irq_vector[0].drv_inst = pm8001_ha;
805 rc = request_irq(pdev->irq, pm8001_interrupt_handler_intx, IRQF_SHARED, 967 rc = request_irq(pdev->irq, pm8001_interrupt_handler_intx, IRQF_SHARED,
806 DRV_NAME, SHOST_TO_SAS_HA(pm8001_ha->shost)); 968 DRV_NAME, SHOST_TO_SAS_HA(pm8001_ha->shost));
807 return rc; 969 return rc;
@@ -901,12 +1063,9 @@ static int pm8001_pci_probe(struct pci_dev *pdev,
901 1063
902 pm8001_init_sas_add(pm8001_ha); 1064 pm8001_init_sas_add(pm8001_ha);
903 /* phy setting support for motherboard controller */ 1065 /* phy setting support for motherboard controller */
904 if (pdev->subsystem_vendor != PCI_VENDOR_ID_ADAPTEC2 && 1066 if (pm8001_configure_phy_settings(pm8001_ha))
905 pdev->subsystem_vendor != 0) { 1067 goto err_out_shost;
906 rc = pm8001_get_phy_settings_info(pm8001_ha); 1068
907 if (rc)
908 goto err_out_shost;
909 }
910 pm8001_post_sas_ha_init(shost, chip); 1069 pm8001_post_sas_ha_init(shost, chip);
911 rc = sas_register_ha(SHOST_TO_SAS_HA(shost)); 1070 rc = sas_register_ha(SHOST_TO_SAS_HA(shost));
912 if (rc) 1071 if (rc)
@@ -936,10 +1095,10 @@ static void pm8001_pci_remove(struct pci_dev *pdev)
936 struct pm8001_hba_info *pm8001_ha; 1095 struct pm8001_hba_info *pm8001_ha;
937 int i, j; 1096 int i, j;
938 pm8001_ha = sha->lldd_ha; 1097 pm8001_ha = sha->lldd_ha;
1098 scsi_remove_host(pm8001_ha->shost);
939 sas_unregister_ha(sha); 1099 sas_unregister_ha(sha);
940 sas_remove_host(pm8001_ha->shost); 1100 sas_remove_host(pm8001_ha->shost);
941 list_del(&pm8001_ha->list); 1101 list_del(&pm8001_ha->list);
942 scsi_remove_host(pm8001_ha->shost);
943 PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF); 1102 PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
944 PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha); 1103 PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
945 1104
@@ -955,7 +1114,8 @@ static void pm8001_pci_remove(struct pci_dev *pdev)
955#endif 1114#endif
956#ifdef PM8001_USE_TASKLET 1115#ifdef PM8001_USE_TASKLET
957 /* For non-msix and msix interrupts */ 1116 /* For non-msix and msix interrupts */
958 if ((!pdev->msix_cap) || (pm8001_ha->chip_id == chip_8001)) 1117 if ((!pdev->msix_cap || !pci_msi_enabled()) ||
1118 (pm8001_ha->chip_id == chip_8001))
959 tasklet_kill(&pm8001_ha->tasklet[0]); 1119 tasklet_kill(&pm8001_ha->tasklet[0]);
960 else 1120 else
961 for (j = 0; j < PM8001_MAX_MSIX_VEC; j++) 1121 for (j = 0; j < PM8001_MAX_MSIX_VEC; j++)
@@ -1004,7 +1164,8 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state)
1004#endif 1164#endif
1005#ifdef PM8001_USE_TASKLET 1165#ifdef PM8001_USE_TASKLET
1006 /* For non-msix and msix interrupts */ 1166 /* For non-msix and msix interrupts */
1007 if ((!pdev->msix_cap) || (pm8001_ha->chip_id == chip_8001)) 1167 if ((!pdev->msix_cap || !pci_msi_enabled()) ||
1168 (pm8001_ha->chip_id == chip_8001))
1008 tasklet_kill(&pm8001_ha->tasklet[0]); 1169 tasklet_kill(&pm8001_ha->tasklet[0]);
1009 else 1170 else
1010 for (j = 0; j < PM8001_MAX_MSIX_VEC; j++) 1171 for (j = 0; j < PM8001_MAX_MSIX_VEC; j++)
@@ -1073,7 +1234,8 @@ static int pm8001_pci_resume(struct pci_dev *pdev)
1073 goto err_out_disable; 1234 goto err_out_disable;
1074#ifdef PM8001_USE_TASKLET 1235#ifdef PM8001_USE_TASKLET
1075 /* Tasklet for non msi-x interrupt handler */ 1236 /* Tasklet for non msi-x interrupt handler */
1076 if ((!pdev->msix_cap) || (pm8001_ha->chip_id == chip_8001)) 1237 if ((!pdev->msix_cap || !pci_msi_enabled()) ||
1238 (pm8001_ha->chip_id == chip_8001))
1077 tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet, 1239 tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet,
1078 (unsigned long)&(pm8001_ha->irq_vector[0])); 1240 (unsigned long)&(pm8001_ha->irq_vector[0]));
1079 else 1241 else
@@ -1086,6 +1248,19 @@ static int pm8001_pci_resume(struct pci_dev *pdev)
1086 for (i = 1; i < pm8001_ha->number_of_intr; i++) 1248 for (i = 1; i < pm8001_ha->number_of_intr; i++)
1087 PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, i); 1249 PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, i);
1088 } 1250 }
1251
1252 /* Chip documentation for the 8070 and 8072 SPCv */
1253 /* states that a 500ms minimum delay is required */
1254 /* before issuing commands. Otherwise, the firmare */
1255 /* will enter an unrecoverable state. */
1256
1257 if (pm8001_ha->chip_id == chip_8070 ||
1258 pm8001_ha->chip_id == chip_8072) {
1259 mdelay(500);
1260 }
1261
1262 /* Spin up the PHYs */
1263
1089 pm8001_ha->flags = PM8001F_RUN_TIME; 1264 pm8001_ha->flags = PM8001F_RUN_TIME;
1090 for (i = 0; i < pm8001_ha->chip->n_phy; i++) { 1265 for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
1091 pm8001_ha->phy[i].enable_completion = &completion; 1266 pm8001_ha->phy[i].enable_completion = &completion;
@@ -1164,6 +1339,20 @@ static struct pci_device_id pm8001_pci_table[] = {
1164 PCI_VENDOR_ID_ADAPTEC2, 0x0808, 0, 0, chip_8077 }, 1339 PCI_VENDOR_ID_ADAPTEC2, 0x0808, 0, 0, chip_8077 },
1165 { PCI_VENDOR_ID_ADAPTEC2, 0x8074, 1340 { PCI_VENDOR_ID_ADAPTEC2, 0x8074,
1166 PCI_VENDOR_ID_ADAPTEC2, 0x0404, 0, 0, chip_8074 }, 1341 PCI_VENDOR_ID_ADAPTEC2, 0x0404, 0, 0, chip_8074 },
1342 { PCI_VENDOR_ID_ATTO, 0x8070,
1343 PCI_VENDOR_ID_ATTO, 0x0070, 0, 0, chip_8070 },
1344 { PCI_VENDOR_ID_ATTO, 0x8070,
1345 PCI_VENDOR_ID_ATTO, 0x0071, 0, 0, chip_8070 },
1346 { PCI_VENDOR_ID_ATTO, 0x8072,
1347 PCI_VENDOR_ID_ATTO, 0x0072, 0, 0, chip_8072 },
1348 { PCI_VENDOR_ID_ATTO, 0x8072,
1349 PCI_VENDOR_ID_ATTO, 0x0073, 0, 0, chip_8072 },
1350 { PCI_VENDOR_ID_ATTO, 0x8070,
1351 PCI_VENDOR_ID_ATTO, 0x0080, 0, 0, chip_8070 },
1352 { PCI_VENDOR_ID_ATTO, 0x8072,
1353 PCI_VENDOR_ID_ATTO, 0x0081, 0, 0, chip_8072 },
1354 { PCI_VENDOR_ID_ATTO, 0x8072,
1355 PCI_VENDOR_ID_ATTO, 0x0082, 0, 0, chip_8072 },
1167 {} /* terminate list */ 1356 {} /* terminate list */
1168}; 1357};
1169 1358
@@ -1219,7 +1408,7 @@ MODULE_AUTHOR("Anand Kumar Santhanam <AnandKumar.Santhanam@pmcs.com>");
1219MODULE_AUTHOR("Sangeetha Gnanasekaran <Sangeetha.Gnanasekaran@pmcs.com>"); 1408MODULE_AUTHOR("Sangeetha Gnanasekaran <Sangeetha.Gnanasekaran@pmcs.com>");
1220MODULE_AUTHOR("Nikith Ganigarakoppal <Nikith.Ganigarakoppal@pmcs.com>"); 1409MODULE_AUTHOR("Nikith Ganigarakoppal <Nikith.Ganigarakoppal@pmcs.com>");
1221MODULE_DESCRIPTION( 1410MODULE_DESCRIPTION(
1222 "PMC-Sierra PM8001/8006/8081/8088/8089/8074/8076/8077 " 1411 "PMC-Sierra PM8001/8006/8081/8088/8089/8074/8076/8077/8070/8072 "
1223 "SAS/SATA controller driver"); 1412 "SAS/SATA controller driver");
1224MODULE_VERSION(DRV_VERSION); 1413MODULE_VERSION(DRV_VERSION);
1225MODULE_LICENSE("GPL"); 1414MODULE_LICENSE("GPL");