Lines Matching refs:host
29 static int ufs_qcom_get_bus_vote(struct ufs_qcom_host *host,
31 static int ufs_qcom_set_bus_vote(struct ufs_qcom_host *host, int vote);
76 static void ufs_qcom_disable_lane_clks(struct ufs_qcom_host *host) in ufs_qcom_disable_lane_clks() argument
78 if (!host->is_lane_clks_enabled) in ufs_qcom_disable_lane_clks()
81 clk_disable_unprepare(host->tx_l1_sync_clk); in ufs_qcom_disable_lane_clks()
82 clk_disable_unprepare(host->tx_l0_sync_clk); in ufs_qcom_disable_lane_clks()
83 clk_disable_unprepare(host->rx_l1_sync_clk); in ufs_qcom_disable_lane_clks()
84 clk_disable_unprepare(host->rx_l0_sync_clk); in ufs_qcom_disable_lane_clks()
86 host->is_lane_clks_enabled = false; in ufs_qcom_disable_lane_clks()
89 static int ufs_qcom_enable_lane_clks(struct ufs_qcom_host *host) in ufs_qcom_enable_lane_clks() argument
92 struct device *dev = host->hba->dev; in ufs_qcom_enable_lane_clks()
94 if (host->is_lane_clks_enabled) in ufs_qcom_enable_lane_clks()
98 host->rx_l0_sync_clk); in ufs_qcom_enable_lane_clks()
103 host->tx_l0_sync_clk); in ufs_qcom_enable_lane_clks()
108 host->rx_l1_sync_clk); in ufs_qcom_enable_lane_clks()
113 host->tx_l1_sync_clk); in ufs_qcom_enable_lane_clks()
117 host->is_lane_clks_enabled = true; in ufs_qcom_enable_lane_clks()
121 clk_disable_unprepare(host->rx_l1_sync_clk); in ufs_qcom_enable_lane_clks()
123 clk_disable_unprepare(host->tx_l0_sync_clk); in ufs_qcom_enable_lane_clks()
125 clk_disable_unprepare(host->rx_l0_sync_clk); in ufs_qcom_enable_lane_clks()
130 static int ufs_qcom_init_lane_clks(struct ufs_qcom_host *host) in ufs_qcom_init_lane_clks() argument
133 struct device *dev = host->hba->dev; in ufs_qcom_init_lane_clks()
136 "rx_lane0_sync_clk", &host->rx_l0_sync_clk); in ufs_qcom_init_lane_clks()
141 "tx_lane0_sync_clk", &host->tx_l0_sync_clk); in ufs_qcom_init_lane_clks()
146 &host->rx_l1_sync_clk); in ufs_qcom_init_lane_clks()
151 &host->tx_l1_sync_clk); in ufs_qcom_init_lane_clks()
158 struct ufs_qcom_host *host = hba->priv; in ufs_qcom_link_startup_post_change() local
159 struct phy *phy = host->generic_phy; in ufs_qcom_link_startup_post_change()
214 struct ufs_qcom_host *host = hba->priv; in ufs_qcom_power_up_sequence() local
215 struct phy *phy = host->generic_phy; in ufs_qcom_power_up_sequence()
276 struct ufs_qcom_host *host = hba->priv; in ufs_qcom_hce_enable_notify() local
287 err = ufs_qcom_enable_lane_clks(host); in ufs_qcom_hce_enable_notify()
440 struct ufs_qcom_host *host = hba->priv; in ufs_qcom_suspend() local
441 struct phy *phy = host->generic_phy; in ufs_qcom_suspend()
450 ufs_qcom_disable_lane_clks(host); in ufs_qcom_suspend()
471 struct ufs_qcom_host *host = hba->priv; in ufs_qcom_resume() local
472 struct phy *phy = host->generic_phy; in ufs_qcom_resume()
586 static int ufs_qcom_update_bus_bw_vote(struct ufs_qcom_host *host) in ufs_qcom_update_bus_bw_vote() argument
592 ufs_qcom_get_speed_mode(&host->dev_req_params, mode); in ufs_qcom_update_bus_bw_vote()
594 vote = ufs_qcom_get_bus_vote(host, mode); in ufs_qcom_update_bus_bw_vote()
596 err = ufs_qcom_set_bus_vote(host, vote); in ufs_qcom_update_bus_bw_vote()
601 dev_err(host->hba->dev, "%s: failed %d\n", __func__, err); in ufs_qcom_update_bus_bw_vote()
603 host->bus_vote.saved_vote = vote; in ufs_qcom_update_bus_bw_vote()
613 struct ufs_qcom_host *host = hba->priv; in ufs_qcom_pwr_change_notify() local
614 struct phy *phy = host->generic_phy; in ufs_qcom_pwr_change_notify()
674 memcpy(&host->dev_req_params, in ufs_qcom_pwr_change_notify()
676 ufs_qcom_update_bus_bw_vote(host); in ufs_qcom_pwr_change_notify()
697 struct ufs_qcom_host *host = hba->priv; in ufs_qcom_advertise_quirks() local
699 if (host->hw_ver.major == 0x1) in ufs_qcom_advertise_quirks()
702 if (host->hw_ver.major >= 0x2) { in ufs_qcom_advertise_quirks()
703 if (!ufs_qcom_cap_qunipro(host)) in ufs_qcom_advertise_quirks()
711 struct ufs_qcom_host *host = hba->priv; in ufs_qcom_set_caps() local
713 if (host->hw_ver.major >= 0x2) in ufs_qcom_set_caps()
714 host->caps = UFS_QCOM_CAP_QUNIPRO; in ufs_qcom_set_caps()
717 static int ufs_qcom_get_bus_vote(struct ufs_qcom_host *host, in ufs_qcom_get_bus_vote() argument
720 struct device *dev = host->hba->dev; in ufs_qcom_get_bus_vote()
730 if (host->bus_vote.is_max_bw_needed && !!strcmp(speed_mode, "MIN")) in ufs_qcom_get_bus_vote()
742 static int ufs_qcom_set_bus_vote(struct ufs_qcom_host *host, int vote) in ufs_qcom_set_bus_vote() argument
746 if (vote != host->bus_vote.curr_vote) in ufs_qcom_set_bus_vote()
747 host->bus_vote.curr_vote = vote; in ufs_qcom_set_bus_vote()
782 struct ufs_qcom_host *host = hba->priv; in ufs_qcom_setup_clocks() local
791 if (!host) in ufs_qcom_setup_clocks()
795 err = ufs_qcom_phy_enable_iface_clk(host->generic_phy); in ufs_qcom_setup_clocks()
799 err = ufs_qcom_phy_enable_ref_clk(host->generic_phy); in ufs_qcom_setup_clocks()
803 ufs_qcom_phy_disable_iface_clk(host->generic_phy); in ufs_qcom_setup_clocks()
807 ufs_qcom_phy_enable_dev_ref_clk(host->generic_phy); in ufs_qcom_setup_clocks()
808 vote = host->bus_vote.saved_vote; in ufs_qcom_setup_clocks()
809 if (vote == host->bus_vote.min_bw_vote) in ufs_qcom_setup_clocks()
810 ufs_qcom_update_bus_bw_vote(host); in ufs_qcom_setup_clocks()
813 ufs_qcom_phy_disable_iface_clk(host->generic_phy); in ufs_qcom_setup_clocks()
816 ufs_qcom_phy_disable_ref_clk(host->generic_phy); in ufs_qcom_setup_clocks()
818 ufs_qcom_phy_disable_dev_ref_clk(host->generic_phy); in ufs_qcom_setup_clocks()
820 vote = host->bus_vote.min_bw_vote; in ufs_qcom_setup_clocks()
823 err = ufs_qcom_set_bus_vote(host, vote); in ufs_qcom_setup_clocks()
837 struct ufs_qcom_host *host = hba->priv; in show_ufs_to_mem_max_bus_bw() local
840 host->bus_vote.is_max_bw_needed); in show_ufs_to_mem_max_bus_bw()
848 struct ufs_qcom_host *host = hba->priv; in store_ufs_to_mem_max_bus_bw() local
852 host->bus_vote.is_max_bw_needed = !!value; in store_ufs_to_mem_max_bus_bw()
853 ufs_qcom_update_bus_bw_vote(host); in store_ufs_to_mem_max_bus_bw()
859 static int ufs_qcom_bus_register(struct ufs_qcom_host *host) in ufs_qcom_bus_register() argument
862 struct device *dev = host->hba->dev; in ufs_qcom_bus_register()
873 host->bus_vote.min_bw_vote = ufs_qcom_get_bus_vote(host, "MIN"); in ufs_qcom_bus_register()
874 host->bus_vote.max_bw_vote = ufs_qcom_get_bus_vote(host, "MAX"); in ufs_qcom_bus_register()
876 host->bus_vote.max_bus_bw.show = show_ufs_to_mem_max_bus_bw; in ufs_qcom_bus_register()
877 host->bus_vote.max_bus_bw.store = store_ufs_to_mem_max_bus_bw; in ufs_qcom_bus_register()
878 sysfs_attr_init(&host->bus_vote.max_bus_bw.attr); in ufs_qcom_bus_register()
879 host->bus_vote.max_bus_bw.attr.name = "max_bus_bw"; in ufs_qcom_bus_register()
880 host->bus_vote.max_bus_bw.attr.mode = S_IRUGO | S_IWUSR; in ufs_qcom_bus_register()
881 err = device_create_file(dev, &host->bus_vote.max_bus_bw); in ufs_qcom_bus_register()
909 struct ufs_qcom_host *host; in ufs_qcom_init() local
914 host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); in ufs_qcom_init()
915 if (!host) { in ufs_qcom_init()
921 host->hba = hba; in ufs_qcom_init()
922 hba->priv = (void *)host; in ufs_qcom_init()
924 host->generic_phy = devm_phy_get(dev, "ufsphy"); in ufs_qcom_init()
926 if (IS_ERR(host->generic_phy)) { in ufs_qcom_init()
927 err = PTR_ERR(host->generic_phy); in ufs_qcom_init()
932 err = ufs_qcom_bus_register(host); in ufs_qcom_init()
936 ufs_qcom_get_controller_revision(hba, &host->hw_ver.major, in ufs_qcom_init()
937 &host->hw_ver.minor, &host->hw_ver.step); in ufs_qcom_init()
940 ufs_qcom_phy_save_controller_version(host->generic_phy, in ufs_qcom_init()
941 host->hw_ver.major, host->hw_ver.minor, host->hw_ver.step); in ufs_qcom_init()
943 phy_init(host->generic_phy); in ufs_qcom_init()
944 err = phy_power_on(host->generic_phy); in ufs_qcom_init()
948 err = ufs_qcom_init_lane_clks(host); in ufs_qcom_init()
961 ufs_qcom_hosts[hba->dev->id] = host; in ufs_qcom_init()
966 phy_power_off(host->generic_phy); in ufs_qcom_init()
968 phy_exit(host->generic_phy); in ufs_qcom_init()
970 devm_kfree(dev, host); in ufs_qcom_init()
978 struct ufs_qcom_host *host = hba->priv; in ufs_qcom_exit() local
980 ufs_qcom_disable_lane_clks(host); in ufs_qcom_exit()
981 phy_power_off(host->generic_phy); in ufs_qcom_exit()
987 struct ufs_qcom_host *host = hba->priv; in ufs_qcom_clk_scale_notify() local
988 struct ufs_pa_layer_attr *dev_req_params = &host->dev_req_params; in ufs_qcom_clk_scale_notify()