mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	od@zcrc.me, linux-pwm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] pwm: jz4740: Add support for the JZ4725B
Date: Sun, 24 May 2020 19:51:23 +0200	[thread overview]
Message-ID: <N9KUAQ.VPI8V42FNJQU@crapouillou.net> (raw)
In-Reply-To: <20200524173711.ofprgoueyimhkowj@pengutronix.de>

Hi Uwe,

Le dim. 24 mai 2020 à 19:37, Uwe Kleine-König 
<u.kleine-koenig@pengutronix.de> a écrit :
> On Mon, Apr 13, 2020 at 02:14:45PM +0200, Paul Cercueil wrote:
>>  The PWM hardware in the JZ4725B works the same as in the JZ4740, 
>> but has
>>  only six channels available.
>> 
>>  Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>>  ---
>> 
>>  Notes:
>>      I did not add documentation for the new jz4725b-pwm compatible
>>      string on purpose. The reason is that the documentation file
>>      for the Timer/Counter Unit (TCU) of Ingenic SoCs will be
>>      completely rewritten from .txt to YAML in a separate patchset.
>> 
>>   drivers/pwm/pwm-jz4740.c | 20 +++++++++++++++++---
>>   1 file changed, 17 insertions(+), 3 deletions(-)
>> 
>>  diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
>>  index f566f9d248d6..bb27934fb6c2 100644
>>  --- a/drivers/pwm/pwm-jz4740.c
>>  +++ b/drivers/pwm/pwm-jz4740.c
>>  @@ -22,6 +22,10 @@
>> 
>>   #define NUM_PWM 8
>> 
>>  +struct soc_info {
>>  +	unsigned int num_pwms;
>>  +};
>>  +
>>   struct jz4740_pwm_chip {
>>   	struct pwm_chip chip;
>>   	struct regmap *map;
>>  @@ -36,7 +40,7 @@ static bool jz4740_pwm_can_use_chn(struct 
>> jz4740_pwm_chip *jz,
>>   				   unsigned int channel)
>>   {
>>   	/* Enable all TCU channels for PWM use by default except channels 
>> 0/1 */
>>  -	u32 pwm_channels_mask = GENMASK(NUM_PWM - 1, 2);
>>  +	u32 pwm_channels_mask = GENMASK(jz->chip.npwm - 1, 2);
>> 
>>   	device_property_read_u32(jz->chip.dev->parent,
>>   				 "ingenic,pwm-channels-mask",
>>  @@ -214,6 +218,7 @@ static int jz4740_pwm_probe(struct 
>> platform_device *pdev)
>>   {
>>   	struct device *dev = &pdev->dev;
>>   	struct jz4740_pwm_chip *jz4740;
>>  +	const struct soc_info *info = device_get_match_data(dev);
>> 
>>   	jz4740 = devm_kzalloc(dev, sizeof(*jz4740), GFP_KERNEL);
>>   	if (!jz4740)
>>  @@ -227,8 +232,8 @@ static int jz4740_pwm_probe(struct 
>> platform_device *pdev)
>> 
>>   	jz4740->chip.dev = dev;
>>   	jz4740->chip.ops = &jz4740_pwm_ops;
>>  -	jz4740->chip.npwm = NUM_PWM;
>>   	jz4740->chip.base = -1;
>>  +	jz4740->chip.npwm = info ? info->num_pwms : NUM_PWM;
> 
> Can info be actually NULL? I don't think so, so you can just use
> info->num_pwms here and drop the definition of NUM_PWM.

In *theory* it can be NULL if the kernel is configured without 
CONFIG_OF, which will never happen on any board supported by this 
driver. I can add a dependency on CONFIG_OF in V2, then use 
info->num_pwms there.

cheers,
-Paul

>>   	jz4740->chip.of_xlate = of_pwm_xlate_with_flags;
>>   	jz4740->chip.of_pwm_n_cells = 3;
>> 
> 
> Best regards
> Uwe
> 
> --
> Pengutronix e.K.                           | Uwe Kleine-König        
>     |
> Industrial Linux Solutions                 | 
> https://www.pengutronix.de/ |



  reply	other threads:[~2020-05-24 17:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-13 12:14 [PATCH 1/3] pwm: jz4740: Drop dependency on MACH_INGENIC Paul Cercueil
2020-04-13 12:14 ` [PATCH 2/3] pwm: jz4740: Make PWM start with the active part Paul Cercueil
2020-05-24 17:35   ` Uwe Kleine-König
2020-04-13 12:14 ` [PATCH 3/3] pwm: jz4740: Add support for the JZ4725B Paul Cercueil
2020-05-24 17:37   ` Uwe Kleine-König
2020-05-24 17:51     ` Paul Cercueil [this message]
2020-05-24 18:56       ` Uwe Kleine-König
2020-05-24 16:16 ` [PATCH 1/3] pwm: jz4740: Drop dependency on MACH_INGENIC Paul Cercueil
2020-05-24 17:03 ` 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=N9KUAQ.VPI8V42FNJQU@crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=od@zcrc.me \
    --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®