summaryrefslogtreecommitdiff
path: root/plat/imx/common/sci/svc/irq/irq_rpc_clnt.c
blob: a0f495843f800f4c1ea088a52fbd8a05b561551e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * Copyright (C) 2016 Freescale Semiconductor, Inc.
 * Copyright 2017-2019 NXP
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

/*!
 * File containing client-side RPC functions for the IRQ service. These
 * functions are ported to clients that communicate to the SC.
 *
 * @addtogroup IRQ_SVC
 * @{
 */

/* Includes */

#include <sci/sci_types.h>
#include <sci/svc/rm/sci_rm_api.h>
#include <sci/svc/irq/sci_irq_api.h>
#include <sci/sci_rpc.h>
#include "sci_irq_rpc.h"
#include <stdlib.h>

/* Local Defines */

/* Local Types */

/* Local Functions */

sc_err_t sc_irq_enable(sc_ipc_t ipc, sc_rsrc_t resource, sc_irq_group_t group,
		       uint32_t mask, sc_bool_t enable)
{
	sc_rpc_msg_t msg;
	sc_err_t err;

	RPC_VER(&msg) = SC_RPC_VERSION;
	RPC_SIZE(&msg) = 3U;
	RPC_SVC(&msg) = U8(SC_RPC_SVC_IRQ);
	RPC_FUNC(&msg) = U8(IRQ_FUNC_ENABLE);

	RPC_U32(&msg, 0U) = U32(mask);
	RPC_U16(&msg, 4U) = U16(resource);
	RPC_U8(&msg, 6U) = U8(group);
	RPC_U8(&msg, 7U) = B2U8(enable);

	sc_call_rpc(ipc, &msg, SC_FALSE);

	err = (sc_err_t)RPC_R8(&msg);

	return err;
}

sc_err_t sc_irq_status(sc_ipc_t ipc, sc_rsrc_t resource, sc_irq_group_t group,
		       uint32_t *status)
{
	sc_rpc_msg_t msg;
	sc_err_t err;

	RPC_VER(&msg) = SC_RPC_VERSION;
	RPC_SIZE(&msg) = 2U;
	RPC_SVC(&msg) = U8(SC_RPC_SVC_IRQ);
	RPC_FUNC(&msg) = U8(IRQ_FUNC_STATUS);

	RPC_U16(&msg, 0U) = U16(resource);
	RPC_U8(&msg, 2U) = U8(group);

	sc_call_rpc(ipc, &msg, SC_FALSE);

	err = (sc_err_t)RPC_R8(&msg);

	if (status != NULL) {
		*status = (uint32_t)RPC_U32(&msg, 0U);
	}

	return err;
}

/**@}*/