summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorAnson Huang <Anson.Huang@nxp.com>2017-09-01 13:30:29 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commit811e3a3e77639e42a6b412e1193b197ed3d8df9d (patch)
tree974469638f5657a78868971ca676025115ee7afd /drivers/rtc
parent8d1c65b64df32d002a145e59474662cad16edf50 (diff)
MLK-16351 rtc: imx-sc: use SIP to set RTC time
For system controller RTC, as it belongs SC_R_SYSTEM, and SC_R_SYSTEM is assigned in ARM-Trusted-Firmware, so here needs to use SIP to trap into ATF to do set time, or system controller firmware will return error since linux kernel does NOT own this system resource. Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-imx-sc.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/drivers/rtc/rtc-imx-sc.c b/drivers/rtc/rtc-imx-sc.c
index ce3add9dbddd..4fd2619db92c 100644
--- a/drivers/rtc/rtc-imx-sc.c
+++ b/drivers/rtc/rtc-imx-sc.c
@@ -10,6 +10,7 @@
* http://www.gnu.org/copyleft/gpl.html
*/
+#include <linux/arm-smccc.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/kernel.h>
@@ -18,6 +19,7 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/rtc.h>
+#include <soc/imx/fsl_sip.h>
#include <soc/imx8/sc/sci.h>
sc_ipc_t timer_ipcHandle;
@@ -63,25 +65,16 @@ static int imx_sc_rtc_read_time(struct device *dev, struct rtc_time *tm)
static int imx_sc_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
- sc_err_t sciErr = SC_ERR_NONE;
+ struct arm_smccc_res res;
- if (!timer_ipcHandle)
- return -ENODEV;
+ /* pack 2 time parameters into 1 register, 16 bits for each */
+ arm_smccc_smc(FSL_SIP_SRTC, FSL_SIP_SRTC_SET_TIME,
+ ((tm->tm_year + 1900) << 16) | (tm->tm_mon + 1),
+ (tm->tm_mday << 16) | tm->tm_hour,
+ (tm->tm_min << 16) | tm->tm_sec,
+ 0, 0, 0, &res);
- sciErr = sc_timer_set_rtc_time(timer_ipcHandle,
- tm->tm_year + 1900,
- tm->tm_mon + 1,
- tm->tm_mday,
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec);
-
- if (sciErr) {
- dev_err(dev, "failed to set time: %d\n", sciErr);
- return -EINVAL;
- }
-
- return 0;
+ return res.a0;
}
static int imx_sc_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)