Linux PWM subsystem development
 help / color / mirror / Atom feed
From: Clemens Gruber <clemens.gruber@pqgruber.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-pwm@vger.kernel.org
Subject: Configuring multiple PWM channels in one step
Date: Fri, 21 Oct 2016 19:30:19 +0200	[thread overview]
Message-ID: <20161021173019.GA24301@archie.localdomain> (raw)

Hi,

we control flow valves through PCA9685 PWM chips and the duty cycle
values are changing continuously.
With the current PWM API, every duty cycle change is sent out
individually to the I2C bus.

What do you think about a config_multiple feature to atomically set the
duty cycles of several channels in one step?
(Somewhat similar to the set_multiple function in struct gpio_chip)

Some pwm chips have special registers to configure subsets of outputs at
once. But even if that's not available, sending the values for multiple
channels in one step is an improvement, especially on a slow bus.

One possibility would be to add a new structure to atomically configure
all outputs of a pwm chip:

I'd only make the duty cycle (and maybe the enabled state) individually
configurable. Period and polarity should be set for all, because on many
chips, these are chip-wide settings.

struct pwm_chip_state {
	unsigned int period;
	unsigned int *duty_cycles;
	enum pwm_polarity polarity;
	unsigned int enabled_mask;
};

Then adding a pwm_chip_apply_state function which takes a pointer to the
struct pwm_chip and the struct pwm_chip_state.

For the drivers we would need a .config_multiple function in pwm_ops.
Maybe something like:
int (*config_multiple)(struct pwm_chip *chip, unsigned int change_mask,
unsigned int *duty_cycles_ns, unsigned int enabled_mask,
unsigned int period_ns, enum pwm_polarity polarity);
And if there is no implementation, a fallback to configure it
sequentially.

--

Or am I going in the wrong direction here, with this idea?

Thanks,
Clemens

                 reply	other threads:[~2016-10-21 17:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161021173019.GA24301@archie.localdomain \
    --to=clemens.gruber@pqgruber.com \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox