linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: Rob Herring <robh@kernel.org>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Mark Rutland <mark.rutland@arm.com>,
	linux-rtc@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rtc: jz4740: Add support for the JZ4725B, JZ4760, JZ4770
Date: Fri, 20 Jul 2018 21:03:59 +0200	[thread overview]
Message-ID: <1532113439.2309.1@smtp.crapouillou.net> (raw)
In-Reply-To: <20180720153956.GA18135@rob-hp-laptop>

Hi,

Le ven. 20 juil. 2018 =E0 17:39, Rob Herring <robh@kernel.org> a =E9crit :
> On Sat, Jul 14, 2018 at 03:50:08PM +0200, Paul Cercueil wrote:
>>=20
>>=20
>>  Le sam. 14 juil. 2018 =E0 15:32, Alexandre Belloni
>>  <alexandre.belloni@bootlin.com> a =E9crit :
>>  > On 14/07/2018 15:25:33+0200, Paul Cercueil wrote:
>>  > >  Hi Alexandre,
>>  > >
>>  > >  Le sam. 14 juil. 2018 =E0 15:19, Alexandre Belloni
>>  > >  <alexandre.belloni@bootlin.com> a =E9crit :
>>  > >  > Hello,
>>  > >  >
>>  > >  > On 13/07/2018 17:14:24+0200, Paul Cercueil wrote:
>>  > >  > >  The RTC in the JZ4725B works just like the one in the=20
>> JZ4740.
>>  > >  > >
>>  > >  > >  The RTC in the JZ4760 and JZ4770 work just like the one=20
>> in the
>>  > >  > > JZ4780.
>>  > >  > >
>>  > >  > >  Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>>  > >  > >  ---
>>  > >  > >  =20
>> Documentation/devicetree/bindings/rtc/ingenic,jz4740-rtc.txt
>>  > > |  3
>>  > >  > > +++
>>  > >  > >   drivers/rtc/rtc-jz4740.c
>>  > > | 11
>>  > >  > > ++++++++++-
>>  > >  > >   2 files changed, 13 insertions(+), 1 deletion(-)
>>  > >  > >
>>  > >  > >  diff --git
>>  > >  > >=20
>> a/Documentation/devicetree/bindings/rtc/ingenic,jz4740-rtc.txt
>>  > >  > >=20
>> b/Documentation/devicetree/bindings/rtc/ingenic,jz4740-rtc.txt
>>  > >  > >  index 41c7ae18fd7b..a9e821de84f2 100644
>>  > >  > >  ---
>>  > > a/Documentation/devicetree/bindings/rtc/ingenic,jz4740-rtc.txt
>>  > >  > >  +++
>>  > > b/Documentation/devicetree/bindings/rtc/ingenic,jz4740-rtc.txt
>>  > >  > >  @@ -4,6 +4,9 @@ Required properties:
>>  > >  > >
>>  > >  > >   - compatible: One of:
>>  > >  > >     - "ingenic,jz4740-rtc" - for use with the JZ4740 SoC
>>  > >  > >  +  - "ingenic,jz4725b-rtc" - for use with the JZ4725B SoC
>>  > >  > >  +  - "ingenic,jz4760-rtc" - for use with the JZ4760 SoC
>>  > >  > >  +  - "ingenic,jz4770-rtc" - for use with the JZ4770 SoC
>>  > >  > >     - "ingenic,jz4780-rtc" - for use with the JZ4780 SoC
>>  > >  > >   - reg: Address range of rtc register set
>>  > >  > >   - interrupts: IRQ number for the alarm interrupt
>>  > >  > >  diff --git a/drivers/rtc/rtc-jz4740.c
>>  > > b/drivers/rtc/rtc-jz4740.c
>>  > >  > >  index d0a891777f44..1c867e3a0ea5 100644
>>  > >  > >  --- a/drivers/rtc/rtc-jz4740.c
>>  > >  > >  +++ b/drivers/rtc/rtc-jz4740.c
>>  > >  > >  @@ -54,6 +54,9 @@
>>  > >  > >
>>  > >  > >   enum jz4740_rtc_type {
>>  > >  > >   	ID_JZ4740,
>>  > >  > >  +	ID_JZ4725B,
>>  > >  > >  +	ID_JZ4760,
>>  > >  > >  +	ID_JZ4770,
>>  > >  >
>>  > >  > I wouldn't introduce those ids unless there are handling
>>  > > differences at
>>  > >  > some point.
>>  > >
>>  > >  Well there are handling differences, see below.
>>  > >
>>  > >  > >   	ID_JZ4780,
>>  > >  > >   };
>>  > >  > >
>>  > >  > >  @@ -114,7 +117,7 @@ static inline int
>>  > > jz4740_rtc_reg_write(struct
>>  > >  > > jz4740_rtc *rtc, size_t reg,
>>  > >  > >   {
>>  > >  > >   	int ret =3D 0;
>>  > >  > >
>>  > >  > >  -	if (rtc->type >=3D ID_JZ4780)
>>  > >  > >  +	if (rtc->type >=3D ID_JZ4760)
>>  > >  >
>>  > >  > This would avoid that change (and the test would preferably=20
>> be
>>  > >  > (rtc->type =3D=3D ID_JZ4780))
>>  > >
>>  > >  That branch should be taken if the SoC is JZ4760, JZ4770 or=20
>> JZ4780.
>>  > >  It should not be taken if the SoC is JZ4740 or JZ4725B.
>>  >
>>  > Sure but you can achieve that with only 2 ids...
>>  >
>>  > >
>>  > >  > >   		ret =3D jz4780_rtc_enable_write(rtc);
>>  > >  > >   	if (ret =3D=3D 0)
>>  > >  > >   		ret =3D jz4740_rtc_wait_write_ready(rtc);
>>  > >  > >  @@ -300,6 +303,9 @@ static void jz4740_rtc_power_off(void)
>>  > >  > >
>>  > >  > >   static const struct of_device_id jz4740_rtc_of_match[] =3D=20
>> {
>>  > >  > >   	{ .compatible =3D "ingenic,jz4740-rtc", .data =3D (void
>>  > > *)ID_JZ4740 },
>>  > >  > >  +	{ .compatible =3D "ingenic,jz4725b-rtc", .data =3D (void
>>  > > *)ID_JZ4725B
>>  > >  > > },
>>  > >  > >  +	{ .compatible =3D "ingenic,jz4760-rtc", .data =3D (void
>>  > > *)ID_JZ4760 },
>>  > >  > >  +	{ .compatible =3D "ingenic,jz4770-rtc", .data =3D (void
>>  > > *)ID_JZ4770 },
>>  >
>>  > By doing the correct mapping here e.g:
>>  >
>>  > { .compatible =3D "ingenic,jz4725b-rtc", .data =3D (void *)ID_JZ4740=20
>> },
>>=20
>>  Not very pretty and future-proof if you ask me...
>=20
> Looks to me like this can be handled entirely in DT without driver
> changes like the other patches. Correct usage of compatible strings is
> what gives you future-proofing. And no driver change is better than
> needless changing.

If I make e.g. the jz4760 and jz4770 use the jz4780 compatible string,=20
but
then I want to implement a new feature that only exists on the jz4780,=20
how
can I do it without breaking everything?

> It may look a bit wierd if 4780 is the fallback for 4770, but if the
> 4780 is older, then that actually makes sense.

The 4770 is older than the 4780.

Thanks,
-Paul
=

  reply	other threads:[~2018-07-20 19:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 15:14 [PATCH] rtc: jz4740: Add support for the JZ4725B, JZ4760, JZ4770 Paul Cercueil
2018-07-14 13:19 ` Alexandre Belloni
2018-07-14 13:25   ` Paul Cercueil
2018-07-14 13:32     ` Alexandre Belloni
2018-07-14 13:50       ` Paul Cercueil
2018-07-14 16:24         ` Alexandre Belloni
2018-07-20 15:39         ` Rob Herring
2018-07-20 19:03           ` Paul Cercueil [this message]
2018-07-23 14:18             ` Rob Herring
2018-07-23 14:20               ` Paul Cercueil

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=1532113439.2309.1@smtp.crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).