Board logo

标题: RTC实时时钟驱动(5) [打印本页]

作者: yuyang911220    时间: 2014-8-26 12:21     标题: RTC实时时钟驱动(5)

pr_debug("s3c2410_rtc: tick irq %d, alarm irq %d\n",
         s3c_rtc_tickno, s3c_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;
    }

    s3c_rtc_mem = request_mem_region(res->start,
                     res->end-res->start+1,
                     pdev->name);

    if (s3c_rtc_mem == NULL) {
        dev_err(&pdev->dev, "failed to reserve memory region\n");
        ret = -ENOENT;
        goto err_nores;
    }

    s3c_rtc_base = ioremap(res->start, res->end - res->start + 1);
    if (s3c_rtc_base == NULL) {
        dev_err(&pdev->dev, "failed ioremap()\n");
        ret = -EINVAL;
        goto err_nomap;
    }

    /* check to see if everything is setup correctly */

    s3c_rtc_enable(pdev, 1);

     pr_debug("s3c2410_rtc: RTCCON=%02x\n",
         readb(s3c_rtc_base + S3C2410_RTCCON));

    s3c_rtc_setfreq(&pdev->dev, 1);

    device_init_wakeup(&pdev->dev, 1);

    /* register RTC and exit */

    rtc = rtc_device_register("s3c", &pdev->dev, &s3c_rtcops,
                  THIS_MODULE);

    if (IS_ERR(rtc)) {
        dev_err(&pdev->dev, "cannot attach rtc\n");
        ret = PTR_ERR(rtc);
        goto err_nortc;
    }

    rtc->max_user_freq = 128;

    platform_set_drvdata(pdev, rtc);
    return 0;

err_nortc:
    s3c_rtc_enable(pdev, 0);
    iounmap(s3c_rtc_base);

err_nomap:
    release_resource(s3c_rtc_mem);

err_nores:
    return ret;
}




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0