zephyr/drivers/ethernet/eth_stellaris_priv.h
Vijay Kumar B cffb2d8051 drivers: ethernet: Add TI Stellaris ethernet controller driver.
The driver can be tested using different networking emulation
approaches.

This approach will work across multiple Qemu instances. There can be
more than one Qemu instance, run using the following command. They
would appear to be on the same Ethernet network.

  $ qemu-system-arm -M lm3s6965evb                      \
                    -serial stdio                       \
                    -net nic                            \
                    -net socket,mcast=230.0.0.1:1234    \
                    -kernel zephyr.elf

This approach will work with other virtualization technologies that
support connecting to a VDE switch, like VirtualBox and User Mode
Linux. The switch can be started using the following command.

  $ vde_switch --sock /tmp/switch

Qemu can be connected to the switch using the following command.

  $ qemu-system-arm -M lm3s6965evb                      \
                    -serial stdio                       \
                    -net nic                            \
                    -net vde,sock=/tmp/switch   	\
                    -kernel zephyr.elf

Signed-off-by: Fadhel Habeeb <fadhel@zilogic.com>
Signed-off-by: Nirav Parmar <niravparmar@zilogic.com>
Signed-off-by: Vijay Kumar B <vijaykumar@zilogic.com>
2018-12-04 09:36:51 -06:00

75 lines
2.0 KiB
C

/* STELLARIS Ethernet Controller
*
* Copyright (c) 2018 Zilogic Systems
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ETH_STELLARIS_PRIV_H_
#define ETH_STELLARIS_PRIV_H_
#define ETH_MTU 1500
#define DEV_DATA(dev) \
((struct eth_stellaris_runtime *)(dev)->driver_data)
#define DEV_CFG(dev) \
((struct eth_stellaris_config *const)(dev)->config->config_info)
/*
* Register mapping
*/
/* Registers for ethernet system, mac_base + offset */
#define REG_MACRIS ((DEV_CFG(dev)->mac_base) + 0x000)
#define REG_MACIM ((DEV_CFG(dev)->mac_base) + 0x004)
#define REG_MACRCTL ((DEV_CFG(dev)->mac_base) + 0x008)
#define REG_MACTCTL ((DEV_CFG(dev)->mac_base) + 0x00C)
#define REG_MACDATA ((DEV_CFG(dev)->mac_base) + 0x010)
#define REG_MACIA0 ((DEV_CFG(dev)->mac_base) + 0x014)
#define REG_MACIA1 ((DEV_CFG(dev)->mac_base) + 0x018)
#define REG_MACNP ((DEV_CFG(dev)->mac_base) + 0x034)
#define REG_MACTR ((DEV_CFG(dev)->mac_base) + 0x038)
/* ETH MAC Receive Control bit fields set value */
#define BIT_MACRCTL_RSTFIFO 0x10
#define BIT_MACRCTL_BADCRC 0x8
#define BIT_MACRCTL_RXEN 0x1
#define BIT_MACRCTL_PRMS 0x4
/* ETH MAC Transmit Control bit fields set value */
#define BIT_MACTCTL_DUPLEX 0x10
#define BIT_MACTCTL_CRC 0x4
#define BIT_MACTCTL_PADEN 0x2
#define BIT_MACTCTL_TXEN 0x1
/* ETH MAC Txn req bit fields set value */
#define BIT_MACTR_NEWTX 0x1
/* Ethernet MAC RAW Interrupt Status/Ack bit set values */
#define BIT_MACRIS_RXINT 0x1
#define BIT_MACRIS_TXER 0x2
#define BIT_MACRIS_TXEMP 0x4
#define BIT_MACRIS_FOV 0x8
#define BIT_MACRIS_RXER 0x10
struct eth_stellaris_runtime {
struct net_if *iface;
u8_t mac_addr[6];
struct k_sem tx_sem;
bool tx_err;
u32_t tx_word;
int tx_pos;
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
struct net_stats_eth stats;
#endif
};
typedef void (*eth_stellaris_config_irq_t)(struct device *dev);
struct eth_stellaris_config {
u32_t mac_base;
u32_t sys_ctrl_base;
u32_t irq_num;
eth_stellaris_config_irq_t config_func;
};
#endif /* ETH_STELLARIS_PRIV_H_ */