Path: blob/main/sys/contrib/ncsw/Peripherals/FM/MAC/memac.h
48524 views
/*1* Copyright 2008-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*/313233/******************************************************************************34@File memac.h3536@Description FM Multirate Ethernet MAC (mEMAC)37*//***************************************************************************/38#ifndef __MEMAC_H39#define __MEMAC_H4041#include "std_ext.h"42#include "error_ext.h"43#include "list_ext.h"4445#include "fsl_fman_memac_mii_acc.h"46#include "fm_mac.h"47#include "fsl_fman_memac.h"484950#define MEMAC_default_exceptions \51((uint32_t)(MEMAC_IMASK_TSECC_ER | MEMAC_IMASK_TECC_ER | MEMAC_IMASK_RECC_ER | MEMAC_IMASK_MGI))5253#define GET_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \54case e_FM_MAC_EX_10G_1TX_ECC_ER: \55bitMask = MEMAC_IMASK_TECC_ER; break; \56case e_FM_MAC_EX_10G_RX_ECC_ER: \57bitMask = MEMAC_IMASK_RECC_ER; break; \58case e_FM_MAC_EX_TS_FIFO_ECC_ERR: \59bitMask = MEMAC_IMASK_TSECC_ER; break; \60case e_FM_MAC_EX_MAGIC_PACKET_INDICATION: \61bitMask = MEMAC_IMASK_MGI; break; \62default: bitMask = 0;break;}636465typedef struct66{67t_FmMacControllerDriver fmMacControllerDriver; /**< Upper Mac control block */68t_Handle h_App; /**< Handle to the upper layer application */69struct memac_regs *p_MemMap; /**< Pointer to MAC memory mapped registers */70struct memac_mii_access_mem_map *p_MiiMemMap; /**< Pointer to MII memory mapped registers */71uint64_t addr; /**< MAC address of device */72e_EnetMode enetMode; /**< Ethernet physical interface */73t_FmMacExceptionCallback *f_Exception;74int mdioIrq;75t_FmMacExceptionCallback *f_Event;76bool indAddrRegUsed[MEMAC_NUM_OF_PADDRS]; /**< Whether a particular individual address recognition register is being used */77uint64_t paddr[MEMAC_NUM_OF_PADDRS]; /**< MAC address for particular individual address recognition register */78uint8_t numOfIndAddrInRegs; /**< Number of individual addresses in registers for this station. */79t_EthHash *p_MulticastAddrHash; /**< Pointer to driver's global address hash table */80t_EthHash *p_UnicastAddrHash; /**< Pointer to driver's individual address hash table */81bool debugMode;82uint8_t macId;83uint32_t exceptions;84struct memac_cfg *p_MemacDriverParam;85} t_Memac;868788/* Internal PHY access */89#define PHY_MDIO_ADDR 09091/* Internal PHY Registers - SGMII */92#define PHY_SGMII_CR_PHY_RESET 0x800093#define PHY_SGMII_CR_RESET_AN 0x020094#define PHY_SGMII_CR_DEF_VAL 0x114095#define PHY_SGMII_DEV_ABILITY_SGMII 0x400196#define PHY_SGMII_DEV_ABILITY_1000X 0x01A097#define PHY_SGMII_IF_SPEED_GIGABIT 0x000898#define PHY_SGMII_IF_MODE_AN 0x000299#define PHY_SGMII_IF_MODE_SGMII 0x0001100#define PHY_SGMII_IF_MODE_1000X 0x0000101102103#define MEMAC_TO_MII_OFFSET 0x030 /* Offset from the MEM map to the MDIO mem map */104105t_Error MEMAC_MII_WritePhyReg(t_Handle h_Memac, uint8_t phyAddr, uint8_t reg, uint16_t data);106t_Error MEMAC_MII_ReadPhyReg(t_Handle h_Memac, uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);107108109#endif /* __MEMAC_H */110111112