From: "Lothar Waßmann" <LW@KARO-electronics.de> To: linux-pwm@vger.kernel.org Cc: "Thierry Reding" <thierry.reding@gmail.com>, linux-arm-kernel@lists.infradead.org, "Shawn Guo" <shawn.guo@linaro.org>, "Sascha Hauer" <s.hauer@pengutronix.de>, "Tony Prisk" <linux@prisktech.co.nz>, "Lothar Waßmann" <LW@KARO-electronics.de> Subject: [PATCHv5 2/3] pwm: make the PWM_POLARITY flag in DTB optional Date: Tue, 7 Oct 2014 15:55:33 +0200 [thread overview] Message-ID: <1412690134-13712-3-git-send-email-LW@KARO-electronics.de> (raw) In-Reply-To: <1412690134-13712-1-git-send-email-LW@KARO-electronics.de> 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ßmann <LW@KARO-electronics.de> Reviewed-by: Sascha Hauer <s.hauer@pengutronix.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 130bbea..ae1596f 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; - if (pc->of_pwm_n_cells < 3) + if (args->args_count != 3) return ERR_PTR(-EINVAL); if (args->args[0] >= pc->npwm) @@ -162,12 +162,15 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) { struct pwm_device *pwm; - if (pc->of_pwm_n_cells < 2) + if (args->args_count < 2) return ERR_PTR(-EINVAL); if (args->args[0] >= pc->npwm) return ERR_PTR(-EINVAL); + if (args->args_count > 2) + return of_pwm_xlate_with_flags(pc, args); + pwm = 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; - if (!chip->of_xlate) { + if (!chip->of_xlate) chip->of_xlate = of_pwm_simple_xlate; - chip->of_pwm_n_cells = 2; - } 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; } - if (args.args_count != pc->of_pwm_n_cells) { - pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name, - args.np->full_name); - pwm = ERR_PTR(-EINVAL); - goto put; - } - pwm = 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 d56e5b7..8ffa460 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_device *pdev) tcbpwm->chip.dev = &pdev->dev; tcbpwm->chip.ops = &atmel_tcb_pwm_ops; tcbpwm->chip.of_xlate = of_pwm_xlate_with_flags; - tcbpwm->chip.of_pwm_n_cells = 3; tcbpwm->chip.base = -1; tcbpwm->chip.npwm = NPWM; tcbpwm->tc = tc; diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index d3c22de..394c54f 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c @@ -348,10 +348,8 @@ static int atmel_pwm_probe(struct platform_device *pdev) atmel_pwm->chip.dev = &pdev->dev; atmel_pwm->chip.ops = &atmel_pwm_ops; - if (pdev->dev.of_node) { + if (pdev->dev.of_node) atmel_pwm->chip.of_xlate = of_pwm_xlate_with_flags; - atmel_pwm->chip.of_pwm_n_cells = 3; - } atmel_pwm->chip.base = -1; atmel_pwm->chip.npwm = 4; diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c index 0b312ec..56560529 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 = -1; pwm->chip.npwm = (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1; - if (IS_ENABLED(CONFIG_OF)) { + if (IS_ENABLED(CONFIG_OF)) pwm->chip.of_xlate = pxa_pwm_of_xlate; - pwm->chip.of_pwm_n_cells = 1; - } + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); pwm->mmio_base = devm_ioremap_resource(&pdev->dev, r); diff --git a/drivers/pwm/pwm-renesas-tpu.c b/drivers/pwm/pwm-renesas-tpu.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 = &pdev->dev; tpu->chip.ops = &tpu_pwm_ops; tpu->chip.of_xlate = of_pwm_xlate_with_flags; - tpu->chip.of_pwm_n_cells = 3; tpu->chip.base = -1; tpu->chip.npwm = TPU_CHANNEL_MAX; 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; chip->chip.of_xlate = of_pwm_xlate_with_flags; - chip->chip.of_pwm_n_cells = 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 *pdev) pc->chip.dev = &pdev->dev; pc->chip.ops = &ecap_pwm_ops; pc->chip.of_xlate = of_pwm_xlate_with_flags; - pc->chip.of_pwm_n_cells = 3; pc->chip.base = -1; pc->chip.npwm = 1; 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 = &pdev->dev; pc->chip.ops = &ehrpwm_pwm_ops; pc->chip.of_xlate = of_pwm_xlate_with_flags; - pc->chip.of_pwm_n_cells = 3; pc->chip.base = -1; pc->chip.npwm = NUM_PWM_CHANNEL; 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 = &pdev->dev; chip->chip.ops = &vt8500_pwm_ops; chip->chip.of_xlate = of_pwm_xlate_with_flags; - chip->chip.of_pwm_n_cells = 3; chip->chip.base = -1; chip->chip.npwm = VT8500_NR_PWMS; 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 { struct pwm_device * (*of_xlate)(struct pwm_chip *pc, const struct of_phandle_args *args); - unsigned int of_pwm_n_cells; bool can_sleep; }; -- 1.7.10.4
WARNING: multiple messages have this Message-ID (diff)
From: LW@KARO-electronics.de (Lothar Waßmann) To: linux-arm-kernel@lists.infradead.org Subject: [PATCHv5 2/3] pwm: make the PWM_POLARITY flag in DTB optional Date: Tue, 7 Oct 2014 15:55:33 +0200 [thread overview] Message-ID: <1412690134-13712-3-git-send-email-LW@KARO-electronics.de> (raw) In-Reply-To: <1412690134-13712-1-git-send-email-LW@KARO-electronics.de> 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?mann <LW@KARO-electronics.de> Reviewed-by: Sascha Hauer <s.hauer@pengutronix.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 130bbea..ae1596f 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; - if (pc->of_pwm_n_cells < 3) + if (args->args_count != 3) return ERR_PTR(-EINVAL); if (args->args[0] >= pc->npwm) @@ -162,12 +162,15 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) { struct pwm_device *pwm; - if (pc->of_pwm_n_cells < 2) + if (args->args_count < 2) return ERR_PTR(-EINVAL); if (args->args[0] >= pc->npwm) return ERR_PTR(-EINVAL); + if (args->args_count > 2) + return of_pwm_xlate_with_flags(pc, args); + pwm = 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; - if (!chip->of_xlate) { + if (!chip->of_xlate) chip->of_xlate = of_pwm_simple_xlate; - chip->of_pwm_n_cells = 2; - } 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; } - if (args.args_count != pc->of_pwm_n_cells) { - pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name, - args.np->full_name); - pwm = ERR_PTR(-EINVAL); - goto put; - } - pwm = 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 d56e5b7..8ffa460 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_device *pdev) tcbpwm->chip.dev = &pdev->dev; tcbpwm->chip.ops = &atmel_tcb_pwm_ops; tcbpwm->chip.of_xlate = of_pwm_xlate_with_flags; - tcbpwm->chip.of_pwm_n_cells = 3; tcbpwm->chip.base = -1; tcbpwm->chip.npwm = NPWM; tcbpwm->tc = tc; diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index d3c22de..394c54f 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c @@ -348,10 +348,8 @@ static int atmel_pwm_probe(struct platform_device *pdev) atmel_pwm->chip.dev = &pdev->dev; atmel_pwm->chip.ops = &atmel_pwm_ops; - if (pdev->dev.of_node) { + if (pdev->dev.of_node) atmel_pwm->chip.of_xlate = of_pwm_xlate_with_flags; - atmel_pwm->chip.of_pwm_n_cells = 3; - } atmel_pwm->chip.base = -1; atmel_pwm->chip.npwm = 4; diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c index 0b312ec..56560529 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 = -1; pwm->chip.npwm = (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1; - if (IS_ENABLED(CONFIG_OF)) { + if (IS_ENABLED(CONFIG_OF)) pwm->chip.of_xlate = pxa_pwm_of_xlate; - pwm->chip.of_pwm_n_cells = 1; - } + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); pwm->mmio_base = devm_ioremap_resource(&pdev->dev, r); diff --git a/drivers/pwm/pwm-renesas-tpu.c b/drivers/pwm/pwm-renesas-tpu.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 = &pdev->dev; tpu->chip.ops = &tpu_pwm_ops; tpu->chip.of_xlate = of_pwm_xlate_with_flags; - tpu->chip.of_pwm_n_cells = 3; tpu->chip.base = -1; tpu->chip.npwm = TPU_CHANNEL_MAX; 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; chip->chip.of_xlate = of_pwm_xlate_with_flags; - chip->chip.of_pwm_n_cells = 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 *pdev) pc->chip.dev = &pdev->dev; pc->chip.ops = &ecap_pwm_ops; pc->chip.of_xlate = of_pwm_xlate_with_flags; - pc->chip.of_pwm_n_cells = 3; pc->chip.base = -1; pc->chip.npwm = 1; 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 = &pdev->dev; pc->chip.ops = &ehrpwm_pwm_ops; pc->chip.of_xlate = of_pwm_xlate_with_flags; - pc->chip.of_pwm_n_cells = 3; pc->chip.base = -1; pc->chip.npwm = NUM_PWM_CHANNEL; 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 = &pdev->dev; chip->chip.ops = &vt8500_pwm_ops; chip->chip.of_xlate = of_pwm_xlate_with_flags; - chip->chip.of_pwm_n_cells = 3; chip->chip.base = -1; chip->chip.npwm = VT8500_NR_PWMS; 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 { struct pwm_device * (*of_xlate)(struct pwm_chip *pc, const struct of_phandle_args *args); - unsigned int of_pwm_n_cells; bool can_sleep; }; -- 1.7.10.4
next prev parent reply other threads:[~2014-10-07 13:55 UTC|newest] Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-10-07 13:55 [PATCHv4 0/3] pwm: imx: support output polarity inversion Lothar Waßmann 2014-10-07 13:55 ` Lothar Waßmann 2014-10-07 13:55 ` [PATCHv5 1/3] pwm: print error messages with pr_err() instead of pr_debug() Lothar Waßmann 2014-10-07 13:55 ` Lothar Waßmann 2014-10-07 13:55 ` Lothar Waßmann [this message] 2014-10-07 13:55 ` [PATCHv5 2/3] pwm: make the PWM_POLARITY flag in DTB optional Lothar Waßmann 2014-10-09 15:16 ` Thierry Reding 2014-10-09 15:16 ` Thierry Reding 2014-10-10 14:22 ` [PATCHv6 0/3] pwm: imx: support output polarity inversion Lothar Waßmann 2014-10-10 14:22 ` Lothar Waßmann 2014-10-10 14:22 ` [PATCHv6 1/3] pwm: print error messages with pr_err() instead of pr_debug() Lothar Waßmann 2014-10-10 14:22 ` Lothar Waßmann 2014-10-10 14:22 ` [PATCHv6 2/3] pwm: make the PWM_POLARITY flag in DTB optional Lothar Waßmann 2014-10-10 14:22 ` Lothar Waßmann 2014-10-10 14:22 ` [PATCH 3/3] pwm: imx: support output polarity inversion Lothar Waßmann 2014-10-10 14:22 ` Lothar Waßmann 2016-09-08 22:15 ` [PATCHv6 0/3] " Stefan Agner 2016-09-08 22:15 ` Stefan Agner 2016-09-09 7:18 ` Lothar Waßmann 2016-09-09 7:18 ` Lothar Waßmann 2016-09-12 12:45 ` Alexandre Belloni 2016-09-12 12:45 ` Alexandre Belloni 2016-09-12 14:04 ` Uwe Kleine-König 2016-09-12 14:04 ` Uwe Kleine-König 2016-09-12 16:51 ` Stefan Agner 2016-09-12 16:51 ` Stefan Agner 2016-09-12 20:00 ` Uwe Kleine-König 2016-09-12 20:00 ` Uwe Kleine-König 2016-09-12 21:12 ` Clemens Gruber 2016-09-12 21:12 ` Clemens Gruber 2016-09-13 6:45 ` Uwe Kleine-König 2016-09-13 6:45 ` Uwe Kleine-König 2016-09-12 13:54 ` Vladimir Zapolskiy 2016-09-12 13:54 ` Vladimir Zapolskiy 2014-10-07 13:55 ` [PATCHv5 3/3] " Lothar Waßmann 2014-10-07 13:55 ` Lothar Waßmann
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=1412690134-13712-3-git-send-email-LW@KARO-electronics.de \ --to=lw@karo-electronics.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-pwm@vger.kernel.org \ --cc=linux@prisktech.co.nz \ --cc=s.hauer@pengutronix.de \ --cc=shawn.guo@linaro.org \ --cc=thierry.reding@gmail.com \ /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: linkBe 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.