mbox series

[v3,0/3] RTC: nuvoton: Add nuvoton real time clock driver

Message ID 20220527084647.30835-1-ctcchien@nuvoton.com
Headers show
Series RTC: nuvoton: Add nuvoton real time clock driver | expand

Message

Medad CChien May 27, 2022, 8:46 a.m. UTC
From: Medad CChien <ctcchien@nuvoton.com>

Support Nuvoton NCT3018Y real time clock.

Changes since version 3:
 - Add part number in Kconfig.
 - Refactor rtc-nct3018y.c.

Changes since version 2:
 - Fix errors in rtc-nct3018y.c.
 - Fix warnings in rtc-nct3018y.c.

Changes since version 1:
 - Add nuvoton,nct3018y property in NPCM devicetree.
 - Add new property in rtc binding document.
 - Add new driver for nuvoton real time clock driver.

Medad CChien (3):
  dt-bindings: rtc: nuvoton: add NCT3018Y Real Time Clock
  ARM: dts: nuvoton: Add nuvoton RTC3018Y node
  RTC: nuvoton: Add NCT3018Y real time clock driver

 .../bindings/rtc/nuvoton,nct3018y.yaml        |  44 ++
 MAINTAINERS                                   |   2 +
 arch/arm/boot/dts/nuvoton-npcm750-evb.dts     |   6 +
 drivers/rtc/Kconfig                           |  10 +
 drivers/rtc/Makefile                          |   1 +
 drivers/rtc/rtc-nct3018y.c                    | 560 ++++++++++++++++++
 6 files changed, 623 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
 create mode 100644 drivers/rtc/rtc-nct3018y.c

Comments

Mining Lin July 7, 2022, 9:36 a.m. UTC | #1
Dear Alexandre,

Thank you for your comment and response.
I will refine again and reply below.

Thanks.
Best Regards,
Mia

Alexandre Belloni <alexandre.belloni@bootlin.com> 於 2022年7月7日 週四 下午3:52寫道:
>
> On 07/07/2022 15:17:28+0800, Mining Lin wrote:
> > Dear Alexandre,
> >
> > Thank you for your comments.
> > I will refine and reply below.
> >
> > Thanks.
> > Best Regards,
> > Mia
> >
> > Medad Young <medadyoung@gmail.com> 於 2022年7月7日 週四 下午1:31寫道:
> > >
> > > Hello Alexandre,
> > >
> > > Thanks for your comments.
> > > I add Mining Lin <mimi05633@gmail.com> into this mail thread,
> > > and she is going to follow up this RTC driver.
> > > She will be in charge of maintaining this driver.
> > >
> > > Alexandre Belloni <alexandre.belloni@bootlin.com> 於 2022年6月25日 週六 凌晨4:26寫道:
> > > >
> > > > Hello,
> > > >
> > > > Please run ./scripts/checkpatch.pl --strict on your patch, there are a
> > > > bunch of issues.
> > > >
> > [Mia] I will run ./scripts/checkpatch.pl --strict on my patch to fix issues.
> >
> > > > On 27/05/2022 16:46:47+0800, medadyoung@gmail.com wrote:
> > > > > +static int nct3018y_set_alarm_mode(struct i2c_client *client, bool on)
> > > > > +{
> > > > > +     int err, flags;
> > > > > +
> > > > > +     dev_dbg(&client->dev, "%s:on:%d\n", __func__, on);
> > > > > +
> > > > > +     flags =  i2c_smbus_read_byte_data(client, NCT3018Y_REG_CTRL);
> > > > > +     if (flags < 0) {
> > > > > +             dev_err(&client->dev,
> > > > > +                     "Failed to read NCT3018Y_REG_CTRL\n");
> > > >
> > > > You should cut down on the number of error messages, they are usually
> > > > not useful as the user doesn't have any specific action after getting
> > > > one of them apart from trying the action once again. Also, this will
> > > > make your code shorter. dev_dbg is fine.
> > > >
> > [Mia] I will modify dev_err to dev_dbg if there is an error and nothing to do.
> >
> > > > > +/*
> > > > > + * In the routines that deal directly with the nct3018y hardware, we use
> > > > > + * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
> > > > > + */
> > > > > +static int nct3018y_rtc_read_time(struct device *dev, struct rtc_time *tm)
> > > > > +{
> > > > > +     struct i2c_client *client = to_i2c_client(dev);
> > > > > +     unsigned char buf[10];
> > > > > +     int err;
> > > > > +
> > > >
> > > > You should still return an error if the time is invalid there but without
> > > > an error message.
> > > >
> > [Mia] I will verify the time by rtc_valid_tm(tm).
> >
>
> No, I meant checking NCT3018Y_REG_ST as was done in the previous
> revisions of the series
>
[Mia] I will check NCT3018Y_REG_ST as was done in the previous revisions.

> > > > > +static struct clk *nct3018y_clkout_register_clk(struct nct3018y *nct3018y)
> > > > > +{
> > > > > +     struct i2c_client *client = nct3018y->client;
> > > > > +     struct device_node *node = client->dev.of_node;
> > > > > +     struct clk *clk;
> > > > > +     struct clk_init_data init;
> > > > > +     int flags, err;
> > > > > +
> > > > > +     /* disable the clkout output */
> > > > > +     flags = 0;
> > > > > +     err = i2c_smbus_write_byte_data(client, NCT3018Y_REG_CLKO, flags);
> > > >
> > > > BTW, this introduces a glitch in the clock output if the clock is
> > > > actually used. Maybe you could just rely on the CCF core to disable this
> > > > clock when there are no users.
> > > >
> > [Mia] Do you mean there is no need to disable the clock output here?
> >
>
> The CCF will disable the clock at boot time if there are no users
>
[Mia] I will remove disable clock output. Thank you so much for your reply.

> --
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com