static bool_t realview_register_rtc(struct resource_t * res) { struct rtc_t * rtc; char name[64]; rtc = malloc(sizeof(struct rtc_t)); if(!rtc) return FALSE; snprintf(name, sizeof(name), "%s.%d", res->name, res->id); rtc->name = strdup(name); rtc->init = rtc_init; rtc->exit = rtc_exit; rtc->settime = rtc_settime, rtc->gettime = rtc_gettime, rtc->suspend = rtc_suspend, rtc->resume = rtc_resume, rtc->priv = res; if(register_rtc(rtc)) return TRUE; free(rtc->name); free(rtc); return FALSE; }
static int mv_rtc_init(void) { MV_RTC_TIME time; struct timespec tv; switch(mvBoardIdGet()) { case RD_88F5181L_VOIP_FXO_GE: case RD_88W8660_AP82S_DDR1: return 0; } mvRtcDS1339TimeGet(&time); /* check if the year is invalid - bigger than 2038 */ if (time.year >= 38) { time.year=0; mvRtcDS1339TimeSet(&time); printk(KERN_INFO "RTC has been updated!!!"); } tv.tv_nsec = 0; /* same as in the U-Boot we use the year for century 20 only */ tv.tv_sec = mktime ( time.year + 2000, time.month, time.date, time.hours, time.minutes, time.seconds); do_settimeofday(&tv); set_rtc = mv_set_rtc; register_rtc(&rtc_ops); printk("RTC registered\n"); return 0; }
int stm32_rtc_init() { memset(&stm32rtc, 0 , sizeof(RTC_Device)); strncpy(stm32rtc.name,DEV_NAME,MAX_RTC_DEV_NAME); stm32rtc.get_datetime = stm32_get_datetime; stm32rtc.set_datetime = stm32_set_datetime; register_rtc(&stm32rtc); return 1; }
static int rtc_probe(struct amba_device *dev, void *id) { int ret; if (rtc_base) return -EBUSY; ret = amba_request_regions(dev, NULL); if (ret) goto out; rtc_base = ioremap(dev->res.start, SZ_4K); if (!rtc_base) { ret = -ENOMEM; goto res_out; } __raw_writel(0, rtc_base + RTC_CR); __raw_writel(0, rtc_base + RTC_EOI); xtime.tv_sec = __raw_readl(rtc_base + RTC_DR); ret = request_irq(dev->irq[0], rtc_interrupt, SA_INTERRUPT, "rtc-pl030", dev); if (ret) goto map_out; ret = register_rtc(&rtc_ops); if (ret) goto irq_out; set_rtc = integrator_set_rtc; return 0; irq_out: free_irq(dev->irq[0], dev); map_out: iounmap(rtc_base); rtc_base = NULL; res_out: amba_release_regions(dev); out: return ret; }
static int s3c2410_rtc_probe(struct platform_device *pdev) { struct resource *res; int ret; pr_debug("%s: probe=%p\n", __FUNCTION__, pdev); /* find the IRQs */ s3c2410_rtc_tickno = platform_get_irq(pdev, 1); if (s3c2410_rtc_tickno < 0) { dev_err(&pdev->dev, "no irq for rtc tick\n"); return -ENOENT; } s3c2410_rtc_alarmno = platform_get_irq(pdev, 0); if (s3c2410_rtc_alarmno < 0) { dev_err(&pdev->dev, "no irq for alarm\n"); return -ENOENT; } pr_debug("s3c2410_rtc: tick irq %d, alarm irq %d\n", s3c2410_rtc_tickno, s3c2410_rtc_alarmno); /* get the memory region */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(&pdev->dev, "failed to get memory region resource\n"); return -ENOENT; } s3c2410_rtc_mem = request_mem_region(res->start, res->end-res->start+1, pdev->name); if (s3c2410_rtc_mem == NULL) { dev_err(&pdev->dev, "failed to reserve memory region\n"); ret = -ENOENT; goto exit_err; } s3c2410_rtc_base = ioremap(res->start, res->end - res->start + 1); if (s3c2410_rtc_base == NULL) { dev_err(&pdev->dev, "failed ioremap()\n"); ret = -EINVAL; goto exit_err; } s3c2410_rtc_mem = res; pr_debug("s3c2410_rtc_base=%p\n", s3c2410_rtc_base); pr_debug("s3c2410_rtc: RTCCON=%02x\n", readb(S3C2410_RTCCON)); /* check to see if everything is setup correctly */ s3c2410_rtc_enable(pdev, 1); pr_debug("s3c2410_rtc: RTCCON=%02x\n", readb(S3C2410_RTCCON)); s3c2410_rtc_setfreq(s3c2410_rtc_freq); /* register RTC and exit */ register_rtc(&s3c2410_rtcops); return 0; exit_err: dev_err(&pdev->dev, "error %d during initialisation\n", ret); return ret; }