linux/drivers/rtc/rtc-gamecube.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Nintendo GameCube, Wii and Wii U RTC driver
 *
 * This driver is for the MX23L4005, more specifically its real-time clock and
 * SRAM storage.  The value returned by the RTC counter must be added with the
 * offset stored in a bias register in SRAM (on the GameCube and Wii) or in
 * /config/rtc.xml (on the Wii U).  The latter being very impractical to access
 * from Linux, this driver assumes the bootloader has read it and stored it in
 * SRAM like for the other two consoles.
 *
 * This device sits on a bus named EXI (which is similar to SPI), channel 0,
 * device 1.  This driver assumes no other user of the EXI bus, which is
 * currently the case but would have to be reworked to add support for other
 * GameCube hardware exposed on this bus.
 *
 * References:
 * - https://wiiubrew.org/wiki/Hardware/RTC
 * - https://wiibrew.org/wiki/MX23L4005
 *
 * Copyright (C) 2018 rw-r-r-0644
 * Copyright (C) 2021 Emmanuel Gil Peyrot <[email protected]>
 *
 * Based on rtc-gcn.c
 * Copyright (C) 2004-2009 The GameCube Linux Team
 * Copyright (C) 2005,2008,2009 Albert Herranz
 * Based on gamecube_time.c from Torben Nielsen.
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/rtc.h>
#include <linux/time.h>

/* EXI registers */
#define EXICSR
#define EXICR
#define EXIDATA

/* EXI register values */
#define EXICSR_DEV
	#define EXICSR_DEV1
#define EXICSR_CLK
	#define EXICSR_CLK_1MHZ
	#define EXICSR_CLK_2MHZ
	#define EXICSR_CLK_4MHZ
	#define EXICSR_CLK_8MHZ
	#define EXICSR_CLK_16MHZ
	#define EXICSR_CLK_32MHZ
#define EXICSR_INT
	#define EXICSR_INTSET

#define EXICR_TSTART
#define EXICR_TRSMODE
	#define EXICR_TRSMODE_IMM
#define EXICR_TRSTYPE
	#define EXICR_TRSTYPE_R
	#define EXICR_TRSTYPE_W
#define EXICR_TLEN
	#define EXICR_TLEN32

/* EXI registers values to access the RTC */
#define RTC_EXICSR
#define RTC_EXICR_W
#define RTC_EXICR_R
#define RTC_EXIDATA_W

/* RTC registers */
#define RTC_COUNTER
#define RTC_SRAM
#define RTC_SRAM_BIAS
#define RTC_SNAPSHOT
#define RTC_ONTMR
#define RTC_OFFTMR
#define RTC_TEST0
#define RTC_TEST1
#define RTC_TEST2
#define RTC_TEST3
#define RTC_CONTROL0
#define RTC_CONTROL1

/* RTC flags */
#define RTC_CONTROL0_UNSTABLE_POWER
#define RTC_CONTROL0_LOW_BATTERY

struct priv {};

static int exi_read(void *context, u32 reg, u32 *data)
{}

static int exi_write(void *context, u32 reg, u32 data)
{}

static const struct regmap_bus exi_bus =;

static int gamecube_rtc_read_time(struct device *dev, struct rtc_time *t)
{}

static int gamecube_rtc_set_time(struct device *dev, struct rtc_time *t)
{}

static int gamecube_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
{}

static const struct rtc_class_ops gamecube_rtc_ops =;

static int gamecube_rtc_read_offset_from_sram(struct priv *d)
{}

static const struct regmap_range rtc_rd_ranges[] =;

static const struct regmap_access_table rtc_rd_regs =;

static const struct regmap_range rtc_wr_ranges[] =;

static const struct regmap_access_table rtc_wr_regs =;

static const struct regmap_config gamecube_rtc_regmap_config =;

static int gamecube_rtc_probe(struct platform_device *pdev)
{}

static const struct of_device_id gamecube_rtc_of_match[] =;
MODULE_DEVICE_TABLE(of, gamecube_rtc_of_match);

static struct platform_driver gamecube_rtc_driver =;
module_platform_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();