1
0
Fork 0

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>
pull/10/head
Anson Huang 2017-09-01 13:30:29 +08:00 committed by Jason Liu
parent 44789899c2
commit d2c777f7f8
2 changed files with 13 additions and 17 deletions

View File

@ -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)

View File

@ -20,6 +20,9 @@
#define FSL_SIP_CPUFREQ 0xC2000001
#define FSL_SIP_SET_CPUFREQ 0x00
#define FSL_SIP_SRTC 0xC2000002
#define FSL_SIP_SRTC_SET_TIME 0x00
#define IMX8MQ_PD_MIPI 0
#define IMX8MQ_PD_PCIE1 1
#define IMX8MQ_PD_OTG1 2