Path: blob/main/sys/contrib/ncsw/Peripherals/FM/Pcd/fman_prs.c
48524 views
/*1* Copyright 2012 Freescale Semiconductor Inc.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions are met:5* * Redistributions of source code must retain the above copyright6* notice, this list of conditions and the following disclaimer.7* * Redistributions in binary form must reproduce the above copyright8* notice, this list of conditions and the following disclaimer in the9* documentation and/or other materials provided with the distribution.10* * Neither the name of Freescale Semiconductor nor the11* names of its contributors may be used to endorse or promote products12* derived from this software without specific prior written permission.13*14*15* ALTERNATIVELY, this software may be distributed under the terms of the16* GNU General Public License ("GPL") as published by the Free Software17* Foundation, either version 2 of that License or (at your option) any18* later version.19*20* THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY21* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED22* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE23* DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY24* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES25* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;26* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND27* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT28* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS29* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.30*/3132#include "fsl_fman_prs.h"3334uint32_t fman_prs_get_err_event(struct fman_prs_regs *regs, uint32_t ev_mask)35{36return ioread32be(®s->fmpr_perr) & ev_mask;37}3839uint32_t fman_prs_get_err_ev_mask(struct fman_prs_regs *regs)40{41return ioread32be(®s->fmpr_perer);42}4344void fman_prs_ack_err_event(struct fman_prs_regs *regs, uint32_t event)45{46iowrite32be(event, ®s->fmpr_perr);47}4849uint32_t fman_prs_get_expt_event(struct fman_prs_regs *regs, uint32_t ev_mask)50{51return ioread32be(®s->fmpr_pevr) & ev_mask;52}5354uint32_t fman_prs_get_expt_ev_mask(struct fman_prs_regs *regs)55{56return ioread32be(®s->fmpr_pever);57}5859void fman_prs_ack_expt_event(struct fman_prs_regs *regs, uint32_t event)60{61iowrite32be(event, ®s->fmpr_pevr);62}6364void fman_prs_defconfig(struct fman_prs_cfg *cfg)65{66cfg->port_id_stat = 0;67cfg->max_prs_cyc_lim = DEFAULT_MAX_PRS_CYC_LIM;68cfg->prs_exceptions = 0x03000000;69}7071int fman_prs_init(struct fman_prs_regs *regs, struct fman_prs_cfg *cfg)72{73uint32_t tmp;7475iowrite32be(cfg->max_prs_cyc_lim, ®s->fmpr_rpclim);76iowrite32be((FM_PCD_PRS_SINGLE_ECC | FM_PCD_PRS_PORT_IDLE_STS),77®s->fmpr_pevr);7879if (cfg->prs_exceptions & FM_PCD_EX_PRS_SINGLE_ECC)80iowrite32be(FM_PCD_PRS_SINGLE_ECC, ®s->fmpr_pever);81else82iowrite32be(0, ®s->fmpr_pever);8384iowrite32be(FM_PCD_PRS_DOUBLE_ECC, ®s->fmpr_perr);8586tmp = 0;87if (cfg->prs_exceptions & FM_PCD_EX_PRS_DOUBLE_ECC)88tmp |= FM_PCD_PRS_DOUBLE_ECC;89iowrite32be(tmp, ®s->fmpr_perer);9091iowrite32be(cfg->port_id_stat, ®s->fmpr_ppsc);9293return 0;94}9596void fman_prs_enable(struct fman_prs_regs *regs)97{98uint32_t tmp;99100tmp = ioread32be(®s->fmpr_rpimac) | FM_PCD_PRS_RPIMAC_EN;101iowrite32be(tmp, ®s->fmpr_rpimac);102}103104void fman_prs_disable(struct fman_prs_regs *regs)105{106uint32_t tmp;107108tmp = ioread32be(®s->fmpr_rpimac) & ~FM_PCD_PRS_RPIMAC_EN;109iowrite32be(tmp, ®s->fmpr_rpimac);110}111112int fman_prs_is_enabled(struct fman_prs_regs *regs)113{114return ioread32be(®s->fmpr_rpimac) & FM_PCD_PRS_RPIMAC_EN;115}116117void fman_prs_set_stst_port_msk(struct fman_prs_regs *regs, uint32_t pid_msk)118{119iowrite32be(pid_msk, ®s->fmpr_ppsc);120}121122void fman_prs_set_stst(struct fman_prs_regs *regs, bool enable)123{124if (enable)125iowrite32be(FM_PCD_PRS_PPSC_ALL_PORTS, ®s->fmpr_ppsc);126else127iowrite32be(0, ®s->fmpr_ppsc);128}129130131