arch/mips/include/asm/octeon/cvmx-spi.h

Source file repositories/reference/linux-study-clean/arch/mips/include/asm/octeon/cvmx-spi.h

File Facts

System
Linux kernel
Corpus path
arch/mips/include/asm/octeon/cvmx-spi.h
Extension
.h
Size
9142 bytes
Lines
270
Domain
Architecture Layer
Bucket
arch/mips
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

#ifndef __CVMX_SPI_H__
#define __CVMX_SPI_H__

#include <asm/octeon/cvmx-gmxx-defs.h>

/* CSR typedefs have been moved to cvmx-csr-*.h */

typedef enum {
	CVMX_SPI_MODE_UNKNOWN = 0,
	CVMX_SPI_MODE_TX_HALFPLEX = 1,
	CVMX_SPI_MODE_RX_HALFPLEX = 2,
	CVMX_SPI_MODE_DUPLEX = 3
} cvmx_spi_mode_t;

/** Callbacks structure to customize SPI4 initialization sequence */
typedef struct {
    /** Called to reset SPI4 DLL */
	int (*reset_cb) (int interface, cvmx_spi_mode_t mode);

    /** Called to setup calendar */
	int (*calendar_setup_cb) (int interface, cvmx_spi_mode_t mode,
				  int num_ports);

    /** Called for Tx and Rx clock detection */
	int (*clock_detect_cb) (int interface, cvmx_spi_mode_t mode,
				int timeout);

    /** Called to perform link training */
	int (*training_cb) (int interface, cvmx_spi_mode_t mode, int timeout);

    /** Called for calendar data synchronization */
	int (*calendar_sync_cb) (int interface, cvmx_spi_mode_t mode,
				 int timeout);

    /** Called when interface is up */
	int (*interface_up_cb) (int interface, cvmx_spi_mode_t mode);

} cvmx_spi_callbacks_t;

/**
 * Return true if the supplied interface is configured for SPI
 *
 * @interface: Interface to check
 * Returns True if interface is SPI
 */
static inline int cvmx_spi_is_spi_interface(int interface)
{
	uint64_t gmxState = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface));
	return (gmxState & 0x2) && (gmxState & 0x1);
}

/**
 * Initialize and start the SPI interface.
 *
 * @interface: The identifier of the packet interface to configure and
 *		    use as a SPI interface.
 * @mode:      The operating mode for the SPI interface. The interface
 *		    can operate as a full duplex (both Tx and Rx data paths
 *		    active) or as a halfplex (either the Tx data path is
 *		    active or the Rx data path is active, but not both).
 * @timeout:   Timeout to wait for clock synchronization in seconds
 * @num_ports: Number of SPI ports to configure
 *
 * Returns Zero on success, negative of failure.
 */
extern int cvmx_spi_start_interface(int interface, cvmx_spi_mode_t mode,
				    int timeout, int num_ports);

/**
 * This routine restarts the SPI interface after it has lost synchronization
 * with its corespondant system.
 *
 * @interface: The identifier of the packet interface to configure and
 *		    use as a SPI interface.
 * @mode:      The operating mode for the SPI interface. The interface
 *		    can operate as a full duplex (both Tx and Rx data paths
 *		    active) or as a halfplex (either the Tx data path is
 *		    active or the Rx data path is active, but not both).
 * @timeout:   Timeout to wait for clock synchronization in seconds
 * Returns Zero on success, negative of failure.
 */
extern int cvmx_spi_restart_interface(int interface, cvmx_spi_mode_t mode,
				      int timeout);

/**
 * Return non-zero if the SPI interface has a SPI4000 attached
 *
 * @interface: SPI interface the SPI4000 is connected to
 *
 * Returns

Annotation

Implementation Notes