Lines Matching refs:afp

82 static void fu740_pcie_assert_reset(struct fu740_pcie *afp)  in fu740_pcie_assert_reset()  argument
85 gpiod_set_value_cansleep(afp->reset, 0); in fu740_pcie_assert_reset()
87 writel_relaxed(0x0, afp->mgmt_base + PCIEX8MGMT_PERST_N); in fu740_pcie_assert_reset()
90 static void fu740_pcie_deassert_reset(struct fu740_pcie *afp) in fu740_pcie_deassert_reset() argument
93 writel_relaxed(0x1, afp->mgmt_base + PCIEX8MGMT_PERST_N); in fu740_pcie_deassert_reset()
95 gpiod_set_value_cansleep(afp->reset, 1); in fu740_pcie_deassert_reset()
98 static void fu740_pcie_power_on(struct fu740_pcie *afp) in fu740_pcie_power_on() argument
100 gpiod_set_value_cansleep(afp->pwren, 1); in fu740_pcie_power_on()
109 static void fu740_pcie_drive_reset(struct fu740_pcie *afp) in fu740_pcie_drive_reset() argument
111 fu740_pcie_assert_reset(afp); in fu740_pcie_drive_reset()
112 fu740_pcie_power_on(afp); in fu740_pcie_drive_reset()
113 fu740_pcie_deassert_reset(afp); in fu740_pcie_drive_reset()
117 const uint16_t wrdata, struct fu740_pcie *afp) in fu740_phyregwrite() argument
119 struct device *dev = afp->pci.dev; in fu740_phyregwrite()
128 phy_cr_para_addr = afp->mgmt_base + PCIEX8MGMT_PHY1_CR_PARA_ADDR; in fu740_phyregwrite()
129 phy_cr_para_wr_data = afp->mgmt_base + PCIEX8MGMT_PHY1_CR_PARA_WR_DATA; in fu740_phyregwrite()
130 phy_cr_para_wr_en = afp->mgmt_base + PCIEX8MGMT_PHY1_CR_PARA_WR_EN; in fu740_phyregwrite()
131 phy_cr_para_ack = afp->mgmt_base + PCIEX8MGMT_PHY1_CR_PARA_ACK; in fu740_phyregwrite()
133 phy_cr_para_addr = afp->mgmt_base + PCIEX8MGMT_PHY0_CR_PARA_ADDR; in fu740_phyregwrite()
134 phy_cr_para_wr_data = afp->mgmt_base + PCIEX8MGMT_PHY0_CR_PARA_WR_DATA; in fu740_phyregwrite()
135 phy_cr_para_wr_en = afp->mgmt_base + PCIEX8MGMT_PHY0_CR_PARA_WR_EN; in fu740_phyregwrite()
136 phy_cr_para_ack = afp->mgmt_base + PCIEX8MGMT_PHY0_CR_PARA_ACK; in fu740_phyregwrite()
157 static void fu740_pcie_init_phy(struct fu740_pcie *afp) in fu740_pcie_init_phy() argument
160 writel_relaxed(0x1, afp->mgmt_base + PCIEX8MGMT_PHY0_CR_PARA_SEL); in fu740_pcie_init_phy()
161 writel_relaxed(0x1, afp->mgmt_base + PCIEX8MGMT_PHY1_CR_PARA_SEL); in fu740_pcie_init_phy()
170 fu740_phyregwrite(0, PCIEX8MGMT_PHY_LANE0_BASE, PCIEX8MGMT_PHY_INIT_VAL, afp); in fu740_pcie_init_phy()
171 fu740_phyregwrite(0, PCIEX8MGMT_PHY_LANE1_BASE, PCIEX8MGMT_PHY_INIT_VAL, afp); in fu740_pcie_init_phy()
172 fu740_phyregwrite(0, PCIEX8MGMT_PHY_LANE2_BASE, PCIEX8MGMT_PHY_INIT_VAL, afp); in fu740_pcie_init_phy()
173 fu740_phyregwrite(0, PCIEX8MGMT_PHY_LANE3_BASE, PCIEX8MGMT_PHY_INIT_VAL, afp); in fu740_pcie_init_phy()
174 fu740_phyregwrite(1, PCIEX8MGMT_PHY_LANE0_BASE, PCIEX8MGMT_PHY_INIT_VAL, afp); in fu740_pcie_init_phy()
175 fu740_phyregwrite(1, PCIEX8MGMT_PHY_LANE1_BASE, PCIEX8MGMT_PHY_INIT_VAL, afp); in fu740_pcie_init_phy()
176 fu740_phyregwrite(1, PCIEX8MGMT_PHY_LANE2_BASE, PCIEX8MGMT_PHY_INIT_VAL, afp); in fu740_pcie_init_phy()
177 fu740_phyregwrite(1, PCIEX8MGMT_PHY_LANE3_BASE, PCIEX8MGMT_PHY_INIT_VAL, afp); in fu740_pcie_init_phy()
183 struct fu740_pcie *afp = dev_get_drvdata(dev); in fu740_pcie_start_link() local
205 writel_relaxed(0x1, afp->mgmt_base + PCIEX8MGMT_APP_LTSSM_ENABLE); in fu740_pcie_start_link()
242 struct fu740_pcie *afp = to_fu740_pcie(pci); in fu740_pcie_host_init() local
247 fu740_pcie_drive_reset(afp); in fu740_pcie_host_init()
250 ret = clk_prepare_enable(afp->pcie_aux); in fu740_pcie_host_init()
260 writel_relaxed(0x1, afp->mgmt_base + PCIEX8MGMT_APP_HOLD_PHY_RST); in fu740_pcie_host_init()
263 ret = reset_control_deassert(afp->rst); in fu740_pcie_host_init()
269 fu740_pcie_init_phy(afp); in fu740_pcie_host_init()
272 clk_disable_unprepare(afp->pcie_aux); in fu740_pcie_host_init()
274 writel_relaxed(0x0, afp->mgmt_base + PCIEX8MGMT_APP_HOLD_PHY_RST); in fu740_pcie_host_init()
276 clk_prepare_enable(afp->pcie_aux); in fu740_pcie_host_init()
278 writel_relaxed(0x4, afp->mgmt_base + PCIEX8MGMT_DEVICE_TYPE); in fu740_pcie_host_init()
295 struct fu740_pcie *afp; in fu740_pcie_probe() local
297 afp = devm_kzalloc(dev, sizeof(*afp), GFP_KERNEL); in fu740_pcie_probe()
298 if (!afp) in fu740_pcie_probe()
300 pci = &afp->pci; in fu740_pcie_probe()
306 afp->mgmt_base = devm_platform_ioremap_resource_byname(pdev, "mgmt"); in fu740_pcie_probe()
307 if (IS_ERR(afp->mgmt_base)) in fu740_pcie_probe()
308 return PTR_ERR(afp->mgmt_base); in fu740_pcie_probe()
311 afp->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in fu740_pcie_probe()
312 if (IS_ERR(afp->reset)) in fu740_pcie_probe()
313 return dev_err_probe(dev, PTR_ERR(afp->reset), "unable to get reset-gpios\n"); in fu740_pcie_probe()
315 afp->pwren = devm_gpiod_get_optional(dev, "pwren", GPIOD_OUT_LOW); in fu740_pcie_probe()
316 if (IS_ERR(afp->pwren)) in fu740_pcie_probe()
317 return dev_err_probe(dev, PTR_ERR(afp->pwren), "unable to get pwren-gpios\n"); in fu740_pcie_probe()
320 afp->pcie_aux = devm_clk_get(dev, "pcie_aux"); in fu740_pcie_probe()
321 if (IS_ERR(afp->pcie_aux)) in fu740_pcie_probe()
322 return dev_err_probe(dev, PTR_ERR(afp->pcie_aux), in fu740_pcie_probe()
326 afp->rst = devm_reset_control_get_exclusive(dev, NULL); in fu740_pcie_probe()
327 if (IS_ERR(afp->rst)) in fu740_pcie_probe()
328 return dev_err_probe(dev, PTR_ERR(afp->rst), "unable to get reset\n"); in fu740_pcie_probe()
330 platform_set_drvdata(pdev, afp); in fu740_pcie_probe()
337 struct fu740_pcie *afp = platform_get_drvdata(pdev); in fu740_pcie_shutdown() local
340 fu740_pcie_assert_reset(afp); in fu740_pcie_shutdown()