1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2020 Marvell International Ltd.
4  *
5  * Functions for RGMII/GMII/MII initialization, configuration,
6  * and monitoring.
7  */
8 
9 #ifndef __CVMX_HELPER_RGMII_H__
10 #define __CVMX_HELPER_RGMII_H__
11 
12 /**
13  * @INTERNAL
14  * Probe RGMII ports and determine the number present
15  *
16  * @param xiface Interface to probe
17  *
18  * @return Number of RGMII/GMII/MII ports (0-4).
19  */
20 int __cvmx_helper_rgmii_probe(int xiface);
21 
22 /**
23  * Put an RGMII interface in loopback mode. Internal packets sent
24  * out will be received back again on the same port. Externally
25  * received packets will echo back out.
26  *
27  * @param port   IPD port number to loop.
28  */
29 void cvmx_helper_rgmii_internal_loopback(int port);
30 
31 /**
32  * @INTERNAL
33  * Configure all of the ASX, GMX, and PKO regsiters required
34  * to get RGMII to function on the supplied interface.
35  *
36  * @param xiface PKO Interface to configure (0 or 1)
37  *
38  * @return Zero on success
39  */
40 int __cvmx_helper_rgmii_enable(int xiface);
41 
42 /**
43  * @INTERNAL
44  * Return the link state of an IPD/PKO port as returned by
45  * auto negotiation. The result of this function may not match
46  * Octeon's link config if auto negotiation has changed since
47  * the last call to cvmx_helper_link_set().
48  *
49  * @param ipd_port IPD/PKO port to query
50  *
51  * @return Link state
52  */
53 cvmx_helper_link_info_t __cvmx_helper_gmii_link_get(int ipd_port);
54 
55 /**
56  * @INTERNAL
57  * Return the link state of an IPD/PKO port as returned by
58  * auto negotiation. The result of this function may not match
59  * Octeon's link config if auto negotiation has changed since
60  * the last call to cvmx_helper_link_set().
61  *
62  * @param ipd_port IPD/PKO port to query
63  *
64  * @return Link state
65  */
66 cvmx_helper_link_info_t __cvmx_helper_rgmii_link_get(int ipd_port);
67 
68 /**
69  * @INTERNAL
70  * Configure an IPD/PKO port for the specified link state. This
71  * function does not influence auto negotiation at the PHY level.
72  * The passed link state must always match the link state returned
73  * by cvmx_helper_link_get(). It is normally best to use
74  * cvmx_helper_link_autoconf() instead.
75  *
76  * @param ipd_port  IPD/PKO port to configure
77  * @param link_info The new link state
78  *
79  * @return Zero on success, negative on failure
80  */
81 int __cvmx_helper_rgmii_link_set(int ipd_port, cvmx_helper_link_info_t link_info);
82 
83 /**
84  * @INTERNAL
85  * Configure a port for internal and/or external loopback. Internal loopback
86  * causes packets sent by the port to be received by Octeon. External loopback
87  * causes packets received from the wire to sent out again.
88  *
89  * @param ipd_port IPD/PKO port to loopback.
90  * @param enable_internal
91  *                 Non zero if you want internal loopback
92  * @param enable_external
93  *                 Non zero if you want external loopback
94  *
95  * @return Zero on success, negative on failure.
96  */
97 int __cvmx_helper_rgmii_configure_loopback(int ipd_port, int enable_internal, int enable_external);
98 
99 #endif
100