1 | /** |
---|
2 | * @file |
---|
3 | * @ingroup sparc_leon3 |
---|
4 | * @brief LEON3 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 <machine/rtems-bsd-kernel-space.h> |
---|
17 | |
---|
18 | #include <bsp.h> |
---|
19 | #include <libchip/open_eth.h> |
---|
20 | #if (OPEN_ETH_DEBUG & OPEN_ETH_DEBUG_PRINT_REGISTERS) |
---|
21 | #include <stdio.h> |
---|
22 | #endif |
---|
23 | |
---|
24 | /* |
---|
25 | * Default sizes of transmit and receive descriptor areas |
---|
26 | */ |
---|
27 | #define RDA_COUNT 16 |
---|
28 | #define TDA_COUNT 16 |
---|
29 | |
---|
30 | open_eth_configuration_t leon_open_eth_configuration; |
---|
31 | |
---|
32 | int rtems_leon_open_eth_driver_attach( |
---|
33 | struct rtems_bsdnet_ifconfig *config, |
---|
34 | int attach |
---|
35 | ) |
---|
36 | { |
---|
37 | unsigned int base_addr = 0; /* avoid warnings */ |
---|
38 | unsigned int eth_irq = 0; /* avoid warnings */ |
---|
39 | struct ambapp_dev *adev; |
---|
40 | struct ambapp_ahb_info *ahb; |
---|
41 | |
---|
42 | /* Scan for MAC AHB slave interface */ |
---|
43 | adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS), |
---|
44 | VENDOR_OPENCORES, OPENCORES_ETHMAC, |
---|
45 | ambapp_find_by_idx, NULL); |
---|
46 | if (!adev) { |
---|
47 | adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS), |
---|
48 | VENDOR_GAISLER, GAISLER_ETHAHB, |
---|
49 | ambapp_find_by_idx, NULL); |
---|
50 | } |
---|
51 | |
---|
52 | if (adev) |
---|
53 | { |
---|
54 | ahb = DEV_TO_AHB(adev); |
---|
55 | base_addr = ahb->start[0]; |
---|
56 | eth_irq = ahb->irq; |
---|
57 | |
---|
58 | /* clear control register and reset NIC */ |
---|
59 | *(volatile int *) base_addr = 0; |
---|
60 | *(volatile int *) base_addr = 0x800; |
---|
61 | *(volatile int *) base_addr = 0; |
---|
62 | leon_open_eth_configuration.base_address = (void *) base_addr; |
---|
63 | leon_open_eth_configuration.vector = eth_irq + 0x10; |
---|
64 | leon_open_eth_configuration.txd_count = TDA_COUNT; |
---|
65 | leon_open_eth_configuration.rxd_count = RDA_COUNT; |
---|
66 | /* enable 100 MHz operation only if cpu frequency >= 50 MHz */ |
---|
67 | if (LEON3_Timer_Regs->scaler_reload >= 49) |
---|
68 | leon_open_eth_configuration.en100MHz = 1; |
---|
69 | if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) { |
---|
70 | LEON_Clear_interrupt(eth_irq); |
---|
71 | LEON_Unmask_interrupt(eth_irq); |
---|
72 | } |
---|
73 | } |
---|
74 | return 0; |
---|
75 | } |
---|