aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas.h8
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_main.c40
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_v1_hw.c23
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_v2_hw.c24
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_v3_hw.c24
5 files changed, 86 insertions, 33 deletions
diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index b4717bd8af3f..37c9a6246dc8 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -248,6 +248,7 @@ struct hisi_sas_hw {
248 u8 reg_index, u8 reg_count, u8 *write_data); 248 u8 reg_index, u8 reg_count, u8 *write_data);
249 int max_command_entries; 249 int max_command_entries;
250 int complete_hdr_size; 250 int complete_hdr_size;
251 struct scsi_host_template *sht;
251}; 252};
252 253
253struct hisi_hba { 254struct hisi_hba {
@@ -440,8 +441,6 @@ struct hisi_sas_slot_buf_table {
440}; 441};
441 442
442extern struct scsi_transport_template *hisi_sas_stt; 443extern struct scsi_transport_template *hisi_sas_stt;
443extern struct scsi_host_template *hisi_sas_sht;
444
445extern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba); 444extern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba);
446extern int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost); 445extern int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost);
447extern void hisi_sas_free(struct hisi_hba *hisi_hba); 446extern void hisi_sas_free(struct hisi_hba *hisi_hba);
@@ -456,6 +455,11 @@ extern int hisi_sas_probe(struct platform_device *pdev,
456 const struct hisi_sas_hw *ops); 455 const struct hisi_sas_hw *ops);
457extern int hisi_sas_remove(struct platform_device *pdev); 456extern int hisi_sas_remove(struct platform_device *pdev);
458 457
458extern int hisi_sas_slave_configure(struct scsi_device *sdev);
459extern int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time);
460extern void hisi_sas_scan_start(struct Scsi_Host *shost);
461extern struct device_attribute *host_attrs[];
462extern int hisi_sas_host_reset(struct Scsi_Host *shost, int reset_type);
459extern void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy); 463extern void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy);
460extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, 464extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba,
461 struct sas_task *task, 465 struct sas_task *task,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index c8e647a65b30..664aaf7f5147 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -719,7 +719,7 @@ err_out:
719 return rc; 719 return rc;
720} 720}
721 721
722static int hisi_sas_slave_configure(struct scsi_device *sdev) 722int hisi_sas_slave_configure(struct scsi_device *sdev)
723{ 723{
724 struct domain_device *dev = sdev_to_domain_dev(sdev); 724 struct domain_device *dev = sdev_to_domain_dev(sdev);
725 int ret = sas_slave_configure(sdev); 725 int ret = sas_slave_configure(sdev);
@@ -731,15 +731,17 @@ static int hisi_sas_slave_configure(struct scsi_device *sdev)
731 731
732 return 0; 732 return 0;
733} 733}
734EXPORT_SYMBOL_GPL(hisi_sas_slave_configure);
734 735
735static void hisi_sas_scan_start(struct Scsi_Host *shost) 736void hisi_sas_scan_start(struct Scsi_Host *shost)
736{ 737{
737 struct hisi_hba *hisi_hba = shost_priv(shost); 738 struct hisi_hba *hisi_hba = shost_priv(shost);
738 739
739 hisi_hba->hw->phys_init(hisi_hba); 740 hisi_hba->hw->phys_init(hisi_hba);
740} 741}
742EXPORT_SYMBOL_GPL(hisi_sas_scan_start);
741 743
742static int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time) 744int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time)
743{ 745{
744 struct hisi_hba *hisi_hba = shost_priv(shost); 746 struct hisi_hba *hisi_hba = shost_priv(shost);
745 struct sas_ha_struct *sha = &hisi_hba->sha; 747 struct sas_ha_struct *sha = &hisi_hba->sha;
@@ -751,6 +753,7 @@ static int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time)
751 sas_drain_work(sha); 753 sas_drain_work(sha);
752 return 1; 754 return 1;
753} 755}
756EXPORT_SYMBOL_GPL(hisi_sas_scan_finished);
754 757
755static void hisi_sas_phyup_work(struct work_struct *work) 758static void hisi_sas_phyup_work(struct work_struct *work)
756{ 759{
@@ -1824,34 +1827,11 @@ EXPORT_SYMBOL_GPL(hisi_sas_kill_tasklets);
1824struct scsi_transport_template *hisi_sas_stt; 1827struct scsi_transport_template *hisi_sas_stt;
1825EXPORT_SYMBOL_GPL(hisi_sas_stt); 1828EXPORT_SYMBOL_GPL(hisi_sas_stt);
1826 1829
1827static struct device_attribute *host_attrs[] = { 1830struct device_attribute *host_attrs[] = {
1828 &dev_attr_phy_event_threshold, 1831 &dev_attr_phy_event_threshold,
1829 NULL, 1832 NULL,
1830}; 1833};
1831 1834EXPORT_SYMBOL_GPL(host_attrs);
1832static struct scsi_host_template _hisi_sas_sht = {
1833 .module = THIS_MODULE,
1834 .name = DRV_NAME,
1835 .queuecommand = sas_queuecommand,
1836 .target_alloc = sas_target_alloc,
1837 .slave_configure = hisi_sas_slave_configure,
1838 .scan_finished = hisi_sas_scan_finished,
1839 .scan_start = hisi_sas_scan_start,
1840 .change_queue_depth = sas_change_queue_depth,
1841 .bios_param = sas_bios_param,
1842 .can_queue = 1,
1843 .this_id = -1,
1844 .sg_tablesize = SG_ALL,
1845 .max_sectors = SCSI_DEFAULT_MAX_SECTORS,
1846 .use_clustering = ENABLE_CLUSTERING,
1847 .eh_device_reset_handler = sas_eh_device_reset_handler,
1848 .eh_target_reset_handler = sas_eh_target_reset_handler,
1849 .target_destroy = sas_target_destroy,
1850 .ioctl = sas_ioctl,
1851 .shost_attrs = host_attrs,
1852};
1853struct scsi_host_template *hisi_sas_sht = &_hisi_sas_sht;
1854EXPORT_SYMBOL_GPL(hisi_sas_sht);
1855 1835
1856static struct sas_domain_function_template hisi_sas_transport_ops = { 1836static struct sas_domain_function_template hisi_sas_transport_ops = {
1857 .lldd_dev_found = hisi_sas_dev_found, 1837 .lldd_dev_found = hisi_sas_dev_found,
@@ -2161,7 +2141,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
2161 struct hisi_hba *hisi_hba; 2141 struct hisi_hba *hisi_hba;
2162 struct device *dev = &pdev->dev; 2142 struct device *dev = &pdev->dev;
2163 2143
2164 shost = scsi_host_alloc(hisi_sas_sht, sizeof(*hisi_hba)); 2144 shost = scsi_host_alloc(hw->sht, sizeof(*hisi_hba));
2165 if (!shost) { 2145 if (!shost) {
2166 dev_err(dev, "scsi host alloc failed\n"); 2146 dev_err(dev, "scsi host alloc failed\n");
2167 return NULL; 2147 return NULL;
@@ -2211,7 +2191,7 @@ err_out:
2211} 2191}
2212 2192
2213int hisi_sas_probe(struct platform_device *pdev, 2193int hisi_sas_probe(struct platform_device *pdev,
2214 const struct hisi_sas_hw *hw) 2194 const struct hisi_sas_hw *hw)
2215{ 2195{
2216 struct Scsi_Host *shost; 2196 struct Scsi_Host *shost;
2217 struct hisi_hba *hisi_hba; 2197 struct hisi_hba *hisi_hba;
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 8fa79d0968a6..8d5d8575d939 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -1788,6 +1788,28 @@ static int hisi_sas_v1_init(struct hisi_hba *hisi_hba)
1788 return 0; 1788 return 0;
1789} 1789}
1790 1790
1791static struct scsi_host_template sht_v1_hw = {
1792 .name = DRV_NAME,
1793 .module = THIS_MODULE,
1794 .queuecommand = sas_queuecommand,
1795 .target_alloc = sas_target_alloc,
1796 .slave_configure = hisi_sas_slave_configure,
1797 .scan_finished = hisi_sas_scan_finished,
1798 .scan_start = hisi_sas_scan_start,
1799 .change_queue_depth = sas_change_queue_depth,
1800 .bios_param = sas_bios_param,
1801 .can_queue = 1,
1802 .this_id = -1,
1803 .sg_tablesize = SG_ALL,
1804 .max_sectors = SCSI_DEFAULT_MAX_SECTORS,
1805 .use_clustering = ENABLE_CLUSTERING,
1806 .eh_device_reset_handler = sas_eh_device_reset_handler,
1807 .eh_target_reset_handler = sas_eh_target_reset_handler,
1808 .target_destroy = sas_target_destroy,
1809 .ioctl = sas_ioctl,
1810 .shost_attrs = host_attrs,
1811};
1812
1791static const struct hisi_sas_hw hisi_sas_v1_hw = { 1813static const struct hisi_sas_hw hisi_sas_v1_hw = {
1792 .hw_init = hisi_sas_v1_init, 1814 .hw_init = hisi_sas_v1_init,
1793 .setup_itct = setup_itct_v1_hw, 1815 .setup_itct = setup_itct_v1_hw,
@@ -1807,6 +1829,7 @@ static const struct hisi_sas_hw hisi_sas_v1_hw = {
1807 .get_wideport_bitmap = get_wideport_bitmap_v1_hw, 1829 .get_wideport_bitmap = get_wideport_bitmap_v1_hw,
1808 .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V1_HW, 1830 .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V1_HW,
1809 .complete_hdr_size = sizeof(struct hisi_sas_complete_v1_hdr), 1831 .complete_hdr_size = sizeof(struct hisi_sas_complete_v1_hdr),
1832 .sht = &sht_v1_hw,
1810}; 1833};
1811 1834
1812static int hisi_sas_v1_probe(struct platform_device *pdev) 1835static int hisi_sas_v1_probe(struct platform_device *pdev)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index fb0e966a44a8..8def327c4f46 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -3501,6 +3501,29 @@ static int write_gpio_v2_hw(struct hisi_hba *hisi_hba, u8 reg_type,
3501 return 0; 3501 return 0;
3502} 3502}
3503 3503
3504
3505static struct scsi_host_template sht_v2_hw = {
3506 .name = DRV_NAME,
3507 .module = THIS_MODULE,
3508 .queuecommand = sas_queuecommand,
3509 .target_alloc = sas_target_alloc,
3510 .slave_configure = hisi_sas_slave_configure,
3511 .scan_finished = hisi_sas_scan_finished,
3512 .scan_start = hisi_sas_scan_start,
3513 .change_queue_depth = sas_change_queue_depth,
3514 .bios_param = sas_bios_param,
3515 .can_queue = 1,
3516 .this_id = -1,
3517 .sg_tablesize = SG_ALL,
3518 .max_sectors = SCSI_DEFAULT_MAX_SECTORS,
3519 .use_clustering = ENABLE_CLUSTERING,
3520 .eh_device_reset_handler = sas_eh_device_reset_handler,
3521 .eh_target_reset_handler = sas_eh_target_reset_handler,
3522 .target_destroy = sas_target_destroy,
3523 .ioctl = sas_ioctl,
3524 .shost_attrs = host_attrs,
3525};
3526
3504static const struct hisi_sas_hw hisi_sas_v2_hw = { 3527static const struct hisi_sas_hw hisi_sas_v2_hw = {
3505 .hw_init = hisi_sas_v2_init, 3528 .hw_init = hisi_sas_v2_init,
3506 .setup_itct = setup_itct_v2_hw, 3529 .setup_itct = setup_itct_v2_hw,
@@ -3529,6 +3552,7 @@ static const struct hisi_sas_hw hisi_sas_v2_hw = {
3529 .soft_reset = soft_reset_v2_hw, 3552 .soft_reset = soft_reset_v2_hw,
3530 .get_phys_state = get_phys_state_v2_hw, 3553 .get_phys_state = get_phys_state_v2_hw,
3531 .write_gpio = write_gpio_v2_hw, 3554 .write_gpio = write_gpio_v2_hw,
3555 .sht = &sht_v2_hw,
3532}; 3556};
3533 3557
3534static int hisi_sas_v2_probe(struct platform_device *pdev) 3558static int hisi_sas_v2_probe(struct platform_device *pdev)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index a043d9cdbf48..13d21349d1ba 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -2015,6 +2015,28 @@ static int write_gpio_v3_hw(struct hisi_hba *hisi_hba, u8 reg_type,
2015 return 0; 2015 return 0;
2016} 2016}
2017 2017
2018static struct scsi_host_template sht_v3_hw = {
2019 .name = DRV_NAME,
2020 .module = THIS_MODULE,
2021 .queuecommand = sas_queuecommand,
2022 .target_alloc = sas_target_alloc,
2023 .slave_configure = hisi_sas_slave_configure,
2024 .scan_finished = hisi_sas_scan_finished,
2025 .scan_start = hisi_sas_scan_start,
2026 .change_queue_depth = sas_change_queue_depth,
2027 .bios_param = sas_bios_param,
2028 .can_queue = 1,
2029 .this_id = -1,
2030 .sg_tablesize = SG_ALL,
2031 .max_sectors = SCSI_DEFAULT_MAX_SECTORS,
2032 .use_clustering = ENABLE_CLUSTERING,
2033 .eh_device_reset_handler = sas_eh_device_reset_handler,
2034 .eh_target_reset_handler = sas_eh_target_reset_handler,
2035 .target_destroy = sas_target_destroy,
2036 .ioctl = sas_ioctl,
2037 .shost_attrs = host_attrs,
2038};
2039
2018static const struct hisi_sas_hw hisi_sas_v3_hw = { 2040static const struct hisi_sas_hw hisi_sas_v3_hw = {
2019 .hw_init = hisi_sas_v3_init, 2041 .hw_init = hisi_sas_v3_init,
2020 .setup_itct = setup_itct_v3_hw, 2042 .setup_itct = setup_itct_v3_hw,
@@ -2050,7 +2072,7 @@ hisi_sas_shost_alloc_pci(struct pci_dev *pdev)
2050 struct hisi_hba *hisi_hba; 2072 struct hisi_hba *hisi_hba;
2051 struct device *dev = &pdev->dev; 2073 struct device *dev = &pdev->dev;
2052 2074
2053 shost = scsi_host_alloc(hisi_sas_sht, sizeof(*hisi_hba)); 2075 shost = scsi_host_alloc(&sht_v3_hw, sizeof(*hisi_hba));
2054 if (!shost) { 2076 if (!shost) {
2055 dev_err(dev, "shost alloc failed\n"); 2077 dev_err(dev, "shost alloc failed\n");
2056 return NULL; 2078 return NULL;