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; | |
10435e0d | 21 | void __iomem *io_base; |
05013062 | 22 | struct pwm_chip *chip; |
c558e39e AS |
23 | int err; |
24 | ||
90927fe9 | 25 | err = pcim_enable_device(pdev); |
c558e39e AS |
26 | if (err < 0) |
27 | return err; | |
28 | ||
10435e0d PS |
29 | io_base = pcim_iomap_region(pdev, 0, "pwm-lpss"); |
30 | if (IS_ERR(io_base)) | |
31 | return PTR_ERR(io_base); | |
68af6fb0 | 32 | |
c558e39e | 33 | info = (struct pwm_lpss_boardinfo *)id->driver_data; |
10435e0d | 34 | chip = devm_pwm_lpss_probe(&pdev->dev, io_base, info); |
05013062 UKK |
35 | if (IS_ERR(chip)) |
36 | return PTR_ERR(chip); | |
c558e39e | 37 | |
f080be27 QZ |
38 | pm_runtime_put(&pdev->dev); |
39 | pm_runtime_allow(&pdev->dev); | |
40 | ||
c558e39e AS |
41 | return 0; |
42 | } | |
43 | ||
44 | static void pwm_lpss_remove_pci(struct pci_dev *pdev) | |
45 | { | |
f080be27 QZ |
46 | pm_runtime_forbid(&pdev->dev); |
47 | pm_runtime_get_sync(&pdev->dev); | |
c558e39e AS |
48 | } |
49 | ||
50 | static const struct pci_device_id pwm_lpss_pci_ids[] = { | |
87219cb4 | 51 | { PCI_VDEVICE(INTEL, 0x0ac8), (unsigned long)&pwm_lpss_bxt_info}, |
c558e39e AS |
52 | { PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&pwm_lpss_byt_info}, |
53 | { PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&pwm_lpss_byt_info}, | |
3c1460e9 | 54 | { PCI_VDEVICE(INTEL, 0x11a5), (unsigned long)&pwm_lpss_tng_info}, |
87219cb4 | 55 | { PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info}, |
c558e39e AS |
56 | { PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info}, |
57 | { PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info}, | |
ae252054 | 58 | { PCI_VDEVICE(INTEL, 0x31c8), (unsigned long)&pwm_lpss_bxt_info}, |
03f00e53 | 59 | { PCI_VDEVICE(INTEL, 0x5ac8), (unsigned long)&pwm_lpss_bxt_info}, |
c558e39e AS |
60 | { }, |
61 | }; | |
62 | MODULE_DEVICE_TABLE(pci, pwm_lpss_pci_ids); | |
63 | ||
64 | static struct pci_driver pwm_lpss_driver_pci = { | |
65 | .name = "pwm-lpss", | |
66 | .id_table = pwm_lpss_pci_ids, | |
67 | .probe = pwm_lpss_probe_pci, | |
68 | .remove = pwm_lpss_remove_pci, | |
69 | }; | |
70 | module_pci_driver(pwm_lpss_driver_pci); | |
71 | ||
72 | MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS"); | |
73 | MODULE_LICENSE("GPL v2"); | |
cdd30ebb | 74 | MODULE_IMPORT_NS("PWM_LPSS"); |