Discussion:
[PATCH 1/3] pwm: process pwm polarity argument in of_pwm_simple_xlate()
Vladimir Zapolskiy
2014-10-10 15:50:05 UTC
Permalink
The third optional argument of pwms is well defined as polarity and it
is already used in a number of pwm drivers, so, to minimize changes in
the remaining drivers which are to be updated accordingly set polarity
in default of_xlate() function.

Signed-off-by: Vladimir Zapolskiy <***@mentor.com>
Cc: Lothar Wa=C3=9Fmann <***@KARO-electronics.de>
Cc: Sascha Hauer <***@pengutronix.de>
Cc: Thierry Reding <***@gmail.com>
Cc: Shawn Guo <***@linaro.org>
---
drivers/pwm/core.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 966497d..681d154 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -174,6 +174,13 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const str=
uct of_phandle_args *args)
=20
pwm_set_period(pwm, args->args[1]);
=20
+ if (pc->of_pwm_n_cells > 2) {
+ if (args->args[2] & PWM_POLARITY_INVERTED)
+ pwm_set_polarity(pwm, PWM_POLARITY_INVERSED);
+ else
+ pwm_set_polarity(pwm, PWM_POLARITY_NORMAL);
+ }
+
return pwm;
}
=20
--=20
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Vladimir Zapolskiy
2014-10-10 15:50:06 UTC
Permalink
The changed three user messages on fault are printed under pr_debug(),
however all of them are unrecoverable and result in failed pwm device
registration, report this to a user.

Signed-off-by: Vladimir Zapolskiy <***@mentor.com>
Cc: Lothar Wa=C3=9Fmann <***@KARO-electronics.de>
Cc: Sascha Hauer <***@pengutronix.de>
Cc: Thierry Reding <***@gmail.com>
Cc: Shawn Guo <***@linaro.org>
---
drivers/pwm/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 681d154..ccf1be7 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_node =
*np, const char *con_id)
err =3D of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
&args);
if (err) {
- pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
+ pr_warn("%s(): can't parse \"pwms\" property\n", __func__);
return ERR_PTR(err);
}
=20
pc =3D of_node_to_pwmchip(args.np);
if (IS_ERR(pc)) {
- pr_debug("%s(): PWM chip not found\n", __func__);
+ pr_warn("%s(): PWM chip not found\n", __func__);
pwm =3D ERR_CAST(pc);
goto put;
}
=20
if (args.args_count !=3D pc->of_pwm_n_cells) {
- pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
+ pr_warn("%s: wrong #pwm-cells for %s\n", np->full_name,
args.np->full_name);
pwm =3D ERR_PTR(-EINVAL);
goto put;
--=20
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Lothar Waßmann
2014-10-13 06:12:13 UTC
Permalink
Hi,
The changed three user messages on fault are printed under pr_debug()=
,
however all of them are unrecoverable and result in failed pwm device
registration, report this to a user.
=20
---
drivers/pwm/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
=20
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 681d154..ccf1be7 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_nod=
e *np, const char *con_id)
err =3D of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
&args);
if (err) {
- pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
+ pr_warn("%s(): can't parse \"pwms\" property\n", __func__);
As this is an error that leads to not loading the driver it should be
printed with ERROR level.
return ERR_PTR(err);
}
=20
pc =3D of_node_to_pwmchip(args.np);
if (IS_ERR(pc)) {
- pr_debug("%s(): PWM chip not found\n", __func__);
+ pr_warn("%s(): PWM chip not found\n", __func__);
dto.
goto put;
}
=20
if (args.args_count !=3D pc->of_pwm_n_cells) {
- pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
+ pr_warn("%s: wrong #pwm-cells for %s\n", np->full_name,
dto.


Lothar Wa=C3=9Fmann
--=20
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra=C3=9Fe 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch=C3=A4ftsf=C3=BChrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | ***@karo-electronics.de
___________________________________________________________
--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Vladimir Zapolskiy
2014-10-10 15:50:07 UTC
Permalink
=46or backward compatibility board device tree has to define only a
minimal amount of mandatory pwms arguments, additional arguments shall
be considered as optional, update pc->of_pwm_n_cells according to the
actual data taken from device tree file.

Signed-off-by: Vladimir Zapolskiy <***@mentor.com>
Cc: Lothar Wa=C3=9Fmann <***@KARO-electronics.de>
Cc: Sascha Hauer <***@pengutronix.de>
Cc: Thierry Reding <***@gmail.com>
Cc: Shawn Guo <***@linaro.org>
---
drivers/pwm/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index ccf1be7..2b77322 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -543,12 +543,13 @@ struct pwm_device *of_pwm_get(struct device_node =
*np, const char *con_id)
goto put;
}
=20
- if (args.args_count !=3D pc->of_pwm_n_cells) {
+ if (args.args_count < pc->of_pwm_n_cells) {
pr_warn("%s: wrong #pwm-cells for %s\n", np->full_name,
args.np->full_name);
pwm =3D ERR_PTR(-EINVAL);
goto put;
}
+ pc->of_pwm_n_cells =3D args.args_count;
=20
pwm =3D pc->of_xlate(pc, &args);
if (IS_ERR(pwm))
--=20
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Vladimir Zapolskiy
2014-10-13 14:21:36 UTC
Permalink
Please review this alternative in-house version of supporting backward
compatibility of DTB files, if pwms arguments of exisitng PWM drivers
are to be extended with polarity field.

Unfortunately I've firstly created the change and only after that
found that Lothar Wa=C3=9Fmann is working on his version, so I won't in=
sist
on formal preference, but still I like to share my variant since it
technically different from Lothar's one.

One visual benefit of my verison is that if this version is accepted,
then of_pwm_xlate_with_flags() can be removed from all touched PWM
drivers and pwm/core.c as a redundant interface, chip.of_pwm_n_cells
should not be updated also, and generally is looks to be a more simple
change.

The particular changes in iMX PWM driver and other PWM drivers are out
of this change scope.

Changes from v1 to v2:
- corrected the proper kernel log level, thanks to Lothar Wa=C3=9Fmann.

Vladimir Zapolskiy (3):
pwm: process pwm polarity argument in of_pwm_simple_xlate()
pwm: push up dynamic printk level on errors in of_pwm_get()
pwm: set the actual number of pwms arguments defined in board dts

drivers/pwm/core.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

--=20
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Vladimir Zapolskiy
2014-10-13 14:21:38 UTC
Permalink
The changed three user messages on fault are printed under pr_debug(),
however all of them are unrecoverable and result in failed pwm device
registration, report this to a user.

Signed-off-by: Vladimir Zapolskiy <***@mentor.com>
Cc: Lothar Wa=C3=9Fmann <***@KARO-electronics.de>
Cc: Sascha Hauer <***@pengutronix.de>
Cc: Thierry Reding <***@gmail.com>
Cc: Shawn Guo <***@linaro.org>
---
Changes from v1 to v2:
- corrected the proper kernel log level, thanks to Lothar Wa=C3=9Fmann.

drivers/pwm/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 681d154..f6231c6 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_node =
*np, const char *con_id)
err =3D of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
&args);
if (err) {
- pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
+ pr_err("%s(): can't parse \"pwms\" property\n", __func__);
return ERR_PTR(err);
}
=20
pc =3D of_node_to_pwmchip(args.np);
if (IS_ERR(pc)) {
- pr_debug("%s(): PWM chip not found\n", __func__);
+ pr_err("%s(): PWM chip not found\n", __func__);
pwm =3D ERR_CAST(pc);
goto put;
}
=20
if (args.args_count !=3D pc->of_pwm_n_cells) {
- pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
+ pr_err("%s: wrong #pwm-cells for %s\n", np->full_name,
args.np->full_name);
pwm =3D ERR_PTR(-EINVAL);
goto put;
--=20
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Vladimir Zapolskiy
2014-10-13 14:21:35 UTC
Permalink
The changed three user messages on fault are printed under pr_debug(),
however all of them are unrecoverable and result in failed pwm device
registration, report this to a user.

Signed-off-by: Vladimir Zapolskiy <***@mentor.com>
Cc: Lothar Wa=C3=9Fmann <***@KARO-electronics.de>
Cc: Sascha Hauer <***@pengutronix.de>
Cc: Thierry Reding <***@gmail.com>
Cc: Shawn Guo <***@linaro.org>
---
Changes from v1 to v2:
- corrected the proper kernel log level, thanks to Lothar Wa=C3=9Fmann.

drivers/pwm/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 681d154..f6231c6 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_node =
*np, const char *con_id)
err =3D of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
&args);
if (err) {
- pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
+ pr_err("%s(): can't parse \"pwms\" property\n", __func__);
return ERR_PTR(err);
}
=20
pc =3D of_node_to_pwmchip(args.np);
if (IS_ERR(pc)) {
- pr_debug("%s(): PWM chip not found\n", __func__);
+ pr_err("%s(): PWM chip not found\n", __func__);
pwm =3D ERR_CAST(pc);
goto put;
}
=20
if (args.args_count !=3D pc->of_pwm_n_cells) {
- pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
+ pr_err("%s: wrong #pwm-cells for %s\n", np->full_name,
args.np->full_name);
pwm =3D ERR_PTR(-EINVAL);
goto put;
--=20
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Vladimir Zapolskiy
2014-10-13 14:21:37 UTC
Permalink
The third optional argument of pwms is well defined as polarity and it
is already used in a number of pwm drivers, so, to minimize changes in
the remaining drivers which are to be updated accordingly set polarity
in default of_xlate() function.

Signed-off-by: Vladimir Zapolskiy <***@mentor.com>
Cc: Lothar Wa=C3=9Fmann <***@KARO-electronics.de>
Cc: Sascha Hauer <***@pengutronix.de>
Cc: Thierry Reding <***@gmail.com>
Cc: Shawn Guo <***@linaro.org>
---
drivers/pwm/core.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 966497d..681d154 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -174,6 +174,13 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const str=
uct of_phandle_args *args)
=20
pwm_set_period(pwm, args->args[1]);
=20
+ if (pc->of_pwm_n_cells > 2) {
+ if (args->args[2] & PWM_POLARITY_INVERTED)
+ pwm_set_polarity(pwm, PWM_POLARITY_INVERSED);
+ else
+ pwm_set_polarity(pwm, PWM_POLARITY_NORMAL);
+ }
+
return pwm;
}
=20
--=20
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Vladimir Zapolskiy
2014-10-13 14:21:39 UTC
Permalink
=46or backward compatibility board device tree has to define only a
minimal amount of mandatory pwms arguments, which is specified by a
driver. Additional arguments shall be considered as optional, update
pc->of_pwm_n_cells according to the actual data taken from device tree
file.

Signed-off-by: Vladimir Zapolskiy <***@mentor.com>
Cc: Lothar Wa=C3=9Fmann <***@KARO-electronics.de>
Cc: Sascha Hauer <***@pengutronix.de>
Cc: Thierry Reding <***@gmail.com>
Cc: Shawn Guo <***@linaro.org>
---
Changes from v1 to v2:
- rebased on top of modified patch v2 2/3

drivers/pwm/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index f6231c6..4d9fc7f 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -543,12 +543,13 @@ struct pwm_device *of_pwm_get(struct device_node =
*np, const char *con_id)
goto put;
}
=20
- if (args.args_count !=3D pc->of_pwm_n_cells) {
+ if (args.args_count < pc->of_pwm_n_cells) {
pr_err("%s: wrong #pwm-cells for %s\n", np->full_name,
args.np->full_name);
pwm =3D ERR_PTR(-EINVAL);
goto put;
}
+ pc->of_pwm_n_cells =3D args.args_count;
=20
pwm =3D pc->of_xlate(pc, &args);
if (IS_ERR(pwm))
--=20
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Loading...