GNU Linux-libre 4.19.304-gnu1
[releases.git] / drivers / pwm / pwm-sti.c
1 /*
2  * PWM device driver for ST SoCs
3  *
4  * Copyright (C) 2013-2016 STMicroelectronics (R&D) Limited
5  *
6  * Author: Ajit Pal Singh <ajitpal.singh@st.com>
7  *         Lee Jones <lee.jones@linaro.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  */
14
15 #include <linux/clk.h>
16 #include <linux/interrupt.h>
17 #include <linux/math64.h>
18 #include <linux/mfd/syscon.h>
19 #include <linux/module.h>
20 #include <linux/of.h>
21 #include <linux/platform_device.h>
22 #include <linux/pwm.h>
23 #include <linux/regmap.h>
24 #include <linux/sched.h>
25 #include <linux/slab.h>
26 #include <linux/time.h>
27 #include <linux/wait.h>
28
29 #define PWM_OUT_VAL(x)  (0x00 + (4 * (x))) /* Device's Duty Cycle register */
30 #define PWM_CPT_VAL(x)  (0x10 + (4 * (x))) /* Capture value */
31 #define PWM_CPT_EDGE(x) (0x30 + (4 * (x))) /* Edge to capture on */
32
33 #define STI_PWM_CTRL            0x50    /* Control/Config register */
34 #define STI_INT_EN              0x54    /* Interrupt Enable/Disable register */
35 #define STI_INT_STA             0x58    /* Interrupt Status register */
36 #define PWM_INT_ACK             0x5c
37 #define PWM_PRESCALE_LOW_MASK   0x0f
38 #define PWM_PRESCALE_HIGH_MASK  0xf0
39 #define PWM_CPT_EDGE_MASK       0x03
40 #define PWM_INT_ACK_MASK        0x1ff
41
42 #define STI_MAX_CPT_DEVS        4
43 #define CPT_DC_MAX              0xff
44
45 /* Regfield IDs */
46 enum {
47         /* Bits in PWM_CTRL*/
48         PWMCLK_PRESCALE_LOW,
49         PWMCLK_PRESCALE_HIGH,
50         CPTCLK_PRESCALE,
51
52         PWM_OUT_EN,
53         PWM_CPT_EN,
54
55         PWM_CPT_INT_EN,
56         PWM_CPT_INT_STAT,
57
58         /* Keep last */
59         MAX_REGFIELDS
60 };
61
62 /*
63  * Each capture input can be programmed to detect rising-edge, falling-edge,
64  * either edge or neither egde.
65  */
66 enum sti_cpt_edge {
67         CPT_EDGE_DISABLED,
68         CPT_EDGE_RISING,
69         CPT_EDGE_FALLING,
70         CPT_EDGE_BOTH,
71 };
72
73 struct sti_cpt_ddata {
74         u32 snapshot[3];
75         unsigned int index;
76         struct mutex lock;
77         wait_queue_head_t wait;
78 };
79
80 struct sti_pwm_compat_data {
81         const struct reg_field *reg_fields;
82         unsigned int pwm_num_devs;
83         unsigned int cpt_num_devs;
84         unsigned int max_pwm_cnt;
85         unsigned int max_prescale;
86         struct sti_cpt_ddata *ddata;
87 };
88
89 struct sti_pwm_chip {
90         struct device *dev;
91         struct clk *pwm_clk;
92         struct clk *cpt_clk;
93         struct regmap *regmap;
94         struct sti_pwm_compat_data *cdata;
95         struct regmap_field *prescale_low;
96         struct regmap_field *prescale_high;
97         struct regmap_field *pwm_out_en;
98         struct regmap_field *pwm_cpt_en;
99         struct regmap_field *pwm_cpt_int_en;
100         struct regmap_field *pwm_cpt_int_stat;
101         struct pwm_chip chip;
102         struct pwm_device *cur;
103         unsigned long configured;
104         unsigned int en_count;
105         struct mutex sti_pwm_lock; /* To sync between enable/disable calls */
106         void __iomem *mmio;
107 };
108
109 static const struct reg_field sti_pwm_regfields[MAX_REGFIELDS] = {
110         [PWMCLK_PRESCALE_LOW] = REG_FIELD(STI_PWM_CTRL, 0, 3),
111         [PWMCLK_PRESCALE_HIGH] = REG_FIELD(STI_PWM_CTRL, 11, 14),
112         [CPTCLK_PRESCALE] = REG_FIELD(STI_PWM_CTRL, 4, 8),
113         [PWM_OUT_EN] = REG_FIELD(STI_PWM_CTRL, 9, 9),
114         [PWM_CPT_EN] = REG_FIELD(STI_PWM_CTRL, 10, 10),
115         [PWM_CPT_INT_EN] = REG_FIELD(STI_INT_EN, 1, 4),
116         [PWM_CPT_INT_STAT] = REG_FIELD(STI_INT_STA, 1, 4),
117 };
118
119 static inline struct sti_pwm_chip *to_sti_pwmchip(struct pwm_chip *chip)
120 {
121         return container_of(chip, struct sti_pwm_chip, chip);
122 }
123
124 /*
125  * Calculate the prescaler value corresponding to the period.
126  */
127 static int sti_pwm_get_prescale(struct sti_pwm_chip *pc, unsigned long period,
128                                 unsigned int *prescale)
129 {
130         struct sti_pwm_compat_data *cdata = pc->cdata;
131         unsigned long clk_rate;
132         unsigned long value;
133         unsigned int ps;
134
135         clk_rate = clk_get_rate(pc->pwm_clk);
136         if (!clk_rate) {
137                 dev_err(pc->dev, "failed to get clock rate\n");
138                 return -EINVAL;
139         }
140
141         /*
142          * prescale = ((period_ns * clk_rate) / (10^9 * (max_pwm_cnt + 1)) - 1
143          */
144         value = NSEC_PER_SEC / clk_rate;
145         value *= cdata->max_pwm_cnt + 1;
146
147         if (period % value)
148                 return -EINVAL;
149
150         ps  = period / value - 1;
151         if (ps > cdata->max_prescale)
152                 return -EINVAL;
153
154         *prescale = ps;
155
156         return 0;
157 }
158
159 /*
160  * For STiH4xx PWM IP, the PWM period is fixed to 256 local clock cycles. The
161  * only way to change the period (apart from changing the PWM input clock) is
162  * to change the PWM clock prescaler.
163  *
164  * The prescaler is of 8 bits, so 256 prescaler values and hence 256 possible
165  * period values are supported (for a particular clock rate). The requested
166  * period will be applied only if it matches one of these 256 values.
167  */
168 static int sti_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
169                           int duty_ns, int period_ns)
170 {
171         struct sti_pwm_chip *pc = to_sti_pwmchip(chip);
172         struct sti_pwm_compat_data *cdata = pc->cdata;
173         unsigned int ncfg, value, prescale = 0;
174         struct pwm_device *cur = pc->cur;
175         struct device *dev = pc->dev;
176         bool period_same = false;
177         int ret;
178
179         ncfg = hweight_long(pc->configured);
180         if (ncfg)
181                 period_same = (period_ns == pwm_get_period(cur));
182
183         /*
184          * Allow configuration changes if one of the following conditions
185          * satisfy.
186          * 1. No devices have been configured.
187          * 2. Only one device has been configured and the new request is for
188          *    the same device.
189          * 3. Only one device has been configured and the new request is for
190          *    a new device and period of the new device is same as the current
191          *    configured period.
192          * 4. More than one devices are configured and period of the new
193          *    requestis the same as the current period.
194          */
195         if (!ncfg ||
196             ((ncfg == 1) && (pwm->hwpwm == cur->hwpwm)) ||
197             ((ncfg == 1) && (pwm->hwpwm != cur->hwpwm) && period_same) ||
198             ((ncfg > 1) && period_same)) {
199                 /* Enable clock before writing to PWM registers. */
200                 ret = clk_enable(pc->pwm_clk);
201                 if (ret)
202                         return ret;
203
204                 ret = clk_enable(pc->cpt_clk);
205                 if (ret)
206                         return ret;
207
208                 if (!period_same) {
209                         ret = sti_pwm_get_prescale(pc, period_ns, &prescale);
210                         if (ret)
211                                 goto clk_dis;
212
213                         value = prescale & PWM_PRESCALE_LOW_MASK;
214
215                         ret = regmap_field_write(pc->prescale_low, value);
216                         if (ret)
217                                 goto clk_dis;
218
219                         value = (prescale & PWM_PRESCALE_HIGH_MASK) >> 4;
220
221                         ret = regmap_field_write(pc->prescale_high, value);
222                         if (ret)
223                                 goto clk_dis;
224                 }
225
226                 /*
227                  * When PWMVal == 0, PWM pulse = 1 local clock cycle.
228                  * When PWMVal == max_pwm_count,
229                  * PWM pulse = (max_pwm_count + 1) local cycles,
230                  * that is continuous pulse: signal never goes low.
231                  */
232                 value = cdata->max_pwm_cnt * duty_ns / period_ns;
233
234                 ret = regmap_write(pc->regmap, PWM_OUT_VAL(pwm->hwpwm), value);
235                 if (ret)
236                         goto clk_dis;
237
238                 ret = regmap_field_write(pc->pwm_cpt_int_en, 0);
239
240                 set_bit(pwm->hwpwm, &pc->configured);
241                 pc->cur = pwm;
242
243                 dev_dbg(dev, "prescale:%u, period:%i, duty:%i, value:%u\n",
244                         prescale, period_ns, duty_ns, value);
245         } else {
246                 return -EINVAL;
247         }
248
249 clk_dis:
250         clk_disable(pc->pwm_clk);
251         clk_disable(pc->cpt_clk);
252         return ret;
253 }
254
255 static int sti_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
256 {
257         struct sti_pwm_chip *pc = to_sti_pwmchip(chip);
258         struct device *dev = pc->dev;
259         int ret = 0;
260
261         /*
262          * Since we have a common enable for all PWM devices, do not enable if
263          * already enabled.
264          */
265         mutex_lock(&pc->sti_pwm_lock);
266
267         if (!pc->en_count) {
268                 ret = clk_enable(pc->pwm_clk);
269                 if (ret)
270                         goto out;
271
272                 ret = clk_enable(pc->cpt_clk);
273                 if (ret)
274                         goto out;
275
276                 ret = regmap_field_write(pc->pwm_out_en, 1);
277                 if (ret) {
278                         dev_err(dev, "failed to enable PWM device %u: %d\n",
279                                 pwm->hwpwm, ret);
280                         goto out;
281                 }
282         }
283
284         pc->en_count++;
285
286 out:
287         mutex_unlock(&pc->sti_pwm_lock);
288         return ret;
289 }
290
291 static void sti_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
292 {
293         struct sti_pwm_chip *pc = to_sti_pwmchip(chip);
294
295         mutex_lock(&pc->sti_pwm_lock);
296
297         if (--pc->en_count) {
298                 mutex_unlock(&pc->sti_pwm_lock);
299                 return;
300         }
301
302         regmap_field_write(pc->pwm_out_en, 0);
303
304         clk_disable(pc->pwm_clk);
305         clk_disable(pc->cpt_clk);
306
307         mutex_unlock(&pc->sti_pwm_lock);
308 }
309
310 static void sti_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
311 {
312         struct sti_pwm_chip *pc = to_sti_pwmchip(chip);
313
314         clear_bit(pwm->hwpwm, &pc->configured);
315 }
316
317 static int sti_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm,
318                            struct pwm_capture *result, unsigned long timeout)
319 {
320         struct sti_pwm_chip *pc = to_sti_pwmchip(chip);
321         struct sti_pwm_compat_data *cdata = pc->cdata;
322         struct sti_cpt_ddata *ddata = &cdata->ddata[pwm->hwpwm];
323         struct device *dev = pc->dev;
324         unsigned int effective_ticks;
325         unsigned long long high, low;
326         int ret;
327
328         if (pwm->hwpwm >= cdata->cpt_num_devs) {
329                 dev_err(dev, "device %u is not valid\n", pwm->hwpwm);
330                 return -EINVAL;
331         }
332
333         mutex_lock(&ddata->lock);
334         ddata->index = 0;
335
336         /* Prepare capture measurement */
337         regmap_write(pc->regmap, PWM_CPT_EDGE(pwm->hwpwm), CPT_EDGE_RISING);
338         regmap_field_write(pc->pwm_cpt_int_en, BIT(pwm->hwpwm));
339
340         /* Enable capture */
341         ret = regmap_field_write(pc->pwm_cpt_en, 1);
342         if (ret) {
343                 dev_err(dev, "failed to enable PWM capture %u: %d\n",
344                         pwm->hwpwm, ret);
345                 goto out;
346         }
347
348         ret = wait_event_interruptible_timeout(ddata->wait, ddata->index > 1,
349                                                msecs_to_jiffies(timeout));
350
351         regmap_write(pc->regmap, PWM_CPT_EDGE(pwm->hwpwm), CPT_EDGE_DISABLED);
352
353         if (ret == -ERESTARTSYS)
354                 goto out;
355
356         switch (ddata->index) {
357         case 0:
358         case 1:
359                 /*
360                  * Getting here could mean:
361                  *  - input signal is constant of less than 1 Hz
362                  *  - there is no input signal at all
363                  *
364                  * In such case the frequency is rounded down to 0
365                  */
366                 result->period = 0;
367                 result->duty_cycle = 0;
368
369                 break;
370
371         case 2:
372                 /* We have everying we need */
373                 high = ddata->snapshot[1] - ddata->snapshot[0];
374                 low = ddata->snapshot[2] - ddata->snapshot[1];
375
376                 effective_ticks = clk_get_rate(pc->cpt_clk);
377
378                 result->period = (high + low) * NSEC_PER_SEC;
379                 result->period /= effective_ticks;
380
381                 result->duty_cycle = high * NSEC_PER_SEC;
382                 result->duty_cycle /= effective_ticks;
383
384                 break;
385
386         default:
387                 dev_err(dev, "internal error\n");
388                 break;
389         }
390
391 out:
392         /* Disable capture */
393         regmap_field_write(pc->pwm_cpt_en, 0);
394
395         mutex_unlock(&ddata->lock);
396         return ret;
397 }
398
399 static const struct pwm_ops sti_pwm_ops = {
400         .capture = sti_pwm_capture,
401         .config = sti_pwm_config,
402         .enable = sti_pwm_enable,
403         .disable = sti_pwm_disable,
404         .free = sti_pwm_free,
405         .owner = THIS_MODULE,
406 };
407
408 static irqreturn_t sti_pwm_interrupt(int irq, void *data)
409 {
410         struct sti_pwm_chip *pc = data;
411         struct device *dev = pc->dev;
412         struct sti_cpt_ddata *ddata;
413         int devicenum;
414         unsigned int cpt_int_stat;
415         unsigned int reg;
416         int ret = IRQ_NONE;
417
418         ret = regmap_field_read(pc->pwm_cpt_int_stat, &cpt_int_stat);
419         if (ret)
420                 return ret;
421
422         while (cpt_int_stat) {
423                 devicenum = ffs(cpt_int_stat) - 1;
424
425                 ddata = &pc->cdata->ddata[devicenum];
426
427                 /*
428                  * Capture input:
429                  *    _______                   _______
430                  *   |       |                 |       |
431                  * __|       |_________________|       |________
432                  *   ^0      ^1                ^2
433                  *
434                  * Capture start by the first available rising edge. When a
435                  * capture event occurs, capture value (CPT_VALx) is stored,
436                  * index incremented, capture edge changed.
437                  *
438                  * After the capture, if the index > 1, we have collected the
439                  * necessary data so we signal the thread waiting for it and
440                  * disable the capture by setting capture edge to none
441                  */
442
443                 regmap_read(pc->regmap,
444                             PWM_CPT_VAL(devicenum),
445                             &ddata->snapshot[ddata->index]);
446
447                 switch (ddata->index) {
448                 case 0:
449                 case 1:
450                         regmap_read(pc->regmap, PWM_CPT_EDGE(devicenum), &reg);
451                         reg ^= PWM_CPT_EDGE_MASK;
452                         regmap_write(pc->regmap, PWM_CPT_EDGE(devicenum), reg);
453
454                         ddata->index++;
455                         break;
456
457                 case 2:
458                         regmap_write(pc->regmap,
459                                      PWM_CPT_EDGE(devicenum),
460                                      CPT_EDGE_DISABLED);
461                         wake_up(&ddata->wait);
462                         break;
463
464                 default:
465                         dev_err(dev, "Internal error\n");
466                 }
467
468                 cpt_int_stat &= ~BIT_MASK(devicenum);
469
470                 ret = IRQ_HANDLED;
471         }
472
473         /* Just ACK everything */
474         regmap_write(pc->regmap, PWM_INT_ACK, PWM_INT_ACK_MASK);
475
476         return ret;
477 }
478
479 static int sti_pwm_probe_dt(struct sti_pwm_chip *pc)
480 {
481         struct device *dev = pc->dev;
482         const struct reg_field *reg_fields;
483         struct device_node *np = dev->of_node;
484         struct sti_pwm_compat_data *cdata = pc->cdata;
485         u32 num_devs;
486         int ret;
487
488         ret = of_property_read_u32(np, "st,pwm-num-chan", &num_devs);
489         if (!ret)
490                 cdata->pwm_num_devs = num_devs;
491
492         ret = of_property_read_u32(np, "st,capture-num-chan", &num_devs);
493         if (!ret)
494                 cdata->cpt_num_devs = num_devs;
495
496         if (!cdata->pwm_num_devs && !cdata->cpt_num_devs) {
497                 dev_err(dev, "No channels configured\n");
498                 return -EINVAL;
499         }
500
501         reg_fields = cdata->reg_fields;
502
503         pc->prescale_low = devm_regmap_field_alloc(dev, pc->regmap,
504                                         reg_fields[PWMCLK_PRESCALE_LOW]);
505         if (IS_ERR(pc->prescale_low))
506                 return PTR_ERR(pc->prescale_low);
507
508         pc->prescale_high = devm_regmap_field_alloc(dev, pc->regmap,
509                                         reg_fields[PWMCLK_PRESCALE_HIGH]);
510         if (IS_ERR(pc->prescale_high))
511                 return PTR_ERR(pc->prescale_high);
512
513
514         pc->pwm_out_en = devm_regmap_field_alloc(dev, pc->regmap,
515                                                  reg_fields[PWM_OUT_EN]);
516         if (IS_ERR(pc->pwm_out_en))
517                 return PTR_ERR(pc->pwm_out_en);
518
519         pc->pwm_cpt_en = devm_regmap_field_alloc(dev, pc->regmap,
520                                                  reg_fields[PWM_CPT_EN]);
521         if (IS_ERR(pc->pwm_cpt_en))
522                 return PTR_ERR(pc->pwm_cpt_en);
523
524         pc->pwm_cpt_int_en = devm_regmap_field_alloc(dev, pc->regmap,
525                                                 reg_fields[PWM_CPT_INT_EN]);
526         if (IS_ERR(pc->pwm_cpt_int_en))
527                 return PTR_ERR(pc->pwm_cpt_int_en);
528
529         pc->pwm_cpt_int_stat = devm_regmap_field_alloc(dev, pc->regmap,
530                                                 reg_fields[PWM_CPT_INT_STAT]);
531         if (PTR_ERR_OR_ZERO(pc->pwm_cpt_int_stat))
532                 return PTR_ERR(pc->pwm_cpt_int_stat);
533
534         return 0;
535 }
536
537 static const struct regmap_config sti_pwm_regmap_config = {
538         .reg_bits = 32,
539         .val_bits = 32,
540         .reg_stride = 4,
541 };
542
543 static int sti_pwm_probe(struct platform_device *pdev)
544 {
545         struct device *dev = &pdev->dev;
546         struct sti_pwm_compat_data *cdata;
547         struct sti_pwm_chip *pc;
548         struct resource *res;
549         unsigned int i;
550         int irq, ret;
551
552         pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
553         if (!pc)
554                 return -ENOMEM;
555
556         cdata = devm_kzalloc(dev, sizeof(*cdata), GFP_KERNEL);
557         if (!cdata)
558                 return -ENOMEM;
559
560         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
561
562         pc->mmio = devm_ioremap_resource(dev, res);
563         if (IS_ERR(pc->mmio))
564                 return PTR_ERR(pc->mmio);
565
566         pc->regmap = devm_regmap_init_mmio(dev, pc->mmio,
567                                            &sti_pwm_regmap_config);
568         if (IS_ERR(pc->regmap))
569                 return PTR_ERR(pc->regmap);
570
571         irq = platform_get_irq(pdev, 0);
572         if (irq < 0) {
573                 dev_err(&pdev->dev, "Failed to obtain IRQ\n");
574                 return irq;
575         }
576
577         ret = devm_request_irq(&pdev->dev, irq, sti_pwm_interrupt, 0,
578                                pdev->name, pc);
579         if (ret < 0) {
580                 dev_err(&pdev->dev, "Failed to request IRQ\n");
581                 return ret;
582         }
583
584         /*
585          * Setup PWM data with default values: some values could be replaced
586          * with specific ones provided from Device Tree.
587          */
588         cdata->reg_fields = sti_pwm_regfields;
589         cdata->max_prescale = 0xff;
590         cdata->max_pwm_cnt = 255;
591         cdata->pwm_num_devs = 0;
592         cdata->cpt_num_devs = 0;
593
594         pc->cdata = cdata;
595         pc->dev = dev;
596         pc->en_count = 0;
597         mutex_init(&pc->sti_pwm_lock);
598
599         ret = sti_pwm_probe_dt(pc);
600         if (ret)
601                 return ret;
602
603         if (cdata->pwm_num_devs) {
604                 pc->pwm_clk = of_clk_get_by_name(dev->of_node, "pwm");
605                 if (IS_ERR(pc->pwm_clk)) {
606                         dev_err(dev, "failed to get PWM clock\n");
607                         return PTR_ERR(pc->pwm_clk);
608                 }
609
610                 ret = clk_prepare(pc->pwm_clk);
611                 if (ret) {
612                         dev_err(dev, "failed to prepare clock\n");
613                         return ret;
614                 }
615         }
616
617         if (cdata->cpt_num_devs) {
618                 pc->cpt_clk = of_clk_get_by_name(dev->of_node, "capture");
619                 if (IS_ERR(pc->cpt_clk)) {
620                         dev_err(dev, "failed to get PWM capture clock\n");
621                         return PTR_ERR(pc->cpt_clk);
622                 }
623
624                 ret = clk_prepare(pc->cpt_clk);
625                 if (ret) {
626                         dev_err(dev, "failed to prepare clock\n");
627                         return ret;
628                 }
629
630                 cdata->ddata = devm_kzalloc(dev, cdata->cpt_num_devs * sizeof(*cdata->ddata), GFP_KERNEL);
631                 if (!cdata->ddata)
632                         return -ENOMEM;
633         }
634
635         pc->chip.dev = dev;
636         pc->chip.ops = &sti_pwm_ops;
637         pc->chip.base = -1;
638         pc->chip.npwm = pc->cdata->pwm_num_devs;
639
640         for (i = 0; i < cdata->cpt_num_devs; i++) {
641                 struct sti_cpt_ddata *ddata = &cdata->ddata[i];
642
643                 init_waitqueue_head(&ddata->wait);
644                 mutex_init(&ddata->lock);
645         }
646
647         ret = pwmchip_add(&pc->chip);
648         if (ret < 0) {
649                 clk_unprepare(pc->pwm_clk);
650                 clk_unprepare(pc->cpt_clk);
651                 return ret;
652         }
653
654         platform_set_drvdata(pdev, pc);
655
656         return 0;
657 }
658
659 static int sti_pwm_remove(struct platform_device *pdev)
660 {
661         struct sti_pwm_chip *pc = platform_get_drvdata(pdev);
662         unsigned int i;
663
664         for (i = 0; i < pc->cdata->pwm_num_devs; i++)
665                 pwm_disable(&pc->chip.pwms[i]);
666
667         clk_unprepare(pc->pwm_clk);
668         clk_unprepare(pc->cpt_clk);
669
670         return pwmchip_remove(&pc->chip);
671 }
672
673 static const struct of_device_id sti_pwm_of_match[] = {
674         { .compatible = "st,sti-pwm", },
675         { /* sentinel */ }
676 };
677 MODULE_DEVICE_TABLE(of, sti_pwm_of_match);
678
679 static struct platform_driver sti_pwm_driver = {
680         .driver = {
681                 .name = "sti-pwm",
682                 .of_match_table = sti_pwm_of_match,
683         },
684         .probe = sti_pwm_probe,
685         .remove = sti_pwm_remove,
686 };
687 module_platform_driver(sti_pwm_driver);
688
689 MODULE_AUTHOR("Ajit Pal Singh <ajitpal.singh@st.com>");
690 MODULE_DESCRIPTION("STMicroelectronics ST PWM driver");
691 MODULE_LICENSE("GPL");