#include <linux/i2c.h>
#include <linux/rtc.h>
#include <linux/bcd.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/of.h>
#define RS5C372_REG_SECS …
#define RS5C372_REG_MINS …
#define RS5C372_REG_HOURS …
#define RS5C372_REG_WDAY …
#define RS5C372_REG_DAY …
#define RS5C372_REG_MONTH …
#define RS5C372_REG_YEAR …
#define RS5C372_REG_TRIM …
#define RS5C372_TRIM_XSL …
#define RS5C372_TRIM_MASK …
#define R2221TL_TRIM_DEV …
#define RS5C372_TRIM_DECR …
#define RS5C_REG_ALARM_A_MIN …
#define RS5C_REG_ALARM_A_HOURS …
#define RS5C_REG_ALARM_A_WDAY …
#define RS5C_REG_ALARM_B_MIN …
#define RS5C_REG_ALARM_B_HOURS …
#define RS5C_REG_ALARM_B_WDAY …
#define RS5C_REG_CTRL1 …
#define RS5C_CTRL1_AALE …
#define RS5C_CTRL1_BALE …
#define RV5C387_CTRL1_24 …
#define RS5C372A_CTRL1_SL1 …
#define RS5C_CTRL1_CT_MASK …
#define RS5C_CTRL1_CT0 …
#define RS5C_CTRL1_CT4 …
#define RS5C_REG_CTRL2 …
#define RS5C372_CTRL2_24 …
#define RS5C_CTRL2_XSTP …
#define R2x2x_CTRL2_VDET …
#define R2x2x_CTRL2_XSTP …
#define R2x2x_CTRL2_PON …
#define RS5C_CTRL2_CTFG …
#define RS5C_CTRL2_AAFG …
#define RS5C_CTRL2_BAFG …
#define RS5C_ADDR(R) …
enum rtc_type { … };
static const struct i2c_device_id rs5c372_id[] = …;
MODULE_DEVICE_TABLE(i2c, rs5c372_id);
static const __maybe_unused struct of_device_id rs5c372_of_match[] = …;
MODULE_DEVICE_TABLE(of, rs5c372_of_match);
struct rs5c372 { … };
static int rs5c_get_regs(struct rs5c372 *rs5c)
{ … }
static unsigned rs5c_reg2hr(struct rs5c372 *rs5c, unsigned reg)
{ … }
static unsigned rs5c_hr2reg(struct rs5c372 *rs5c, unsigned hour)
{ … }
static int rs5c372_rtc_read_time(struct device *dev, struct rtc_time *tm)
{ … }
static int rs5c372_rtc_set_time(struct device *dev, struct rtc_time *tm)
{ … }
#if IS_ENABLED(CONFIG_RTC_INTF_PROC)
#define NEED_TRIM
#endif
#if IS_ENABLED(CONFIG_RTC_INTF_SYSFS)
#define NEED_TRIM
#endif
#ifdef NEED_TRIM
static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim)
{ … }
#endif
static int rs5c_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
{ … }
static int rs5c_read_alarm(struct device *dev, struct rtc_wkalrm *t)
{ … }
static int rs5c_set_alarm(struct device *dev, struct rtc_wkalrm *t)
{ … }
#if IS_ENABLED(CONFIG_RTC_INTF_PROC)
static int rs5c372_rtc_proc(struct device *dev, struct seq_file *seq)
{ … }
#else
#define rs5c372_rtc_proc …
#endif
#ifdef CONFIG_RTC_INTF_DEV
static int rs5c372_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
{ … }
#else
#define rs5c372_ioctl …
#endif
static int rs5c372_read_offset(struct device *dev, long *offset)
{ … }
static int rs5c372_set_offset(struct device *dev, long offset)
{ … }
static const struct rtc_class_ops rs5c372_rtc_ops = …;
#if IS_ENABLED(CONFIG_RTC_INTF_SYSFS)
static ssize_t rs5c372_sysfs_show_trim(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR(trim, S_IRUGO, rs5c372_sysfs_show_trim, NULL);
static ssize_t rs5c372_sysfs_show_osc(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR(osc, S_IRUGO, rs5c372_sysfs_show_osc, NULL);
static int rs5c_sysfs_register(struct device *dev)
{ … }
static void rs5c_sysfs_unregister(struct device *dev)
{ … }
#else
static int rs5c_sysfs_register(struct device *dev)
{
return 0;
}
static void rs5c_sysfs_unregister(struct device *dev)
{
}
#endif
static struct i2c_driver rs5c372_driver;
static int rs5c_oscillator_setup(struct rs5c372 *rs5c372)
{ … }
static int rs5c372_probe(struct i2c_client *client)
{ … }
static void rs5c372_remove(struct i2c_client *client)
{ … }
static struct i2c_driver rs5c372_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;