/* * EMAC common driver functions * * Copyright (c) 2020 Elvees (support@elvees.com) * Author: Dmitry Evtushenko * */ #ifndef __func_h #define __func_h #include #include #include #include "emac.h" //#define PRINT_ENA //#define USE_REG_ACCESS_BY_FUNC #ifndef USE_REG_ACCESS_BY_FUNC #define MCR(a) *(volatile unsigned*)(a) #define MCA(a) (a) #define _Rd( pe, ofs) \ MCR( pe->eth_regs + (ofs)) #define _Wr( pe, ofs, val) \ MCR( pe->eth_regs + (ofs)) = val #define _Rd_RxDMA( pe, ofs) \ MCR( pe->dma_rx_regs + (ofs)) #define _Wr_RxDMA( pe, ofs, val) \ MCR( pe->dma_rx_regs + (ofs)) = val #define _Rd_TxDMA( pe, ofs) \ MCR( pe->dma_tx_regs + (ofs)) #define _Wr_TxDMA( pe, ofs, val) \ MCR( pe->dma_tx_regs + (ofs)) = val #endif // !USE_REG_ACCESS_BY_FUNC //////////////////// functions: //////////////////// static inline void print_empty( const char *psFmt, ...) {} #ifdef PRINT_ENA #define PRINT pr_info #else //!PRINT_ENA: #define PRINT print_empty #endif //!PRINT_ENA #ifdef USE_REG_ACCESS_BY_FUNC // Функции записи и чтения в регистры EMAC и DMA EMAC: static inline u32 _Rd( mc_emac_t *pe, unsigned ofs) { return __raw_readl( pe->eth_regs + ofs); } static inline void _Wr( mc_emac_t *pe, unsigned ofs, u32 val) { __raw_writel( val, (pe->eth_regs + ofs)); } static inline u32 _Rd_RxDMA( mc_emac_t *pe, unsigned ofs) { return __raw_readl( pe->dma_rx_regs + ofs); } static inline void _Wr_RxDMA( mc_emac_t *pe, unsigned ofs, u32 val) { __raw_writel( val, (pe->dma_rx_regs + ofs)); } static inline u32 _Rd_TxDMA( mc_emac_t *pe, unsigned ofs) { return __raw_readl( pe->dma_tx_regs + ofs); } static inline void _Wr_TxDMA( mc_emac_t *pe, unsigned ofs, u32 val) { __raw_writel( val, (pe->dma_tx_regs + ofs)); } #endif //USE_REG_ACCESS_BY_FUNC #endif //!__func_h