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