Source
140
140
141
141
/*
142
142
* Read current time and date in RTC
143
143
*/
144
144
static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm)
145
145
{
146
146
at91_rtc_decodetime(AT91_RTC_TIMR, AT91_RTC_CALR, tm);
147
147
tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
148
148
tm->tm_year = tm->tm_year - 1900;
149
149
150
-
dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
151
-
1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
152
-
tm->tm_hour, tm->tm_min, tm->tm_sec);
150
+
dev_dbg(dev, "%s(): %ptR\n", __func__, tm);
153
151
154
152
return 0;
155
153
}
156
154
157
155
/*
158
156
* Set current time and date in RTC
159
157
*/
160
158
static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
161
159
{
162
160
unsigned long cr;
163
161
164
-
dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
165
-
1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
166
-
tm->tm_hour, tm->tm_min, tm->tm_sec);
162
+
dev_dbg(dev, "%s(): %ptR\n", __func__, tm);
167
163
168
164
wait_for_completion(&at91_rtc_upd_rdy);
169
165
170
166
/* Stop Time/Calendar from counting */
171
167
cr = at91_rtc_read(AT91_RTC_CR);
172
168
at91_rtc_write(AT91_RTC_CR, cr | AT91_RTC_UPDCAL | AT91_RTC_UPDTIM);
173
169
174
170
at91_rtc_write_ier(AT91_RTC_ACKUPD);
175
171
wait_for_completion(&at91_rtc_updated); /* wait for ACKUPD interrupt */
176
172
at91_rtc_write_idr(AT91_RTC_ACKUPD);
202
198
static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
203
199
{
204
200
struct rtc_time *tm = &alrm->time;
205
201
206
202
at91_rtc_decodetime(AT91_RTC_TIMALR, AT91_RTC_CALALR, tm);
207
203
tm->tm_year = -1;
208
204
209
205
alrm->enabled = (at91_rtc_read_imr() & AT91_RTC_ALARM)
210
206
? 1 : 0;
211
207
212
-
dev_dbg(dev, "%s(): %02d-%02d %02d:%02d:%02d %sabled\n", __func__,
213
-
tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
208
+
dev_dbg(dev, "%s(): %ptR %sabled\n", __func__, tm,
214
209
alrm->enabled ? "en" : "dis");
215
210
216
211
return 0;
217
212
}
218
213
219
214
/*
220
215
* Set alarm time and date in RTC
221
216
*/
222
217
static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
223
218
{
240
235
at91_rtc_write(AT91_RTC_CALALR,
241
236
bin2bcd(tm.tm_mon + 1) << 16 /* tm_mon starts at zero */
242
237
| bin2bcd(tm.tm_mday) << 24
243
238
| AT91_RTC_DATEEN | AT91_RTC_MTHEN);
244
239
245
240
if (alrm->enabled) {
246
241
at91_rtc_write(AT91_RTC_SCCR, AT91_RTC_ALARM);
247
242
at91_rtc_write_ier(AT91_RTC_ALARM);
248
243
}
249
244
250
-
dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
251
-
tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
252
-
tm.tm_min, tm.tm_sec);
245
+
dev_dbg(dev, "%s(): %ptR\n", __func__, &tm);
253
246
254
247
return 0;
255
248
}
256
249
257
250
static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
258
251
{
259
252
dev_dbg(dev, "%s(): cmd=%08x\n", __func__, enabled);
260
253
261
254
if (enabled) {
262
255
at91_rtc_write(AT91_RTC_SCCR, AT91_RTC_ALARM);