2 * pcie-dra7xx - PCIe controller driver for TI DRA7xx SoCs
4 * Copyright (C) 2013-2014 Texas Instruments Incorporated - http://www.ti.com
6 * Authors: Kishon Vijay Abraham I <kishon@ti.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/delay.h>
14 #include <linux/device.h>
15 #include <linux/err.h>
16 #include <linux/interrupt.h>
17 #include <linux/irq.h>
18 #include <linux/irqdomain.h>
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/of_device.h>
22 #include <linux/of_gpio.h>
23 #include <linux/of_pci.h>
24 #include <linux/pci.h>
25 #include <linux/phy/phy.h>
26 #include <linux/platform_device.h>
27 #include <linux/pm_runtime.h>
28 #include <linux/resource.h>
29 #include <linux/types.h>
30 #include <linux/mfd/syscon.h>
31 #include <linux/regmap.h>
33 #include "pcie-designware.h"
35 /* PCIe controller wrapper DRA7XX configuration registers */
37 #define PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN 0x0024
38 #define PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MAIN 0x0028
39 #define ERR_SYS BIT(0)
40 #define ERR_FATAL BIT(1)
41 #define ERR_NONFATAL BIT(2)
42 #define ERR_COR BIT(3)
43 #define ERR_AXI BIT(4)
44 #define ERR_ECRC BIT(5)
45 #define PME_TURN_OFF BIT(8)
46 #define PME_TO_ACK BIT(9)
47 #define PM_PME BIT(10)
48 #define LINK_REQ_RST BIT(11)
49 #define LINK_UP_EVT BIT(12)
50 #define CFG_BME_EVT BIT(13)
51 #define CFG_MSE_EVT BIT(14)
52 #define INTERRUPTS (ERR_SYS | ERR_FATAL | ERR_NONFATAL | ERR_COR | ERR_AXI | \
53 ERR_ECRC | PME_TURN_OFF | PME_TO_ACK | PM_PME | \
54 LINK_REQ_RST | LINK_UP_EVT | CFG_BME_EVT | CFG_MSE_EVT)
56 #define PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI 0x0034
57 #define PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI 0x0038
63 #define LEG_EP_INTERRUPTS (INTA | INTB | INTC | INTD)
65 #define PCIECTRL_TI_CONF_DEVICE_TYPE 0x0100
66 #define DEVICE_TYPE_EP 0x0
67 #define DEVICE_TYPE_LEG_EP 0x1
68 #define DEVICE_TYPE_RC 0x4
70 #define PCIECTRL_DRA7XX_CONF_DEVICE_CMD 0x0104
73 #define PCIECTRL_DRA7XX_CONF_PHY_CS 0x010C
74 #define LINK_UP BIT(16)
75 #define DRA7XX_CPU_TO_BUS_ADDR 0x0FFFFFFF
77 #define EXP_CAP_ID_OFFSET 0x70
79 #define PCIECTRL_TI_CONF_INTX_ASSERT 0x0124
80 #define PCIECTRL_TI_CONF_INTX_DEASSERT 0x0128
82 #define PCIECTRL_TI_CONF_MSI_XMT 0x012c
83 #define MSI_REQ_GRANT BIT(0)
84 #define MSI_VECTOR_SHIFT 7
88 void __iomem *base; /* DT ti_conf */
89 int phy_count; /* DT phy-names count */
92 struct irq_domain *irq_domain;
93 enum dw_pcie_device_mode mode;
96 struct dra7xx_pcie_of_data {
97 enum dw_pcie_device_mode mode;
100 #define to_dra7xx_pcie(x) dev_get_drvdata((x)->dev)
102 static inline u32 dra7xx_pcie_readl(struct dra7xx_pcie *pcie, u32 offset)
104 return readl(pcie->base + offset);
107 static inline void dra7xx_pcie_writel(struct dra7xx_pcie *pcie, u32 offset,
110 writel(value, pcie->base + offset);
113 static u64 dra7xx_pcie_cpu_addr_fixup(u64 pci_addr)
115 return pci_addr & DRA7XX_CPU_TO_BUS_ADDR;
118 static int dra7xx_pcie_link_up(struct dw_pcie *pci)
120 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci);
121 u32 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_PHY_CS);
123 return !!(reg & LINK_UP);
126 static void dra7xx_pcie_stop_link(struct dw_pcie *pci)
128 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci);
131 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD);
133 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
136 static int dra7xx_pcie_establish_link(struct dw_pcie *pci)
138 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci);
139 struct device *dev = pci->dev;
141 u32 exp_cap_off = EXP_CAP_ID_OFFSET;
143 if (dw_pcie_link_up(pci)) {
144 dev_err(dev, "link is already up\n");
148 if (dra7xx->link_gen == 1) {
149 dw_pcie_read(pci->dbi_base + exp_cap_off + PCI_EXP_LNKCAP,
151 if ((reg & PCI_EXP_LNKCAP_SLS) != PCI_EXP_LNKCAP_SLS_2_5GB) {
152 reg &= ~((u32)PCI_EXP_LNKCAP_SLS);
153 reg |= PCI_EXP_LNKCAP_SLS_2_5GB;
154 dw_pcie_write(pci->dbi_base + exp_cap_off +
155 PCI_EXP_LNKCAP, 4, reg);
158 dw_pcie_read(pci->dbi_base + exp_cap_off + PCI_EXP_LNKCTL2,
160 if ((reg & PCI_EXP_LNKCAP_SLS) != PCI_EXP_LNKCAP_SLS_2_5GB) {
161 reg &= ~((u32)PCI_EXP_LNKCAP_SLS);
162 reg |= PCI_EXP_LNKCAP_SLS_2_5GB;
163 dw_pcie_write(pci->dbi_base + exp_cap_off +
164 PCI_EXP_LNKCTL2, 2, reg);
168 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD);
170 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
175 static void dra7xx_pcie_enable_msi_interrupts(struct dra7xx_pcie *dra7xx)
177 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI,
178 LEG_EP_INTERRUPTS | MSI);
180 dra7xx_pcie_writel(dra7xx,
181 PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI,
182 MSI | LEG_EP_INTERRUPTS);
185 static void dra7xx_pcie_enable_wrapper_interrupts(struct dra7xx_pcie *dra7xx)
187 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN,
189 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MAIN,
193 static void dra7xx_pcie_enable_interrupts(struct dra7xx_pcie *dra7xx)
195 dra7xx_pcie_enable_wrapper_interrupts(dra7xx);
196 dra7xx_pcie_enable_msi_interrupts(dra7xx);
199 static int dra7xx_pcie_host_init(struct pcie_port *pp)
201 struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
202 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci);
204 dw_pcie_setup_rc(pp);
206 dra7xx_pcie_establish_link(pci);
207 dw_pcie_wait_for_link(pci);
208 dw_pcie_msi_init(pp);
209 dra7xx_pcie_enable_interrupts(dra7xx);
214 static const struct dw_pcie_host_ops dra7xx_pcie_host_ops = {
215 .host_init = dra7xx_pcie_host_init,
218 static int dra7xx_pcie_intx_map(struct irq_domain *domain, unsigned int irq,
219 irq_hw_number_t hwirq)
221 irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq);
222 irq_set_chip_data(irq, domain->host_data);
227 static const struct irq_domain_ops intx_domain_ops = {
228 .map = dra7xx_pcie_intx_map,
231 static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp)
233 struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
234 struct device *dev = pci->dev;
235 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci);
236 struct device_node *node = dev->of_node;
237 struct device_node *pcie_intc_node = of_get_next_child(node, NULL);
239 if (!pcie_intc_node) {
240 dev_err(dev, "No PCIe Intc node found\n");
244 dra7xx->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
245 &intx_domain_ops, pp);
246 if (!dra7xx->irq_domain) {
247 dev_err(dev, "Failed to get a INTx IRQ domain\n");
254 static irqreturn_t dra7xx_pcie_msi_irq_handler(int irq, void *arg)
256 struct dra7xx_pcie *dra7xx = arg;
257 struct dw_pcie *pci = dra7xx->pci;
258 struct pcie_port *pp = &pci->pp;
261 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI);
265 dw_handle_msi_irq(pp);
271 generic_handle_irq(irq_find_mapping(dra7xx->irq_domain,
276 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI, reg);
281 static irqreturn_t dra7xx_pcie_irq_handler(int irq, void *arg)
283 struct dra7xx_pcie *dra7xx = arg;
284 struct dw_pcie *pci = dra7xx->pci;
285 struct device *dev = pci->dev;
286 struct dw_pcie_ep *ep = &pci->ep;
289 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN);
292 dev_dbg(dev, "System Error\n");
295 dev_dbg(dev, "Fatal Error\n");
297 if (reg & ERR_NONFATAL)
298 dev_dbg(dev, "Non Fatal Error\n");
301 dev_dbg(dev, "Correctable Error\n");
304 dev_dbg(dev, "AXI tag lookup fatal Error\n");
307 dev_dbg(dev, "ECRC Error\n");
309 if (reg & PME_TURN_OFF)
311 "Power Management Event Turn-Off message received\n");
313 if (reg & PME_TO_ACK)
315 "Power Management Turn-Off Ack message received\n");
318 dev_dbg(dev, "PM Power Management Event message received\n");
320 if (reg & LINK_REQ_RST)
321 dev_dbg(dev, "Link Request Reset\n");
323 if (reg & LINK_UP_EVT) {
324 if (dra7xx->mode == DW_PCIE_EP_TYPE)
325 dw_pcie_ep_linkup(ep);
326 dev_dbg(dev, "Link-up state change\n");
329 if (reg & CFG_BME_EVT)
330 dev_dbg(dev, "CFG 'Bus Master Enable' change\n");
332 if (reg & CFG_MSE_EVT)
333 dev_dbg(dev, "CFG 'Memory Space Enable' change\n");
335 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN, reg);
340 static void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar)
344 reg = PCI_BASE_ADDRESS_0 + (4 * bar);
345 dw_pcie_writel_dbi2(pci, reg, 0x0);
346 dw_pcie_writel_dbi(pci, reg, 0x0);
349 static void dra7xx_pcie_ep_init(struct dw_pcie_ep *ep)
351 struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
352 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci);
355 for (bar = BAR_0; bar <= BAR_5; bar++)
356 dw_pcie_ep_reset_bar(pci, bar);
358 dra7xx_pcie_enable_wrapper_interrupts(dra7xx);
361 static void dra7xx_pcie_raise_legacy_irq(struct dra7xx_pcie *dra7xx)
363 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_INTX_ASSERT, 0x1);
365 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_INTX_DEASSERT, 0x1);
368 static void dra7xx_pcie_raise_msi_irq(struct dra7xx_pcie *dra7xx,
373 reg = (interrupt_num - 1) << MSI_VECTOR_SHIFT;
374 reg |= MSI_REQ_GRANT;
375 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_MSI_XMT, reg);
378 static int dra7xx_pcie_raise_irq(struct dw_pcie_ep *ep,
379 enum pci_epc_irq_type type, u8 interrupt_num)
381 struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
382 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci);
385 case PCI_EPC_IRQ_LEGACY:
386 dra7xx_pcie_raise_legacy_irq(dra7xx);
388 case PCI_EPC_IRQ_MSI:
389 dra7xx_pcie_raise_msi_irq(dra7xx, interrupt_num);
392 dev_err(pci->dev, "UNKNOWN IRQ type\n");
398 static struct dw_pcie_ep_ops pcie_ep_ops = {
399 .ep_init = dra7xx_pcie_ep_init,
400 .raise_irq = dra7xx_pcie_raise_irq,
403 static int __init dra7xx_add_pcie_ep(struct dra7xx_pcie *dra7xx,
404 struct platform_device *pdev)
407 struct dw_pcie_ep *ep;
408 struct resource *res;
409 struct device *dev = &pdev->dev;
410 struct dw_pcie *pci = dra7xx->pci;
413 ep->ops = &pcie_ep_ops;
415 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ep_dbics");
416 pci->dbi_base = devm_ioremap(dev, res->start, resource_size(res));
420 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ep_dbics2");
421 pci->dbi_base2 = devm_ioremap(dev, res->start, resource_size(res));
425 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space");
429 ep->phys_base = res->start;
430 ep->addr_size = resource_size(res);
432 ret = dw_pcie_ep_init(ep);
434 dev_err(dev, "failed to initialize endpoint\n");
441 static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx,
442 struct platform_device *pdev)
445 struct dw_pcie *pci = dra7xx->pci;
446 struct pcie_port *pp = &pci->pp;
447 struct device *dev = pci->dev;
448 struct resource *res;
450 pp->irq = platform_get_irq(pdev, 1);
452 dev_err(dev, "missing IRQ resource\n");
456 ret = devm_request_irq(dev, pp->irq, dra7xx_pcie_msi_irq_handler,
457 IRQF_SHARED | IRQF_NO_THREAD,
458 "dra7-pcie-msi", dra7xx);
460 dev_err(dev, "failed to request irq\n");
464 ret = dra7xx_pcie_init_irq_domain(pp);
468 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rc_dbics");
469 pci->dbi_base = devm_ioremap(dev, res->start, resource_size(res));
473 ret = dw_pcie_host_init(pp);
475 dev_err(dev, "failed to initialize host\n");
482 static const struct dw_pcie_ops dw_pcie_ops = {
483 .cpu_addr_fixup = dra7xx_pcie_cpu_addr_fixup,
484 .start_link = dra7xx_pcie_establish_link,
485 .stop_link = dra7xx_pcie_stop_link,
486 .link_up = dra7xx_pcie_link_up,
489 static void dra7xx_pcie_disable_phy(struct dra7xx_pcie *dra7xx)
491 int phy_count = dra7xx->phy_count;
493 while (phy_count--) {
494 phy_power_off(dra7xx->phy[phy_count]);
495 phy_exit(dra7xx->phy[phy_count]);
499 static int dra7xx_pcie_enable_phy(struct dra7xx_pcie *dra7xx)
501 int phy_count = dra7xx->phy_count;
505 for (i = 0; i < phy_count; i++) {
506 ret = phy_init(dra7xx->phy[i]);
510 ret = phy_power_on(dra7xx->phy[i]);
512 phy_exit(dra7xx->phy[i]);
521 phy_power_off(dra7xx->phy[i]);
522 phy_exit(dra7xx->phy[i]);
528 static const struct dra7xx_pcie_of_data dra7xx_pcie_rc_of_data = {
529 .mode = DW_PCIE_RC_TYPE,
532 static const struct dra7xx_pcie_of_data dra7xx_pcie_ep_of_data = {
533 .mode = DW_PCIE_EP_TYPE,
536 static const struct of_device_id of_dra7xx_pcie_match[] = {
538 .compatible = "ti,dra7-pcie",
539 .data = &dra7xx_pcie_rc_of_data,
542 .compatible = "ti,dra7-pcie-ep",
543 .data = &dra7xx_pcie_ep_of_data,
549 * dra7xx_pcie_ep_unaligned_memaccess: workaround for AM572x/AM571x Errata i870
550 * @dra7xx: the dra7xx device where the workaround should be applied
552 * Access to the PCIe slave port that are not 32-bit aligned will result
553 * in incorrect mapping to TLP Address and Byte enable fields. Therefore,
554 * byte and half-word accesses are not possible to byte offset 0x1, 0x2, or
557 * To avoid this issue set PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE to 1.
559 static int dra7xx_pcie_ep_unaligned_memaccess(struct device *dev)
562 struct device_node *np = dev->of_node;
563 struct of_phandle_args args;
564 struct regmap *regmap;
566 regmap = syscon_regmap_lookup_by_phandle(np,
567 "ti,syscon-unaligned-access");
568 if (IS_ERR(regmap)) {
569 dev_dbg(dev, "can't get ti,syscon-unaligned-access\n");
573 ret = of_parse_phandle_with_fixed_args(np, "ti,syscon-unaligned-access",
576 dev_err(dev, "failed to parse ti,syscon-unaligned-access\n");
580 ret = regmap_update_bits(regmap, args.args[0], args.args[1],
583 dev_err(dev, "failed to enable unaligned access\n");
585 of_node_put(args.np);
590 static int __init dra7xx_pcie_probe(struct platform_device *pdev)
598 struct device_link **link;
600 struct resource *res;
602 struct pcie_port *pp;
603 struct dra7xx_pcie *dra7xx;
604 struct device *dev = &pdev->dev;
605 struct device_node *np = dev->of_node;
607 struct gpio_desc *reset;
608 const struct of_device_id *match;
609 const struct dra7xx_pcie_of_data *data;
610 enum dw_pcie_device_mode mode;
612 match = of_match_device(of_match_ptr(of_dra7xx_pcie_match), dev);
616 data = (struct dra7xx_pcie_of_data *)match->data;
617 mode = (enum dw_pcie_device_mode)data->mode;
619 dra7xx = devm_kzalloc(dev, sizeof(*dra7xx), GFP_KERNEL);
623 pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL);
628 pci->ops = &dw_pcie_ops;
631 pp->ops = &dra7xx_pcie_host_ops;
633 irq = platform_get_irq(pdev, 0);
635 dev_err(dev, "missing IRQ resource: %d\n", irq);
639 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ti_conf");
640 base = devm_ioremap_nocache(dev, res->start, resource_size(res));
644 phy_count = of_property_count_strings(np, "phy-names");
646 dev_err(dev, "unable to find the strings\n");
650 phy = devm_kzalloc(dev, sizeof(*phy) * phy_count, GFP_KERNEL);
654 link = devm_kzalloc(dev, sizeof(*link) * phy_count, GFP_KERNEL);
658 for (i = 0; i < phy_count; i++) {
659 snprintf(name, sizeof(name), "pcie-phy%d", i);
660 phy[i] = devm_phy_get(dev, name);
662 return PTR_ERR(phy[i]);
664 link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS);
674 dra7xx->phy_count = phy_count;
676 ret = dra7xx_pcie_enable_phy(dra7xx);
678 dev_err(dev, "failed to enable phy\n");
682 platform_set_drvdata(pdev, dra7xx);
684 pm_runtime_enable(dev);
685 ret = pm_runtime_get_sync(dev);
687 dev_err(dev, "pm_runtime_get_sync failed\n");
691 reset = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH);
693 ret = PTR_ERR(reset);
694 dev_err(&pdev->dev, "gpio request failed, ret %d\n", ret);
698 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD);
700 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
702 dra7xx->link_gen = of_pci_get_max_link_speed(np);
703 if (dra7xx->link_gen < 0 || dra7xx->link_gen > 2)
704 dra7xx->link_gen = 2;
707 case DW_PCIE_RC_TYPE:
708 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE,
710 ret = dra7xx_add_pcie_port(dra7xx, pdev);
714 case DW_PCIE_EP_TYPE:
715 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE,
718 ret = dra7xx_pcie_ep_unaligned_memaccess(dev);
722 ret = dra7xx_add_pcie_ep(dra7xx, pdev);
727 dev_err(dev, "INVALID device type %d\n", mode);
731 ret = devm_request_irq(dev, irq, dra7xx_pcie_irq_handler,
732 IRQF_SHARED, "dra7xx-pcie-main", dra7xx);
734 dev_err(dev, "failed to request irq\n");
744 pm_runtime_disable(dev);
745 dra7xx_pcie_disable_phy(dra7xx);
749 device_link_del(link[i]);
754 #ifdef CONFIG_PM_SLEEP
755 static int dra7xx_pcie_suspend(struct device *dev)
757 struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
758 struct dw_pcie *pci = dra7xx->pci;
761 if (dra7xx->mode != DW_PCIE_RC_TYPE)
765 val = dw_pcie_readl_dbi(pci, PCI_COMMAND);
766 val &= ~PCI_COMMAND_MEMORY;
767 dw_pcie_writel_dbi(pci, PCI_COMMAND, val);
772 static int dra7xx_pcie_resume(struct device *dev)
774 struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
775 struct dw_pcie *pci = dra7xx->pci;
778 if (dra7xx->mode != DW_PCIE_RC_TYPE)
782 val = dw_pcie_readl_dbi(pci, PCI_COMMAND);
783 val |= PCI_COMMAND_MEMORY;
784 dw_pcie_writel_dbi(pci, PCI_COMMAND, val);
789 static int dra7xx_pcie_suspend_noirq(struct device *dev)
791 struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
793 dra7xx_pcie_disable_phy(dra7xx);
798 static int dra7xx_pcie_resume_noirq(struct device *dev)
800 struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
803 ret = dra7xx_pcie_enable_phy(dra7xx);
805 dev_err(dev, "failed to enable phy\n");
813 void dra7xx_pcie_shutdown(struct platform_device *pdev)
815 struct device *dev = &pdev->dev;
816 struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
819 dra7xx_pcie_stop_link(dra7xx->pci);
821 ret = pm_runtime_put_sync(dev);
823 dev_dbg(dev, "pm_runtime_put_sync failed\n");
825 pm_runtime_disable(dev);
826 dra7xx_pcie_disable_phy(dra7xx);
829 static const struct dev_pm_ops dra7xx_pcie_pm_ops = {
830 SET_SYSTEM_SLEEP_PM_OPS(dra7xx_pcie_suspend, dra7xx_pcie_resume)
831 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(dra7xx_pcie_suspend_noirq,
832 dra7xx_pcie_resume_noirq)
835 static struct platform_driver dra7xx_pcie_driver = {
838 .of_match_table = of_dra7xx_pcie_match,
839 .suppress_bind_attrs = true,
840 .pm = &dra7xx_pcie_pm_ops,
842 .shutdown = dra7xx_pcie_shutdown,
844 builtin_platform_driver_probe(dra7xx_pcie_driver, dra7xx_pcie_probe);