summaryrefslogtreecommitdiffstats
path: root/drivers/pwm
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2019-01-07 14:53:52 -0500
committerThierry Reding <thierry.reding@gmail.com>2019-01-16 02:45:33 -0500
commitd80f8206905c1a8c3857d90f12bbfd6293b48a4b (patch)
treea41575aea576d5f2c02c1b979d0ebf2e29ccb872 /drivers/pwm
parentb9a5c60bc2f65561535dc05d0c740aa6e9e3bdf2 (diff)
pwm: imx: Split into two drivers
The two PWM implementations called v1 (for i.MX1 and i.MX21) and v2 (for i.MX27 and later) have nothing in common apart from needing two clocks named "per" and "ipg" and being integrated in a SoC named i.MX. So split the file containing the two disjunct drivers into two files and two complete separate drivers. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [thierry.reding@gmail.com: fix a modular build issue] Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/Kconfig17
-rw-r--r--drivers/pwm/Makefile3
-rw-r--r--drivers/pwm/pwm-imx1.c199
-rw-r--r--drivers/pwm/pwm-imx27.c (renamed from drivers/pwm/pwm-imx.c)191
4 files changed, 257 insertions, 153 deletions
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index a8f47df0655a..54f8238aac0d 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -192,14 +192,23 @@ config PWM_IMG
192 To compile this driver as a module, choose M here: the module 192 To compile this driver as a module, choose M here: the module
193 will be called pwm-img 193 will be called pwm-img
194 194
195config PWM_IMX 195config PWM_IMX1
196 tristate "i.MX PWM support" 196 tristate "i.MX1 PWM support"
197 depends on ARCH_MXC 197 depends on ARCH_MXC
198 help 198 help
199 Generic PWM framework driver for i.MX. 199 Generic PWM framework driver for i.MX1 and i.MX21
200 200
201 To compile this driver as a module, choose M here: the module 201 To compile this driver as a module, choose M here: the module
202 will be called pwm-imx. 202 will be called pwm-imx1.
203
204config PWM_IMX27
205 tristate "i.MX27 PWM support"
206 depends on ARCH_MXC
207 help
208 Generic PWM framework driver for i.MX27 and later i.MX SoCs.
209
210 To compile this driver as a module, choose M here: the module
211 will be called pwm-imx27.
203 212
204config PWM_JZ4740 213config PWM_JZ4740
205 tristate "Ingenic JZ47xx PWM support" 214 tristate "Ingenic JZ47xx PWM support"
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index 9c676a0dadf5..448825e892bc 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -17,7 +17,8 @@ obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o
17obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o 17obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o
18obj-$(CONFIG_PWM_HIBVT) += pwm-hibvt.o 18obj-$(CONFIG_PWM_HIBVT) += pwm-hibvt.o
19obj-$(CONFIG_PWM_IMG) += pwm-img.o 19obj-$(CONFIG_PWM_IMG) += pwm-img.o
20obj-$(CONFIG_PWM_IMX) += pwm-imx.o 20obj-$(CONFIG_PWM_IMX1) += pwm-imx1.o
21obj-$(CONFIG_PWM_IMX27) += pwm-imx27.o
21obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o 22obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o
22obj-$(CONFIG_PWM_LP3943) += pwm-lp3943.o 23obj-$(CONFIG_PWM_LP3943) += pwm-lp3943.o
23obj-$(CONFIG_PWM_LPC18XX_SCT) += pwm-lpc18xx-sct.o 24obj-$(CONFIG_PWM_LPC18XX_SCT) += pwm-lpc18xx-sct.o
diff --git a/drivers/pwm/pwm-imx1.c b/drivers/pwm/pwm-imx1.c
new file mode 100644
index 000000000000..f8b2c2e001a7
--- /dev/null
+++ b/drivers/pwm/pwm-imx1.c
@@ -0,0 +1,199 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * simple driver for PWM (Pulse Width Modulator) controller
4 *
5 * Derived from pxa PWM driver by eric miao <eric.miao@marvell.com>
6 */
7
8#include <linux/bitfield.h>
9#include <linux/bitops.h>
10#include <linux/clk.h>
11#include <linux/delay.h>
12#include <linux/err.h>
13#include <linux/io.h>
14#include <linux/kernel.h>
15#include <linux/module.h>
16#include <linux/of.h>
17#include <linux/of_device.h>
18#include <linux/platform_device.h>
19#include <linux/pwm.h>
20#include <linux/slab.h>
21
22#define MX1_PWMC 0x00 /* PWM Control Register */
23#define MX1_PWMS 0x04 /* PWM Sample Register */
24#define MX1_PWMP 0x08 /* PWM Period Register */
25
26#define MX1_PWMC_EN BIT(4)
27
28struct pwm_imx1_chip {
29 struct clk *clk_ipg;
30 struct clk *clk_per;
31 void __iomem *mmio_base;
32 struct pwm_chip chip;
33};
34
35#define to_pwm_imx1_chip(chip) container_of(chip, struct pwm_imx1_chip, chip)
36
37static int pwm_imx1_clk_prepare_enable(struct pwm_chip *chip)
38{
39 struct pwm_imx1_chip *imx = to_pwm_imx1_chip(chip);
40 int ret;
41
42 ret = clk_prepare_enable(imx->clk_ipg);
43 if (ret)
44 return ret;
45
46 ret = clk_prepare_enable(imx->clk_per);
47 if (ret) {
48 clk_disable_unprepare(imx->clk_ipg);
49 return ret;
50 }
51
52 return 0;
53}
54
55static void pwm_imx1_clk_disable_unprepare(struct pwm_chip *chip)
56{
57 struct pwm_imx1_chip *imx = to_pwm_imx1_chip(chip);
58
59 clk_disable_unprepare(imx->clk_per);
60 clk_disable_unprepare(imx->clk_ipg);
61}
62
63static int pwm_imx1_config(struct pwm_chip *chip,
64 struct pwm_device *pwm, int duty_ns, int period_ns)
65{
66 struct pwm_imx1_chip *imx = to_pwm_imx1_chip(chip);
67 u32 max, p;
68
69 /*
70 * The PWM subsystem allows for exact frequencies. However,
71 * I cannot connect a scope on my device to the PWM line and
72 * thus cannot provide the program the PWM controller
73 * exactly. Instead, I'm relying on the fact that the
74 * Bootloader (u-boot or WinCE+haret) has programmed the PWM
75 * function group already. So I'll just modify the PWM sample
76 * register to follow the ratio of duty_ns vs. period_ns
77 * accordingly.
78 *
79 * This is good enough for programming the brightness of
80 * the LCD backlight.
81 *
82 * The real implementation would divide PERCLK[0] first by
83 * both the prescaler (/1 .. /128) and then by CLKSEL
84 * (/2 .. /16).
85 */
86 max = readl(imx->mmio_base + MX1_PWMP);
87 p = max * duty_ns / period_ns;
88
89 writel(max - p, imx->mmio_base + MX1_PWMS);
90
91 return 0;
92}
93
94static int pwm_imx1_enable(struct pwm_chip *chip, struct pwm_device *pwm)
95{
96 struct pwm_imx1_chip *imx = to_pwm_imx1_chip(chip);
97 u32 value;
98 int ret;
99
100 ret = pwm_imx1_clk_prepare_enable(chip);
101 if (ret < 0)
102 return ret;
103
104 value = readl(imx->mmio_base + MX1_PWMC);
105 value |= MX1_PWMC_EN;
106 writel(value, imx->mmio_base + MX1_PWMC);
107
108 return 0;
109}
110
111static void pwm_imx1_disable(struct pwm_chip *chip, struct pwm_device *pwm)
112{
113 struct pwm_imx1_chip *imx = to_pwm_imx1_chip(chip);
114 u32 value;
115
116 value = readl(imx->mmio_base + MX1_PWMC);
117 value &= ~MX1_PWMC_EN;
118 writel(value, imx->mmio_base + MX1_PWMC);
119
120 pwm_imx1_clk_disable_unprepare(chip);
121}
122
123static const struct pwm_ops pwm_imx1_ops = {
124 .enable = pwm_imx1_enable,
125 .disable = pwm_imx1_disable,
126 .config = pwm_imx1_config,
127 .owner = THIS_MODULE,
128};
129
130static const struct of_device_id pwm_imx1_dt_ids[] = {
131 { .compatible = "fsl,imx1-pwm", },
132 { /* sentinel */ }
133};
134MODULE_DEVICE_TABLE(of, pwm_imx1_dt_ids);
135
136static int pwm_imx1_probe(struct platform_device *pdev)
137{
138 struct pwm_imx1_chip *imx;
139 struct resource *r;
140
141 imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL);
142 if (!imx)
143 return -ENOMEM;
144
145 platform_set_drvdata(pdev, imx);
146
147 imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
148 if (IS_ERR(imx->clk_ipg)) {
149 dev_err(&pdev->dev, "getting ipg clock failed with %ld\n",
150 PTR_ERR(imx->clk_ipg));
151 return PTR_ERR(imx->clk_ipg);
152 }
153
154 imx->clk_per = devm_clk_get(&pdev->dev, "per");
155 if (IS_ERR(imx->clk_per)) {
156 int ret = PTR_ERR(imx->clk_per);
157
158 if (ret != -EPROBE_DEFER)
159 dev_err(&pdev->dev,
160 "failed to get peripheral clock: %d\n",
161 ret);
162
163 return ret;
164 }
165
166 imx->chip.ops = &pwm_imx1_ops;
167 imx->chip.dev = &pdev->dev;
168 imx->chip.base = -1;
169 imx->chip.npwm = 1;
170
171 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
172 imx->mmio_base = devm_ioremap_resource(&pdev->dev, r);
173 if (IS_ERR(imx->mmio_base))
174 return PTR_ERR(imx->mmio_base);
175
176 return pwmchip_add(&imx->chip);
177}
178
179static int pwm_imx1_remove(struct platform_device *pdev)
180{
181 struct pwm_imx1_chip *imx = platform_get_drvdata(pdev);
182
183 pwm_imx1_clk_disable_unprepare(&imx->chip);
184
185 return pwmchip_remove(&imx->chip);
186}
187
188static struct platform_driver pwm_imx1_driver = {
189 .driver = {
190 .name = "pwm-imx1",
191 .of_match_table = pwm_imx1_dt_ids,
192 },
193 .probe = pwm_imx1_probe,
194 .remove = pwm_imx1_remove,
195};
196module_platform_driver(pwm_imx1_driver);
197
198MODULE_LICENSE("GPL v2");
199MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx27.c
index 30380fcb5cfb..8b8b1c6b7f29 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx27.c
@@ -19,16 +19,6 @@
19#include <linux/pwm.h> 19#include <linux/pwm.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21 21
22/* i.MX1 and i.MX21 share the same PWM function block: */
23
24#define MX1_PWMC 0x00 /* PWM Control Register */
25#define MX1_PWMS 0x04 /* PWM Sample Register */
26#define MX1_PWMP 0x08 /* PWM Period Register */
27
28#define MX1_PWMC_EN BIT(4)
29
30/* i.MX27, i.MX31, i.MX35 share the same PWM function block: */
31
32#define MX3_PWMCR 0x00 /* PWM Control Register */ 22#define MX3_PWMCR 0x00 /* PWM Control Register */
33#define MX3_PWMSR 0x04 /* PWM Status Register */ 23#define MX3_PWMSR 0x04 /* PWM Status Register */
34#define MX3_PWMSAR 0x0C /* PWM Sample Register */ 24#define MX3_PWMSAR 0x0C /* PWM Sample Register */
@@ -86,21 +76,18 @@
86/* PWMPR register value of 0xffff has the same effect as 0xfffe */ 76/* PWMPR register value of 0xffff has the same effect as 0xfffe */
87#define MX3_PWMPR_MAX 0xfffe 77#define MX3_PWMPR_MAX 0xfffe
88 78
89struct imx_chip { 79struct pwm_imx27_chip {
90 struct clk *clk_ipg; 80 struct clk *clk_ipg;
91
92 struct clk *clk_per; 81 struct clk *clk_per;
93
94 void __iomem *mmio_base; 82 void __iomem *mmio_base;
95
96 struct pwm_chip chip; 83 struct pwm_chip chip;
97}; 84};
98 85
99#define to_imx_chip(chip) container_of(chip, struct imx_chip, chip) 86#define to_pwm_imx27_chip(chip) container_of(chip, struct pwm_imx27_chip, chip)
100 87
101static int imx_pwm_clk_prepare_enable(struct pwm_chip *chip) 88static int pwm_imx27_clk_prepare_enable(struct pwm_chip *chip)
102{ 89{
103 struct imx_chip *imx = to_imx_chip(chip); 90 struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip);
104 int ret; 91 int ret;
105 92
106 ret = clk_prepare_enable(imx->clk_ipg); 93 ret = clk_prepare_enable(imx->clk_ipg);
@@ -116,22 +103,22 @@ static int imx_pwm_clk_prepare_enable(struct pwm_chip *chip)
116 return 0; 103 return 0;
117} 104}
118 105
119static void imx_pwm_clk_disable_unprepare(struct pwm_chip *chip) 106static void pwm_imx27_clk_disable_unprepare(struct pwm_chip *chip)
120{ 107{
121 struct imx_chip *imx = to_imx_chip(chip); 108 struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip);
122 109
123 clk_disable_unprepare(imx->clk_per); 110 clk_disable_unprepare(imx->clk_per);
124 clk_disable_unprepare(imx->clk_ipg); 111 clk_disable_unprepare(imx->clk_ipg);
125} 112}
126 113
127static void imx_pwm_get_state(struct pwm_chip *chip, 114static void pwm_imx27_get_state(struct pwm_chip *chip,
128 struct pwm_device *pwm, struct pwm_state *state) 115 struct pwm_device *pwm, struct pwm_state *state)
129{ 116{
130 struct imx_chip *imx = to_imx_chip(chip); 117 struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip);
131 u32 period, prescaler, pwm_clk, ret, val; 118 u32 period, prescaler, pwm_clk, ret, val;
132 u64 tmp; 119 u64 tmp;
133 120
134 ret = imx_pwm_clk_prepare_enable(chip); 121 ret = pwm_imx27_clk_prepare_enable(chip);
135 if (ret < 0) 122 if (ret < 0)
136 return; 123 return;
137 124
@@ -139,7 +126,7 @@ static void imx_pwm_get_state(struct pwm_chip *chip,
139 126
140 if (val & MX3_PWMCR_EN) { 127 if (val & MX3_PWMCR_EN) {
141 state->enabled = true; 128 state->enabled = true;
142 ret = imx_pwm_clk_prepare_enable(chip); 129 ret = pwm_imx27_clk_prepare_enable(chip);
143 if (ret) 130 if (ret)
144 return; 131 return;
145 } else { 132 } else {
@@ -176,70 +163,12 @@ static void imx_pwm_get_state(struct pwm_chip *chip,
176 state->duty_cycle = 0; 163 state->duty_cycle = 0;
177 } 164 }
178 165
179 imx_pwm_clk_disable_unprepare(chip); 166 pwm_imx27_clk_disable_unprepare(chip);
180}
181
182static int imx_pwm_config_v1(struct pwm_chip *chip,
183 struct pwm_device *pwm, int duty_ns, int period_ns)
184{
185 struct imx_chip *imx = to_imx_chip(chip);
186
187 /*
188 * The PWM subsystem allows for exact frequencies. However,
189 * I cannot connect a scope on my device to the PWM line and
190 * thus cannot provide the program the PWM controller
191 * exactly. Instead, I'm relying on the fact that the
192 * Bootloader (u-boot or WinCE+haret) has programmed the PWM
193 * function group already. So I'll just modify the PWM sample
194 * register to follow the ratio of duty_ns vs. period_ns
195 * accordingly.
196 *
197 * This is good enough for programming the brightness of
198 * the LCD backlight.
199 *
200 * The real implementation would divide PERCLK[0] first by
201 * both the prescaler (/1 .. /128) and then by CLKSEL
202 * (/2 .. /16).
203 */
204 u32 max = readl(imx->mmio_base + MX1_PWMP);
205 u32 p = max * duty_ns / period_ns;
206 writel(max - p, imx->mmio_base + MX1_PWMS);
207
208 return 0;
209}
210
211static int imx_pwm_enable_v1(struct pwm_chip *chip, struct pwm_device *pwm)
212{
213 struct imx_chip *imx = to_imx_chip(chip);
214 u32 val;
215 int ret;
216
217 ret = imx_pwm_clk_prepare_enable(chip);
218 if (ret < 0)
219 return ret;
220
221 val = readl(imx->mmio_base + MX1_PWMC);
222 val |= MX1_PWMC_EN;
223 writel(val, imx->mmio_base + MX1_PWMC);
224
225 return 0;
226}
227
228static void imx_pwm_disable_v1(struct pwm_chip *chip, struct pwm_device *pwm)
229{
230 struct imx_chip *imx = to_imx_chip(chip);
231 u32 val;
232
233 val = readl(imx->mmio_base + MX1_PWMC);
234 val &= ~MX1_PWMC_EN;
235 writel(val, imx->mmio_base + MX1_PWMC);
236
237 imx_pwm_clk_disable_unprepare(chip);
238} 167}
239 168
240static void imx_pwm_sw_reset(struct pwm_chip *chip) 169static void pwm_imx27_sw_reset(struct pwm_chip *chip)
241{ 170{
242 struct imx_chip *imx = to_imx_chip(chip); 171 struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip);
243 struct device *dev = chip->dev; 172 struct device *dev = chip->dev;
244 int wait_count = 0; 173 int wait_count = 0;
245 u32 cr; 174 u32 cr;
@@ -255,10 +184,10 @@ static void imx_pwm_sw_reset(struct pwm_chip *chip)
255 dev_warn(dev, "software reset timeout\n"); 184 dev_warn(dev, "software reset timeout\n");
256} 185}
257 186
258static void imx_pwm_wait_fifo_slot(struct pwm_chip *chip, 187static void pwm_imx27_wait_fifo_slot(struct pwm_chip *chip,
259 struct pwm_device *pwm) 188 struct pwm_device *pwm)
260{ 189{
261 struct imx_chip *imx = to_imx_chip(chip); 190 struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip);
262 struct device *dev = chip->dev; 191 struct device *dev = chip->dev;
263 unsigned int period_ms; 192 unsigned int period_ms;
264 int fifoav; 193 int fifoav;
@@ -277,11 +206,11 @@ static void imx_pwm_wait_fifo_slot(struct pwm_chip *chip,
277 } 206 }
278} 207}
279 208
280static int imx_pwm_apply_v2(struct pwm_chip *chip, struct pwm_device *pwm, 209static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm,
281 struct pwm_state *state) 210 struct pwm_state *state)
282{ 211{
283 unsigned long period_cycles, duty_cycles, prescale; 212 unsigned long period_cycles, duty_cycles, prescale;
284 struct imx_chip *imx = to_imx_chip(chip); 213 struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip);
285 struct pwm_state cstate; 214 struct pwm_state cstate;
286 unsigned long long c; 215 unsigned long long c;
287 int ret; 216 int ret;
@@ -318,13 +247,13 @@ static int imx_pwm_apply_v2(struct pwm_chip *chip, struct pwm_device *pwm,
318 * enabled. 247 * enabled.
319 */ 248 */
320 if (cstate.enabled) { 249 if (cstate.enabled) {
321 imx_pwm_wait_fifo_slot(chip, pwm); 250 pwm_imx27_wait_fifo_slot(chip, pwm);
322 } else { 251 } else {
323 ret = imx_pwm_clk_prepare_enable(chip); 252 ret = pwm_imx27_clk_prepare_enable(chip);
324 if (ret) 253 if (ret)
325 return ret; 254 return ret;
326 255
327 imx_pwm_sw_reset(chip); 256 pwm_imx27_sw_reset(chip);
328 } 257 }
329 258
330 writel(duty_cycles, imx->mmio_base + MX3_PWMSAR); 259 writel(duty_cycles, imx->mmio_base + MX3_PWMSAR);
@@ -343,59 +272,29 @@ static int imx_pwm_apply_v2(struct pwm_chip *chip, struct pwm_device *pwm,
343 } else if (cstate.enabled) { 272 } else if (cstate.enabled) {
344 writel(0, imx->mmio_base + MX3_PWMCR); 273 writel(0, imx->mmio_base + MX3_PWMCR);
345 274
346 imx_pwm_clk_disable_unprepare(chip); 275 pwm_imx27_clk_disable_unprepare(chip);
347 } 276 }
348 277
349 return 0; 278 return 0;
350} 279}
351 280
352static const struct pwm_ops imx_pwm_ops_v1 = { 281static const struct pwm_ops pwm_imx27_ops = {
353 .enable = imx_pwm_enable_v1, 282 .apply = pwm_imx27_apply,
354 .disable = imx_pwm_disable_v1, 283 .get_state = pwm_imx27_get_state,
355 .config = imx_pwm_config_v1,
356 .owner = THIS_MODULE,
357};
358
359static const struct pwm_ops imx_pwm_ops_v2 = {
360 .apply = imx_pwm_apply_v2,
361 .get_state = imx_pwm_get_state,
362 .owner = THIS_MODULE, 284 .owner = THIS_MODULE,
363}; 285};
364 286
365struct imx_pwm_data { 287static const struct of_device_id pwm_imx27_dt_ids[] = {
366 bool polarity_supported; 288 { .compatible = "fsl,imx27-pwm", },
367 const struct pwm_ops *ops;
368};
369
370static struct imx_pwm_data imx_pwm_data_v1 = {
371 .ops = &imx_pwm_ops_v1,
372};
373
374static struct imx_pwm_data imx_pwm_data_v2 = {
375 .polarity_supported = true,
376 .ops = &imx_pwm_ops_v2,
377};
378
379static const struct of_device_id imx_pwm_dt_ids[] = {
380 { .compatible = "fsl,imx1-pwm", .data = &imx_pwm_data_v1, },
381 { .compatible = "fsl,imx27-pwm", .data = &imx_pwm_data_v2, },
382 { /* sentinel */ } 289 { /* sentinel */ }
383}; 290};
384MODULE_DEVICE_TABLE(of, imx_pwm_dt_ids); 291MODULE_DEVICE_TABLE(of, pwm_imx27_dt_ids);
385 292
386static int imx_pwm_probe(struct platform_device *pdev) 293static int pwm_imx27_probe(struct platform_device *pdev)
387{ 294{
388 const struct of_device_id *of_id = 295 struct pwm_imx27_chip *imx;
389 of_match_device(imx_pwm_dt_ids, &pdev->dev);
390 const struct imx_pwm_data *data;
391 struct imx_chip *imx;
392 struct resource *r; 296 struct resource *r;
393 297
394 if (!of_id)
395 return -ENODEV;
396
397 data = of_id->data;
398
399 imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL); 298 imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL);
400 if (imx == NULL) 299 if (imx == NULL)
401 return -ENOMEM; 300 return -ENOMEM;
@@ -421,16 +320,13 @@ static int imx_pwm_probe(struct platform_device *pdev)
421 return ret; 320 return ret;
422 } 321 }
423 322
424 imx->chip.ops = data->ops; 323 imx->chip.ops = &pwm_imx27_ops;
425 imx->chip.dev = &pdev->dev; 324 imx->chip.dev = &pdev->dev;
426 imx->chip.base = -1; 325 imx->chip.base = -1;
427 imx->chip.npwm = 1; 326 imx->chip.npwm = 1;
428 327
429 if (data->polarity_supported) { 328 imx->chip.of_xlate = of_pwm_xlate_with_flags;
430 dev_dbg(&pdev->dev, "PWM supports output inversion\n"); 329 imx->chip.of_pwm_n_cells = 3;
431 imx->chip.of_xlate = of_pwm_xlate_with_flags;
432 imx->chip.of_pwm_n_cells = 3;
433 }
434 330
435 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 331 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
436 imx->mmio_base = devm_ioremap_resource(&pdev->dev, r); 332 imx->mmio_base = devm_ioremap_resource(&pdev->dev, r);
@@ -440,26 +336,25 @@ static int imx_pwm_probe(struct platform_device *pdev)
440 return pwmchip_add(&imx->chip); 336 return pwmchip_add(&imx->chip);
441} 337}
442 338
443static int imx_pwm_remove(struct platform_device *pdev) 339static int pwm_imx27_remove(struct platform_device *pdev)
444{ 340{
445 struct imx_chip *imx; 341 struct pwm_imx27_chip *imx;
446 342
447 imx = platform_get_drvdata(pdev); 343 imx = platform_get_drvdata(pdev);
448 344
449 imx_pwm_clk_disable_unprepare(&imx->chip); 345 pwm_imx27_clk_disable_unprepare(&imx->chip);
450 346
451 return pwmchip_remove(&imx->chip); 347 return pwmchip_remove(&imx->chip);
452} 348}
453 349
454static struct platform_driver imx_pwm_driver = { 350static struct platform_driver imx_pwm_driver = {
455 .driver = { 351 .driver = {
456 .name = "imx-pwm", 352 .name = "pwm-imx27",
457 .of_match_table = imx_pwm_dt_ids, 353 .of_match_table = pwm_imx27_dt_ids,
458 }, 354 },
459 .probe = imx_pwm_probe, 355 .probe = pwm_imx27_probe,
460 .remove = imx_pwm_remove, 356 .remove = pwm_imx27_remove,
461}; 357};
462
463module_platform_driver(imx_pwm_driver); 358module_platform_driver(imx_pwm_driver);
464 359
465MODULE_LICENSE("GPL v2"); 360MODULE_LICENSE("GPL v2");