xref: /freebsd/sys/contrib/ncsw/inc/flib/fsl_fman_prs.h (revision 13ea0450a9c8742119d36f3bf8f47accdce46e54)
1 /*
2  * Copyright 2008-2012 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_PRS_H
34 #define __FSL_FMAN_PRS_H
35 
36 #include "common/general.h"
37 
38 #define FM_PCD_EX_PRS_DOUBLE_ECC	0x02000000
39 #define FM_PCD_EX_PRS_SINGLE_ECC	0x01000000
40 
41 #define FM_PCD_PRS_PPSC_ALL_PORTS	0xffff0000
42 #define FM_PCD_PRS_RPIMAC_EN		0x00000001
43 #define FM_PCD_PRS_PORT_IDLE_STS	0xffff0000
44 #define FM_PCD_PRS_SINGLE_ECC		0x00004000
45 #define FM_PCD_PRS_DOUBLE_ECC		0x00004000
46 #define PRS_MAX_CYCLE_LIMIT		8191
47 
48 #define DEFAULT_MAX_PRS_CYC_LIM		0
49 
50 struct fman_prs_regs {
51 	uint32_t fmpr_rpclim;
52 	uint32_t fmpr_rpimac;
53 	uint32_t pmeec;
54 	uint32_t res00c[5];
55 	uint32_t fmpr_pevr;
56 	uint32_t fmpr_pever;
57 	uint32_t res028;
58 	uint32_t fmpr_perr;
59 	uint32_t fmpr_perer;
60 	uint32_t res034;
61 	uint32_t res038[10];
62 	uint32_t fmpr_ppsc;
63 	uint32_t res064;
64 	uint32_t fmpr_pds;
65 	uint32_t fmpr_l2rrs;
66 	uint32_t fmpr_l3rrs;
67 	uint32_t fmpr_l4rrs;
68 	uint32_t fmpr_srrs;
69 	uint32_t fmpr_l2rres;
70 	uint32_t fmpr_l3rres;
71 	uint32_t fmpr_l4rres;
72 	uint32_t fmpr_srres;
73 	uint32_t fmpr_spcs;
74 	uint32_t fmpr_spscs;
75 	uint32_t fmpr_hxscs;
76 	uint32_t fmpr_mrcs;
77 	uint32_t fmpr_mwcs;
78 	uint32_t fmpr_mrscs;
79 	uint32_t fmpr_mwscs;
80 	uint32_t fmpr_fcscs;
81 };
82 
83 struct fman_prs_cfg {
84 	uint32_t	port_id_stat;
85 	uint16_t	max_prs_cyc_lim;
86 	uint32_t	prs_exceptions;
87 };
88 
89 uint32_t fman_prs_get_err_event(struct fman_prs_regs *regs, uint32_t ev_mask);
90 uint32_t fman_prs_get_err_ev_mask(struct fman_prs_regs *regs);
91 void fman_prs_ack_err_event(struct fman_prs_regs *regs, uint32_t event);
92 uint32_t fman_prs_get_expt_event(struct fman_prs_regs *regs, uint32_t ev_mask);
93 uint32_t fman_prs_get_expt_ev_mask(struct fman_prs_regs *regs);
94 void fman_prs_ack_expt_event(struct fman_prs_regs *regs, uint32_t event);
95 void fman_prs_defconfig(struct fman_prs_cfg *cfg);
96 int fman_prs_init(struct fman_prs_regs *regs, struct fman_prs_cfg *cfg);
97 void fman_prs_enable(struct fman_prs_regs *regs);
98 void fman_prs_disable(struct fman_prs_regs *regs);
99 int fman_prs_is_enabled(struct fman_prs_regs *regs);
100 void fman_prs_set_stst_port_msk(struct fman_prs_regs *regs, uint32_t pid_msk);
101 void fman_prs_set_stst(struct fman_prs_regs *regs, bool enable);
102 #endif /* __FSL_FMAN_PRS_H */
103