Lines Matching +full:- +full:eproto
1 // SPDX-License-Identifier: GPL-2.0
40 * struct optee_rtc - OP-TEE RTC private data
41 * @dev: OP-TEE based RTC device.
42 * @ctx: OP-TEE context handler.
64 inv_arg.session = priv->session_id; in optee_rtc_readtime()
69 param[0].u.memref.shm = priv->shm; in optee_rtc_readtime()
72 ret = tee_client_invoke_func(priv->ctx, &inv_arg, param); in optee_rtc_readtime()
74 return ret ? ret : -EPROTO; in optee_rtc_readtime()
76 optee_tm = tee_shm_get_va(priv->shm, 0); in optee_rtc_readtime()
81 return -EPROTO; in optee_rtc_readtime()
83 tm->tm_sec = optee_tm->tm_sec; in optee_rtc_readtime()
84 tm->tm_min = optee_tm->tm_min; in optee_rtc_readtime()
85 tm->tm_hour = optee_tm->tm_hour; in optee_rtc_readtime()
86 tm->tm_mday = optee_tm->tm_mday; in optee_rtc_readtime()
87 tm->tm_mon = optee_tm->tm_mon; in optee_rtc_readtime()
88 tm->tm_year = optee_tm->tm_year - 1900; in optee_rtc_readtime()
89 tm->tm_wday = optee_tm->tm_wday; in optee_rtc_readtime()
90 tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year); in optee_rtc_readtime()
104 optee_tm.tm_sec = tm->tm_sec; in optee_rtc_settime()
105 optee_tm.tm_min = tm->tm_min; in optee_rtc_settime()
106 optee_tm.tm_hour = tm->tm_hour; in optee_rtc_settime()
107 optee_tm.tm_mday = tm->tm_mday; in optee_rtc_settime()
108 optee_tm.tm_mon = tm->tm_mon; in optee_rtc_settime()
109 optee_tm.tm_year = tm->tm_year + 1900; in optee_rtc_settime()
110 optee_tm.tm_wday = tm->tm_wday; in optee_rtc_settime()
113 inv_arg.session = priv->session_id; in optee_rtc_settime()
117 param[0].u.memref.shm = priv->shm; in optee_rtc_settime()
120 rtc_data = tee_shm_get_va(priv->shm, 0); in optee_rtc_settime()
126 ret = tee_client_invoke_func(priv->ctx, &inv_arg, param); in optee_rtc_settime()
128 return ret ? ret : -EPROTO; in optee_rtc_settime()
140 if (!(priv->features & TA_RTC_FEATURE_CORRECTION)) in optee_rtc_readoffset()
141 return -EOPNOTSUPP; in optee_rtc_readoffset()
144 inv_arg.session = priv->session_id; in optee_rtc_readoffset()
149 ret = tee_client_invoke_func(priv->ctx, &inv_arg, param); in optee_rtc_readoffset()
151 return ret ? ret : -EPROTO; in optee_rtc_readoffset()
165 if (!(priv->features & TA_RTC_FEATURE_CORRECTION)) in optee_rtc_setoffset()
166 return -EOPNOTSUPP; in optee_rtc_setoffset()
169 inv_arg.session = priv->session_id; in optee_rtc_setoffset()
175 ret = tee_client_invoke_func(priv->ctx, &inv_arg, param); in optee_rtc_setoffset()
177 return ret ? ret : -EPROTO; in optee_rtc_setoffset()
200 inv_arg.session = priv->session_id; in optee_rtc_read_info()
204 param[0].u.memref.shm = priv->shm; in optee_rtc_read_info()
207 ret = tee_client_invoke_func(priv->ctx, &inv_arg, param); in optee_rtc_read_info()
209 return ret ? ret : -EPROTO; in optee_rtc_read_info()
211 info = tee_shm_get_va(priv->shm, 0); in optee_rtc_read_info()
216 return -EPROTO; in optee_rtc_read_info()
218 if (info->version != RTC_INFO_VERSION) in optee_rtc_read_info()
219 return -EPROTO; in optee_rtc_read_info()
221 *features = info->features; in optee_rtc_read_info()
223 tm = &info->range_min; in optee_rtc_read_info()
224 rtc->range_min = mktime64(tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, in optee_rtc_read_info()
225 tm->tm_sec); in optee_rtc_read_info()
226 tm = &info->range_max; in optee_rtc_read_info()
227 rtc->range_max = mktime64(tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, in optee_rtc_read_info()
228 tm->tm_sec); in optee_rtc_read_info()
235 if (ver->impl_id == TEE_IMPL_ID_OPTEE) in optee_ctx_match()
254 return -ENOMEM; in optee_rtc_probe()
261 priv->ctx = tee_client_open_context(NULL, optee_ctx_match, NULL, NULL); in optee_rtc_probe()
262 if (IS_ERR(priv->ctx)) in optee_rtc_probe()
263 return -ENODEV; in optee_rtc_probe()
266 export_uuid(sess_arg.uuid, &rtc_device->id.uuid); in optee_rtc_probe()
269 ret = tee_client_open_session(priv->ctx, &sess_arg, NULL); in optee_rtc_probe()
272 err = -EINVAL; in optee_rtc_probe()
275 priv->session_id = sess_arg.session; in optee_rtc_probe()
277 shm = tee_shm_alloc_kernel_buf(priv->ctx, sizeof(struct optee_rtc_info)); in optee_rtc_probe()
279 dev_err(priv->dev, "tee_shm_alloc_kernel_buf failed\n"); in optee_rtc_probe()
284 priv->shm = shm; in optee_rtc_probe()
285 priv->dev = dev; in optee_rtc_probe()
288 rtc->ops = &optee_rtc_ops; in optee_rtc_probe()
290 err = optee_rtc_read_info(dev, rtc, &priv->features); in optee_rtc_probe()
292 dev_err(dev, "Failed to get RTC features from OP-TEE\n"); in optee_rtc_probe()
304 if (!(priv->features & TA_RTC_FEATURE_CORRECTION)) in optee_rtc_probe()
305 clear_bit(RTC_FEATURE_CORRECTION, rtc->features); in optee_rtc_probe()
310 tee_shm_free(priv->shm); in optee_rtc_probe()
312 tee_client_close_session(priv->ctx, priv->session_id); in optee_rtc_probe()
314 tee_client_close_context(priv->ctx); in optee_rtc_probe()
323 tee_client_close_session(priv->ctx, priv->session_id); in optee_rtc_remove()
324 tee_client_close_context(priv->ctx); in optee_rtc_remove()
362 MODULE_DESCRIPTION("OP-TEE based RTC driver");