7 #include <linux/kernel.h>
15 #define READ_TIME_CMD 0x81
16 #define SET_TIME_CMD 0x80
17 #define TRIMMER_SET_CMD 0xC0
18 #define TRIMMER_VALUE_MASK 0x38
19 #define TRIMMER_SHIFT 3
24 static void rtc_reg_write(
unsigned long val)
29 static unsigned long rtc_reg_read(
void)
31 unsigned long tmp = *ds1603->
reg;
35 static unsigned long rtc_datareg_read(
void)
41 static void rtc_nrst_high(
void)
43 rtc_reg_write(rtc_reg_read() | ds1603->
rst);
46 static void rtc_nrst_low(
void)
48 rtc_reg_write(rtc_reg_read() & ~ds1603->
rst);
51 static void rtc_cycle_clock(
unsigned long data)
57 data &= ~ds1603->
data;
65 static void rtc_write_databit(
unsigned int bit)
67 unsigned long data = rtc_reg_read();
73 data &= ~ds1603->
data;
77 rtc_cycle_clock(data);
80 static unsigned int rtc_read_databit(
void)
86 rtc_cycle_clock(rtc_reg_read());
90 static void rtc_write_byte(
unsigned int byte)
94 for (i = 0; i <= 7; i++) {
95 rtc_write_databit(byte & 1L);
100 static void rtc_write_word(
unsigned long word)
104 for (i = 0; i <= 31; i++) {
105 rtc_write_databit(word & 1L);
110 static unsigned long rtc_read_word(
void)
113 unsigned long word = 0;
114 unsigned long shift = 0;
116 for (i = 0; i <= 31; i++) {
117 word |= rtc_read_databit() << shift;
123 static void rtc_init_op(
void)
127 rtc_reg_write(rtc_reg_read() & ~ds1603->
clk);
132 static void rtc_end_op(
void)
146 word = rtc_read_word();
148 spin_unlock_irqrestore(&
rtc_lock, flags);
161 rtc_write_word(time);
163 spin_unlock_irqrestore(&
rtc_lock, flags);