Lines Matching +full:100 +full:base +full:- +full:tx
1 // SPDX-License-Identifier: GPL-2.0+
56 void __iomem *base; member
71 return DIV_ROUND_CLOSEST(percent - 94U, 2); in phy_tx_vref_tune_from_property()
81 case 100 ... 101: in phy_tx_rise_tune_from_property()
135 percent = min(percent, 100U); in phy_pcs_tx_swing_full_from_property()
137 return (percent * 127) / 100; in phy_pcs_tx_swing_full_from_property()
142 struct device *dev = imx_phy->phy->dev.parent; in imx8m_get_phy_tuning_data()
144 if (device_property_read_u32(dev, "fsl,phy-tx-vref-tune-percent", in imx8m_get_phy_tuning_data()
145 &imx_phy->tx_vref_tune)) in imx8m_get_phy_tuning_data()
146 imx_phy->tx_vref_tune = PHY_TUNE_DEFAULT; in imx8m_get_phy_tuning_data()
148 imx_phy->tx_vref_tune = in imx8m_get_phy_tuning_data()
149 phy_tx_vref_tune_from_property(imx_phy->tx_vref_tune); in imx8m_get_phy_tuning_data()
151 if (device_property_read_u32(dev, "fsl,phy-tx-rise-tune-percent", in imx8m_get_phy_tuning_data()
152 &imx_phy->tx_rise_tune)) in imx8m_get_phy_tuning_data()
153 imx_phy->tx_rise_tune = PHY_TUNE_DEFAULT; in imx8m_get_phy_tuning_data()
155 imx_phy->tx_rise_tune = in imx8m_get_phy_tuning_data()
156 phy_tx_rise_tune_from_property(imx_phy->tx_rise_tune); in imx8m_get_phy_tuning_data()
158 if (device_property_read_u32(dev, "fsl,phy-tx-preemp-amp-tune-microamp", in imx8m_get_phy_tuning_data()
159 &imx_phy->tx_preemp_amp_tune)) in imx8m_get_phy_tuning_data()
160 imx_phy->tx_preemp_amp_tune = PHY_TUNE_DEFAULT; in imx8m_get_phy_tuning_data()
162 imx_phy->tx_preemp_amp_tune = in imx8m_get_phy_tuning_data()
163 phy_tx_preemp_amp_tune_from_property(imx_phy->tx_preemp_amp_tune); in imx8m_get_phy_tuning_data()
165 if (device_property_read_u32(dev, "fsl,phy-tx-vboost-level-microvolt", in imx8m_get_phy_tuning_data()
166 &imx_phy->tx_vboost_level)) in imx8m_get_phy_tuning_data()
167 imx_phy->tx_vboost_level = PHY_TUNE_DEFAULT; in imx8m_get_phy_tuning_data()
169 imx_phy->tx_vboost_level = in imx8m_get_phy_tuning_data()
170 phy_tx_vboost_level_from_property(imx_phy->tx_vboost_level); in imx8m_get_phy_tuning_data()
172 if (device_property_read_u32(dev, "fsl,phy-comp-dis-tune-percent", in imx8m_get_phy_tuning_data()
173 &imx_phy->comp_dis_tune)) in imx8m_get_phy_tuning_data()
174 imx_phy->comp_dis_tune = PHY_TUNE_DEFAULT; in imx8m_get_phy_tuning_data()
176 imx_phy->comp_dis_tune = in imx8m_get_phy_tuning_data()
177 phy_comp_dis_tune_from_property(imx_phy->comp_dis_tune); in imx8m_get_phy_tuning_data()
179 if (device_property_read_u32(dev, "fsl,phy-pcs-tx-deemph-3p5db-attenuation-db", in imx8m_get_phy_tuning_data()
180 &imx_phy->pcs_tx_deemph_3p5db)) in imx8m_get_phy_tuning_data()
181 imx_phy->pcs_tx_deemph_3p5db = PHY_TUNE_DEFAULT; in imx8m_get_phy_tuning_data()
183 imx_phy->pcs_tx_deemph_3p5db = in imx8m_get_phy_tuning_data()
184 phy_pcs_tx_deemph_3p5db_from_property(imx_phy->pcs_tx_deemph_3p5db); in imx8m_get_phy_tuning_data()
186 if (device_property_read_u32(dev, "fsl,phy-pcs-tx-swing-full-percent", in imx8m_get_phy_tuning_data()
187 &imx_phy->pcs_tx_swing_full)) in imx8m_get_phy_tuning_data()
188 imx_phy->pcs_tx_swing_full = PHY_TUNE_DEFAULT; in imx8m_get_phy_tuning_data()
190 imx_phy->pcs_tx_swing_full = in imx8m_get_phy_tuning_data()
191 phy_pcs_tx_swing_full_from_property(imx_phy->pcs_tx_swing_full); in imx8m_get_phy_tuning_data()
199 if (imx_phy->pcs_tx_deemph_3p5db != PHY_TUNE_DEFAULT) { in imx8m_phy_tune()
200 value = readl(imx_phy->base + PHY_CTRL4); in imx8m_phy_tune()
203 imx_phy->pcs_tx_deemph_3p5db); in imx8m_phy_tune()
204 writel(value, imx_phy->base + PHY_CTRL4); in imx8m_phy_tune()
207 if (imx_phy->pcs_tx_swing_full != PHY_TUNE_DEFAULT) { in imx8m_phy_tune()
208 value = readl(imx_phy->base + PHY_CTRL5); in imx8m_phy_tune()
210 imx_phy->pcs_tx_swing_full); in imx8m_phy_tune()
211 writel(value, imx_phy->base + PHY_CTRL5); in imx8m_phy_tune()
214 if ((imx_phy->tx_vref_tune & imx_phy->tx_rise_tune & in imx8m_phy_tune()
215 imx_phy->tx_preemp_amp_tune & imx_phy->comp_dis_tune & in imx8m_phy_tune()
216 imx_phy->tx_vboost_level) == PHY_TUNE_DEFAULT) in imx8m_phy_tune()
220 value = readl(imx_phy->base + PHY_CTRL3); in imx8m_phy_tune()
222 if (imx_phy->tx_vref_tune != PHY_TUNE_DEFAULT) { in imx8m_phy_tune()
225 imx_phy->tx_vref_tune); in imx8m_phy_tune()
228 if (imx_phy->tx_rise_tune != PHY_TUNE_DEFAULT) { in imx8m_phy_tune()
231 imx_phy->tx_rise_tune); in imx8m_phy_tune()
234 if (imx_phy->tx_preemp_amp_tune != PHY_TUNE_DEFAULT) { in imx8m_phy_tune()
237 imx_phy->tx_preemp_amp_tune); in imx8m_phy_tune()
240 if (imx_phy->comp_dis_tune != PHY_TUNE_DEFAULT) { in imx8m_phy_tune()
243 imx_phy->comp_dis_tune); in imx8m_phy_tune()
246 if (imx_phy->tx_vboost_level != PHY_TUNE_DEFAULT) { in imx8m_phy_tune()
249 imx_phy->tx_vboost_level); in imx8m_phy_tune()
252 writel(value, imx_phy->base + PHY_CTRL3); in imx8m_phy_tune()
260 value = readl(imx_phy->base + PHY_CTRL1); in imx8mq_usb_phy_init()
264 writel(value, imx_phy->base + PHY_CTRL1); in imx8mq_usb_phy_init()
266 value = readl(imx_phy->base + PHY_CTRL0); in imx8mq_usb_phy_init()
268 writel(value, imx_phy->base + PHY_CTRL0); in imx8mq_usb_phy_init()
270 value = readl(imx_phy->base + PHY_CTRL2); in imx8mq_usb_phy_init()
272 writel(value, imx_phy->base + PHY_CTRL2); in imx8mq_usb_phy_init()
274 value = readl(imx_phy->base + PHY_CTRL1); in imx8mq_usb_phy_init()
276 writel(value, imx_phy->base + PHY_CTRL1); in imx8mq_usb_phy_init()
287 value = readl(imx_phy->base + PHY_CTRL0); in imx8mp_usb_phy_init()
290 writel(value, imx_phy->base + PHY_CTRL0); in imx8mp_usb_phy_init()
293 value = readl(imx_phy->base + PHY_CTRL6); in imx8mp_usb_phy_init()
295 writel(value, imx_phy->base + PHY_CTRL6); in imx8mp_usb_phy_init()
297 value = readl(imx_phy->base + PHY_CTRL1); in imx8mp_usb_phy_init()
300 writel(value, imx_phy->base + PHY_CTRL1); in imx8mp_usb_phy_init()
302 value = readl(imx_phy->base + PHY_CTRL0); in imx8mp_usb_phy_init()
304 writel(value, imx_phy->base + PHY_CTRL0); in imx8mp_usb_phy_init()
306 value = readl(imx_phy->base + PHY_CTRL2); in imx8mp_usb_phy_init()
308 writel(value, imx_phy->base + PHY_CTRL2); in imx8mp_usb_phy_init()
312 value = readl(imx_phy->base + PHY_CTRL1); in imx8mp_usb_phy_init()
314 writel(value, imx_phy->base + PHY_CTRL1); in imx8mp_usb_phy_init()
326 ret = regulator_enable(imx_phy->vbus); in imx8mq_phy_power_on()
330 return clk_prepare_enable(imx_phy->clk); in imx8mq_phy_power_on()
337 clk_disable_unprepare(imx_phy->clk); in imx8mq_phy_power_off()
338 regulator_disable(imx_phy->vbus); in imx8mq_phy_power_off()
358 {.compatible = "fsl,imx8mq-usb-phy",
360 {.compatible = "fsl,imx8mp-usb-phy",
369 struct device *dev = &pdev->dev; in imx8mq_usb_phy_probe()
375 return -ENOMEM; in imx8mq_usb_phy_probe()
377 imx_phy->clk = devm_clk_get(dev, "phy"); in imx8mq_usb_phy_probe()
378 if (IS_ERR(imx_phy->clk)) { in imx8mq_usb_phy_probe()
380 return PTR_ERR(imx_phy->clk); in imx8mq_usb_phy_probe()
383 imx_phy->base = devm_platform_ioremap_resource(pdev, 0); in imx8mq_usb_phy_probe()
384 if (IS_ERR(imx_phy->base)) in imx8mq_usb_phy_probe()
385 return PTR_ERR(imx_phy->base); in imx8mq_usb_phy_probe()
389 return -EINVAL; in imx8mq_usb_phy_probe()
391 imx_phy->phy = devm_phy_create(dev, NULL, phy_ops); in imx8mq_usb_phy_probe()
392 if (IS_ERR(imx_phy->phy)) in imx8mq_usb_phy_probe()
393 return PTR_ERR(imx_phy->phy); in imx8mq_usb_phy_probe()
395 imx_phy->vbus = devm_regulator_get(dev, "vbus"); in imx8mq_usb_phy_probe()
396 if (IS_ERR(imx_phy->vbus)) in imx8mq_usb_phy_probe()
397 return dev_err_probe(dev, PTR_ERR(imx_phy->vbus), "failed to get vbus\n"); in imx8mq_usb_phy_probe()
399 phy_set_drvdata(imx_phy->phy, imx_phy); in imx8mq_usb_phy_probe()
411 .name = "imx8mq-usb-phy",