Discussion:
[PATCHv4 3/4] pwm: imx: indentation cleanup
Lothar Waßmann
2014-08-20 06:55:55 UTC
Permalink
Signed-off-by: Lothar Wa=C3=9Fmann <***@KARO-electronics.de>
---
drivers/pwm/pwm-imx.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
index 5449d91..f836635 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx.c
@@ -25,20 +25,21 @@
#define MX1_PWMS 0x04 /* PWM Sample Register */
#define MX1_PWMP 0x08 /* PWM Period Register */
=20
-#define MX1_PWMC_EN (1 << 4)
+#define MX1_PWMC_EN (1 << 4)
=20
/* i.MX27, i.MX31, i.MX35 share the same PWM function block: */
=20
-#define MX3_PWMCR 0x00 /* PWM Control Register */
-#define MX3_PWMSAR 0x0C /* PWM Sample Register */
-#define MX3_PWMPR 0x10 /* PWM Period Register */
-#define MX3_PWMCR_PRESCALER(x) (((x - 1) & 0xFFF) << 4)
-#define MX3_PWMCR_DOZEEN (1 << 24)
-#define MX3_PWMCR_WAITEN (1 << 23)
+#define MX3_PWMCR 0x00 /* PWM Control Register */
+#define MX3_PWMSAR 0x0C /* PWM Sample Register */
+#define MX3_PWMPR 0x10 /* PWM Period Register */
+#define MX3_PWMCR_PRESCALER(x) ((((x) - 1) & 0xFFF) << 4)
+#define MX3_PWMCR_DOZEEN (1 << 24)
+#define MX3_PWMCR_WAITEN (1 << 23)
#define MX3_PWMCR_DBGEN (1 << 22)
-#define MX3_PWMCR_CLKSRC_IPG_HIGH (2 << 16)
-#define MX3_PWMCR_CLKSRC_IPG (1 << 16)
-#define MX3_PWMCR_EN (1 << 0)
+#define MX3_PWMCR_POUTC (1 << 18)
+#define MX3_PWMCR_CLKSRC_IPG_HIGH (2 << 16)
+#define MX3_PWMCR_CLKSRC_IPG (1 << 16)
+#define MX3_PWMCR_EN (1 << 0)
=20
struct imx_chip {
struct clk *clk_per;
--=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-08-20 06:55:53 UTC
Permalink
Make the messages that are printed in case of fatal errors actually
visible to the user without having to recompile the driver with
debugging enabled.

Signed-off-by: Lothar Wa=C3=9Fmann <***@KARO-electronics.de>
---
drivers/pwm/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 4b66bf0..7af0043 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -525,13 +525,13 @@ 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
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-08-20 06:55:54 UTC
Permalink
Change the pwm chip driver registration, so that a chip driver that
supports polarity inversion can still be used with DTBs that don't
provide the 'PWM_POLARITY' flag.

This is done to provide polarity inversion support for the pwm-imx
driver without having to modify all existing DTS files.

Signed-off-by: Lothar Wa=C3=9Fmann <***@KARO-electronics.de>
---
drivers/pwm/core.c | 18 ++++++------------
drivers/pwm/pwm-atmel-tcb.c | 1 -
drivers/pwm/pwm-atmel.c | 4 +---
drivers/pwm/pwm-pxa.c | 5 ++---
drivers/pwm/pwm-renesas-tpu.c | 1 -
drivers/pwm/pwm-samsung.c | 1 -
drivers/pwm/pwm-tiecap.c | 1 -
drivers/pwm/pwm-tiehrpwm.c | 1 -
drivers/pwm/pwm-vt8500.c | 1 -
include/linux/pwm.h | 1 -
10 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 7af0043..ab0fc5a 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -136,7 +136,7 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const =
struct of_phandle_args *args)
{
struct pwm_device *pwm;
=20
- if (pc->of_pwm_n_cells < 3)
+ if (args->args_count !=3D 3)
return ERR_PTR(-EINVAL);
=20
if (args->args[0] >=3D pc->npwm)
@@ -162,12 +162,15 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const st=
ruct of_phandle_args *args)
{
struct pwm_device *pwm;
=20
- if (pc->of_pwm_n_cells < 2)
+ if (args->args_count < 2)
return ERR_PTR(-EINVAL);
=20
if (args->args[0] >=3D pc->npwm)
return ERR_PTR(-EINVAL);
=20
+ if (args->args_count > 2)
+ return of_pwm_xlate_with_flags(pc, args);
+
pwm =3D pwm_request_from_chip(pc, args->args[0], NULL);
if (IS_ERR(pwm))
return pwm;
@@ -182,10 +185,8 @@ static void of_pwmchip_add(struct pwm_chip *chip)
if (!chip->dev || !chip->dev->of_node)
return;
=20
- if (!chip->of_xlate) {
+ if (!chip->of_xlate)
chip->of_xlate =3D of_pwm_simple_xlate;
- chip->of_pwm_n_cells =3D 2;
- }
=20
of_node_get(chip->dev->of_node);
}
@@ -536,13 +537,6 @@ 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) {
- pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
- args.np->full_name);
- pwm =3D ERR_PTR(-EINVAL);
- goto put;
- }
-
pwm =3D pc->of_xlate(pc, &args);
if (IS_ERR(pwm))
goto put;
diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
index f3dcd02..55fabf8 100644
--- a/drivers/pwm/pwm-atmel-tcb.c
+++ b/drivers/pwm/pwm-atmel-tcb.c
@@ -395,7 +395,6 @@ static int atmel_tcb_pwm_probe(struct platform_devi=
ce *pdev)
tcbpwm->chip.dev =3D &pdev->dev;
tcbpwm->chip.ops =3D &atmel_tcb_pwm_ops;
tcbpwm->chip.of_xlate =3D of_pwm_xlate_with_flags;
- tcbpwm->chip.of_pwm_n_cells =3D 3;
tcbpwm->chip.base =3D -1;
tcbpwm->chip.npwm =3D NPWM;
tcbpwm->tc =3D tc;
diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
index 6e700a5..ae7c946 100644
--- a/drivers/pwm/pwm-atmel.c
+++ b/drivers/pwm/pwm-atmel.c
@@ -350,10 +350,8 @@ static int atmel_pwm_probe(struct platform_device =
*pdev)
atmel_pwm->chip.dev =3D &pdev->dev;
atmel_pwm->chip.ops =3D &atmel_pwm_ops;
=20
- if (pdev->dev.of_node) {
+ if (pdev->dev.of_node)
atmel_pwm->chip.of_xlate =3D of_pwm_xlate_with_flags;
- atmel_pwm->chip.of_pwm_n_cells =3D 3;
- }
=20
atmel_pwm->chip.base =3D -1;
atmel_pwm->chip.npwm =3D 4;
diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
index 0b312ec..5656052 100644
--- a/drivers/pwm/pwm-pxa.c
+++ b/drivers/pwm/pwm-pxa.c
@@ -191,10 +191,9 @@ static int pwm_probe(struct platform_device *pdev)
pwm->chip.base =3D -1;
pwm->chip.npwm =3D (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1;
=20
- if (IS_ENABLED(CONFIG_OF)) {
+ if (IS_ENABLED(CONFIG_OF))
pwm->chip.of_xlate =3D pxa_pwm_of_xlate;
- pwm->chip.of_pwm_n_cells =3D 1;
- }
+
=20
r =3D platform_get_resource(pdev, IORESOURCE_MEM, 0);
pwm->mmio_base =3D devm_ioremap_resource(&pdev->dev, r);
diff --git a/drivers/pwm/pwm-renesas-tpu.c b/drivers/pwm/pwm-renesas-tp=
u.c
index 3b71b42..5271da3 100644
--- a/drivers/pwm/pwm-renesas-tpu.c
+++ b/drivers/pwm/pwm-renesas-tpu.c
@@ -419,7 +419,6 @@ static int tpu_probe(struct platform_device *pdev)
tpu->chip.dev =3D &pdev->dev;
tpu->chip.ops =3D &tpu_pwm_ops;
tpu->chip.of_xlate =3D of_pwm_xlate_with_flags;
- tpu->chip.of_pwm_n_cells =3D 3;
tpu->chip.base =3D -1;
tpu->chip.npwm =3D TPU_CHANNEL_MAX;
=20
diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c
index ba6b650..317d7d1 100644
--- a/drivers/pwm/pwm-samsung.c
+++ b/drivers/pwm/pwm-samsung.c
@@ -484,7 +484,6 @@ static int pwm_samsung_probe(struct platform_device=
*pdev)
return ret;
=20
chip->chip.of_xlate =3D of_pwm_xlate_with_flags;
- chip->chip.of_pwm_n_cells =3D 3;
} else {
if (!pdev->dev.platform_data) {
dev_err(&pdev->dev, "no platform data specified\n");
diff --git a/drivers/pwm/pwm-tiecap.c b/drivers/pwm/pwm-tiecap.c
index 74efbe7..a8e8282 100644
--- a/drivers/pwm/pwm-tiecap.c
+++ b/drivers/pwm/pwm-tiecap.c
@@ -227,7 +227,6 @@ static int ecap_pwm_probe(struct platform_device *p=
dev)
pc->chip.dev =3D &pdev->dev;
pc->chip.ops =3D &ecap_pwm_ops;
pc->chip.of_xlate =3D of_pwm_xlate_with_flags;
- pc->chip.of_pwm_n_cells =3D 3;
pc->chip.base =3D -1;
pc->chip.npwm =3D 1;
=20
diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index cb75133..12a8ae4 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -458,7 +458,6 @@ static int ehrpwm_pwm_probe(struct platform_device =
*pdev)
pc->chip.dev =3D &pdev->dev;
pc->chip.ops =3D &ehrpwm_pwm_ops;
pc->chip.of_xlate =3D of_pwm_xlate_with_flags;
- pc->chip.of_pwm_n_cells =3D 3;
pc->chip.base =3D -1;
pc->chip.npwm =3D NUM_PWM_CHANNEL;
=20
diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c
index 652e6b5..e04a3c0 100644
--- a/drivers/pwm/pwm-vt8500.c
+++ b/drivers/pwm/pwm-vt8500.c
@@ -217,7 +217,6 @@ static int vt8500_pwm_probe(struct platform_device =
*pdev)
chip->chip.dev =3D &pdev->dev;
chip->chip.ops =3D &vt8500_pwm_ops;
chip->chip.of_xlate =3D of_pwm_xlate_with_flags;
- chip->chip.of_pwm_n_cells =3D 3;
chip->chip.base =3D -1;
chip->chip.npwm =3D VT8500_NR_PWMS;
=20
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index e90628c..4cf1569 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -174,7 +174,6 @@ struct pwm_chip {
=20
struct pwm_device * (*of_xlate)(struct pwm_chip *pc,
const struct of_phandle_args *args);
- unsigned int of_pwm_n_cells;
bool can_sleep;
};
=20
--=20
1.7.10.4
Lothar Waßmann
2014-08-20 06:55:56 UTC
Permalink
The i.MX pwm unit on i.MX27 and newer SoCs provides a configurable
output polarity. This patch adds support to utilize this feature where
available.

Signed-off-by: Lothar Wa=C3=9Fmann <***@KARO-electronics.de>
---
drivers/pwm/pwm-imx.c | 38 +++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
index f836635..585b0a8 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx.c
@@ -138,6 +138,8 @@ static int imx_pwm_config_v2(struct pwm_chip *chip,
=20
if (test_bit(PWMF_ENABLED, &pwm->flags))
cr |=3D MX3_PWMCR_EN;
+ if (pwm->polarity =3D=3D PWM_POLARITY_INVERSED)
+ cr |=3D MX3_PWMCR_POUTC;
=20
writel(cr, imx->mmio_base + MX3_PWMCR);
=20
@@ -156,6 +158,11 @@ static void imx_pwm_set_enable_v2(struct pwm_chip =
*chip, bool enable)
else
val &=3D ~MX3_PWMCR_EN;
=20
+ if (chip->pwms[0].polarity =3D=3D PWM_POLARITY_INVERSED)
+ val |=3D MX3_PWMCR_POUTC;
+ else
+ val &=3D ~MX3_PWMCR_POUTC;
+
writel(val, imx->mmio_base + MX3_PWMCR);
}
=20
@@ -199,27 +206,49 @@ static void imx_pwm_disable(struct pwm_chip *chip=
, struct pwm_device *pwm)
clk_disable_unprepare(imx->clk_per);
}
=20
-static struct pwm_ops imx_pwm_ops =3D {
+static int imx_pwm_set_polarity(struct pwm_chip *chip, struct pwm_devi=
ce *pwm,
+ enum pwm_polarity polarity)
+{
+ struct imx_chip *imx =3D to_imx_chip(chip);
+
+ dev_dbg(imx->chip.dev, "%s: polarity set to %s\n", __func__,
+ polarity =3D=3D PWM_POLARITY_INVERSED ? "inverted" : "normal");
+
+ return 0;
+}
+
+static struct pwm_ops imx_pwm_ops_v1 =3D {
.enable =3D imx_pwm_enable,
.disable =3D imx_pwm_disable,
.config =3D imx_pwm_config,
.owner =3D THIS_MODULE,
};
=20
+static struct pwm_ops imx_pwm_ops_v2 =3D {
+ .enable =3D imx_pwm_enable,
+ .disable =3D imx_pwm_disable,
+ .set_polarity =3D imx_pwm_set_polarity,
+ .config =3D imx_pwm_config,
+ .owner =3D THIS_MODULE,
+};
+
struct imx_pwm_data {
int (*config)(struct pwm_chip *chip,
struct pwm_device *pwm, int duty_ns, int period_ns);
void (*set_enable)(struct pwm_chip *chip, bool enable);
+ struct pwm_ops *pwm_ops;
};
=20
static struct imx_pwm_data imx_pwm_data_v1 =3D {
.config =3D imx_pwm_config_v1,
.set_enable =3D imx_pwm_set_enable_v1,
+ .pwm_ops =3D &imx_pwm_ops_v1,
};
=20
static struct imx_pwm_data imx_pwm_data_v2 =3D {
.config =3D imx_pwm_config_v2,
.set_enable =3D imx_pwm_set_enable_v2,
+ .pwm_ops =3D &imx_pwm_ops_v2,
};
=20
static const struct of_device_id imx_pwm_dt_ids[] =3D {
@@ -241,6 +270,10 @@ static int imx_pwm_probe(struct platform_device *p=
dev)
if (!of_id)
return -ENODEV;
=20
+ data =3D of_id->data;
+ if (data->pwm_ops->set_polarity)
+ dev_dbg(&pdev->dev, "PWM supports output inversion\n");
+
imx =3D devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL);
if (imx =3D=3D NULL)
return -ENOMEM;
@@ -259,7 +292,7 @@ static int imx_pwm_probe(struct platform_device *pd=
ev)
return PTR_ERR(imx->clk_ipg);
}
=20
- imx->chip.ops =3D &imx_pwm_ops;
+ imx->chip.ops =3D data->pwm_ops;
imx->chip.dev =3D &pdev->dev;
imx->chip.base =3D -1;
imx->chip.npwm =3D 1;
@@ -270,7 +303,6 @@ static int imx_pwm_probe(struct platform_device *pd=
ev)
if (IS_ERR(imx->mmio_base))
return PTR_ERR(imx->mmio_base);
=20
- data =3D of_id->data;
imx->config =3D data->config;
imx->set_enable =3D data->set_enable;
=20
--=20
1.7.10.4
Shawn Guo
2014-08-26 07:39:13 UTC
Permalink
Post by Lothar Waßmann
The i.MX pwm unit on i.MX27 and newer SoCs provides a configurable
output polarity. This patch adds support to utilize this feature wher=
e
Post by Lothar Waßmann
available.
=20
Acked-by: Shawn Guo <***@linaro.org>
--
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-08-26 07:24:09 UTC
Permalink
Hi,
This patch series adds support for polarity inversion to the pwm-imx
driver. The patches have been tested on i.MX6, i.MX53 and with the
ti-ehrpwm.c driver.
=20
- make the use of '#pwm-cells =3D <3>' optional, so that the change d=
oes
not break existing DT blobs as suggested by Arnd Bergmann and Sasch=
a
Hauer.
=20
- implemented the approach suggested by Sascha Hauer=20
- don't modify struct pwm_ops in the imx_pwm probe function
=20
=20
Any further comments?
Anyone taking care of these patches?


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
Sascha Hauer
2014-09-29 10:58:42 UTC
Permalink
Post by Lothar Waßmann
Hi,
=20
This patch series adds support for polarity inversion to the pwm-im=
x
Post by Lothar Waßmann
driver. The patches have been tested on i.MX6, i.MX53 and with the
ti-ehrpwm.c driver.
=20
- make the use of '#pwm-cells =3D <3>' optional, so that the change=
does
Post by Lothar Waßmann
not break existing DT blobs as suggested by Arnd Bergmann and Sas=
cha
Post by Lothar Waßmann
Hauer.
=20
- implemented the approach suggested by Sascha Hauer=20
- don't modify struct pwm_ops in the imx_pwm probe function
=20
=20
Any further comments?
No, except this one:

Reviewed-by: Sascha Hauer <***@pengutronix.de>

Sascha

--=20
Pengutronix e.K. | =
|
Industrial Linux Solutions | http://www.pengutronix.de/=
|
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 =
|
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-555=
5 |
--
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-09-29 10:07:23 UTC
Permalink
Hi,
This patch series adds support for polarity inversion to the pwm-imx
driver. The patches have been tested on i.MX6, i.MX53 and with the
ti-ehrpwm.c driver.
=20
- make the use of '#pwm-cells =3D <3>' optional, so that the change d=
oes
not break existing DT blobs as suggested by Arnd Bergmann and Sasch=
a
Hauer.
=20
- implemented the approach suggested by Sascha Hauer=20
- don't modify struct pwm_ops in the imx_pwm probe function
=20
=20
Ping?
It's now over a month without any reaction. What should I do with these
patches?


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
Loading...