source: rtems/c/src/lib/libbsp/sparc/leon3/leon_open_eth/leon_open_eth.c @ b1274bd9

4.104.115
Last change on this file since b1274bd9 was 44b06ca, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/29/09 at 15:33:28

Whitespace removal.

  • Property mode set to 100644
File size: 2.1 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 *  $Id$
12 */
13
14
15#include <bsp.h>
16#include <libchip/open_eth.h>
17#if (OPEN_ETH_DEBUG & OPEN_ETH_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     16
25#define TDA_COUNT     16
26
27open_eth_configuration_t leon_open_eth_configuration;
28
29int rtems_leon_open_eth_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
41  /* Scan for MAC AHB slave interface */
42  for (i = 0; i < amba_conf.ahbslv.devnr; i++)
43  {
44    conf = amba_get_confword(amba_conf.ahbslv, i, 0);
45    if (((amba_vendor(conf) == VENDOR_OPENCORES) && (amba_device(conf) == OPENCORES_ETHMAC)) ||
46        ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_ETHAHB)))
47    {
48      iobar = amba_ahb_get_membar(amba_conf.ahbslv, i, 0);
49      base_addr = amba_iobar_start(LEON3_IO_AREA, iobar);
50      eth_irq = amba_irq(conf) + 0x10;
51      device_found = 1;
52      break;
53    }
54  }
55
56
57  if (device_found)
58  {
59    /* clear control register and reset NIC */
60    *(volatile int *) base_addr = 0;
61    *(volatile int *) base_addr = 0x800;
62    *(volatile int *) base_addr = 0;
63    leon_open_eth_configuration.base_address = base_addr;
64    leon_open_eth_configuration.vector = eth_irq;
65    leon_open_eth_configuration.txd_count = TDA_COUNT;
66    leon_open_eth_configuration.rxd_count = RDA_COUNT;
67    /* enable 100 MHz operation only if cpu frequency >= 50 MHz */
68    if (LEON3_Timer_Regs->scaler_reload >= 49) leon_open_eth_configuration.en100MHz = 1;
69    if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) {
70      LEON_Clear_interrupt(leon_open_eth_configuration.vector);
71      LEON_Unmask_interrupt(leon_open_eth_configuration.vector);
72    }
73  }
74  return 0;
75}
Note: See TracBrowser for help on using the repository browser.