aboutsummaryrefslogtreecommitdiff
path: root/drivers/pwm/pwm-omap-dmtimer.c
AgeCommit message (Collapse)AuthorFilesLines
2021-05-25pwm: Simplify all drivers with explicit of_pwm_n_cells = 3Uwe Kleine-König1-2/+0
With the previous commit there is no need for the lowlevel driver any more to specify it it uses two or three cells. So simplify accordingly. The only non-trival change affects the pwm-rockchip driver: It used to only support three cells if the hardware supports polarity. Now the default number depends on the device tree which has to match hardware anyhow (and if it doesn't the error is just a bit delayed as a PWM handle with an inverted setting is catched when pwm_apply_state() is called). Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2021-03-22pwm: Always allocate PWM chip base ID dynamicallyUwe Kleine-König1-1/+0
Since commit 5e5da1e9fbee ("pwm: ab8500: Explicitly allocate pwm chip base dynamically") all drivers use dynamic ID allocation explicitly. New drivers are supposed to do the same, so remove support for driver specified base IDs and drop all assignments in the low-level drivers. Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2020-07-30pwm: Replace HTTP links with HTTPS onesAlexander A. Klimov1-1/+1
Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov <[email protected]> Acked-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2020-07-30pwm: omap-dmtimer: Repair pwm_omap_dmtimer_chip's broken kerneldoc headerLee Jones1-1/+1
Argument descriptions must be prepended with a '@' to be understood by the kerneldoc tooling/parsers/validators. Fixes the following W=1 warning: drivers/pwm/pwm-omap-dmtimer.c:70: warning: Function parameter or member 'dm_timer_pdev' not described in 'pwm_omap_dmtimer_chip' Cc: Tony Lindgren <[email protected]> Cc: Joachim Eastwood <[email protected]> Cc: NeilBrown <[email protected]> Cc: Grant Erickson <[email protected]> Signed-off-by: Lee Jones <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2020-03-30pwm: omap-dmtimer: Implement .apply callbackLokesh Vutla1-51/+129
Implement .apply callback and drop the legacy callbacks(enable, disable, config, set_polarity). In .apply() check for the current hardware status before changing the PWM configuration. Signed-off-by: Lokesh Vutla <[email protected]> Tested-by: Tony Lindgren <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2020-03-30pwm: omap-dmtimer: Do not disable PWM before changing period/duty_cycleLokesh Vutla1-14/+7
Only the Timer control register(TCLR) cannot be updated when the timer is running. Registers like Counter register (TCRR), loader register (TLDR) and match register (TMAR) can be updated while the counter is running. Since TCLR is not updated in pwm_omap_dmtimer_config(), do not stop the timer for period/duty_cycle update. Tested-by: Tony Lindgren <[email protected]> Signed-off-by: Lokesh Vutla <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2020-03-30pwm: omap-dmtimer: Fix PWM enabling sequenceLokesh Vutla1-5/+5
To configure DM timer in PWM mode the following needs to be set in OMAP_TIMER_CTRL_REG using set_pwm callback: - Set toggle mode on PORTIMERPWM output pin - Set trigger on overflow and match on PORTIMERPWM output pin. - Set auto reload This is a one time configuration and needs to be set before the start of the DM timer. But the current driver tries to set the same configuration for every period/duty cycle update, which is not needed. So move the PWM setup before enabling timer and do not update it in pwm_omap_dmtimer_config(). Tested-by: Tony Lindgren <[email protected]> Signed-off-by: Lokesh Vutla <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2020-03-30pwm: omap-dmtimer: Update description for PWM OMAP DM timerLokesh Vutla1-1/+9
Update the description with a brief about how PWM is generated using OMAP DM timer and add limitations for the PWM generations. Also add a link to the reference manual. Suggested-by: Uwe Kleine-König <[email protected]> Acked-by: Tony Lindgren <[email protected]> Signed-off-by: Lokesh Vutla <[email protected]> Acked-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2020-03-30pwm: omap-dmtimer: Drop unused header fileLokesh Vutla1-11/+9
pwm_omap_dmtimer.h is used only: - to typedef struct omap_dm_timer to pwm_omap_dmtimer - for macro PWM_OMAP_DMTIMER_TRIGGER_OVERFLOW_AND_COMPARE Rest of the file is pretty mush unsed. So reuse omap_dm_timer and OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE in pwm-omap-dmtimer.c and delete the header file. Acked-by: Tony Lindgren <[email protected]> Signed-off-by: Lokesh Vutla <[email protected]> Acked-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2020-03-16clocksource/drivers/timer-ti-dm: Enable autoreload in set_pwmLokesh Vutla1-3/+5
dm timer ops set_load() api allows to configure the load value and to set the auto reload feature. But auto reload feature is independent of load value and should be part of configuring pwm. This way pwm can be disabled by disabling auto reload feature using set_pwm() so that the current pwm cycle will be completed. Else pwm disabling causes the cycle to be stopped abruptly. Signed-off-by: Lokesh Vutla <[email protected]> Acked-by: Tony Lindgren <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
2020-01-20pwm: omap-dmtimer: put_device() after of_find_device_by_node()Uwe Kleine-König1-6/+15
This was found by coccicheck: drivers/pwm/pwm-omap-dmtimer.c:304:2-8: ERROR: missing put_device; call of_find_device_by_node on line 255, but without a corresponding object release within this function. Reported-by: Markus Elfring <[email protected]> Fixes: 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers") Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2020-01-20pwm: omap-dmtimer: Simplify error handlingUwe Kleine-König1-9/+19
Instead of doing error handling in the middle of ->probe(), move error handling and freeing the reference to timer to the end. This fixes a resource leak as dm_timer wasn't freed when allocating *omap failed. Implementation note: The put: label was never reached without a goto and ret being unequal to 0, so the removed return statement is fine. Fixes: 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers") Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2020-01-20pwm: omap-dmtimer: Remove PWM chip in .remove before making it unfunctionalUwe Kleine-König1-1/+6
In the old code (e.g.) mutex_destroy() was called before pwmchip_remove(). Between these two calls it is possible that a PWM callback is used which tries to grab the mutex. Fixes: 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers") Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2019-06-19treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500Thomas Gleixner1-4/+1
Based on 2 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation # extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 4122 file(s). Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Enrico Weigelt <[email protected]> Reviewed-by: Kate Stewart <[email protected]> Reviewed-by: Allison Randal <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2018-08-20pwm: omap-dmtimer: Return -EPROBE_DEFER if no dmtimer platform dataDavid Rivshin1-2/+3
If a pwm-omap-dmtimer is probed before the dmtimer it uses, the platform data won't be set yet. Fixes: ac30751df953 ("ARM: OMAP: pdata-quirks: Remove unused timer pdata") Cc: <[email protected]> # 4.17+ Signed-off-by: David Rivshin <[email protected]> Acked-by: Pavel Machek <[email protected]> Tested-by: Pavel Machek <[email protected]> Acked-by: Ladislav Michl <[email protected]> Tested-by: Andreas Kemnade <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2018-02-22pwm: pwm-omap-dmtimer: Adapt driver to utilize dmtimer pdata opsKeerthy1-26/+42
Adapt driver to utilize dmtimer pdata ops instead of pdata-quirks. Signed-off-by: Keerthy <[email protected]> Acked-by: Neil Armstrong <[email protected]> Reviewed-by: Claudiu Beznea <[email protected]> Signed-off-by: Tony Lindgren <[email protected]>
2016-06-29pwm: omap-dmtimer: Allow for setting dmtimer clock sourceIvaylo Dimitrov1-5/+7
OMAP GP timers can have different input clocks that allow different PWM frequencies. However, there is no other way of setting the clock source but through clocks or clock-names properties of the timer itself. This limits PWM functionality to only the frequencies allowed by the particular clock source. Allowing setting the clock source by PWM rather than by timer allows different PWMs to have different ranges by not hard-wiring the clock source to the timer. Signed-off-by: Ivaylo Dimitrov <[email protected]> Acked-by: Rob Herring <[email protected]> Acked-by: Thierry Reding <[email protected]> Acked-by: Pali Rohár <[email protected]> Signed-off-by: Tony Lindgren <[email protected]>
2016-05-17pwm: Use pwm_get/set_xxx() helpers where appropriateBoris Brezillon1-1/+1
Use pwm_get/set_xxx() helpers instead of directly accessing the pwm->xxx field. Doing that will ease adaptation of the PWM framework to support atomic update. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2016-03-23pwm: omap-dmtimer: Add debug message for effective period and duty cycleDavid Rivshin1-1/+8
After going through the math and constraints checking to compute load and match values, it is helpful to know what the resultant period and duty cycle are. Signed-off-by: David Rivshin <[email protected]> Acked-by: Neil Armstrong <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2016-03-23pwm: omap-dmtimer: Round load and match values rather than truncateDavid Rivshin1-5/+1
When converting period and duty_cycle from nanoseconds to fclk cycles, the error introduced by the integer division can be appreciable, especially in the case of slow fclk or short period. Use DIV_ROUND_CLOSEST_ULL() so that the error is kept to +/- 0.5 clock cycles. Fixes: 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers") Signed-off-by: David Rivshin <[email protected]> Acked-by: Neil Armstrong <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2016-03-23pwm: omap-dmtimer: Add sanity checking for load and match valuesDavid Rivshin1-4/+30
Add sanity checking to ensure that we do not program load or match values that are out of range if a user requests period or duty_cycle values which are not achievable. The match value cannot be less than the load value (but can be equal), and neither can be 0xffffffff. This means that there must be at least one fclk cycle between load and match, and another between match and overflow. Fixes: 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers") Signed-off-by: David Rivshin <[email protected]> Acked-by: Neil Armstrong <[email protected]> [[email protected]: minor coding style cleanups] Signed-off-by: Thierry Reding <[email protected]>
2016-03-23pwm: omap-dmtimer: Fix inaccurate period and duty cycle calculationsDavid Rivshin1-7/+20
Fix the calculation of load_value and match_value. Currently they are slightly too low, which produces a noticeably wrong PWM rate with sufficiently short periods (i.e. when 1/period approaches clk_rate/2). Example: clk_rate=32768Hz, period=122070ns, duty_cycle=61035ns (8192Hz/50% PWM) Correct values: load = 0xfffffffc, match = 0xfffffffd Current values: load = 0xfffffffa, match = 0xfffffffc effective PWM: period=183105ns, duty_cycle=91553ns (5461Hz/50% PWM) Fixes: 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers") Signed-off-by: David Rivshin <[email protected]> Acked-by: Neil Armstrong <[email protected]> Tested-by: Adam Ford <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2016-01-04pwm: omap-dmtimer: Potential NULL dereference on errorDan Carpenter1-1/+1
"omap" is NULL so we can't dereference it. Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2015-12-16pwm: Add PWM driver for OMAP using dual-mode timersNeil Armstrong1-0/+327
Adds support for using a OMAP dual-mode timer with PWM capability as a Linux PWM device. The driver controls the timer by using the dmtimer API. Add a platform_data structure for each pwm-omap-dmtimer nodes containing the dmtimers functions in order to get driver not rely on platform specific functions. Cc: Grant Erickson <[email protected]> Cc: NeilBrown <[email protected]> Cc: Joachim Eastwood <[email protected]> Suggested-by: Tony Lindgren <[email protected]> Signed-off-by: Neil Armstrong <[email protected]> Acked-by: Tony Lindgren <[email protected]> [[email protected]: coding style bikeshed, fix timer leak] Signed-off-by: Thierry Reding <[email protected]>