forked from Imagelibrary/rtems
Add networking support for griscv bsp
* Only GRETH device supported for now * Fix endian problem in GRETH driver * Remove SPARC assembly from greth.c * Builds with both autoconf and waf
This commit is contained in:
@@ -64,7 +64,7 @@ static int find_matching_apbuart(struct ambapp_dev *dev, int index, void *arg)
|
||||
|
||||
/* Extract needed information of one APBUART */
|
||||
apbuarts[uarts].regs = (struct apbuart_regs *)apb->start;
|
||||
apbuarts[uarts].irq = apb->irq;
|
||||
apbuarts[uarts].irq = apb->common.irq;
|
||||
/* Get APBUART core frequency, it is assumed that it is the same
|
||||
* as Bus frequency where the UART is situated
|
||||
*/
|
||||
|
||||
@@ -75,6 +75,20 @@ extern void BSP_shared_interrupt_mask(int irq);
|
||||
extern void BSP_shared_interrupt_clear(int irq);
|
||||
extern void BSP_shared_interrupt_unmask(int irq);
|
||||
|
||||
/*
|
||||
* Network driver configuration for greth
|
||||
*/
|
||||
struct rtems_bsdnet_ifconfig;
|
||||
extern int rtems_griscv_greth_driver_attach(
|
||||
struct rtems_bsdnet_ifconfig *config,
|
||||
int attach
|
||||
);
|
||||
|
||||
#define RTEMS_BSP_NETWORK_DRIVER_NAME "gr_eth1"
|
||||
#define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_griscv_greth_driver_attach
|
||||
#define GRETH_SUPPORTED
|
||||
#define CPU_U32_FIX
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
59
bsps/riscv/griscv/net/griscv_greth.c
Normal file
59
bsps/riscv/griscv/net/griscv_greth.c
Normal file
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user