summaryrefslogtreecommitdiffstats
path: root/drivers/pwm
Commit message (Collapse)AuthorAgeFilesLines
* dm: fix build errors generated by last mergesDario Binacchi2021-01-151-1/+1
| | | | | | | | | | | | | | | Something was wrong in the merge process into the mainline. Some added patches access driver structure fields and functions that have been modified by previous patches. The patch renames: - dev_get_platdata to dev_get_plat - dev_get_uclass_platdata to dev_get_uclass_plat - ofdata_to_platdata to of_to_plat - plat_data_alloc_size to plat_auto - priv_auto_alloc_size to priv_auto - video_uc_platdata to video_uc_plat Signed-off-by: Dario Binacchi <dariobin@libero.it>
* pwm: ti: am33xx: add enhanced pwm driverDario Binacchi2021-01-123-0/+476
| | | | | | | | | | | | | Enhanced high resolution PWM module (EHRPWM) hardware can be used to generate PWM output over 2 channels. This commit adds PWM driver support for EHRPWM device present on AM33XX SOC. The code is based on the drivers/pwm/pwm-tiehrpwm.c driver of the Linux kernel version 5.9-rc7. For DT binding details see: - Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt Signed-off-by: Dario Binacchi <dariobin@libero.it>
* dm: core: Access device ofnode through functionsSimon Glass2021-01-051-3/+6
| | | | | | | | At present ofnode is present in the device even if it is never used. With of-platdata this field is not used, so can be removed. In preparation for this, change the access to go through inline functions. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: treewide: Rename ofdata_to_platdata() to of_to_plat()Simon Glass2020-12-137-14/+14
| | | | | | | This name is far too long. Rename it to remove the 'data' bits. This makes it consistent with the platdata->plat rename. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: treewide: Rename auto_alloc_size members to be shorterSimon Glass2020-12-139-9/+9
| | | | | | | | | | | | This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <sjg@chromium.org>
* pwm: Add driver for Amlogic Meson PWM controllerNeil Armstrong2020-10-053-0/+536
| | | | | | | | | | | | | | | | | This adds the driver for the PWM controller found in the Amlogic SoCs. This PWM is only a set of Gates, Dividers and Counters: PWM output is achieved by calculating a clock that permits calculating two periods (low and high). The counter then has to be set to switch after N cycles for the first half period. The hardware has no "polarity" setting. This driver reverses the period cycles (the low length is inverted with the high length) for PWM_POLARITY_INVERSED. Disabling the PWM stops the output immediately (without waiting for the current period to complete first). Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
* treewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr()Masahiro Yamada2020-07-254-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Use the _ptr suffixed variant instead of casting. Also, convert it to dev_read_addr_ptr(), which is safe to CONFIG_OF_LIVE. One curious part is an error check like follows in drivers/watchdog/omap_wdt.c: priv->regs = (struct wd_timer *)devfdt_get_addr(dev); if (!priv->regs) return -EINVAL; devfdt_get_addr() returns FDT_ADDR_T_NONE (i.e. -1) on error. So, this code does not catch any error in DT parsing. dev_read_addr_ptr() returns NULL on error, so this error check will work. I generated this commit by the following command: $ find . -name .git -prune -o -name '*.[ch]' -type f -print | \ xargs sed -i -e 's/([^*)]*\*)devfdt_get_addr(/dev_read_addr_ptr(/' I manually fixed drivers/usb/host/ehci-mx6.c Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
* Revert "Merge tag 'dm-pull-20jul20' of git://git.denx.de/u-boot-dm"Tom Rini2020-07-244-4/+4
| | | | | | | | | | This reverts commit 5d3a21df6694ebd66d5c34c9d62a26edc7456fc7, reversing changes made to 56d37f1c564107e27d873181d838571b7d7860e7. Unfortunately this is causing CI failures: https://travis-ci.org/github/trini/u-boot/jobs/711313649 Signed-off-by: Tom Rini <trini@konsulko.com>
* treewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr()Masahiro Yamada2020-07-204-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Use the _ptr suffixed variant instead of casting. Also, convert it to dev_read_addr_ptr(), which is safe to CONFIG_OF_LIVE. One curious part is an error check like follows in drivers/watchdog/omap_wdt.c: priv->regs = (struct wd_timer *)devfdt_get_addr(dev); if (!priv->regs) return -EINVAL; devfdt_get_addr() returns FDT_ADDR_T_NONE (i.e. -1) on error. So, this code does not catch any error in DT parsing. dev_read_addr_ptr() returns NULL on error, so this error check will work. I generated this commit by the following command: $ find . -name .git -prune -o -name '*.[ch]' -type f -print | \ xargs sed -i -e 's/([^*)]*\*)devfdt_get_addr(/dev_read_addr_ptr(/' I manually fixed drivers/usb/host/ehci-mx6.c Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
* pwm: Add PWM driver for SiFive SoCYash Shah2020-07-093-0/+179
| | | | | | | | | | Adds a PWM driver for PWM chip present in SiFive's HiFive Unleashed SoC This driver is simple port of Linux pwm sifive driver from Linux v5.6 commit: 9e37a53eb051 ("pwm: sifive: Add a driver for SiFive SoC PWM") Signed-off-by: Yash Shah <yash.shah@sifive.com> Reviewed-by: Heiko Schocher <hs@denx.de>
* common: Drop linux/bitops.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Drop log.h from common headerSimon Glass2020-05-185-0/+5
| | | | | | Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* mediatek: pwm: add pwm driver for MediaTek SoCsSam Shih2020-04-173-0/+196
| | | | | | | This driver support the standard PWM API for MediaTek MT7623, MT7622 and MT7629 SoCs Signed-off-by: Sam Shih <sam.shih@mediatek.com>
* pwm: rk_pwm: Make PWM driver to support all Rockchip SocsDavid Wu2019-12-061-19/+119
| | | | | | | | | | | | | | | | | This PWM driver can be used to support pwm functions for on all Rockchip Socs. The previous chips than RK3288 did not support polarity, and register layout was different from the RK3288 PWM. The RK3288 keep the current functions. RK3328 and the chips after it, which can support hardware lock, configure duty, period and polarity at next same period, to prevent the intermediate temporary state. Signed-off-by: David Wu <david.wu@rock-chips.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
* pwm: imx: add DM_PWM supportHeiko Schocher2019-07-191-9/+101
| | | | | | add DM support for pwm-imx driver. Signed-off-by: Heiko Schocher <hs@denx.de>
* pwm: imx: add Kconfig supportHeiko Schocher2019-07-191-0/+5
| | | | | | | add Kconfig support for this driver. Signed-off-by: Heiko Schocher <hs@denx.de> Acked-by: Martyn Welch <martyn.welch@collabora.co.uk>
* rockchip: use 'arch-rockchip' as header file pathKever Yang2019-05-011-1/+1
| | | | | | | | Rockchip use 'arch-rockchip' instead of arch-$(SOC) as common header file path, so that we can get the correct path directly. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
* pwm: sunxi: choose best prescaler to improve PWM resolutionVasily Khoruzhick2018-10-241-13/+19
| | | | | | | | | | | Choose best prescaler to improve PWM resolution. Without this change driver chooses first prescaler that gives us period value within range, but it could be not the best one. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Tested-by: Vagrant Cascadian <vagrant@debian.org> Acked-by: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Jagan Teki <jagan@openedev.com>
* pwm: sunxi: use new prescaler when configuring PWMVasily Khoruzhick2018-10-241-1/+1
| | | | | | | | Looks like old prescaler was used when configuring PWM, fix it. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Acked-by: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Jagan Teki <jagan@openedev.com>
* pwm: sunxi: fix off-by-one that prevented PWM to use prescaler bypassVasily Khoruzhick2018-10-241-1/+1
| | | | | | | | | Fix off-by-one that prevented PWM driver to use prescaler bypass. Without this change prescaler is always enabled. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Acked-by: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Jagan Teki <jagan@openedev.com>
* test: panel: Add a test for the panel uclassSimon Glass2018-10-091-0/+25
| | | | | | | At present this uclass has no tests. Add a simple one which checks the PWM configuration, regulator and GPIO. Signed-off-by: Simon Glass <sjg@chromium.org>
* pwm: sunxi: add support for PWM found on Allwinner A64Vasily Khoruzhick2018-05-153-0/+186
| | | | | | | This commit adds basic support for PWM found on Allwinner A64. It can be used for pwm_backlight driver (e.g. for Pinebook) Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
* SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini2018-05-079-19/+9
| | | | | | | | | | | | | | | | | | | | When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
* Remove unnecessary instances of DECLARE_GLOBAL_DATA_PTRTom Rini2018-04-274-8/+0
| | | | | | | | We have a large number of places where while we historically referenced gd in the code we no longer do, as well as cases where the code added that line "just in case" during development and never dropped it. Signed-off-by: Tom Rini <trini@konsulko.com>
* rockchip: pwm: convert to use live dtKever Yang2018-03-131-1/+1
| | | | | | | | use live dt api to get base addr Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
* pwm: imx: Enable PWM support on i.MX53Martyn Welch2017-11-201-0/+2
| | | | | | | | | Add missing parts for i.MX53 PWM support Acked-by: Nandor Han <nandor.han@ge.com> Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk> Cc: Stefano Babic <sbabic@denx.de> Acked-by: Stefano Babic <sbabic@denx.de>
* dm: tegra: pwm: Convert to livetreeSimon Glass2017-07-281-1/+1
| | | | | | | | | Update the tegra pwm driver to support a live device tree. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1 Tested-by: Stephen Warren <swarren@nvidia.com>
* rockchip: pwm: add mask for config settingKever Yang2017-07-271-0/+1
| | | | | | | | | | | Use mask to clear old setting before direct set the new config, or else there it will mess up the config when it's not the same with default value. Fixes: 3851059 rockchip: Setup default PWM flags Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
* rockchip: Setup default PWM flagsSimon Glass2017-06-091-0/+1
| | | | | | | At present if the Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: 874ee59 (rockchip: pwm: implement pwm_set_invert())
* dm: Rename dev_addr..() functionsSimon Glass2017-06-013-3/+3
| | | | | | | | | | | | | | | | | | | These support the flat device tree. We want to use the dev_read_..() prefix for functions that support both flat tree and live tree. So rename the existing functions to avoid confusion. In the end we will have: 1. dev_read_addr...() - works on devices, supports flat/live tree 2. devfdt_get_addr...() - current functions, flat tree only 3. of_get_address() etc. - new functions, live tree only All drivers will be written to use 1. That function will in turn call either 2 or 3 depending on whether the flat or live tree is in use. Note this involves changing some dead code - the imx_lpi2c.c file. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: sandbox: pwm: add test for pwm_set_invert()Kever Yang2017-05-101-0/+16
| | | | | | | | | Add test case for new interface set_invert(). Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org> Fix typo in subject and build error in sandbox_pwm_set_invert(): Signed-off-by: Simon Glass <sjg@chromium.org>
* rockchip: pwm: implement pwm_set_invert()Kever Yang2017-05-101-1/+16
| | | | | | | | Rockchip pwm need to init polarity, implement pwm_set_invert() to do it. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
* power: regulator: pwm: support pwm polarity settingKever Yang2017-05-101-0/+10
| | | | | | | | | | | | | The latest kernel PWM drivers enable the polarity settings. When system run from U-Boot to kerenl, if there are differences in polarity set or duty cycle, the PMW will re-init: close -> set polarity and duty cycle -> enable the PWM. The power supply controled by pwm regulator may have voltage shaking, which lead to the system not stable. Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com> Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
* dm: sandbox: pwm: Add a basic pwm testSimon Glass2017-04-273-0/+84
| | | | | | | | | | | Unfortunately a test for the PWM uclass was not included when it was submitted. This was noticed when trying to add more functionality: http://patchwork.ozlabs.org/patch/748172/ Add a simple test to get us started. Signed-off-by: Simon Glass <sjg@chromium.org>
* pwm: remove unneeded ifdef CONFIG_DM_PWM ... endifMasahiro Yamada2017-02-081-7/+6
| | | | | | | | | | | | Both CONFIG_PWM_TEGRA and CONFIG_PWM_EXYNOS depend on CONFIG_DM_PWM, i.e. they are already guarded by Kconfig correctly. Remove unneeded ifdef CONFIG_DM_PWM ... endif. While we are here, let's tidy up alignment and sort the lines alphabetically in Makefile. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* pwm: imx: increase support up to PWM8 for i.MX6SXChristoph Fritz2016-11-291-1/+11
| | | | | | | This patch increases supported PWMs from previously PWM4 now up to PWM8 if i.MX6SX is in use. Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
* PWM: Correct misspellings of "module" in context of PWMRobert P. J. Day2016-10-063-3/+3
| | | | | Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca> Acked-by: Heiko Schocher <hs@denx.de>
* rk_pwm: remove grf setting code from driverKever Yang2016-09-221-11/+0
| | | | | | | | | We consider the grf setting for pwm controller select as the system operation instead of driver operation, move it to soc init, let's remove it from pwm driver first. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org>
* rk_pwm: use clock framework API to get module clockKever Yang2016-09-221-3/+14
| | | | | | | | | This patch use clock API instead of hardcode for get pwm clock. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org> Fix printf() to debug() nit: Signed-off-by: Simon Glass <sjg@chromium.org>
* exynos: pwm: Add a driver for the exynos5 PWMSimon Glass2016-05-253-0/+130
| | | | | | | | This driver supports the standard PWM API. There are 5 PWMs. Four are used normally and the last is normally used as a timer. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
* tegra: video: Move LCD driver to use the DM PWM driverSimon Glass2016-02-161-0/+1
| | | | | | | | Use the driver-model PWM driver in preference to the old code. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Anatolij Gustschin <agust@denx.de> Signed-off-by: Tom Warren <twarren@nvidia.com>
* tegra: Convert CONFIG_PWM_TEGRA to KconfigSimon Glass2016-02-161-0/+8
| | | | | | | | Move this option to Kconfig and clean up the header files. Adjust the only user (the LCD driver) to work with the new driver. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>
* tegra: pwm: Add a driver for the tegra PWMSimon Glass2016-02-162-0/+88
| | | | | | | | This PWM supports four channels. The driver always uses the 32KHz clock, and adjusts the duty cycle accordingly. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>
* pwm: rockchip: Add a PWM driver for Rockchip SoCsSimon Glass2016-01-213-0/+113
| | | | | | Add a simple driver which implements the standard PWM uclass interface. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: pwm: Add a PWM uclassSimon Glass2016-01-213-0/+47
| | | | | | | Add a uclass that supports Pulse Width Modulation (PWM) devices. It provides methods to enable/disable and configure the device. Signed-off-by: Simon Glass <sjg@chromium.org>
* pwm: imx: Remove unreachable codeAxel Lin2015-05-261-4/+0
| | | | | | | | The break after return is unreachable code, remove it. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Stefano Babic <sbabic@denx.de> Acked-by: Heiko Schocher <hs@denx.de>
* pwm: imx: Prevent NULL pointer dereferenceAxel Lin2015-05-261-0/+12
| | | | | | | | | pwm_id_to_reg() can return NULL, so add NULL testing to prevent NULL pointer dereference. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Stefano Babic <sbabic@denx.de> Acked-by: Heiko Schocher <hs@denx.de>
* bugfix i.mx6 pwm: prevent overflow of period_c * duty_nsBrecht Neyrinck2015-05-151-1/+1
| | | | | | | Prevent overflow by casting duty_ns to ull first. This bug came up when trying to create a 200 Hz PWM Signed-off-by: Brecht Neyrinck <bnrn@psicontrol.com> Acked-by: Heiko Schocher<hs@denx.de>
* pwm, imx6: add support for pwm modul on imx6Heiko Schocher2014-07-234-0/+161
add basic support for the pwm modul found on imx6. Pieces of this code are based on linux code from drivers/pwm/pwm-imx.c Commit "cd3de83f1476 Linux 3.16-rc4" Signed-off-by: Heiko Schocher <hs@denx.de> Acked-by: Stefano Babic <sbabic@denx.de> Cc: Wolfgang Denk <wd@denx.de>