[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180809214414.20905-14-paul@crapouillou.net>
Date: Thu, 9 Aug 2018 23:44:03 +0200
From: Paul Cercueil <paul@...pouillou.net>
To: Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Thierry Reding <thierry.reding@...il.com>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Thomas Gleixner <tglx@...utronix.de>,
Wim Van Sebroeck <wim@...ux-watchdog.org>,
Guenter Roeck <linux@...ck-us.net>,
Ralf Baechle <ralf@...ux-mips.org>,
Paul Burton <paul.burton@...s.com>,
James Hogan <jhogan@...nel.org>,
Jonathan Corbet <corbet@....net>,
Lee Jones <lee.jones@...aro.org>,
Mathieu Malaterre <malat@...ian.org>,
Ezequiel Garcia <ezequiel@...labora.co.uk>
Cc: linux-pwm@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-watchdog@...r.kernel.org,
linux-mips@...ux-mips.org, linux-doc@...r.kernel.org,
linux-clk@...r.kernel.org, Paul Cercueil <paul@...pouillou.net>
Subject: [PATCH v6 13/24] pwm: jz4740: Allow selection of PWM channels 0 and 1
The TCU channels 0 and 1 were previously reserved for system tasks, and
thus unavailable for PWM.
This commit uses the newly introduced API functions of the ingenic-timer
driver to request/release the TCU channels that should be used as PWM.
This allows all the TCU channels to be used as PWM.
Signed-off-by: Paul Cercueil <paul@...pouillou.net>
---
drivers/pwm/pwm-jz4740.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
v6: New patch
diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
index 1bda8d8e9865..d08274ec007f 100644
--- a/drivers/pwm/pwm-jz4740.c
+++ b/drivers/pwm/pwm-jz4740.c
@@ -43,27 +43,30 @@ static int jz4740_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
char clk_name[16];
int ret;
- /*
- * Timers 0 and 1 are used for system tasks, so they are unavailable
- * for use as PWMs.
- */
- if (pwm->hwpwm < 2)
- return -EBUSY;
+ ret = ingenic_tcu_request_channel(pwm->hwpwm);
+ if (ret)
+ return ret;
snprintf(clk_name, sizeof(clk_name), "timer%u", pwm->hwpwm);
clk = clk_get(chip->dev, clk_name);
- if (IS_ERR(clk))
- return PTR_ERR(clk);
+ if (IS_ERR(clk)) {
+ ret = PTR_ERR(clk);
+ goto err_free_channel;
+ }
ret = clk_prepare_enable(clk);
- if (ret) {
- clk_put(clk);
- return ret;
- }
+ if (ret)
+ goto err_clk_put;
jz->clks[pwm->hwpwm] = clk;
return 0;
+
+err_clk_put:
+ clk_put(clk);
+err_free_channel:
+ ingenic_tcu_release_channel(pwm->hwpwm);
+ return ret;
}
static void jz4740_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
@@ -73,6 +76,7 @@ static void jz4740_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
clk_disable_unprepare(clk);
clk_put(clk);
+ ingenic_tcu_release_channel(pwm->hwpwm);
}
static int jz4740_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
--
2.11.0
Powered by blists - more mailing lists