diff options
author | Anson Huang <Anson.Huang@nxp.com> | 2017-09-01 13:30:29 +0800 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:28:21 +0800 |
commit | 7292fba301c6e715e4736b5e8ff712047a97913d (patch) | |
tree | b1733c962012f66e5cae5b494ec57517de755730 /drivers/rtc | |
parent | f29bdffa0fec16954ef6e219f54bb38d8203d60f (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.c | 27 |
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) |