rtc-rv8803.c (96acb25c50e77355673b89765b96bd764abf487d) | rtc-rv8803.c (a1e98e09704ad247bff3c0de1bef6a73dc88b6d0) |
---|---|
1/* 2 * RTC driver for the Micro Crystal RV8803 3 * 4 * Copyright (C) 2015 Micro Crystal SA 5 * 6 * Alexandre Belloni <alexandre.belloni@free-electrons.com> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 * 12 */ 13 14#include <linux/bcd.h> 15#include <linux/bitops.h> | 1/* 2 * RTC driver for the Micro Crystal RV8803 3 * 4 * Copyright (C) 2015 Micro Crystal SA 5 * 6 * Alexandre Belloni <alexandre.belloni@free-electrons.com> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 * 12 */ 13 14#include <linux/bcd.h> 15#include <linux/bitops.h> |
16#include <linux/log2.h> |
|
16#include <linux/i2c.h> 17#include <linux/interrupt.h> 18#include <linux/kernel.h> 19#include <linux/module.h> 20#include <linux/rtc.h> 21 22#define RV8803_SEC 0x00 23#define RV8803_MIN 0x01 --- 116 unchanged lines hidden (view full) --- 140 141 if ((date2[RV8803_SEC] & 0x7f) != bin2bcd(59)) 142 date = date2; 143 } 144 145 tm->tm_sec = bcd2bin(date[RV8803_SEC] & 0x7f); 146 tm->tm_min = bcd2bin(date[RV8803_MIN] & 0x7f); 147 tm->tm_hour = bcd2bin(date[RV8803_HOUR] & 0x3f); | 17#include <linux/i2c.h> 18#include <linux/interrupt.h> 19#include <linux/kernel.h> 20#include <linux/module.h> 21#include <linux/rtc.h> 22 23#define RV8803_SEC 0x00 24#define RV8803_MIN 0x01 --- 116 unchanged lines hidden (view full) --- 141 142 if ((date2[RV8803_SEC] & 0x7f) != bin2bcd(59)) 143 date = date2; 144 } 145 146 tm->tm_sec = bcd2bin(date[RV8803_SEC] & 0x7f); 147 tm->tm_min = bcd2bin(date[RV8803_MIN] & 0x7f); 148 tm->tm_hour = bcd2bin(date[RV8803_HOUR] & 0x3f); |
148 tm->tm_wday = ffs(date[RV8803_WEEK] & 0x7f); | 149 tm->tm_wday = ilog2(date[RV8803_WEEK] & 0x7f); |
149 tm->tm_mday = bcd2bin(date[RV8803_DAY] & 0x3f); 150 tm->tm_mon = bcd2bin(date[RV8803_MONTH] & 0x1f) - 1; 151 tm->tm_year = bcd2bin(date[RV8803_YEAR]) + 100; 152 153 return 0; 154} 155 156static int rv8803_set_time(struct device *dev, struct rtc_time *tm) --- 376 unchanged lines hidden --- | 150 tm->tm_mday = bcd2bin(date[RV8803_DAY] & 0x3f); 151 tm->tm_mon = bcd2bin(date[RV8803_MONTH] & 0x1f) - 1; 152 tm->tm_year = bcd2bin(date[RV8803_YEAR]) + 100; 153 154 return 0; 155} 156 157static int rv8803_set_time(struct device *dev, struct rtc_time *tm) --- 376 unchanged lines hidden --- |