linux/drivers/rtc/rtc-snvs.c File Reference

Secure Real Time Clock (SRTC) interface in Freescale's SNVS module. More...

Functions

static u32 rtc_read_lp_counter (void __iomem *counter_reg)
static void rtc_write_sync_lp (void __iomem *ioaddr)
static int rtc_update_alarm (struct device *dev, struct rtc_time *alrm)
static irqreturn_t snvs_rtc_interrupt (int irq, void *dev_id)
static int snvs_rtc_open (struct device *dev)
static void snvs_rtc_release (struct device *dev)
static int snvs_rtc_read_time (struct device *dev, struct rtc_time *tm)
static int snvs_rtc_set_time (struct device *dev, struct rtc_time *tm)
static int snvs_rtc_read_alarm (struct device *dev, struct rtc_wkalrm *alrm)
static int snvs_rtc_set_alarm (struct device *dev, struct rtc_wkalrm *alrm)
static int snvs_rtc_proc (struct device *dev, struct seq_file *seq)
static int snvs_rtc_ioctl (struct device *dev, unsigned int cmd, unsigned long arg)
static int snvs_rtc_probe (struct platform_device *pdev)
static int snvs_rtc_suspend (struct platform_device *pdev, pm_message_t state)
static int snvs_rtc_resume (struct platform_device *pdev)
static int __init snvs_rtc_init (void)
static void __exit snvs_rtc_exit (void)

Variables

static struct rtc_class_ops snvs_rtc_ops
static struct platform_driver snvs_rtc_driver

Detailed Description

Secure Real Time Clock (SRTC) interface in Freescale's SNVS module.

This file contains Real Time Clock interface for Linux. The Freescale SNVS module's Low Power (LP) SRTC functionality is utilized in this driver, in non-secure mode.


Function Documentation

static u32 rtc_read_lp_counter ( void __iomem *  counter_reg  )  [inline, static]

LP counter register reads should always use this function. This function reads 2 consective times from LP counter register until the 2 values match. This is to avoid reading corrupt value if the counter is in the middle of updating (TKT052983)

Referenced by rtc_update_alarm(), snvs_rtc_probe(), and snvs_rtc_read_time().

static int rtc_update_alarm ( struct device *  dev,
struct rtc_time *  alrm 
) [static]

This function updates the RTC alarm registers and then clears all the interrupt status bits.

Parameters:
alrm the new alarm value to be updated in the RTC
Returns:
0 if successful; non-zero otherwise.

References rtc_read_lp_counter(), and rtc_write_sync_lp().

Referenced by snvs_rtc_set_alarm().

static void rtc_write_sync_lp ( void __iomem *  ioaddr  )  [inline, static]

This function does write synchronization for writes to the lp srtc block. To take care of the asynchronous CKIL clock, all writes from the IP domain will be synchronized to the CKIL domain.

Referenced by rtc_update_alarm(), snvs_rtc_interrupt(), snvs_rtc_set_alarm(), and snvs_rtc_set_time().

static void __exit snvs_rtc_exit ( void   )  [static]

This function removes the /proc/driver/rtc file and un-registers the device RTC from the /dev/misc directory.

static int __init snvs_rtc_init ( void   )  [static]

This function creates the /proc/driver/rtc file and registers the device RTC in the /dev/misc directory. It also reads the RTC value from external source and setup the internal RTC properly.

Returns:
-1 if RTC is failed to initialize; 0 is successful.
static irqreturn_t snvs_rtc_interrupt ( int  irq,
void *  dev_id 
) [static]

This function is the RTC interrupt service routine.

Parameters:
irq RTC IRQ number
dev_id device ID which is not used
Returns:
IRQ_HANDLED as defined in the include/linux/interrupt.h file.

References IRQ_HANDLED, and rtc_write_sync_lp().

Referenced by snvs_rtc_probe().

static int snvs_rtc_ioctl ( struct device *  dev,
unsigned int  cmd,
unsigned long  arg 
) [static]

This function is used to support some ioctl calls directly. Other ioctl calls are supported indirectly through the arm/common/rtctime.c file.

Parameters:
cmd ioctl command as defined in include/linux/rtc.h
arg value for the ioctl command
Returns:
0 if successful or negative value otherwise.
static int snvs_rtc_open ( struct device *  dev  )  [static]

This function is used to open the RTC driver.

Returns:
0 if successful; non-zero otherwise.
static int snvs_rtc_probe ( struct platform_device *  pdev  )  [static]

SNVS RTC Power management control

References rtc_read_lp_counter(), and snvs_rtc_interrupt().

static int snvs_rtc_proc ( struct device *  dev,
struct seq_file *  seq 
) [static]

This function is used to provide the content for the /proc/driver/rtc file.

Parameters:
seq buffer to hold the information that the driver wants to write
Returns:
The number of bytes written into the rtc file.
static int snvs_rtc_read_alarm ( struct device *  dev,
struct rtc_wkalrm *  alrm 
) [static]

This function reads the current alarm value into the passed in alrm argument. It updates the alrm's pending field value based on the whether an alarm interrupt occurs or not.

Parameters:
alrm contains the RTC alarm value upon return
Returns:
0 if successful; non-zero otherwise.
static int snvs_rtc_read_time ( struct device *  dev,
struct rtc_time *  tm 
) [static]

This function reads the current RTC time into tm in Gregorian date.

Parameters:
tm contains the RTC time value upon return
Returns:
0 if successful; non-zero otherwise.

References rtc_read_lp_counter().

static void snvs_rtc_release ( struct device *  dev  )  [static]

clear all interrupts and release the IRQ

static int snvs_rtc_resume ( struct platform_device *  pdev  )  [static]

This function is called to correct the system time based on the current SNVS RTC time relative to the time delta saved during suspend.

Parameters:
pdev not used
Returns:
The function always returns 0.
static int snvs_rtc_set_alarm ( struct device *  dev,
struct rtc_wkalrm *  alrm 
) [static]

This function sets the RTC alarm based on passed in alrm.

Parameters:
alrm the alarm value to be set in the RTC
Returns:
0 if successful; non-zero otherwise.

References rtc_update_alarm(), and rtc_write_sync_lp().

static int snvs_rtc_set_time ( struct device *  dev,
struct rtc_time *  tm 
) [static]

This function sets the internal RTC time based on tm in Gregorian date.

Parameters:
tm the time value to be set in the RTC
Returns:
0 if successful; non-zero otherwise.

References rtc_write_sync_lp().

static int snvs_rtc_suspend ( struct platform_device *  pdev,
pm_message_t  state 
) [static]

This function is called to save the system time delta relative to the SNVS RTC when enterring a low power state. This time delta is then used on resume to adjust the system time to account for time loss while suspended.

Parameters:
pdev not used
state Power state to enter.
Returns:
The function always returns 0.

Variable Documentation

struct platform_driver snvs_rtc_driver [static]
Initial value:
 {
        .driver = {
                   .name = "snvs_rtc",
                   },
        .probe = snvs_rtc_probe,
        .remove = __exit_p(snvs_rtc_remove),
        .suspend = snvs_rtc_suspend,
        .resume = snvs_rtc_resume,
}

Contains pointers to the power management callback functions.

struct rtc_class_ops snvs_rtc_ops [static]
Initial value:
 {
        .open = snvs_rtc_open,
        .release = snvs_rtc_release,
        .read_time = snvs_rtc_read_time,
        .set_time = snvs_rtc_set_time,
        .read_alarm = snvs_rtc_read_alarm,
        .set_alarm = snvs_rtc_set_alarm,
        .proc = snvs_rtc_proc,
        .ioctl = snvs_rtc_ioctl,
        .alarm_irq_enable = snvs_rtc_alarm_irq_enable,
}

The RTC driver structure

footer
©  Freescale Semiconductor, Inc., 2007.  All rights reserved.
Freescale Confidential Proprietary
NDA Required
doxygen