Source
95
95
while (!(__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_AER) & AERRWENB)
96
96
&& --timeout)
97
97
mdelay(1);
98
98
99
99
if (!timeout)
100
100
return ERR_PTR(-EPERM);
101
101
102
102
return NULL;
103
103
}
104
104
105
-
static int nuc900_rtc_bcd2bin(unsigned int timereg,
106
-
unsigned int calreg, struct rtc_time *tm)
105
+
static void nuc900_rtc_bcd2bin(unsigned int timereg,
106
+
unsigned int calreg, struct rtc_time *tm)
107
107
{
108
108
tm->tm_mday = bcd2bin(calreg >> 0);
109
109
tm->tm_mon = bcd2bin(calreg >> 8);
110
110
tm->tm_year = bcd2bin(calreg >> 16) + 100;
111
111
112
112
tm->tm_sec = bcd2bin(timereg >> 0);
113
113
tm->tm_min = bcd2bin(timereg >> 8);
114
114
tm->tm_hour = bcd2bin(timereg >> 16);
115
-
116
-
return rtc_valid_tm(tm);
117
115
}
118
116
119
117
static void nuc900_rtc_bin2bcd(struct device *dev, struct rtc_time *settm,
120
118
struct nuc900_bcd_time *gettm)
121
119
{
122
120
gettm->bcd_mday = bin2bcd(settm->tm_mday) << 0;
123
121
gettm->bcd_mon = bin2bcd(settm->tm_mon) << 8;
124
122
125
123
if (settm->tm_year < 100) {
126
124
dev_warn(dev, "The year will be between 1970-1999, right?\n");
149
147
}
150
148
151
149
static int nuc900_rtc_read_time(struct device *dev, struct rtc_time *tm)
152
150
{
153
151
struct nuc900_rtc *rtc = dev_get_drvdata(dev);
154
152
unsigned int timeval, clrval;
155
153
156
154
timeval = __raw_readl(rtc->rtc_reg + REG_RTC_TLR);
157
155
clrval = __raw_readl(rtc->rtc_reg + REG_RTC_CLR);
158
156
159
-
return nuc900_rtc_bcd2bin(timeval, clrval, tm);
157
+
nuc900_rtc_bcd2bin(timeval, clrval, tm);
158
+
159
+
return 0;
160
160
}
161
161
162
162
static int nuc900_rtc_set_time(struct device *dev, struct rtc_time *tm)
163
163
{
164
164
struct nuc900_rtc *rtc = dev_get_drvdata(dev);
165
165
struct nuc900_bcd_time gettm;
166
166
unsigned long val;
167
167
int *err;
168
168
169
169
nuc900_rtc_bin2bcd(dev, tm, &gettm);
182
182
}
183
183
184
184
static int nuc900_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
185
185
{
186
186
struct nuc900_rtc *rtc = dev_get_drvdata(dev);
187
187
unsigned int timeval, carval;
188
188
189
189
timeval = __raw_readl(rtc->rtc_reg + REG_RTC_TAR);
190
190
carval = __raw_readl(rtc->rtc_reg + REG_RTC_CAR);
191
191
192
-
return nuc900_rtc_bcd2bin(timeval, carval, &alrm->time);
192
+
nuc900_rtc_bcd2bin(timeval, carval, &alrm->time);
193
+
194
+
return rtc_valid_tm(&alrm->time);
193
195
}
194
196
195
197
static int nuc900_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
196
198
{
197
199
struct nuc900_rtc *rtc = dev_get_drvdata(dev);
198
200
struct nuc900_bcd_time tm;
199
201
unsigned long val;
200
202
int *err;
201
203
202
204
nuc900_rtc_bin2bcd(dev, &alrm->time, &tm);