aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2014-05-09 04:35:21 -0400
committerThierry Reding <thierry.reding@gmail.com>2014-08-07 07:18:03 -0400
commit65accd87381ed96bf8893124b149bae08edd2740 (patch)
treeeede25d9b3766884e78fd130ee0a9a393aafdba5 /drivers/pwm
parented1a819a3fdbde279f3ca18e2268cc12666e9bf1 (diff)
pwm: lpss: remove dependency on clk framework
Unlike other Intel LPSS devices, the PWM does not have the clock dividers or the gate. All we get from the clock is the rate. Since PCI case uses the driver data to get the rate, we can drop the clk and use the same data also in case of ACPI. The frequency is the same. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Chew, Chiau Ee <chiau.ee.chew@intel.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/pwm-lpss.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c
index 44ce6c6103ae..4df994f72d96 100644
--- a/drivers/pwm/pwm-lpss.c
+++ b/drivers/pwm/pwm-lpss.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16#include <linux/acpi.h> 16#include <linux/acpi.h>
17#include <linux/clk.h>
18#include <linux/device.h> 17#include <linux/device.h>
19#include <linux/kernel.h> 18#include <linux/kernel.h>
20#include <linux/module.h> 19#include <linux/module.h>
@@ -37,7 +36,6 @@ static int pci_drv, plat_drv; /* So we know which drivers registered */
37struct pwm_lpss_chip { 36struct pwm_lpss_chip {
38 struct pwm_chip chip; 37 struct pwm_chip chip;
39 void __iomem *regs; 38 void __iomem *regs;
40 struct clk *clk;
41 unsigned long clk_rate; 39 unsigned long clk_rate;
42}; 40};
43 41
@@ -97,11 +95,6 @@ static int pwm_lpss_enable(struct pwm_chip *chip, struct pwm_device *pwm)
97{ 95{
98 struct pwm_lpss_chip *lpwm = to_lpwm(chip); 96 struct pwm_lpss_chip *lpwm = to_lpwm(chip);
99 u32 ctrl; 97 u32 ctrl;
100 int ret;
101
102 ret = clk_prepare_enable(lpwm->clk);
103 if (ret)
104 return ret;
105 98
106 ctrl = readl(lpwm->regs + PWM); 99 ctrl = readl(lpwm->regs + PWM);
107 writel(ctrl | PWM_ENABLE, lpwm->regs + PWM); 100 writel(ctrl | PWM_ENABLE, lpwm->regs + PWM);
@@ -116,8 +109,6 @@ static void pwm_lpss_disable(struct pwm_chip *chip, struct pwm_device *pwm)
116 109
117 ctrl = readl(lpwm->regs + PWM); 110 ctrl = readl(lpwm->regs + PWM);
118 writel(ctrl & ~PWM_ENABLE, lpwm->regs + PWM); 111 writel(ctrl & ~PWM_ENABLE, lpwm->regs + PWM);
119
120 clk_disable_unprepare(lpwm->clk);
121} 112}
122 113
123static const struct pwm_ops pwm_lpss_ops = { 114static const struct pwm_ops pwm_lpss_ops = {
@@ -142,17 +133,7 @@ static struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev,
142 if (IS_ERR(lpwm->regs)) 133 if (IS_ERR(lpwm->regs))
143 return ERR_CAST(lpwm->regs); 134 return ERR_CAST(lpwm->regs);
144 135
145 if (info) { 136 lpwm->clk_rate = info->clk_rate;
146 lpwm->clk_rate = info->clk_rate;
147 } else {
148 lpwm->clk = devm_clk_get(dev, NULL);
149 if (IS_ERR(lpwm->clk)) {
150 dev_err(dev, "failed to get PWM clock\n");
151 return ERR_CAST(lpwm->clk);
152 }
153 lpwm->clk_rate = clk_get_rate(lpwm->clk);
154 }
155
156 lpwm->chip.dev = dev; 137 lpwm->chip.dev = dev;
157 lpwm->chip.ops = &pwm_lpss_ops; 138 lpwm->chip.ops = &pwm_lpss_ops;
158 lpwm->chip.base = -1; 139 lpwm->chip.base = -1;
@@ -221,12 +202,19 @@ static struct pci_driver pwm_lpss_driver_pci = {
221 202
222static int pwm_lpss_probe_platform(struct platform_device *pdev) 203static int pwm_lpss_probe_platform(struct platform_device *pdev)
223{ 204{
205 const struct pwm_lpss_boardinfo *info;
206 const struct acpi_device_id *id;
224 struct pwm_lpss_chip *lpwm; 207 struct pwm_lpss_chip *lpwm;
225 struct resource *r; 208 struct resource *r;
226 209
210 id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev);
211 if (!id)
212 return -ENODEV;
213
227 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 214 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
228 215
229 lpwm = pwm_lpss_probe(&pdev->dev, r, NULL); 216 info = (struct pwm_lpss_boardinfo *)id->driver_data;
217 lpwm = pwm_lpss_probe(&pdev->dev, r, info);
230 if (IS_ERR(lpwm)) 218 if (IS_ERR(lpwm))
231 return PTR_ERR(lpwm); 219 return PTR_ERR(lpwm);
232 220
@@ -242,7 +230,7 @@ static int pwm_lpss_remove_platform(struct platform_device *pdev)
242} 230}
243 231
244static const struct acpi_device_id pwm_lpss_acpi_match[] = { 232static const struct acpi_device_id pwm_lpss_acpi_match[] = {
245 { "80860F09", 0 }, 233 { "80860F09", (unsigned long)&byt_info },
246 { }, 234 { },
247}; 235};
248MODULE_DEVICE_TABLE(acpi, pwm_lpss_acpi_match); 236MODULE_DEVICE_TABLE(acpi, pwm_lpss_acpi_match);