H A D | rtc-davinci.c | 119 struct davinci_rtc { struct 125 static inline void rtcif_write(struct davinci_rtc *davinci_rtc, rtcif_write() argument 128 writel(val, davinci_rtc->base + addr); rtcif_write() 131 static inline u32 rtcif_read(struct davinci_rtc *davinci_rtc, u32 addr) rtcif_read() argument 133 return readl(davinci_rtc->base + addr); rtcif_read() 136 static inline void rtcif_wait(struct davinci_rtc *davinci_rtc) rtcif_wait() argument 138 while (rtcif_read(davinci_rtc, PRTCIF_CTLR) & PRTCIF_CTLR_BUSY) rtcif_wait() 142 static inline void rtcss_write(struct davinci_rtc *davinci_rtc, rtcss_write() argument 145 rtcif_wait(davinci_rtc); rtcss_write() 147 rtcif_write(davinci_rtc, PRTCIF_CTLR_BENL_LSB | addr, PRTCIF_CTLR); rtcss_write() 148 rtcif_write(davinci_rtc, val, PRTCIF_LDATA); rtcss_write() 150 rtcif_wait(davinci_rtc); rtcss_write() 153 static inline u8 rtcss_read(struct davinci_rtc *davinci_rtc, u8 addr) rtcss_read() argument 155 rtcif_wait(davinci_rtc); rtcss_read() 157 rtcif_write(davinci_rtc, PRTCIF_CTLR_DIR | PRTCIF_CTLR_BENL_LSB | addr, rtcss_read() 160 rtcif_wait(davinci_rtc); rtcss_read() 162 return rtcif_read(davinci_rtc, PRTCIF_LDATA); rtcss_read() 165 static inline void davinci_rtcss_calendar_wait(struct davinci_rtc *davinci_rtc) davinci_rtcss_calendar_wait() argument 167 while (rtcss_read(davinci_rtc, PRTCSS_RTC_CCTRL) & davinci_rtcss_calendar_wait() 174 struct davinci_rtc *davinci_rtc = class_dev; davinci_rtc_interrupt() local 181 irq_flg = rtcif_read(davinci_rtc, PRTCIF_INTFLG) & davinci_rtc_interrupt() 184 alm_irq = rtcss_read(davinci_rtc, PRTCSS_RTC_CCTRL) & davinci_rtc_interrupt() 187 tmr_irq = rtcss_read(davinci_rtc, PRTCSS_RTC_CTRL) & davinci_rtc_interrupt() 193 rtc_cctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CCTRL); davinci_rtc_interrupt() 195 rtcss_write(davinci_rtc, rtc_cctrl, PRTCSS_RTC_CCTRL); davinci_rtc_interrupt() 198 rtc_ctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CTRL); davinci_rtc_interrupt() 200 rtcss_write(davinci_rtc, rtc_ctrl, PRTCSS_RTC_CTRL); davinci_rtc_interrupt() 203 rtcif_write(davinci_rtc, PRTCIF_INTFLG_RTCSS, davinci_rtc_interrupt() 205 rtc_update_irq(davinci_rtc->rtc, 1, events); davinci_rtc_interrupt() 216 struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); davinci_rtc_ioctl() local 223 rtc_ctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CTRL); davinci_rtc_ioctl() 236 rtcss_write(davinci_rtc, rtc_ctrl, PRTCSS_RTC_CTRL); davinci_rtc_ioctl() 288 struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); davinci_rtc_read_time() local 295 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_read_time() 296 tm->tm_sec = bcd2bin(rtcss_read(davinci_rtc, PRTCSS_RTC_SEC)); davinci_rtc_read_time() 298 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_read_time() 299 tm->tm_min = bcd2bin(rtcss_read(davinci_rtc, PRTCSS_RTC_MIN)); davinci_rtc_read_time() 301 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_read_time() 302 tm->tm_hour = bcd2bin(rtcss_read(davinci_rtc, PRTCSS_RTC_HOUR)); davinci_rtc_read_time() 304 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_read_time() 305 day0 = rtcss_read(davinci_rtc, PRTCSS_RTC_DAY0); davinci_rtc_read_time() 307 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_read_time() 308 day1 = rtcss_read(davinci_rtc, PRTCSS_RTC_DAY1); davinci_rtc_read_time() 324 struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); davinci_rtc_set_time() local 334 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_set_time() 335 rtcss_write(davinci_rtc, bin2bcd(tm->tm_sec), PRTCSS_RTC_SEC); davinci_rtc_set_time() 337 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_set_time() 338 rtcss_write(davinci_rtc, bin2bcd(tm->tm_min), PRTCSS_RTC_MIN); davinci_rtc_set_time() 340 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_set_time() 341 rtcss_write(davinci_rtc, bin2bcd(tm->tm_hour), PRTCSS_RTC_HOUR); davinci_rtc_set_time() 343 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_set_time() 344 rtcss_write(davinci_rtc, days & 0xFF, PRTCSS_RTC_DAY0); davinci_rtc_set_time() 346 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_set_time() 347 rtcss_write(davinci_rtc, (days & 0xFF00) >> 8, PRTCSS_RTC_DAY1); davinci_rtc_set_time() 349 rtc_cctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CCTRL); davinci_rtc_set_time() 351 rtcss_write(davinci_rtc, rtc_cctrl, PRTCSS_RTC_CCTRL); davinci_rtc_set_time() 361 struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); davinci_rtc_alarm_irq_enable() local 363 u8 rtc_cctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CCTRL); davinci_rtc_alarm_irq_enable() 376 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_alarm_irq_enable() 377 rtcss_write(davinci_rtc, rtc_cctrl, PRTCSS_RTC_CCTRL); davinci_rtc_alarm_irq_enable() 386 struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); davinci_rtc_read_alarm() local 393 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_read_alarm() 394 alm->time.tm_min = bcd2bin(rtcss_read(davinci_rtc, PRTCSS_RTC_AMIN)); davinci_rtc_read_alarm() 396 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_read_alarm() 397 alm->time.tm_hour = bcd2bin(rtcss_read(davinci_rtc, PRTCSS_RTC_AHOUR)); davinci_rtc_read_alarm() 399 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_read_alarm() 400 day0 = rtcss_read(davinci_rtc, PRTCSS_RTC_ADAY0); davinci_rtc_read_alarm() 402 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_read_alarm() 403 day1 = rtcss_read(davinci_rtc, PRTCSS_RTC_ADAY1); davinci_rtc_read_alarm() 413 alm->pending = !!(rtcss_read(davinci_rtc, davinci_rtc_read_alarm() 423 struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); davinci_rtc_set_alarm() local 453 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_set_alarm() 454 rtcss_write(davinci_rtc, bin2bcd(alm->time.tm_min), PRTCSS_RTC_AMIN); davinci_rtc_set_alarm() 456 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_set_alarm() 457 rtcss_write(davinci_rtc, bin2bcd(alm->time.tm_hour), PRTCSS_RTC_AHOUR); davinci_rtc_set_alarm() 459 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_set_alarm() 460 rtcss_write(davinci_rtc, days & 0xFF, PRTCSS_RTC_ADAY0); davinci_rtc_set_alarm() 462 davinci_rtcss_calendar_wait(davinci_rtc); davinci_rtc_set_alarm() 463 rtcss_write(davinci_rtc, (days & 0xFF00) >> 8, PRTCSS_RTC_ADAY1); davinci_rtc_set_alarm() 482 struct davinci_rtc *davinci_rtc; davinci_rtc_probe() local 486 davinci_rtc = devm_kzalloc(&pdev->dev, sizeof(struct davinci_rtc), GFP_KERNEL); davinci_rtc_probe() 487 if (!davinci_rtc) davinci_rtc_probe() 490 davinci_rtc->irq = platform_get_irq(pdev, 0); davinci_rtc_probe() 491 if (davinci_rtc->irq < 0) { davinci_rtc_probe() 493 return davinci_rtc->irq; davinci_rtc_probe() 497 davinci_rtc->base = devm_ioremap_resource(dev, res); davinci_rtc_probe() 498 if (IS_ERR(davinci_rtc->base)) davinci_rtc_probe() 499 return PTR_ERR(davinci_rtc->base); davinci_rtc_probe() 501 platform_set_drvdata(pdev, davinci_rtc); davinci_rtc_probe() 503 davinci_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, davinci_rtc_probe() 505 if (IS_ERR(davinci_rtc->rtc)) { davinci_rtc_probe() 508 return PTR_ERR(davinci_rtc->rtc); davinci_rtc_probe() 511 rtcif_write(davinci_rtc, PRTCIF_INTFLG_RTCSS, PRTCIF_INTFLG); davinci_rtc_probe() 512 rtcif_write(davinci_rtc, 0, PRTCIF_INTEN); davinci_rtc_probe() 513 rtcss_write(davinci_rtc, 0, PRTCSS_RTC_INTC_EXTENA1); davinci_rtc_probe() 515 rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CTRL); davinci_rtc_probe() 516 rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CCTRL); davinci_rtc_probe() 518 ret = devm_request_irq(dev, davinci_rtc->irq, davinci_rtc_interrupt, davinci_rtc_probe() 519 0, "davinci_rtc", davinci_rtc); davinci_rtc_probe() 526 rtcif_write(davinci_rtc, PRTCIF_INTEN_RTCSS, PRTCIF_INTEN); davinci_rtc_probe() 527 rtcss_write(davinci_rtc, PRTCSS_RTC_INTC_EXTENA1_MASK, davinci_rtc_probe() 530 rtcss_write(davinci_rtc, PRTCSS_RTC_CCTRL_CAEN, PRTCSS_RTC_CCTRL); davinci_rtc_probe() 539 struct davinci_rtc *davinci_rtc = platform_get_drvdata(pdev); davinci_rtc_remove() local 543 rtcif_write(davinci_rtc, 0, PRTCIF_INTEN); davinci_rtc_remove()
|