Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: ufs-qcom: phy/hcd: Refactoring phy clock handling

Add phy clock enable code to phy_power_on/off callbacks, and
remove explicit calls to enable these phy clocks from the
ufs-qcom hcd driver.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Vivek Gautam and committed by
Martin K. Petersen
feb3d798 9c7ce698

+24 -51
+18 -18
drivers/phy/phy-qcom-ufs.c
··· 361 361 return ret; 362 362 } 363 363 364 - int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy) 364 + static int ufs_qcom_phy_enable_ref_clk(struct ufs_qcom_phy *phy) 365 365 { 366 366 int ret = 0; 367 - struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy); 368 367 369 368 if (phy->is_ref_clk_enabled) 370 369 goto out; ··· 410 411 out: 411 412 return ret; 412 413 } 413 - EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_ref_clk); 414 414 415 415 static int ufs_qcom_phy_disable_vreg(struct device *dev, 416 416 struct ufs_qcom_phy_vreg *vreg) ··· 433 435 return ret; 434 436 } 435 437 436 - void ufs_qcom_phy_disable_ref_clk(struct phy *generic_phy) 438 + static void ufs_qcom_phy_disable_ref_clk(struct ufs_qcom_phy *phy) 437 439 { 438 - struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy); 439 - 440 440 if (phy->is_ref_clk_enabled) { 441 441 clk_disable_unprepare(phy->ref_clk); 442 442 /* ··· 447 451 phy->is_ref_clk_enabled = false; 448 452 } 449 453 } 450 - EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_ref_clk); 451 454 452 455 #define UFS_REF_CLK_EN (1 << 5) 453 456 ··· 499 504 EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_dev_ref_clk); 500 505 501 506 /* Turn ON M-PHY RMMI interface clocks */ 502 - int ufs_qcom_phy_enable_iface_clk(struct phy *generic_phy) 507 + static int ufs_qcom_phy_enable_iface_clk(struct ufs_qcom_phy *phy) 503 508 { 504 - struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy); 505 509 int ret = 0; 506 510 507 511 if (phy->is_iface_clk_enabled) ··· 524 530 out: 525 531 return ret; 526 532 } 527 - EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_iface_clk); 528 533 529 534 /* Turn OFF M-PHY RMMI interface clocks */ 530 - void ufs_qcom_phy_disable_iface_clk(struct phy *generic_phy) 535 + void ufs_qcom_phy_disable_iface_clk(struct ufs_qcom_phy *phy) 531 536 { 532 - struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy); 533 - 534 537 if (phy->is_iface_clk_enabled) { 535 538 clk_disable_unprepare(phy->tx_iface_clk); 536 539 clk_disable_unprepare(phy->rx_iface_clk); 537 540 phy->is_iface_clk_enabled = false; 538 541 } 539 542 } 540 - EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_iface_clk); 541 543 542 544 int ufs_qcom_phy_start_serdes(struct phy *generic_phy) 543 545 { ··· 651 661 goto out_disable_phy; 652 662 } 653 663 654 - err = ufs_qcom_phy_enable_ref_clk(generic_phy); 664 + err = ufs_qcom_phy_enable_iface_clk(phy_common); 665 + if (err) { 666 + dev_err(dev, "%s enable phy iface clock failed, err=%d\n", 667 + __func__, err); 668 + goto out_disable_pll; 669 + } 670 + 671 + err = ufs_qcom_phy_enable_ref_clk(phy_common); 655 672 if (err) { 656 673 dev_err(dev, "%s enable phy ref clock failed, err=%d\n", 657 674 __func__, err); 658 - goto out_disable_pll; 675 + goto out_disable_iface_clk; 659 676 } 660 677 661 678 /* enable device PHY ref_clk pad rail */ ··· 680 683 goto out; 681 684 682 685 out_disable_ref_clk: 683 - ufs_qcom_phy_disable_ref_clk(generic_phy); 686 + ufs_qcom_phy_disable_ref_clk(phy_common); 687 + out_disable_iface_clk: 688 + ufs_qcom_phy_disable_iface_clk(phy_common); 684 689 out_disable_pll: 685 690 ufs_qcom_phy_disable_vreg(dev, &phy_common->vdda_pll); 686 691 out_disable_phy: ··· 701 702 if (phy_common->vddp_ref_clk.reg) 702 703 ufs_qcom_phy_disable_vreg(phy_common->dev, 703 704 &phy_common->vddp_ref_clk); 704 - ufs_qcom_phy_disable_ref_clk(generic_phy); 705 + ufs_qcom_phy_disable_ref_clk(phy_common); 706 + ufs_qcom_phy_disable_iface_clk(phy_common); 705 707 706 708 ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_pll); 707 709 ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_phy);
+6 -15
drivers/scsi/ufs/ufs-qcom.c
··· 1114 1114 return 0; 1115 1115 1116 1116 if (on && (status == POST_CHANGE)) { 1117 - err = ufs_qcom_phy_enable_iface_clk(host->generic_phy); 1118 - if (err) 1119 - goto out; 1117 + phy_power_on(host->generic_phy); 1120 1118 1121 - err = ufs_qcom_phy_enable_ref_clk(host->generic_phy); 1122 - if (err) { 1123 - dev_err(hba->dev, "%s enable phy ref clock failed, err=%d\n", 1124 - __func__, err); 1125 - ufs_qcom_phy_disable_iface_clk(host->generic_phy); 1126 - goto out; 1127 - } 1128 1119 /* enable the device ref clock for HS mode*/ 1129 1120 if (ufshcd_is_hs_mode(&hba->pwr_info)) 1130 1121 ufs_qcom_dev_ref_clk_ctrl(host, true); ··· 1124 1133 ufs_qcom_update_bus_bw_vote(host); 1125 1134 1126 1135 } else if (!on && (status == PRE_CHANGE)) { 1127 - 1128 - /* M-PHY RMMI interface clocks can be turned off */ 1129 - ufs_qcom_phy_disable_iface_clk(host->generic_phy); 1130 - if (!ufs_qcom_is_link_active(hba)) 1136 + if (!ufs_qcom_is_link_active(hba)) { 1131 1137 /* disable device ref_clk */ 1132 1138 ufs_qcom_dev_ref_clk_ctrl(host, false); 1139 + 1140 + /* powering off PHY during aggressive clk gating */ 1141 + phy_power_off(host->generic_phy); 1142 + } 1133 1143 1134 1144 vote = host->bus_vote.min_bw_vote; 1135 1145 } ··· 1140 1148 dev_err(hba->dev, "%s: set bus vote failed %d\n", 1141 1149 __func__, err); 1142 1150 1143 - out: 1144 1151 return err; 1145 1152 } 1146 1153
-18
include/linux/phy/phy-qcom-ufs.h
··· 18 18 #include "phy.h" 19 19 20 20 /** 21 - * ufs_qcom_phy_enable_ref_clk() - Enable the phy 22 - * ref clock. 23 - * @phy: reference to a generic phy 24 - * 25 - * returns 0 for success, and non-zero for error. 26 - */ 27 - int ufs_qcom_phy_enable_ref_clk(struct phy *phy); 28 - 29 - /** 30 - * ufs_qcom_phy_disable_ref_clk() - Disable the phy 31 - * ref clock. 32 - * @phy: reference to a generic phy. 33 - */ 34 - void ufs_qcom_phy_disable_ref_clk(struct phy *phy); 35 - 36 - /** 37 21 * ufs_qcom_phy_enable_dev_ref_clk() - Enable the device 38 22 * ref clock. 39 23 * @phy: reference to a generic phy. ··· 31 47 */ 32 48 void ufs_qcom_phy_disable_dev_ref_clk(struct phy *phy); 33 49 34 - int ufs_qcom_phy_enable_iface_clk(struct phy *phy); 35 - void ufs_qcom_phy_disable_iface_clk(struct phy *phy); 36 50 int ufs_qcom_phy_start_serdes(struct phy *phy); 37 51 int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 tx_lanes); 38 52 int ufs_qcom_phy_calibrate_phy(struct phy *phy, bool is_rate_B);