9 #include <linux/module.h>
10 #include <linux/pci.h>
11 #include <linux/kernel.h>
12 #include <linux/errno.h>
27 #define DRIVER_VERSION "v1.0"
29 #define DRIVER_DESC "PCIe Port Bus Driver"
43 static int __init pcie_port_setup(
char *
str)
45 if (!
strncmp(str,
"compat", 6)) {
47 }
else if (!
strncmp(str,
"native", 6)) {
50 }
else if (!
strncmp(str,
"auto", 4)) {
57 __setup(
"pcie_ports=", pcie_port_setup);
70 static int pcie_portdrv_restore_config(
struct pci_dev *
dev)
82 static int pcie_port_resume_noirq(
struct device *dev)
96 #ifdef CONFIG_PM_RUNTIME
99 unsigned int d3cold_delay;
102 static int pci_dev_d3cold_info(
struct pci_dev *pdev,
void *
data)
109 info->no_d3cold =
true;
113 static int pcie_port_runtime_suspend(
struct device *dev)
116 struct d3cold_info d3cold_info = {
132 static int pcie_port_runtime_resume(
struct device *dev)
137 static int pcie_port_runtime_idle(
struct device *dev)
144 #define pcie_port_runtime_suspend NULL
145 #define pcie_port_runtime_resume NULL
146 #define pcie_port_runtime_idle NULL
149 static const struct dev_pm_ops pcie_portdrv_pm_ops = {
150 .
suspend = pcie_port_device_suspend,
151 .resume = pcie_port_device_resume,
152 .freeze = pcie_port_device_suspend,
153 .thaw = pcie_port_device_resume,
154 .poweroff = pcie_port_device_suspend,
155 .restore = pcie_port_device_resume,
156 .resume_noirq = pcie_port_resume_noirq,
157 .runtime_suspend = pcie_port_runtime_suspend,
158 .runtime_resume = pcie_port_runtime_resume,
159 .runtime_idle = pcie_port_runtime_idle,
162 #define PCIE_PORTDRV_PM_OPS (&pcie_portdrv_pm_ops)
166 #define PCIE_PORTDRV_PM_OPS NULL
173 static const struct pci_device_id port_runtime_pm_black_list[] = {
190 if (!pci_is_pcie(dev) ||
196 if (!dev->
irq && dev->
pin) {
197 dev_warn(&dev->
dev,
"device [%04x:%04x] has invalid IRQ; "
211 pm_runtime_put_noidle(&dev->
dev);
216 static void pcie_portdrv_remove(
struct pci_dev *dev)
219 pm_runtime_get_noresume(&dev->
dev);
224 static int error_detected_iter(
struct device *
device,
void *data)
247 merge_result(result_data->
result, status);
265 static int mmio_enabled_iter(
struct device *device,
void *data)
267 struct pcie_device *pcie_device;
283 *result = merge_result(*result, status);
300 static int slot_reset_iter(
struct device *device,
void *data)
302 struct pcie_device *pcie_device;
318 *result = merge_result(*result, status);
334 pcie_portdrv_restore_config(dev);
344 static int resume_iter(
struct device *device,
void *data)
346 struct pcie_device *pcie_device;
364 static void pcie_portdrv_err_resume(
struct pci_dev *dev)
382 .error_detected = pcie_portdrv_error_detected,
383 .mmio_enabled = pcie_portdrv_mmio_enabled,
384 .slot_reset = pcie_portdrv_slot_reset,
385 .resume = pcie_portdrv_err_resume,
390 .id_table = &port_pci_ids[0],
392 .probe = pcie_portdrv_probe,
393 .remove = pcie_portdrv_remove,
395 .err_handler = &pcie_portdrv_err_handler,
402 pr_notice(
"%s detected: will not use MSI for PCIe PME signaling\n",
404 pcie_pme_disable_msi();
413 .callback = dmi_pcie_pme_disable_msi,
414 .ident =
"MSI Wind U-100",
417 "MICRO-STAR INTERNATIONAL CO., LTD"),
424 static int __init pcie_portdrv_init(
void)
429 return pci_register_driver(&pcie_portdriver);
438 retval = pci_register_driver(&pcie_portdriver);