Lines Matching +full:apb +full:- +full:base

1 // SPDX-License-Identifier: GPL-2.0
154 void __iomem *base; member
155 struct regmap *apb; member
171 writel(val, phy->base + APB_PHY_START_ADDR + reg); in hi3670_apb_phy_writel()
176 return readl(phy->base + APB_PHY_START_ADDR + reg); in hi3670_apb_phy_readl()
193 writel(val, phy->base + reg); in kirin_apb_natural_phy_writel()
199 return readl(phy->base + reg); in kirin_apb_natural_phy_readl()
206 regmap_read(phy->sysctrl, SCTRL_PCIE_OE_OFFSET, &val); in hi3670_pcie_phy_oe_enable()
212 regmap_write(phy->sysctrl, SCTRL_PCIE_OE_OFFSET, val); in hi3670_pcie_phy_oe_enable()
217 struct device *dev = phy->dev; in hi3670_pcie_get_eyeparam()
221 np = dev->of_node; in hi3670_pcie_get_eyeparam()
223 ret = of_property_read_u32_array(np, "hisilicon,eye-diagram-param", in hi3670_pcie_get_eyeparam()
224 phy->eye_param, NUM_EYEPARAM); in hi3670_pcie_get_eyeparam()
230 phy->eye_param[i] = EYEPARAM_NOCFG; in hi3670_pcie_get_eyeparam()
239 if (phy->eye_param[1] != EYEPARAM_NOCFG) { in hi3670_pcie_set_eyeparam()
241 val |= FIELD_PREP(EYE_PARM1_MASK, phy->eye_param[1]); in hi3670_pcie_set_eyeparam()
249 if (phy->eye_param[2] != EYEPARAM_NOCFG) { in hi3670_pcie_set_eyeparam()
250 val |= FIELD_PREP(EYE_PARM2_MASK, phy->eye_param[2]); in hi3670_pcie_set_eyeparam()
254 if (phy->eye_param[3] != EYEPARAM_NOCFG) { in hi3670_pcie_set_eyeparam()
255 val |= FIELD_PREP(EYE_PARM3_MASK, phy->eye_param[3]); in hi3670_pcie_set_eyeparam()
262 if (phy->eye_param[0] != EYEPARAM_NOCFG) { in hi3670_pcie_set_eyeparam()
264 val |= FIELD_PREP(EYE_PARM0_MASK, phy->eye_param[0]); in hi3670_pcie_set_eyeparam()
270 if (phy->eye_param[4] != EYEPARAM_NOCFG) { in hi3670_pcie_set_eyeparam()
272 val |= FIELD_PREP(EYE_PARM4_MASK, phy->eye_param[4]); in hi3670_pcie_set_eyeparam()
283 regmap_write(phy->apb, SOC_PCIECTRL_CTRL20_ADDR, in hi3670_pcie_natural_cfg()
286 regmap_read(phy->apb, SOC_PCIECTRL_CTRL7_ADDR, &val); in hi3670_pcie_natural_cfg()
288 regmap_write(phy->apb, SOC_PCIECTRL_CTRL7_ADDR, val); in hi3670_pcie_natural_cfg()
291 regmap_read(phy->apb, SOC_PCIECTRL_CTRL12_ADDR, &val); in hi3670_pcie_natural_cfg()
294 regmap_write(phy->apb, SOC_PCIECTRL_CTRL12_ADDR, val); in hi3670_pcie_natural_cfg()
336 struct device *dev = phy->dev; in hi3670_pcie_pll_ctrl()
350 return -EINVAL; in hi3670_pcie_pll_ctrl()
352 time--; in hi3670_pcie_pll_ctrl()
378 regmap_write(phy->crgctrl, CRGPERIPH_PEREN12, in hi3670_pcie_hp_debounce_gt()
382 regmap_write(phy->crgctrl, CRGPERIPH_PERDIS12, in hi3670_pcie_hp_debounce_gt()
390 regmap_read(phy->crgctrl, CRGPERIPH_PCIECTRL0, &val); in hi3670_pcie_phyref_gt()
397 regmap_write(phy->crgctrl, CRGPERIPH_PCIECTRL0, val); in hi3670_pcie_phyref_gt()
400 regmap_write(phy->crgctrl, CRGPERIPH_PERDIS12, IO_PHYREF_SOFT_GT_MODE); in hi3670_pcie_phyref_gt()
407 regmap_read(phy->crgctrl, CRGPERIPH_PCIECTRL0, &val); in hi3670_pcie_oe_ctrl()
426 regmap_write(phy->crgctrl, CRGPERIPH_PCIECTRL0, val); in hi3670_pcie_oe_ctrl()
434 regmap_write(phy->apb, SOC_PCIECTRL_CTRL21_ADDR, in hi3670_pcie_ioref_gt()
440 regmap_read(phy->crgctrl, CRGPERIPH_PCIECTRL0, &val); in hi3670_pcie_ioref_gt()
442 regmap_write(phy->crgctrl, CRGPERIPH_PCIECTRL0, val); in hi3670_pcie_ioref_gt()
445 regmap_write(phy->crgctrl, CRGPERIPH_PERDIS12, in hi3670_pcie_ioref_gt()
450 regmap_read(phy->crgctrl, CRGPERIPH_PCIECTRL0, &val); in hi3670_pcie_ioref_gt()
452 regmap_write(phy->crgctrl, CRGPERIPH_PCIECTRL0, val); in hi3670_pcie_ioref_gt()
455 regmap_write(phy->crgctrl, CRGPERIPH_PERDIS12, in hi3670_pcie_ioref_gt()
464 struct device *dev = phy->dev; in hi3670_pcie_allclk_ctrl()
479 return -EINVAL; in hi3670_pcie_allclk_ctrl()
485 ret = clk_set_rate(phy->aclk, AXI_CLK_FREQ); in hi3670_pcie_allclk_ctrl()
505 struct device *dev = phy->dev; in is_pipe_clk_stable()
517 time--; in is_pipe_clk_stable()
526 struct device *dev = phy->dev; in hi3670_pcie_noc_power()
537 regmap_write(phy->pmctrl, NOC_POWER_IDLEREQ_1, val); in hi3670_pcie_noc_power()
540 regmap_read(phy->pmctrl, NOC_POWER_IDLE_1, &val); in hi3670_pcie_noc_power()
544 dev_err(dev, "Failed to reverse noc power-status\n"); in hi3670_pcie_noc_power()
545 return -EINVAL; in hi3670_pcie_noc_power()
547 time--; in hi3670_pcie_noc_power()
548 regmap_read(phy->pmctrl, NOC_POWER_IDLE_1, &val); in hi3670_pcie_noc_power()
557 struct device *dev = phy->dev; in hi3670_pcie_get_resources_from_pcie()
560 pcie_port = of_get_child_by_name(dev->parent->of_node, "pcie"); in hi3670_pcie_get_resources_from_pcie()
563 dev->parent->of_node->full_name); in hi3670_pcie_get_resources_from_pcie()
564 return -ENODEV; in hi3670_pcie_get_resources_from_pcie()
570 return -ENODEV; in hi3670_pcie_get_resources_from_pcie()
574 * We might just use NULL instead of the APB name, as the in hi3670_pcie_get_resources_from_pcie()
575 * pcie-kirin currently registers directly just one regmap (although in hi3670_pcie_get_resources_from_pcie()
581 phy->apb = dev_get_regmap(pcie_dev, "kirin_pcie_apb"); in hi3670_pcie_get_resources_from_pcie()
582 if (!phy->apb) { in hi3670_pcie_get_resources_from_pcie()
583 dev_err(dev, "Failed to get APB regmap\n"); in hi3670_pcie_get_resources_from_pcie()
584 return -ENODEV; in hi3670_pcie_get_resources_from_pcie()
597 ret = clk_set_rate(phy->phy_ref_clk, REF_CLK_FREQ); in kirin_pcie_clk_ctrl()
601 ret = clk_prepare_enable(phy->phy_ref_clk); in kirin_pcie_clk_ctrl()
605 ret = clk_prepare_enable(phy->apb_sys_clk); in kirin_pcie_clk_ctrl()
609 ret = clk_prepare_enable(phy->apb_phy_clk); in kirin_pcie_clk_ctrl()
613 ret = clk_prepare_enable(phy->aclk); in kirin_pcie_clk_ctrl()
617 ret = clk_prepare_enable(phy->aux_clk); in kirin_pcie_clk_ctrl()
624 clk_disable_unprepare(phy->aux_clk); in kirin_pcie_clk_ctrl()
626 clk_disable_unprepare(phy->aclk); in kirin_pcie_clk_ctrl()
628 clk_disable_unprepare(phy->apb_phy_clk); in kirin_pcie_clk_ctrl()
630 clk_disable_unprepare(phy->apb_sys_clk); in kirin_pcie_clk_ctrl()
632 clk_disable_unprepare(phy->phy_ref_clk); in kirin_pcie_clk_ctrl()
644 * access the reset-gpios and the APB registers, both from the in hi3670_pcie_phy_init()
645 * pcie-kirin driver. in hi3670_pcie_phy_init()
647 * The APB is obtained via the pcie driver's regmap in hi3670_pcie_phy_init()
649 * power_on sequence, as the code inside pcie-kirin needs to in hi3670_pcie_phy_init()
650 * be already probed, as it needs to register the APB regmap. in hi3670_pcie_phy_init()
666 regmap_write(phy->sysctrl, SCTRL_PCIE_CMOS_OFFSET, SCTRL_PCIE_CMOS_BIT); in hi3670_pcie_phy_power_on()
676 regmap_write(phy->sysctrl, SCTRL_PCIE_ISO_OFFSET, SCTRL_PCIE_ISO_BIT); in hi3670_pcie_phy_power_on()
677 regmap_write(phy->crgctrl, CRGCTRL_PCIE_ASSERT_OFFSET, in hi3670_pcie_phy_power_on()
679 regmap_write(phy->sysctrl, SCTRL_PCIE_HPCLK_OFFSET, in hi3670_pcie_phy_power_on()
693 regmap_read(phy->apb, SOC_PCIECTRL_CTRL12_ADDR, &val); in hi3670_pcie_phy_power_on()
695 regmap_write(phy->apb, SOC_PCIECTRL_CTRL12_ADDR, val); in hi3670_pcie_phy_power_on()
724 regmap_write(phy->sysctrl, SCTRL_PCIE_CMOS_OFFSET, 0); in hi3670_pcie_phy_power_off()
730 * CLK_IS_CRITICAL at clk-hi3670 driver, as powering such clocks off in hi3670_pcie_phy_power_off()
732 * While clk-hi3670 is not fixed, we cannot risk disabling clocks here. in hi3670_pcie_phy_power_off()
748 struct device *dev = &pdev->dev; in hi3670_pcie_phy_get_resources()
751 phy->crgctrl = syscon_regmap_lookup_by_compatible("hisilicon,hi3670-crgctrl"); in hi3670_pcie_phy_get_resources()
752 if (IS_ERR(phy->crgctrl)) in hi3670_pcie_phy_get_resources()
753 return PTR_ERR(phy->crgctrl); in hi3670_pcie_phy_get_resources()
755 phy->sysctrl = syscon_regmap_lookup_by_compatible("hisilicon,hi3670-sctrl"); in hi3670_pcie_phy_get_resources()
756 if (IS_ERR(phy->sysctrl)) in hi3670_pcie_phy_get_resources()
757 return PTR_ERR(phy->sysctrl); in hi3670_pcie_phy_get_resources()
759 phy->pmctrl = syscon_regmap_lookup_by_compatible("hisilicon,hi3670-pmctrl"); in hi3670_pcie_phy_get_resources()
760 if (IS_ERR(phy->pmctrl)) in hi3670_pcie_phy_get_resources()
761 return PTR_ERR(phy->pmctrl); in hi3670_pcie_phy_get_resources()
764 phy->phy_ref_clk = devm_clk_get(dev, "phy_ref"); in hi3670_pcie_phy_get_resources()
765 if (IS_ERR(phy->phy_ref_clk)) in hi3670_pcie_phy_get_resources()
766 return PTR_ERR(phy->phy_ref_clk); in hi3670_pcie_phy_get_resources()
768 phy->aux_clk = devm_clk_get(dev, "aux"); in hi3670_pcie_phy_get_resources()
769 if (IS_ERR(phy->aux_clk)) in hi3670_pcie_phy_get_resources()
770 return PTR_ERR(phy->aux_clk); in hi3670_pcie_phy_get_resources()
772 phy->apb_phy_clk = devm_clk_get(dev, "apb_phy"); in hi3670_pcie_phy_get_resources()
773 if (IS_ERR(phy->apb_phy_clk)) in hi3670_pcie_phy_get_resources()
774 return PTR_ERR(phy->apb_phy_clk); in hi3670_pcie_phy_get_resources()
776 phy->apb_sys_clk = devm_clk_get(dev, "apb_sys"); in hi3670_pcie_phy_get_resources()
777 if (IS_ERR(phy->apb_sys_clk)) in hi3670_pcie_phy_get_resources()
778 return PTR_ERR(phy->apb_sys_clk); in hi3670_pcie_phy_get_resources()
780 phy->aclk = devm_clk_get(dev, "aclk"); in hi3670_pcie_phy_get_resources()
781 if (IS_ERR(phy->aclk)) in hi3670_pcie_phy_get_resources()
782 return PTR_ERR(phy->aclk); in hi3670_pcie_phy_get_resources()
785 phy->base = devm_platform_ioremap_resource(pdev, 0); in hi3670_pcie_phy_get_resources()
786 if (IS_ERR(phy->base)) in hi3670_pcie_phy_get_resources()
787 return PTR_ERR(phy->base); in hi3670_pcie_phy_get_resources()
797 struct device *dev = &pdev->dev; in hi3670_pcie_phy_probe()
804 return -ENOMEM; in hi3670_pcie_phy_probe()
806 phy->dev = dev; in hi3670_pcie_phy_probe()
812 generic_phy = devm_phy_create(dev, dev->of_node, &hi3670_phy_ops); in hi3670_pcie_phy_probe()
826 .compatible = "hisilicon,hi970-pcie-phy",