1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2020 Marvell International Ltd.
4  *
5  * Functions for SPI initialization, configuration,
6  * and monitoring.
7  */
8 
9 #ifndef __CVMX_HELPER_SPI_H__
10 #define __CVMX_HELPER_SPI_H__
11 
12 #include "cvmx-helper.h"
13 
14 /**
15  * @INTERNAL
16  * Probe a SPI interface and determine the number of ports
17  * connected to it. The SPI interface should still be down after
18  * this call.
19  *
20  * @param interface Interface to probe
21  *
22  * @return Number of ports on the interface. Zero to disable.
23  */
24 int __cvmx_helper_spi_probe(int interface);
25 int __cvmx_helper_spi_enumerate(int interface);
26 
27 /**
28  * @INTERNAL
29  * Bringup and enable a SPI interface. After this call packet I/O
30  * should be fully functional. This is called with IPD enabled but
31  * PKO disabled.
32  *
33  * @param interface Interface to bring up
34  *
35  * @return Zero on success, negative on failure
36  */
37 int __cvmx_helper_spi_enable(int interface);
38 
39 /**
40  * @INTERNAL
41  * Return the link state of an IPD/PKO port as returned by
42  * auto negotiation. The result of this function may not match
43  * Octeon's link config if auto negotiation has changed since
44  * the last call to cvmx_helper_link_set().
45  *
46  * @param ipd_port IPD/PKO port to query
47  *
48  * @return Link state
49  */
50 cvmx_helper_link_info_t __cvmx_helper_spi_link_get(int ipd_port);
51 
52 /**
53  * @INTERNAL
54  * Configure an IPD/PKO port for the specified link state. This
55  * function does not influence auto negotiation at the PHY level.
56  * The passed link state must always match the link state returned
57  * by cvmx_helper_link_get(). It is normally best to use
58  * cvmx_helper_link_autoconf() instead.
59  *
60  * @param ipd_port  IPD/PKO port to configure
61  * @param link_info The new link state
62  *
63  * @return Zero on success, negative on failure
64  */
65 int __cvmx_helper_spi_link_set(int ipd_port, cvmx_helper_link_info_t link_info);
66 
67 /**
68  * Sets the spi timeout in config data
69  * @param timeout value
70  */
71 void cvmx_spi_config_set_timeout(int timeout);
72 
73 #endif
74