18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2015, NVIDIA Corporation. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef _FALCON_H_ 78c2ecf20Sopenharmony_ci#define _FALCON_H_ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/types.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define FALCON_UCLASS_METHOD_OFFSET 0x00000040 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define FALCON_UCLASS_METHOD_DATA 0x00000044 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define FALCON_IRQMSET 0x00001010 168c2ecf20Sopenharmony_ci#define FALCON_IRQMSET_WDTMR (1 << 1) 178c2ecf20Sopenharmony_ci#define FALCON_IRQMSET_HALT (1 << 4) 188c2ecf20Sopenharmony_ci#define FALCON_IRQMSET_EXTERR (1 << 5) 198c2ecf20Sopenharmony_ci#define FALCON_IRQMSET_SWGEN0 (1 << 6) 208c2ecf20Sopenharmony_ci#define FALCON_IRQMSET_SWGEN1 (1 << 7) 218c2ecf20Sopenharmony_ci#define FALCON_IRQMSET_EXT(v) (((v) & 0xff) << 8) 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define FALCON_IRQDEST 0x0000101c 248c2ecf20Sopenharmony_ci#define FALCON_IRQDEST_HALT (1 << 4) 258c2ecf20Sopenharmony_ci#define FALCON_IRQDEST_EXTERR (1 << 5) 268c2ecf20Sopenharmony_ci#define FALCON_IRQDEST_SWGEN0 (1 << 6) 278c2ecf20Sopenharmony_ci#define FALCON_IRQDEST_SWGEN1 (1 << 7) 288c2ecf20Sopenharmony_ci#define FALCON_IRQDEST_EXT(v) (((v) & 0xff) << 8) 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define FALCON_ITFEN 0x00001048 318c2ecf20Sopenharmony_ci#define FALCON_ITFEN_CTXEN (1 << 0) 328c2ecf20Sopenharmony_ci#define FALCON_ITFEN_MTHDEN (1 << 1) 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define FALCON_IDLESTATE 0x0000104c 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define FALCON_CPUCTL 0x00001100 378c2ecf20Sopenharmony_ci#define FALCON_CPUCTL_STARTCPU (1 << 1) 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define FALCON_BOOTVEC 0x00001104 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define FALCON_DMACTL 0x0000110c 428c2ecf20Sopenharmony_ci#define FALCON_DMACTL_DMEM_SCRUBBING (1 << 1) 438c2ecf20Sopenharmony_ci#define FALCON_DMACTL_IMEM_SCRUBBING (1 << 2) 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define FALCON_DMATRFBASE 0x00001110 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define FALCON_DMATRFMOFFS 0x00001114 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#define FALCON_DMATRFCMD 0x00001118 508c2ecf20Sopenharmony_ci#define FALCON_DMATRFCMD_IDLE (1 << 1) 518c2ecf20Sopenharmony_ci#define FALCON_DMATRFCMD_IMEM (1 << 4) 528c2ecf20Sopenharmony_ci#define FALCON_DMATRFCMD_SIZE_256B (6 << 8) 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define FALCON_DMATRFFBOFFS 0x0000111c 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cistruct falcon_fw_bin_header_v1 { 578c2ecf20Sopenharmony_ci u32 magic; /* 0x10de */ 588c2ecf20Sopenharmony_ci u32 version; /* version of bin format (1) */ 598c2ecf20Sopenharmony_ci u32 size; /* entire image size including this header */ 608c2ecf20Sopenharmony_ci u32 os_header_offset; 618c2ecf20Sopenharmony_ci u32 os_data_offset; 628c2ecf20Sopenharmony_ci u32 os_size; 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistruct falcon_fw_os_app_v1 { 668c2ecf20Sopenharmony_ci u32 offset; 678c2ecf20Sopenharmony_ci u32 size; 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistruct falcon_fw_os_header_v1 { 718c2ecf20Sopenharmony_ci u32 code_offset; 728c2ecf20Sopenharmony_ci u32 code_size; 738c2ecf20Sopenharmony_ci u32 data_offset; 748c2ecf20Sopenharmony_ci u32 data_size; 758c2ecf20Sopenharmony_ci}; 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_cistruct falcon_firmware_section { 788c2ecf20Sopenharmony_ci unsigned long offset; 798c2ecf20Sopenharmony_ci size_t size; 808c2ecf20Sopenharmony_ci}; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_cistruct falcon_firmware { 838c2ecf20Sopenharmony_ci /* Firmware after it is read but not loaded */ 848c2ecf20Sopenharmony_ci const struct firmware *firmware; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci /* Raw firmware data */ 878c2ecf20Sopenharmony_ci dma_addr_t iova; 888c2ecf20Sopenharmony_ci dma_addr_t phys; 898c2ecf20Sopenharmony_ci void *virt; 908c2ecf20Sopenharmony_ci size_t size; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci /* Parsed firmware information */ 938c2ecf20Sopenharmony_ci struct falcon_firmware_section bin_data; 948c2ecf20Sopenharmony_ci struct falcon_firmware_section data; 958c2ecf20Sopenharmony_ci struct falcon_firmware_section code; 968c2ecf20Sopenharmony_ci}; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistruct falcon { 998c2ecf20Sopenharmony_ci /* Set by falcon client */ 1008c2ecf20Sopenharmony_ci struct device *dev; 1018c2ecf20Sopenharmony_ci void __iomem *regs; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci struct falcon_firmware firmware; 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ciint falcon_init(struct falcon *falcon); 1078c2ecf20Sopenharmony_civoid falcon_exit(struct falcon *falcon); 1088c2ecf20Sopenharmony_ciint falcon_read_firmware(struct falcon *falcon, const char *firmware_name); 1098c2ecf20Sopenharmony_ciint falcon_load_firmware(struct falcon *falcon); 1108c2ecf20Sopenharmony_ciint falcon_boot(struct falcon *falcon); 1118c2ecf20Sopenharmony_civoid falcon_execute_method(struct falcon *falcon, u32 method, u32 data); 1128c2ecf20Sopenharmony_ciint falcon_wait_idle(struct falcon *falcon); 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci#endif /* _FALCON_H_ */ 115