aboutsummaryrefslogtreecommitdiff
path: root/module/scmi/include/internal/mod_scmi.h
blob: 822e196bfda830262f68822020092ba9e72d50dd (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
/*
 * Arm SCP/MCP Software
 * Copyright (c) 2015-2018, Arm Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *
 * Description:
 *     System Control and Management Interface (SCMI) support.
 */

#ifndef MOD_INTERNAL_SCMI_H
#define MOD_INTERNAL_SCMI_H

#include <stddef.h>
#include <stdint.h>
#include <mod_scmi.h>

#define SCMI_VERSION 0x10000

#define SCMI_MESSAGE_HEADER_MESSAGE_ID_POS  0
#define SCMI_MESSAGE_HEADER_PROTOCOL_ID_POS 10
#define SCMI_MESSAGE_HEADER_TOKEN_POS       18

#define SCMI_MESSAGE_HEADER_MESSAGE_ID_MASK \
    (UINT32_C(0x3FF) << SCMI_MESSAGE_HEADER_MESSAGE_ID_POS)
#define SCMI_MESSAGE_HEADER_PROTOCOL_ID_MASK \
    (UINT32_C(0xFF)  << SCMI_MESSAGE_HEADER_PROTOCOL_ID_POS)
#define SCMI_MESSAGE_HEADER_TOKEN_MASK  \
    (UINT32_C(0x3FF) << SCMI_MESSAGE_HEADER_TOKEN_POS)

#define SCMI_MESSAGE_HEADER(MESSAGE_ID, PROTOCOL_ID, TOKEN) \
    ((((MESSAGE_ID) << SCMI_MESSAGE_HEADER_MESSAGE_ID_POS) & \
        SCMI_MESSAGE_HEADER_MESSAGE_ID_MASK) | \
    (((PROTOCOL_ID) << SCMI_MESSAGE_HEADER_PROTOCOL_ID_POS) & \
        SCMI_MESSAGE_HEADER_PROTOCOL_ID_MASK) | \
    (((TOKEN) << SCMI_MESSAGE_HEADER_TOKEN_POS) & \
        SCMI_MESSAGE_HEADER_TOKEN_POS))

/* SCMI service context */
struct scmi_service_ctx {
    /* Pointer to SCMI service configuration data */
    const struct mod_scmi_service_config *config;

    /*
     * Identifier of the transport entity used by the service to read/respond
     * to SCMI messages.
     */
    fwk_id_t transport_id;

    /* Pointer to the transport API used to read and respond to messages */
    const struct mod_scmi_to_transport_api *transport_api;

    /* Copy of the pointer to the 'respond' function within the transport API */
    int (*respond)(fwk_id_t transport_id, const void *payload, size_t size);

    /* SCMI identifier of the protocol processing the current message */
    unsigned int scmi_protocol_id;

    /* SCMI identifier of the message currently being processed */
    unsigned int scmi_message_id;
};

#endif /* MOD_INTERNAL_SCMI_H */