diff options
-rw-r--r-- | drivers/pwm/Kconfig | 19 | ||||
-rw-r--r-- | drivers/pwm/Makefile | 2 | ||||
-rw-r--r-- | drivers/pwm/pwm-lpss-pci.c | 65 | ||||
-rw-r--r-- | drivers/pwm/pwm-lpss-platform.c | 68 | ||||
-rw-r--r-- | drivers/pwm/pwm-lpss.c | 136 | ||||
-rw-r--r-- | drivers/pwm/pwm-lpss.h | 32 |
6 files changed, 195 insertions, 127 deletions
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index e56e91e4fde6..090741635f71 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig | |||
@@ -150,7 +150,6 @@ config PWM_LPC32XX | |||
150 | 150 | ||
151 | config PWM_LPSS | 151 | config PWM_LPSS |
152 | tristate "Intel LPSS PWM support" | 152 | tristate "Intel LPSS PWM support" |
153 | depends on ACPI | ||
154 | help | 153 | help |
155 | Generic PWM framework driver for Intel Low Power Subsystem PWM | 154 | Generic PWM framework driver for Intel Low Power Subsystem PWM |
156 | controller. | 155 | controller. |
@@ -158,6 +157,24 @@ config PWM_LPSS | |||
158 | To compile this driver as a module, choose M here: the module | 157 | To compile this driver as a module, choose M here: the module |
159 | will be called pwm-lpss. | 158 | will be called pwm-lpss. |
160 | 159 | ||
160 | config PWM_LPSS_PCI | ||
161 | tristate "Intel LPSS PWM PCI driver" | ||
162 | depends on PWM_LPSS && PCI | ||
163 | help | ||
164 | The PCI driver for Intel Low Power Subsystem PWM controller. | ||
165 | |||
166 | To compile this driver as a module, choose M here: the module | ||
167 | will be called pwm-lpss-pci. | ||
168 | |||
169 | config PWM_LPSS_PLATFORM | ||
170 | tristate "Intel LPSS PWM platform driver" | ||
171 | depends on PWM_LPSS && ACPI | ||
172 | help | ||
173 | The platform driver for Intel Low Power Subsystem PWM controller. | ||
174 | |||
175 | To compile this driver as a module, choose M here: the module | ||
176 | will be called pwm-lpss-platform. | ||
177 | |||
161 | config PWM_MXS | 178 | config PWM_MXS |
162 | tristate "Freescale MXS PWM support" | 179 | tristate "Freescale MXS PWM support" |
163 | depends on ARCH_MXS && OF | 180 | depends on ARCH_MXS && OF |
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index f8c577d41091..c458606c3755 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile | |||
@@ -13,6 +13,8 @@ obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o | |||
13 | obj-$(CONFIG_PWM_LP3943) += pwm-lp3943.o | 13 | obj-$(CONFIG_PWM_LP3943) += pwm-lp3943.o |
14 | obj-$(CONFIG_PWM_LPC32XX) += pwm-lpc32xx.o | 14 | obj-$(CONFIG_PWM_LPC32XX) += pwm-lpc32xx.o |
15 | obj-$(CONFIG_PWM_LPSS) += pwm-lpss.o | 15 | obj-$(CONFIG_PWM_LPSS) += pwm-lpss.o |
16 | obj-$(CONFIG_PWM_LPSS_PCI) += pwm-lpss-pci.o | ||
17 | obj-$(CONFIG_PWM_LPSS_PLATFORM) += pwm-lpss-platform.o | ||
16 | obj-$(CONFIG_PWM_MXS) += pwm-mxs.o | 18 | obj-$(CONFIG_PWM_MXS) += pwm-mxs.o |
17 | obj-$(CONFIG_PWM_PCA9685) += pwm-pca9685.o | 19 | obj-$(CONFIG_PWM_PCA9685) += pwm-pca9685.o |
18 | obj-$(CONFIG_PWM_PUV3) += pwm-puv3.o | 20 | obj-$(CONFIG_PWM_PUV3) += pwm-puv3.o |
diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c new file mode 100644 index 000000000000..1bfdd89c329c --- /dev/null +++ b/drivers/pwm/pwm-lpss-pci.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * Intel Low Power Subsystem PWM controller PCI driver | ||
3 | * | ||
4 | * Copyright (C) 2014, Intel Corporation | ||
5 | * | ||
6 | * Derived from the original pwm-lpss.c | ||
7 | * | ||
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. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/pci.h> | ||
16 | |||
17 | #include "pwm-lpss.h" | ||
18 | |||
19 | static int pwm_lpss_probe_pci(struct pci_dev *pdev, | ||
20 | const struct pci_device_id *id) | ||
21 | { | ||
22 | const struct pwm_lpss_boardinfo *info; | ||
23 | struct pwm_lpss_chip *lpwm; | ||
24 | int err; | ||
25 | |||
26 | err = pci_enable_device(pdev); | ||
27 | if (err < 0) | ||
28 | return err; | ||
29 | |||
30 | info = (struct pwm_lpss_boardinfo *)id->driver_data; | ||
31 | lpwm = pwm_lpss_probe(&pdev->dev, &pdev->resource[0], info); | ||
32 | if (IS_ERR(lpwm)) | ||
33 | return PTR_ERR(lpwm); | ||
34 | |||
35 | pci_set_drvdata(pdev, lpwm); | ||
36 | return 0; | ||
37 | } | ||
38 | |||
39 | static void pwm_lpss_remove_pci(struct pci_dev *pdev) | ||
40 | { | ||
41 | struct pwm_lpss_chip *lpwm = pci_get_drvdata(pdev); | ||
42 | |||
43 | pwm_lpss_remove(lpwm); | ||
44 | pci_disable_device(pdev); | ||
45 | } | ||
46 | |||
47 | static const struct pci_device_id pwm_lpss_pci_ids[] = { | ||
48 | { PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&pwm_lpss_byt_info}, | ||
49 | { PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&pwm_lpss_byt_info}, | ||
50 | { PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info}, | ||
51 | { PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info}, | ||
52 | { }, | ||
53 | }; | ||
54 | MODULE_DEVICE_TABLE(pci, pwm_lpss_pci_ids); | ||
55 | |||
56 | static struct pci_driver pwm_lpss_driver_pci = { | ||
57 | .name = "pwm-lpss", | ||
58 | .id_table = pwm_lpss_pci_ids, | ||
59 | .probe = pwm_lpss_probe_pci, | ||
60 | .remove = pwm_lpss_remove_pci, | ||
61 | }; | ||
62 | module_pci_driver(pwm_lpss_driver_pci); | ||
63 | |||
64 | MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS"); | ||
65 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/pwm/pwm-lpss-platform.c b/drivers/pwm/pwm-lpss-platform.c new file mode 100644 index 000000000000..18a9c880a76d --- /dev/null +++ b/drivers/pwm/pwm-lpss-platform.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * Intel Low Power Subsystem PWM controller driver | ||
3 | * | ||
4 | * Copyright (C) 2014, Intel Corporation | ||
5 | * | ||
6 | * Derived from the original pwm-lpss.c | ||
7 | * | ||
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. | ||
11 | */ | ||
12 | |||
13 | #include <linux/acpi.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | |||
18 | #include "pwm-lpss.h" | ||
19 | |||
20 | static int pwm_lpss_probe_platform(struct platform_device *pdev) | ||
21 | { | ||
22 | const struct pwm_lpss_boardinfo *info; | ||
23 | const struct acpi_device_id *id; | ||
24 | struct pwm_lpss_chip *lpwm; | ||
25 | struct resource *r; | ||
26 | |||
27 | id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev); | ||
28 | if (!id) | ||
29 | return -ENODEV; | ||
30 | |||
31 | info = (const struct pwm_lpss_boardinfo *)id->driver_data; | ||
32 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
33 | |||
34 | lpwm = pwm_lpss_probe(&pdev->dev, r, info); | ||
35 | if (IS_ERR(lpwm)) | ||
36 | return PTR_ERR(lpwm); | ||
37 | |||
38 | platform_set_drvdata(pdev, lpwm); | ||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | static int pwm_lpss_remove_platform(struct platform_device *pdev) | ||
43 | { | ||
44 | struct pwm_lpss_chip *lpwm = platform_get_drvdata(pdev); | ||
45 | |||
46 | return pwm_lpss_remove(lpwm); | ||
47 | } | ||
48 | |||
49 | static const struct acpi_device_id pwm_lpss_acpi_match[] = { | ||
50 | { "80860F09", (unsigned long)&pwm_lpss_byt_info }, | ||
51 | { "80862288", (unsigned long)&pwm_lpss_bsw_info }, | ||
52 | { }, | ||
53 | }; | ||
54 | MODULE_DEVICE_TABLE(acpi, pwm_lpss_acpi_match); | ||
55 | |||
56 | static struct platform_driver pwm_lpss_driver_platform = { | ||
57 | .driver = { | ||
58 | .name = "pwm-lpss", | ||
59 | .acpi_match_table = pwm_lpss_acpi_match, | ||
60 | }, | ||
61 | .probe = pwm_lpss_probe_platform, | ||
62 | .remove = pwm_lpss_remove_platform, | ||
63 | }; | ||
64 | module_platform_driver(pwm_lpss_driver_platform); | ||
65 | |||
66 | MODULE_DESCRIPTION("PWM platform driver for Intel LPSS"); | ||
67 | MODULE_LICENSE("GPL v2"); | ||
68 | MODULE_ALIAS("platform:pwm-lpss"); | ||
diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c index d04eee7aa967..ce9bf147811f 100644 --- a/drivers/pwm/pwm-lpss.c +++ b/drivers/pwm/pwm-lpss.c | |||
@@ -13,15 +13,10 @@ | |||
13 | * published by the Free Software Foundation. | 13 | * published by the Free Software Foundation. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/acpi.h> | ||
17 | #include <linux/device.h> | ||
18 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
19 | #include <linux/module.h> | 17 | #include <linux/module.h> |
20 | #include <linux/pwm.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/pci.h> | ||
23 | 18 | ||
24 | static int pci_drv, plat_drv; /* So we know which drivers registered */ | 19 | #include "pwm-lpss.h" |
25 | 20 | ||
26 | #define PWM 0x00000000 | 21 | #define PWM 0x00000000 |
27 | #define PWM_ENABLE BIT(31) | 22 | #define PWM_ENABLE BIT(31) |
@@ -39,19 +34,17 @@ struct pwm_lpss_chip { | |||
39 | unsigned long clk_rate; | 34 | unsigned long clk_rate; |
40 | }; | 35 | }; |
41 | 36 | ||
42 | struct pwm_lpss_boardinfo { | ||
43 | unsigned long clk_rate; | ||
44 | }; | ||
45 | |||
46 | /* BayTrail */ | 37 | /* BayTrail */ |
47 | static const struct pwm_lpss_boardinfo byt_info = { | 38 | const struct pwm_lpss_boardinfo pwm_lpss_byt_info = { |
48 | 25000000 | 39 | 25000000 |
49 | }; | 40 | }; |
41 | EXPORT_SYMBOL_GPL(pwm_lpss_byt_info); | ||
50 | 42 | ||
51 | /* Braswell */ | 43 | /* Braswell */ |
52 | static const struct pwm_lpss_boardinfo bsw_info = { | 44 | const struct pwm_lpss_boardinfo pwm_lpss_bsw_info = { |
53 | 19200000 | 45 | 19200000 |
54 | }; | 46 | }; |
47 | EXPORT_SYMBOL_GPL(pwm_lpss_bsw_info); | ||
55 | 48 | ||
56 | static inline struct pwm_lpss_chip *to_lpwm(struct pwm_chip *chip) | 49 | static inline struct pwm_lpss_chip *to_lpwm(struct pwm_chip *chip) |
57 | { | 50 | { |
@@ -123,9 +116,8 @@ static const struct pwm_ops pwm_lpss_ops = { | |||
123 | .owner = THIS_MODULE, | 116 | .owner = THIS_MODULE, |
124 | }; | 117 | }; |
125 | 118 | ||
126 | static struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, | 119 | struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, |
127 | struct resource *r, | 120 | const struct pwm_lpss_boardinfo *info) |
128 | const struct pwm_lpss_boardinfo *info) | ||
129 | { | 121 | { |
130 | struct pwm_lpss_chip *lpwm; | 122 | struct pwm_lpss_chip *lpwm; |
131 | int ret; | 123 | int ret; |
@@ -152,8 +144,9 @@ static struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, | |||
152 | 144 | ||
153 | return lpwm; | 145 | return lpwm; |
154 | } | 146 | } |
147 | EXPORT_SYMBOL_GPL(pwm_lpss_probe); | ||
155 | 148 | ||
156 | static int pwm_lpss_remove(struct pwm_lpss_chip *lpwm) | 149 | int pwm_lpss_remove(struct pwm_lpss_chip *lpwm) |
157 | { | 150 | { |
158 | u32 ctrl; | 151 | u32 ctrl; |
159 | 152 | ||
@@ -162,117 +155,8 @@ static int pwm_lpss_remove(struct pwm_lpss_chip *lpwm) | |||
162 | 155 | ||
163 | return pwmchip_remove(&lpwm->chip); | 156 | return pwmchip_remove(&lpwm->chip); |
164 | } | 157 | } |
165 | 158 | EXPORT_SYMBOL_GPL(pwm_lpss_remove); | |
166 | static int pwm_lpss_probe_pci(struct pci_dev *pdev, | ||
167 | const struct pci_device_id *id) | ||
168 | { | ||
169 | const struct pwm_lpss_boardinfo *info; | ||
170 | struct pwm_lpss_chip *lpwm; | ||
171 | int err; | ||
172 | |||
173 | err = pci_enable_device(pdev); | ||
174 | if (err < 0) | ||
175 | return err; | ||
176 | |||
177 | info = (struct pwm_lpss_boardinfo *)id->driver_data; | ||
178 | lpwm = pwm_lpss_probe(&pdev->dev, &pdev->resource[0], info); | ||
179 | if (IS_ERR(lpwm)) | ||
180 | return PTR_ERR(lpwm); | ||
181 | |||
182 | pci_set_drvdata(pdev, lpwm); | ||
183 | return 0; | ||
184 | } | ||
185 | |||
186 | static void pwm_lpss_remove_pci(struct pci_dev *pdev) | ||
187 | { | ||
188 | struct pwm_lpss_chip *lpwm = pci_get_drvdata(pdev); | ||
189 | |||
190 | pwm_lpss_remove(lpwm); | ||
191 | pci_disable_device(pdev); | ||
192 | } | ||
193 | |||
194 | static struct pci_device_id pwm_lpss_pci_ids[] = { | ||
195 | { PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&byt_info}, | ||
196 | { PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&byt_info}, | ||
197 | { PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&bsw_info}, | ||
198 | { PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&bsw_info}, | ||
199 | { }, | ||
200 | }; | ||
201 | MODULE_DEVICE_TABLE(pci, pwm_lpss_pci_ids); | ||
202 | |||
203 | static struct pci_driver pwm_lpss_driver_pci = { | ||
204 | .name = "pwm-lpss", | ||
205 | .id_table = pwm_lpss_pci_ids, | ||
206 | .probe = pwm_lpss_probe_pci, | ||
207 | .remove = pwm_lpss_remove_pci, | ||
208 | }; | ||
209 | |||
210 | static int pwm_lpss_probe_platform(struct platform_device *pdev) | ||
211 | { | ||
212 | const struct pwm_lpss_boardinfo *info; | ||
213 | const struct acpi_device_id *id; | ||
214 | struct pwm_lpss_chip *lpwm; | ||
215 | struct resource *r; | ||
216 | |||
217 | id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev); | ||
218 | if (!id) | ||
219 | return -ENODEV; | ||
220 | |||
221 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
222 | |||
223 | info = (struct pwm_lpss_boardinfo *)id->driver_data; | ||
224 | lpwm = pwm_lpss_probe(&pdev->dev, r, info); | ||
225 | if (IS_ERR(lpwm)) | ||
226 | return PTR_ERR(lpwm); | ||
227 | |||
228 | platform_set_drvdata(pdev, lpwm); | ||
229 | return 0; | ||
230 | } | ||
231 | |||
232 | static int pwm_lpss_remove_platform(struct platform_device *pdev) | ||
233 | { | ||
234 | struct pwm_lpss_chip *lpwm = platform_get_drvdata(pdev); | ||
235 | |||
236 | return pwm_lpss_remove(lpwm); | ||
237 | } | ||
238 | |||
239 | static const struct acpi_device_id pwm_lpss_acpi_match[] = { | ||
240 | { "80860F09", (unsigned long)&byt_info }, | ||
241 | { "80862288", (unsigned long)&bsw_info }, | ||
242 | { }, | ||
243 | }; | ||
244 | MODULE_DEVICE_TABLE(acpi, pwm_lpss_acpi_match); | ||
245 | |||
246 | static struct platform_driver pwm_lpss_driver_platform = { | ||
247 | .driver = { | ||
248 | .name = "pwm-lpss", | ||
249 | .acpi_match_table = pwm_lpss_acpi_match, | ||
250 | }, | ||
251 | .probe = pwm_lpss_probe_platform, | ||
252 | .remove = pwm_lpss_remove_platform, | ||
253 | }; | ||
254 | |||
255 | static int __init pwm_init(void) | ||
256 | { | ||
257 | pci_drv = pci_register_driver(&pwm_lpss_driver_pci); | ||
258 | plat_drv = platform_driver_register(&pwm_lpss_driver_platform); | ||
259 | if (pci_drv && plat_drv) | ||
260 | return pci_drv; | ||
261 | |||
262 | return 0; | ||
263 | } | ||
264 | module_init(pwm_init); | ||
265 | |||
266 | static void __exit pwm_exit(void) | ||
267 | { | ||
268 | if (!pci_drv) | ||
269 | pci_unregister_driver(&pwm_lpss_driver_pci); | ||
270 | if (!plat_drv) | ||
271 | platform_driver_unregister(&pwm_lpss_driver_platform); | ||
272 | } | ||
273 | module_exit(pwm_exit); | ||
274 | 159 | ||
275 | MODULE_DESCRIPTION("PWM driver for Intel LPSS"); | 160 | MODULE_DESCRIPTION("PWM driver for Intel LPSS"); |
276 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); | 161 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); |
277 | MODULE_LICENSE("GPL v2"); | 162 | MODULE_LICENSE("GPL v2"); |
278 | MODULE_ALIAS("platform:pwm-lpss"); | ||
diff --git a/drivers/pwm/pwm-lpss.h b/drivers/pwm/pwm-lpss.h new file mode 100644 index 000000000000..aa041bb1b67d --- /dev/null +++ b/drivers/pwm/pwm-lpss.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | * Intel Low Power Subsystem PWM controller driver | ||
3 | * | ||
4 | * Copyright (C) 2014, Intel Corporation | ||
5 | * | ||
6 | * Derived from the original pwm-lpss.c | ||
7 | * | ||
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. | ||
11 | */ | ||
12 | |||
13 | #ifndef __PWM_LPSS_H | ||
14 | #define __PWM_LPSS_H | ||
15 | |||
16 | #include <linux/device.h> | ||
17 | #include <linux/pwm.h> | ||
18 | |||
19 | struct pwm_lpss_chip; | ||
20 | |||
21 | struct pwm_lpss_boardinfo { | ||
22 | unsigned long clk_rate; | ||
23 | }; | ||
24 | |||
25 | extern const struct pwm_lpss_boardinfo pwm_lpss_byt_info; | ||
26 | extern const struct pwm_lpss_boardinfo pwm_lpss_bsw_info; | ||
27 | |||
28 | struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, | ||
29 | const struct pwm_lpss_boardinfo *info); | ||
30 | int pwm_lpss_remove(struct pwm_lpss_chip *lpwm); | ||
31 | |||
32 | #endif /* __PWM_LPSS_H */ | ||