1 // SPDX-License-Identifier: GPL-2.0-only
3 * Intel Low Power Subsystem PWM controller PCI driver
5 * Copyright (C) 2014, Intel Corporation
7 * Derived from the original pwm-lpss.c
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/pci.h>
13 #include <linux/pm_runtime.h>
18 static const struct pwm_lpss_boardinfo pwm_lpss_byt_info
= {
25 static const struct pwm_lpss_boardinfo pwm_lpss_bsw_info
= {
32 static const struct pwm_lpss_boardinfo pwm_lpss_bxt_info
= {
40 static const struct pwm_lpss_boardinfo pwm_lpss_tng_info
= {
46 static int pwm_lpss_probe_pci(struct pci_dev
*pdev
,
47 const struct pci_device_id
*id
)
49 const struct pwm_lpss_boardinfo
*info
;
50 struct pwm_lpss_chip
*lpwm
;
53 err
= pcim_enable_device(pdev
);
57 info
= (struct pwm_lpss_boardinfo
*)id
->driver_data
;
58 lpwm
= pwm_lpss_probe(&pdev
->dev
, &pdev
->resource
[0], info
);
62 pci_set_drvdata(pdev
, lpwm
);
64 pm_runtime_put(&pdev
->dev
);
65 pm_runtime_allow(&pdev
->dev
);
70 static void pwm_lpss_remove_pci(struct pci_dev
*pdev
)
72 struct pwm_lpss_chip
*lpwm
= pci_get_drvdata(pdev
);
74 pm_runtime_forbid(&pdev
->dev
);
75 pm_runtime_get_sync(&pdev
->dev
);
77 pwm_lpss_remove(lpwm
);
81 static int pwm_lpss_runtime_suspend_pci(struct device
*dev
)
84 * The PCI core will handle transition to D3 automatically. We only
85 * need to provide runtime PM hooks for that to happen.
90 static int pwm_lpss_runtime_resume_pci(struct device
*dev
)
96 static const struct dev_pm_ops pwm_lpss_pci_pm
= {
97 SET_RUNTIME_PM_OPS(pwm_lpss_runtime_suspend_pci
,
98 pwm_lpss_runtime_resume_pci
, NULL
)
101 static const struct pci_device_id pwm_lpss_pci_ids
[] = {
102 { PCI_VDEVICE(INTEL
, 0x0ac8), (unsigned long)&pwm_lpss_bxt_info
},
103 { PCI_VDEVICE(INTEL
, 0x0f08), (unsigned long)&pwm_lpss_byt_info
},
104 { PCI_VDEVICE(INTEL
, 0x0f09), (unsigned long)&pwm_lpss_byt_info
},
105 { PCI_VDEVICE(INTEL
, 0x11a5), (unsigned long)&pwm_lpss_tng_info
},
106 { PCI_VDEVICE(INTEL
, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info
},
107 { PCI_VDEVICE(INTEL
, 0x2288), (unsigned long)&pwm_lpss_bsw_info
},
108 { PCI_VDEVICE(INTEL
, 0x2289), (unsigned long)&pwm_lpss_bsw_info
},
109 { PCI_VDEVICE(INTEL
, 0x31c8), (unsigned long)&pwm_lpss_bxt_info
},
110 { PCI_VDEVICE(INTEL
, 0x5ac8), (unsigned long)&pwm_lpss_bxt_info
},
113 MODULE_DEVICE_TABLE(pci
, pwm_lpss_pci_ids
);
115 static struct pci_driver pwm_lpss_driver_pci
= {
117 .id_table
= pwm_lpss_pci_ids
,
118 .probe
= pwm_lpss_probe_pci
,
119 .remove
= pwm_lpss_remove_pci
,
121 .pm
= &pwm_lpss_pci_pm
,
124 module_pci_driver(pwm_lpss_driver_pci
);
126 MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS");
127 MODULE_LICENSE("GPL v2");