1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2020 Marvell International Ltd.
4  *
5  * Functions for XAUI initialization, configuration,
6  * and monitoring.
7  */
8 
9 #ifndef __CVMX_HELPER_XAUI_H__
10 #define __CVMX_HELPER_XAUI_H__
11 
12 /**
13  * @INTERNAL
14  * Probe a XAUI interface and determine the number of ports
15  * connected to it. The XAUI interface should still be down
16  * after this call.
17  *
18  * @param xiface Interface to probe
19  *
20  * @return Number of ports on the interface. Zero to disable.
21  */
22 int __cvmx_helper_xaui_probe(int xiface);
23 int __cvmx_helper_xaui_enumerate(int xiface);
24 
25 /**
26  * @INTERNAL
27  * Bringup and enable a XAUI interface. After this call packet
28  * I/O should be fully functional. This is called with IPD
29  * enabled but PKO disabled.
30  *
31  * @param xiface Interface to bring up
32  *
33  * @return Zero on success, negative on failure
34  */
35 int __cvmx_helper_xaui_enable(int xiface);
36 
37 /**
38  * Retrain XAUI interface.
39  *
40  * GMX is disabled as part of retraining.
41  * While GMX is disabled, new received packets are dropped.
42  * If GMX was in the middle of recieving a packet when disabled,
43  * that packet will be received before GMX idles.
44  * Transmitted packets are buffered normally, but not sent.
45  * If GMX was in the middle of transmitting a packet when disabled,
46  * that packet will be transmitted before GMX idles.
47  *
48  * @param interface Interface to retrain
49  *
50  * @return Zero on success, negative on failure
51  */
52 int cvmx_helper_xaui_link_retrain(int interface);
53 
54 /**
55  * Reinitialize XAUI interface.  Does a probe without changing the hardware
56  * state.
57  *
58  * @param interface	Interface to reinitialize
59  *
60  * @return	0 on success, negative on failure
61  */
62 int cvmx_helper_xaui_link_reinit(int interface);
63 
64 /**
65  * @INTERNAL
66  * Return the link state of an IPD/PKO port as returned by
67  * auto negotiation. The result of this function may not match
68  * Octeon's link config if auto negotiation has changed since
69  * the last call to cvmx_helper_link_set().
70  *
71  * @param ipd_port IPD/PKO port to query
72  *
73  * @return Link state
74  */
75 cvmx_helper_link_info_t __cvmx_helper_xaui_link_get(int ipd_port);
76 
77 /**
78  * @INTERNAL
79  * Configure an IPD/PKO port for the specified link state. This
80  * function does not influence auto negotiation at the PHY level.
81  * The passed link state must always match the link state returned
82  * by cvmx_helper_link_get(). It is normally best to use
83  * cvmx_helper_link_autoconf() instead.
84  *
85  * @param ipd_port  IPD/PKO port to configure
86  * @param link_info The new link state
87  *
88  * @return Zero on success, negative on failure
89  */
90 int __cvmx_helper_xaui_link_set(int ipd_port, cvmx_helper_link_info_t link_info);
91 
92 /**
93  * @INTERNAL
94  * Configure a port for internal and/or external loopback. Internal loopback
95  * causes packets sent by the port to be received by Octeon. External loopback
96  * causes packets received from the wire to sent out again.
97  *
98  * @param ipd_port IPD/PKO port to loopback.
99  * @param enable_internal
100  *                 Non zero if you want internal loopback
101  * @param enable_external
102  *                 Non zero if you want external loopback
103  *
104  * @return Zero on success, negative on failure.
105  */
106 int __cvmx_helper_xaui_configure_loopback(int ipd_port, int enable_internal, int enable_external);
107 
108 #endif
109