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) \ argument
25 for (i = 0; i < (phy)->lane_cnt; i++)
31 static void samsung_ufs_phy_config(struct samsung_ufs_phy *phy, in samsung_ufs_phy_config() argument
39 writel(cfg->val, (phy)->reg_pma + cfg->off_0); in samsung_ufs_phy_config()
43 writel(cfg->val, (phy)->reg_pma + cfg->off_1); in samsung_ufs_phy_config()
48 static int samsung_ufs_phy_wait_for_lock_acq(struct phy *phy) in samsung_ufs_phy_wait_for_lock_acq() argument
50 struct samsung_ufs_phy *ufs_phy = get_samsung_ufs_phy(phy); in samsung_ufs_phy_wait_for_lock_acq()
61 "failed to get phy pll lock acquisition %d\n", err); in samsung_ufs_phy_wait_for_lock_acq()
71 "failed to get phy cdr lock acquisition %d\n", err); in samsung_ufs_phy_wait_for_lock_acq()
76 static int samsung_ufs_phy_calibrate(struct phy *phy) in samsung_ufs_phy_calibrate() argument
78 struct samsung_ufs_phy *ufs_phy = get_samsung_ufs_phy(phy); in samsung_ufs_phy_calibrate()
86 dev_err(ufs_phy->dev, "invalid phy config index %d\n", ufs_phy->ufs_phy_state); in samsung_ufs_phy_calibrate()
101 err = samsung_ufs_phy_wait_for_lock_acq(phy); in samsung_ufs_phy_calibrate()
104 * In Samsung ufshci, PHY need to be calibrated at different in samsung_ufs_phy_calibrate()
107 * Below state machine to make sure to calibrate PHY in each in samsung_ufs_phy_calibrate()
108 * state. Here after configuring PHY in a given state, will in samsung_ufs_phy_calibrate()
109 * change the state to next state so that next state phy in samsung_ufs_phy_calibrate()
128 dev_err(ufs_phy->dev, "wrong state for phy calibration\n"); in samsung_ufs_phy_calibrate()
134 static int samsung_ufs_phy_clks_init(struct samsung_ufs_phy *phy) in samsung_ufs_phy_clks_init() argument
137 const struct samsung_ufs_phy_drvdata *drvdata = phy->drvdata; in samsung_ufs_phy_clks_init()
140 phy->clks = devm_kcalloc(phy->dev, num_clks, sizeof(*phy->clks), in samsung_ufs_phy_clks_init()
142 if (!phy->clks) in samsung_ufs_phy_clks_init()
146 phy->clks[i].id = drvdata->clk_list[i]; in samsung_ufs_phy_clks_init()
148 return devm_clk_bulk_get(phy->dev, num_clks, phy->clks); in samsung_ufs_phy_clks_init()
151 static int samsung_ufs_phy_init(struct phy *phy) in samsung_ufs_phy_init() argument
153 struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy); in samsung_ufs_phy_init()
155 ss_phy->lane_cnt = phy->attrs.bus_width; in samsung_ufs_phy_init()
161 static int samsung_ufs_phy_power_on(struct phy *phy) in samsung_ufs_phy_power_on() argument
163 struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy); in samsung_ufs_phy_power_on()
170 dev_err(ss_phy->dev, "failed to enable ufs phy clocks\n"); in samsung_ufs_phy_power_on()
175 ret = samsung_ufs_phy_calibrate(phy); in samsung_ufs_phy_power_on()
177 dev_err(ss_phy->dev, "ufs phy calibration failed\n"); in samsung_ufs_phy_power_on()
183 static int samsung_ufs_phy_power_off(struct phy *phy) in samsung_ufs_phy_power_off() argument
185 struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy); in samsung_ufs_phy_power_off()
194 static int samsung_ufs_phy_set_mode(struct phy *generic_phy, in samsung_ufs_phy_set_mode()
207 static int samsung_ufs_phy_exit(struct phy *phy) in samsung_ufs_phy_exit() argument
209 struct samsung_ufs_phy *ss_phy = get_samsung_ufs_phy(phy); in samsung_ufs_phy_exit()
232 struct samsung_ufs_phy *phy; in samsung_ufs_phy_probe() local
233 struct phy *gen_phy; in samsung_ufs_phy_probe()
246 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); in samsung_ufs_phy_probe()
247 if (!phy) { in samsung_ufs_phy_probe()
252 phy->reg_pma = devm_platform_ioremap_resource_byname(pdev, "phy-pma"); in samsung_ufs_phy_probe()
253 if (IS_ERR(phy->reg_pma)) { in samsung_ufs_phy_probe()
254 err = PTR_ERR(phy->reg_pma); in samsung_ufs_phy_probe()
258 phy->reg_pmu = syscon_regmap_lookup_by_phandle( in samsung_ufs_phy_probe()
260 if (IS_ERR(phy->reg_pmu)) { in samsung_ufs_phy_probe()
261 err = PTR_ERR(phy->reg_pmu); in samsung_ufs_phy_probe()
269 dev_err(dev, "failed to create PHY for ufs-phy\n"); in samsung_ufs_phy_probe()
274 phy->dev = dev; in samsung_ufs_phy_probe()
275 phy->drvdata = drvdata; in samsung_ufs_phy_probe()
276 phy->cfgs = drvdata->cfgs; in samsung_ufs_phy_probe()
277 memcpy(&phy->isol, &drvdata->isol, sizeof(phy->isol)); in samsung_ufs_phy_probe()
281 phy->isol.offset = isol_offset; in samsung_ufs_phy_probe()
283 phy->lane_cnt = PHY_DEF_LANE_CNT; in samsung_ufs_phy_probe()
285 err = samsung_ufs_phy_clks_init(phy); in samsung_ufs_phy_probe()
287 dev_err(dev, "failed to get phy clocks\n"); in samsung_ufs_phy_probe()
291 phy_set_drvdata(gen_phy, phy); in samsung_ufs_phy_probe()
296 dev_err(dev, "failed to register phy-provider\n"); in samsung_ufs_phy_probe()
305 .compatible = "samsung,exynos7-ufs-phy",
308 .compatible = "samsung,exynosautov9-ufs-phy",
311 .compatible = "tesla,fsd-ufs-phy",
321 .name = "samsung-ufs-phy",
326 MODULE_DESCRIPTION("Samsung SoC UFS PHY Driver");