OpenCores
URL https://opencores.org/ocsvn/xenie/xenie/trunk

Subversion Repositories xenie

[/] [xenie/] [trunk/] [examples/] [Eth_example/] [mb_fw/] [xenie_eth_test_womtd/] [src/] [udpip_rxaui.c] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 DFC
/******************************************************************************
2
**
3
** (C) Copyright 2017 DFC Design, s.r.o., Brno, Czech Republic
4
** Author: Marek Kvas (m.kvas@dspfpga.com)
5
**
6
****************************************************************************
7
**
8
** This file is part of Xenia Ethernet Example project.
9
**
10
** Xenia Ethernet Example project is free software: you can
11
** redistribute it and/or modify it under the terms of
12
** the GNU Lesser General Public License as published by the Free
13
** Software Foundation, either version 3 of the License, or
14
** (at your option) any later version.
15
**
16
** Xenia Ethernet Example project is distributed in the hope that
17
** it will be useful, but WITHOUT ANY WARRANTY; without even
18
** the implied warranty of MERCHANTABILITY or FITNESS FOR A
19
** PARTICULAR PURPOSE.  See the GNU Lesser General Public License
20
** for more details.
21
**
22
** You should have received a copy of the GNU Lesser General Public
23
** License along with Xenia Ethernet Example project.  If not,
24
** see <http://www.gnu.org/licenses/>.
25
****************************************************************************
26
*/
27
 
28
#include "sleep.h"
29
#include "gpio.h"
30
#include "udpip_rxaui.h"
31
#include "eth_phy.h"
32
 
33
void rxaui_core_reset()
34
{
35
        /* Assert reset */
36
        gpio_set_out(GPIO0_BANK, GPIO0_RXAUI_RESET);
37
        usleep(10*1000);
38
        /* Deassert */
39
        gpio_clear_out(GPIO0_BANK, GPIO0_RXAUI_RESET);
40
}
41
 
42
void udp_ip_core_reset(int rst)
43
{
44
        if (rst)
45
                gpio_clear_out(GPIO0_BANK, GPIO0_FRAME_GEN_NRST);
46
        else
47
                gpio_set_out(GPIO0_BANK, GPIO0_FRAME_GEN_NRST);
48
}
49
 
50
/*
51
 * Tell UDP/IP core what speed we are using.
52
 * If there is a mismatch between real link speed
53
 * and speed reported to UDP/IP core outgoing traffic
54
 * can be corrupted.
55
 *
56
 * Because of lack of synchronizers UDP/IP core should
57
 * be in reset during change
58
 *
59
 */
60
 
61
int udpip_core_set_speed(uint16_t phy_speed)
62
{
63
        enum udp_ip_core_speed spd;
64
        int ret = 0;
65
 
66
        switch(phy_speed) {
67
        case PHY_SPEED_10M_FD:
68
                spd = spd_10M;
69
                break;
70
        case PHY_SPEED_100M_FD:
71
                spd = spd_100M;
72
                break;
73
        case PHY_SPEED_1GIG_FD:
74
                spd = spd_1G;
75
                break;
76
        case PHY_SPEED_10GIG_FD:
77
                spd = spd_10G;
78
                break;
79
        case PHY_SPEED_2P5GIG_FD:
80
                spd = spd_2G5;
81
                break;
82
        case PHY_SPEED_5GIG_FD:
83
                spd = spd_5G;
84
                break;
85
        default:
86
                spd = spd_10M;
87
                ret = -1;
88
                break;
89
        }
90
 
91
 
92
        /* Set speed */
93
        gpio_set_dir_field(GPIO4_BANK,GPIO4_DIR_LINK_SPEED_MASK,
94
                                GPIO4_DIR_LINK_SPEED_SHIFT, spd);
95
 
96
        return ret;
97
}
98
 
99
/*
100
 * Set host MAC address, IP address and netmask for
101
 * UDP/IP core.
102
 * Because of lack of synchronizers UDP/IP core should
103
 * be in reset during change
104
 */
105
void udpip_core_set_host_info(u8* mac, u32 ip, u32 nemask)
106
{
107
        /* MAC Address */
108
        gpio_set_field(GPIO4_BANK, GPIO4_HOST_MAC0_MASK,
109
                        GPIO4_HOST_MAC0_SHIFT, mac[5] | (mac[4] << 8) |
110
                        (mac[3] << 16) | (mac[2] << 24));
111
        gpio_set_dir_field(GPIO4_BANK, GPIO4_DIR_HOST_MAC1_MASK,
112
                                GPIO4_DIR_HOST_MAC1_SHIFT, mac[1] | (mac[0] << 8));
113
 
114
        /* IP Address */
115
        gpio_set_field(GPIO5_BANK, GPIO5_HOST_IP_MASK, GPIO5_HOST_IP_SHIFT, ip);
116
        /* Netmask */
117
        gpio_set_dir_field(GPIO5_BANK, GPIO5_DIR_HOST_NETMASK_MASK,
118
                        GPIO5_DIR_HOST_NETMASK_SHIFT, nemask);
119
}
120
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.