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

Subversion Repositories xenie

[/] [xenie/] [trunk/] [examples/] [Eth_example/] [mb_fw/] [xenie_eth_test_womtd/] [lib/] [eth_phy.h] - 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
#ifndef __ETH_PHY_H__
29
#define __ETH_PHY_H__
30
 
31
/* Link speed constants used to specify what
32
 * speeds are advertized for autonegotiation or
33
 * what final resolved speed is. They can be
34
 * combined by ORring in the first case.
35
 */
36
#define PHY_ADV_NONE           0x0000 // No speeds to be advertised
37
#define PHY_SPEED_10M_HD       0x0001 // 10BT half-duplex
38
#define PHY_SPEED_10M_FD       0x0002 // 10BT full-duplex
39
#define PHY_SPEED_100M_HD      0x0004 // 100BASE-TX half-duplex
40
#define PHY_SPEED_100M_FD      0x0008 // 100BASE-TX full-duplex
41
#define PHY_SPEED_1GIG_HD      0x0010 // 1000BASE-T half-duplex
42
#define PHY_SPEED_1GIG_FD      0x0020 // 1000BASE-T full-duplex
43
#define PHY_SPEED_10GIG_FD     0x0040 // 10GBASE-T full-duplex
44
#define PHY_SPEED_2P5GIG_FD    0x0800 // 2.5GBASE-T full-duplex, 88X33X0/88E20X0 family only
45
#define PHY_SPEED_5GIG_FD      0x1000 // 5GBASE-T full-duplex, 88X33X0/88E20X0 family only
46
 
47
/*
48
 * Structure holding context of PHY
49
 * driver. User should never need its
50
 * contents.
51
 */
52
struct phy_dev;
53
 
54
/*
55
 * Typedefs for function pointers that point
56
 * to user-defined mdio access routines.
57
 */
58
typedef int (*mdio_read_fcn_type)(void *ctx, uint16_t phyaddr, uint16_t devaddr,
59
                uint16_t regaddr, uint16_t *data);
60
typedef int (*mdio_write_fcn_type)(void *ctx, uint16_t phyaddr, uint16_t devaddr,
61
                uint16_t regaddr, uint16_t data);
62
typedef int (*mdio_write_burst_fcn_type)(void *ctx, uint16_t phyaddr, uint16_t devaddr,
63
                uint16_t regaddr, uint8_t *data, int size);
64
 
65
/*
66
 * Initialize driver of PHY.
67
 * Space for struct phy_dev is dynamically
68
 * allocated inside the function - if it succeeds.
69
 *
70
 * On success, zero is returned. On error, -1 is returned.
71
 *
72
 * It fails if PHY is not accessible via MDIO - e.g. held in reset.
73
 */
74
int phy_init_drv(struct phy_dev **dev,
75
                uint16_t phy_addr,
76
                mdio_read_fcn_type mdio_read_fcn,
77
                mdio_write_fcn_type mdio_write_fcn,
78
                mdio_write_burst_fcn_type mdio_write_burst_fcn,
79
                void *mdio_ctx);
80
 
81
/*
82
 * Switch PHY to Xilinx RGMII core RXAUI mode.
83
 *
84
 * On success, zero is returned. On error, -1 is returned.
85
 */
86
int phy_configure_xilinx_rgmii(struct phy_dev *dev);
87
 
88
/*
89
 * Get revision of firmware that is currently running
90
 * by PHY's internal processor.
91
 *
92
 * On success, zero is returned. On error, -1 is returned.
93
 *
94
 * It fails if PHY is not accessible, or no firmware
95
 * is running. In case of fauilure all parts of version number
96
 * are set to 0.
97
 */
98
int phy_get_fw_rev (struct phy_dev *dev, uint8_t *fw_maj, uint8_t *fw_min,
99
                uint8_t *fw_inc, uint8_t *fw_test);
100
/*
101
 * Update and start new firmware on PHY's internal
102
 * processor.
103
 *
104
 * On success, zero is returned. On error, -1 is returned.
105
 *
106
 * If it succeeds firmware is up and running.
107
 */
108
int phy_update_fw(struct phy_dev *dev, void *fw_data, int fw_length);
109
 
110
/*
111
 * Set speeds that will be advertised for autonegotiation.
112
 * Autonegotiation is restarted.
113
 *
114
 * On success, zero is returned. On error, -1 is returned.
115
 *
116
 */
117
int phy_enable_speeds(struct phy_dev *dev, uint16_t speeds);
118
 
119
/*
120
 * Get link state and speed.
121
 *
122
 * On success, zero is returned. On error, -1 is returned.
123
 *
124
 * If function failed, speed and link values are invalid.
125
 */
126
int phy_is_baseT_up(struct phy_dev *dev, uint16_t *speed, int *link);
127
 
128
/*
129
 * Return string that contains version info of this library
130
 * and underlying Marvell MTD library.
131
 */
132
char *phy_get_version_string();
133
 
134
#endif /* __ETH_PHY_H__ */

powered by: WebSVN 2.1.0

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