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