Documentation ¶
Overview ¶
Package enet implements a driver for NXP Ethernet controllers adopting the following reference specifications:
- IMX6ULLRM - i.MX 6ULL Applications Processor Reference Manual - Rev 1 2017/11
This package is only meant to be used with `GOOS=tamago GOARCH=arm` as supported by the TamaGo framework for bare metal Go on ARM SoCs, see https://github.com/usbarmory/tamago.
Index ¶
- Constants
- type ENET
- func (hw *ENET) ClearInterrupt(event int)
- func (hw *ENET) EnableInterrupt(event int)
- func (hw *ENET) Init()
- func (hw *ENET) MDIO22(op, pa, ra int, data uint16) (frame uint32)
- func (hw *ENET) MDIO45(op, prtad, devad int, data uint16) (frame uint32)
- func (hw *ENET) ReadPHYRegister(pa int, ra int) (data uint16)
- func (hw *ENET) Rx() (buf []byte)
- func (hw *ENET) SetMAC(mac net.HardwareAddr)
- func (hw *ENET) Start(rx bool)
- func (hw *ENET) Tx(buf []byte)
- func (hw *ENET) WritePHYRegister(pa int, ra int, data uint16)
- type Stats
Constants ¶
const ( BD_ST_W = 13 // Wrap BD_ST_L = 11 // Last )
Common buffer descriptor fields
const ( BD_RX_ST_E = 15 // Empty BD_RX_ST_LG = 5 // Frame length violation BD_RX_ST_NO = 4 // Non-octet aligned frame BD_RX_ST_CR = 2 // CRC or frame error BD_RX_ST_OV = 1 // Overrun BD_RX_ST_TR = 0 // Frame truncated )
p1014, Table 22-35. Receive buffer descriptor field definitions, IMX6ULLRM
const ( BD_TX_ST_R = 15 // Ready BD_TX_ST_TC = 10 // Transmit CRC )
p1017, Table 22-37. Enhanced transmit buffer descriptor field definitions, IMX6ULLRM
const ( ENETx_EIR = 0x0004 ENETx_EIMR = 0x0008 ENETx_RDAR = 0x0010 RDAR_ACTIVE = 24 ENETx_TDAR = 0x0014 TDAR_ACTIVE = 24 ENETx_ECR = 0x0024 ECR_DBSWP = 8 ECR_EN1588 = 5 ECR_ETHEREN = 1 ECR_RESET = 0 ENETx_MMFR = 0x0040 MMFR_ST = 30 MMFR_OP = 28 MMFR_PA = 23 MMFR_RA = 18 MMFR_TA = 16 MMFR_DATA = 0 ENETx_MSCR = 0x0044 MSCR_HOLDTIME = 8 MSCR_MII_SPEED = 1 ENETx_MIB = 0x0064 MIB_DIS = 31 ENETx_RCR = 0x0084 RCR_MAX_FL = 16 RCR_RMII_MODE = 8 RCR_FCE = 5 RCR_MII_MODE = 2 RCR_LOOP = 0 ENETx_TCR = 0x00c4 TCR_FDEN = 2 ENETx_PALR = 0x00e4 ENETx_PAUR = 0x00e8 ENETx_RDSR = 0x0180 ENETx_TDSR = 0x0184 ENETx_MRBR = 0x0188 ENETx_FTRL = 0x01b0 ENETx_RACC = 0x01c4 RACC_LINEDIS = 6 )
ENET registers
const ( IRQ_BABR = 30 IRQ_BABT = 29 IRQ_GRA = 28 IRQ_TXF = 27 IRQ_TXB = 26 IRQ_RXF = 25 IRQ_RXB = 24 IRQ_MII = 23 IRQ_EBERR = 22 IRQ_LC = 21 IRQ_RL = 20 IRQ_UN = 19 IRQ_PLR = 18 IRQ_WAKEUP = 17 IRQ_TS_AVAIL = 16 IRQ_TS_TIMER = 15 )
ENET interrupt events
const ( // IEEE 802.3-2008 Clause 22 MDIO_ST = 0b01 MDIO_OP_READ = 0b10 MDIO_OP_WRITE = 0b01 MDIO_TA = 0b10 // IEEE 802.3-2008 Clause 45 MDIO_45_ST = 0b00 MDIO_45_OP_ADDR = 0b00 MDIO_45_OP_WRITE = 0b01 MDIO_45_OP_READ_INC = 0b10 MDIO_45_OP_READ = 0b11 MDIO_45_TA = 0b10 )
const (
MTU = 1518
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ENET ¶
type ENET struct { sync.Mutex // Controller index Index int // Base register Base uint32 // Clock gate register CCGR uint32 // Clock gate CG int // Clock retrieval function Clock func() uint32 // Interrupt ID IRQ int // PLL enable function EnablePLL func(index int) error // PHY enable function EnablePHY func(eth *ENET) error // RMII mode RMII bool // MAC address (use SetMAC() for post Init() changes) MAC net.HardwareAddr // Incoming packet handler RxHandler func([]byte) // Descriptor ring size RingSize int // Discard MAC layer errors DiscardErrors bool // Statistics about the MAC Stats Stats // contains filtered or unexported fields }
ENET represents an Ethernet MAC instance.
func (*ENET) ClearInterrupt ¶
ClearInterrupt clears the interrupt corresponding to a specific event.
func (*ENET) EnableInterrupt ¶
EnableInterrupt enables interrupt generation for a specific event.
func (*ENET) Init ¶
func (hw *ENET) Init()
Init initializes and enables the Ethernet MAC controller for 100 Mbps full duplex operation with Auto-Negotiation enabled.
func (*ENET) MDIO22 ¶
MDIO22 transmits an MII frame (IEEE 802.3-2008 Clause 22) to a connected Ethernet PHY, the transacted frame is returned.
func (*ENET) MDIO45 ¶
MDIO45 transmits an MII frame (IEEE 802.3-2008 Clause 45) to a connected Ethernet PHY, the transacted frame is returned.
func (*ENET) ReadPHYRegister ¶
ReadPHYRegister reads a standard management register of a connected Ethernet PHY (IEE 802.3-2008 Clause 22).
func (*ENET) Rx ¶
Rx receives a single Ethernet frame, excluding the checksum, from the MAC controller ring buffer.
func (*ENET) SetMAC ¶
func (hw *ENET) SetMAC(mac net.HardwareAddr)
SetMAC allows to change the controller physical address register after initialization.
func (*ENET) Start ¶
Start begins processing of incoming packets. When the argument is true the function waits and handles received packets (see Rx()) through RxHandler() (when set), it should never return.