#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/mfd/pcf50633/core.h>
#define PCF50633_REG_RTCSC 0x59
#define PCF50633_REG_RTCMN 0x5a
#define PCF50633_REG_RTCHR 0x5b
#define PCF50633_REG_RTCWD 0x5c
#define PCF50633_REG_RTCDT 0x5d
#define PCF50633_REG_RTCMT 0x5e
#define PCF50633_REG_RTCYR 0x5f
#define PCF50633_REG_RTCSCA 0x60
#define PCF50633_REG_RTCMNA 0x61
#define PCF50633_REG_RTCHRA 0x62
#define PCF50633_REG_RTCWDA 0x63
#define PCF50633_REG_RTCDTA 0x64
#define PCF50633_REG_RTCMTA 0x65
#define PCF50633_REG_RTCYRA 0x66
enum pcf50633_time_indexes {
u_int8_t time[PCF50633_TI_EXTENT];
struct rtc_device *rtc_dev;
static void pcf2rtc_time(struct rtc_time *rtc, struct pcf50633_time *pcf)
rtc->tm_sec = bcd2bin(pcf->time[PCF50633_TI_SEC]);
rtc->tm_min = bcd2bin(pcf->time[PCF50633_TI_MIN]);
rtc->tm_hour = bcd2bin(pcf->time[PCF50633_TI_HOUR]);
rtc->tm_wday = bcd2bin(pcf->time[PCF50633_TI_WKDAY]);
rtc->tm_mday = bcd2bin(pcf->time[PCF50633_TI_DAY]);
rtc->tm_mon = bcd2bin(pcf->time[PCF50633_TI_MONTH]) - 1;
rtc->tm_year = bcd2bin(pcf->time[PCF50633_TI_YEAR]) + 100;
static void rtc2pcf_time(struct pcf50633_time *pcf, struct rtc_time *rtc)
pcf->time[PCF50633_TI_SEC] = bin2bcd(rtc->tm_sec);
pcf->time[PCF50633_TI_MIN] = bin2bcd(rtc->tm_min);
pcf->time[PCF50633_TI_HOUR] = bin2bcd(rtc->tm_hour);
pcf->time[PCF50633_TI_WKDAY] = bin2bcd(rtc->tm_wday);
pcf->time[PCF50633_TI_DAY] = bin2bcd(rtc->tm_mday);
pcf->time[PCF50633_TI_MONTH] = bin2bcd(rtc->tm_mon + 1);
pcf->time[PCF50633_TI_YEAR] = bin2bcd(rtc->tm_year % 100);
pcf50633_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
struct pcf50633_rtc *rtc = dev_get_drvdata(dev);