All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten ter Huurne <maarten@treewalker.org>
To: Thierry Reding <thierry.reding@avionic-design.de>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	Antony Pavlov <antonynpavlov@gmail.com>,
	Lars-Peter Clausen <lars@metafoo.de>
Subject: Re: [PATCH 0/3] MIPS: JZ4740: Move PWM driver to PWM framework
Date: Sun, 02 Sep 2012 15:25:55 +0200	[thread overview]
Message-ID: <1890769.KjIbOv8Xbz@hyperion> (raw)
In-Reply-To: <1346579550-5990-1-git-send-email-thierry.reding@avionic-design.de>

[-- Attachment #1: Type: text/plain, Size: 1723 bytes --]

On Sunday 02 September 2012 11:52:27 Thierry Reding wrote:

> This small series fixes a build error due to a circular header
> dependency, exports the timer API so it can be used outside of
> the arch/mips/jz4740 tree and finally moves and converts the
> JZ4740 PWM driver to the PWM framework.
> 
> Note that I don't have any hardware to test this on, so I had to
> rely on compile tests only. Patches 1 and 2 should probably go
> through the MIPS tree, while I can take patch 3 through the PWM
> tree. It touches a couple of files in arch/mips but the changes
> are unlikely to cause conflicts.

Exporting the hardware outputs PWM2-7 as index 0-5 in the PWM core is rather 
confusing. I discussed with Lars on IRC and it's probably better to expose 
PWM0-7 through the API, but refuse to hand out PWM0 and PWM1 when requested, 
since their associated timers are in use by the system. I attached a diff 
that illustrates this approach.

Note that if this approach is taken, the beeper ID in board-qi_lb60.c should 
be changed back from 2 to 4, since the beeper is attached to PWM4.

I tested the "for-next" branch on the Dingoo A320 with the pwm-backlight 
driver. It didn't work at first, because the PWM number and the timer number 
didn't align: I requested PWM number 5 to get PWM7 and the GPIO of PWM7 was 
used, but with timer 5 instead of timer 7, resulting in a dark screen. 
However, it works fine after adding PWM0/1 as described above.

If other people want to test on real hardware, you can find the code in 
branch jz-3.6-rc2-pwm in the qi-kernel repository. Unfortunately our web 
interface for git is still broken, but the repo itself is fine.
  git://projects.qi-hardware.com/qi-kernel.git

Bye,
		Maarten

[-- Attachment #2: jz4740-pwm-all-8.diff --]
[-- Type: text/x-patch, Size: 779 bytes --]

diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
index db29b37..554e414 100644
--- a/drivers/pwm/pwm-jz4740.c
+++ b/drivers/pwm/pwm-jz4740.c
@@ -24,9 +24,11 @@
 #include <asm/mach-jz4740/gpio.h>
 #include <timer.h>
 
-#define NUM_PWM 6
+#define NUM_PWM 8
 
 static const unsigned int jz4740_pwm_gpio_list[NUM_PWM] = {
+	JZ_GPIO_PWM0,
+	JZ_GPIO_PWM1,
 	JZ_GPIO_PWM2,
 	JZ_GPIO_PWM3,
 	JZ_GPIO_PWM4,
@@ -50,6 +52,13 @@ static int jz4740_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
 	unsigned int gpio = jz4740_pwm_gpio_list[pwm->hwpwm];
 	int ret;
 
+	/*
+	 * Timer 0 and 1 are used for system tasks, so they are unavailable
+	 * for use as PWMs.
+	 */
+	if (pwm->hwpwm < 2)
+		return -EBUSY;
+
 	ret = gpio_request(gpio, pwm->label);
 
 	if (ret) {

  parent reply	other threads:[~2012-09-02 13:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-02  9:52 [PATCH 0/3] MIPS: JZ4740: Move PWM driver to PWM framework Thierry Reding
2012-09-02  9:52 ` [PATCH 1/3] MIPS: JZ4740: Break circular header dependency Thierry Reding
2012-09-02 14:48   ` Lars-Peter Clausen
2012-09-02 19:16     ` Thierry Reding
2012-09-02  9:52 ` [PATCH 2/3] MIPS: JZ4740: Export timer API Thierry Reding
2012-09-02 14:45   ` Lars-Peter Clausen
2012-09-02 20:21     ` Thierry Reding
2012-09-02 20:27       ` Lars-Peter Clausen
2012-09-02 20:46         ` Thierry Reding
2012-09-02  9:52 ` [PATCH 3/3] pwm: Add Ingenic JZ4740 support Thierry Reding
2012-09-02 14:44   ` Lars-Peter Clausen
2012-09-02 19:59     ` Thierry Reding
2012-09-02 20:22       ` Lars-Peter Clausen
2012-09-02 20:37         ` Thierry Reding
2012-09-02 13:25 ` Maarten ter Huurne [this message]
2012-09-02 19:27   ` [PATCH 0/3] MIPS: JZ4740: Move PWM driver to PWM framework Thierry Reding
2012-09-02 21:34     ` Maarten ter Huurne

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=1890769.KjIbOv8Xbz@hyperion \
    --to=maarten@treewalker.org \
    --cc=antonynpavlov@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=thierry.reding@avionic-design.de \
    /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.