1210284Sjmallett/***********************license start***************
2232812Sjmallett * Copyright (c) 2003-2010  Cavium Inc. (support@cavium.com). All rights
3215990Sjmallett * reserved.
4210284Sjmallett *
5210284Sjmallett *
6215990Sjmallett * Redistribution and use in source and binary forms, with or without
7215990Sjmallett * modification, are permitted provided that the following conditions are
8215990Sjmallett * met:
9210284Sjmallett *
10215990Sjmallett *   * Redistributions of source code must retain the above copyright
11215990Sjmallett *     notice, this list of conditions and the following disclaimer.
12210284Sjmallett *
13215990Sjmallett *   * Redistributions in binary form must reproduce the above
14215990Sjmallett *     copyright notice, this list of conditions and the following
15215990Sjmallett *     disclaimer in the documentation and/or other materials provided
16215990Sjmallett *     with the distribution.
17215990Sjmallett
18232812Sjmallett *   * Neither the name of Cavium Inc. nor the names of
19215990Sjmallett *     its contributors may be used to endorse or promote products
20215990Sjmallett *     derived from this software without specific prior written
21215990Sjmallett *     permission.
22215990Sjmallett
23215990Sjmallett * This Software, including technical data, may be subject to U.S. export  control
24215990Sjmallett * laws, including the U.S. Export Administration Act and its  associated
25215990Sjmallett * regulations, and may be subject to export or import  regulations in other
26215990Sjmallett * countries.
27215990Sjmallett
28215990Sjmallett * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29232812Sjmallett * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30215990Sjmallett * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31215990Sjmallett * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32215990Sjmallett * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33215990Sjmallett * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34215990Sjmallett * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35215990Sjmallett * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36215990Sjmallett * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37215990Sjmallett * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38210284Sjmallett ***********************license end**************************************/
39210284Sjmallett
40210284Sjmallett
41210284Sjmallett
42210284Sjmallett
43210284Sjmallett
44210284Sjmallett
45215990Sjmallett
46210284Sjmallett/**
47210284Sjmallett * @file
48210284Sjmallett *
49210284Sjmallett * Functions for RGMII/GMII/MII initialization, configuration,
50210284Sjmallett * and monitoring.
51210284Sjmallett *
52232812Sjmallett * <hr>$Revision: 70030 $<hr>
53210284Sjmallett */
54210284Sjmallett#ifndef __CVMX_HELPER_RGMII_H__
55210284Sjmallett#define __CVMX_HELPER_RGMII_H__
56210284Sjmallett
57210284Sjmallett/**
58210284Sjmallett * @INTERNAL
59210284Sjmallett * Probe RGMII ports and determine the number present
60210284Sjmallett *
61210284Sjmallett * @param interface Interface to probe
62210284Sjmallett *
63210284Sjmallett * @return Number of RGMII/GMII/MII ports (0-4).
64210284Sjmallett */
65210284Sjmallettextern int __cvmx_helper_rgmii_probe(int interface);
66232812Sjmallettstatic inline int __cvmx_helper_rgmii_enumerate(int interface)
67232812Sjmallett{
68232812Sjmallett	return __cvmx_helper_rgmii_probe(interface);
69232812Sjmallett}
70210284Sjmallett
71210284Sjmallett/**
72210284Sjmallett * Put an RGMII interface in loopback mode. Internal packets sent
73210284Sjmallett * out will be received back again on the same port. Externally
74210284Sjmallett * received packets will echo back out.
75210284Sjmallett *
76210284Sjmallett * @param port   IPD port number to loop.
77210284Sjmallett */
78210284Sjmallettextern void cvmx_helper_rgmii_internal_loopback(int port);
79210284Sjmallett
80210284Sjmallett/**
81210284Sjmallett * @INTERNAL
82210284Sjmallett * Configure all of the ASX, GMX, and PKO regsiters required
83210284Sjmallett * to get RGMII to function on the supplied interface.
84210284Sjmallett *
85210284Sjmallett * @param interface PKO Interface to configure (0 or 1)
86210284Sjmallett *
87210284Sjmallett * @return Zero on success
88210284Sjmallett */
89210284Sjmallettextern int __cvmx_helper_rgmii_enable(int interface);
90210284Sjmallett
91210284Sjmallett/**
92210284Sjmallett * @INTERNAL
93210284Sjmallett * Return the link state of an IPD/PKO port as returned by
94210284Sjmallett * auto negotiation. The result of this function may not match
95210284Sjmallett * Octeon's link config if auto negotiation has changed since
96210284Sjmallett * the last call to cvmx_helper_link_set().
97210284Sjmallett *
98210284Sjmallett * @param ipd_port IPD/PKO port to query
99210284Sjmallett *
100210284Sjmallett * @return Link state
101210284Sjmallett */
102210284Sjmallettextern cvmx_helper_link_info_t __cvmx_helper_rgmii_link_get(int ipd_port);
103210284Sjmallett
104210284Sjmallett/**
105210284Sjmallett * @INTERNAL
106210284Sjmallett * Configure an IPD/PKO port for the specified link state. This
107210284Sjmallett * function does not influence auto negotiation at the PHY level.
108210284Sjmallett * The passed link state must always match the link state returned
109210284Sjmallett * by cvmx_helper_link_get(). It is normally best to use
110210284Sjmallett * cvmx_helper_link_autoconf() instead.
111210284Sjmallett *
112210284Sjmallett * @param ipd_port  IPD/PKO port to configure
113210284Sjmallett * @param link_info The new link state
114210284Sjmallett *
115210284Sjmallett * @return Zero on success, negative on failure
116210284Sjmallett */
117210284Sjmallettextern int __cvmx_helper_rgmii_link_set(int ipd_port, cvmx_helper_link_info_t link_info);
118210284Sjmallett
119210284Sjmallett/**
120210284Sjmallett * @INTERNAL
121210284Sjmallett * Configure a port for internal and/or external loopback. Internal loopback
122210284Sjmallett * causes packets sent by the port to be received by Octeon. External loopback
123210284Sjmallett * causes packets received from the wire to sent out again.
124210284Sjmallett *
125210284Sjmallett * @param ipd_port IPD/PKO port to loopback.
126210284Sjmallett * @param enable_internal
127210284Sjmallett *                 Non zero if you want internal loopback
128210284Sjmallett * @param enable_external
129210284Sjmallett *                 Non zero if you want external loopback
130210284Sjmallett *
131210284Sjmallett * @return Zero on success, negative on failure.
132210284Sjmallett */
133210284Sjmallettextern int __cvmx_helper_rgmii_configure_loopback(int ipd_port, int enable_internal, int enable_external);
134210284Sjmallett
135210284Sjmallett#endif
136