From: Bill Pringlemeir <bpringlemeir@nbsps.com>
To: Xiubo Li <Li.Xiubo@freescale.com>
Cc: linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCHv6 1/4] pwm: Add Freescale FTM PWM driver support
Date: Thu, 19 Dec 2013 16:55:57 -0500 [thread overview]
Message-ID: <87y53gy07m.fsf@nbsps.com> (raw)
In-Reply-To: <1384220218-12716-2-git-send-email-Li.Xiubo@freescale.com> (Xiubo Li's message of "Tue, 12 Nov 2013 09:36:55 +0800")
On 11 Nov 2013, Li.Xiubo at freescale.com wrote:
> +static int fsl_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> + int duty_ns, int period_ns)
> +{
> + unsigned long period_cycles, duty_cycles;
> + unsigned long cntin = FTM_CNTIN_VAL;
> + struct fsl_pwm_chip *fpc;
> +
> + fpc = to_fsl_chip(chip);
> +
> + period_cycles = fsl_rate_to_cycles(fpc, period_ns);
> + if (period_cycles > 0xFFFF) {
> + dev_err(chip->dev, "required PWM period cycles(%lu) overflow "
> + "16-bits counter!\n", period_cycles);
> + return -EINVAL;
> + }
> +
> + duty_cycles = fsl_rate_to_cycles(fpc, duty_ns);
> + if (duty_cycles >= 0xFFFF) {
> + dev_err(chip->dev, "required PWM duty cycles(%lu) overflow "
> + "16-bits counter!\n", duty_cycles);
> + return -EINVAL;
> + }
> +
> + writel(FTMCnSC_MSB | FTMCnSC_ELSB, fpc->base + FTM_CSC(pwm->hwpwm));
> +
> + writel(0xF0, fpc->base + FTM_OUTMASK);
> + writel(0x0F, fpc->base + FTM_OUTINIT);
> + writel(FTM_CNTIN_VAL, fpc->base + FTM_CNTIN);
> +
> + writel(period_cycles + cntin - 1, fpc->base + FTM_MOD);
> + writel(duty_cycles + cntin, fpc->base + FTM_CV(pwm->hwpwm));
> +
> + return 0;
> +}
Even though the module can support eight channels, the FTM_MOD is global
and is updated in each 'config'. So, if we have two PWMs, and both call
'config' with different periods, the last one to call will win? There
doesn't seem to be any locking/inspection of 'MOD'. I think this is
global to the FTM, while 'FTM_CV()' is per channel.
So we may have 8 PWMs, all with the same period, but with different duty
cycles. Is this correct? Or are we only supporting one channel per
FTM/PWM?
Thanks,
Bill Pringlemeir.
WARNING: multiple messages have this Message-ID (diff)
From: bpringlemeir@nbsps.com (Bill Pringlemeir)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv6 1/4] pwm: Add Freescale FTM PWM driver support
Date: Thu, 19 Dec 2013 16:55:57 -0500 [thread overview]
Message-ID: <87y53gy07m.fsf@nbsps.com> (raw)
In-Reply-To: <1384220218-12716-2-git-send-email-Li.Xiubo@freescale.com> (Xiubo Li's message of "Tue, 12 Nov 2013 09:36:55 +0800")
On 11 Nov 2013, Li.Xiubo at freescale.com wrote:
> +static int fsl_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> + int duty_ns, int period_ns)
> +{
> + unsigned long period_cycles, duty_cycles;
> + unsigned long cntin = FTM_CNTIN_VAL;
> + struct fsl_pwm_chip *fpc;
> +
> + fpc = to_fsl_chip(chip);
> +
> + period_cycles = fsl_rate_to_cycles(fpc, period_ns);
> + if (period_cycles > 0xFFFF) {
> + dev_err(chip->dev, "required PWM period cycles(%lu) overflow "
> + "16-bits counter!\n", period_cycles);
> + return -EINVAL;
> + }
> +
> + duty_cycles = fsl_rate_to_cycles(fpc, duty_ns);
> + if (duty_cycles >= 0xFFFF) {
> + dev_err(chip->dev, "required PWM duty cycles(%lu) overflow "
> + "16-bits counter!\n", duty_cycles);
> + return -EINVAL;
> + }
> +
> + writel(FTMCnSC_MSB | FTMCnSC_ELSB, fpc->base + FTM_CSC(pwm->hwpwm));
> +
> + writel(0xF0, fpc->base + FTM_OUTMASK);
> + writel(0x0F, fpc->base + FTM_OUTINIT);
> + writel(FTM_CNTIN_VAL, fpc->base + FTM_CNTIN);
> +
> + writel(period_cycles + cntin - 1, fpc->base + FTM_MOD);
> + writel(duty_cycles + cntin, fpc->base + FTM_CV(pwm->hwpwm));
> +
> + return 0;
> +}
Even though the module can support eight channels, the FTM_MOD is global
and is updated in each 'config'. So, if we have two PWMs, and both call
'config' with different periods, the last one to call will win? There
doesn't seem to be any locking/inspection of 'MOD'. I think this is
global to the FTM, while 'FTM_CV()' is per channel.
So we may have 8 PWMs, all with the same period, but with different duty
cycles. Is this correct? Or are we only supporting one channel per
FTM/PWM?
Thanks,
Bill Pringlemeir.
next prev parent reply other threads:[~2013-12-19 21:55 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-12 1:36 [PATCHv6 0/4] Add Freescale FTM PWM driver Xiubo Li
2013-11-12 1:36 ` Xiubo Li
2013-11-12 1:36 ` Xiubo Li
2013-11-12 1:36 ` Xiubo Li
2013-11-12 1:36 ` [PATCHv6 1/4] pwm: Add Freescale FTM PWM driver support Xiubo Li
2013-11-12 1:36 ` Xiubo Li
2013-11-12 1:36 ` Xiubo Li
2013-11-12 1:36 ` Xiubo Li
2013-11-28 21:25 ` Thierry Reding
2013-11-28 21:25 ` Thierry Reding
2013-11-28 22:37 ` Thierry Reding
2013-11-28 22:37 ` Thierry Reding
2013-12-02 11:02 ` Mark Rutland
2013-12-02 11:02 ` Mark Rutland
2013-12-02 11:02 ` Mark Rutland
2013-12-02 11:02 ` Mark Rutland
2013-12-04 6:01 ` Li Xiubo
2013-12-04 6:01 ` Li Xiubo
2013-12-04 6:01 ` Li Xiubo
2013-11-29 5:58 ` Li Xiubo
2013-11-29 5:58 ` Li Xiubo
2013-11-29 5:58 ` Li Xiubo
2013-11-29 6:42 ` Li Xiubo
2013-11-29 6:42 ` Li Xiubo
2013-11-29 6:42 ` Li Xiubo
2013-11-29 9:22 ` Thierry Reding
2013-11-29 9:22 ` Thierry Reding
2013-11-29 9:22 ` Thierry Reding
2013-12-02 2:45 ` Li Xiubo
2013-12-02 2:45 ` Li Xiubo
2013-12-02 2:45 ` Li Xiubo
2013-12-13 9:30 ` Li.Xiubo
2013-12-13 9:30 ` Li.Xiubo
2013-12-13 9:30 ` Li.Xiubo at freescale.com
2013-12-19 21:55 ` Bill Pringlemeir [this message]
2013-12-19 21:55 ` Bill Pringlemeir
2013-12-20 7:47 ` Li.Xiubo
2013-12-20 7:47 ` Li.Xiubo at freescale.com
2013-11-12 1:36 ` [PATCHv6 2/4] ARM: dts: Add Freescale FTM PWM node for VF610 Xiubo Li
2013-11-12 1:36 ` Xiubo Li
2013-11-12 1:36 ` Xiubo Li
2013-11-28 21:26 ` Thierry Reding
2013-11-28 21:26 ` Thierry Reding
2013-11-12 1:36 ` [PATCHv6 3/4] ARM: dts: Enables FTM PWM device for Vybrid VF610 TOWER board Xiubo Li
2013-11-12 1:36 ` Xiubo Li
2013-11-12 1:36 ` Xiubo Li
2013-11-12 1:36 ` [PATCHv6 4/4] Documentation: Add device tree bindings for Freescale FTM PWM Xiubo Li
2013-11-12 1:36 ` Xiubo Li
2013-11-12 1:36 ` Xiubo Li
2013-11-28 21:32 ` Thierry Reding
2013-11-28 21:32 ` Thierry Reding
2013-12-02 7:17 ` Li Xiubo
2013-12-02 7:17 ` Li Xiubo
2013-12-03 6:56 ` Li Xiubo
2013-12-03 6:56 ` Li Xiubo
2013-12-03 6:56 ` Li Xiubo
2013-11-22 7:18 ` [PATCHv6 0/4] Add Freescale FTM PWM driver Li Xiubo
2013-11-22 7:18 ` Li Xiubo
2013-11-22 7:18 ` Li Xiubo
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=87y53gy07m.fsf@nbsps.com \
--to=bpringlemeir@nbsps.com \
--cc=Li.Xiubo@freescale.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pwm@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.