Lines Matching +full:0 +full:- +full:mon
1 // SPDX-License-Identifier: GPL-2.0-or-later
27 return __raw_readl(&priv->rtcregs[reg]) & 0xff; in ds1286_rtc_read()
32 __raw_writel(data, &priv->rtcregs[reg]); in ds1286_rtc_write()
43 spin_lock_irqsave(&priv->lock, flags); in ds1286_alarm_irq_enable()
50 spin_unlock_irqrestore(&priv->lock, flags); in ds1286_alarm_irq_enable()
52 return 0; in ds1286_alarm_irq_enable()
66 spin_lock_irqsave(&priv->lock, flags); in ds1286_ioctl()
70 spin_unlock_irqrestore(&priv->lock, flags); in ds1286_ioctl()
74 spin_lock_irqsave(&priv->lock, flags); in ds1286_ioctl()
78 spin_unlock_irqrestore(&priv->lock, flags); in ds1286_ioctl()
81 return -ENOIOCTLCMD; in ds1286_ioctl()
83 return 0; in ds1286_ioctl()
105 amode = ((ds1286_rtc_read(priv, RTC_MINUTES_ALARM) & 0x80) >> 5) | in ds1286_proc()
106 ((ds1286_rtc_read(priv, RTC_HOURS_ALARM) & 0x80) >> 6) | in ds1286_proc()
107 ((ds1286_rtc_read(priv, RTC_DAY_ALARM) & 0x80) >> 7); in ds1286_proc()
118 case 0: in ds1286_proc()
143 return 0; in ds1286_proc()
160 * to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP. in ds1286_read_time()
175 * by the RTC when initially set to a non-zero value. in ds1286_read_time()
177 spin_lock_irqsave(&priv->lock, flags); in ds1286_read_time()
181 tm->tm_sec = ds1286_rtc_read(priv, RTC_SECONDS); in ds1286_read_time()
182 tm->tm_min = ds1286_rtc_read(priv, RTC_MINUTES); in ds1286_read_time()
183 tm->tm_hour = ds1286_rtc_read(priv, RTC_HOURS) & 0x3f; in ds1286_read_time()
184 tm->tm_mday = ds1286_rtc_read(priv, RTC_DATE); in ds1286_read_time()
185 tm->tm_mon = ds1286_rtc_read(priv, RTC_MONTH) & 0x1f; in ds1286_read_time()
186 tm->tm_year = ds1286_rtc_read(priv, RTC_YEAR); in ds1286_read_time()
189 spin_unlock_irqrestore(&priv->lock, flags); in ds1286_read_time()
191 tm->tm_sec = bcd2bin(tm->tm_sec); in ds1286_read_time()
192 tm->tm_min = bcd2bin(tm->tm_min); in ds1286_read_time()
193 tm->tm_hour = bcd2bin(tm->tm_hour); in ds1286_read_time()
194 tm->tm_mday = bcd2bin(tm->tm_mday); in ds1286_read_time()
195 tm->tm_mon = bcd2bin(tm->tm_mon); in ds1286_read_time()
196 tm->tm_year = bcd2bin(tm->tm_year); in ds1286_read_time()
202 if (tm->tm_year < 45) in ds1286_read_time()
203 tm->tm_year += 30; in ds1286_read_time()
204 tm->tm_year += 40; in ds1286_read_time()
205 if (tm->tm_year < 70) in ds1286_read_time()
206 tm->tm_year += 100; in ds1286_read_time()
208 tm->tm_mon--; in ds1286_read_time()
210 return 0; in ds1286_read_time()
216 unsigned char mon, day, hrs, min, sec; in ds1286_set_time() local
221 yrs = tm->tm_year + 1900; in ds1286_set_time()
222 mon = tm->tm_mon + 1; /* tm_mon starts at zero */ in ds1286_set_time()
223 day = tm->tm_mday; in ds1286_set_time()
224 hrs = tm->tm_hour; in ds1286_set_time()
225 min = tm->tm_min; in ds1286_set_time()
226 sec = tm->tm_sec; in ds1286_set_time()
229 return -EINVAL; in ds1286_set_time()
231 yrs -= 1940; in ds1286_set_time()
233 return -EINVAL; in ds1286_set_time()
236 yrs -= 100; in ds1286_set_time()
242 mon = bin2bcd(mon); in ds1286_set_time()
245 spin_lock_irqsave(&priv->lock, flags); in ds1286_set_time()
250 ds1286_rtc_write(priv, mon, RTC_MONTH); in ds1286_set_time()
255 ds1286_rtc_write(priv, 0, RTC_HUNDREDTH_SECOND); in ds1286_set_time()
258 spin_unlock_irqrestore(&priv->lock, flags); in ds1286_set_time()
259 return 0; in ds1286_set_time()
271 spin_lock_irqsave(&priv->lock, flags); in ds1286_read_alarm()
272 alm->time.tm_min = ds1286_rtc_read(priv, RTC_MINUTES_ALARM) & 0x7f; in ds1286_read_alarm()
273 alm->time.tm_hour = ds1286_rtc_read(priv, RTC_HOURS_ALARM) & 0x1f; in ds1286_read_alarm()
274 alm->time.tm_wday = ds1286_rtc_read(priv, RTC_DAY_ALARM) & 0x07; in ds1286_read_alarm()
276 spin_unlock_irqrestore(&priv->lock, flags); in ds1286_read_alarm()
278 alm->time.tm_min = bcd2bin(alm->time.tm_min); in ds1286_read_alarm()
279 alm->time.tm_hour = bcd2bin(alm->time.tm_hour); in ds1286_read_alarm()
280 alm->time.tm_sec = 0; in ds1286_read_alarm()
281 return 0; in ds1286_read_alarm()
289 hrs = alm->time.tm_hour; in ds1286_set_alarm()
290 min = alm->time.tm_min; in ds1286_set_alarm()
291 sec = alm->time.tm_sec; in ds1286_set_alarm()
294 hrs = 0xff; in ds1286_set_alarm()
297 min = 0xff; in ds1286_set_alarm()
299 if (sec != 0) in ds1286_set_alarm()
300 return -EINVAL; in ds1286_set_alarm()
305 spin_lock(&priv->lock); in ds1286_set_alarm()
308 spin_unlock(&priv->lock); in ds1286_set_alarm()
310 return 0; in ds1286_set_alarm()
328 priv = devm_kzalloc(&pdev->dev, sizeof(struct ds1286_priv), GFP_KERNEL); in ds1286_probe()
330 return -ENOMEM; in ds1286_probe()
332 priv->rtcregs = devm_platform_ioremap_resource(pdev, 0); in ds1286_probe()
333 if (IS_ERR(priv->rtcregs)) in ds1286_probe()
334 return PTR_ERR(priv->rtcregs); in ds1286_probe()
336 spin_lock_init(&priv->lock); in ds1286_probe()
338 rtc = devm_rtc_device_register(&pdev->dev, "ds1286", &ds1286_ops, in ds1286_probe()
342 priv->rtc = rtc; in ds1286_probe()
343 return 0; in ds1286_probe()
348 .name = "rtc-ds1286",
358 MODULE_ALIAS("platform:rtc-ds1286");