18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * Copyright 2017-2018 HabanaLabs, Ltd. 48c2ecf20Sopenharmony_ci * All Rights Reserved. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef GOYA_PACKETS_H 98c2ecf20Sopenharmony_ci#define GOYA_PACKETS_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/types.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define PACKET_HEADER_PACKET_ID_SHIFT 56 148c2ecf20Sopenharmony_ci#define PACKET_HEADER_PACKET_ID_MASK 0x1F00000000000000ull 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_cienum packet_id { 178c2ecf20Sopenharmony_ci PACKET_WREG_32 = 0x1, 188c2ecf20Sopenharmony_ci PACKET_WREG_BULK = 0x2, 198c2ecf20Sopenharmony_ci PACKET_MSG_LONG = 0x3, 208c2ecf20Sopenharmony_ci PACKET_MSG_SHORT = 0x4, 218c2ecf20Sopenharmony_ci PACKET_CP_DMA = 0x5, 228c2ecf20Sopenharmony_ci PACKET_MSG_PROT = 0x7, 238c2ecf20Sopenharmony_ci PACKET_FENCE = 0x8, 248c2ecf20Sopenharmony_ci PACKET_LIN_DMA = 0x9, 258c2ecf20Sopenharmony_ci PACKET_NOP = 0xA, 268c2ecf20Sopenharmony_ci PACKET_STOP = 0xB, 278c2ecf20Sopenharmony_ci MAX_PACKET_ID = (PACKET_HEADER_PACKET_ID_MASK >> 288c2ecf20Sopenharmony_ci PACKET_HEADER_PACKET_ID_SHIFT) + 1 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cienum goya_dma_direction { 328c2ecf20Sopenharmony_ci DMA_HOST_TO_DRAM, 338c2ecf20Sopenharmony_ci DMA_HOST_TO_SRAM, 348c2ecf20Sopenharmony_ci DMA_DRAM_TO_SRAM, 358c2ecf20Sopenharmony_ci DMA_SRAM_TO_DRAM, 368c2ecf20Sopenharmony_ci DMA_SRAM_TO_HOST, 378c2ecf20Sopenharmony_ci DMA_DRAM_TO_HOST, 388c2ecf20Sopenharmony_ci DMA_DRAM_TO_DRAM, 398c2ecf20Sopenharmony_ci DMA_SRAM_TO_SRAM, 408c2ecf20Sopenharmony_ci DMA_ENUM_MAX 418c2ecf20Sopenharmony_ci}; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define GOYA_PKT_CTL_OPCODE_SHIFT 24 448c2ecf20Sopenharmony_ci#define GOYA_PKT_CTL_OPCODE_MASK 0x1F000000 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define GOYA_PKT_CTL_EB_SHIFT 29 478c2ecf20Sopenharmony_ci#define GOYA_PKT_CTL_EB_MASK 0x20000000 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#define GOYA_PKT_CTL_RB_SHIFT 30 508c2ecf20Sopenharmony_ci#define GOYA_PKT_CTL_RB_MASK 0x40000000 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define GOYA_PKT_CTL_MB_SHIFT 31 538c2ecf20Sopenharmony_ci#define GOYA_PKT_CTL_MB_MASK 0x80000000 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci/* All packets have, at least, an 8-byte header, which contains 568c2ecf20Sopenharmony_ci * the packet type. The kernel driver uses the packet header for packet 578c2ecf20Sopenharmony_ci * validation and to perform any necessary required preparation before 588c2ecf20Sopenharmony_ci * sending them off to the hardware. 598c2ecf20Sopenharmony_ci */ 608c2ecf20Sopenharmony_cistruct goya_packet { 618c2ecf20Sopenharmony_ci __le64 header; 628c2ecf20Sopenharmony_ci /* The rest of the packet data follows. Use the corresponding 638c2ecf20Sopenharmony_ci * packet_XXX struct to deference the data, based on packet type 648c2ecf20Sopenharmony_ci */ 658c2ecf20Sopenharmony_ci u8 contents[0]; 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistruct packet_nop { 698c2ecf20Sopenharmony_ci __le32 reserved; 708c2ecf20Sopenharmony_ci __le32 ctl; 718c2ecf20Sopenharmony_ci}; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_cistruct packet_stop { 748c2ecf20Sopenharmony_ci __le32 reserved; 758c2ecf20Sopenharmony_ci __le32 ctl; 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define GOYA_PKT_WREG32_CTL_REG_OFFSET_SHIFT 0 798c2ecf20Sopenharmony_ci#define GOYA_PKT_WREG32_CTL_REG_OFFSET_MASK 0x0000FFFF 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_cistruct packet_wreg32 { 828c2ecf20Sopenharmony_ci __le32 value; 838c2ecf20Sopenharmony_ci __le32 ctl; 848c2ecf20Sopenharmony_ci}; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cistruct packet_wreg_bulk { 878c2ecf20Sopenharmony_ci __le32 size64; 888c2ecf20Sopenharmony_ci __le32 ctl; 898c2ecf20Sopenharmony_ci __le64 values[0]; /* data starts here */ 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cistruct packet_msg_long { 938c2ecf20Sopenharmony_ci __le32 value; 948c2ecf20Sopenharmony_ci __le32 ctl; 958c2ecf20Sopenharmony_ci __le64 addr; 968c2ecf20Sopenharmony_ci}; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistruct packet_msg_short { 998c2ecf20Sopenharmony_ci __le32 value; 1008c2ecf20Sopenharmony_ci __le32 ctl; 1018c2ecf20Sopenharmony_ci}; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_cistruct packet_msg_prot { 1048c2ecf20Sopenharmony_ci __le32 value; 1058c2ecf20Sopenharmony_ci __le32 ctl; 1068c2ecf20Sopenharmony_ci __le64 addr; 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cistruct packet_fence { 1108c2ecf20Sopenharmony_ci __le32 cfg; 1118c2ecf20Sopenharmony_ci __le32 ctl; 1128c2ecf20Sopenharmony_ci}; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci#define GOYA_PKT_LIN_DMA_CTL_WO_SHIFT 0 1158c2ecf20Sopenharmony_ci#define GOYA_PKT_LIN_DMA_CTL_WO_MASK 0x00000001 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci#define GOYA_PKT_LIN_DMA_CTL_RDCOMP_SHIFT 1 1188c2ecf20Sopenharmony_ci#define GOYA_PKT_LIN_DMA_CTL_RDCOMP_MASK 0x00000002 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci#define GOYA_PKT_LIN_DMA_CTL_WRCOMP_SHIFT 2 1218c2ecf20Sopenharmony_ci#define GOYA_PKT_LIN_DMA_CTL_WRCOMP_MASK 0x00000004 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci#define GOYA_PKT_LIN_DMA_CTL_MEMSET_SHIFT 6 1248c2ecf20Sopenharmony_ci#define GOYA_PKT_LIN_DMA_CTL_MEMSET_MASK 0x00000040 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci#define GOYA_PKT_LIN_DMA_CTL_DMA_DIR_SHIFT 20 1278c2ecf20Sopenharmony_ci#define GOYA_PKT_LIN_DMA_CTL_DMA_DIR_MASK 0x00700000 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_cistruct packet_lin_dma { 1308c2ecf20Sopenharmony_ci __le32 tsize; 1318c2ecf20Sopenharmony_ci __le32 ctl; 1328c2ecf20Sopenharmony_ci __le64 src_addr; 1338c2ecf20Sopenharmony_ci __le64 dst_addr; 1348c2ecf20Sopenharmony_ci}; 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_cistruct packet_cp_dma { 1378c2ecf20Sopenharmony_ci __le32 tsize; 1388c2ecf20Sopenharmony_ci __le32 ctl; 1398c2ecf20Sopenharmony_ci __le64 src_addr; 1408c2ecf20Sopenharmony_ci}; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci#endif /* GOYA_PACKETS_H */ 143