[bec7ba52] | 1 | /* |
---|
| 2 | * LEON2 Opencores Ethernet MAC Configuration Information |
---|
| 3 | */ |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | #include <bsp.h> |
---|
| 7 | #include <libchip/open_eth.h> |
---|
| 8 | #if (OPEN_ETH_DEBUG & OPEN_ETH_DEBUG_PRINT_REGISTERS) |
---|
| 9 | #include <stdio.h> |
---|
| 10 | #endif |
---|
| 11 | |
---|
| 12 | /* |
---|
| 13 | * Default sizes of transmit and receive descriptor areas |
---|
| 14 | */ |
---|
| 15 | #define RDA_COUNT 16 |
---|
| 16 | #define TDA_COUNT 16 |
---|
| 17 | |
---|
| 18 | /* |
---|
| 19 | * Default location of device registers |
---|
| 20 | */ |
---|
| 21 | #define OPEN_ETH_BASE_ADDRESS 0xb0000000 |
---|
| 22 | |
---|
| 23 | /* |
---|
| 24 | * Default interrupt vector |
---|
| 25 | */ |
---|
| 26 | #define OPEN_ETH_VECTOR 0x1C |
---|
| 27 | |
---|
| 28 | open_eth_configuration_t leon_open_eth_configuration = { |
---|
[44b06ca] | 29 | OPEN_ETH_BASE_ADDRESS, /* base address */ |
---|
| 30 | OPEN_ETH_VECTOR, /* vector number */ |
---|
[bec7ba52] | 31 | TDA_COUNT, /* number of transmit descriptors */ |
---|
| 32 | RDA_COUNT, /* number of receive descriptors */ |
---|
| 33 | 0 /* 100 MHz operation */ |
---|
| 34 | }; |
---|
| 35 | |
---|
| 36 | int rtems_leon_open_eth_driver_attach(struct rtems_bsdnet_ifconfig *config) |
---|
| 37 | { |
---|
| 38 | |
---|
| 39 | /* clear control register and reset NIC */ |
---|
| 40 | *(volatile int *) OPEN_ETH_BASE_ADDRESS = 0; |
---|
| 41 | *(volatile int *) OPEN_ETH_BASE_ADDRESS = 0x800; |
---|
| 42 | *(volatile int *) OPEN_ETH_BASE_ADDRESS = 0; |
---|
| 43 | |
---|
| 44 | /* enable 100 MHz operation only if cpu frequency >= 50 MHz */ |
---|
| 45 | if (LEON_REG.Scaler_Reload >= 49) leon_open_eth_configuration.en100MHz = 1; |
---|
| 46 | |
---|
| 47 | if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) { |
---|
| 48 | LEON_REG.Interrupt_Clear = (1 << (OPEN_ETH_VECTOR - 0x10)); |
---|
| 49 | LEON_REG.Interrupt_Mask |= (1 << (OPEN_ETH_VECTOR - 0x10)); |
---|
| 50 | } |
---|
| 51 | return 0; |
---|
| 52 | } |
---|