static int msmrtc_timeremote_read_time(struct device *dev, struct rtc_time *tm) { int rc; struct rtc_tod_args rtc_args; rtc_args.proc = TIMEREMOTE_PROCEEDURE_GET_JULIAN; rtc_args.tm = tm; rc = msm_rpc_client_req(rpc_client, TIMEREMOTE_PROCEEDURE_GET_JULIAN, msmrtc_tod_proc_args, &rtc_args, msmrtc_tod_proc_result, &rtc_args, -1); if (rc) { pr_err("%s: Error retrieving rtc (TOD) time\n", __func__); return rc; } if (tm->tm_year < 80) { int rc; tm->tm_year = 80; tm->tm_mon = 0; tm->tm_mday = 1; tm->tm_hour = 0; tm->tm_min = 0; tm->tm_sec = 0; tm->tm_wday = 2; rc = msmrtc_timeremote_set_time(dev, tm); if (rc < 0) { pr_err("%s: Failed to set default " "time and date.\n", __func__); return rc; } } return 0; }
static int msmrtc_probe(struct platform_device *pdev) { int rc; struct rpcsvr_platform_device *rdev = container_of(pdev, struct rpcsvr_platform_device, base); uint32_t prog_version; #ifdef CONFIG_MACH_ACER_A4 struct rtc_time tm; #endif if (pdev->id == (TIMEREMOTE_PROG_VER_1 & RPC_VERSION_MAJOR_MASK)) prog_version = TIMEREMOTE_PROG_VER_1; else if (pdev->id == (TIMEREMOTE_PROG_VER_2 & RPC_VERSION_MAJOR_MASK)) prog_version = TIMEREMOTE_PROG_VER_2; else return -EINVAL; rpc_client = msm_rpc_register_client("rtc", rdev->prog, prog_version, 1, msmrtc_cb_func); if (IS_ERR(rpc_client)) { pr_err("%s: init RPC failed! VERS = %x\n", __func__, prog_version); return PTR_ERR(rpc_client); } #ifdef CONFIG_MACH_ACER_A4 /* Set the default system time to 2010-10-01 00:00:00 UTC. */ msmrtc_timeremote_read_time(&pdev->dev, &tm); if (tm.tm_year < 90) { tm.tm_year = 110; /* RTC layer expects years to start at 1900 */ tm.tm_mon = 9; /* RTC layer expects mons to be 0 based */ tm.tm_mday = 1; tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_wday = 4; /* 2010-10-01 is Fri. */ msmrtc_timeremote_set_time(&pdev->dev, &tm); } #endif /* * Set up the callback client. * For older targets this initialization will fail */ rc = msmrtc_setup_cb(); if (rc) pr_debug("%s: Could not initialize RPC callback\n", __func__); rtc = rtc_device_register("msm_rtc", &pdev->dev, &msm_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) { printk(KERN_ERR "%s: Can't register RTC device (%ld)\n", pdev->name, PTR_ERR(rtc)); rc = PTR_ERR(rtc); goto fail_cb_setup; } #ifdef CONFIG_RTC_SECURE_TIME_SUPPORT rtcsecure = rtc_device_register("msm_rtc_secure", &pdev->dev, &msm_rtc_ops_secure, THIS_MODULE); if (IS_ERR(rtcsecure)) { printk(KERN_ERR "%s: Can't register RTC Secure device (%ld)\n", pdev->name, PTR_ERR(rtcsecure)); rtc_device_unregister(rtc); rc = PTR_ERR(rtcsecure); goto fail_cb_setup; } #endif return 0; fail_cb_setup: msm_rpc_unregister_client(rpc_client); return rc; }
static int __devinit msmrtc_probe(struct platform_device *pdev) { int rc; struct msm_rtc *rtc_pdata = NULL; struct rpcsvr_platform_device *rdev = container_of(pdev, struct rpcsvr_platform_device, base); uint32_t prog_version; #if defined(CONFIG_MACH_ACER_A4) || defined(CONFIG_MACH_ACER_A5) struct rtc_time tm; #endif if (pdev->id == (TIMEREMOTE_PROG_VER_1 & RPC_VERSION_MAJOR_MASK)) prog_version = TIMEREMOTE_PROG_VER_1; else if (pdev->id == (TIMEREMOTE_PROG_VER_2 & RPC_VERSION_MAJOR_MASK)) prog_version = TIMEREMOTE_PROG_VER_2; else return -EINVAL; rtc_pdata = kzalloc(sizeof(*rtc_pdata), GFP_KERNEL); if (rtc_pdata == NULL) { dev_err(&pdev->dev, "%s: Unable to allocate memory\n", __func__); return -ENOMEM; } rtc_pdata->rpc_client = msm_rpc_register_client("rtc", rdev->prog, prog_version, 1, msmrtc_cb_func); if (IS_ERR(rtc_pdata->rpc_client)) { dev_err(&pdev->dev, "%s: init RPC failed! VERS = %x\n", __func__, prog_version); rc = PTR_ERR(rtc_pdata->rpc_client); kfree(rtc_pdata); return rc; } /* * Set up the callback client. * For older targets this initialization will fail */ rc = msmrtc_setup_cb(rtc_pdata); if (rc) dev_dbg(&pdev->dev, "%s: Could not initialize RPC callback\n", __func__); rtc_pdata->rtcalarm_time = 0; platform_set_drvdata(pdev, rtc_pdata); #if defined(CONFIG_MACH_ACER_A4) || defined(CONFIG_MACH_ACER_A5) /* Set the default system time to 2011-03-01 00:00:00 UTC. */ msmrtc_timeremote_read_time(&pdev->dev, &tm); if (tm.tm_year < 90) { tm.tm_year = 111; /* RTC layer expects years to start at 1900 */ tm.tm_mon = 2; /* RTC layer expects mons to be 0 based */ tm.tm_mday = 1; tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_wday = 1; /* 2011-03-01 is Tuesday */ msmrtc_timeremote_set_time(&pdev->dev, &tm); } #endif rtc_pdata->rtc = rtc_device_register("msm_rtc", &pdev->dev, &msm_rtc_ops, THIS_MODULE); if (IS_ERR(rtc_pdata->rtc)) { dev_err(&pdev->dev, "%s: Can't register RTC device (%ld)\n", pdev->name, PTR_ERR(rtc_pdata->rtc)); rc = PTR_ERR(rtc_pdata->rtc); goto fail_cb_setup; } #ifdef CONFIG_RTC_SECURE_TIME_SUPPORT rtc_pdata->rtcsecure = rtc_device_register("msm_rtc_secure", &pdev->dev, &msm_rtc_ops_secure, THIS_MODULE); if (IS_ERR(rtc_pdata->rtcsecure)) { dev_err(&pdev->dev, "%s: Can't register RTC Secure device (%ld)\n", pdev->name, PTR_ERR(rtc_pdata->rtcsecure)); rtc_device_unregister(rtc_pdata->rtc); rc = PTR_ERR(rtc_pdata->rtcsecure); goto fail_cb_setup; } #endif #ifdef CONFIG_RTC_ASYNC_MODEM_SUPPORT rtc_hctosys(); #endif return 0; fail_cb_setup: msm_rpc_unregister_client(rtc_pdata->rpc_client); kfree(rtc_pdata); return rc; }