1 /* 2 * Copyright 2013 Freescale Semiconductor Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above copyright 9 * notice, this list of conditions and the following disclaimer in the 10 * documentation and/or other materials provided with the distribution. 11 * * Neither the name of Freescale Semiconductor nor the 12 * names of its contributors may be used to endorse or promote products 13 * derived from this software without specific prior written permission. 14 * 15 * 16 * ALTERNATIVELY, this software may be distributed under the terms of the 17 * GNU General Public License ("GPL") as published by the Free Software 18 * Foundation, either version 2 of that License or (at your option) any 19 * later version. 20 * 21 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY 22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY 25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef __FSL_FMAN_SP_H 34 #define __FSL_FMAN_SP_H 35 36 #include "common/general.h" 37 #include "fsl_fman.h" 38 39 40 struct fm_pcd_storage_profile_regs{ 41 uint32_t fm_sp_ebmpi[8]; 42 /*offset 0 - 0xc*/ 43 /**< Buffer Manager pool Information */ 44 45 uint32_t fm_sp_acnt; /*offset 0x20*/ 46 uint32_t fm_sp_ebm; /*offset 0x24*/ 47 uint32_t fm_sp_da; /*offset 0x28*/ 48 uint32_t fm_sp_icp; /*offset 0x2c*/ 49 uint32_t fm_sp_mpd; /*offset 0x30*/ 50 uint32_t res1[2]; /*offset 0x34 - 0x38*/ 51 uint32_t fm_sp_spliodn; /*offset 0x3c*/ 52 }; 53 54 /**************************************************************************//** 55 @Description structure for defining internal context copying 56 *//***************************************************************************/ 57 struct fman_sp_int_context_data_copy{ 58 uint16_t ext_buf_offset; /**< Offset in External buffer to which 59 internal context is copied to (Rx) 60 or taken from (Tx, Op). */ 61 uint8_t int_context_offset; /**< Offset within internal context to copy 62 from (Rx) or to copy to (Tx, Op).*/ 63 uint16_t size; /**< Internal offset size to be copied */ 64 }; 65 66 /**************************************************************************//** 67 @Description struct for defining external buffer margins 68 *//***************************************************************************/ 69 struct fman_sp_buf_margins{ 70 uint16_t start_margins; /**< Number of bytes to be left at the 71 beginning of the external buffer (must be 72 divisible by 16) */ 73 uint16_t end_margins; /**< number of bytes to be left at the end of 74 the external buffer(must be divisible by 16)*/ 75 }; 76 77 struct fm_storage_profile_params { 78 struct fman_ext_pools fm_ext_pools; 79 struct fman_backup_bm_pools backup_pools; 80 struct fman_sp_int_context_data_copy *int_context; 81 struct fman_sp_buf_margins *buf_margins; 82 enum fman_dma_swap_option dma_swap_data; 83 enum fman_dma_cache_option int_context_cache_attr; 84 enum fman_dma_cache_option header_cache_attr; 85 enum fman_dma_cache_option scatter_gather_cache_attr; 86 bool dma_write_optimize; 87 uint16_t liodn_offset; 88 bool no_scather_gather; 89 struct fman_buf_pool_depletion buf_pool_depletion; 90 }; 91 92 /**************************************************************************//** 93 @Description Registers bit fields 94 *//***************************************************************************/ 95 #define FMAN_SP_EXT_BUF_POOL_EN_COUNTER 0x40000000 96 #define FMAN_SP_EXT_BUF_POOL_VALID 0x80000000 97 #define FMAN_SP_EXT_BUF_POOL_BACKUP 0x20000000 98 #define FMAN_SP_DMA_ATTR_WRITE_OPTIMIZE 0x00100000 99 #define FMAN_SP_SG_DISABLE 0x80000000 100 101 /* shifts */ 102 #define FMAN_SP_EXT_BUF_POOL_ID_SHIFT 16 103 #define FMAN_SP_POOL_DEP_NUM_OF_POOLS_SHIFT 16 104 #define FMAN_SP_EXT_BUF_MARG_START_SHIFT 16 105 #define FMAN_SP_EXT_BUF_MARG_END_SHIFT 0 106 #define FMAN_SP_DMA_ATTR_SWP_SHIFT 30 107 #define FMAN_SP_DMA_ATTR_IC_CACHE_SHIFT 28 108 #define FMAN_SP_DMA_ATTR_HDR_CACHE_SHIFT 26 109 #define FMAN_SP_DMA_ATTR_SG_CACHE_SHIFT 24 110 #define FMAN_SP_IC_TO_EXT_SHIFT 16 111 #define FMAN_SP_IC_FROM_INT_SHIFT 8 112 #define FMAN_SP_IC_SIZE_SHIFT 0 113 114 /**************************************************************************//** 115 @Description defaults 116 *//***************************************************************************/ 117 #define DEFAULT_FMAN_SP_DMA_SWAP_DATA FMAN_DMA_NO_SWP 118 #define DEFAULT_FMAN_SP_DMA_INT_CONTEXT_CACHE_ATTR FMAN_DMA_NO_STASH 119 #define DEFAULT_FMAN_SP_DMA_HEADER_CACHE_ATTR FMAN_DMA_NO_STASH 120 #define DEFAULT_FMAN_SP_DMA_SCATTER_GATHER_CACHE_ATTR FMAN_DMA_NO_STASH 121 #define DEFAULT_FMAN_SP_DMA_WRITE_OPTIMIZE TRUE 122 #define DEFAULT_FMAN_SP_NO_SCATTER_GATHER FALSE 123 124 void fman_vsp_defconfig(struct fm_storage_profile_params *cfg); 125 126 void fman_vsp_init(struct fm_pcd_storage_profile_regs *regs, 127 uint16_t index, struct fm_storage_profile_params *fm_vsp_params, 128 int port_max_num_of_ext_pools, int bm_max_num_of_pools, 129 int max_num_of_pfc_priorities); 130 131 uint32_t fman_vsp_get_statistics(struct fm_pcd_storage_profile_regs *regs, 132 uint16_t index); 133 134 void fman_vsp_set_statistics(struct fm_pcd_storage_profile_regs *regs, 135 uint16_t index, uint32_t value); 136 137 138 #endif /* __FSL_FMAN_SP_H */ 139