linux/drivers/rtc/rtc-ti-k3.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Texas Instruments K3 RTC driver
 *
 * Copyright (C) 2021-2022 Texas Instruments Incorporated - https://www.ti.com/
 */

#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/sys_soc.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/rtc.h>

/* Registers */
#define REG_K3RTC_S_CNT_LSW
#define REG_K3RTC_S_CNT_MSW
#define REG_K3RTC_COMP
#define REG_K3RTC_ON_OFF_S_CNT_LSW
#define REG_K3RTC_ON_OFF_S_CNT_MSW
#define REG_K3RTC_SCRATCH0
#define REG_K3RTC_SCRATCH7
#define REG_K3RTC_GENERAL_CTL
#define REG_K3RTC_IRQSTATUS_RAW_SYS
#define REG_K3RTC_IRQSTATUS_SYS
#define REG_K3RTC_IRQENABLE_SET_SYS
#define REG_K3RTC_IRQENABLE_CLR_SYS
#define REG_K3RTC_SYNCPEND
#define REG_K3RTC_KICK0
#define REG_K3RTC_KICK1

/* Freeze when lsw is read and unfreeze when msw is read */
#define K3RTC_CNT_FMODE_S_CNT_VALUE

/* Magic values for lock/unlock */
#define K3RTC_KICK0_UNLOCK_VALUE
#define K3RTC_KICK1_UNLOCK_VALUE

/* Multiplier for ppb conversions */
#define K3RTC_PPB_MULT
/* Min and max values supported with 'offset' interface (swapped sign) */
#define K3RTC_MIN_OFFSET
#define K3RTC_MAX_OFFSET

static const struct regmap_config ti_k3_rtc_regmap_config =;

enum ti_k3_rtc_fields {};

static const struct reg_field ti_rtc_reg_fields[] =;

/**
 * struct ti_k3_rtc - Private data for ti-k3-rtc
 * @irq:		IRQ
 * @sync_timeout_us:	data sync timeout period in uSec
 * @rate_32k:		32k clock rate in Hz
 * @rtc_dev:		rtc device
 * @regmap:		rtc mmio regmap
 * @r_fields:		rtc register fields
 */
struct ti_k3_rtc {};

static int k3rtc_field_read(struct ti_k3_rtc *priv, enum ti_k3_rtc_fields f)
{}

static void k3rtc_field_write(struct ti_k3_rtc *priv, enum ti_k3_rtc_fields f, u32 val)
{}

/**
 * k3rtc_fence  - Ensure a register sync took place between the two domains
 * @priv:      pointer to priv data
 *
 * Return: 0 if the sync took place, else returns -ETIMEDOUT
 */
static int k3rtc_fence(struct ti_k3_rtc *priv)
{}

static inline int k3rtc_check_unlocked(struct ti_k3_rtc *priv)
{}

static int k3rtc_unlock_rtc(struct ti_k3_rtc *priv)
{}

/*
 * This is the list of SoCs affected by TI's i2327 errata causing the RTC
 * state-machine to break if not unlocked fast enough during boot. These
 * SoCs must have the bootloader unlock this device very early in the
 * boot-flow before we (Linux) can use this device.
 */
static const struct soc_device_attribute has_erratum_i2327[] =;

static int k3rtc_configure(struct device *dev)
{}

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

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

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

static int ti_k3_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{}

static int ti_k3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{}

static int ti_k3_rtc_read_offset(struct device *dev, long *offset)
{}

static int ti_k3_rtc_set_offset(struct device *dev, long offset)
{}

static irqreturn_t ti_k3_rtc_interrupt(s32 irq, void *dev_id)
{}

static const struct rtc_class_ops ti_k3_rtc_ops =;

static int ti_k3_rtc_scratch_read(void *priv_data, unsigned int offset,
				  void *val, size_t bytes)
{}

static int ti_k3_rtc_scratch_write(void *priv_data, unsigned int offset,
				   void *val, size_t bytes)
{}

static struct nvmem_config ti_k3_rtc_nvmem_config =;

static int k3rtc_get_32kclk(struct device *dev, struct ti_k3_rtc *priv)
{}

static int k3rtc_get_vbusclk(struct device *dev, struct ti_k3_rtc *priv)
{}

static int ti_k3_rtc_probe(struct platform_device *pdev)
{}

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

static int __maybe_unused ti_k3_rtc_suspend(struct device *dev)
{}

static int __maybe_unused ti_k3_rtc_resume(struct device *dev)
{}

static SIMPLE_DEV_PM_OPS(ti_k3_rtc_pm_ops, ti_k3_rtc_suspend, ti_k3_rtc_resume);

static struct platform_driver ti_k3_rtc_driver =;
module_platform_driver();

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