diff options
author | Vijay Kumar Banerjee <vijay@rtems.org> | 2021-02-16 16:41:54 -0700 |
---|---|---|
committer | Vijay Kumar Banerjee <vijay@rtems.org> | 2021-03-02 14:32:11 -0700 |
commit | 22f3e3c64addcefee992eed572d758a6eab2313b (patch) | |
tree | 8a3f58d7ac48836a0e5d127e5fdff6f2a196d3fa /bsps/riscv | |
parent | Add libmisc and librpc from RTEMS cpukit (diff) | |
download | rtems-net-legacy-22f3e3c64addcefee992eed572d758a6eab2313b.tar.bz2 |
Add support for building bsp specific net drivers
Diffstat (limited to 'bsps/riscv')
-rw-r--r-- | bsps/riscv/griscv/net/griscv_greth.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/bsps/riscv/griscv/net/griscv_greth.c b/bsps/riscv/griscv/net/griscv_greth.c new file mode 100644 index 0000000..e5c05fd --- /dev/null +++ b/bsps/riscv/griscv/net/griscv_greth.c @@ -0,0 +1,59 @@ +/* + * LEON3 Opencores Ethernet MAC Configuration Information + * + * COPYRIGHT (c) 2004. + * Gaisler Research + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#include <machine/rtems-bsd-kernel-space.h> +#include <bsp.h> +#include <amba.h> +#include <grlib/ambapp.h> +#include <libchip/greth.h> +/*#if (GRETH_DEBUG & GRETH_DEBUG_PRINT_REGISTERS)*/ +#include <stdio.h> +/*#endif*/ + +/* + * Default sizes of transmit and receive descriptor areas + */ +#define RDA_COUNT 32 +#define TDA_COUNT 32 + +greth_configuration_t griscv_greth_configuration; + +int rtems_griscv_greth_driver_attach( + struct rtems_bsdnet_ifconfig *config, + int attach +) +{ + unsigned int base_addr = 0; /* avoid warnings */ + unsigned int eth_irq = 0; /* avoid warnings */ + struct ambapp_dev *adev; + struct ambapp_apb_info *apb; + + /* Scan for MAC AHB slave interface */ + adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), + VENDOR_GAISLER, GAISLER_ETHMAC, + ambapp_find_by_idx, NULL); + if (adev) { + apb = DEV_TO_APB(adev); + base_addr = apb->start; + eth_irq = apb->common.irq; + + /* clear control register and reset NIC */ + *(volatile int *) base_addr = 0; + *(volatile int *) base_addr = GRETH_CTRL_RST; + *(volatile int *) base_addr = 0; + griscv_greth_configuration.base_address = (void*)base_addr; + griscv_greth_configuration.vector = eth_irq; /* on LEON vector is IRQ no. */ + griscv_greth_configuration.txd_count = TDA_COUNT; + griscv_greth_configuration.rxd_count = RDA_COUNT; + rtems_greth_driver_attach(config, &griscv_greth_configuration); + } + return 0; +} |