hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/pwm/pwm-lpc18xx-sct.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * NXP LPC18xx State Configurable Timer - Pulse Width Modulator driver
34 *
45 * Copyright (c) 2015 Ariel D'Alessandro <ariel@vanguardiasur.com>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License.
96 *
107 * Notes
118 * =====
....@@ -296,7 +293,6 @@
296293
297294 set_bit(event, &lpc18xx_pwm->event_map);
298295 lpc18xx_data->duty_event = event;
299
- lpc18xx_pwm_config_duty(chip, pwm, pwm_get_duty_cycle(pwm));
300296
301297 return 0;
302298 }
....@@ -306,8 +302,6 @@
306302 struct lpc18xx_pwm_chip *lpc18xx_pwm = to_lpc18xx_pwm_chip(chip);
307303 struct lpc18xx_pwm_data *lpc18xx_data = pwm_get_chip_data(pwm);
308304
309
- pwm_disable(pwm);
310
- pwm_set_duty_cycle(pwm, 0);
311305 clear_bit(lpc18xx_data->duty_event, &lpc18xx_pwm->event_map);
312306 }
313307
....@@ -331,7 +325,6 @@
331325 {
332326 struct lpc18xx_pwm_chip *lpc18xx_pwm;
333327 struct pwm_device *pwm;
334
- struct resource *res;
335328 int ret, i;
336329 u64 val;
337330
....@@ -342,8 +335,7 @@
342335
343336 lpc18xx_pwm->dev = &pdev->dev;
344337
345
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
346
- lpc18xx_pwm->base = devm_ioremap_resource(&pdev->dev, res);
338
+ lpc18xx_pwm->base = devm_platform_ioremap_resource(pdev, 0);
347339 if (IS_ERR(lpc18xx_pwm->base))
348340 return PTR_ERR(lpc18xx_pwm->base);
349341
....@@ -406,12 +398,6 @@
406398 lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_LIMIT,
407399 BIT(lpc18xx_pwm->period_event));
408400
409
- ret = pwmchip_add(&lpc18xx_pwm->chip);
410
- if (ret < 0) {
411
- dev_err(&pdev->dev, "pwmchip_add failed: %d\n", ret);
412
- goto disable_pwmclk;
413
- }
414
-
415401 for (i = 0; i < lpc18xx_pwm->chip.npwm; i++) {
416402 struct lpc18xx_pwm_data *data;
417403
....@@ -421,13 +407,11 @@
421407 GFP_KERNEL);
422408 if (!data) {
423409 ret = -ENOMEM;
424
- goto remove_pwmchip;
410
+ goto disable_pwmclk;
425411 }
426412
427413 pwm_set_chip_data(pwm, data);
428414 }
429
-
430
- platform_set_drvdata(pdev, lpc18xx_pwm);
431415
432416 val = lpc18xx_pwm_readl(lpc18xx_pwm, LPC18XX_PWM_CTRL);
433417 val &= ~LPC18XX_PWM_BIDIR;
....@@ -436,10 +420,16 @@
436420 val |= LPC18XX_PWM_PRE(0);
437421 lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CTRL, val);
438422
423
+ ret = pwmchip_add(&lpc18xx_pwm->chip);
424
+ if (ret < 0) {
425
+ dev_err(&pdev->dev, "pwmchip_add failed: %d\n", ret);
426
+ goto disable_pwmclk;
427
+ }
428
+
429
+ platform_set_drvdata(pdev, lpc18xx_pwm);
430
+
439431 return 0;
440432
441
-remove_pwmchip:
442
- pwmchip_remove(&lpc18xx_pwm->chip);
443433 disable_pwmclk:
444434 clk_disable_unprepare(lpc18xx_pwm->pwm_clk);
445435 return ret;