1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */ 2cf4c3448SCalvin Johnson /* 3cf4c3448SCalvin Johnson * Copyright 2015-2016 Freescale Semiconductor, Inc. 4cf4c3448SCalvin Johnson * Copyright 2017 NXP 5cf4c3448SCalvin Johnson */ 6cf4c3448SCalvin Johnson 7cf4c3448SCalvin Johnson #ifndef _PFE_H_ 8cf4c3448SCalvin Johnson #define _PFE_H_ 9cf4c3448SCalvin Johnson 10cf4c3448SCalvin Johnson #include <elf.h> 11cf4c3448SCalvin Johnson #include "cbus.h" 12cf4c3448SCalvin Johnson 13cf4c3448SCalvin Johnson #define PFE_RESET_WA 14cf4c3448SCalvin Johnson 15cf4c3448SCalvin Johnson #define CLASS_DMEM_BASE_ADDR(i) (0x00000000 | ((i) << 20)) 16cf4c3448SCalvin Johnson /* Only valid for mem access register interface */ 17cf4c3448SCalvin Johnson #define CLASS_IMEM_BASE_ADDR(i) (0x00000000 | ((i) << 20)) 18cf4c3448SCalvin Johnson #define CLASS_DMEM_SIZE 0x00002000 19cf4c3448SCalvin Johnson #define CLASS_IMEM_SIZE 0x00008000 20cf4c3448SCalvin Johnson 21cf4c3448SCalvin Johnson #define TMU_DMEM_BASE_ADDR(i) (0x00000000 + ((i) << 20)) 22cf4c3448SCalvin Johnson /* Only valid for mem access register interface */ 23cf4c3448SCalvin Johnson #define TMU_IMEM_BASE_ADDR(i) (0x00000000 + ((i) << 20)) 24cf4c3448SCalvin Johnson #define TMU_DMEM_SIZE 0x00000800 25cf4c3448SCalvin Johnson #define TMU_IMEM_SIZE 0x00002000 26cf4c3448SCalvin Johnson 27cf4c3448SCalvin Johnson #define UTIL_DMEM_BASE_ADDR 0x00000000 28cf4c3448SCalvin Johnson #define UTIL_DMEM_SIZE 0x00002000 29cf4c3448SCalvin Johnson 30cf4c3448SCalvin Johnson #define PE_LMEM_BASE_ADDR 0xc3010000 31cf4c3448SCalvin Johnson #define PE_LMEM_SIZE 0x8000 32cf4c3448SCalvin Johnson #define PE_LMEM_END (PE_LMEM_BASE_ADDR + PE_LMEM_SIZE) 33cf4c3448SCalvin Johnson 34cf4c3448SCalvin Johnson #define DMEM_BASE_ADDR 0x00000000 35cf4c3448SCalvin Johnson #define DMEM_SIZE 0x2000 /* TMU has less... */ 36cf4c3448SCalvin Johnson #define DMEM_END (DMEM_BASE_ADDR + DMEM_SIZE) 37cf4c3448SCalvin Johnson 38cf4c3448SCalvin Johnson #define PMEM_BASE_ADDR 0x00010000 39cf4c3448SCalvin Johnson #define PMEM_SIZE 0x8000 /* TMU has less... */ 40cf4c3448SCalvin Johnson #define PMEM_END (PMEM_BASE_ADDR + PMEM_SIZE) 41cf4c3448SCalvin Johnson 42cf4c3448SCalvin Johnson /* Memory ranges check from PE point of view/memory map */ 43cf4c3448SCalvin Johnson #define IS_DMEM(addr, len) (((unsigned long)(addr) >= DMEM_BASE_ADDR) &&\ 44cf4c3448SCalvin Johnson (((unsigned long)(addr) +\ 45cf4c3448SCalvin Johnson (len)) <= DMEM_END)) 46cf4c3448SCalvin Johnson #define IS_PMEM(addr, len) (((unsigned long)(addr) >= PMEM_BASE_ADDR) &&\ 47cf4c3448SCalvin Johnson (((unsigned long)(addr) +\ 48cf4c3448SCalvin Johnson (len)) <= PMEM_END)) 49cf4c3448SCalvin Johnson #define IS_PE_LMEM(addr, len) (((unsigned long)(addr) >= PE_LMEM_BASE_ADDR\ 50cf4c3448SCalvin Johnson ) && (((unsigned long)(addr)\ 51cf4c3448SCalvin Johnson + (len)) <= PE_LMEM_END)) 52cf4c3448SCalvin Johnson 53cf4c3448SCalvin Johnson #define IS_PFE_LMEM(addr, len) (((unsigned long)(addr) >=\ 54cf4c3448SCalvin Johnson CBUS_VIRT_TO_PFE(LMEM_BASE_ADDR)) &&\ 55cf4c3448SCalvin Johnson (((unsigned long)(addr) + (len)) <=\ 56cf4c3448SCalvin Johnson CBUS_VIRT_TO_PFE(LMEM_END))) 57cf4c3448SCalvin Johnson #define IS_PHYS_DDR(addr, len) (((unsigned long)(addr) >=\ 58cf4c3448SCalvin Johnson PFE_DDR_PHYS_BASE_ADDR) &&\ 59cf4c3448SCalvin Johnson (((unsigned long)(addr) + (len)) <=\ 60cf4c3448SCalvin Johnson PFE_DDR_PHYS_END)) 61cf4c3448SCalvin Johnson 62cf4c3448SCalvin Johnson /* Host View Address */ 63cf4c3448SCalvin Johnson extern void *ddr_pfe_base_addr; 64cf4c3448SCalvin Johnson 65cf4c3448SCalvin Johnson /* PFE View Address */ 66cf4c3448SCalvin Johnson /* DDR physical base address as seen by PE's. */ 67cf4c3448SCalvin Johnson #define PFE_DDR_PHYS_BASE_ADDR 0x03800000 68cf4c3448SCalvin Johnson #define PFE_DDR_PHYS_SIZE 0xC000000 69cf4c3448SCalvin Johnson #define PFE_DDR_PHYS_END (PFE_DDR_PHYS_BASE_ADDR + PFE_DDR_PHYS_SIZE) 70cf4c3448SCalvin Johnson /* CBUS physical base address as seen by PE's. */ 71cf4c3448SCalvin Johnson #define PFE_CBUS_PHYS_BASE_ADDR 0xc0000000 72cf4c3448SCalvin Johnson 73cf4c3448SCalvin Johnson /* Host<->PFE Mapping */ 74cf4c3448SCalvin Johnson #define DDR_PFE_TO_VIRT(p) ((unsigned long int)((p) + 0x80000000)) 75cf4c3448SCalvin Johnson #define CBUS_VIRT_TO_PFE(v) (((v) - CBUS_BASE_ADDR) +\ 76cf4c3448SCalvin Johnson PFE_CBUS_PHYS_BASE_ADDR) 77cf4c3448SCalvin Johnson #define CBUS_PFE_TO_VIRT(p) (((p) - PFE_CBUS_PHYS_BASE_ADDR) +\ 78cf4c3448SCalvin Johnson CBUS_BASE_ADDR) 79cf4c3448SCalvin Johnson 80cf4c3448SCalvin Johnson enum { 81cf4c3448SCalvin Johnson CLASS0_ID = 0, 82cf4c3448SCalvin Johnson CLASS1_ID, 83cf4c3448SCalvin Johnson CLASS2_ID, 84cf4c3448SCalvin Johnson CLASS3_ID, 85cf4c3448SCalvin Johnson CLASS4_ID, 86cf4c3448SCalvin Johnson CLASS5_ID, 87cf4c3448SCalvin Johnson 88cf4c3448SCalvin Johnson TMU0_ID, 89cf4c3448SCalvin Johnson TMU1_ID, 90cf4c3448SCalvin Johnson TMU2_ID, 91cf4c3448SCalvin Johnson TMU3_ID, 92cf4c3448SCalvin Johnson MAX_PE 93cf4c3448SCalvin Johnson }; 94cf4c3448SCalvin Johnson 95cf4c3448SCalvin Johnson #define CLASS_MASK (BIT(CLASS0_ID) | BIT(CLASS1_ID) | BIT(CLASS2_ID)\ 96cf4c3448SCalvin Johnson | BIT(CLASS3_ID) | BIT(CLASS4_ID) |\ 97cf4c3448SCalvin Johnson BIT(CLASS5_ID)) 98cf4c3448SCalvin Johnson #define CLASS_MAX_ID CLASS5_ID 99cf4c3448SCalvin Johnson 100cf4c3448SCalvin Johnson #define TMU_MASK (BIT(TMU0_ID) | BIT(TMU1_ID) | BIT(TMU3_ID)) 101cf4c3448SCalvin Johnson #define TMU_MAX_ID TMU3_ID 102cf4c3448SCalvin Johnson 103cf4c3448SCalvin Johnson /* 104cf4c3448SCalvin Johnson * PE information. 105cf4c3448SCalvin Johnson * Structure containing PE's specific information. It is used to create 106cf4c3448SCalvin Johnson * generic C functions common to all PEs. 107cf4c3448SCalvin Johnson * Before using the library functions this structure needs to be 108cf4c3448SCalvin Johnson * initialized with the different registers virtual addresses 109cf4c3448SCalvin Johnson * (according to the ARM MMU mmaping). The default initialization supports a 110cf4c3448SCalvin Johnson * virtual == physical mapping. 111cf4c3448SCalvin Johnson * 112cf4c3448SCalvin Johnson */ 113cf4c3448SCalvin Johnson struct pe_info { 114cf4c3448SCalvin Johnson u32 dmem_base_addr; /* PE's dmem base address */ 115cf4c3448SCalvin Johnson u32 pmem_base_addr; /* PE's pmem base address */ 116cf4c3448SCalvin Johnson u32 pmem_size; /* PE's pmem size */ 117cf4c3448SCalvin Johnson 118cf4c3448SCalvin Johnson void *mem_access_wdata; /* PE's _MEM_ACCESS_WDATA 119cf4c3448SCalvin Johnson * register address 120cf4c3448SCalvin Johnson */ 121cf4c3448SCalvin Johnson void *mem_access_addr; /* PE's _MEM_ACCESS_ADDR 122cf4c3448SCalvin Johnson * register address 123cf4c3448SCalvin Johnson */ 124cf4c3448SCalvin Johnson void *mem_access_rdata; /* PE's _MEM_ACCESS_RDATA 125cf4c3448SCalvin Johnson * register address 126cf4c3448SCalvin Johnson */ 127cf4c3448SCalvin Johnson }; 128cf4c3448SCalvin Johnson 129cf4c3448SCalvin Johnson void pe_lmem_read(u32 *dst, u32 len, u32 offset); 130cf4c3448SCalvin Johnson void pe_lmem_write(u32 *src, u32 len, u32 offset); 131cf4c3448SCalvin Johnson 132cf4c3448SCalvin Johnson u32 pe_pmem_read(int id, u32 addr, u8 size); 133cf4c3448SCalvin Johnson void pe_dmem_write(int id, u32 val, u32 addr, u8 size); 134cf4c3448SCalvin Johnson u32 pe_dmem_read(int id, u32 addr, u8 size); 135cf4c3448SCalvin Johnson 136cf4c3448SCalvin Johnson int pe_load_elf_section(int id, const void *data, Elf32_Shdr *shdr); 137cf4c3448SCalvin Johnson 138cf4c3448SCalvin Johnson void pfe_lib_init(void); 139cf4c3448SCalvin Johnson 140cf4c3448SCalvin Johnson void bmu_init(void *base, struct bmu_cfg *cfg); 141cf4c3448SCalvin Johnson void bmu_enable(void *base); 142cf4c3448SCalvin Johnson 143cf4c3448SCalvin Johnson void gpi_init(void *base, struct gpi_cfg *cfg); 144cf4c3448SCalvin Johnson void gpi_enable(void *base); 145cf4c3448SCalvin Johnson void gpi_disable(void *base); 146cf4c3448SCalvin Johnson 147cf4c3448SCalvin Johnson void class_init(struct class_cfg *cfg); 148cf4c3448SCalvin Johnson void class_enable(void); 149cf4c3448SCalvin Johnson void class_disable(void); 150cf4c3448SCalvin Johnson 151cf4c3448SCalvin Johnson void tmu_init(struct tmu_cfg *cfg); 152cf4c3448SCalvin Johnson void tmu_enable(u32 pe_mask); 153cf4c3448SCalvin Johnson void tmu_disable(u32 pe_mask); 154cf4c3448SCalvin Johnson 155cf4c3448SCalvin Johnson void hif_init(void); 156cf4c3448SCalvin Johnson void hif_tx_enable(void); 157cf4c3448SCalvin Johnson void hif_tx_disable(void); 158cf4c3448SCalvin Johnson void hif_rx_enable(void); 159cf4c3448SCalvin Johnson void hif_rx_disable(void); 160cf4c3448SCalvin Johnson void hif_rx_desc_disable(void); 161cf4c3448SCalvin Johnson 162cf4c3448SCalvin Johnson #endif /* _PFE_H_ */ 163