iPXE
Data Structures | Macros | Functions
cgem.h File Reference

Cadence Gigabit Ethernet MAC (GEM) network driver. More...

#include <ipxe/if_ether.h>
#include <ipxe/mii.h>
#include <ipxe/dma.h>
#include <ipxe/retry.h>

Go to the source code of this file.

Data Structures

struct  cgem_descriptor
 A Cadence GEM descriptor. More...
 
union  cgem_mac
 A Cadence GEM MAC address. More...
 
struct  cgem_ring
 A Cadence GEM descriptor ring. More...
 
struct  cgem_nic
 A Cadence GEM network card. More...
 

Macros

#define CGEM_REG_IDX   0
 I/O region index. More...
 
#define CGEM_REG_LEN   0x800
 I/O region length. More...
 
#define CGEM_NWCTRL   0x000
 Network control register. More...
 
#define CGEM_NWCTRL_STARTTX   0x00000200
 Start transmission. More...
 
#define CGEM_NWCTRL_STATCLR   0x00000020
 Clear statistics. More...
 
#define CGEM_NWCTRL_MDEN   0x00000010
 MII interface enable. More...
 
#define CGEM_NWCTRL_TXEN   0x00000008
 Transmit enable. More...
 
#define CGEM_NWCTRL_RXEN   0x00000004
 Receive enable. More...
 
#define CGEM_NWCTRL_NORMAL   ( CGEM_NWCTRL_MDEN | CGEM_NWCTRL_TXEN | CGEM_NWCTRL_RXEN )
 Normal value for network control register while up and running. More...
 
#define CGEM_NWCFG   0x004
 Network configuration register. More...
 
#define CGEM_NWSR   0x008
 Network status register. More...
 
#define CGEM_NWSR_MII_IDLE   0x00000004
 MII interface is idle. More...
 
#define CGEM_DMACR   0x010
 DMA configuration register. More...
 
#define CGEM_DMACR_RXBUF(x)   ( ( (x) / 64 ) << 16 )
 RX buffer size. More...
 
#define CGEM_DMACR_TXSIZE(x)   ( (x) << 10 )
 TX memory size. More...
 
#define CGEM_DMACR_TXSIZE_MAX   CGEM_DMACR_TXSIZE ( 0x1 )
 Max TX memory size. More...
 
#define CGEM_DMACR_RXSIZE(x)   ( (x) << 8 )
 RX memory size. More...
 
#define CGEM_DMACR_RXSIZE_MAX   CGEM_DMACR_RXSIZE ( 0x3 )
 Max RX memory size. More...
 
#define CGEM_DMACR_BLENGTH(x)   ( (x) << 0 )
 DMA burst length. More...
 
#define CGEM_DMACR_BLENGTH_MAX   CGEM_DMACR_BLENGTH ( 0x10 )
 Max DMA burst length. More...
 
#define CGEM_RXQBASE   0x018
 RX queue base address register. More...
 
#define CGEM_TXQBASE   0x01c
 TX queue base address register. More...
 
#define CGEM_IDR   0x02c
 Interrupt disable register. More...
 
#define CGEM_IDR_ALL   0xffffffff
 Disable all interrupts. More...
 
#define CGEM_PHYMNTNC   0x034
 PHY maintenance register. More...
 
#define CGEM_PHYMNTNC_CLAUSE22   0x40000000
 Clause 22 operation. More...
 
#define CGEM_PHYMNTNC_OP_WRITE   0x10000000
 Write to PHY register. More...
 
#define CGEM_PHYMNTNC_OP_READ   0x20000000
 Read from PHY register. More...
 
#define CGEM_PHYMNTNC_ADDR(x)   ( (x) << 23 )
 PHY address. More...
 
#define CGEM_PHYMNTNC_REG(x)   ( (x) << 18 )
 Register address. More...
 
#define CGEM_PHYMNTNC_FIXED   0x00020000
 Fixed value to write. More...
 
#define CGEM_PHYMNTNC_DATA_MASK   0x0000ffff
 Data mask. More...
 
#define CGEM_MII_MAX_WAIT_US   500
 Maximum time to wait for PHY access, in microseconds. More...
 
#define CGEM_LINK_INTERVAL   ( 2 * TICKS_PER_SEC )
 Link state check interval. More...
 
#define CGEM_LADDRL   0x088
 Local MAC address (low half) register. More...
 
#define CGEM_LADDRH   0x08c
 Local MAC address (high half) register. More...
 
#define CGEM_TX_FL_OWNED   0x80000000
 Transmit flags. More...
 
#define CGEM_TX_FL_WRAP   0x40000000
 End of descriptor ring. More...
 
#define CGEM_TX_FL_LAST   0x00008000
 Last buffer in frame. More...
 
#define CGEM_NUM_TX_DESC   8
 Transmit ring length. More...
 
#define CGEM_RX_ADDR_OWNED   0x00000001
 Receive flags (in buffer address) More...
 
#define CGEM_RX_ADDR_WRAP   0x00000002
 End of descriptor ring. More...
 
#define CGEM_RX_FL_LEN(x)   ( (x) & 0x1fff )
 Receive flags. More...
 
#define CGEM_NUM_RX_DESC   8
 Receive ring length. More...
 
#define CGEM_RX_LEN   1536
 Length of receive buffers. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void cgem_init_ring (struct cgem_ring *ring, unsigned int count, unsigned int qbase)
 Initialise descriptor ring. More...
 

Detailed Description

Cadence Gigabit Ethernet MAC (GEM) network driver.

Definition in file cgem.h.

Macro Definition Documentation

◆ CGEM_REG_IDX

#define CGEM_REG_IDX   0

I/O region index.

Definition at line 18 of file cgem.h.

◆ CGEM_REG_LEN

#define CGEM_REG_LEN   0x800

I/O region length.

Definition at line 21 of file cgem.h.

◆ CGEM_NWCTRL

#define CGEM_NWCTRL   0x000

Network control register.

Definition at line 24 of file cgem.h.

◆ CGEM_NWCTRL_STARTTX

#define CGEM_NWCTRL_STARTTX   0x00000200

Start transmission.

Definition at line 25 of file cgem.h.

◆ CGEM_NWCTRL_STATCLR

#define CGEM_NWCTRL_STATCLR   0x00000020

Clear statistics.

Definition at line 26 of file cgem.h.

◆ CGEM_NWCTRL_MDEN

#define CGEM_NWCTRL_MDEN   0x00000010

MII interface enable.

Definition at line 27 of file cgem.h.

◆ CGEM_NWCTRL_TXEN

#define CGEM_NWCTRL_TXEN   0x00000008

Transmit enable.

Definition at line 28 of file cgem.h.

◆ CGEM_NWCTRL_RXEN

#define CGEM_NWCTRL_RXEN   0x00000004

Receive enable.

Definition at line 29 of file cgem.h.

◆ CGEM_NWCTRL_NORMAL

#define CGEM_NWCTRL_NORMAL   ( CGEM_NWCTRL_MDEN | CGEM_NWCTRL_TXEN | CGEM_NWCTRL_RXEN )

Normal value for network control register while up and running.

Definition at line 32 of file cgem.h.

◆ CGEM_NWCFG

#define CGEM_NWCFG   0x004

Network configuration register.

Definition at line 36 of file cgem.h.

◆ CGEM_NWSR

#define CGEM_NWSR   0x008

Network status register.

Definition at line 39 of file cgem.h.

◆ CGEM_NWSR_MII_IDLE

#define CGEM_NWSR_MII_IDLE   0x00000004

MII interface is idle.

Definition at line 40 of file cgem.h.

◆ CGEM_DMACR

#define CGEM_DMACR   0x010

DMA configuration register.

Definition at line 43 of file cgem.h.

◆ CGEM_DMACR_RXBUF

#define CGEM_DMACR_RXBUF (   x)    ( ( (x) / 64 ) << 16 )

RX buffer size.

Definition at line 44 of file cgem.h.

◆ CGEM_DMACR_TXSIZE

#define CGEM_DMACR_TXSIZE (   x)    ( (x) << 10 )

TX memory size.

Definition at line 45 of file cgem.h.

◆ CGEM_DMACR_TXSIZE_MAX

#define CGEM_DMACR_TXSIZE_MAX   CGEM_DMACR_TXSIZE ( 0x1 )

Max TX memory size.

Definition at line 46 of file cgem.h.

◆ CGEM_DMACR_RXSIZE

#define CGEM_DMACR_RXSIZE (   x)    ( (x) << 8 )

RX memory size.

Definition at line 48 of file cgem.h.

◆ CGEM_DMACR_RXSIZE_MAX

#define CGEM_DMACR_RXSIZE_MAX   CGEM_DMACR_RXSIZE ( 0x3 )

Max RX memory size.

Definition at line 49 of file cgem.h.

◆ CGEM_DMACR_BLENGTH

#define CGEM_DMACR_BLENGTH (   x)    ( (x) << 0 )

DMA burst length.

Definition at line 51 of file cgem.h.

◆ CGEM_DMACR_BLENGTH_MAX

#define CGEM_DMACR_BLENGTH_MAX   CGEM_DMACR_BLENGTH ( 0x10 )

Max DMA burst length.

Definition at line 52 of file cgem.h.

◆ CGEM_RXQBASE

#define CGEM_RXQBASE   0x018

RX queue base address register.

Definition at line 56 of file cgem.h.

◆ CGEM_TXQBASE

#define CGEM_TXQBASE   0x01c

TX queue base address register.

Definition at line 59 of file cgem.h.

◆ CGEM_IDR

#define CGEM_IDR   0x02c

Interrupt disable register.

Definition at line 62 of file cgem.h.

◆ CGEM_IDR_ALL

#define CGEM_IDR_ALL   0xffffffff

Disable all interrupts.

Definition at line 63 of file cgem.h.

◆ CGEM_PHYMNTNC

#define CGEM_PHYMNTNC   0x034

PHY maintenance register.

Definition at line 66 of file cgem.h.

◆ CGEM_PHYMNTNC_CLAUSE22

#define CGEM_PHYMNTNC_CLAUSE22   0x40000000

Clause 22 operation.

Definition at line 67 of file cgem.h.

◆ CGEM_PHYMNTNC_OP_WRITE

#define CGEM_PHYMNTNC_OP_WRITE   0x10000000

Write to PHY register.

Definition at line 68 of file cgem.h.

◆ CGEM_PHYMNTNC_OP_READ

#define CGEM_PHYMNTNC_OP_READ   0x20000000

Read from PHY register.

Definition at line 69 of file cgem.h.

◆ CGEM_PHYMNTNC_ADDR

#define CGEM_PHYMNTNC_ADDR (   x)    ( (x) << 23 )

PHY address.

Definition at line 70 of file cgem.h.

◆ CGEM_PHYMNTNC_REG

#define CGEM_PHYMNTNC_REG (   x)    ( (x) << 18 )

Register address.

Definition at line 71 of file cgem.h.

◆ CGEM_PHYMNTNC_FIXED

#define CGEM_PHYMNTNC_FIXED   0x00020000

Fixed value to write.

Definition at line 72 of file cgem.h.

◆ CGEM_PHYMNTNC_DATA_MASK

#define CGEM_PHYMNTNC_DATA_MASK   0x0000ffff

Data mask.

Definition at line 73 of file cgem.h.

◆ CGEM_MII_MAX_WAIT_US

#define CGEM_MII_MAX_WAIT_US   500

Maximum time to wait for PHY access, in microseconds.

Definition at line 76 of file cgem.h.

◆ CGEM_LINK_INTERVAL

#define CGEM_LINK_INTERVAL   ( 2 * TICKS_PER_SEC )

Link state check interval.

Definition at line 79 of file cgem.h.

◆ CGEM_LADDRL

#define CGEM_LADDRL   0x088

Local MAC address (low half) register.

Definition at line 82 of file cgem.h.

◆ CGEM_LADDRH

#define CGEM_LADDRH   0x08c

Local MAC address (high half) register.

Definition at line 85 of file cgem.h.

◆ CGEM_TX_FL_OWNED

#define CGEM_TX_FL_OWNED   0x80000000

Transmit flags.

Owned by software

Definition at line 96 of file cgem.h.

◆ CGEM_TX_FL_WRAP

#define CGEM_TX_FL_WRAP   0x40000000

End of descriptor ring.

Definition at line 97 of file cgem.h.

◆ CGEM_TX_FL_LAST

#define CGEM_TX_FL_LAST   0x00008000

Last buffer in frame.

Definition at line 98 of file cgem.h.

◆ CGEM_NUM_TX_DESC

#define CGEM_NUM_TX_DESC   8

Transmit ring length.

Definition at line 101 of file cgem.h.

◆ CGEM_RX_ADDR_OWNED

#define CGEM_RX_ADDR_OWNED   0x00000001

Receive flags (in buffer address)

Owned by software

Definition at line 104 of file cgem.h.

◆ CGEM_RX_ADDR_WRAP

#define CGEM_RX_ADDR_WRAP   0x00000002

End of descriptor ring.

Definition at line 105 of file cgem.h.

◆ CGEM_RX_FL_LEN

#define CGEM_RX_FL_LEN (   x)    ( (x) & 0x1fff )

Receive flags.

RX packet length

Definition at line 108 of file cgem.h.

◆ CGEM_NUM_RX_DESC

#define CGEM_NUM_RX_DESC   8

Receive ring length.

Definition at line 111 of file cgem.h.

◆ CGEM_RX_LEN

#define CGEM_RX_LEN   1536

Length of receive buffers.

Must be a multiple of 64.

Definition at line 117 of file cgem.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ cgem_init_ring()

static void cgem_init_ring ( struct cgem_ring ring,
unsigned int  count,
unsigned int  qbase 
)
inlinestatic

Initialise descriptor ring.

Parameters
ringDescriptor ring
countNumber of descriptors
qbaseQueue base address register

Definition at line 155 of file cgem.h.

156  {
157 
158  ring->qbase = qbase;
159  ring->count = count;
160  ring->len = ( count * sizeof ( ring->desc[0] ) );
161 }
struct cgem_descriptor * desc
Descriptors.
Definition: cgem.h:131
uint16_t len
Length of descriptors.
Definition: cgem.h:144
static unsigned int unsigned int qbase
Definition: dwmac.h:225
uint8_t qbase
Queue base address register.
Definition: cgem.h:140
static unsigned int count
Number of entries.
Definition: dwmac.h:225
uint8_t count
Number of descriptors.
Definition: cgem.h:142

References cgem_ring::count, count, cgem_ring::desc, cgem_ring::len, cgem_ring::qbase, and qbase.

Referenced by cgem_probe().