LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/5] dt-bindings: Remove unused compatible strings
@ 2019-05-21 15:34 Paul Cercueil
2019-05-21 15:34 ` [PATCH 2/5] pwm: jz4740: Remove unused devicetree " Paul Cercueil
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Paul Cercueil @ 2019-05-21 15:34 UTC (permalink / raw)
To: Thierry Reding, Rob Herring, Mark Rutland
Cc: od, linux-pwm, devicetree, linux-kernel, Paul Cercueil
Right now none of the Ingenic-based boards probe this driver from
devicetree. This driver defined three compatible strings for the exact
same behaviour. Before these strings are used, we can remove two of
them.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
Documentation/devicetree/bindings/pwm/ingenic,jz47xx-pwm.txt | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/pwm/ingenic,jz47xx-pwm.txt b/Documentation/devicetree/bindings/pwm/ingenic,jz47xx-pwm.txt
index 7d9d3f90641b..493bec80d59b 100644
--- a/Documentation/devicetree/bindings/pwm/ingenic,jz47xx-pwm.txt
+++ b/Documentation/devicetree/bindings/pwm/ingenic,jz47xx-pwm.txt
@@ -2,10 +2,7 @@ Ingenic JZ47xx PWM Controller
=============================
Required properties:
-- compatible: One of:
- * "ingenic,jz4740-pwm"
- * "ingenic,jz4770-pwm"
- * "ingenic,jz4780-pwm"
+- compatible: Should be "ingenic,jz4740-pwm"
- #pwm-cells: Should be 3. See pwm.txt in this directory for a description
of the cells format.
- clocks : phandle to the external clock.
--
2.21.0.593.g511ec345e18
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/5] pwm: jz4740: Remove unused devicetree compatible strings
2019-05-21 15:34 [PATCH 1/5] dt-bindings: Remove unused compatible strings Paul Cercueil
@ 2019-05-21 15:34 ` Paul Cercueil
2019-05-21 15:34 ` [PATCH 3/5] pwm: jz4740: Apply configuration atomically Paul Cercueil
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Paul Cercueil @ 2019-05-21 15:34 UTC (permalink / raw)
To: Thierry Reding, Rob Herring, Mark Rutland
Cc: od, linux-pwm, devicetree, linux-kernel, Paul Cercueil
Right now none of the Ingenic-based boards probe this driver from
devicetree. This driver defined three compatible strings for the exact
same behaviour. Before these strings are used, we can remove two of
them.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
drivers/pwm/pwm-jz4740.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
index a7b134af5e04..c274136613c8 100644
--- a/drivers/pwm/pwm-jz4740.c
+++ b/drivers/pwm/pwm-jz4740.c
@@ -193,8 +193,6 @@ static int jz4740_pwm_remove(struct platform_device *pdev)
#ifdef CONFIG_OF
static const struct of_device_id jz4740_pwm_dt_ids[] = {
{ .compatible = "ingenic,jz4740-pwm", },
- { .compatible = "ingenic,jz4770-pwm", },
- { .compatible = "ingenic,jz4780-pwm", },
{},
};
MODULE_DEVICE_TABLE(of, jz4740_pwm_dt_ids);
--
2.21.0.593.g511ec345e18
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/5] pwm: jz4740: Apply configuration atomically
2019-05-21 15:34 [PATCH 1/5] dt-bindings: Remove unused compatible strings Paul Cercueil
2019-05-21 15:34 ` [PATCH 2/5] pwm: jz4740: Remove unused devicetree " Paul Cercueil
@ 2019-05-21 15:34 ` Paul Cercueil
2019-05-21 15:34 ` [PATCH 4/5] pwm: jz4740: Drop dependency on MACH_INGENIC Paul Cercueil
2019-05-21 15:34 ` [PATCH 5/5] pwm: jz4740: Switch to SPDX license identifier Paul Cercueil
3 siblings, 0 replies; 5+ messages in thread
From: Paul Cercueil @ 2019-05-21 15:34 UTC (permalink / raw)
To: Thierry Reding, Rob Herring, Mark Rutland
Cc: od, linux-pwm, devicetree, linux-kernel, Paul Cercueil
This is cleaner, more future-proof, and incidentally it also fixes the
PWM resetting its config when stopped/started several times.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
drivers/pwm/pwm-jz4740.c | 37 ++++++++++++-------------------------
1 file changed, 12 insertions(+), 25 deletions(-)
diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
index c274136613c8..e73ee72df09d 100644
--- a/drivers/pwm/pwm-jz4740.c
+++ b/drivers/pwm/pwm-jz4740.c
@@ -83,17 +83,16 @@ static void jz4740_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
jz4740_timer_disable(pwm->hwpwm);
}
-static int jz4740_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
- int duty_ns, int period_ns)
+static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+ struct pwm_state *state)
{
struct jz4740_pwm_chip *jz4740 = to_jz4740(pwm->chip);
unsigned long long tmp;
unsigned long period, duty;
unsigned int prescaler = 0;
uint16_t ctrl;
- bool is_enabled;
- tmp = (unsigned long long)clk_get_rate(jz4740->clk) * period_ns;
+ tmp = (unsigned long long)clk_get_rate(jz4740->clk) * state->period;
do_div(tmp, 1000000000);
period = tmp;
@@ -105,16 +104,14 @@ static int jz4740_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
if (prescaler == 6)
return -EINVAL;
- tmp = (unsigned long long)period * duty_ns;
- do_div(tmp, period_ns);
+ tmp = (unsigned long long)period * state->duty_cycle;
+ do_div(tmp, state->period);
duty = period - tmp;
if (duty >= period)
duty = period - 1;
- is_enabled = jz4740_timer_is_enabled(pwm->hwpwm);
- if (is_enabled)
- jz4740_pwm_disable(chip, pwm);
+ jz4740_pwm_disable(chip, pwm);
jz4740_timer_set_count(pwm->hwpwm, 0);
jz4740_timer_set_duty(pwm->hwpwm, duty);
@@ -125,18 +122,7 @@ static int jz4740_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
jz4740_timer_set_ctrl(pwm->hwpwm, ctrl);
- if (is_enabled)
- jz4740_pwm_enable(chip, pwm);
-
- return 0;
-}
-
-static int jz4740_pwm_set_polarity(struct pwm_chip *chip,
- struct pwm_device *pwm, enum pwm_polarity polarity)
-{
- uint32_t ctrl = jz4740_timer_get_ctrl(pwm->pwm);
-
- switch (polarity) {
+ switch (state->polarity) {
case PWM_POLARITY_NORMAL:
ctrl &= ~JZ_TIMER_CTRL_PWM_ACTIVE_LOW;
break;
@@ -146,16 +132,17 @@ static int jz4740_pwm_set_polarity(struct pwm_chip *chip,
}
jz4740_timer_set_ctrl(pwm->hwpwm, ctrl);
+
+ if (state->enabled)
+ jz4740_pwm_enable(chip, pwm);
+
return 0;
}
static const struct pwm_ops jz4740_pwm_ops = {
.request = jz4740_pwm_request,
.free = jz4740_pwm_free,
- .config = jz4740_pwm_config,
- .set_polarity = jz4740_pwm_set_polarity,
- .enable = jz4740_pwm_enable,
- .disable = jz4740_pwm_disable,
+ .apply = jz4740_pwm_apply,
.owner = THIS_MODULE,
};
--
2.21.0.593.g511ec345e18
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/5] pwm: jz4740: Drop dependency on MACH_INGENIC
2019-05-21 15:34 [PATCH 1/5] dt-bindings: Remove unused compatible strings Paul Cercueil
2019-05-21 15:34 ` [PATCH 2/5] pwm: jz4740: Remove unused devicetree " Paul Cercueil
2019-05-21 15:34 ` [PATCH 3/5] pwm: jz4740: Apply configuration atomically Paul Cercueil
@ 2019-05-21 15:34 ` Paul Cercueil
2019-05-21 15:34 ` [PATCH 5/5] pwm: jz4740: Switch to SPDX license identifier Paul Cercueil
3 siblings, 0 replies; 5+ messages in thread
From: Paul Cercueil @ 2019-05-21 15:34 UTC (permalink / raw)
To: Thierry Reding, Rob Herring, Mark Rutland
Cc: od, linux-pwm, devicetree, linux-kernel, Paul Cercueil
Depending on MACH_INGENIC prevent us from creating a generic kernel that
works on more than one MIPS board. Instead, we just depend on MIPS being
set.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
drivers/pwm/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 1311b54089be..1dfdf2cd533a 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -223,7 +223,7 @@ config PWM_IMX_TPM
config PWM_JZ4740
tristate "Ingenic JZ47xx PWM support"
- depends on MACH_INGENIC
+ depends on MIPS
help
Generic PWM framework driver for Ingenic JZ47xx based
machines.
--
2.21.0.593.g511ec345e18
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5/5] pwm: jz4740: Switch to SPDX license identifier
2019-05-21 15:34 [PATCH 1/5] dt-bindings: Remove unused compatible strings Paul Cercueil
` (2 preceding siblings ...)
2019-05-21 15:34 ` [PATCH 4/5] pwm: jz4740: Drop dependency on MACH_INGENIC Paul Cercueil
@ 2019-05-21 15:34 ` Paul Cercueil
3 siblings, 0 replies; 5+ messages in thread
From: Paul Cercueil @ 2019-05-21 15:34 UTC (permalink / raw)
To: Thierry Reding, Rob Herring, Mark Rutland
Cc: od, linux-pwm, devicetree, linux-kernel, Paul Cercueil
Use a SPDX license identifier instead of a wall of text.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
drivers/pwm/pwm-jz4740.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
index e73ee72df09d..138b4f596525 100644
--- a/drivers/pwm/pwm-jz4740.c
+++ b/drivers/pwm/pwm-jz4740.c
@@ -1,16 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
* JZ4740 platform PWM support
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- *
*/
#include <linux/clk.h>
--
2.21.0.593.g511ec345e18
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-05-21 15:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21 15:34 [PATCH 1/5] dt-bindings: Remove unused compatible strings Paul Cercueil
2019-05-21 15:34 ` [PATCH 2/5] pwm: jz4740: Remove unused devicetree " Paul Cercueil
2019-05-21 15:34 ` [PATCH 3/5] pwm: jz4740: Apply configuration atomically Paul Cercueil
2019-05-21 15:34 ` [PATCH 4/5] pwm: jz4740: Drop dependency on MACH_INGENIC Paul Cercueil
2019-05-21 15:34 ` [PATCH 5/5] pwm: jz4740: Switch to SPDX license identifier Paul Cercueil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).