Classes | Macros | Typedefs | Functions | Variables
lw_emac.c File Reference
#include <bsp.h>
#include <kern.h>
#include <config.h>
#include <bfin_dma.h>
#include <string.h>
#include "lw_emac.h"
Include dependency graph for lw_emac.c:

Go to the source code of this file.

Classes

struct  bfin_emac_regs
 
struct  ethernet_data
 

Macros

#define ETH_FRAME_SIZE   0x614
 
#define ETH_RX_BUF_SIZE   2
 
#define ETH_TX_BUF_SIZE   1
 
#define MII_ANAR_100_FD   BIT (8) /* Can do 100BASE-TX full duplex */
 
#define MII_ANAR_10_FD   BIT (6) /* Can do 10BASE-T full duplex */
 
#define MII_BMCR   0x00 /* Basic Mode Control Register */
 
#define MII_BMCR_ANEG_EN   BIT (12)
 
#define MII_BMCR_ANEG_RST   BIT (9)
 
#define MII_BMCR_RST   BIT (15)
 
#define MII_BMSR   0x01 /* Basic Mode Status Register */
 
#define MII_BMSR_ANEGACK   BIT (5)
 
#define MII_BMSR_LINK   BIT (2)
 
#define MII_LPAR   0x05 /* Auto-Negotiation Link Partner Ability Register */
 
#define MII_PHYIDR1   0x02 /* PHY Identifier Register 1 */
 
#define MII_PHYIDR2   0x03 /* PHY Identifier Register 2 */
 
#define PHY_ADDR   0
 
#define PHY_MDC_Hz   2500000
 
#define PHY_RETRIES   3000
 

Typedefs

typedef struct bfin_emac_regs bfin_emac_regs_t
 
typedef struct ethernet_data ethernet_data_t
 

Functions

static ethernet_data_t rxBuffer[ETH_RX_BUF_SIZE__attribute__ ((section(".dma")))
 
int bfin_EMAC_init (uint8_t *ethAddr)
 
int bfin_EMAC_recv (uint8_t *packet, size_t size)
 
int bfin_EMAC_send (void *packet, int length)
 
 COMPILETIME_ASSERT (offsetof(bfin_emac_regs_t, mmc_ctl)==0x80)
 
 COMPILETIME_ASSERT (offsetof(bfin_emac_regs_t, mmc_rxc_dmaovf)==0x110)
 
 COMPILETIME_ASSERT (offsetof(bfin_emac_regs_t, mmc_rxc_ge1024)==0x15c)
 
 COMPILETIME_ASSERT (offsetof(bfin_emac_regs_t, mmc_rxc_ok)==0x100)
 
 COMPILETIME_ASSERT (offsetof(bfin_emac_regs_t, mmc_tirqe)==0x90)
 
 COMPILETIME_ASSERT (offsetof(bfin_emac_regs_t, opmode)==0x0)
 
 COMPILETIME_ASSERT (offsetof(bfin_emac_regs_t, rx_stat)==0x68)
 
 COMPILETIME_ASSERT (offsetof(bfin_emac_regs_t, staadd)==0x14)
 
 COMPILETIME_ASSERT (offsetof(bfin_emac_regs_t, sysctl)==0x60)
 
 COMPILETIME_ASSERT (offsetof(bfin_emac_regs_t, wkup_ctl)==0x2c)
 
 COMPILETIME_ASSERT (offsetof(bfin_emac_regs_t, wkup_ffcrc1)==0x4c)
 
 COMPILETIME_ASSERT (sizeof(ethernet_data_t)==0x618)
 
static uint8_t lw_emac_init_registers (uint8_t *ethAddr)
 
static uint32_t lw_emac_read_phy_reg (uint8_t phy_addr, uint8_t reg_addr)
 
static void lw_emac_set_mac_addr (uint8_t *ethAddr)
 
static void lw_emac_write_phy_reg (uint8_t phy_addr, uint8_t reg_addr, uint32_t data)
 

Variables

static volatile bfin_emac_regs_tpEth = (bfin_emac_regs_t *) EMAC_OPMODE
 
static uint8_t rxIdx
 
static uint8_t txIdx
 

Macro Definition Documentation

◆ ETH_FRAME_SIZE

#define ETH_FRAME_SIZE   0x614

Definition at line 66 of file lw_emac.c.

◆ ETH_RX_BUF_SIZE

#define ETH_RX_BUF_SIZE   2

Definition at line 64 of file lw_emac.c.

◆ ETH_TX_BUF_SIZE

#define ETH_TX_BUF_SIZE   1

Definition at line 65 of file lw_emac.c.

◆ MII_ANAR_100_FD

#define MII_ANAR_100_FD   BIT (8) /* Can do 100BASE-TX full duplex */

Definition at line 52 of file lw_emac.c.

◆ MII_ANAR_10_FD

#define MII_ANAR_10_FD   BIT (6) /* Can do 10BASE-T full duplex */

Definition at line 53 of file lw_emac.c.

◆ MII_BMCR

#define MII_BMCR   0x00 /* Basic Mode Control Register */

Definition at line 36 of file lw_emac.c.

◆ MII_BMCR_ANEG_EN

#define MII_BMCR_ANEG_EN   BIT (12)

Definition at line 44 of file lw_emac.c.

◆ MII_BMCR_ANEG_RST

#define MII_BMCR_ANEG_RST   BIT (9)

Definition at line 45 of file lw_emac.c.

◆ MII_BMCR_RST

#define MII_BMCR_RST   BIT (15)

Definition at line 43 of file lw_emac.c.

◆ MII_BMSR

#define MII_BMSR   0x01 /* Basic Mode Status Register */

Definition at line 37 of file lw_emac.c.

◆ MII_BMSR_ANEGACK

#define MII_BMSR_ANEGACK   BIT (5)

Definition at line 48 of file lw_emac.c.

◆ MII_BMSR_LINK

#define MII_BMSR_LINK   BIT (2)

Definition at line 49 of file lw_emac.c.

◆ MII_LPAR

#define MII_LPAR   0x05 /* Auto-Negotiation Link Partner Ability Register */

Definition at line 40 of file lw_emac.c.

◆ MII_PHYIDR1

#define MII_PHYIDR1   0x02 /* PHY Identifier Register 1 */

Definition at line 38 of file lw_emac.c.

◆ MII_PHYIDR2

#define MII_PHYIDR2   0x03 /* PHY Identifier Register 2 */

Definition at line 39 of file lw_emac.c.

◆ PHY_ADDR

#define PHY_ADDR   0

Definition at line 62 of file lw_emac.c.

◆ PHY_MDC_Hz

#define PHY_MDC_Hz   2500000

Definition at line 59 of file lw_emac.c.

◆ PHY_RETRIES

#define PHY_RETRIES   3000

Definition at line 60 of file lw_emac.c.

Typedef Documentation

◆ bfin_emac_regs_t

◆ ethernet_data_t

Function Documentation

◆ __attribute__()

static ethernet_data_t rxBuffer [ETH_RX_BUF_SIZE] __attribute__ ( (section(".dma"))  )
static

◆ bfin_EMAC_init()

int bfin_EMAC_init ( uint8_t ethAddr)

Definition at line 288 of file lw_emac.c.

◆ bfin_EMAC_recv()

int bfin_EMAC_recv ( uint8_t packet,
size_t  size 
)

Definition at line 384 of file lw_emac.c.

◆ bfin_EMAC_send()

int bfin_EMAC_send ( void *  packet,
int  length 
)

Definition at line 354 of file lw_emac.c.

◆ COMPILETIME_ASSERT() [1/12]

COMPILETIME_ASSERT ( offsetof(bfin_emac_regs_t, mmc_ctl)  = =0x80)

◆ COMPILETIME_ASSERT() [2/12]

COMPILETIME_ASSERT ( offsetof(bfin_emac_regs_t, mmc_rxc_dmaovf)  = =0x110)

◆ COMPILETIME_ASSERT() [3/12]

COMPILETIME_ASSERT ( offsetof(bfin_emac_regs_t, mmc_rxc_ge1024)  = =0x15c)

◆ COMPILETIME_ASSERT() [4/12]

COMPILETIME_ASSERT ( offsetof(bfin_emac_regs_t, mmc_rxc_ok)  = =0x100)

◆ COMPILETIME_ASSERT() [5/12]

COMPILETIME_ASSERT ( offsetof(bfin_emac_regs_t, mmc_tirqe)  = =0x90)

◆ COMPILETIME_ASSERT() [6/12]

COMPILETIME_ASSERT ( offsetof(bfin_emac_regs_t, opmode)  = =0x0)

◆ COMPILETIME_ASSERT() [7/12]

COMPILETIME_ASSERT ( offsetof(bfin_emac_regs_t, rx_stat)  = =0x68)

◆ COMPILETIME_ASSERT() [8/12]

COMPILETIME_ASSERT ( offsetof(bfin_emac_regs_t, staadd)  = =0x14)

◆ COMPILETIME_ASSERT() [9/12]

COMPILETIME_ASSERT ( offsetof(bfin_emac_regs_t, sysctl)  = =0x60)

◆ COMPILETIME_ASSERT() [10/12]

COMPILETIME_ASSERT ( offsetof(bfin_emac_regs_t, wkup_ctl)  = =0x2c)

◆ COMPILETIME_ASSERT() [11/12]

COMPILETIME_ASSERT ( offsetof(bfin_emac_regs_t, wkup_ffcrc1)  = =0x4c)

◆ COMPILETIME_ASSERT() [12/12]

COMPILETIME_ASSERT ( sizeof(ethernet_data_t = =0x618)

◆ lw_emac_init_registers()

static uint8_t lw_emac_init_registers ( uint8_t ethAddr)
static

Definition at line 202 of file lw_emac.c.

◆ lw_emac_read_phy_reg()

static uint32_t lw_emac_read_phy_reg ( uint8_t  phy_addr,
uint8_t  reg_addr 
)
static

Definition at line 182 of file lw_emac.c.

◆ lw_emac_set_mac_addr()

static void lw_emac_set_mac_addr ( uint8_t ethAddr)
static

Definition at line 190 of file lw_emac.c.

◆ lw_emac_write_phy_reg()

static void lw_emac_write_phy_reg ( uint8_t  phy_addr,
uint8_t  reg_addr,
uint32_t  data 
)
static

Definition at line 172 of file lw_emac.c.

Variable Documentation

◆ pEth

volatile bfin_emac_regs_t* pEth = (bfin_emac_regs_t *) EMAC_OPMODE
static

Definition at line 157 of file lw_emac.c.

◆ rxIdx

uint8_t rxIdx
static

Definition at line 168 of file lw_emac.c.

◆ txIdx

uint8_t txIdx
static

Definition at line 168 of file lw_emac.c.



soem
Author(s): Arthur Ketels and M.J.G. van den Molengraft
autogenerated on Wed Mar 2 2022 01:01:49