4 * SPDX-License-Identifier: BSD-3-Clause
9 #include <services/std_svc.h>
11 #include <platform_def.h>
12 #include <common/debug.h>
13 #include <common/runtime_svc.h>
14 #include <imx_sip_svc.h>
18 const static int ap_cluster_index
[PLATFORM_CLUSTER_COUNT
] = {
23 static int imx_srtc_set_time(uint32_t year_mon
,
24 unsigned long day_hour
,
25 unsigned long min_sec
)
27 return sc_timer_set_rtc_time(ipc_handle
,
28 year_mon
>> 16, year_mon
& 0xffff,
29 day_hour
>> 16, day_hour
& 0xffff,
30 min_sec
>> 16, min_sec
& 0xffff);
33 int imx_srtc_handler(uint32_t smc_fid
,
43 case IMX_SIP_SRTC_SET_TIME
:
44 ret
= imx_srtc_set_time(x2
, x3
, x4
);
50 SMC_RET1(handle
, ret
);
53 static void imx_cpufreq_set_target(uint32_t cluster_id
, unsigned long freq
)
55 sc_pm_clock_rate_t rate
= (sc_pm_clock_rate_t
)freq
;
58 sc_pm_set_clock_rate(ipc_handle
, ap_cluster_index
[cluster_id
], SC_PM_CLK_CPU
, &rate
);
61 sc_pm_set_clock_rate(ipc_handle
, SC_R_A35
, SC_PM_CLK_CPU
, &rate
);
65 int imx_cpufreq_handler(uint32_t smc_fid
,
71 case IMX_SIP_SET_CPUFREQ
:
72 imx_cpufreq_set_target(x2
, x3
);
81 static bool wakeup_src_irqsteer
;
83 bool imx_is_wakeup_src_irqsteer(void)
85 return wakeup_src_irqsteer
;
88 int imx_wakeup_src_handler(uint32_t smc_fid
,
94 case IMX_SIP_WAKEUP_SRC_IRQSTEER
:
95 wakeup_src_irqsteer
= true;
97 case IMX_SIP_WAKEUP_SRC_SCU
:
98 wakeup_src_irqsteer
= false;
107 int imx_otp_handler(uint32_t smc_fid
,
116 case IMX_SIP_OTP_READ
:
117 ret
= sc_misc_otp_fuse_read(ipc_handle
, x1
, &fuse
);
118 SMC_RET2(handle
, ret
, fuse
);
120 case IMX_SIP_OTP_WRITE
:
121 ret
= sc_misc_otp_fuse_write(ipc_handle
, x1
, x2
);
122 SMC_RET1(handle
, ret
);
126 SMC_RET1(handle
, ret
);
133 int imx_misc_set_temp_handler(uint32_t smc_fid
,
139 return sc_misc_set_temp(ipc_handle
, x1
, x2
, x3
, x4
);
142 static uint64_t imx_get_commit_hash(u_register_t x2
,
146 /* Parse the version_string */
147 char *parse
= (char *)version_string
;
151 parse
= strchr(parse
, '-');
154 if (*(parse
) == 'g') {
155 /* Default is 7 hexadecimal digits */
156 memcpy((void *)&hash
, (void *)(parse
+ 1), 7);
161 } while (parse
!= NULL
);
166 uint64_t imx_buildinfo_handler(uint32_t smc_fid
,
175 case IMX_SIP_BUILDINFO_GET_COMMITHASH
:
176 ret
= imx_get_commit_hash(x2
, x3
, x4
);