18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2008 - 2015 Freescale Semiconductor Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
58c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions are met:
68c2ecf20Sopenharmony_ci *     * Redistributions of source code must retain the above copyright
78c2ecf20Sopenharmony_ci *	 notice, this list of conditions and the following disclaimer.
88c2ecf20Sopenharmony_ci *     * Redistributions in binary form must reproduce the above copyright
98c2ecf20Sopenharmony_ci *	 notice, this list of conditions and the following disclaimer in the
108c2ecf20Sopenharmony_ci *	 documentation and/or other materials provided with the distribution.
118c2ecf20Sopenharmony_ci *     * Neither the name of Freescale Semiconductor nor the
128c2ecf20Sopenharmony_ci *	 names of its contributors may be used to endorse or promote products
138c2ecf20Sopenharmony_ci *	 derived from this software without specific prior written permission.
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * ALTERNATIVELY, this software may be distributed under the terms of the
168c2ecf20Sopenharmony_ci * GNU General Public License ("GPL") as published by the Free Software
178c2ecf20Sopenharmony_ci * Foundation, either version 2 of that License or (at your option) any
188c2ecf20Sopenharmony_ci * later version.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
218c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
228c2ecf20Sopenharmony_ci * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
238c2ecf20Sopenharmony_ci * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
248c2ecf20Sopenharmony_ci * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
258c2ecf20Sopenharmony_ci * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
268c2ecf20Sopenharmony_ci * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
278c2ecf20Sopenharmony_ci * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
288c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
298c2ecf20Sopenharmony_ci * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
308c2ecf20Sopenharmony_ci */
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#ifndef __FM_SP_H
338c2ecf20Sopenharmony_ci#define __FM_SP_H
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#include "fman.h"
368c2ecf20Sopenharmony_ci#include <linux/types.h>
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#define ILLEGAL_BASE    (~0)
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* defaults */
418c2ecf20Sopenharmony_ci#define DFLT_FM_SP_BUFFER_PREFIX_CONTEXT_DATA_ALIGN	64
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* Registers bit fields */
448c2ecf20Sopenharmony_ci#define FMAN_SP_EXT_BUF_POOL_EN_COUNTER		0x40000000
458c2ecf20Sopenharmony_ci#define FMAN_SP_EXT_BUF_POOL_VALID			0x80000000
468c2ecf20Sopenharmony_ci#define FMAN_SP_EXT_BUF_POOL_BACKUP			0x20000000
478c2ecf20Sopenharmony_ci#define FMAN_SP_DMA_ATTR_WRITE_OPTIMIZE		0x00100000
488c2ecf20Sopenharmony_ci#define FMAN_SP_SG_DISABLE				0x80000000
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/* shifts */
518c2ecf20Sopenharmony_ci#define FMAN_SP_EXT_BUF_MARG_START_SHIFT		16
528c2ecf20Sopenharmony_ci#define FMAN_SP_DMA_ATTR_SWP_SHIFT			30
538c2ecf20Sopenharmony_ci#define FMAN_SP_IC_TO_EXT_SHIFT			16
548c2ecf20Sopenharmony_ci#define FMAN_SP_IC_FROM_INT_SHIFT			8
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* structure for defining internal context copying */
578c2ecf20Sopenharmony_cistruct fman_sp_int_context_data_copy {
588c2ecf20Sopenharmony_ci	/* < Offset in External buffer to which internal
598c2ecf20Sopenharmony_ci	 *  context is copied to (Rx) or taken from (Tx, Op).
608c2ecf20Sopenharmony_ci	 */
618c2ecf20Sopenharmony_ci	u16 ext_buf_offset;
628c2ecf20Sopenharmony_ci	/* Offset within internal context to copy from
638c2ecf20Sopenharmony_ci	 * (Rx) or to copy to (Tx, Op).
648c2ecf20Sopenharmony_ci	 */
658c2ecf20Sopenharmony_ci	u8 int_context_offset;
668c2ecf20Sopenharmony_ci	/* Internal offset size to be copied */
678c2ecf20Sopenharmony_ci	u16 size;
688c2ecf20Sopenharmony_ci};
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/*  struct for defining external buffer margins */
718c2ecf20Sopenharmony_cistruct fman_sp_buf_margins {
728c2ecf20Sopenharmony_ci	/* Number of bytes to be left at the beginning
738c2ecf20Sopenharmony_ci	 * of the external buffer (must be divisible by 16)
748c2ecf20Sopenharmony_ci	 */
758c2ecf20Sopenharmony_ci	u16 start_margins;
768c2ecf20Sopenharmony_ci	/* number of bytes to be left at the end
778c2ecf20Sopenharmony_ci	 * of the external buffer(must be divisible by 16)
788c2ecf20Sopenharmony_ci	 */
798c2ecf20Sopenharmony_ci	u16 end_margins;
808c2ecf20Sopenharmony_ci};
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_cistruct fman_sp_buffer_offsets {
838c2ecf20Sopenharmony_ci	u32 data_offset;
848c2ecf20Sopenharmony_ci	u32 prs_result_offset;
858c2ecf20Sopenharmony_ci	u32 time_stamp_offset;
868c2ecf20Sopenharmony_ci	u32 hash_result_offset;
878c2ecf20Sopenharmony_ci};
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ciint fman_sp_build_buffer_struct(struct fman_sp_int_context_data_copy
908c2ecf20Sopenharmony_ci				*int_context_data_copy,
918c2ecf20Sopenharmony_ci				struct fman_buffer_prefix_content
928c2ecf20Sopenharmony_ci				*buffer_prefix_content,
938c2ecf20Sopenharmony_ci				struct fman_sp_buf_margins *buf_margins,
948c2ecf20Sopenharmony_ci				struct fman_sp_buffer_offsets
958c2ecf20Sopenharmony_ci				*buffer_offsets,
968c2ecf20Sopenharmony_ci				u8 *internal_buf_offset);
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_civoid fman_sp_set_buf_pools_in_asc_order_of_buf_sizes(struct fman_ext_pools
998c2ecf20Sopenharmony_ci						     *fm_ext_pools,
1008c2ecf20Sopenharmony_ci						     u8 *ordered_array,
1018c2ecf20Sopenharmony_ci						     u16 *sizes_array);
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci#endif	/* __FM_SP_H */
104