Lines Matching defs:phy
18 #include <linux/phy/phy.h>
22 #include "phy-samsung-ufs.h"
24 #define for_each_phy_lane(phy, i) \
25 for (i = 0; i < (phy)->lane_cnt; i++)
31 static void samsung_ufs_phy_config(struct samsung_ufs_phy *phy,
39 writel(cfg->val, (phy)->reg_pma + cfg->off_0);
43 writel(cfg->val, (phy)->reg_pma + cfg->off_1);
48 static int samsung_ufs_phy_wait_for_lock_acq(struct phy *phy)
50 struct samsung_ufs_phy *ufs_phy = get_samsung_ufs_phy(phy);
61 "failed to get phy pll lock acquisition %d\n", err);
71 "failed to get phy cdr lock acquisition %d\n", err);
76 static int samsung_ufs_phy_calibrate(struct phy *phy)
78 struct samsung_ufs_phy *ufs_phy = get_samsung_ufs_phy(phy);
86 dev_err(ufs_phy->dev, "invalid phy config index %d\n", ufs_phy->ufs_phy_state);
101 err = samsung_ufs_phy_wait_for_lock_acq(phy);
109 * change the state to next state so that next state phy
128 dev_err(ufs_phy->dev, "wrong state for phy calibration\n");
134 static int samsung_ufs_phy_clks_init(struct samsung_ufs_phy *phy)
137 const struct samsung_ufs_phy_drvdata *drvdata = phy->drvdata;
140 phy->clks = devm_kcalloc(phy->dev, num_clks, sizeof(*phy->clks),
142 if (!phy->clks)
146 phy->clks[i].id = drvdata->clk_list[i];
148 return devm_clk_bulk_get(phy->dev, num_clks, phy->clks);
151 static int samsung_ufs_phy_init(struct phy *phy)
153 struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy);
155 ss_phy->lane_cnt = phy->attrs.bus_width;
161 static int samsung_ufs_phy_power_on(struct phy *phy)
163 struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy);
170 dev_err(ss_phy->dev, "failed to enable ufs phy clocks\n");
175 ret = samsung_ufs_phy_calibrate(phy);
177 dev_err(ss_phy->dev, "ufs phy calibration failed\n");
183 static int samsung_ufs_phy_power_off(struct phy *phy)
185 struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy);
194 static int samsung_ufs_phy_set_mode(struct phy *generic_phy,
207 static int samsung_ufs_phy_exit(struct phy *phy)
209 struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy);
232 struct samsung_ufs_phy *phy;
233 struct phy *gen_phy;
246 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
247 if (!phy) {
252 phy->reg_pma = devm_platform_ioremap_resource_byname(pdev, "phy-pma");
253 if (IS_ERR(phy->reg_pma)) {
254 err = PTR_ERR(phy->reg_pma);
258 phy->reg_pmu = syscon_regmap_lookup_by_phandle(
260 if (IS_ERR(phy->reg_pmu)) {
261 err = PTR_ERR(phy->reg_pmu);
269 dev_err(dev, "failed to create PHY for ufs-phy\n");
274 phy->dev = dev;
275 phy->drvdata = drvdata;
276 phy->cfgs = drvdata->cfgs;
277 memcpy(&phy->isol, &drvdata->isol, sizeof(phy->isol));
281 phy->isol.offset = isol_offset;
283 phy->lane_cnt = PHY_DEF_LANE_CNT;
285 err = samsung_ufs_phy_clks_init(phy);
287 dev_err(dev, "failed to get phy clocks\n");
291 phy_set_drvdata(gen_phy, phy);
296 dev_err(dev, "failed to register phy-provider\n");
305 .compatible = "samsung,exynos7-ufs-phy",
308 .compatible = "samsung,exynosautov9-ufs-phy",
311 .compatible = "tesla,fsd-ufs-phy",
321 .name = "samsung-ufs-phy",