Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82278fc0 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'pwm/for-4.3-rc1' of...

Merge tag 'pwm/for-4.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm

Pull pwm updates from Thierry Reding:
 "This set of changes introduces the beginnings of a new API that's
  based around the concept of states that can be atomically applied.
  Drivers go to various lengths to implement something similar, which
  indicates that the core should really be providing the necessary
  framework.

  On top of that, there is a bit of cleanup as well as improved
  kerneldoc and integration into the device-drivers DocBook.

  Regarding drivers there is a new one for the NXP LPC18xx family of
  SoCs and a couple of fixes for existing drivers (pca9685, Broadcom
  Kona and Atmel HLCDC)"

* tag 'pwm/for-4.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm:
  ARM: at91: pwm: atmel-hlcdc: Add at91sam9n12 errata
  pwm: Add NXP LPC18xx PWM/SCT DT binding documentation
  pwm: NXP LPC18xx PWM/SCT driver
  pwm-pca9685: Support changing the output frequency
  pwm-pca9685: Fix several driver bugs
  pwm: kona: Modify settings application sequence
  pwm: pca9685: Drop owner assignment
  pwm: Add to device-drivers documentation
  pwm: Clean up kerneldoc
  pwm: Remove useless whitespace
  pwm: sysfs: Remove unnecessary padding
  pwm: sysfs: Properly convert from enum to string
  pwm: Make use of pwm_get_xxx() helpers where appropriate
  pwm: Add pwm_get_polarity() helper function
  pwm: Constify PWM device where possible
  pwm: Add the pwm_is_enabled() helper
parents bd2843fe 7a593820
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -490,4 +490,31 @@ X!Ilib/fonts/fonts.c
!Edrivers/hsi/hsi.c
  </chapter>

  <chapter id="pwm">
    <title>Pulse-Width Modulation (PWM)</title>
    <para>
      Pulse-width modulation is a modulation technique primarily used to
      control power supplied to electrical devices.
    </para>
    <para>
      The PWM framework provides an abstraction for providers and consumers
      of PWM signals. A controller that provides one or more PWM signals is
      registered as <structname>struct pwm_chip</structname>. Providers are
      expected to embed this structure in a driver-specific structure. This
      structure contains fields that describe a particular chip.
    </para>
    <para>
      A chip exposes one or more PWM signal sources, each of which exposed
      as a <structname>struct pwm_device</structname>. Operations can be
      performed on PWM devices to control the period, duty cycle, polarity
      and active state of the signal.
    </para>
    <para>
      Note that PWM devices are exclusive resources: they can always only be
      used by one consumer at a time.
    </para>
!Iinclude/linux/pwm.h
!Edrivers/pwm/core.c
  </chapter>

</book>
+20 −0
Original line number Diff line number Diff line
* NXP LPC18xx State Configurable Timer - Pulse Width Modulator driver

Required properties:
  - compatible: Should be "nxp,lpc1850-sct-pwm"
  - reg: Should contain physical base address and length of pwm registers.
  - clocks: Must contain an entry for each entry in clock-names.
    See ../clock/clock-bindings.txt for details.
  - clock-names: Must include the following entries.
    - pwm: PWM operating clock.
  - #pwm-cells: Should be 3. See pwm.txt in this directory for the description
    of the cells format.

Example:
  pwm: pwm@40000000 {
    compatible = "nxp,lpc1850-sct-pwm";
    reg = <0x40000000 0x1000>;
    clocks =<&ccu1 CLK_CPU_SCT>;
    clock-names = "pwm";
    #pwm-cells = <3>;
  };
+12 −0
Original line number Diff line number Diff line
@@ -180,6 +180,18 @@ config PWM_LP3943
	  To compile this driver as a module, choose M here: the module
	  will be called pwm-lp3943.

config PWM_LPC18XX_SCT
	tristate "LPC18xx/43xx PWM/SCT support"
	depends on ARCH_LPC18XX
	help
	  Generic PWM framework driver for NXP LPC18xx PWM/SCT which
	  supports 16 channels.
	  A maximum of 15 channels can be requested simultaneously and
	  must have the same period.

	  To compile this driver as a module, choose M here: the module
	  will be called pwm-lpc18xx-sct.

config PWM_LPC32XX
	tristate "LPC32XX PWM support"
	depends on ARCH_LPC32XX
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ obj-$(CONFIG_PWM_IMG) += pwm-img.o
obj-$(CONFIG_PWM_IMX)		+= pwm-imx.o
obj-$(CONFIG_PWM_JZ4740)	+= pwm-jz4740.o
obj-$(CONFIG_PWM_LP3943)	+= pwm-lp3943.o
obj-$(CONFIG_PWM_LPC18XX_SCT)	+= pwm-lpc18xx-sct.o
obj-$(CONFIG_PWM_LPC32XX)	+= pwm-lpc32xx.o
obj-$(CONFIG_PWM_LPSS)		+= pwm-lpss.o
obj-$(CONFIG_PWM_LPSS_PCI)	+= pwm-lpss-pci.o
+40 −9
Original line number Diff line number Diff line
@@ -200,6 +200,8 @@ static void of_pwmchip_remove(struct pwm_chip *chip)
 * pwm_set_chip_data() - set private chip data for a PWM
 * @pwm: PWM device
 * @data: pointer to chip-specific data
 *
 * Returns: 0 on success or a negative error code on failure.
 */
int pwm_set_chip_data(struct pwm_device *pwm, void *data)
{
@@ -215,6 +217,8 @@ EXPORT_SYMBOL_GPL(pwm_set_chip_data);
/**
 * pwm_get_chip_data() - get private chip data for a PWM
 * @pwm: PWM device
 *
 * Returns: A pointer to the chip-private data for the PWM device.
 */
void *pwm_get_chip_data(struct pwm_device *pwm)
{
@@ -230,6 +234,8 @@ EXPORT_SYMBOL_GPL(pwm_get_chip_data);
 * Register a new PWM chip. If chip->base < 0 then a dynamically assigned base
 * will be used. The initial polarity for all channels is specified by the
 * @polarity parameter.
 *
 * Returns: 0 on success or a negative error code on failure.
 */
int pwmchip_add_with_polarity(struct pwm_chip *chip,
			      enum pwm_polarity polarity)
@@ -291,6 +297,8 @@ EXPORT_SYMBOL_GPL(pwmchip_add_with_polarity);
 *
 * Register a new PWM chip. If chip->base < 0 then a dynamically assigned base
 * will be used. The initial polarity for all channels is normal.
 *
 * Returns: 0 on success or a negative error code on failure.
 */
int pwmchip_add(struct pwm_chip *chip)
{
@@ -304,6 +312,8 @@ EXPORT_SYMBOL_GPL(pwmchip_add);
 *
 * Removes a PWM chip. This function may return busy if the PWM chip provides
 * a PWM device that is still requested.
 *
 * Returns: 0 on success or a negative error code on failure.
 */
int pwmchip_remove(struct pwm_chip *chip)
{
@@ -338,10 +348,13 @@ EXPORT_SYMBOL_GPL(pwmchip_remove);

/**
 * pwm_request() - request a PWM device
 * @pwm_id: global PWM device index
 * @pwm: global PWM device index
 * @label: PWM device label
 *
 * This function is deprecated, use pwm_get() instead.
 *
 * Returns: A pointer to a PWM device or an ERR_PTR()-encoded error code on
 * failure.
 */
struct pwm_device *pwm_request(int pwm, const char *label)
{
@@ -376,9 +389,9 @@ EXPORT_SYMBOL_GPL(pwm_request);
 * @index: per-chip index of the PWM to request
 * @label: a literal description string of this PWM
 *
 * Returns the PWM at the given index of the given PWM chip. A negative error
 * code is returned if the index is not valid for the specified PWM chip or
 * if the PWM device cannot be requested.
 * Returns: A pointer to the PWM device at the given index of the given PWM
 * chip. A negative error code is returned if the index is not valid for the
 * specified PWM chip or if the PWM device cannot be requested.
 */
struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
					 unsigned int index,
@@ -419,6 +432,8 @@ EXPORT_SYMBOL_GPL(pwm_free);
 * @pwm: PWM device
 * @duty_ns: "on" time (in nanoseconds)
 * @period_ns: duration (in nanoseconds) of one cycle
 *
 * Returns: 0 on success or a negative error code on failure.
 */
int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
{
@@ -443,7 +458,10 @@ EXPORT_SYMBOL_GPL(pwm_config);
 * @pwm: PWM device
 * @polarity: new polarity of the PWM signal
 *
 * Note that the polarity cannot be configured while the PWM device is enabled
 * Note that the polarity cannot be configured while the PWM device is
 * enabled.
 *
 * Returns: 0 on success or a negative error code on failure.
 */
int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity)
{
@@ -455,7 +473,7 @@ int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity)
	if (!pwm->chip->ops->set_polarity)
		return -ENOSYS;

	if (test_bit(PWMF_ENABLED, &pwm->flags))
	if (pwm_is_enabled(pwm))
		return -EBUSY;

	err = pwm->chip->ops->set_polarity(pwm->chip, pwm, polarity);
@@ -471,6 +489,8 @@ EXPORT_SYMBOL_GPL(pwm_set_polarity);
/**
 * pwm_enable() - start a PWM output toggling
 * @pwm: PWM device
 *
 * Returns: 0 on success or a negative error code on failure.
 */
int pwm_enable(struct pwm_device *pwm)
{
@@ -524,6 +544,9 @@ static struct pwm_chip *of_node_to_pwmchip(struct device_node *np)
 * lookup of the PWM index. This also means that the "pwm-names" property
 * becomes mandatory for devices that look up the PWM device via the con_id
 * parameter.
 *
 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
 * error code on failure.
 */
struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
{
@@ -630,6 +653,9 @@ void pwm_remove_table(struct pwm_lookup *table, size_t num)
 *
 * Once a PWM chip has been found the specified PWM device will be requested
 * and is ready to be used.
 *
 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
 * error code on failure.
 */
struct pwm_device *pwm_get(struct device *dev, const char *con_id)
{
@@ -752,6 +778,9 @@ static void devm_pwm_release(struct device *dev, void *res)
 *
 * This function performs like pwm_get() but the acquired PWM device will
 * automatically be released on driver detach.
 *
 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
 * error code on failure.
 */
struct pwm_device *devm_pwm_get(struct device *dev, const char *con_id)
{
@@ -781,6 +810,9 @@ EXPORT_SYMBOL_GPL(devm_pwm_get);
 *
 * This function performs like of_pwm_get() but the acquired PWM device will
 * automatically be released on driver detach.
 *
 * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
 * error code on failure.
 */
struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np,
				   const char *con_id)
@@ -832,7 +864,7 @@ EXPORT_SYMBOL_GPL(devm_pwm_put);
  * pwm_can_sleep() - report whether PWM access will sleep
  * @pwm: PWM device
  *
  * It returns true if accessing the PWM can sleep, false otherwise.
  * Returns: True if accessing the PWM can sleep, false otherwise.
  */
bool pwm_can_sleep(struct pwm_device *pwm)
{
@@ -853,7 +885,7 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
		if (test_bit(PWMF_REQUESTED, &pwm->flags))
			seq_puts(s, " requested");

		if (test_bit(PWMF_ENABLED, &pwm->flags))
		if (pwm_is_enabled(pwm))
			seq_puts(s, " enabled");

		seq_puts(s, "\n");
@@ -924,6 +956,5 @@ static int __init pwm_debugfs_init(void)

	return 0;
}

subsys_initcall(pwm_debugfs_init);
#endif /* CONFIG_DEBUG_FS */
Loading