int imx_sc_misc_get_control(struct imx_sc_ipc *ipc, u32 resource, u8 ctrl, u32 *val) { struct imx_sc_msg_req_misc_get_ctrl msg; struct imx_sc_msg_resp_misc_get_ctrl *resp; struct imx_sc_rpc_msg *hdr = &msg.hdr; int ret; hdr->ver = IMX_SC_RPC_VERSION; hdr->svc = (uint8_t)IMX_SC_RPC_SVC_MISC; hdr->func = (uint8_t)IMX_SC_MISC_FUNC_GET_CONTROL; hdr->size = 3; msg.ctrl = ctrl; msg.resource = resource; ret = imx_scu_call_rpc(ipc, &msg, true); if (ret) return ret; resp = (struct imx_sc_msg_resp_misc_get_ctrl *)&msg; if (val != NULL) *val = resp->val; return 0; }
int imx_sc_misc_set_control(struct imx_sc_ipc *ipc, u32 resource, u8 ctrl, u32 val) { struct imx_sc_msg_req_misc_set_ctrl msg; struct imx_sc_rpc_msg *hdr = &msg.hdr; hdr->ver = IMX_SC_RPC_VERSION; hdr->svc = (uint8_t)IMX_SC_RPC_SVC_MISC; hdr->func = (uint8_t)IMX_SC_MISC_FUNC_SET_CONTROL; hdr->size = 4; msg.ctrl = ctrl; msg.val = val; msg.resource = resource; return imx_scu_call_rpc(ipc, &msg, true); }
static int imx_sc_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct imx_sc_msg_timer_get_rtc_time msg; struct imx_sc_rpc_msg *hdr = &msg.hdr; int ret; hdr->ver = IMX_SC_RPC_VERSION; hdr->svc = IMX_SC_RPC_SVC_TIMER; hdr->func = IMX_SC_TIMER_FUNC_GET_RTC_SEC1970; hdr->size = 1; ret = imx_scu_call_rpc(rtc_ipc_handle, &msg, true); if (ret) { dev_err(dev, "read rtc time failed, ret %d\n", ret); return ret; } rtc_time64_to_tm(msg.time, tm); return 0; }