source: rtems/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c @ 1c554014

4.115
Last change on this file since 1c554014 was 1c554014, checked in by Ralf Corsépius <ralf.corsepius@…>, on 07/19/12 at 14:14:53

Remove CVS-Ids.

  • Property mode set to 100644
File size: 1.6 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.com/license/LICENSE.
10 */
11
12
13#include <bsp.h>
14#include <libchip/greth.h>
15/*#if (GRETH_DEBUG & GRETH_DEBUG_PRINT_REGISTERS)*/
16#include <stdio.h>
17/*#endif*/
18
19/*
20 * Default sizes of transmit and receive descriptor areas
21 */
22#define RDA_COUNT     32
23#define TDA_COUNT     32
24
25greth_configuration_t leon_greth_configuration;
26
27int rtems_leon_greth_driver_attach(
28  struct rtems_bsdnet_ifconfig *config,
29  int attach
30)
31{
32  unsigned int base_addr = 0; /* avoid warnings */
33  unsigned int eth_irq = 0;   /* avoid warnings */
34  struct ambapp_dev *adev;
35  struct ambapp_apb_info *apb;
36
37  /* Scan for MAC AHB slave interface */
38  adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
39                                 VENDOR_GAISLER, GAISLER_ETHMAC,
40                                 ambapp_find_by_idx, NULL);
41  if (adev) {
42    apb = DEV_TO_APB(adev);
43    base_addr = apb->start;
44    eth_irq = apb->irq;
45
46    /* clear control register and reset NIC */
47    *(volatile int *) base_addr = 0;
48    *(volatile int *) base_addr = GRETH_CTRL_RST;
49    *(volatile int *) base_addr = 0;
50    leon_greth_configuration.base_address = base_addr;
51    leon_greth_configuration.vector = eth_irq; /* on LEON vector is IRQ no. */
52    leon_greth_configuration.txd_count = TDA_COUNT;
53    leon_greth_configuration.rxd_count = RDA_COUNT;
54    rtems_greth_driver_attach(config, &leon_greth_configuration);
55  }
56  return 0;
57}
Note: See TracBrowser for help on using the repository browser.