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