1 | /* |
---|
2 | * LEON3 Opencores Ethernet MAC Configuration Information |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 2004. |
---|
5 | * Gaisler Research |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | * |
---|
11 | * leon_open_eth.c,v 1.1.2.1 2005/10/05 19:26:00 joel Exp |
---|
12 | */ |
---|
13 | |
---|
14 | |
---|
15 | #include <bsp.h> |
---|
16 | #include <libchip/greth.h> |
---|
17 | /*#if (GRETH_DEBUG & GRETH_DEBUG_PRINT_REGISTERS)*/ |
---|
18 | #include <stdio.h> |
---|
19 | /*#endif*/ |
---|
20 | |
---|
21 | /* |
---|
22 | * Default sizes of transmit and receive descriptor areas |
---|
23 | */ |
---|
24 | #define RDA_COUNT 32 |
---|
25 | #define TDA_COUNT 32 |
---|
26 | |
---|
27 | greth_configuration_t leon_greth_configuration; |
---|
28 | |
---|
29 | int rtems_leon_greth_driver_attach( |
---|
30 | struct rtems_bsdnet_ifconfig *config, |
---|
31 | int attach |
---|
32 | ) |
---|
33 | { |
---|
34 | int device_found = 0; |
---|
35 | unsigned int base_addr = 0; /* avoid warnings */ |
---|
36 | unsigned int eth_irq = 0; /* avoid warnings */ |
---|
37 | amba_apb_device apbgreth; |
---|
38 | |
---|
39 | /* Scan for MAC AHB slave interface */ |
---|
40 | device_found = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_ETHMAC,&apbgreth); |
---|
41 | if (device_found == 1) |
---|
42 | { |
---|
43 | base_addr = apbgreth.start; |
---|
44 | eth_irq = apbgreth.irq; |
---|
45 | |
---|
46 | /* clear control register and reset NIC */ |
---|
47 | *(volatile int *) base_addr = 0; |
---|
48 | *(volatile int *) base_addr = GRETH_CTRL_RST; |
---|
49 | *(volatile int *) base_addr = 0; |
---|
50 | leon_greth_configuration.base_address = base_addr; |
---|
51 | leon_greth_configuration.vector = eth_irq; /* on LEON vector is IRQ no. */ |
---|
52 | leon_greth_configuration.txd_count = TDA_COUNT; |
---|
53 | leon_greth_configuration.rxd_count = RDA_COUNT; |
---|
54 | rtems_greth_driver_attach(config, &leon_greth_configuration); |
---|
55 | } |
---|
56 | return 0; |
---|
57 | } |
---|