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

4.115
Last change on this file since d230d8e was d230d8e, checked in by Radu Toma <radustoma@…>, on 11/30/13 at 20:51:35

sparc/leon3: Add doxygen.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/**
2 * @file
3 * @ingroup sparc_leon3
4 * @brief LEON3 Opencores Ethernet MAC Configuration Information
5 */
6
7/*  COPYRIGHT (c) 2004.
8 *  Gaisler Research
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 */
14
15
16#include <bsp.h>
17#include <libchip/open_eth.h>
18#if (OPEN_ETH_DEBUG & OPEN_ETH_DEBUG_PRINT_REGISTERS)
19#include <stdio.h>
20#endif
21
22/*
23 * Default sizes of transmit and receive descriptor areas
24 */
25#define RDA_COUNT     16
26#define TDA_COUNT     16
27
28open_eth_configuration_t leon_open_eth_configuration;
29
30int rtems_leon_open_eth_driver_attach(
31  struct rtems_bsdnet_ifconfig *config,
32  int attach
33)
34{
35  unsigned int base_addr = 0; /* avoid warnings */
36  unsigned int eth_irq = 0;   /* avoid warnings */
37  struct ambapp_dev *adev;
38  struct ambapp_ahb_info *ahb;
39
40  /* Scan for MAC AHB slave interface */
41  adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS),
42                                 VENDOR_OPENCORES, OPENCORES_ETHMAC,
43                                 ambapp_find_by_idx, NULL);
44  if (!adev) {
45    adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS),
46                                   VENDOR_GAISLER, GAISLER_ETHAHB,
47                                   ambapp_find_by_idx, NULL);
48  }
49
50  if (adev)
51  {
52    ahb = DEV_TO_AHB(adev);
53    base_addr = ahb->start[0];
54    eth_irq = ahb->irq;
55
56    /* clear control register and reset NIC */
57    *(volatile int *) base_addr = 0;
58    *(volatile int *) base_addr = 0x800;
59    *(volatile int *) base_addr = 0;
60    leon_open_eth_configuration.base_address = (void *) base_addr;
61    leon_open_eth_configuration.vector = eth_irq + 0x10;
62    leon_open_eth_configuration.txd_count = TDA_COUNT;
63    leon_open_eth_configuration.rxd_count = RDA_COUNT;
64    /* enable 100 MHz operation only if cpu frequency >= 50 MHz */
65    if (LEON3_Timer_Regs->scaler_reload >= 49)
66      leon_open_eth_configuration.en100MHz = 1;
67    if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) {
68      LEON_Clear_interrupt(eth_irq);
69      LEON_Unmask_interrupt(eth_irq);
70    }
71  }
72  return 0;
73}
Note: See TracBrowser for help on using the repository browser.