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 | |
---|
38 | open_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 | |
---|
46 | int 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 | } |
---|