linux/drivers/rtc/interface.c

// SPDX-License-Identifier: GPL-2.0
/*
 * RTC subsystem, interface functions
 *
 * Copyright (C) 2005 Tower Technologies
 * Author: Alessandro Zummo <[email protected]>
 *
 * based on arch/arm/common/rtctime.c
 */

#include <linux/rtc.h>
#include <linux/sched.h>
#include <linux/module.h>
#include <linux/log2.h>
#include <linux/workqueue.h>

#define CREATE_TRACE_POINTS
#include <trace/events/rtc.h>

static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer);
static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer);

static void rtc_add_offset(struct rtc_device *rtc, struct rtc_time *tm)
{}

static void rtc_subtract_offset(struct rtc_device *rtc, struct rtc_time *tm)
{}

static int rtc_valid_range(struct rtc_device *rtc, struct rtc_time *tm)
{}

static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
{}

int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
{}
EXPORT_SYMBOL_GPL();

int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
{}
EXPORT_SYMBOL_GPL();

static int rtc_read_alarm_internal(struct rtc_device *rtc,
				   struct rtc_wkalrm *alarm)
{}

int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
{}

int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
{}
EXPORT_SYMBOL_GPL();

static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
{}

int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
{}
EXPORT_SYMBOL_GPL();

/* Called once per device from rtc_device_register */
int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
{}
EXPORT_SYMBOL_GPL();

int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
{}
EXPORT_SYMBOL_GPL();

int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
{}
EXPORT_SYMBOL_GPL();

/**
 * rtc_handle_legacy_irq - AIE, UIE and PIE event hook
 * @rtc: pointer to the rtc device
 * @num: number of occurence of the event
 * @mode: type of the event, RTC_AF, RTC_UF of RTC_PF
 *
 * This function is called when an AIE, UIE or PIE mode interrupt
 * has occurred (or been emulated).
 *
 */
void rtc_handle_legacy_irq(struct rtc_device *rtc, int num, int mode)
{}

/**
 * rtc_aie_update_irq - AIE mode rtctimer hook
 * @rtc: pointer to the rtc_device
 *
 * This functions is called when the aie_timer expires.
 */
void rtc_aie_update_irq(struct rtc_device *rtc)
{}

/**
 * rtc_uie_update_irq - UIE mode rtctimer hook
 * @rtc: pointer to the rtc_device
 *
 * This functions is called when the uie_timer expires.
 */
void rtc_uie_update_irq(struct rtc_device *rtc)
{}

/**
 * rtc_pie_update_irq - PIE mode hrtimer hook
 * @timer: pointer to the pie mode hrtimer
 *
 * This function is used to emulate PIE mode interrupts
 * using an hrtimer. This function is called when the periodic
 * hrtimer expires.
 */
enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer)
{}

/**
 * rtc_update_irq - Triggered when a RTC interrupt occurs.
 * @rtc: the rtc device
 * @num: how many irqs are being reported (usually one)
 * @events: mask of RTC_IRQF with one or more of RTC_PF, RTC_AF, RTC_UF
 * Context: any
 */
void rtc_update_irq(struct rtc_device *rtc,
		    unsigned long num, unsigned long events)
{}
EXPORT_SYMBOL_GPL();

struct rtc_device *rtc_class_open(const char *name)
{}
EXPORT_SYMBOL_GPL();

void rtc_class_close(struct rtc_device *rtc)
{}
EXPORT_SYMBOL_GPL();

static int rtc_update_hrtimer(struct rtc_device *rtc, int enabled)
{}

/**
 * rtc_irq_set_state - enable/disable 2^N Hz periodic IRQs
 * @rtc: the rtc device
 * @enabled: true to enable periodic IRQs
 * Context: any
 *
 * Note that rtc_irq_set_freq() should previously have been used to
 * specify the desired frequency of periodic IRQ.
 */
int rtc_irq_set_state(struct rtc_device *rtc, int enabled)
{}

/**
 * rtc_irq_set_freq - set 2^N Hz periodic IRQ frequency for IRQ
 * @rtc: the rtc device
 * @freq: positive frequency
 * Context: any
 *
 * Note that rtc_irq_set_state() is used to enable or disable the
 * periodic IRQs.
 */
int rtc_irq_set_freq(struct rtc_device *rtc, int freq)
{}

/**
 * rtc_timer_enqueue - Adds a rtc_timer to the rtc_device timerqueue
 * @rtc: rtc device
 * @timer: timer being added.
 *
 * Enqueues a timer onto the rtc devices timerqueue and sets
 * the next alarm event appropriately.
 *
 * Sets the enabled bit on the added timer.
 *
 * Must hold ops_lock for proper serialization of timerqueue
 */
static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
{}

static void rtc_alarm_disable(struct rtc_device *rtc)
{}

/**
 * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue
 * @rtc: rtc device
 * @timer: timer being removed.
 *
 * Removes a timer onto the rtc devices timerqueue and sets
 * the next alarm event appropriately.
 *
 * Clears the enabled bit on the removed timer.
 *
 * Must hold ops_lock for proper serialization of timerqueue
 */
static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
{}

/**
 * rtc_timer_do_work - Expires rtc timers
 * @work: work item
 *
 * Expires rtc timers. Reprograms next alarm event if needed.
 * Called via worktask.
 *
 * Serializes access to timerqueue via ops_lock mutex
 */
void rtc_timer_do_work(struct work_struct *work)
{}

/* rtc_timer_init - Initializes an rtc_timer
 * @timer: timer to be intiialized
 * @f: function pointer to be called when timer fires
 * @rtc: pointer to the rtc_device
 *
 * Kernel interface to initializing an rtc_timer.
 */
void rtc_timer_init(struct rtc_timer *timer, void (*f)(struct rtc_device *r),
		    struct rtc_device *rtc)
{}

/* rtc_timer_start - Sets an rtc_timer to fire in the future
 * @ rtc: rtc device to be used
 * @ timer: timer being set
 * @ expires: time at which to expire the timer
 * @ period: period that the timer will recur
 *
 * Kernel interface to set an rtc_timer
 */
int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer *timer,
		    ktime_t expires, ktime_t period)
{}

/* rtc_timer_cancel - Stops an rtc_timer
 * @ rtc: rtc device to be used
 * @ timer: timer being set
 *
 * Kernel interface to cancel an rtc_timer
 */
void rtc_timer_cancel(struct rtc_device *rtc, struct rtc_timer *timer)
{}

/**
 * rtc_read_offset - Read the amount of rtc offset in parts per billion
 * @rtc: rtc device to be used
 * @offset: the offset in parts per billion
 *
 * see below for details.
 *
 * Kernel interface to read rtc clock offset
 * Returns 0 on success, or a negative number on error.
 * If read_offset() is not implemented for the rtc, return -EINVAL
 */
int rtc_read_offset(struct rtc_device *rtc, long *offset)
{}

/**
 * rtc_set_offset - Adjusts the duration of the average second
 * @rtc: rtc device to be used
 * @offset: the offset in parts per billion
 *
 * Some rtc's allow an adjustment to the average duration of a second
 * to compensate for differences in the actual clock rate due to temperature,
 * the crystal, capacitor, etc.
 *
 * The adjustment applied is as follows:
 *   t = t0 * (1 + offset * 1e-9)
 * where t0 is the measured length of 1 RTC second with offset = 0
 *
 * Kernel interface to adjust an rtc clock offset.
 * Return 0 on success, or a negative number on error.
 * If the rtc offset is not setable (or not implemented), return -EINVAL
 */
int rtc_set_offset(struct rtc_device *rtc, long offset)
{}