liteeth: LiteX Ethernet device
Subsystems (2)
Joel Stanley
maintainerPATCH v2 1/1 liteeth: LiteX Ethernet device
LiteX is a soft system-on-chip that targets FPGAs. LiteETH is a basic network device that is commonly used in LiteX designs.
Signed-off-by Joel Stanley <[email protected]>
Reviewed-by Ramon Fried <[email protected]>
---
v2:
Fixed some return values
Add asm/byteorder.h to fix building
v1:
https://lore.kernel.org/r/[email protected]
--- include/linux/litex.h | 84 +++++++++++++++++ drivers/net/liteeth.c | 214 ++++++++++++++++++++++++++++++++++++++++++ drivers/net/Kconfig | 5 + drivers/net/Makefile | 1 + 4 files changed, 304 insertions(+) create mode 100644 include/linux/litex.h create mode 100644 drivers/net/liteeth.c
include/linux/litex.h new file +84 -0
@@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Common LiteX header providing +* helper functions for accessing CSRs. +* +* Copyright (C) 2019-2020 Antmicro <www.antmicro.com> +*/ + +#ifndef _LINUX_LITEX_H +#define _LINUX_LITEX_H + +#include <linux/io.h> +#include <asm/byteorder.h> + +static inline void _write_litex_subregister (u32 val,void __iomem *addr) +{ +writel ((u32 __force )cpu_to_le32 (val), addr); +} + +static inline u32 _read_litex_subregister (void __iomem *addr) +{ +return le32_to_cpu ((__le32 __force )readl (addr)); +} + +/* +* LiteX SoC Generator, depending on the configuration, can split a single +* logical CSR (Control&Status Register) into a series of consecutive physical +* registers. +* +* For example, in the configuration with 8-bit CSR Bus, a 32-bit aligned, +* 32-bit wide logical CSR will be laid out as four 32-bit physical +* subregisters, each one containing one byte of meaningful data. +* +* For Linux support, upstream LiteX enforces a 32-bit wide CSR bus, which +* means that only larger-than-32-bit CSRs will be split across multiple +* subregisters (e.g., a 64-bit CSR will be spread across two consecutive +* 32-bit subregisters). +* +* For details see: https://github.com/enjoy-digital/litex/wiki/CSR-Bus +*/ + +static inline void litex_write8 (void __iomem *reg,u8 val) +{ +_write_litex_subregister (val, reg); +} + +static inline void litex_write16 (void __iomem *reg,u16 val) +{ +_write_litex_subregister (val, reg); +} + +static inline void litex_write32 (void __iomem *reg,u32 val) +{ +_write_litex_subregister (val, reg); +} + +static inline void litex_write64 (void __iomem *reg,u64 val) +{ +_write_litex_subregister (val >>32 , reg); +_write_litex_subregister (val, reg +4 ); +} + +static inline u8 litex_read8 (void __iomem *reg) +{ +return _read_litex_subregister (reg); +} + +static inline u16 litex_read16 (void __iomem *reg) +{ +return _read_litex_subregister (reg); +} + +static inline u32 litex_read32 (void __iomem *reg) +{ +return _read_litex_subregister (reg); +} + +static inline u64 litex_read64 (void __iomem *reg) +{ +return ((u64 )_read_litex_subregister (reg) <<32 ) | +_read_litex_subregister (reg +4 ); +} + +#endif /* _LINUX_LITEX_H */
drivers/net/liteeth.c new file +214 -0
214 lines not on this page · raw message
drivers/net/Kconfig +5 -0
@@ -438,6 +438,11 @@ config KSZ9477 This driver implements a DSA switch driver for the KSZ9477 family of GbE switches using the I2C interface. +config LITEETH + bool "LiteX LiteEth Ethernet MAC" + help + Driver for the LiteEth Ethernet MAC from LiteX. + config MVGBE bool "Marvell Orion5x/Kirkwood network interface support" depends on ARCH_KIRKWOOD || ARCH_ORION5X
drivers/net/Makefile +1 -0
@@ -47,6 +47,7 @@ obj-$(CONFIG_GMAC_ROCKCHIP) += gmac_rockchip.o obj-$(CONFIG_HIGMACV300_ETH) += higmacv300.o obj-$(CONFIG_KS8851_MLL) += ks8851_mll.o obj-$(CONFIG_KSZ9477) += ksz9477.o +obj-$(CONFIG_LITEETH) += liteeth.o obj-$(CONFIG_MACB) += macb.o obj-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o obj-$(CONFIG_MDIO_IPQ4019) += mdio-ipq4019.o
Signature · 1 line
2.35.1
Quoted 5 lines · Joel Stanley
LiteX is a soft system-on-chip that targets FPGAs. LiteETH is a basic network device that is commonly used in LiteX designs.
Signed-off-by Joel Stanley <[email protected]>Reviewed-by Ramon Fried <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom