| /* SPDX-License-Identifier: GPL-2.0-only */ |
| /* |
| * GXP host-device interface structures. |
| * |
| * Copyright (C) 2021 Google LLC |
| * |
| * This header is shared with the GXP firmware. It establishes the format of the |
| * shared structures used by the GXP driver to describe to the GXP FW the HW |
| * setup and memory regions needed by the FW to operate. |
| * Since the header is shared with the FW, it cannot rely on kernel-specific |
| * headers or data structures. |
| * |
| */ |
| |
| #ifndef __GXP_HOST_DEVICE_STRUCTURES_H__ |
| #define __GXP_HOST_DEVICE_STRUCTURES_H__ |
| |
| #define MAX_NUM_CORES 4 |
| |
| /* The number of physical doorbells and sync barriers allocated to each VD */ |
| #define GXP_NUM_DOORBELLS_PER_VD 7 |
| #define GXP_NUM_SYNC_BARRIERS_PER_VD 4 |
| |
| /* The first allowed doorbell and sync barrier to be used for VDs' usage */ |
| #define GXP_DOORBELLS_START 4 /* The first 4 are used for boot */ |
| #define GXP_SYNC_BARRIERS_START 1 /* The first 1 is used for UART */ |
| |
| /* Definitions for host->device boot mode requests */ |
| /* |
| * No boot action is needed. This is a valid mode once a core is running. |
| * However, it's an invalid state when a FW is powering on. The DSP core will |
| * write it to the boot mode register once it starts a transition. |
| * This is helpful in case the core reboots/crashes while performing the |
| * transition so it doesn't get stuck in a boot loop. |
| */ |
| #define GXP_BOOT_MODE_NONE 0 |
| |
| /* |
| * Request that the core performs a normal cold boot on the next power-on event. |
| * This does not actually wake the core up, but is required before powering the |
| * core up if cold boot is desired. |
| * Core power-on could be performed using any wake-up source like the doorbells. |
| * Upon success, the boot status should be GXP_BOOT_STATUS_ACTIVE. |
| */ |
| #define GXP_BOOT_MODE_COLD_BOOT 1 |
| |
| /* |
| * Request that the core suspends on the next suspend signal arrival. This does |
| * not trigger a suspend operation. A subsequent mailbox command or notification |
| * is needed to trigger the actual transition. Upon success, the boot status |
| * should be GXP_BOOT_STATUS_SUSPENDED. |
| */ |
| #define GXP_BOOT_MODE_SUSPEND 2 |
| |
| /* |
| * Request that the core to preempt the active workload on the next suspend |
| * signal arrival.Upon success, the boot status should be |
| * GXP_BOOT_STATUS_SUSPENDED. |
| */ |
| #define GXP_BOOT_MODE_PREEMPT 3 |
| |
| /* |
| * Request the core resumes on the next power on-event. This does not trigger a |
| * resume operation, but is required before powering the core up if warm |
| * boot/resume is desired. |
| * Core power-on could be performed using any wake-up source like direct LPM |
| * transition into PS0. Upon success, the boot status should be |
| * GXP_BOOT_STATUS_ACTIVE |
| */ |
| #define GXP_BOOT_MODE_RESUME 4 |
| |
| /* |
| * Request the core shutdown. A subsequent mailbox command or notification |
| * is needed to trigger the actual transition. Upon success, the boot status |
| * should be GXP_BOOT_STATUS_OFF. |
| */ |
| #define GXP_BOOT_MODE_SHUTDOWN 5 |
| |
| /* Definitions for host->device boot status */ |
| /* Initial status */ |
| #define GXP_BOOT_STATUS_NONE 0 |
| |
| /* Final status */ |
| #define GXP_BOOT_STATUS_ACTIVE 1 |
| #define GXP_BOOT_STATUS_SUSPENDED 2 |
| #define GXP_BOOT_STATUS_OFF 3 |
| |
| /* Transition status */ |
| #define GXP_BOOT_STATUS_INVALID_MODE 4 |
| #define GXP_BOOT_STATUS_BOOTING 5 |
| #define GXP_BOOT_STATUS_BOOTING_FAILED 6 |
| #define GXP_BOOT_STATUS_SUSPENDING 7 |
| #define GXP_BOOT_STATUS_SUSPENDING_FAILED 8 |
| #define GXP_BOOT_STATUS_SUSPENDING_FAILED_ACTIVE_WL 9 |
| #define GXP_BOOT_STATUS_WAITING_FOR_WORKLOAD 10 |
| #define GXP_BOOT_STATUS_WAITING_FOR_DMA 11 |
| #define GXP_BOOT_STATUS_SHUTTING_DOWN 12 |
| |
| /* Bit masks for the status fields in the core telemetry structures. */ |
| /* The core telemetry buffers have been setup by the host. */ |
| #define GXP_CORE_TELEMETRY_HOST_STATUS_ENABLED (1 << 0) |
| /* The core telemetry buffers are being used by the device. */ |
| #define GXP_CORE_TELEMETRY_DEVICE_STATUS_ENABLED (1 << 0) |
| /* There was an attempt to use the buffers but their content was invalid. */ |
| #define GXP_CORE_TELEMETRY_DEVICE_STATUS_SANITY_CHECK_FAILED (1 << 1) |
| |
| /* |
| * A structure describing the core telemetry (logging and tracing) parameters |
| * and buffers. |
| */ |
| struct gxp_core_telemetry_descriptor { |
| /* A struct for describing the parameters for core telemetry buffers. */ |
| struct core_telemetry_descriptor { |
| /* |
| * The core telemetry status from the host's point of view. See |
| * the top of the file for the appropriate flags. |
| */ |
| uint32_t host_status; |
| /* |
| * The core telemetry status from the device point of view. See |
| * the top of the file for the appropriate flags. |
| */ |
| uint32_t device_status; |
| /* |
| * The device address for the buffer used for storing events. |
| * The head and tail indices are described inside the data |
| * pointed to by `buffer_addr`. |
| */ |
| uint32_t buffer_addr; |
| /* The size of the buffer (in bytes) */ |
| uint32_t buffer_size; |
| /* The watermark interrupt threshold (in bytes) */ |
| uint32_t watermark_level; |
| } per_core_loggers[MAX_NUM_CORES], per_core_tracers[MAX_NUM_CORES]; |
| }; |
| |
| /* |
| * A structure for describing the state of the job this worker core is part of. |
| * This struct is expected to change per dispatch/context switch/preepmtion as |
| * it describes the HW resources, FW IDs, and other parameters that may change |
| * across job dispatches. |
| * It also establishes a slot used for the various HW resources this VD is |
| * expected to use. |
| * Each FW in a VD is expected to be provided its own copy of this structure |
| * based on the job that it's part of. |
| */ |
| struct gxp_job_descriptor { |
| /* The number of workers participating in this job. */ |
| uint32_t workers_count; |
| |
| /* |
| * A mapping between a worker ID and the FW ID handling it. The FW ID |
| * used for handling worker 'w' is defined in worker_to_fw[w]. |
| */ |
| int32_t worker_to_fw[MAX_NUM_CORES]; |
| |
| /* |
| * A slot ID between 0 and MAX_NUM_CORES (exclusive) that indicates |
| * which block of HW resources this VD is expected to use. All system |
| * HW resources (such as doorbells, sync barriers, etc) are split across |
| * the slots evenly; usually starting at a specific physical ID and |
| * spanning a number consecutive instances. The start ID for each HW |
| * resource category is defined in GXP_<resource_name>_START; and the |
| * number of resources alloted to each slot is defined in |
| * GXP_NUM_<resource_name>_PER_VD. |
| */ |
| uint32_t hardware_resources_slot; |
| }; |
| |
| /* |
| * A per-FW control structure used to communicate between the host (MCU or |
| * kernel) and the DSP core. The region is expected to be hosted in uncached |
| * memory. |
| */ |
| struct gxp_host_control_region { |
| /* |
| * Written to by the FW to indicate to the host that the core is |
| * alive. |
| */ |
| uint32_t core_alive_magic; |
| |
| /* |
| * Written to by the FW to indicate to the host that the core can read |
| * TOP registers. |
| */ |
| uint32_t top_access_ok; |
| |
| /* |
| * Written to by the host to specify the request FW boot mode. See the |
| * GXP_BOOT_MODE_* definitions for valid values. Always set by the FW to |
| * GXP_BOOT_MODE_NONE once the requested boot mode transition is |
| * completed. |
| */ |
| uint32_t boot_mode; |
| |
| /* |
| * Written to by the FW to indicate the boot status. See |
| * GXP_BOOT_STATUS_* definitions for valid values. |
| */ |
| uint32_t boot_status; |
| |
| /* Reserved fields for future expansion */ |
| uint32_t reserved_boot[12]; |
| |
| /* To be used to communicate statistics for timing events during boot */ |
| uint32_t timing_entries[16]; |
| |
| /* To be used to communicate crash events in case of failures */ |
| uint32_t valid_crash_info; |
| uint32_t crash_exccause; |
| uint32_t crash_excvaddr; |
| uint32_t crash_epc1; |
| uint32_t reserved_crash_info[12]; |
| |
| /* Reserved for more categories */ |
| uint32_t reserved[16]; |
| |
| /* |
| * The per-core job descriptor. This struct will be inspected by the FW |
| * at the beginning of every dispatch. |
| */ |
| struct gxp_job_descriptor job_descriptor; |
| }; |
| |
| /* |
| * A structure describing the telemetry (logging and tracing) parameters and |
| * buffers; this describes R/O aspects of the telemetry buffers. |
| */ |
| struct gxp_telemetry_descriptor_ro { |
| struct telemetry_descriptor_ro { |
| /* |
| * The telemetry status from the host's point of view. See the |
| * top of the file for the appropriate flags. |
| */ |
| uint32_t host_status; |
| |
| /* |
| * The device address for the buffer used for storing events. |
| * The head and tail indices are described inside the data |
| * pointed to by `buffer_addr`. |
| */ |
| uint32_t buffer_addr; |
| |
| /* The size of the buffer (in bytes) */ |
| uint32_t buffer_size; |
| } per_core_loggers[MAX_NUM_CORES], per_core_tracers[MAX_NUM_CORES]; |
| }; |
| |
| /* |
| * A structure describing the external state of the VD. This structure is read |
| * once by the FW upon the first cold boot and is never checked again. |
| */ |
| struct gxp_vd_descriptor { |
| /* The ID for this GXP application. */ |
| uint32_t application_id; |
| |
| /* |
| * Whether or not this VD has been initialized by one of its cores. |
| * This variable is protected by sync barrier at offset 0. Should be |
| * initialized by the host to 0. |
| */ |
| uint32_t vd_is_initialized; |
| }; |
| |
| /* |
| * A descriptor for data that is common to the entire system; usually accessed |
| * by physical core. This region is mapped as R/O for all VDs. Should be |
| * writable by the host (MCU/Kernel) |
| */ |
| struct gxp_system_descriptor_ro { |
| /* A device address for the common debug dump region */ |
| uint32_t debug_dump_dev_addr; |
| |
| /* |
| * A R/O descriptor for the telemetry data. Describing buffer |
| * parameters. |
| */ |
| struct gxp_telemetry_descriptor_ro telemetry_desc; |
| }; |
| |
| /* |
| * A structure describing the telemetry (logging and tracing) parameters; this |
| * describes R/W aspects of the telemetry system. |
| */ |
| struct gxp_telemetry_descriptor_rw { |
| /* A struct for describing R/W status parameters of the buffer */ |
| struct telemetry_descriptor_rw { |
| /* |
| * The telemetry status from the device point of view. See the |
| * top of the file for the appropriate flags. |
| */ |
| uint32_t device_status; |
| |
| /* |
| * Whether or not this telemetry category has data available |
| * for the host |
| */ |
| uint32_t data_available; |
| } per_core_loggers[MAX_NUM_CORES], per_core_tracers[MAX_NUM_CORES]; |
| }; |
| |
| /* |
| * A descriptor for data that is common to the entire system; usually accessed |
| * by physical core. This region is mapped as R/W for all VDs. |
| */ |
| struct gxp_system_descriptor_rw { |
| /* A R/W descriptor for the telemetry data */ |
| struct gxp_telemetry_descriptor_rw telemetry_desc; |
| }; |
| |
| #endif /* __GXP_HOST_DEVICE_STRUCTURES_H__ */ |