All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: neil.armstrong@linaro.org,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Neil Armstrong" <narmstrong@baylibre.com>,
	"Kevin Hilman" <khilman@baylibre.com>,
	"Jerome Brunet" <jbrunet@baylibre.com>,
	"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>
Cc: linux-pwm@vger.kernel.org,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"open list:ARM/Amlogic Meson..."
	<linux-amlogic@lists.infradead.org>
Subject: Re: [PATCH] pwm: meson: add support for S4 chip family
Date: Mon, 27 Mar 2023 19:00:35 +0200	[thread overview]
Message-ID: <45dbd1d4-a2b8-af33-beec-64906c0e98da@gmail.com> (raw)
In-Reply-To: <3492657f-6cc2-5828-b153-30c609a92783@linaro.org>

On 27.03.2023 09:33, Neil Armstrong wrote:
> On 24/03/2023 23:23, Heiner Kallweit wrote:
>> This adds pwm support for (at least) the s4 chip family. The extension
>> is based on the vendor driver that can be found at [0]. There the
>> version with the new clock handling is called meson-v2-pwm.
>> Central change is that the clock is now fully provided by the SoC clock
>> core. The multiplexer isn't any longer part of the pwm block.
>>
>> This was tested on a sc2-based system that uses the same pwm block.
>>
>> [0] https://github.com/khadas/linux/blob/khadas-vims-5.4.y/drivers/pwm/pwm-meson.c
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>> Adding the amlogic,meson-s4-pwm compatible to the documentation was part
>> of the yaml conversion already.
>> ---
>>   drivers/pwm/pwm-meson.c | 38 ++++++++++++++++++++++++++++++++++----
>>   1 file changed, 34 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
>> index 16d79ca5d..7a93fdada 100644
>> --- a/drivers/pwm/pwm-meson.c
>> +++ b/drivers/pwm/pwm-meson.c
>> @@ -98,6 +98,7 @@ struct meson_pwm_channel {
>>   struct meson_pwm_data {
>>       const char * const *parent_names;
>>       unsigned int num_parents;
>> +    unsigned int ext_clk:1;
> 
> Drop the :1, the compiler will align the struct size to the register size, so simply use unsigned int or bool.
> 
Having one flag only it doesn't really make a difference, right.
I chose this single bit because in future there may come another flag,
then having them in one bitfield would be advantageous.

Also https://www.kernel.org/doc/Documentation/process/coding-style.rst
Part "17) Using bool" prefers bits for bool values in structs, even though
the mentioned use cases like multiple flags don't apply here.

> I'd use a better name for that, like: no_mux_blk, pwm_clk_input....
> 
OK

>>   };
>>     struct meson_pwm {
>> @@ -158,6 +159,7 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
>>       struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm];
>>       unsigned int duty, period, pre_div, cnt, duty_cnt;
>>       unsigned long fin_freq;
>> +    int err;
>>         duty = state->duty_cycle;
>>       period = state->period;
>> @@ -165,6 +167,14 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
>>       if (state->polarity == PWM_POLARITY_INVERSED)
>>           duty = period - duty;
>>   +    if (meson->data->ext_clk) {
>> +        err = clk_set_rate(channel->clk, 0xffffUL * NSEC_PER_SEC / period);
>> +        if (err) {
>> +            dev_err(meson->chip.dev, "failed to set pwm clock rate\n");
>> +            return err;
>> +        }
> 
> If the same MUX architecture has been moved out of the PWM registers, then why would you call
> set_rate ? we don't call set_rate today, so why should we ?
> 
> Today the MUX selection is static depending on the clk names specified in the bindings (yes it's
> really not the good way to do that,....) but now the MUX is outside the PWM registers block
> we should stick to the same architecture and mark the MUX as NO_REPARENT and instead of using
> a bad bindings specify the MUX parent & rate in dt using assigned-clk-parent/rate.
> 
> So please drop this set_rate().
> 
Implicitly there's a set_rate() also today, by setting the pre_div divider value.
By the way: Not sure why the divider isn't handled via CCF, like e.g. in meson-gx-mmc.

The best (for achieving best precision) input frequency is 0xffff / period.
So we should do our best to come as close as possible to this frequency.
By using set_rate() CCF will choose the optimal mux input and divider value.
Not sure why we should restrict ourselves to one mux parent only.
E.g. for a very low duty cycle a higher input frequency than the xtal 24MHz may be preferable.

Not only the mux is outside the PWM block now, also the divider (8 bit wide instead of 7 bit
as of today). So we need a set_rate() anyway to set the divider value.
What I can't say is whether the internal divider still exists (then external and internal
divider would be cascaded) or is removed or bypassed.
It seems like when adding the external PWM clock feature Amlogic forgot to update
the PWM block documentation, as there's no reference at all to the now external input clock
(except in the clocks section).

>> +    }
>> +
>>       fin_freq = clk_get_rate(channel->clk);
>>       if (fin_freq == 0) {
>>           dev_err(meson->chip.dev, "invalid source clock frequency\n");
>> @@ -173,10 +183,14 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
>>         dev_dbg(meson->chip.dev, "fin_freq: %lu Hz\n", fin_freq);
>>   -    pre_div = div64_u64(fin_freq * (u64)period, NSEC_PER_SEC * 0xffffLL);
>> -    if (pre_div > MISC_CLK_DIV_MASK) {
>> -        dev_err(meson->chip.dev, "unable to get period pre_div\n");
>> -        return -EINVAL;
>> +    if (meson->data->ext_clk) {
>> +        pre_div = 0;
>> +    } else {
>> +        pre_div = div64_u64(fin_freq * (u64)period, NSEC_PER_SEC * 0xffffLL);
>> +        if (pre_div > MISC_CLK_DIV_MASK) {
>> +            dev_err(meson->chip.dev, "unable to get period pre_div\n");
>> +            return -EINVAL;
>> +        }
>>       }
>>         cnt = div64_u64(fin_freq * (u64)period, NSEC_PER_SEC * (pre_div + 1));
>> @@ -445,6 +459,10 @@ static const struct meson_pwm_data pwm_g12a_ee_data = {
>>       .num_parents = ARRAY_SIZE(pwm_g12a_ee_parent_names),
>>   };
>>   +static const struct meson_pwm_data pwm_s4_data = {
>> +    .ext_clk = 1,
>> +};
>> +
>>   static const struct of_device_id meson_pwm_matches[] = {
>>       {
>>           .compatible = "amlogic,meson8b-pwm",
>> @@ -478,6 +496,10 @@ static const struct of_device_id meson_pwm_matches[] = {
>>           .compatible = "amlogic,meson-g12a-ao-pwm-cd",
>>           .data = &pwm_g12a_ao_cd_data
>>       },
>> +    {
>> +        .compatible = "amlogic,meson-s4-pwm",
> 
> This deserved a bindings update, and we should perhaps start a new bindings by using
> new clock-names (!= clkin0/1) to differentiate from the old buggy bindings.
> 
We could simply name the clocks pwm_a, pwm_b. If you think this could be confusing
for pwm PWM_C/PWM_D, then we may use pwm0 and pwm1.

The changed binding would have to reflect that now both input clocks for a pwm
are required.

> Neil
> 
>> +        .data = &pwm_s4_data
>> +    },
>>       {},
>>   };
>>   MODULE_DEVICE_TABLE(of, meson_pwm_matches);
>> @@ -493,6 +515,14 @@ static int meson_pwm_init_channels(struct meson_pwm *meson)
>>       for (i = 0; i < meson->chip.npwm; i++) {
>>           struct meson_pwm_channel *channel = &meson->channels[i];
>>   +        if (meson->data->ext_clk) {
>> +            snprintf(name, sizeof(name), "clkin%u", i);
>> +            channel->clk = devm_clk_get(dev, name);
>> +            if (IS_ERR(channel->clk))
>> +                return PTR_ERR(channel->clk);
>> +            continue;
>> +        }
>> +
>>           snprintf(name, sizeof(name), "%s#mux%u", dev_name(dev), i);
>>             init.name = name;
> 


WARNING: multiple messages have this Message-ID (diff)
From: Heiner Kallweit <hkallweit1@gmail.com>
To: neil.armstrong@linaro.org,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Neil Armstrong" <narmstrong@baylibre.com>,
	"Kevin Hilman" <khilman@baylibre.com>,
	"Jerome Brunet" <jbrunet@baylibre.com>,
	"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>
Cc: linux-pwm@vger.kernel.org,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"open list:ARM/Amlogic Meson..."
	<linux-amlogic@lists.infradead.org>
Subject: Re: [PATCH] pwm: meson: add support for S4 chip family
Date: Mon, 27 Mar 2023 19:00:35 +0200	[thread overview]
Message-ID: <45dbd1d4-a2b8-af33-beec-64906c0e98da@gmail.com> (raw)
In-Reply-To: <3492657f-6cc2-5828-b153-30c609a92783@linaro.org>

On 27.03.2023 09:33, Neil Armstrong wrote:
> On 24/03/2023 23:23, Heiner Kallweit wrote:
>> This adds pwm support for (at least) the s4 chip family. The extension
>> is based on the vendor driver that can be found at [0]. There the
>> version with the new clock handling is called meson-v2-pwm.
>> Central change is that the clock is now fully provided by the SoC clock
>> core. The multiplexer isn't any longer part of the pwm block.
>>
>> This was tested on a sc2-based system that uses the same pwm block.
>>
>> [0] https://github.com/khadas/linux/blob/khadas-vims-5.4.y/drivers/pwm/pwm-meson.c
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>> Adding the amlogic,meson-s4-pwm compatible to the documentation was part
>> of the yaml conversion already.
>> ---
>>   drivers/pwm/pwm-meson.c | 38 ++++++++++++++++++++++++++++++++++----
>>   1 file changed, 34 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
>> index 16d79ca5d..7a93fdada 100644
>> --- a/drivers/pwm/pwm-meson.c
>> +++ b/drivers/pwm/pwm-meson.c
>> @@ -98,6 +98,7 @@ struct meson_pwm_channel {
>>   struct meson_pwm_data {
>>       const char * const *parent_names;
>>       unsigned int num_parents;
>> +    unsigned int ext_clk:1;
> 
> Drop the :1, the compiler will align the struct size to the register size, so simply use unsigned int or bool.
> 
Having one flag only it doesn't really make a difference, right.
I chose this single bit because in future there may come another flag,
then having them in one bitfield would be advantageous.

Also https://www.kernel.org/doc/Documentation/process/coding-style.rst
Part "17) Using bool" prefers bits for bool values in structs, even though
the mentioned use cases like multiple flags don't apply here.

> I'd use a better name for that, like: no_mux_blk, pwm_clk_input....
> 
OK

>>   };
>>     struct meson_pwm {
>> @@ -158,6 +159,7 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
>>       struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm];
>>       unsigned int duty, period, pre_div, cnt, duty_cnt;
>>       unsigned long fin_freq;
>> +    int err;
>>         duty = state->duty_cycle;
>>       period = state->period;
>> @@ -165,6 +167,14 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
>>       if (state->polarity == PWM_POLARITY_INVERSED)
>>           duty = period - duty;
>>   +    if (meson->data->ext_clk) {
>> +        err = clk_set_rate(channel->clk, 0xffffUL * NSEC_PER_SEC / period);
>> +        if (err) {
>> +            dev_err(meson->chip.dev, "failed to set pwm clock rate\n");
>> +            return err;
>> +        }
> 
> If the same MUX architecture has been moved out of the PWM registers, then why would you call
> set_rate ? we don't call set_rate today, so why should we ?
> 
> Today the MUX selection is static depending on the clk names specified in the bindings (yes it's
> really not the good way to do that,....) but now the MUX is outside the PWM registers block
> we should stick to the same architecture and mark the MUX as NO_REPARENT and instead of using
> a bad bindings specify the MUX parent & rate in dt using assigned-clk-parent/rate.
> 
> So please drop this set_rate().
> 
Implicitly there's a set_rate() also today, by setting the pre_div divider value.
By the way: Not sure why the divider isn't handled via CCF, like e.g. in meson-gx-mmc.

The best (for achieving best precision) input frequency is 0xffff / period.
So we should do our best to come as close as possible to this frequency.
By using set_rate() CCF will choose the optimal mux input and divider value.
Not sure why we should restrict ourselves to one mux parent only.
E.g. for a very low duty cycle a higher input frequency than the xtal 24MHz may be preferable.

Not only the mux is outside the PWM block now, also the divider (8 bit wide instead of 7 bit
as of today). So we need a set_rate() anyway to set the divider value.
What I can't say is whether the internal divider still exists (then external and internal
divider would be cascaded) or is removed or bypassed.
It seems like when adding the external PWM clock feature Amlogic forgot to update
the PWM block documentation, as there's no reference at all to the now external input clock
(except in the clocks section).

>> +    }
>> +
>>       fin_freq = clk_get_rate(channel->clk);
>>       if (fin_freq == 0) {
>>           dev_err(meson->chip.dev, "invalid source clock frequency\n");
>> @@ -173,10 +183,14 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
>>         dev_dbg(meson->chip.dev, "fin_freq: %lu Hz\n", fin_freq);
>>   -    pre_div = div64_u64(fin_freq * (u64)period, NSEC_PER_SEC * 0xffffLL);
>> -    if (pre_div > MISC_CLK_DIV_MASK) {
>> -        dev_err(meson->chip.dev, "unable to get period pre_div\n");
>> -        return -EINVAL;
>> +    if (meson->data->ext_clk) {
>> +        pre_div = 0;
>> +    } else {
>> +        pre_div = div64_u64(fin_freq * (u64)period, NSEC_PER_SEC * 0xffffLL);
>> +        if (pre_div > MISC_CLK_DIV_MASK) {
>> +            dev_err(meson->chip.dev, "unable to get period pre_div\n");
>> +            return -EINVAL;
>> +        }
>>       }
>>         cnt = div64_u64(fin_freq * (u64)period, NSEC_PER_SEC * (pre_div + 1));
>> @@ -445,6 +459,10 @@ static const struct meson_pwm_data pwm_g12a_ee_data = {
>>       .num_parents = ARRAY_SIZE(pwm_g12a_ee_parent_names),
>>   };
>>   +static const struct meson_pwm_data pwm_s4_data = {
>> +    .ext_clk = 1,
>> +};
>> +
>>   static const struct of_device_id meson_pwm_matches[] = {
>>       {
>>           .compatible = "amlogic,meson8b-pwm",
>> @@ -478,6 +496,10 @@ static const struct of_device_id meson_pwm_matches[] = {
>>           .compatible = "amlogic,meson-g12a-ao-pwm-cd",
>>           .data = &pwm_g12a_ao_cd_data
>>       },
>> +    {
>> +        .compatible = "amlogic,meson-s4-pwm",
> 
> This deserved a bindings update, and we should perhaps start a new bindings by using
> new clock-names (!= clkin0/1) to differentiate from the old buggy bindings.
> 
We could simply name the clocks pwm_a, pwm_b. If you think this could be confusing
for pwm PWM_C/PWM_D, then we may use pwm0 and pwm1.

The changed binding would have to reflect that now both input clocks for a pwm
are required.

> Neil
> 
>> +        .data = &pwm_s4_data
>> +    },
>>       {},
>>   };
>>   MODULE_DEVICE_TABLE(of, meson_pwm_matches);
>> @@ -493,6 +515,14 @@ static int meson_pwm_init_channels(struct meson_pwm *meson)
>>       for (i = 0; i < meson->chip.npwm; i++) {
>>           struct meson_pwm_channel *channel = &meson->channels[i];
>>   +        if (meson->data->ext_clk) {
>> +            snprintf(name, sizeof(name), "clkin%u", i);
>> +            channel->clk = devm_clk_get(dev, name);
>> +            if (IS_ERR(channel->clk))
>> +                return PTR_ERR(channel->clk);
>> +            continue;
>> +        }
>> +
>>           snprintf(name, sizeof(name), "%s#mux%u", dev_name(dev), i);
>>             init.name = name;
> 


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

WARNING: multiple messages have this Message-ID (diff)
From: Heiner Kallweit <hkallweit1@gmail.com>
To: neil.armstrong@linaro.org,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Neil Armstrong" <narmstrong@baylibre.com>,
	"Kevin Hilman" <khilman@baylibre.com>,
	"Jerome Brunet" <jbrunet@baylibre.com>,
	"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>
Cc: linux-pwm@vger.kernel.org,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"open list:ARM/Amlogic Meson..."
	<linux-amlogic@lists.infradead.org>
Subject: Re: [PATCH] pwm: meson: add support for S4 chip family
Date: Mon, 27 Mar 2023 19:00:35 +0200	[thread overview]
Message-ID: <45dbd1d4-a2b8-af33-beec-64906c0e98da@gmail.com> (raw)
In-Reply-To: <3492657f-6cc2-5828-b153-30c609a92783@linaro.org>

On 27.03.2023 09:33, Neil Armstrong wrote:
> On 24/03/2023 23:23, Heiner Kallweit wrote:
>> This adds pwm support for (at least) the s4 chip family. The extension
>> is based on the vendor driver that can be found at [0]. There the
>> version with the new clock handling is called meson-v2-pwm.
>> Central change is that the clock is now fully provided by the SoC clock
>> core. The multiplexer isn't any longer part of the pwm block.
>>
>> This was tested on a sc2-based system that uses the same pwm block.
>>
>> [0] https://github.com/khadas/linux/blob/khadas-vims-5.4.y/drivers/pwm/pwm-meson.c
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>> Adding the amlogic,meson-s4-pwm compatible to the documentation was part
>> of the yaml conversion already.
>> ---
>>   drivers/pwm/pwm-meson.c | 38 ++++++++++++++++++++++++++++++++++----
>>   1 file changed, 34 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
>> index 16d79ca5d..7a93fdada 100644
>> --- a/drivers/pwm/pwm-meson.c
>> +++ b/drivers/pwm/pwm-meson.c
>> @@ -98,6 +98,7 @@ struct meson_pwm_channel {
>>   struct meson_pwm_data {
>>       const char * const *parent_names;
>>       unsigned int num_parents;
>> +    unsigned int ext_clk:1;
> 
> Drop the :1, the compiler will align the struct size to the register size, so simply use unsigned int or bool.
> 
Having one flag only it doesn't really make a difference, right.
I chose this single bit because in future there may come another flag,
then having them in one bitfield would be advantageous.

Also https://www.kernel.org/doc/Documentation/process/coding-style.rst
Part "17) Using bool" prefers bits for bool values in structs, even though
the mentioned use cases like multiple flags don't apply here.

> I'd use a better name for that, like: no_mux_blk, pwm_clk_input....
> 
OK

>>   };
>>     struct meson_pwm {
>> @@ -158,6 +159,7 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
>>       struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm];
>>       unsigned int duty, period, pre_div, cnt, duty_cnt;
>>       unsigned long fin_freq;
>> +    int err;
>>         duty = state->duty_cycle;
>>       period = state->period;
>> @@ -165,6 +167,14 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
>>       if (state->polarity == PWM_POLARITY_INVERSED)
>>           duty = period - duty;
>>   +    if (meson->data->ext_clk) {
>> +        err = clk_set_rate(channel->clk, 0xffffUL * NSEC_PER_SEC / period);
>> +        if (err) {
>> +            dev_err(meson->chip.dev, "failed to set pwm clock rate\n");
>> +            return err;
>> +        }
> 
> If the same MUX architecture has been moved out of the PWM registers, then why would you call
> set_rate ? we don't call set_rate today, so why should we ?
> 
> Today the MUX selection is static depending on the clk names specified in the bindings (yes it's
> really not the good way to do that,....) but now the MUX is outside the PWM registers block
> we should stick to the same architecture and mark the MUX as NO_REPARENT and instead of using
> a bad bindings specify the MUX parent & rate in dt using assigned-clk-parent/rate.
> 
> So please drop this set_rate().
> 
Implicitly there's a set_rate() also today, by setting the pre_div divider value.
By the way: Not sure why the divider isn't handled via CCF, like e.g. in meson-gx-mmc.

The best (for achieving best precision) input frequency is 0xffff / period.
So we should do our best to come as close as possible to this frequency.
By using set_rate() CCF will choose the optimal mux input and divider value.
Not sure why we should restrict ourselves to one mux parent only.
E.g. for a very low duty cycle a higher input frequency than the xtal 24MHz may be preferable.

Not only the mux is outside the PWM block now, also the divider (8 bit wide instead of 7 bit
as of today). So we need a set_rate() anyway to set the divider value.
What I can't say is whether the internal divider still exists (then external and internal
divider would be cascaded) or is removed or bypassed.
It seems like when adding the external PWM clock feature Amlogic forgot to update
the PWM block documentation, as there's no reference at all to the now external input clock
(except in the clocks section).

>> +    }
>> +
>>       fin_freq = clk_get_rate(channel->clk);
>>       if (fin_freq == 0) {
>>           dev_err(meson->chip.dev, "invalid source clock frequency\n");
>> @@ -173,10 +183,14 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
>>         dev_dbg(meson->chip.dev, "fin_freq: %lu Hz\n", fin_freq);
>>   -    pre_div = div64_u64(fin_freq * (u64)period, NSEC_PER_SEC * 0xffffLL);
>> -    if (pre_div > MISC_CLK_DIV_MASK) {
>> -        dev_err(meson->chip.dev, "unable to get period pre_div\n");
>> -        return -EINVAL;
>> +    if (meson->data->ext_clk) {
>> +        pre_div = 0;
>> +    } else {
>> +        pre_div = div64_u64(fin_freq * (u64)period, NSEC_PER_SEC * 0xffffLL);
>> +        if (pre_div > MISC_CLK_DIV_MASK) {
>> +            dev_err(meson->chip.dev, "unable to get period pre_div\n");
>> +            return -EINVAL;
>> +        }
>>       }
>>         cnt = div64_u64(fin_freq * (u64)period, NSEC_PER_SEC * (pre_div + 1));
>> @@ -445,6 +459,10 @@ static const struct meson_pwm_data pwm_g12a_ee_data = {
>>       .num_parents = ARRAY_SIZE(pwm_g12a_ee_parent_names),
>>   };
>>   +static const struct meson_pwm_data pwm_s4_data = {
>> +    .ext_clk = 1,
>> +};
>> +
>>   static const struct of_device_id meson_pwm_matches[] = {
>>       {
>>           .compatible = "amlogic,meson8b-pwm",
>> @@ -478,6 +496,10 @@ static const struct of_device_id meson_pwm_matches[] = {
>>           .compatible = "amlogic,meson-g12a-ao-pwm-cd",
>>           .data = &pwm_g12a_ao_cd_data
>>       },
>> +    {
>> +        .compatible = "amlogic,meson-s4-pwm",
> 
> This deserved a bindings update, and we should perhaps start a new bindings by using
> new clock-names (!= clkin0/1) to differentiate from the old buggy bindings.
> 
We could simply name the clocks pwm_a, pwm_b. If you think this could be confusing
for pwm PWM_C/PWM_D, then we may use pwm0 and pwm1.

The changed binding would have to reflect that now both input clocks for a pwm
are required.

> Neil
> 
>> +        .data = &pwm_s4_data
>> +    },
>>       {},
>>   };
>>   MODULE_DEVICE_TABLE(of, meson_pwm_matches);
>> @@ -493,6 +515,14 @@ static int meson_pwm_init_channels(struct meson_pwm *meson)
>>       for (i = 0; i < meson->chip.npwm; i++) {
>>           struct meson_pwm_channel *channel = &meson->channels[i];
>>   +        if (meson->data->ext_clk) {
>> +            snprintf(name, sizeof(name), "clkin%u", i);
>> +            channel->clk = devm_clk_get(dev, name);
>> +            if (IS_ERR(channel->clk))
>> +                return PTR_ERR(channel->clk);
>> +            continue;
>> +        }
>> +
>>           snprintf(name, sizeof(name), "%s#mux%u", dev_name(dev), i);
>>             init.name = name;
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-03-27 17:00 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24 22:23 [PATCH] pwm: meson: add support for S4 chip family Heiner Kallweit
2023-03-24 22:23 ` Heiner Kallweit
2023-03-24 22:23 ` Heiner Kallweit
2023-03-25  8:20 ` Uwe Kleine-König
2023-03-25  8:20   ` Uwe Kleine-König
2023-03-25  8:20   ` Uwe Kleine-König
2023-03-25  9:43   ` Heiner Kallweit
2023-03-25  9:43     ` Heiner Kallweit
2023-03-25  9:43     ` Heiner Kallweit
2023-03-25 13:24 ` Jerome Brunet
2023-03-25 13:24   ` Jerome Brunet
2023-03-25 13:24   ` Jerome Brunet
2023-03-25 22:58   ` Heiner Kallweit
2023-03-25 22:58     ` Heiner Kallweit
2023-03-25 22:58     ` Heiner Kallweit
2023-03-26 10:02     ` Heiner Kallweit
2023-03-26 10:02       ` Heiner Kallweit
2023-03-26 10:02       ` Heiner Kallweit
2023-03-27 12:13     ` Jerome Brunet
2023-03-27 12:13       ` Jerome Brunet
2023-03-27 12:13       ` Jerome Brunet
2023-03-27  7:33 ` Neil Armstrong
2023-03-27  7:33   ` Neil Armstrong
2023-03-27  7:33   ` Neil Armstrong
2023-03-27 17:00   ` Heiner Kallweit [this message]
2023-03-27 17:00     ` Heiner Kallweit
2023-03-27 17:00     ` Heiner Kallweit
2023-03-27 17:50     ` Uwe Kleine-König
2023-03-27 17:50       ` Uwe Kleine-König
2023-03-27 17:50       ` Uwe Kleine-König
2023-03-27 21:14       ` Heiner Kallweit
2023-03-27 21:14         ` Heiner Kallweit
2023-03-27 21:14         ` Heiner Kallweit
2023-03-27 18:11     ` neil.armstrong
2023-03-27 18:11       ` neil.armstrong
2023-03-27 18:11       ` 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=45dbd1d4-a2b8-af33-beec-64906c0e98da@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=jbrunet@baylibre.com \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=narmstrong@baylibre.com \
    --cc=neil.armstrong@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 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.