summaryrefslogtreecommitdiffstats
path: root/drivers/pwm
Commit message (Collapse)AuthorAgeFilesLines
* pwm: atmel: point MMIO accesses at correct addressAhmad Fatoum2022-01-051-1/+1
| | | | | | | | | | | | | | The base address for MMIO writes was the address of the resource struct, not the start address pointed at by it. Change untested, but it doesn't look like this driver could ever have worked. Cc: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Link: https://lore.barebox.org/20220103115718.1723730-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: migrate "GPL-2.0" license identifiers to SPDX 2.0Roland Hieber2021-11-225-5/+5
| | | | | | | | | | "GPL-2.0-only" was introduced in SPDX 2.0, and the old identifier "GPL-2.0" is now considered deprecated; see <https://spdx.org/licenses>. Fixes: 28f4a6a4df76f0f1581d (2021-10-30, "drivers: add missing SPDX-License-Identifier") Signed-off-by: Roland Hieber <rhi@pengutronix.de> Link: https://lore.barebox.org/20211117113851.2022669-2-rhi@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/spdx'Sascha Hauer2021-11-154-6/+4
|\
| * drivers: add missing SPDX-License-IdentifierAhmad Fatoum2021-11-014-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the suitable SPDX-License-Identifier to all files in drivers/ that previously lacked one. To aid manual inspection, following heuristics can be used: * No changes outside of comments/whitespace: git show -U0 HEAD | rg -v '^(@@|diff|index)|[-+]([-+]|//|#|[\s/]\*)' * -or-later come in pairs: git show --inter-hunk-context=19 HEAD | \ perl -0777 -F'/^@/gm' -ne 'for (@F) { @m = /later/g; print if @m & 1 }' Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175632.2276077-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | include: add dedicated header for printf/printkAhmad Fatoum2021-11-011-1/+1
|/ | | | | | | | | | | | Including <stdio.h> for printf is a bit problematic, because it pulls in other headers for <console.h>, which includes quite a few more headers as well. To make it easier to share code between barebox and host tools make <printk.h> the new minimal header for printf and move the extra logging stuff into <linux/printk.h>. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030141739.2207431-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pwm: add pwm-atmel from Linux kernel 4.14Sam Ravnborg2021-04-133-0/+296
| | | | | | | | | | | | This add the pwm-atmel.c file from kernel 4.14, modified for barebox use. The code is modelled over pwm-mxs. pwm-atmel is required to support PWM's used on a board with AT91SAM9263 - controlling backlight and contrast. Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
* treewide: include <linux/math64.h> wrapper instead of <asm-generic/div64.h>Ahmad Fatoum2021-02-193-3/+3
| | | | | | | | | | | <asm-generic/div64.h> isn't meant for direct usage as <asm/div64.h> may override this on a per-architecture basis. We don't do that currently, but in the future we might. Include the <linux/math64.h> instead. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: make use of PTR_ERR_OR_ZEROUwe Kleine-König2020-06-261-4/+1
| | | | | | | | | | | PTR_ERR_OR_ZERO is designed to replace boiler plate like: if (IS_ERR(x)) return PTR_ERR(x); return 0; Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pwm: Replace license and copyright boilerplate by SPDX identfiersUwe Kleine-König2020-05-253-26/+7
| | | | | | | | | | | | This adapts all files that were identifed by licensecheck (https://salsa.debian.org/build-common-team/licensecheck.git) as licensed under the GPL and that have a (IMHO) clear copyright statement. The advantage is that these specifiers are machine-parseable which helps license conformance, e.g. for packaging barebox in Debian. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: mark first batch of compilable drivers for COMPILE_TESTAhmad Fatoum2020-05-081-2/+2
| | | | | | | | | All of these drivers have a runtime dependency on SoC peripherals, but can nevertheless be compile-tested. Add COMPILE_TEST as an alternate dependency. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: explicitly select dependency STMP_DEVICE for i.MX23/28 driversAhmad Fatoum2020-05-081-0/+1
| | | | | | | | | | | | | Some of the i.MXs drivers can be build tested even if building for other platforms. Support adding a future COMPILE_TEST dependency to some of these drivers by explicitly having their Kconfig symbol select STMP_DEVICE if the driver calls stmp_reset_block. This has not been necessary for the normal build, because the ARCH symbols for the IMX23 and IMX28 already selected STMP_DEVICE. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: add support for STM32Ahmad Fatoum2020-03-313-0/+407
| | | | | | | | This driver adds support for PWM driver on STM32 platform based on the Linux v5.4 support. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: core: add apply API support for polarityAhmad Fatoum2020-03-311-4/+17
| | | | | | | | Some PWM chips support outputting an inverted PWM signal. Add API support for this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: core: apply initial state in of_pwm_requestAhmad Fatoum2020-03-311-4/+66
| | | | | | | | | | | | This functions prepares a state that can later be tweaked and applied to the PWM device with pwm_apply_state(). This is a convenient function that first retrieves the current PWM state and the replaces the period with the reference values defined in pwm->args. Once the function returns, you can adjust the ->enabled and ->duty_cycle fields according to your needs before calling pwm_apply_state(). Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: core: retire pwm_set_periodAhmad Fatoum2020-03-311-6/+1
| | | | | | | | Client code can use pwm_apply_state or pwm_config to set period as well as duty cycle. Having a pwm_set_period thus doesn't add any value. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: core: remove old PWM API in favor of Linux ->applyAhmad Fatoum2020-03-314-103/+125
| | | | | | | | | Linux has the new atomic PWM API in addition to the old one for backward compatibility. We only have three PWM drivers in here, so port them over to the new ->apply API. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: core: group PWM state into new struct pwm_stateAhmad Fatoum2020-03-311-18/+16
| | | | | | | | As a prerequisite for moving to the new apply API, we need to group all state into one struct that we can apply at once. Prepare for this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: core: remove ineffectual pwm_{set,get}_duty_cycleAhmad Fatoum2020-03-311-10/+0
| | | | | | | | | The setter sets a value unused anywhere, but in the getter. As the functions are unused, just drop them. There's pwm_config that can be used for this instead. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: core: remove FLAG_ENABLEDAhmad Fatoum2020-03-311-4/+8
| | | | | | | | In preparation for moving to a struct pwm_state like Linux does, turn the flag into a variable. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: pxa: make MMIO writes always little endianAhmad Fatoum2020-02-101-3/+3
| | | | | | | | Even when the processor runs in big-endian mode, the peripheral is little-endian and is used as such in Linux. Do here likewise. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: pxa: remove unused struct membersAhmad Fatoum2020-02-101-5/+0
| | | | | | | Both duty_ns and period_ns are stored to, but never read. Drop them. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-1/+1
| | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* param: make parameter functions more consistentSascha Hauer2017-04-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | This patch creates a consitent set of device parameter functions. With this we have: dev_add_param_<type><access> "type" is one of: int32, uint32, int64, uint64, string, mac, ipv4, enum, bitmask The improvement here is that we now can exactly specify the width of the int type parameters and also correctly distinguish between signed and unsigned variables which means that a variable no longer ends up with INT_MAX when it's assigned -1. "access" can be empty for regular read/write parameter, "_ro" for readonly parameters which get their value from a variable pointer in the background or "_fixed" for parameters which are set to a fixed value (without a pointer in the background). Some more exotic types are not (yet) implemented, like dev_add_param_ip_ro. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: update enable status when using the internal APIJan Luebbe2017-01-101-0/+4
| | | | | | | | Without these, 'devinfo pwmX' will show enabled=0 even though the PWM was enabled (for example by a pwm-backlight). Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* string: Fix (v)asprintf prototypesSascha Hauer2016-04-153-4/+5
| | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: replace dev_request_mem_region with dev_request_mem_resourceSascha Hauer2016-03-073-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // <smpl> @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: Add MXS PWM supportSascha Hauer2015-06-123-0/+181
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: Allow multiple PWMs per device nodeSascha Hauer2015-06-121-3/+4
| | | | | | | Matching a device node is enough since a device node may have multiple PWMs. Check for a id aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 2011 barebox' of_device_id struct uses unsigned long type for data field: struct of_device_id { char *compatible; unsigned long data; }; Almost always struct of_device_id.data field are used as pointer and need 'unsigned long' casting. E.g. see 'git grep -A 4 of_device_id drivers/' output: drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = { drivers/ata/sata-imx.c- { drivers/ata/sata-imx.c- .compatible = "fsl,imx6q-ahci", drivers/ata/sata-imx.c- .data = (unsigned long)&data_imx6, drivers/ata/sata-imx.c- }, { Here is of_device_id struct in linux kernel v4.0: struct of_device_id { char name[32]; char type[32]; char compatible[128]; const void *data; }; Changing of_device_id.data type to 'const void *data' will increase barebox' linux kernel compatibility and decrease number of 'unsigned long' casts. Part of the patch was done using the 'coccinelle' tool with the following semantic patch: @rule1@ identifier dev; identifier type; identifier func; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type) + dev_get_drvdata(dev, (const void **)&type) ...> } @rule2@ identifier dev; identifier type; identifier func; identifier data; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type->data) + dev_get_drvdata(dev, (const void **)&type->data) ...> } Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: i.MX: register successfully without aliasSascha Hauer2015-03-091-8/+6
| | | | | | | When a PWM does not have an of alias generate a name from the base address so that we can register it successfully. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* resource: Let dev_request_mem_region return an error pointerSascha Hauer2014-09-161-2/+3
| | | | | | For all users fix or add the error check. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: Implement devicetree supportSascha Hauer2014-02-281-7/+64
| | | | | | This implements of_pwm_request() for PWM client drivers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: Add functions for getting/setting period/duty cycleSascha Hauer2014-02-281-0/+20
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: Add i.MX PWM driverSascha Hauer2014-02-143-1/+270
| | | | | | | The Kernel driver from Linux-3.13 with some adjustments for barebox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: pxa: use pwmx as devnameSascha Hauer2014-02-141-1/+1
| | | | | | | As this changes the name of the pwm we also have to adjust it in pwm_request. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* PWM: Use a separate device for PWMsSascha Hauer2014-02-131-5/+15
| | | | | | | | Instead of directly using the hardware devicet for PWMs register a logical PWM device so that the user operates on pwmx devices rather than pxa-pwmx. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pwm: sanity check values before passing them to the driversSascha Hauer2013-09-271-0/+7
| | | | | | | | | Check for valid period size before calling ops->config. This fixes the pxa driver which otherwise does a division by zero. While at it, also check for duty_ns being smaller or equal to period_ns. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Cc: Robert Jarzmik <robert.jarzmik@free.fr>
* pwm: Use dev_add_param_int for pwm parametersSascha Hauer2013-04-111-59/+30
| | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Cc: Robert Jarzmik <robert.jarzmik@free.fr>
* switch all platform_bus device/driver registering to ↵Jean-Christophe PLAGNIOL-VILLARD2012-10-041-1/+1
| | | | | | | | platform_driver/device_register now register_driver and register_device are for bus only usage. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-4/+0
| | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pwm PXA: Compile only on PXASascha Hauer2012-07-251-0/+1
| | | | | | | The PXA PWM driver does not compile on any other architecture, so depend on PXA. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers/pwm: add PXA pulse width modulator controllerRobert Jarzmik2012-02-173-0/+164
| | | | | | | | | Add PXA embedded pulse width modulator support. The PWM can generate signals from 49.6kHz to 1.625MHz. The driver is for pxa2xx family. The pxa3xx was not handled yet. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers/pwm: add duty_ns and period_ns to core pwm chipRobert Jarzmik2012-02-171-1/+75
| | | | | | | | | | Add variables to control the duty_ns and period_ns of PWM chips. When these variables are set, a call to either pwm_enable() or pwm_config() is performed to enforce the setup values. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add pwm core supportSascha Hauer2012-02-173-0/+176
This patch adds framework support for PWM (pulse width modulation) devices. A new pwm can be registered from a hardware driver using pwmchip_add(). It can then be requested from a client driver using pwm_request(). A string is used as a unique identifier for the pwms. It should usually be initialized by the hardware drivers using dev_name(dev). The client API is the same as currently in the Linux Kernel. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>