diff options
author | Yaniv Gardi <ygardi@codeaurora.org> | 2015-10-28 07:15:47 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2015-11-09 17:47:40 -0500 |
commit | 1ce5898af55e23e933f6a68d102d4be730e9b503 (patch) | |
tree | e3b94ae7ea55320882c5072abdc7ce75d73be4af /drivers/scsi/ufs | |
parent | 9bac5db4b229977054c9936e859dc41e1cd64c59 (diff) |
scsi: ufs: add ufshcd_get_variant ufshcd_set_variant
This patch adds ufshcd_get_variant() and ufshcd_set_variant()
routines in order to get/set the variant specific data.
Reviewed-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Tested-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/ufs')
-rw-r--r-- | drivers/scsi/ufs/ufs-qcom.c | 34 | ||||
-rw-r--r-- | drivers/scsi/ufs/ufshcd.h | 21 |
2 files changed, 38 insertions, 17 deletions
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 6c23bbfe8d36..64c54b79051e 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c | |||
@@ -155,7 +155,7 @@ out: | |||
155 | 155 | ||
156 | static int ufs_qcom_link_startup_post_change(struct ufs_hba *hba) | 156 | static int ufs_qcom_link_startup_post_change(struct ufs_hba *hba) |
157 | { | 157 | { |
158 | struct ufs_qcom_host *host = hba->priv; | 158 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
159 | struct phy *phy = host->generic_phy; | 159 | struct phy *phy = host->generic_phy; |
160 | u32 tx_lanes; | 160 | u32 tx_lanes; |
161 | int err = 0; | 161 | int err = 0; |
@@ -211,7 +211,7 @@ static int ufs_qcom_check_hibern8(struct ufs_hba *hba) | |||
211 | 211 | ||
212 | static int ufs_qcom_power_up_sequence(struct ufs_hba *hba) | 212 | static int ufs_qcom_power_up_sequence(struct ufs_hba *hba) |
213 | { | 213 | { |
214 | struct ufs_qcom_host *host = hba->priv; | 214 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
215 | struct phy *phy = host->generic_phy; | 215 | struct phy *phy = host->generic_phy; |
216 | int ret = 0; | 216 | int ret = 0; |
217 | bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B) | 217 | bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B) |
@@ -273,7 +273,7 @@ static void ufs_qcom_enable_hw_clk_gating(struct ufs_hba *hba) | |||
273 | 273 | ||
274 | static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba, bool status) | 274 | static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba, bool status) |
275 | { | 275 | { |
276 | struct ufs_qcom_host *host = hba->priv; | 276 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
277 | int err = 0; | 277 | int err = 0; |
278 | 278 | ||
279 | switch (status) { | 279 | switch (status) { |
@@ -307,7 +307,7 @@ static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba, bool status) | |||
307 | static unsigned long | 307 | static unsigned long |
308 | ufs_qcom_cfg_timers(struct ufs_hba *hba, u32 gear, u32 hs, u32 rate) | 308 | ufs_qcom_cfg_timers(struct ufs_hba *hba, u32 gear, u32 hs, u32 rate) |
309 | { | 309 | { |
310 | struct ufs_qcom_host *host = hba->priv; | 310 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
311 | struct ufs_clk_info *clki; | 311 | struct ufs_clk_info *clki; |
312 | u32 core_clk_period_in_ns; | 312 | u32 core_clk_period_in_ns; |
313 | u32 tx_clk_cycles_per_us = 0; | 313 | u32 tx_clk_cycles_per_us = 0; |
@@ -448,7 +448,7 @@ static int ufs_qcom_link_startup_notify(struct ufs_hba *hba, bool status) | |||
448 | 448 | ||
449 | static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) | 449 | static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) |
450 | { | 450 | { |
451 | struct ufs_qcom_host *host = hba->priv; | 451 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
452 | struct phy *phy = host->generic_phy; | 452 | struct phy *phy = host->generic_phy; |
453 | int ret = 0; | 453 | int ret = 0; |
454 | 454 | ||
@@ -479,7 +479,7 @@ out: | |||
479 | 479 | ||
480 | static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) | 480 | static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) |
481 | { | 481 | { |
482 | struct ufs_qcom_host *host = hba->priv; | 482 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
483 | struct phy *phy = host->generic_phy; | 483 | struct phy *phy = host->generic_phy; |
484 | int err; | 484 | int err; |
485 | 485 | ||
@@ -621,7 +621,7 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba, | |||
621 | struct ufs_pa_layer_attr *dev_req_params) | 621 | struct ufs_pa_layer_attr *dev_req_params) |
622 | { | 622 | { |
623 | u32 val; | 623 | u32 val; |
624 | struct ufs_qcom_host *host = hba->priv; | 624 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
625 | struct phy *phy = host->generic_phy; | 625 | struct phy *phy = host->generic_phy; |
626 | struct ufs_qcom_dev_params ufs_qcom_cap; | 626 | struct ufs_qcom_dev_params ufs_qcom_cap; |
627 | int ret = 0; | 627 | int ret = 0; |
@@ -696,7 +696,7 @@ out: | |||
696 | 696 | ||
697 | static u32 ufs_qcom_get_ufs_hci_version(struct ufs_hba *hba) | 697 | static u32 ufs_qcom_get_ufs_hci_version(struct ufs_hba *hba) |
698 | { | 698 | { |
699 | struct ufs_qcom_host *host = hba->priv; | 699 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
700 | 700 | ||
701 | if (host->hw_ver.major == 0x1) | 701 | if (host->hw_ver.major == 0x1) |
702 | return UFSHCI_VERSION_11; | 702 | return UFSHCI_VERSION_11; |
@@ -715,7 +715,7 @@ static u32 ufs_qcom_get_ufs_hci_version(struct ufs_hba *hba) | |||
715 | */ | 715 | */ |
716 | static void ufs_qcom_advertise_quirks(struct ufs_hba *hba) | 716 | static void ufs_qcom_advertise_quirks(struct ufs_hba *hba) |
717 | { | 717 | { |
718 | struct ufs_qcom_host *host = hba->priv; | 718 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
719 | 719 | ||
720 | if (host->hw_ver.major == 0x01) { | 720 | if (host->hw_ver.major == 0x01) { |
721 | hba->quirks |= UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS | 721 | hba->quirks |= UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS |
@@ -740,7 +740,7 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba) | |||
740 | 740 | ||
741 | static void ufs_qcom_set_caps(struct ufs_hba *hba) | 741 | static void ufs_qcom_set_caps(struct ufs_hba *hba) |
742 | { | 742 | { |
743 | struct ufs_qcom_host *host = hba->priv; | 743 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
744 | 744 | ||
745 | if (host->hw_ver.major >= 0x2) | 745 | if (host->hw_ver.major >= 0x2) |
746 | host->caps = UFS_QCOM_CAP_QUNIPRO; | 746 | host->caps = UFS_QCOM_CAP_QUNIPRO; |
@@ -811,7 +811,7 @@ static void ufs_qcom_get_speed_mode(struct ufs_pa_layer_attr *p, char *result) | |||
811 | 811 | ||
812 | static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on) | 812 | static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on) |
813 | { | 813 | { |
814 | struct ufs_qcom_host *host = hba->priv; | 814 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
815 | int err = 0; | 815 | int err = 0; |
816 | int vote = 0; | 816 | int vote = 0; |
817 | 817 | ||
@@ -866,7 +866,7 @@ show_ufs_to_mem_max_bus_bw(struct device *dev, struct device_attribute *attr, | |||
866 | char *buf) | 866 | char *buf) |
867 | { | 867 | { |
868 | struct ufs_hba *hba = dev_get_drvdata(dev); | 868 | struct ufs_hba *hba = dev_get_drvdata(dev); |
869 | struct ufs_qcom_host *host = hba->priv; | 869 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
870 | 870 | ||
871 | return snprintf(buf, PAGE_SIZE, "%u\n", | 871 | return snprintf(buf, PAGE_SIZE, "%u\n", |
872 | host->bus_vote.is_max_bw_needed); | 872 | host->bus_vote.is_max_bw_needed); |
@@ -877,7 +877,7 @@ store_ufs_to_mem_max_bus_bw(struct device *dev, struct device_attribute *attr, | |||
877 | const char *buf, size_t count) | 877 | const char *buf, size_t count) |
878 | { | 878 | { |
879 | struct ufs_hba *hba = dev_get_drvdata(dev); | 879 | struct ufs_hba *hba = dev_get_drvdata(dev); |
880 | struct ufs_qcom_host *host = hba->priv; | 880 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
881 | uint32_t value; | 881 | uint32_t value; |
882 | 882 | ||
883 | if (!kstrtou32(buf, 0, &value)) { | 883 | if (!kstrtou32(buf, 0, &value)) { |
@@ -954,7 +954,7 @@ static int ufs_qcom_init(struct ufs_hba *hba) | |||
954 | } | 954 | } |
955 | 955 | ||
956 | host->hba = hba; | 956 | host->hba = hba; |
957 | hba->priv = (void *)host; | 957 | ufshcd_set_variant(hba, host); |
958 | 958 | ||
959 | host->generic_phy = devm_phy_get(dev, "ufsphy"); | 959 | host->generic_phy = devm_phy_get(dev, "ufsphy"); |
960 | 960 | ||
@@ -1003,14 +1003,14 @@ out_unregister_bus: | |||
1003 | phy_exit(host->generic_phy); | 1003 | phy_exit(host->generic_phy); |
1004 | out_host_free: | 1004 | out_host_free: |
1005 | devm_kfree(dev, host); | 1005 | devm_kfree(dev, host); |
1006 | hba->priv = NULL; | 1006 | ufshcd_set_variant(hba, NULL); |
1007 | out: | 1007 | out: |
1008 | return err; | 1008 | return err; |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | static void ufs_qcom_exit(struct ufs_hba *hba) | 1011 | static void ufs_qcom_exit(struct ufs_hba *hba) |
1012 | { | 1012 | { |
1013 | struct ufs_qcom_host *host = hba->priv; | 1013 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
1014 | 1014 | ||
1015 | ufs_qcom_disable_lane_clks(host); | 1015 | ufs_qcom_disable_lane_clks(host); |
1016 | phy_power_off(host->generic_phy); | 1016 | phy_power_off(host->generic_phy); |
@@ -1019,7 +1019,7 @@ static void ufs_qcom_exit(struct ufs_hba *hba) | |||
1019 | static | 1019 | static |
1020 | void ufs_qcom_clk_scale_notify(struct ufs_hba *hba) | 1020 | void ufs_qcom_clk_scale_notify(struct ufs_hba *hba) |
1021 | { | 1021 | { |
1022 | struct ufs_qcom_host *host = hba->priv; | 1022 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
1023 | struct ufs_pa_layer_attr *dev_req_params = &host->dev_req_params; | 1023 | struct ufs_pa_layer_attr *dev_req_params = &host->dev_req_params; |
1024 | 1024 | ||
1025 | if (!dev_req_params) | 1025 | if (!dev_req_params) |
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index c40a0e78a6c4..54e7afb4a432 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h | |||
@@ -594,6 +594,27 @@ static inline void check_upiu_size(void) | |||
594 | GENERAL_UPIU_REQUEST_SIZE + QUERY_DESC_MAX_SIZE); | 594 | GENERAL_UPIU_REQUEST_SIZE + QUERY_DESC_MAX_SIZE); |
595 | } | 595 | } |
596 | 596 | ||
597 | /** | ||
598 | * ufshcd_set_variant - set variant specific data to the hba | ||
599 | * @hba - per adapter instance | ||
600 | * @variant - pointer to variant specific data | ||
601 | */ | ||
602 | static inline void ufshcd_set_variant(struct ufs_hba *hba, void *variant) | ||
603 | { | ||
604 | BUG_ON(!hba); | ||
605 | hba->priv = variant; | ||
606 | } | ||
607 | |||
608 | /** | ||
609 | * ufshcd_get_variant - get variant specific data from the hba | ||
610 | * @hba - per adapter instance | ||
611 | */ | ||
612 | static inline void *ufshcd_get_variant(struct ufs_hba *hba) | ||
613 | { | ||
614 | BUG_ON(!hba); | ||
615 | return hba->priv; | ||
616 | } | ||
617 | |||
597 | extern int ufshcd_runtime_suspend(struct ufs_hba *hba); | 618 | extern int ufshcd_runtime_suspend(struct ufs_hba *hba); |
598 | extern int ufshcd_runtime_resume(struct ufs_hba *hba); | 619 | extern int ufshcd_runtime_resume(struct ufs_hba *hba); |
599 | extern int ufshcd_runtime_idle(struct ufs_hba *hba); | 620 | extern int ufshcd_runtime_idle(struct ufs_hba *hba); |