Lines Matching full:phy
3 * UFS PHY driver for Samsung SoC
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 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 int samsung_ufs_phy_wait_for_lock_acq(struct phy *phy, u8 lane)
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);
103 err = ufs_phy->drvdata->wait_for_cal(phy, i);
110 err = ufs_phy->drvdata->wait_for_cdr(phy, i);
117 * In Samsung ufshci, PHY need to be calibrated at different
120 * Below state machine to make sure to calibrate PHY in each
121 * state. Here after configuring PHY in a given state, will
122 * change the state to next state so that next state phy
141 dev_err(ufs_phy->dev, "wrong state for phy calibration\n");
147 static int samsung_ufs_phy_clks_init(struct samsung_ufs_phy *phy)
150 const struct samsung_ufs_phy_drvdata *drvdata = phy->drvdata;
153 phy->clks = devm_kcalloc(phy->dev, num_clks, sizeof(*phy->clks),
155 if (!phy->clks)
159 phy->clks[i].id = drvdata->clk_list[i];
161 return devm_clk_bulk_get(phy->dev, num_clks, phy->clks);
164 static int samsung_ufs_phy_init(struct phy *phy)
166 struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy);
168 ss_phy->lane_cnt = phy->attrs.bus_width;
174 static int samsung_ufs_phy_power_on(struct phy *phy)
176 struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy);
183 dev_err(ss_phy->dev, "failed to enable ufs phy clocks\n");
188 ret = samsung_ufs_phy_calibrate(phy);
190 dev_err(ss_phy->dev, "ufs phy calibration failed\n");
196 static int samsung_ufs_phy_power_off(struct phy *phy)
198 struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy);
207 static int samsung_ufs_phy_set_mode(struct phy *generic_phy,
220 static int samsung_ufs_phy_exit(struct phy *phy)
222 struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy);
245 struct samsung_ufs_phy *phy;
246 struct phy *gen_phy;
259 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
260 if (!phy) {
265 phy->reg_pma = devm_platform_ioremap_resource_byname(pdev, "phy-pma");
266 if (IS_ERR(phy->reg_pma)) {
267 err = PTR_ERR(phy->reg_pma);
271 phy->reg_pmu = syscon_regmap_lookup_by_phandle(dev->of_node,
273 if (IS_ERR(phy->reg_pmu)) {
274 err = PTR_ERR(phy->reg_pmu);
282 dev_err(dev, "failed to create PHY for ufs-phy\n");
287 phy->dev = dev;
288 phy->drvdata = drvdata;
289 phy->cfgs = drvdata->cfgs;
290 memcpy(&phy->isol, &drvdata->isol, sizeof(phy->isol));
294 phy->isol.offset = isol_offset;
296 phy->lane_cnt = PHY_DEF_LANE_CNT;
298 err = samsung_ufs_phy_clks_init(phy);
300 dev_err(dev, "failed to get phy clocks\n");
304 phy_set_drvdata(gen_phy, phy);
309 dev_err(dev, "failed to register phy-provider\n");
318 .compatible = "google,gs101-ufs-phy",
321 .compatible = "samsung,exynos7-ufs-phy",
324 .compatible = "samsung,exynosautov9-ufs-phy",
327 .compatible = "samsung,exynosautov920-ufs-phy",
330 .compatible = "tesla,fsd-ufs-phy",
340 .name = "samsung-ufs-phy",
345 MODULE_DESCRIPTION("Samsung SoC UFS PHY Driver");