source: rtems/bsps/sparc/leon3/net/leon_greth.c @ db94626b

Last change on this file since db94626b was db94626b, checked in by Sebastian Huber <sebastian.huber@…>, on 10/26/20 at 14:09:36

bsp/leon3: Updat due to API changes

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  LEON3 Opencores Ethernet MAC Configuration Information
3 *
4 *  COPYRIGHT (c) 2004.
5 *  Gaisler Research
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.org/license/LICENSE.
10 */
11
12#include <machine/rtems-bsd-kernel-space.h>
13
14#include <bsp.h>
15#include <libchip/greth.h>
16/*#if (GRETH_DEBUG & GRETH_DEBUG_PRINT_REGISTERS)*/
17#include <stdio.h>
18/*#endif*/
19
20/*
21 * Default sizes of transmit and receive descriptor areas
22 */
23#define RDA_COUNT     32
24#define TDA_COUNT     32
25
26greth_configuration_t leon_greth_configuration;
27
28int rtems_leon_greth_driver_attach(
29  struct rtems_bsdnet_ifconfig *config,
30  int attach
31)
32{
33  unsigned int base_addr = 0; /* avoid warnings */
34  unsigned int eth_irq = 0;   /* avoid warnings */
35  struct ambapp_dev *adev;
36  struct ambapp_apb_info *apb;
37
38  /* Scan for MAC AHB slave interface */
39  adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
40                                 VENDOR_GAISLER, GAISLER_ETHMAC,
41                                 ambapp_find_by_idx, NULL);
42  if (adev) {
43    apb = DEV_TO_APB(adev);
44    base_addr = apb->start;
45    eth_irq = apb->common.irq;
46
47    /* clear control register and reset NIC */
48    *(volatile int *) base_addr = 0;
49    *(volatile int *) base_addr = GRETH_CTRL_RST;
50    *(volatile int *) base_addr = 0;
51    leon_greth_configuration.base_address = (void*)base_addr;
52    leon_greth_configuration.vector = eth_irq; /* on LEON vector is IRQ no. */
53    leon_greth_configuration.txd_count = TDA_COUNT;
54    leon_greth_configuration.rxd_count = RDA_COUNT;
55    rtems_greth_driver_attach(config, &leon_greth_configuration);
56  }
57  return 0;
58}
Note: See TracBrowser for help on using the repository browser.