Lines Matching refs:cbphy

107 	struct intel_combo_phy *cbphy = iphy->parent;
108 u32 mask = BIT(cbphy->phy_mode * 2 + iphy->id);
114 return regmap_update_bits(cbphy->hsiocfg, REG_CLK_DISABLE(cbphy->bid),
120 struct intel_combo_phy *cbphy = iphy->parent;
121 u32 mask = BIT(cbphy->id * 2 + iphy->id);
127 return regmap_update_bits(cbphy->syscfg, PAD_DIS_CFG, mask, val);
144 struct intel_combo_phy *cbphy = iphy->parent;
151 if (cbphy->aggr_mode != PHY_DL_MODE)
154 return phy_cfg(&cbphy->iphy[PHY_1]);
159 struct intel_combo_phy *cbphy = iphy->parent;
164 dev_err(cbphy->dev, "Failed to enable PCIe pad refclk\n");
168 if (cbphy->init_cnt)
171 combo_phy_w32_off_mask(cbphy->app_base, PCIE_PHY_GEN_CTRL,
182 struct intel_combo_phy *cbphy = iphy->parent;
187 dev_err(cbphy->dev, "Failed to disable PCIe pad refclk\n");
191 if (cbphy->init_cnt)
194 combo_phy_w32_off_mask(cbphy->app_base, PCIE_PHY_GEN_CTRL,
200 static int intel_cbphy_set_mode(struct intel_combo_phy *cbphy)
203 enum aggregated_mode aggr = cbphy->aggr_mode;
204 struct device *dev = cbphy->dev;
208 mode = cbphy->phy_mode;
231 ret = regmap_write(cbphy->hsiocfg, REG_COMBO_MODE(cbphy->bid), cb_mode);
238 static void intel_cbphy_rst_assert(struct intel_combo_phy *cbphy)
240 reset_control_assert(cbphy->core_rst);
241 reset_control_assert(cbphy->phy_rst);
244 static void intel_cbphy_rst_deassert(struct intel_combo_phy *cbphy)
246 reset_control_deassert(cbphy->core_rst);
247 reset_control_deassert(cbphy->phy_rst);
254 struct intel_combo_phy *cbphy = iphy->parent;
257 if (!cbphy->init_cnt) {
258 ret = clk_prepare_enable(cbphy->core_clk);
260 dev_err(cbphy->dev, "Clock enable failed!\n");
264 ret = clk_set_rate(cbphy->core_clk, cbphy->clk_rate);
266 dev_err(cbphy->dev, "Clock freq set to %lu failed!\n",
267 cbphy->clk_rate);
271 intel_cbphy_rst_assert(cbphy);
272 intel_cbphy_rst_deassert(cbphy);
273 ret = intel_cbphy_set_mode(cbphy);
280 dev_err(cbphy->dev, "Failed enabling PHY core\n");
286 dev_err(cbphy->dev, "PHY(%u:%u) reset deassert failed!\n",
297 clk_disable_unprepare(cbphy->core_clk);
304 struct intel_combo_phy *cbphy = iphy->parent;
309 dev_err(cbphy->dev, "PHY(%u:%u) reset assert failed!\n",
316 dev_err(cbphy->dev, "Failed disabling PHY core\n");
320 if (cbphy->init_cnt)
323 clk_disable_unprepare(cbphy->core_clk);
324 intel_cbphy_rst_assert(cbphy);
332 struct intel_combo_phy *cbphy = iphy->parent;
335 mutex_lock(&cbphy->lock);
340 if (cbphy->phy_mode == PHY_PCIE_MODE) {
346 cbphy->init_cnt++;
349 mutex_unlock(&cbphy->lock);
357 struct intel_combo_phy *cbphy = iphy->parent;
360 mutex_lock(&cbphy->lock);
361 cbphy->init_cnt--;
362 if (cbphy->phy_mode == PHY_PCIE_MODE) {
371 mutex_unlock(&cbphy->lock);
379 struct intel_combo_phy *cbphy = iphy->parent;
380 void __iomem *cr_base = cbphy->cr_base;
383 if (cbphy->phy_mode != PHY_XPCS_MODE)
395 dev_err(cbphy->dev, "RX Adaptation failed!\n");
397 dev_dbg(cbphy->dev, "RX Adaptation success!\n");
406 static int intel_cbphy_fwnode_parse(struct intel_combo_phy *cbphy)
408 struct device *dev = cbphy->dev;
415 cbphy->core_clk = devm_clk_get(dev, NULL);
416 if (IS_ERR(cbphy->core_clk)) {
417 ret = PTR_ERR(cbphy->core_clk);
423 cbphy->core_rst = devm_reset_control_get_optional(dev, "core");
424 if (IS_ERR(cbphy->core_rst)) {
425 ret = PTR_ERR(cbphy->core_rst);
431 cbphy->phy_rst = devm_reset_control_get_optional(dev, "phy");
432 if (IS_ERR(cbphy->phy_rst)) {
433 ret = PTR_ERR(cbphy->phy_rst);
439 cbphy->iphy[0].app_rst = devm_reset_control_get_optional(dev, "iphy0");
440 if (IS_ERR(cbphy->iphy[0].app_rst)) {
441 ret = PTR_ERR(cbphy->iphy[0].app_rst);
447 cbphy->iphy[1].app_rst = devm_reset_control_get_optional(dev, "iphy1");
448 if (IS_ERR(cbphy->iphy[1].app_rst)) {
449 ret = PTR_ERR(cbphy->iphy[1].app_rst);
455 cbphy->app_base = devm_platform_ioremap_resource_byname(pdev, "app");
456 if (IS_ERR(cbphy->app_base))
457 return PTR_ERR(cbphy->app_base);
459 cbphy->cr_base = devm_platform_ioremap_resource_byname(pdev, "core");
460 if (IS_ERR(cbphy->cr_base))
461 return PTR_ERR(cbphy->cr_base);
473 cbphy->id = ref.args[0];
474 cbphy->syscfg = device_node_to_regmap(to_of_node(ref.fwnode));
482 cbphy->bid = ref.args[0];
483 cbphy->hsiocfg = device_node_to_regmap(to_of_node(ref.fwnode));
492 cbphy->phy_mode = PHY_PCIE_MODE;
496 cbphy->phy_mode = PHY_SATA_MODE;
500 cbphy->phy_mode = PHY_XPCS_MODE;
508 cbphy->clk_rate = intel_iphy_clk_rates[cbphy->phy_mode];
511 cbphy->aggr_mode = PHY_DL_MODE;
513 cbphy->aggr_mode = PHY_SL_MODE;
528 struct intel_combo_phy *cbphy = dev_get_drvdata(dev);
542 if (cbphy->aggr_mode == PHY_DL_MODE && iphy_id == PHY_1) {
547 return cbphy->iphy[iphy_id].phy;
550 static int intel_cbphy_create(struct intel_combo_phy *cbphy)
553 struct device *dev = cbphy->dev;
558 iphy = &cbphy->iphy[i];
559 iphy->parent = cbphy;
563 if (cbphy->aggr_mode == PHY_DL_MODE && iphy->id == PHY_1)
577 dev_set_drvdata(dev, cbphy);
588 struct intel_combo_phy *cbphy;
591 cbphy = devm_kzalloc(dev, sizeof(*cbphy), GFP_KERNEL);
592 if (!cbphy)
595 cbphy->dev = dev;
596 cbphy->init_cnt = 0;
597 mutex_init(&cbphy->lock);
598 ret = intel_cbphy_fwnode_parse(cbphy);
602 platform_set_drvdata(pdev, cbphy);
604 return intel_cbphy_create(cbphy);
609 struct intel_combo_phy *cbphy = platform_get_drvdata(pdev);
611 intel_cbphy_rst_assert(cbphy);
612 clk_disable_unprepare(cbphy->core_clk);