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

4.104.114.84.95
Last change on this file since 4795141 was 4795141, checked in by Joel Sherrill <joel.sherrill@…>, on 07/11/06 at 15:56:58

2006-07-11 Joel Sherrill <joel@…>

  • leon_greth/.cvsignore, leon_greth/leon_greth.c: New files. Missed adding in previous commit of merge.
  • Property mode set to 100644
File size: 1.9 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 *  leon_open_eth.c,v 1.1.2.1 2005/10/05 19:26:00 joel Exp
12 */
13
14
15#include <bsp.h>
16#include <libchip/greth.h>
17/*#if (GRETH_DEBUG & GRETH_DEBUG_PRINT_REGISTERS)*/
18#include <stdio.h>
19/*#endif*/
20
21/*
22 * Default sizes of transmit and receive descriptor areas
23 */
24#define RDA_COUNT     32
25#define TDA_COUNT     32
26
27greth_configuration_t leon_greth_configuration;
28
29int rtems_leon_greth_driver_attach(
30  struct rtems_bsdnet_ifconfig *config,
31  int attach
32)
33{
34  int device_found = 0;
35  int i;
36  unsigned int conf, iobar;
37  unsigned int base_addr = 0; /* avoid warnings */
38  unsigned int eth_irq = 0;   /* avoid warnings */
39
40  /* Scan for MAC AHB slave interface */
41  for (i = 0; i < amba_conf.apbslv.devnr; i++)
42  {
43    conf = amba_get_confword(amba_conf.apbslv, i, 0);
44    if ((amba_vendor(conf) == VENDOR_GAISLER) &&
45        (amba_device(conf) == GAISLER_ETHMAC))
46    {
47      iobar = amba_apb_get_membar(amba_conf.apbslv, i);
48      base_addr = amba_iobar_start(amba_conf.apbmst, iobar);
49      eth_irq = amba_irq(conf) + 0x10;
50      device_found = 1;
51      break;
52    }
53  }
54
55  if (device_found)
56  {
57    /* clear control register and reset NIC */
58    *(volatile int *) base_addr = 0;
59    *(volatile int *) base_addr = GRETH_CTRL_RST;
60    *(volatile int *) base_addr = 0;
61    leon_greth_configuration.base_address = base_addr;
62    leon_greth_configuration.vector = eth_irq;
63    leon_greth_configuration.txd_count = TDA_COUNT;
64    leon_greth_configuration.rxd_count = RDA_COUNT;
65    if (rtems_greth_driver_attach( config, &leon_greth_configuration )) {
66      LEON_Clear_interrupt(leon_greth_configuration.vector);
67      LEON_Unmask_interrupt(leon_greth_configuration.vector);
68    }
69  }
70  return 0;
71}
Note: See TracBrowser for help on using the repository browser.