Source
static int as3722_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
/*
* rtc-as3722.c - Real Time Clock driver for ams AS3722 PMICs
*
* Copyright (C) 2013 ams AG
* Copyright (c) 2013, NVIDIA Corporation. All rights reserved.
*
* Author: Florian Lobmaier <florian.lobmaier@ams.com>
* Author: Laxman Dewangan <ldewangan@nvidia.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
struct as3722_rtc {
struct rtc_device *rtc;
struct device *dev;
struct as3722 *as3722;
int alarm_irq;
bool irq_enable;
};
static void as3722_time_to_reg(u8 *rbuff, struct rtc_time *tm)
{
rbuff[0] = bin2bcd(tm->tm_sec);
rbuff[1] = bin2bcd(tm->tm_min);
rbuff[2] = bin2bcd(tm->tm_hour);
rbuff[3] = bin2bcd(tm->tm_mday);
rbuff[4] = bin2bcd(tm->tm_mon + 1);
rbuff[5] = bin2bcd(tm->tm_year - (AS3722_RTC_START_YEAR - 1900));
}
static void as3722_reg_to_time(u8 *rbuff, struct rtc_time *tm)
{
tm->tm_sec = bcd2bin(rbuff[0] & 0x7F);
tm->tm_min = bcd2bin(rbuff[1] & 0x7F);
tm->tm_hour = bcd2bin(rbuff[2] & 0x3F);
tm->tm_mday = bcd2bin(rbuff[3] & 0x3F);
tm->tm_mon = bcd2bin(rbuff[4] & 0x1F) - 1;
tm->tm_year = (AS3722_RTC_START_YEAR - 1900) + bcd2bin(rbuff[5] & 0x7F);
return;
}
static int as3722_rtc_read_time(struct device *dev, struct rtc_time *tm)