mbox series

[0/6] rtc: add rtc_{read,write}8_array and rtc command

Message ID 20200504212032.3759-1-rasmus.villemoes@prevas.dk
Headers show
Series rtc: add rtc_{read,write}8_array and rtc command | expand

Message

Rasmus Villemoes May 4, 2020, 9:20 p.m. UTC
I need access to registers other than just the timekeeping ones of the
pcf2127, so I wanted to implement ->read8 and ->write8. But for
testing these it appeared there was no convenient way to invoke those
from the shell, so I also ended up adding such a command.

Also, it seemed more natural to provide array variants that can read
or write several registers at once, so rtc_ops is expanded a bit.

There are a few things one could do on top, but for now I just want
some feedback, especially on the new _array methods. "rtc set", "rtc
get" and "rtc reset" are rather obvious subsommands to add at some
point. Also, rtc_{read,write}{16,32} can be simplified a bit, along
the lines of

__le16 v;
int ret = rtc_read8_array(dev, reg, &v, 2);
if (ret)
  return ret;
*valuep = __le16_to_cpu(v);
return 0;

Rasmus Villemoes (6):
  rtc: add rtc_read8_array helper and ->read8_array method
  rtc: add rtc_write8_array() helper
  rtc: fall back to ->{read,write}8_array if ->{read,write}8 are not
    provided
  rtc: pcf2127: provide ->read8_array method
  rtc: pcf2127: provide ->write8_array method
  rtc: add rtc command

 cmd/Kconfig              |   6 ++
 cmd/Makefile             |   1 +
 cmd/rtc.c                | 153 +++++++++++++++++++++++++++++++++++++++
 drivers/rtc/pcf2127.c    |  14 +++-
 drivers/rtc/rtc-uclass.c |  53 +++++++++++++-
 include/rtc.h            |  48 ++++++++++++
 6 files changed, 270 insertions(+), 5 deletions(-)
 create mode 100644 cmd/rtc.c

Comments

Rasmus Villemoes May 19, 2020, 10:01 p.m. UTC | #1
I need access to registers other than just the timekeeping ones of the
pcf2127, so I wanted to implement ->read8 and ->write8. But for
testing these it appeared there was no convenient way to invoke those
from the shell, so I also ended up adding such a command.

Also, it seemed more natural to provide array variants that can read
or write several registers at once, so rtc_ops is expanded a bit.

Changes in v2:

- Use simply "read" and "write" instead of "read8_array",
  "write8_array", both for functions and methods, as suggested by
  Simon.

- The rtc command's interface has been simplified a bit (no separate
  read/readm; the number of arguments determines whether the user
  wants the result on the console or to a memory address)

- Add tests, both of rtc_{read,write}() and of the shell command,
  fixing a few things I stumbled on.

Rasmus Villemoes (10):
  rtc: add rtc_read helper and ->read method
  rtc: add rtc_write() helper
  rtc: fall back to ->{read,write} if ->{read,write}8 are not provided
  rtc: pcf2127: provide ->read method
  rtc: pcf2127: provide ->write method
  rtc: add rtc command
  rtc: sandbox-rtc: fix set method
  rtc: i2c_rtc_emul: catch any write to the "reset" register
  test: dm: rtc: add test of rtc_read, rtc_write
  test: dm: rtc: add tests of rtc shell command

 arch/sandbox/include/asm/rtc.h |   5 ++
 cmd/Kconfig                    |   6 ++
 cmd/Makefile                   |   1 +
 cmd/rtc.c                      | 159 +++++++++++++++++++++++++++++++++
 drivers/rtc/i2c_rtc_emul.c     |   3 +-
 drivers/rtc/pcf2127.c          |  13 ++-
 drivers/rtc/rtc-uclass.c       |  56 +++++++++++-
 drivers/rtc/sandbox_rtc.c      |  65 +++++---------
 include/rtc.h                  |  47 ++++++++++
 test/dm/rtc.c                  | 121 ++++++++++++++++++++++++-
 10 files changed, 426 insertions(+), 50 deletions(-)
 create mode 100644 cmd/rtc.c