Skip to content

Commit a4de58a

Browse files
petegriffinvinodkoul
authored andcommitted
phy: samsung-ufs: ufs: Add SoC callbacks for calibration and clk data recovery
Some SoCs like gs101 don't fit in well with the existing pll lock and clock data recovery (CDR) callback used by existing exynos platforms. Allow SoCs to specifify and implement their own calibration and CDR functions that can be called by the generic samsung phy code. Signed-off-by: Peter Griffin <[email protected]> Acked-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent f2c6d0f commit a4de58a

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

drivers/phy/samsung/phy-exynos7-ufs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,5 @@ const struct samsung_ufs_phy_drvdata exynos7_ufs_phy = {
8282
.clk_list = exynos7_ufs_phy_clks,
8383
.num_clks = ARRAY_SIZE(exynos7_ufs_phy_clks),
8484
.cdr_lock_status_offset = EXYNOS7_EMBEDDED_COMBO_PHY_CDR_LOCK_STATUS,
85+
.wait_for_cdr = samsung_ufs_phy_wait_for_lock_acq,
8586
};

drivers/phy/samsung/phy-exynosautov9-ufs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,5 @@ const struct samsung_ufs_phy_drvdata exynosautov9_ufs_phy = {
7171
.clk_list = exynosautov9_ufs_phy_clks,
7272
.num_clks = ARRAY_SIZE(exynosautov9_ufs_phy_clks),
7373
.cdr_lock_status_offset = EXYNOSAUTOV9_EMBEDDED_COMBO_PHY_CDR_LOCK_STATUS,
74+
.wait_for_cdr = samsung_ufs_phy_wait_for_lock_acq,
7475
};

drivers/phy/samsung/phy-fsd-ufs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ const struct samsung_ufs_phy_drvdata fsd_ufs_phy = {
6060
.clk_list = fsd_ufs_phy_clks,
6161
.num_clks = ARRAY_SIZE(fsd_ufs_phy_clks),
6262
.cdr_lock_status_offset = FSD_EMBEDDED_COMBO_PHY_CDR_LOCK_STATUS,
63+
.wait_for_cdr = samsung_ufs_phy_wait_for_lock_acq,
6364
};

drivers/phy/samsung/phy-samsung-ufs.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static void samsung_ufs_phy_config(struct samsung_ufs_phy *phy,
4646
}
4747
}
4848

49-
static int samsung_ufs_phy_wait_for_lock_acq(struct phy *phy)
49+
int samsung_ufs_phy_wait_for_lock_acq(struct phy *phy, u8 lane)
5050
{
5151
struct samsung_ufs_phy *ufs_phy = get_samsung_ufs_phy(phy);
5252
const unsigned int timeout_us = 100000;
@@ -98,8 +98,15 @@ static int samsung_ufs_phy_calibrate(struct phy *phy)
9898
}
9999
}
100100

101-
if (ufs_phy->ufs_phy_state == CFG_POST_PWR_HS)
102-
err = samsung_ufs_phy_wait_for_lock_acq(phy);
101+
for_each_phy_lane(ufs_phy, i) {
102+
if (ufs_phy->ufs_phy_state == CFG_PRE_INIT &&
103+
ufs_phy->drvdata->wait_for_cal)
104+
err = ufs_phy->drvdata->wait_for_cal(phy, i);
105+
106+
if (ufs_phy->ufs_phy_state == CFG_POST_PWR_HS &&
107+
ufs_phy->drvdata->wait_for_cdr)
108+
err = ufs_phy->drvdata->wait_for_cdr(phy, i);
109+
}
103110

104111
/**
105112
* In Samsung ufshci, PHY need to be calibrated at different

drivers/phy/samsung/phy-samsung-ufs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ struct samsung_ufs_phy_drvdata {
112112
const char * const *clk_list;
113113
int num_clks;
114114
u32 cdr_lock_status_offset;
115+
/* SoC's specific operations */
116+
int (*wait_for_cal)(struct phy *phy, u8 lane);
117+
int (*wait_for_cdr)(struct phy *phy, u8 lane);
115118
};
116119

117120
struct samsung_ufs_phy {
@@ -139,6 +142,8 @@ static inline void samsung_ufs_phy_ctrl_isol(
139142
phy->isol.mask, isol ? 0 : phy->isol.en);
140143
}
141144

145+
int samsung_ufs_phy_wait_for_lock_acq(struct phy *phy, u8 lane);
146+
142147
extern const struct samsung_ufs_phy_drvdata exynos7_ufs_phy;
143148
extern const struct samsung_ufs_phy_drvdata exynosautov9_ufs_phy;
144149
extern const struct samsung_ufs_phy_drvdata fsd_ufs_phy;

0 commit comments

Comments
 (0)