source: rtems/c/src/lib/libbsp/sparc/leon2/leon_open_eth/leon_open_eth.c @ c903fc2

4.115
Last change on this file since c903fc2 was c903fc2, checked in by Daniel Cederman <cederman@…>, on 05/08/14 at 14:33:08

bsps/sparc: Add copyright and license information

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 * @ingroup sparc_leon2
4 * @brief LEON2 Opencores Ethernet MAC Configuration Information
5 */
6
7/*
8 * Copyright (c) 2004.
9 * Aeroflex Gaisler AB.
10 *
11 * The license and distribution terms for this file may be
12 * found in the file LICENSE in this distribution or at
13 * http://www.rtems.org/license/LICENSE.
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
28/*
29 * Default location of device registers
30 */
31#define OPEN_ETH_BASE_ADDRESS 0xb0000000
32
33/*
34 * Default interrupt vector
35 */
36#define OPEN_ETH_VECTOR 0x1C
37
38open_eth_configuration_t leon_open_eth_configuration = {
39  OPEN_ETH_BASE_ADDRESS,        /* base address */
40  OPEN_ETH_VECTOR,              /* vector number */
41  TDA_COUNT,                 /* number of transmit descriptors */
42  RDA_COUNT,                 /* number of receive descriptors */
43  0                   /* 100 MHz operation */
44};
45
46int rtems_leon_open_eth_driver_attach(struct rtems_bsdnet_ifconfig *config)
47{
48
49  /* clear control register and reset NIC */
50  *(volatile int *) OPEN_ETH_BASE_ADDRESS = 0;
51  *(volatile int *) OPEN_ETH_BASE_ADDRESS = 0x800;
52  *(volatile int *) OPEN_ETH_BASE_ADDRESS = 0;
53
54  /* enable 100 MHz operation only if cpu frequency >= 50 MHz */
55  if (LEON_REG.Scaler_Reload >= 49) leon_open_eth_configuration.en100MHz = 1;
56
57  if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) {
58    LEON_REG.Interrupt_Clear = (1 << (OPEN_ETH_VECTOR - 0x10));
59    LEON_REG.Interrupt_Mask  |= (1 << (OPEN_ETH_VECTOR - 0x10));
60  }
61  return 0;
62}
Note: See TracBrowser for help on using the repository browser.