From: Steev Klimaszewski <steev@kali.org>
To: "Bjorn Andersson" <bjorn.andersson@linaro.org>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Lee Jones" <lee.jones@linaro.org>
Cc: Andrzej Hajda <a.hajda@samsung.com>,
Neil Armstrong <narmstrong@baylibre.com>,
Robert Foss <robert.foss@linaro.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-pwm@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Doug Anderson <dianders@google.com>
Subject: Re: [PATCH v6 1/3] pwm: Introduce single-PWM of_xlate function
Date: Thu, 30 Sep 2021 16:35:23 -0500 [thread overview]
Message-ID: <aa563e12-4c3c-1854-ce91-efa7676d1676@kali.org> (raw)
In-Reply-To: <20210930030557.1426-1-bjorn.andersson@linaro.org>
On 9/29/21 10:05 PM, Bjorn Andersson wrote:
> The existing pxa driver and the upcoming addition of PWM support in the
> TI sn565dsi86 DSI/eDP bridge driver both has a single PWM channel and
> thereby a need for a of_xlate function with the period as its single
> argument.
>
> Introduce a common helper function in the core that can be used as
> of_xlate by such drivers and migrate the pxa driver to use this.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>
> Changes since v4:
> - None
>
> drivers/pwm/core.c | 26 ++++++++++++++++++++++++++
> drivers/pwm/pwm-pxa.c | 16 +---------------
> include/linux/pwm.h | 2 ++
> 3 files changed, 29 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 4527f09a5c50..2c6b155002a2 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -152,6 +152,32 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args)
> }
> EXPORT_SYMBOL_GPL(of_pwm_xlate_with_flags);
>
> +struct pwm_device *
> +of_pwm_single_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
> +{
> + struct pwm_device *pwm;
> +
> + if (pc->of_pwm_n_cells < 1)
> + return ERR_PTR(-EINVAL);
> +
> + /* validate that one cell is specified, optionally with flags */
> + if (args->args_count != 1 && args->args_count != 2)
> + return ERR_PTR(-EINVAL);
> +
> + pwm = pwm_request_from_chip(pc, 0, NULL);
> + if (IS_ERR(pwm))
> + return pwm;
> +
> + pwm->args.period = args->args[0];
> + pwm->args.polarity = PWM_POLARITY_NORMAL;
> +
> + if (args->args_count == 2 && args->args[2] & PWM_POLARITY_INVERTED)
> + pwm->args.polarity = PWM_POLARITY_INVERSED;
> +
> + return pwm;
> +}
> +EXPORT_SYMBOL_GPL(of_pwm_single_xlate);
> +
> static void of_pwmchip_add(struct pwm_chip *chip)
> {
> if (!chip->dev || !chip->dev->of_node)
> diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
> index a9efdcf839ae..238ec88c130b 100644
> --- a/drivers/pwm/pwm-pxa.c
> +++ b/drivers/pwm/pwm-pxa.c
> @@ -148,20 +148,6 @@ static const struct platform_device_id *pxa_pwm_get_id_dt(struct device *dev)
> return id ? id->data : NULL;
> }
>
> -static struct pwm_device *
> -pxa_pwm_of_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
> -{
> - struct pwm_device *pwm;
> -
> - pwm = pwm_request_from_chip(pc, 0, NULL);
> - if (IS_ERR(pwm))
> - return pwm;
> -
> - pwm->args.period = args->args[0];
> -
> - return pwm;
> -}
> -
> static int pwm_probe(struct platform_device *pdev)
> {
> const struct platform_device_id *id = platform_get_device_id(pdev);
> @@ -187,7 +173,7 @@ static int pwm_probe(struct platform_device *pdev)
> pc->chip.npwm = (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1;
>
> if (IS_ENABLED(CONFIG_OF)) {
> - pc->chip.of_xlate = pxa_pwm_of_xlate;
> + pc->chip.of_xlate = of_pwm_single_xlate;
> pc->chip.of_pwm_n_cells = 1;
> }
>
> diff --git a/include/linux/pwm.h b/include/linux/pwm.h
> index 725c9b784e60..dd51d4931fdc 100644
> --- a/include/linux/pwm.h
> +++ b/include/linux/pwm.h
> @@ -414,6 +414,8 @@ struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
>
> struct pwm_device *of_pwm_xlate_with_flags(struct pwm_chip *pc,
> const struct of_phandle_args *args);
> +struct pwm_device *of_pwm_single_xlate(struct pwm_chip *pc,
> + const struct of_phandle_args *args);
>
> struct pwm_device *pwm_get(struct device *dev, const char *con_id);
> struct pwm_device *of_pwm_get(struct device *dev, struct device_node *np,
I've tested these v6 all 3 patches on the Lenovo Yoga C630
Tested-by: Steev Klimaszewski <steev@kali.org>
next prev parent reply other threads:[~2021-09-30 21:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-30 3:05 Bjorn Andersson
2021-09-30 3:05 ` [PATCH v6 2/3] drm/bridge: ti-sn65dsi86: Use regmap_bulk_write API Bjorn Andersson
2021-09-30 15:40 ` Doug Anderson
2021-09-30 3:05 ` [PATCH v6 3/3] drm/bridge: ti-sn65dsi86: Implement the pwm_chip Bjorn Andersson
2021-10-07 3:53 ` Bjorn Andersson
2021-10-08 15:46 ` Robert Foss
2021-10-08 21:37 ` Doug Anderson
2021-10-25 8:42 ` Uwe Kleine-König
2021-10-25 15:27 ` Bjorn Andersson
2021-09-30 21:35 ` Steev Klimaszewski [this message]
2021-10-25 8:58 ` [PATCH v6 1/3] pwm: Introduce single-PWM of_xlate function Uwe Kleine-König
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=aa563e12-4c3c-1854-ce91-efa7676d1676@kali.org \
--to=steev@kali.org \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=a.hajda@samsung.com \
--cc=airlied@linux.ie \
--cc=bjorn.andersson@linaro.org \
--cc=daniel@ffwll.ch \
--cc=dianders@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=lee.jones@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=narmstrong@baylibre.com \
--cc=robert.foss@linaro.org \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®