summaryrefslogtreecommitdiff
path: root/gxp-firmware-data.h
blob: a947cb8f4da8fd07a203dff7dac0a7b042da00a1 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * GXP firmware data manager.
 * A sub-module responsible for managing the resources/data regions shared
 * between the GXP driver and FW.
 *
 * Copyright (C) 2021 Google LLC
 */
#ifndef __GXP_FIRMWARE_DATA_H__
#define __GXP_FIRMWARE_DATA_H__

#include "gxp-dma.h"
#include "gxp-internal.h"

/**
 * gxp_fw_data_init() - Initializes the FW data manager submodule.
 * @gxp: The parent GXP device
 *
 * Return:
 * 0       - Successfully initialized submodule
 * -ENOMEM - Insufficient memory to create the submodule
 * -ENODEV - Failed to locate the shared driver-device region
 * -Other  - Error codes propagated from internal functions.
 */
int gxp_fw_data_init(struct gxp_dev *gxp);

/**
 * gxp_fw_data_create_app() - Allocates HW and memory resources needed to create
 *                            a GXP device application (1:1 with a GXP driver
 *                            virtual device) used by the specified physical
 *                            cores.
 * @gxp: The parent GXP device
 * @core_list: A bitmap of the physical cores used in this application
 *
 * Return:
 * ptr     - A pointer of the newly created application handle, an error pointer
 *           (PTR_ERR) otherwise.
 * -ENOMEM - Insufficient memory to create the application
 */
void *gxp_fw_data_create_app(struct gxp_dev *gxp, uint core_list);

/**
 * gxp_fw_data_destroy_app() - Deallocates the HW and memory resources used by
 *                             the specified application.
 * @gxp: The parent GXP device
 * @application: The handle to the application to deallocate
 */
void gxp_fw_data_destroy_app(struct gxp_dev *gxp, void *application);

/**
 * gxp_fw_data_destroy() - Destroys the FW data manager submodule and free all
 *                         its resources.
 * @gxp: The parent GXP device
 */
void gxp_fw_data_destroy(struct gxp_dev *gxp);

/**
 * gxp_fw_data_set_core_telemetry_descriptors() - Set new logging or tracing
 *                                                buffers for firmware to write
 *                                                to.
 * @gxp: The GXP device to set buffer descriptors for
 * @type: Either `GXP_TELEMETRY_TYPE_LOGGING` or `GXP_TELEMETRY_TYPE_TRACING`
 * @host_status:  Bitfield describing the host's core telemetry status. See the
 *                bit definitions in gxp-host-device-structs.h.
 * @buffers: An array of coherent buffers for logging and tracing
 * @per_buffer_size: The size of each core's logging or tracing buffer in bytes
 *
 * `gxp_fw_data_init()` must have been called before this function.
 *
 * Caller must hold gxp->core_telemetry_mgr's lock.
 *
 * Return:
 * 0       - Success
 * -EINVAL - Invalid @type provided or @buffer_addrs are not addressable by @gxp
 */
int gxp_fw_data_set_core_telemetry_descriptors(struct gxp_dev *gxp, u8 type,
					       u32 host_status,
					       struct gxp_coherent_buf *buffers,
					       u32 per_buffer_size);

/**
 * gxp_fw_data_get_core_telemetry_device_status() - Returns a bitfield
 *                                                  describing a core's
 *                                                  telemetry status.
 * @gxp: The GXP device to get core telemetry status for
 * @core: The core in @gxp to get the core telemetry status for
 * @type: Either `GXP_TELEMETRY_TYPE_LOGGING` or `GXP_TELEMETRY_TYPE_TRACING`
 *
 * Caller must hold gxp->core_telemetry_mgr's lock.
 *
 * Return: The bitfield describing @core's telemetry status. If @core or @type
 *         are invalid, the result will always be 0.
 */
u32 gxp_fw_data_get_core_telemetry_device_status(struct gxp_dev *gxp, uint core,
						 u8 type);

#endif /* __GXP_FIRMWARE_DATA_H__ */