1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2020 Marvell International Ltd.
4 *
5 * Functions for SGMII initialization, configuration,
6 * and monitoring.
7 */
8
9#ifndef __CVMX_HELPER_SGMII_H__
10#define __CVMX_HELPER_SGMII_H__
11
12/**
13 * @INTERNAL
14 * Probe a SGMII interface and determine the number of ports
15 * connected to it. The SGMII interface should still be down after
16 * this call.
17 *
18 * @param xiface Interface to probe
19 *
20 * Return: Number of ports on the interface. Zero to disable.
21 */
22int __cvmx_helper_sgmii_probe(int xiface);
23int __cvmx_helper_sgmii_enumerate(int xiface);
24
25/**
26 * @INTERNAL
27 * Bringup and enable a SGMII 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 */
35int __cvmx_helper_sgmii_enable(int xiface);
36
37/**
38 * @INTERNAL
39 * Return the link state of an IPD/PKO port as returned by
40 * auto negotiation. The result of this function may not match
41 * Octeon's link config if auto negotiation has changed since
42 * the last call to cvmx_helper_link_set().
43 *
44 * @param ipd_port IPD/PKO port to query
45 *
46 * Return: Link state
47 */
48cvmx_helper_link_info_t __cvmx_helper_sgmii_link_get(int ipd_port);
49
50/**
51 * @INTERNAL
52 * Configure an IPD/PKO port for the specified link state. This
53 * function does not influence auto negotiation at the PHY level.
54 * The passed link state must always match the link state returned
55 * by cvmx_helper_link_get(). It is normally best to use
56 * cvmx_helper_link_autoconf() instead.
57 *
58 * @param ipd_port  IPD/PKO port to configure
59 * @param link_info The new link state
60 *
61 * Return: Zero on success, negative on failure
62 */
63int __cvmx_helper_sgmii_link_set(int ipd_port, cvmx_helper_link_info_t link_info);
64
65/**
66 * @INTERNAL
67 * Configure a port for internal and/or external loopback. Internal loopback
68 * causes packets sent by the port to be received by Octeon. External loopback
69 * causes packets received from the wire to sent out again.
70 *
71 * @param ipd_port IPD/PKO port to loopback.
72 * @param enable_internal
73 *                 Non zero if you want internal loopback
74 * @param enable_external
75 *                 Non zero if you want external loopback
76 *
77 * Return: Zero on success, negative on failure.
78 */
79int __cvmx_helper_sgmii_configure_loopback(int ipd_port, int enable_internal, int enable_external);
80
81#endif
82