Commit | Line | Data |
---|---|---|
d2912cb1 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
c558e39e AS |
2 | /* |
3 | * Intel Low Power Subsystem PWM controller PCI driver | |
4 | * | |
5 | * Copyright (C) 2014, Intel Corporation | |
6 | * | |
7 | * Derived from the original pwm-lpss.c | |
c558e39e AS |
8 | */ |
9 | ||
10 | #include <linux/kernel.h> | |
11 | #include <linux/module.h> | |
12 | #include <linux/pci.h> | |
f080be27 | 13 | #include <linux/pm_runtime.h> |
c558e39e AS |
14 | |
15 | #include "pwm-lpss.h" | |
16 | ||
17 | static int pwm_lpss_probe_pci(struct pci_dev *pdev, | |
18 | const struct pci_device_id *id) | |
19 | { | |
20 | const struct pwm_lpss_boardinfo *info; | |
05013062 | 21 | struct pwm_chip *chip; |
c558e39e AS |
22 | int err; |
23 | ||
90927fe9 | 24 | err = pcim_enable_device(pdev); |
c558e39e AS |
25 | if (err < 0) |
26 | return err; | |
27 | ||
68af6fb0 AS |
28 | err = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev)); |
29 | if (err) | |
30 | return err; | |
31 | ||
c558e39e | 32 | info = (struct pwm_lpss_boardinfo *)id->driver_data; |
05013062 UKK |
33 | chip = devm_pwm_lpss_probe(&pdev->dev, pcim_iomap_table(pdev)[0], info); |
34 | if (IS_ERR(chip)) | |
35 | return PTR_ERR(chip); | |
c558e39e | 36 | |
f080be27 QZ |
37 | pm_runtime_put(&pdev->dev); |
38 | pm_runtime_allow(&pdev->dev); | |
39 | ||
c558e39e AS |
40 | return 0; |
41 | } | |
42 | ||
43 | static void pwm_lpss_remove_pci(struct pci_dev *pdev) | |
44 | { | |
f080be27 QZ |
45 | pm_runtime_forbid(&pdev->dev); |
46 | pm_runtime_get_sync(&pdev->dev); | |
c558e39e AS |
47 | } |
48 | ||
49 | static const struct pci_device_id pwm_lpss_pci_ids[] = { | |
87219cb4 | 50 | { PCI_VDEVICE(INTEL, 0x0ac8), (unsigned long)&pwm_lpss_bxt_info}, |
c558e39e AS |
51 | { PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&pwm_lpss_byt_info}, |
52 | { PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&pwm_lpss_byt_info}, | |
3c1460e9 | 53 | { PCI_VDEVICE(INTEL, 0x11a5), (unsigned long)&pwm_lpss_tng_info}, |
87219cb4 | 54 | { PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info}, |
c558e39e AS |
55 | { PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info}, |
56 | { PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info}, | |
ae252054 | 57 | { PCI_VDEVICE(INTEL, 0x31c8), (unsigned long)&pwm_lpss_bxt_info}, |
03f00e53 | 58 | { PCI_VDEVICE(INTEL, 0x5ac8), (unsigned long)&pwm_lpss_bxt_info}, |
c558e39e AS |
59 | { }, |
60 | }; | |
61 | MODULE_DEVICE_TABLE(pci, pwm_lpss_pci_ids); | |
62 | ||
63 | static struct pci_driver pwm_lpss_driver_pci = { | |
64 | .name = "pwm-lpss", | |
65 | .id_table = pwm_lpss_pci_ids, | |
66 | .probe = pwm_lpss_probe_pci, | |
67 | .remove = pwm_lpss_remove_pci, | |
68 | }; | |
69 | module_pci_driver(pwm_lpss_driver_pci); | |
70 | ||
71 | MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS"); | |
72 | MODULE_LICENSE("GPL v2"); | |
a3682d2f | 73 | MODULE_IMPORT_NS(PWM_LPSS); |