#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
static DEFINE_MUTEX(m41t80_rtc_mutex);
static struct i2c_client *save_client;
#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;
static void wdt_ping(void)
{ … }
static void wdt_disable(void)
{ … }
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)
{ … }
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)
{ … }
static int wdt_open(struct inode *inode, struct file *file)
{ … }
static int wdt_release(struct inode *inode, struct file *file)
{ … }
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 = …;
static struct notifier_block wdt_notifier = …;
#endif
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(…) …;