pad_rpc_clnt.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. /*
  2. * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. /*!
  7. * File containing client-side RPC functions for the PAD service. These
  8. * functions are ported to clients that communicate to the SC.
  9. *
  10. * @addtogroup PAD_SVC
  11. * @{
  12. */
  13. /* Includes */
  14. #include <stdlib.h>
  15. #include <sci/sci_types.h>
  16. #include <sci/svc/rm/sci_rm_api.h>
  17. #include <sci/svc/pad/sci_pad_api.h>
  18. #include <sci/sci_rpc.h>
  19. #include "sci_pad_rpc.h"
  20. /* Local Defines */
  21. /* Local Types */
  22. /* Local Functions */
  23. sc_err_t sc_pad_set_mux(sc_ipc_t ipc, sc_pad_t pad,
  24. uint8_t mux, sc_pad_config_t config, sc_pad_iso_t iso)
  25. {
  26. sc_rpc_msg_t msg;
  27. uint8_t result;
  28. RPC_VER(&msg) = SC_RPC_VERSION;
  29. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  30. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_MUX;
  31. RPC_U16(&msg, 0U) = (uint16_t)pad;
  32. RPC_U8(&msg, 2U) = (uint8_t)mux;
  33. RPC_U8(&msg, 3U) = (uint8_t)config;
  34. RPC_U8(&msg, 4U) = (uint8_t)iso;
  35. RPC_SIZE(&msg) = 3U;
  36. sc_call_rpc(ipc, &msg, SC_FALSE);
  37. result = RPC_R8(&msg);
  38. return (sc_err_t)result;
  39. }
  40. sc_err_t sc_pad_get_mux(sc_ipc_t ipc, sc_pad_t pad,
  41. uint8_t *mux, sc_pad_config_t *config,
  42. sc_pad_iso_t *iso)
  43. {
  44. sc_rpc_msg_t msg;
  45. uint8_t result;
  46. RPC_VER(&msg) = SC_RPC_VERSION;
  47. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  48. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_MUX;
  49. RPC_U16(&msg, 0U) = (uint16_t)pad;
  50. RPC_SIZE(&msg) = 2U;
  51. sc_call_rpc(ipc, &msg, SC_FALSE);
  52. result = RPC_R8(&msg);
  53. if (mux != NULL) {
  54. *mux = RPC_U8(&msg, 0U);
  55. }
  56. if (config != NULL) {
  57. *config = RPC_U8(&msg, 1U);
  58. }
  59. if (iso != NULL) {
  60. *iso = RPC_U8(&msg, 2U);
  61. }
  62. return (sc_err_t)result;
  63. }
  64. sc_err_t sc_pad_set_gp(sc_ipc_t ipc, sc_pad_t pad, uint32_t ctrl)
  65. {
  66. sc_rpc_msg_t msg;
  67. uint8_t result;
  68. RPC_VER(&msg) = SC_RPC_VERSION;
  69. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  70. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_GP;
  71. RPC_U32(&msg, 0U) = (uint32_t)ctrl;
  72. RPC_U16(&msg, 4U) = (uint16_t)pad;
  73. RPC_SIZE(&msg) = 3U;
  74. sc_call_rpc(ipc, &msg, SC_FALSE);
  75. result = RPC_R8(&msg);
  76. return (sc_err_t)result;
  77. }
  78. sc_err_t sc_pad_get_gp(sc_ipc_t ipc, sc_pad_t pad, uint32_t *ctrl)
  79. {
  80. sc_rpc_msg_t msg;
  81. uint8_t result;
  82. RPC_VER(&msg) = SC_RPC_VERSION;
  83. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  84. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_GP;
  85. RPC_U16(&msg, 0U) = (uint16_t)pad;
  86. RPC_SIZE(&msg) = 2U;
  87. sc_call_rpc(ipc, &msg, SC_FALSE);
  88. if (ctrl != NULL) {
  89. *ctrl = RPC_U32(&msg, 0U);
  90. }
  91. result = RPC_R8(&msg);
  92. return (sc_err_t)result;
  93. }
  94. sc_err_t sc_pad_set_wakeup(sc_ipc_t ipc, sc_pad_t pad, sc_pad_wakeup_t wakeup)
  95. {
  96. sc_rpc_msg_t msg;
  97. uint8_t result;
  98. RPC_VER(&msg) = SC_RPC_VERSION;
  99. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  100. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_WAKEUP;
  101. RPC_U16(&msg, 0U) = (uint16_t)pad;
  102. RPC_U8(&msg, 2U) = (uint8_t)wakeup;
  103. RPC_SIZE(&msg) = 2U;
  104. sc_call_rpc(ipc, &msg, SC_FALSE);
  105. result = RPC_R8(&msg);
  106. return (sc_err_t)result;
  107. }
  108. sc_err_t sc_pad_get_wakeup(sc_ipc_t ipc, sc_pad_t pad, sc_pad_wakeup_t *wakeup)
  109. {
  110. sc_rpc_msg_t msg;
  111. uint8_t result;
  112. RPC_VER(&msg) = SC_RPC_VERSION;
  113. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  114. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_WAKEUP;
  115. RPC_U16(&msg, 0U) = (uint16_t)pad;
  116. RPC_SIZE(&msg) = 2U;
  117. sc_call_rpc(ipc, &msg, SC_FALSE);
  118. result = RPC_R8(&msg);
  119. if (wakeup != NULL) {
  120. *wakeup = RPC_U8(&msg, 0U);
  121. }
  122. return (sc_err_t)result;
  123. }
  124. sc_err_t sc_pad_set_all(sc_ipc_t ipc, sc_pad_t pad, uint8_t mux,
  125. sc_pad_config_t config, sc_pad_iso_t iso, uint32_t ctrl,
  126. sc_pad_wakeup_t wakeup)
  127. {
  128. sc_rpc_msg_t msg;
  129. uint8_t result;
  130. RPC_VER(&msg) = SC_RPC_VERSION;
  131. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  132. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_ALL;
  133. RPC_U32(&msg, 0U) = (uint32_t)ctrl;
  134. RPC_U16(&msg, 4U) = (uint16_t)pad;
  135. RPC_U8(&msg, 6U) = (uint8_t)mux;
  136. RPC_U8(&msg, 7U) = (uint8_t)config;
  137. RPC_U8(&msg, 8U) = (uint8_t)iso;
  138. RPC_U8(&msg, 9U) = (uint8_t)wakeup;
  139. RPC_SIZE(&msg) = 4U;
  140. sc_call_rpc(ipc, &msg, SC_FALSE);
  141. result = RPC_R8(&msg);
  142. return (sc_err_t)result;
  143. }
  144. sc_err_t sc_pad_get_all(sc_ipc_t ipc, sc_pad_t pad, uint8_t *mux,
  145. sc_pad_config_t *config, sc_pad_iso_t *iso,
  146. uint32_t *ctrl, sc_pad_wakeup_t *wakeup)
  147. {
  148. sc_rpc_msg_t msg;
  149. uint8_t result;
  150. RPC_VER(&msg) = SC_RPC_VERSION;
  151. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  152. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_ALL;
  153. RPC_U16(&msg, 0U) = (uint16_t)pad;
  154. RPC_SIZE(&msg) = 2U;
  155. sc_call_rpc(ipc, &msg, SC_FALSE);
  156. if (ctrl != NULL) {
  157. *ctrl = RPC_U32(&msg, 0U);
  158. }
  159. result = RPC_R8(&msg);
  160. if (mux != NULL) {
  161. *mux = RPC_U8(&msg, 4U);
  162. }
  163. if (config != NULL) {
  164. *config = RPC_U8(&msg, 5U);
  165. }
  166. if (iso != NULL) {
  167. *iso = RPC_U8(&msg, 6U);
  168. }
  169. if (wakeup != NULL) {
  170. *wakeup = RPC_U8(&msg, 7U);
  171. }
  172. return (sc_err_t)result;
  173. }
  174. sc_err_t sc_pad_set(sc_ipc_t ipc, sc_pad_t pad, uint32_t val)
  175. {
  176. sc_rpc_msg_t msg;
  177. uint8_t result;
  178. RPC_VER(&msg) = SC_RPC_VERSION;
  179. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  180. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET;
  181. RPC_U32(&msg, 0U) = (uint32_t)val;
  182. RPC_U16(&msg, 4U) = (uint16_t)pad;
  183. RPC_SIZE(&msg) = 3U;
  184. sc_call_rpc(ipc, &msg, SC_FALSE);
  185. result = RPC_R8(&msg);
  186. return (sc_err_t)result;
  187. }
  188. sc_err_t sc_pad_get(sc_ipc_t ipc, sc_pad_t pad, uint32_t *val)
  189. {
  190. sc_rpc_msg_t msg;
  191. uint8_t result;
  192. RPC_VER(&msg) = SC_RPC_VERSION;
  193. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  194. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET;
  195. RPC_U16(&msg, 0U) = (uint16_t)pad;
  196. RPC_SIZE(&msg) = 2U;
  197. sc_call_rpc(ipc, &msg, SC_FALSE);
  198. if (val != NULL) {
  199. *val = RPC_U32(&msg, 0U);
  200. }
  201. result = RPC_R8(&msg);
  202. return (sc_err_t)result;
  203. }
  204. sc_err_t sc_pad_set_gp_28fdsoi(sc_ipc_t ipc, sc_pad_t pad,
  205. sc_pad_28fdsoi_dse_t dse, sc_pad_28fdsoi_ps_t ps)
  206. {
  207. sc_rpc_msg_t msg;
  208. uint8_t result;
  209. RPC_VER(&msg) = SC_RPC_VERSION;
  210. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  211. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_GP_28FDSOI;
  212. RPC_U16(&msg, 0U) = (uint16_t)pad;
  213. RPC_U8(&msg, 2U) = (uint8_t)dse;
  214. RPC_U8(&msg, 3U) = (uint8_t)ps;
  215. RPC_SIZE(&msg) = 2U;
  216. sc_call_rpc(ipc, &msg, SC_FALSE);
  217. result = RPC_R8(&msg);
  218. return (sc_err_t)result;
  219. }
  220. sc_err_t sc_pad_get_gp_28fdsoi(sc_ipc_t ipc, sc_pad_t pad,
  221. sc_pad_28fdsoi_dse_t *dse,
  222. sc_pad_28fdsoi_ps_t *ps)
  223. {
  224. sc_rpc_msg_t msg;
  225. uint8_t result;
  226. RPC_VER(&msg) = SC_RPC_VERSION;
  227. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  228. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_GP_28FDSOI;
  229. RPC_U16(&msg, 0U) = (uint16_t)pad;
  230. RPC_SIZE(&msg) = 2U;
  231. sc_call_rpc(ipc, &msg, SC_FALSE);
  232. result = RPC_R8(&msg);
  233. if (dse != NULL) {
  234. *dse = RPC_U8(&msg, 0U);
  235. }
  236. if (ps != NULL) {
  237. *ps = RPC_U8(&msg, 1U);
  238. }
  239. return (sc_err_t)result;
  240. }
  241. sc_err_t sc_pad_set_gp_28fdsoi_hsic(sc_ipc_t ipc, sc_pad_t pad,
  242. sc_pad_28fdsoi_dse_t dse, sc_bool_t hys,
  243. sc_pad_28fdsoi_pus_t pus, sc_bool_t pke,
  244. sc_bool_t pue)
  245. {
  246. sc_rpc_msg_t msg;
  247. uint8_t result;
  248. RPC_VER(&msg) = SC_RPC_VERSION;
  249. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  250. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_GP_28FDSOI_HSIC;
  251. RPC_U16(&msg, 0U) = (uint16_t)pad;
  252. RPC_U8(&msg, 2U) = (uint8_t)dse;
  253. RPC_U8(&msg, 3U) = (uint8_t)pus;
  254. RPC_U8(&msg, 4U) = (uint8_t)hys;
  255. RPC_U8(&msg, 5U) = (uint8_t)pke;
  256. RPC_U8(&msg, 6U) = (uint8_t)pue;
  257. RPC_SIZE(&msg) = 3U;
  258. sc_call_rpc(ipc, &msg, SC_FALSE);
  259. result = RPC_R8(&msg);
  260. return (sc_err_t)result;
  261. }
  262. sc_err_t sc_pad_get_gp_28fdsoi_hsic(sc_ipc_t ipc, sc_pad_t pad,
  263. sc_pad_28fdsoi_dse_t *dse, sc_bool_t *hys,
  264. sc_pad_28fdsoi_pus_t *pus, sc_bool_t *pke,
  265. sc_bool_t *pue)
  266. {
  267. sc_rpc_msg_t msg;
  268. uint8_t result;
  269. RPC_VER(&msg) = SC_RPC_VERSION;
  270. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  271. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_GP_28FDSOI_HSIC;
  272. RPC_U16(&msg, 0U) = (uint16_t)pad;
  273. RPC_SIZE(&msg) = 2U;
  274. sc_call_rpc(ipc, &msg, SC_FALSE);
  275. result = RPC_R8(&msg);
  276. if (dse != NULL) {
  277. *dse = RPC_U8(&msg, 0U);
  278. }
  279. if (pus != NULL) {
  280. *pus = RPC_U8(&msg, 1U);
  281. }
  282. if (hys != NULL) {
  283. *hys = RPC_U8(&msg, 2U);
  284. }
  285. if (pke != NULL) {
  286. *pke = RPC_U8(&msg, 3U);
  287. }
  288. if (pue != NULL) {
  289. *pue = RPC_U8(&msg, 4U);
  290. }
  291. return (sc_err_t)result;
  292. }
  293. sc_err_t sc_pad_set_gp_28fdsoi_comp(sc_ipc_t ipc, sc_pad_t pad,
  294. uint8_t compen, sc_bool_t fastfrz,
  295. uint8_t rasrcp, uint8_t rasrcn,
  296. sc_bool_t nasrc_sel, sc_bool_t psw_ovr)
  297. {
  298. sc_rpc_msg_t msg;
  299. uint8_t result;
  300. RPC_VER(&msg) = SC_RPC_VERSION;
  301. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  302. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_GP_28FDSOI_COMP;
  303. RPC_U16(&msg, 0U) = (uint16_t)pad;
  304. RPC_U8(&msg, 2U) = (uint8_t)compen;
  305. RPC_U8(&msg, 3U) = (uint8_t)rasrcp;
  306. RPC_U8(&msg, 4U) = (uint8_t)rasrcn;
  307. RPC_U8(&msg, 5U) = (uint8_t)fastfrz;
  308. RPC_U8(&msg, 6U) = (uint8_t)nasrc_sel;
  309. RPC_U8(&msg, 7U) = (uint8_t)psw_ovr;
  310. RPC_SIZE(&msg) = 3U;
  311. sc_call_rpc(ipc, &msg, SC_FALSE);
  312. result = RPC_R8(&msg);
  313. return (sc_err_t)result;
  314. }
  315. sc_err_t sc_pad_get_gp_28fdsoi_comp(sc_ipc_t ipc, sc_pad_t pad,
  316. uint8_t *compen, sc_bool_t *fastfrz,
  317. uint8_t *rasrcp, uint8_t *rasrcn,
  318. sc_bool_t *nasrc_sel, sc_bool_t *compok,
  319. uint8_t *nasrc, sc_bool_t *psw_ovr)
  320. {
  321. sc_rpc_msg_t msg;
  322. uint8_t result;
  323. RPC_VER(&msg) = SC_RPC_VERSION;
  324. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD;
  325. RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_GP_28FDSOI_COMP;
  326. RPC_U16(&msg, 0U) = (uint16_t)pad;
  327. RPC_SIZE(&msg) = 2U;
  328. sc_call_rpc(ipc, &msg, SC_FALSE);
  329. result = RPC_R8(&msg);
  330. if (compen != NULL) {
  331. *compen = RPC_U8(&msg, 0U);
  332. }
  333. if (rasrcp != NULL) {
  334. *rasrcp = RPC_U8(&msg, 1U);
  335. }
  336. if (rasrcn != NULL) {
  337. *rasrcn = RPC_U8(&msg, 2U);
  338. }
  339. if (nasrc != NULL) {
  340. *nasrc = RPC_U8(&msg, 3U);
  341. }
  342. if (fastfrz != NULL) {
  343. *fastfrz = RPC_U8(&msg, 4U);
  344. }
  345. if (nasrc_sel != NULL) {
  346. *nasrc_sel = RPC_U8(&msg, 5U);
  347. }
  348. if (compok != NULL) {
  349. *compok = RPC_U8(&msg, 6U);
  350. }
  351. if (psw_ovr != NULL) {
  352. *psw_ovr = RPC_U8(&msg, 7U);
  353. }
  354. return (sc_err_t)result;
  355. }
  356. /**@}*/