linux/drivers/rtc/rtc-mcp795.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * SPI Driver for Microchip MCP795 RTC
 *
 * Copyright (C) Josef Gajdusek <[email protected]>
 *
 * based on other Linux RTC drivers
 *
 * Device datasheet:
 * https://ww1.microchip.com/downloads/en/DeviceDoc/22280A.pdf
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/printk.h>
#include <linux/spi/spi.h>
#include <linux/rtc.h>
#include <linux/of.h>
#include <linux/bcd.h>
#include <linux/delay.h>

/* MCP795 Instructions, see datasheet table 3-1 */
#define MCP795_EEREAD
#define MCP795_EEWRITE
#define MCP795_EEWRDI
#define MCP795_EEWREN
#define MCP795_SRREAD
#define MCP795_SRWRITE
#define MCP795_READ
#define MCP795_WRITE
#define MCP795_UNLOCK
#define MCP795_IDWRITE
#define MCP795_IDREAD
#define MCP795_CLRWDT
#define MCP795_CLRRAM

/* MCP795 RTCC registers, see datasheet table 4-1 */
#define MCP795_REG_SECONDS
#define MCP795_REG_DAY
#define MCP795_REG_MONTH
#define MCP795_REG_CONTROL
#define MCP795_REG_ALM0_SECONDS
#define MCP795_REG_ALM0_DAY

#define MCP795_ST_BIT
#define MCP795_24_BIT
#define MCP795_LP_BIT
#define MCP795_EXTOSC_BIT
#define MCP795_OSCON_BIT
#define MCP795_ALM0_BIT
#define MCP795_ALM1_BIT
#define MCP795_ALM0IF_BIT
#define MCP795_ALM0C0_BIT
#define MCP795_ALM0C1_BIT
#define MCP795_ALM0C2_BIT

#define SEC_PER_DAY

static int mcp795_rtcc_read(struct device *dev, u8 addr, u8 *buf, u8 count)
{}

static int mcp795_rtcc_write(struct device *dev, u8 addr, u8 *data, u8 count)
{}

static int mcp795_rtcc_set_bits(struct device *dev, u8 addr, u8 mask, u8 state)
{}

static int mcp795_stop_oscillator(struct device *dev, bool *extosc)
{}

static int mcp795_start_oscillator(struct device *dev, bool *extosc)
{}

/* Enable or disable Alarm 0 in RTC */
static int mcp795_update_alarm(struct device *dev, bool enable)
{}

static int mcp795_set_time(struct device *dev, struct rtc_time *tim)
{}

static int mcp795_read_time(struct device *dev, struct rtc_time *tim)
{}

static int mcp795_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
{}

static int mcp795_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
{}

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

static irqreturn_t mcp795_irq(int irq, void *data)
{}

static const struct rtc_class_ops mcp795_rtc_ops =;

static int mcp795_probe(struct spi_device *spi)
{}

#ifdef CONFIG_OF
static const struct of_device_id mcp795_of_match[] =;
MODULE_DEVICE_TABLE(of, mcp795_of_match);
#endif

static const struct spi_device_id mcp795_spi_ids[] =;
MODULE_DEVICE_TABLE(spi, mcp795_spi_ids);

static struct spi_driver mcp795_driver =;

module_spi_driver();

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