linux/drivers/rtc/rtc-rs5c372.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * An I2C driver for Ricoh RS5C372, R2025S/D and RV5C38[67] RTCs
 *
 * Copyright (C) 2005 Pavel Mironchik <[email protected]>
 * Copyright (C) 2006 Tower Technologies
 * Copyright (C) 2008 Paul Mundt
 */

#include <linux/i2c.h>
#include <linux/rtc.h>
#include <linux/bcd.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/of.h>

/*
 * Ricoh has a family of I2C based RTCs, which differ only slightly from
 * each other.  Differences center on pinout (e.g. how many interrupts,
 * output clock, etc) and how the control registers are used.  The '372
 * is significant only because that's the one this driver first supported.
 */
#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


/* to read (style 1) or write registers starting at R */
#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);

/* REVISIT:  this assumes that:
 *  - we're in the 21st century, so it's safe to ignore the century
 *    bit for rv5c38[67] (REG_MONTH bit 7);
 *  - we should use ALARM_A not ALARM_B (may be wrong on some boards)
 */
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)
{}


/* NOTE:  Since RTC_WKALM_{RD,SET} were originally defined for EFI,
 * which only exposes a polled programming interface; and since
 * these calls map directly to those EFI requests; we don't demand
 * we have an IRQ for this chip when we go through this API.
 *
 * The older x86_pc derived RTC_ALM_{READ,SET} calls require irqs
 * though, managed through RTC_AIE_{ON,OFF} requests.
 */

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)
{
	/* nothing */
}
#endif	/* SYSFS */

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();