stm32_pcie
static void stm32_pcie_disable_resources(struct stm32_pcie *stm32_pcie)
clk_disable_unprepare(stm32_pcie->clk);
phy_exit(stm32_pcie->phy);
struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
struct dw_pcie_ep *ep = &stm32_pcie->pci.ep;
regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR,
stm32_pcie_disable_resources(stm32_pcie);
struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
ret = stm32_pcie_enable_resources(stm32_pcie);
regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR,
stm32_pcie_disable_resources(stm32_pcie);
struct stm32_pcie *stm32_pcie = data;
struct dw_pcie *pci = &stm32_pcie->pci;
perst = gpiod_get_value(stm32_pcie->perst_gpio);
irq_set_irq_type(gpiod_to_irq(stm32_pcie->perst_gpio),
static int stm32_add_pcie_ep(struct stm32_pcie *stm32_pcie,
struct dw_pcie_ep *ep = &stm32_pcie->pci.ep;
ret = regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR,
reset_control_assert(stm32_pcie->rst);
reset_control_deassert(stm32_pcie->rst);
ret = stm32_pcie_enable_resources(stm32_pcie);
struct stm32_pcie *stm32_pcie;
stm32_pcie = devm_kzalloc(dev, sizeof(*stm32_pcie), GFP_KERNEL);
if (!stm32_pcie)
stm32_pcie->pci.dev = dev;
stm32_pcie->pci.ops = &dw_pcie_ops;
stm32_pcie->regmap = syscon_regmap_lookup_by_compatible("st,stm32mp25-syscfg");
if (IS_ERR(stm32_pcie->regmap))
return dev_err_probe(dev, PTR_ERR(stm32_pcie->regmap),
stm32_pcie->phy = devm_phy_get(dev, NULL);
if (IS_ERR(stm32_pcie->phy))
return dev_err_probe(dev, PTR_ERR(stm32_pcie->phy),
stm32_pcie->clk = devm_clk_get(dev, NULL);
if (IS_ERR(stm32_pcie->clk))
return dev_err_probe(dev, PTR_ERR(stm32_pcie->clk),
stm32_pcie->rst = devm_reset_control_get_exclusive(dev, NULL);
if (IS_ERR(stm32_pcie->rst))
return dev_err_probe(dev, PTR_ERR(stm32_pcie->rst),
stm32_pcie->perst_gpio = devm_gpiod_get(dev, "reset", GPIOD_IN);
if (IS_ERR(stm32_pcie->perst_gpio))
return dev_err_probe(dev, PTR_ERR(stm32_pcie->perst_gpio),
ret = phy_set_mode(stm32_pcie->phy, PHY_MODE_PCIE);
platform_set_drvdata(pdev, stm32_pcie);
stm32_pcie->perst_irq = gpiod_to_irq(stm32_pcie->perst_gpio);
irq_set_status_flags(stm32_pcie->perst_irq, IRQ_NOAUTOEN);
ret = devm_request_threaded_irq(dev, stm32_pcie->perst_irq, NULL,
"perst_irq", stm32_pcie);
ret = stm32_add_pcie_ep(stm32_pcie, pdev);
struct stm32_pcie *stm32_pcie = platform_get_drvdata(pdev);
struct dw_pcie *pci = &stm32_pcie->pci;
stm32_pcie_disable_resources(stm32_pcie);
struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
enable_irq(stm32_pcie->perst_irq);
struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
disable_irq(stm32_pcie->perst_irq);
static int stm32_pcie_enable_resources(struct stm32_pcie *stm32_pcie)
ret = phy_init(stm32_pcie->phy);
ret = clk_prepare_enable(stm32_pcie->clk);
phy_exit(stm32_pcie->phy);
ret = phy_init(stm32_pcie->phy);
ret = clk_prepare_enable(stm32_pcie->clk);
stm32_pcie_deassert_perst(stm32_pcie);
ret = dw_pcie_resume_noirq(&stm32_pcie->pci);
stm32_pcie_assert_perst(stm32_pcie);
clk_disable_unprepare(stm32_pcie->clk);
phy_exit(stm32_pcie->phy);
static int stm32_add_pcie_port(struct stm32_pcie *stm32_pcie)
struct device *dev = stm32_pcie->pci.dev;
ret = phy_set_mode(stm32_pcie->phy, PHY_MODE_PCIE);
ret = phy_init(stm32_pcie->phy);
ret = regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR,
stm32_pcie_deassert_perst(stm32_pcie);
if (stm32_pcie->wake_gpio) {
wake_irq = gpiod_to_irq(stm32_pcie->wake_gpio);
stm32_pcie_assert_perst(stm32_pcie);
phy_exit(stm32_pcie->phy);
static void stm32_remove_pcie_port(struct stm32_pcie *stm32_pcie)
dev_pm_clear_wake_irq(stm32_pcie->pci.dev);
stm32_pcie_assert_perst(stm32_pcie);
phy_exit(stm32_pcie->phy);
static int stm32_pcie_parse_port(struct stm32_pcie *stm32_pcie)
struct device *dev = stm32_pcie->pci.dev;
stm32_pcie->phy = devm_of_phy_get(dev, root_port, NULL);
if (IS_ERR(stm32_pcie->phy)) {
return dev_err_probe(dev, PTR_ERR(stm32_pcie->phy),
stm32_pcie->perst_gpio = devm_fwnode_gpiod_get(dev, of_fwnode_handle(root_port),
if (IS_ERR(stm32_pcie->perst_gpio)) {
if (PTR_ERR(stm32_pcie->perst_gpio) != -ENOENT) {
return dev_err_probe(dev, PTR_ERR(stm32_pcie->perst_gpio),
stm32_pcie->perst_gpio = NULL;
stm32_pcie->wake_gpio = devm_fwnode_gpiod_get(dev, of_fwnode_handle(root_port),
if (IS_ERR(stm32_pcie->wake_gpio)) {
if (PTR_ERR(stm32_pcie->wake_gpio) != -ENOENT) {
return dev_err_probe(dev, PTR_ERR(stm32_pcie->wake_gpio),
stm32_pcie->wake_gpio = NULL;
struct stm32_pcie *stm32_pcie;
stm32_pcie = devm_kzalloc(dev, sizeof(*stm32_pcie), GFP_KERNEL);
if (!stm32_pcie)
stm32_pcie->pci.dev = dev;
stm32_pcie->pci.ops = &dw_pcie_ops;
stm32_pcie->pci.pp.ops = &stm32_pcie_host_ops;
stm32_pcie->regmap = syscon_regmap_lookup_by_compatible("st,stm32mp25-syscfg");
if (IS_ERR(stm32_pcie->regmap))
return dev_err_probe(dev, PTR_ERR(stm32_pcie->regmap),
stm32_pcie->clk = devm_clk_get(dev, NULL);
if (IS_ERR(stm32_pcie->clk))
return dev_err_probe(dev, PTR_ERR(stm32_pcie->clk),
stm32_pcie->rst = devm_reset_control_get_exclusive(dev, NULL);
if (IS_ERR(stm32_pcie->rst))
return dev_err_probe(dev, PTR_ERR(stm32_pcie->rst),
ret = stm32_pcie_parse_port(stm32_pcie);
platform_set_drvdata(pdev, stm32_pcie);
ret = stm32_add_pcie_port(stm32_pcie);
reset_control_assert(stm32_pcie->rst);
reset_control_deassert(stm32_pcie->rst);
ret = clk_prepare_enable(stm32_pcie->clk);
ret = dw_pcie_host_init(&stm32_pcie->pci.pp);
if (stm32_pcie->wake_gpio)
clk_disable_unprepare(stm32_pcie->clk);
stm32_remove_pcie_port(stm32_pcie);
struct stm32_pcie *stm32_pcie = platform_get_drvdata(pdev);
struct dw_pcie_rp *pp = &stm32_pcie->pci.pp;
if (stm32_pcie->wake_gpio)
clk_disable_unprepare(stm32_pcie->clk);
stm32_remove_pcie_port(stm32_pcie);
static void stm32_pcie_deassert_perst(struct stm32_pcie *stm32_pcie)
if (stm32_pcie->perst_gpio) {
gpiod_set_value(stm32_pcie->perst_gpio, 0);
static void stm32_pcie_assert_perst(struct stm32_pcie *stm32_pcie)
gpiod_set_value(stm32_pcie->perst_gpio, 1);
struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
return regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR,
struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR,
struct stm32_pcie *stm32_pcie = dev_get_drvdata(dev);
ret = dw_pcie_suspend_noirq(&stm32_pcie->pci);
stm32_pcie_assert_perst(stm32_pcie);
clk_disable_unprepare(stm32_pcie->clk);
phy_exit(stm32_pcie->phy);
struct stm32_pcie *stm32_pcie = dev_get_drvdata(dev);