linux/drivers/rtc/rtc-m41t80.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * I2C client/driver for the ST M41T80 family of i2c rtc chips.
 *
 * Author: Alexander Bigga <[email protected]>
 *
 * Based on m41t00.c by Mark A. Greer <[email protected]>
 *
 * 2006 (c) mycable GmbH
 */

#define pr_fmt(fmt)

#include <linux/bcd.h>
#include <linux/clk-provider.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/rtc.h>
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/string.h>
#ifdef CONFIG_RTC_DRV_M41T80_WDT
#include <linux/fs.h>
#include <linux/ioctl.h>
#include <linux/miscdevice.h>
#include <linux/reboot.h>
#include <linux/watchdog.h>
#endif

#define M41T80_REG_SSEC
#define M41T80_REG_SEC
#define M41T80_REG_MIN
#define M41T80_REG_HOUR
#define M41T80_REG_WDAY
#define M41T80_REG_DAY
#define M41T80_REG_MON
#define M41T80_REG_YEAR
#define M41T80_REG_ALARM_MON
#define M41T80_REG_ALARM_DAY
#define M41T80_REG_ALARM_HOUR
#define M41T80_REG_ALARM_MIN
#define M41T80_REG_ALARM_SEC
#define M41T80_REG_FLAGS
#define M41T80_REG_SQW

#define M41T80_DATETIME_REG_SIZE
#define M41T80_ALARM_REG_SIZE

#define M41T80_SQW_MAX_FREQ

#define M41T80_SEC_ST
#define M41T80_ALMON_AFE
#define M41T80_ALMON_SQWE
#define M41T80_ALHOUR_HT
#define M41T80_FLAGS_OF
#define M41T80_FLAGS_AF
#define M41T80_FLAGS_BATT_LOW
#define M41T80_WATCHDOG_RB2
#define M41T80_WATCHDOG_RB1
#define M41T80_WATCHDOG_RB0

#define M41T80_FEATURE_HT
#define M41T80_FEATURE_BL
#define M41T80_FEATURE_SQ
#define M41T80_FEATURE_WD
#define M41T80_FEATURE_SQ_ALT

static const struct i2c_device_id m41t80_id[] =;
MODULE_DEVICE_TABLE(i2c, m41t80_id);

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

struct m41t80_data {};

static irqreturn_t m41t80_handle_irq(int irq, void *dev_id)
{}

static int m41t80_rtc_read_time(struct device *dev, struct rtc_time *tm)
{}

static int m41t80_rtc_set_time(struct device *dev, struct rtc_time *tm)
{}

static int m41t80_rtc_proc(struct device *dev, struct seq_file *seq)
{}

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

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

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

static const struct rtc_class_ops m41t80_rtc_ops =;

#ifdef CONFIG_PM_SLEEP
static int m41t80_suspend(struct device *dev)
{}

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

static SIMPLE_DEV_PM_OPS(m41t80_pm, m41t80_suspend, m41t80_resume);

#ifdef CONFIG_COMMON_CLK
#define sqw_to_m41t80_data(_hw)

static unsigned long m41t80_decode_freq(int setting)
{}

static unsigned long m41t80_get_freq(struct m41t80_data *m41t80)
{}

static unsigned long m41t80_sqw_recalc_rate(struct clk_hw *hw,
					    unsigned long parent_rate)
{}

static long m41t80_sqw_round_rate(struct clk_hw *hw, unsigned long rate,
				  unsigned long *prate)
{}

static int m41t80_sqw_set_rate(struct clk_hw *hw, unsigned long rate,
			       unsigned long parent_rate)
{}

static int m41t80_sqw_control(struct clk_hw *hw, bool enable)
{}

static int m41t80_sqw_prepare(struct clk_hw *hw)
{}

static void m41t80_sqw_unprepare(struct clk_hw *hw)
{}

static int m41t80_sqw_is_prepared(struct clk_hw *hw)
{}

static const struct clk_ops m41t80_sqw_ops =;

static struct clk *m41t80_sqw_register_clk(struct m41t80_data *m41t80)
{}
#endif

#ifdef CONFIG_RTC_DRV_M41T80_WDT
/*
 *****************************************************************************
 *
 * Watchdog Driver
 *
 *****************************************************************************
 */
static DEFINE_MUTEX(m41t80_rtc_mutex);
static struct i2c_client *save_client;

/* Default margin */
#define WD_TIMO

static int wdt_margin =;
module_param(wdt_margin, int, 0);
MODULE_PARM_DESC();

static unsigned long wdt_is_open;
static int boot_flag;

/**
 *	wdt_ping - Reload counter one with the watchdog timeout.
 *	We don't bother reloading the cascade counter.
 */
static void wdt_ping(void)
{}

/**
 *	wdt_disable - disables watchdog.
 */
static void wdt_disable(void)
{}

/**
 *	wdt_write - write to watchdog.
 *	@file: file handle to the watchdog
 *	@buf: buffer to write (unused as data does not matter here
 *	@count: count of bytes
 *	@ppos: pointer to the position to write. No seeks allowed
 *
 *	A write to a watchdog device is defined as a keepalive signal. Any
 *	write of data will do, as we don't define content meaning.
 */
static ssize_t wdt_write(struct file *file, const char __user *buf,
			 size_t count, loff_t *ppos)
{}

static ssize_t wdt_read(struct file *file, char __user *buf,
			size_t count, loff_t *ppos)
{}

/**
 *	wdt_ioctl - ioctl handler to set watchdog.
 *	@file: file handle to the device
 *	@cmd: watchdog command
 *	@arg: argument pointer
 *
 *	The watchdog API defines a common set of functions for all watchdogs
 *	according to their available features. We only actually usefully support
 *	querying capabilities and current status.
 */
static int wdt_ioctl(struct file *file, unsigned int cmd,
		     unsigned long arg)
{}

static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd,
			       unsigned long arg)
{}

/**
 *	wdt_open - open a watchdog.
 *	@inode: inode of device
 *	@file: file handle to device
 *
 */
static int wdt_open(struct inode *inode, struct file *file)
{}

/**
 *	wdt_release - release a watchdog.
 *	@inode: inode to board
 *	@file: file handle to board
 *
 */
static int wdt_release(struct inode *inode, struct file *file)
{}

/**
 *	wdt_notify_sys - notify to watchdog.
 *	@this: our notifier block
 *	@code: the event being reported
 *	@unused: unused
 *
 *	Our notifier is called on system shutdowns. We want to turn the card
 *	off at reboot otherwise the machine will reboot again during memory
 *	test or worse yet during the following fsck. This would suck, in fact
 *	trust me - if it happens it does suck.
 */
static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
			  void *unused)
{}

static const struct file_operations wdt_fops =;

static struct miscdevice wdt_dev =;

/*
 *	The WDT card needs to learn about soft shutdowns in order to
 *	turn the timebomb registers off.
 */
static struct notifier_block wdt_notifier =;
#endif /* CONFIG_RTC_DRV_M41T80_WDT */

/*
 *****************************************************************************
 *
 *	Driver Interface
 *
 *****************************************************************************
 */

static int m41t80_probe(struct i2c_client *client)
{}

static void m41t80_remove(struct i2c_client *client)
{}

static struct i2c_driver m41t80_driver =;

module_i2c_driver();

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