#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mfd/ezx-pcap.h>
#include <linux/platform_device.h>
static irqreturn_t pcap_rtc_irq(int irq, void *_pcap_rtc)
struct pcap_rtc *pcap_rtc = _pcap_rtc;
unsigned long rtc_events;
if (irq == pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ))
rtc_events = RTC_IRQF | RTC_UF;
else if (irq == pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA))
rtc_events = RTC_IRQF | RTC_AF;
rtc_update_irq(pcap_rtc->rtc, 1, rtc_events);
static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev);
struct rtc_time *tm = &alrm->time;
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_TODA, &tod);
secs = tod & PCAP_RTC_TOD_MASK;
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, &days);
secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
rtc_time_to_tm(secs, tm);
static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)