From: Neil Armstrong <narmstrong@baylibre.com>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
linux-amlogic@lists.infradead.org, linux-pwm@vger.kernel.org,
thierry.reding@gmail.com, u.kleine-koenig@pengutronix.de
Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 07/14] pwm: meson: add the meson_pwm_channel data to struct meson_pwm
Date: Mon, 27 May 2019 14:27:25 +0200 [thread overview]
Message-ID: <f218f396-9f07-c81c-62cc-bd363abfcbaa@baylibre.com> (raw)
In-Reply-To: <20190525181133.4875-8-martin.blumenstingl@googlemail.com>
On 25/05/2019 20:11, Martin Blumenstingl wrote:
> Make struct meson_pwm_channel accessible from struct meson_pwm.
>
> PWM core has a limitation: per-channel data can only be set after
> pwmchip_add() is called. However, pwmchip_add() internally calls
> pwm_ops.get_state(). If pwm_ops.get_state() needs access to the
> per-channel data it has to obtain it from struct pwm_chip and struct
> pwm_device's hwpwm information.
>
> Add a struct meson_pwm_channel for each PWM channel to struct meson_pwm
> so the pwm_ops.get_state() callback can be implemented as it needs
> access to the clock from struct meson_pwm_channel.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
> drivers/pwm/pwm-meson.c | 25 ++++++++++---------------
> 1 file changed, 10 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
> index d6eb4d04d5c9..d1718f54ecec 100644
> --- a/drivers/pwm/pwm-meson.c
> +++ b/drivers/pwm/pwm-meson.c
> @@ -37,6 +37,8 @@
> #define MISC_B_EN BIT(1)
> #define MISC_A_EN BIT(0)
>
> +#define MESON_NUM_PWMS 2
> +
> static const unsigned int mux_reg_shifts[] = {
> MISC_A_CLK_SEL_SHIFT,
> MISC_B_CLK_SEL_SHIFT
> @@ -62,6 +64,7 @@ struct meson_pwm_data {
> struct meson_pwm {
> struct pwm_chip chip;
> const struct meson_pwm_data *data;
> + struct meson_pwm_channel channels[MESON_NUM_PWMS];
> void __iomem *base;
> /*
> * Protects register (write) access to the REG_MISC_AB register
> @@ -435,8 +438,7 @@ static const struct of_device_id meson_pwm_matches[] = {
> };
> MODULE_DEVICE_TABLE(of, meson_pwm_matches);
>
> -static int meson_pwm_init_channels(struct meson_pwm *meson,
> - struct meson_pwm_channel *channels)
> +static int meson_pwm_init_channels(struct meson_pwm *meson)
> {
> struct device *dev = meson->chip.dev;
> struct clk_init_data init;
> @@ -445,7 +447,7 @@ static int meson_pwm_init_channels(struct meson_pwm *meson,
> int err;
>
> for (i = 0; i < meson->chip.npwm; i++) {
> - struct meson_pwm_channel *channel = &channels[i];
> + struct meson_pwm_channel *channel = &meson->channels[i];
>
> snprintf(name, sizeof(name), "%s#mux%u", dev_name(dev), i);
>
> @@ -480,18 +482,16 @@ static int meson_pwm_init_channels(struct meson_pwm *meson,
> return 0;
> }
>
> -static void meson_pwm_add_channels(struct meson_pwm *meson,
> - struct meson_pwm_channel *channels)
> +static void meson_pwm_add_channels(struct meson_pwm *meson)
> {
> unsigned int i;
>
> for (i = 0; i < meson->chip.npwm; i++)
> - pwm_set_chip_data(&meson->chip.pwms[i], &channels[i]);
> + pwm_set_chip_data(&meson->chip.pwms[i], &meson->channels[i]);
> }
>
> static int meson_pwm_probe(struct platform_device *pdev)
> {
> - struct meson_pwm_channel *channels;
> struct meson_pwm *meson;
> struct resource *regs;
> int err;
> @@ -509,18 +509,13 @@ static int meson_pwm_probe(struct platform_device *pdev)
> meson->chip.dev = &pdev->dev;
> meson->chip.ops = &meson_pwm_ops;
> meson->chip.base = -1;
> - meson->chip.npwm = 2;
> + meson->chip.npwm = MESON_NUM_PWM;
> meson->chip.of_xlate = of_pwm_xlate_with_flags;
> meson->chip.of_pwm_n_cells = 3;
>
> meson->data = of_device_get_match_data(&pdev->dev);
>
> - channels = devm_kcalloc(&pdev->dev, meson->chip.npwm,
> - sizeof(*channels), GFP_KERNEL);
> - if (!channels)
> - return -ENOMEM;
> -
> - err = meson_pwm_init_channels(meson, channels);
> + err = meson_pwm_init_channels(meson);
> if (err < 0)
> return err;
>
> @@ -530,7 +525,7 @@ static int meson_pwm_probe(struct platform_device *pdev)
> return err;
> }
>
> - meson_pwm_add_channels(meson, channels);
> + meson_pwm_add_channels(meson);
>
> platform_set_drvdata(pdev, meson);
>
>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
next prev parent reply other threads:[~2019-05-27 12:27 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-25 18:11 [PATCH 00/14] pwm-meson: cleanups and improvements Martin Blumenstingl
2019-05-25 18:11 ` [PATCH 01/14] pwm: meson: unify the parameter list of meson_pwm_{enable,disable} Martin Blumenstingl
2019-05-27 12:25 ` [PATCH 01/14] pwm: meson: unify the parameter list of meson_pwm_{enable, disable} Neil Armstrong
2019-05-25 18:11 ` [PATCH 02/14] pwm: meson: use devm_clk_get_optional() to get the input clock Martin Blumenstingl
2019-05-27 12:25 ` Neil Armstrong
2019-05-25 18:11 ` [PATCH 03/14] pwm: meson: use GENMASK and FIELD_PREP for the lo and hi values Martin Blumenstingl
2019-05-27 12:25 ` Neil Armstrong
2019-05-25 18:11 ` [PATCH 04/14] pwm: meson: change MISC_CLK_SEL_WIDTH to MISC_CLK_SEL_MASK Martin Blumenstingl
2019-05-27 12:26 ` Neil Armstrong
2019-05-27 17:46 ` Martin Blumenstingl
2019-05-27 18:00 ` Uwe Kleine-König
2019-05-28 18:04 ` Martin Blumenstingl
2019-05-25 18:11 ` [PATCH 05/14] pwm: meson: don't duplicate the polarity internally Martin Blumenstingl
2019-05-27 12:26 ` Neil Armstrong
2019-05-25 18:11 ` [PATCH 06/14] pwm: meson: pass struct pwm_device to meson_pwm_calc() Martin Blumenstingl
2019-05-27 12:27 ` Neil Armstrong
2019-05-25 18:11 ` [PATCH 07/14] pwm: meson: add the meson_pwm_channel data to struct meson_pwm Martin Blumenstingl
2019-05-27 12:27 ` Neil Armstrong [this message]
2019-05-27 17:52 ` Martin Blumenstingl
2019-05-25 18:11 ` [PATCH 08/14] pwm: meson: add the per-channel register offsets and bits in a struct Martin Blumenstingl
2019-05-27 12:28 ` Neil Armstrong
2019-05-27 17:57 ` Martin Blumenstingl
2019-05-28 8:11 ` Neil Armstrong
2019-05-25 18:11 ` [PATCH 09/14] pwm: meson: move pwm_set_chip_data() to meson_pwm_request() Martin Blumenstingl
2019-05-27 12:30 ` Neil Armstrong
2019-05-25 18:11 ` [PATCH 10/14] pwm: meson: simplify the calculation of the pre-divider and count Martin Blumenstingl
2019-05-26 19:41 ` Uwe Kleine-König
2019-05-27 12:37 ` Neil Armstrong
2019-05-25 18:11 ` [PATCH 11/14] pwm: meson: read the full hardware state in meson_pwm_get_state() Martin Blumenstingl
2019-05-27 12:31 ` Neil Armstrong
2019-05-25 18:11 ` [PATCH 12/14] pwm: meson: don't cache struct pwm_state internally Martin Blumenstingl
2019-05-27 12:31 ` Neil Armstrong
2019-05-25 18:11 ` [PATCH 13/14] pwm: meson: add support PWM_POLARITY_INVERSED when disabling Martin Blumenstingl
2019-05-27 12:33 ` Neil Armstrong
2019-05-27 17:50 ` Martin Blumenstingl
2019-05-25 18:11 ` [PATCH 14/14] pwm: meson: add documentation to the driver Martin Blumenstingl
2019-05-27 12:33 ` Neil Armstrong
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=f218f396-9f07-c81c-62cc-bd363abfcbaa@baylibre.com \
--to=narmstrong@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--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