Embedded Xinu Operating System
An ongoing research project and educational operating system.
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
Files | Functions

Driver for the Microchip LAN7800 Ethernet device. More...

Files

file  lan7800.c
 

Functions

usb_status_t lan7800_wait_device_attached (ushort minor)
 
devcall etherInit (device *devptr)
 
usb_status_t lan7800_write_reg (struct usb_device *udev, uint32_t index, uint32_t data)
 
usb_status_t lan7800_read_reg (struct usb_device *udev, uint32_t index, uint32_t *data)
 
usb_status_t lan7800_modify_reg (struct usb_device *udev, uint32_t index, uint32_t mask, uint32_t set)
 
usb_status_t lan7800_set_reg_bits (struct usb_device *udev, uint32_t index, uint32_t set)
 
usb_status_t lan7800_set_mac_address (struct usb_device *udev, const uint8_t *macaddr)
 
usb_status_t lan7800_get_mac_address (struct usb_device *udev, uint8_t *macaddr)
 
usb_status_t lan7800_mdio_wait_for_bit (struct usb_device *udev, const uint32_t reg, const uint32_t mask, const bool set)
 
usb_status_t lan7800_phy_wait_not_busy (struct usb_device *udev)
 
usb_status_t lan7800_read_raw_eeprom (struct usb_device *udev, uint32_t offset, uint32_t length, uint8_t *data)
 
usb_status_t lan7800_set_rx_max_frame_length (struct usb_device *udev, int size)
 
usb_status_t lan7800_set_features (struct usb_device *udev, uint32_t set)
 
usb_status_t lan7800_init (struct usb_device *udev, uint8_t *macaddress)
 

Detailed Description

Driver for the Microchip LAN7800 Ethernet device.

This module presents a driver implementation for the Raspberry Pi 3 B+ Ethernet device.

Authors
Rade Latinovich Patrick J. McGee

Initialization for the LAN7800 USB Ethernet Adapter

Function Documentation

devcall etherInit ( device *  devptr)

Implementation of etherInit() for lan7800; documentation in ether.h

Parameters
devptrPointer to ethernet device.
Returns
::OK on successful initialization, ::SYSERR otherwise.

LAN7800-specific notes: This function returns ::OK if the Ethernet Driver was successfully registered with the USB core, otherwise ::SYSERR. This is a work-around to use USB's dynamic device model at the same time as Xinu's static device model, and there is no guarantee that the device actually exists when the function returns.

usb_status_t lan7800_get_mac_address ( struct usb_device *  udev,
uint8_t *  macaddr 
)

Reads the MAC address of the MICROCHIP LAN7800 USB Ethernet Adapter.

Parameters
udevUSB device for the adapter
macaddrPointer into which to write the MAC address (6 bytes long)
Returns
::USB_STATUS_SUCCESS on success; otherwise another ::usb_status_t error code.
usb_status_t lan7800_init ( struct usb_device *  udev,
uint8_t *  macaddress 
)

Initialize various functions for the Microchip LAN7800 Ethernet device.

Parameters
udevUSB device for the adapter
macaddressMAC address to be set on the device (obtained from the BCM2837B0 mailbox)
Returns
::USB_STATUS_SUCCESS on success.
usb_status_t lan7800_mdio_wait_for_bit ( struct usb_device *  udev,
const uint32_t  reg,
const uint32_t  mask,
const bool  set 
)

Wait for a bit value to change on the Microchip LAN7800 USB Ethernet Adapter.

Parameters
udevUSB device for the adapter
regRegister to change
maskMask value for register
setValue of register bit to apply
Returns
::USB_STATUS_SUCCESS after value is applied
usb_status_t lan7800_modify_reg ( struct usb_device *  udev,
uint32_t  index,
uint32_t  mask,
uint32_t  set 
)

Modify the value contained in a register on the Microchip LAN7800 USB Ethernet Adapter.

Parameters
udevUSB device for the adapter
indexIndex of the register to modify
maskMask that contains 1 for the bits where the old value in the register will be kept rather than cleared (unless those bits also appear in set, in which case they will still be set).
setMask of bits to set in the register.
Returns
::USB_STATUS_SUCCESS on success; otherwise another ::usb_status_t error code.
usb_status_t lan7800_phy_wait_not_busy ( struct usb_device *  udev)

Waits for PHY to be free.

Parameters
udevUSB device for the adapter
Returns
::USB_STATUS_SUCCESS on success.
usb_status_t lan7800_read_raw_eeprom ( struct usb_device *  udev,
uint32_t  offset,
uint32_t  length,
uint8_t *  data 
)

Read raw EEPROM from the Microchip LAN7800 Ethernet device.

Parameters
udevUSB device for the adapter
Returns
::USB_STATUS_SUCCESS on success.
usb_status_t lan7800_read_reg ( struct usb_device *  udev,
uint32_t  index,
uint32_t *  data 
)

Read from a register on the Microchip LAN7800 USB Ethernet Adapter.

Parameters
udevUSB device for the adapter
indexIndex of the register to read
dataPointer into which to write the register's value
Returns
::USB_STATUS_SUCCESS on success; otherwise another ::usb_status_t error code.
usb_status_t lan7800_set_features ( struct usb_device *  udev,
uint32_t  set 
)

Enable or disable Rx checksum offload engine for the Microchip LAN7800 Ethernet device.

Parameters
udevUSB device for the adapter
setBit (whether to enable or disable)
Returns
::USB_STATUS_SUCCESS on success.
usb_status_t lan7800_set_mac_address ( struct usb_device *  udev,
const uint8_t *  macaddr 
)

Change the MAC address of the Microchip LAN7800 USB Ethernet Adapter on the actual hardware by writing to its registers.

Parameters
udevUSB device for the adapter
macaddrNew MAC address to set (6 bytes long)
Returns
::USB_STATUS_SUCCESS on success; otherwise another ::usb_status_t error code. On failure the existing MAC address may have been partially modified.
usb_status_t lan7800_set_reg_bits ( struct usb_device *  udev,
uint32_t  index,
uint32_t  set 
)

Set bits in a register on the Microchip LAN7800 USB Ethernet Adapter.

Parameters
udevUSB Device for the adapter
indexIndex of the register to modify
setBits to set in the register. At positions where the is a 0, the old value in the register will be written.
Returns
::USB_STATUS_SUCCESS on success; otherwise another ::usb_status_t error code.
usb_status_t lan7800_set_rx_max_frame_length ( struct usb_device *  udev,
int  size 
)

Set max RX frame length for the Microchip LAN7800 Ethernet device.

Parameters
udevUSB device for the adapter
sizeSize of max RX frame
Returns
::USB_STATUS_SUCCESS on success.
usb_status_t lan7800_wait_device_attached ( ushort  minor)

Wait until the specified Ethernet device has been attached. This is necessary because USB is a dynamic bus, but Xinu expects static devices.

Parameters
minorMinor number of the Ethernet device to wait for.
Returns
Currently ::USB_STATUS_SUCCESS.
usb_status_t lan7800_write_reg ( struct usb_device *  udev,
uint32_t  index,
uint32_t  data 
)

Write to a register on the Microchip LAN7800 USB Ethernet Adapter.

Parameters
udevUSB device for the adapter
indexIndex of the register to write
dataValue to write to the register
Returns
::USB_STATUS_SUCCESS on success; otherwise another ::usb_status_t error code.