linux/drivers/rtc/rtc-at91sam9.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * "RTT as Real Time Clock" driver for AT91SAM9 SoC family
 *
 * (C) 2007 Michel Benoit
 *
 * Based on rtc-at91rm9200.c by Rick Bronson
 */

#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/ioctl.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/rtc.h>
#include <linux/slab.h>
#include <linux/suspend.h>
#include <linux/time.h>

/*
 * This driver uses two configurable hardware resources that live in the
 * AT91SAM9 backup power domain (intended to be powered at all times)
 * to implement the Real Time Clock interfaces
 *
 *  - A "Real-time Timer" (RTT) counts up in seconds from a base time.
 *    We can't assign the counter value (CRTV) ... but we can reset it.
 *
 *  - One of the "General Purpose Backup Registers" (GPBRs) holds the
 *    base time, normally an offset from the beginning of the POSIX
 *    epoch (1970-Jan-1 00:00:00 UTC).  Some systems also include the
 *    local timezone's offset.
 *
 * The RTC's value is the RTT counter plus that offset.  The RTC's alarm
 * is likewise a base (ALMV) plus that offset.
 *
 * Not all RTTs will be used as RTCs; some systems have multiple RTTs to
 * choose from, or a "real" RTC module.  All systems have multiple GPBR
 * registers available, likewise usable for more than "RTC" support.
 */

#define AT91_RTT_MR
#define AT91_RTT_RTPRES
#define AT91_RTT_ALMIEN
#define AT91_RTT_RTTINCIEN
#define AT91_RTT_RTTRST

#define AT91_RTT_AR
#define AT91_RTT_ALMV

#define AT91_RTT_VR
#define AT91_RTT_CRTV

#define AT91_RTT_SR
#define AT91_RTT_ALMS
#define AT91_RTT_RTTINC

/*
 * We store ALARM_DISABLED in ALMV to record that no alarm is set.
 * It's also the reset value for that field.
 */
#define ALARM_DISABLED

struct sam9_rtc {};

#define rtt_readl(rtc, field)
#define rtt_writel(rtc, field, val)

static inline unsigned int gpbr_readl(struct sam9_rtc *rtc)
{}

static inline void gpbr_writel(struct sam9_rtc *rtc, unsigned int val)
{}

/*
 * Read current time and date in RTC
 */
static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm)
{}

/*
 * Set current time and date in RTC
 */
static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
{}

static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
{}

static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
{}

static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
{}

/*
 * Provide additional RTC information in /proc/driver/rtc
 */
static int at91_rtc_proc(struct device *dev, struct seq_file *seq)
{}

static irqreturn_t at91_rtc_cache_events(struct sam9_rtc *rtc)
{}

static void at91_rtc_flush_events(struct sam9_rtc *rtc)
{}

/*
 * IRQ handler for the RTC
 */
static irqreturn_t at91_rtc_interrupt(int irq, void *_rtc)
{}

static const struct rtc_class_ops at91_rtc_ops =;

/*
 * Initialize and install RTC driver
 */
static int at91_rtc_probe(struct platform_device *pdev)
{}

/*
 * Disable and remove the RTC driver
 */
static void at91_rtc_remove(struct platform_device *pdev)
{}

static void at91_rtc_shutdown(struct platform_device *pdev)
{}

#ifdef CONFIG_PM_SLEEP

/* AT91SAM9 RTC Power management control */

static int at91_rtc_suspend(struct device *dev)
{}

static int at91_rtc_resume(struct device *dev)
{}
#endif

static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume);

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

static struct platform_driver at91_rtc_driver =;

module_platform_driver();

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