mbox series

[v3,0/5] rtc: nintendo: Add a RTC driver for the GameCube, Wii and Wii U

Message ID 20211215175501.6761-1-linkmauve@linkmauve.fr (mailing list archive)
Headers show
Series rtc: nintendo: Add a RTC driver for the GameCube, Wii and Wii U | expand

Message

Emmanuel Gil Peyrot Dec. 15, 2021, 5:54 p.m. UTC
These three consoles share a device, the MX23L4005, which contains a
clock and 64 bytes of SRAM storage, and is exposed on the EXI bus
(similar to SPI) on channel 0, device 1.  This driver allows it to be
used as a Linux RTC device, where time can be read and set.

The hardware also exposes two timers, one which shuts down the console
and one which powers it on, but these aren’t supported currently.

On the Wii U, the counter bias is stored in a XML file, /config/rtc.xml,
encrypted in the SLC (eMMC storage), using a proprietary filesystem.  In
order to avoid having to implement all that, this driver assumes a
bootloader will parse this XML file and write the bias into the SRAM, at
the same location the other two consoles have it.

Changes since v1:
- Rename the driver to rtc-gamecube.
- Switch to the regmap API for debugfs support.
- Report low battery and unstable power as invalid data.
- Remove Wii U support in Kconfig, nothing specific to this console
  needs to be changed in the code.
- Don’t attempt to change HW_SRNPROT on the GameCube, this register
  doesn’t exist so we can use SRAM just fine without doing anything.
- Add needed changes to the wii device tree.
- Enable this driver on the gamecube and wii platforms.

Changes since v2:
- Report low battery correctly.

Emmanuel Gil Peyrot (5):
  rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U
  rtc: gamecube: Report low battery as invalid data
  powerpc: wii.dts: Expose HW_SRNPROT on this platform
  powerpc: gamecube_defconfig: Enable the RTC driver
  powerpc: wii_defconfig: Enable the RTC driver

 arch/powerpc/boot/dts/wii.dts           |   5 +
 arch/powerpc/configs/gamecube_defconfig |   2 +-
 arch/powerpc/configs/wii_defconfig      |   2 +-
 drivers/rtc/Kconfig                     |  11 +
 drivers/rtc/Makefile                    |   1 +
 drivers/rtc/rtc-gamecube.c              | 377 ++++++++++++++++++++++++
 6 files changed, 396 insertions(+), 2 deletions(-)
 create mode 100644 drivers/rtc/rtc-gamecube.c

Comments

Michael Ellerman Dec. 16, 2021, 4:52 a.m. UTC | #1
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> writes:
> These three consoles share a device, the MX23L4005, which contains a
> clock and 64 bytes of SRAM storage, and is exposed on the EXI bus
> (similar to SPI) on channel 0, device 1.  This driver allows it to be
> used as a Linux RTC device, where time can be read and set.
>
> The hardware also exposes two timers, one which shuts down the console
> and one which powers it on, but these aren’t supported currently.
>
> On the Wii U, the counter bias is stored in a XML file, /config/rtc.xml,
> encrypted in the SLC (eMMC storage), using a proprietary filesystem.  In
> order to avoid having to implement all that, this driver assumes a
> bootloader will parse this XML file and write the bias into the SRAM, at
> the same location the other two consoles have it.
>
> Changes since v1:
> - Rename the driver to rtc-gamecube.
> - Switch to the regmap API for debugfs support.
> - Report low battery and unstable power as invalid data.
> - Remove Wii U support in Kconfig, nothing specific to this console
>   needs to be changed in the code.
> - Don’t attempt to change HW_SRNPROT on the GameCube, this register
>   doesn’t exist so we can use SRAM just fine without doing anything.
> - Add needed changes to the wii device tree.
> - Enable this driver on the gamecube and wii platforms.
>
> Changes since v2:
> - Report low battery correctly.
>
> Emmanuel Gil Peyrot (5):
>   rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U
>   rtc: gamecube: Report low battery as invalid data
>   powerpc: wii.dts: Expose HW_SRNPROT on this platform
>   powerpc: gamecube_defconfig: Enable the RTC driver
>   powerpc: wii_defconfig: Enable the RTC driver
>
>  drivers/rtc/Kconfig                     |  11 +
>  drivers/rtc/Makefile                    |   1 +
>  drivers/rtc/rtc-gamecube.c              | 377 ++++++++++++++++++++++++

This is basically an rtc series as far as I'm concerned.

>  arch/powerpc/boot/dts/wii.dts           |   5 +
>  arch/powerpc/configs/gamecube_defconfig |   2 +-
>  arch/powerpc/configs/wii_defconfig      |   2 +-

I have nothing queued in the powerpc tree that touches any of those
files, so conflicts are unlikely.

So I'm happy for this to go via the rtc tree whenever it's ready.

Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)

cheers
Alexandre Belloni Dec. 16, 2021, 9:49 a.m. UTC | #2
On Wed, 15 Dec 2021 18:54:56 +0100, Emmanuel Gil Peyrot wrote:
> These three consoles share a device, the MX23L4005, which contains a
> clock and 64 bytes of SRAM storage, and is exposed on the EXI bus
> (similar to SPI) on channel 0, device 1.  This driver allows it to be
> used as a Linux RTC device, where time can be read and set.
> 
> The hardware also exposes two timers, one which shuts down the console
> and one which powers it on, but these aren’t supported currently.
> 
> [...]

Applied, thanks!

[1/5] rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U
      commit: 86559400b3ef9de93ba50523cffe767c35cd531a
[2/5] rtc: gamecube: Report low battery as invalid data
      commit: 322539a014bcd24cbb9281832c09b24e07912237
[3/5] powerpc: wii.dts: Expose HW_SRNPROT on this platform
      commit: 5479618e1e2641dd57352a73b7b7b2f6908fbeee
[4/5] powerpc: gamecube_defconfig: Enable the RTC driver
      commit: 57bd7d356506b713d0df8d8e42da7810a18864df
[5/5] powerpc: wii_defconfig: Enable the RTC driver
      commit: 69e8ba80ddda4db31e59facbf2db19773ad3785b

This one didn't apply ceanly but I believe I did the right thing. Can you check?


Best regards,
Alexandre Belloni Dec. 16, 2021, 9:50 a.m. UTC | #3
Hello,

On 16/12/2021 15:52:59+1100, Michael Ellerman wrote:
> > Emmanuel Gil Peyrot (5):
> >   rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U
> >   rtc: gamecube: Report low battery as invalid data
> >   powerpc: wii.dts: Expose HW_SRNPROT on this platform
> >   powerpc: gamecube_defconfig: Enable the RTC driver
> >   powerpc: wii_defconfig: Enable the RTC driver
> >
> >  drivers/rtc/Kconfig                     |  11 +
> >  drivers/rtc/Makefile                    |   1 +
> >  drivers/rtc/rtc-gamecube.c              | 377 ++++++++++++++++++++++++
> 
> This is basically an rtc series as far as I'm concerned.
> 
> >  arch/powerpc/boot/dts/wii.dts           |   5 +
> >  arch/powerpc/configs/gamecube_defconfig |   2 +-
> >  arch/powerpc/configs/wii_defconfig      |   2 +-
> 
> I have nothing queued in the powerpc tree that touches any of those
> files, so conflicts are unlikely.
> 
> So I'm happy for this to go via the rtc tree whenever it's ready.
> 
> Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)

That's done, thanks.
Emmanuel Gil Peyrot Dec. 16, 2021, 8:22 p.m. UTC | #4
On Thu, Dec 16, 2021 at 10:49:44AM +0100, Alexandre Belloni wrote:
> On Wed, 15 Dec 2021 18:54:56 +0100, Emmanuel Gil Peyrot wrote:
> > These three consoles share a device, the MX23L4005, which contains a
> > clock and 64 bytes of SRAM storage, and is exposed on the EXI bus
> > (similar to SPI) on channel 0, device 1.  This driver allows it to be
> > used as a Linux RTC device, where time can be read and set.
> > 
> > The hardware also exposes two timers, one which shuts down the console
> > and one which powers it on, but these aren’t supported currently.
> > 
> > [...]
> 
> Applied, thanks!
> 
> [1/5] rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U
>       commit: 86559400b3ef9de93ba50523cffe767c35cd531a
> [2/5] rtc: gamecube: Report low battery as invalid data
>       commit: 322539a014bcd24cbb9281832c09b24e07912237
> [3/5] powerpc: wii.dts: Expose HW_SRNPROT on this platform
>       commit: 5479618e1e2641dd57352a73b7b7b2f6908fbeee
> [4/5] powerpc: gamecube_defconfig: Enable the RTC driver
>       commit: 57bd7d356506b713d0df8d8e42da7810a18864df
> [5/5] powerpc: wii_defconfig: Enable the RTC driver
>       commit: 69e8ba80ddda4db31e59facbf2db19773ad3785b
> 
> This one didn't apply ceanly but I believe I did the right thing. Can you check?

I believe you didn’t, at least that commit[1] seems to have one “+” too
many in the modified line, whereas the previous one[2] doesn’t.

But thanks for applying them!

> 
> 
> Best regards,
> -- 
> Alexandre Belloni <alexandre.belloni@bootlin.com>

[1] https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git/commit/?id=69e8ba80dd
[2] https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git/commit/?id=57bd7d3565
Alexandre Belloni Dec. 16, 2021, 8:56 p.m. UTC | #5
On 16/12/2021 21:22:20+0100, Emmanuel Gil Peyrot wrote:
> On Thu, Dec 16, 2021 at 10:49:44AM +0100, Alexandre Belloni wrote:
> > On Wed, 15 Dec 2021 18:54:56 +0100, Emmanuel Gil Peyrot wrote:
> > > These three consoles share a device, the MX23L4005, which contains a
> > > clock and 64 bytes of SRAM storage, and is exposed on the EXI bus
> > > (similar to SPI) on channel 0, device 1.  This driver allows it to be
> > > used as a Linux RTC device, where time can be read and set.
> > > 
> > > The hardware also exposes two timers, one which shuts down the console
> > > and one which powers it on, but these aren’t supported currently.
> > > 
> > > [...]
> > 
> > Applied, thanks!
> > 
> > [1/5] rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U
> >       commit: 86559400b3ef9de93ba50523cffe767c35cd531a
> > [2/5] rtc: gamecube: Report low battery as invalid data
> >       commit: 322539a014bcd24cbb9281832c09b24e07912237
> > [3/5] powerpc: wii.dts: Expose HW_SRNPROT on this platform
> >       commit: 5479618e1e2641dd57352a73b7b7b2f6908fbeee
> > [4/5] powerpc: gamecube_defconfig: Enable the RTC driver
> >       commit: 57bd7d356506b713d0df8d8e42da7810a18864df
> > [5/5] powerpc: wii_defconfig: Enable the RTC driver
> >       commit: 69e8ba80ddda4db31e59facbf2db19773ad3785b
> > 
> > This one didn't apply ceanly but I believe I did the right thing. Can you check?
> 
> I believe you didn’t, at least that commit[1] seems to have one “+” too
> many in the modified line, whereas the previous one[2] doesn’t.
> 

I knew I needed you to check, this is fixed now.

https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git/commit/?id=c636783d594f6cfc95db51c796761719317ce5eb
Emmanuel Gil Peyrot Dec. 16, 2021, 8:58 p.m. UTC | #6
On Thu, Dec 16, 2021 at 09:56:06PM +0100, Alexandre Belloni wrote:
> On 16/12/2021 21:22:20+0100, Emmanuel Gil Peyrot wrote:
> > On Thu, Dec 16, 2021 at 10:49:44AM +0100, Alexandre Belloni wrote:
> > > On Wed, 15 Dec 2021 18:54:56 +0100, Emmanuel Gil Peyrot wrote:
> > > > These three consoles share a device, the MX23L4005, which contains a
> > > > clock and 64 bytes of SRAM storage, and is exposed on the EXI bus
> > > > (similar to SPI) on channel 0, device 1.  This driver allows it to be
> > > > used as a Linux RTC device, where time can be read and set.
> > > > 
> > > > The hardware also exposes two timers, one which shuts down the console
> > > > and one which powers it on, but these aren’t supported currently.
> > > > 
> > > > [...]
> > > 
> > > Applied, thanks!
> > > 
> > > [1/5] rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U
> > >       commit: 86559400b3ef9de93ba50523cffe767c35cd531a
> > > [2/5] rtc: gamecube: Report low battery as invalid data
> > >       commit: 322539a014bcd24cbb9281832c09b24e07912237
> > > [3/5] powerpc: wii.dts: Expose HW_SRNPROT on this platform
> > >       commit: 5479618e1e2641dd57352a73b7b7b2f6908fbeee
> > > [4/5] powerpc: gamecube_defconfig: Enable the RTC driver
> > >       commit: 57bd7d356506b713d0df8d8e42da7810a18864df
> > > [5/5] powerpc: wii_defconfig: Enable the RTC driver
> > >       commit: 69e8ba80ddda4db31e59facbf2db19773ad3785b
> > > 
> > > This one didn't apply ceanly but I believe I did the right thing. Can you check?
> > 
> > I believe you didn’t, at least that commit[1] seems to have one “+” too
> > many in the modified line, whereas the previous one[2] doesn’t.
> > 
> 
> I knew I needed you to check, this is fixed now.
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git/commit/?id=c636783d594f6cfc95db51c796761719317ce5eb

Perfect, thanks a lot!

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