xref: /OK3568_Linux_fs/u-boot/arch/sandbox/include/asm/spi.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Simulate a SPI port and clients (see README.sandbox for details)
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright (c) 2011-2013 The Chromium OS Authors.
5*4882a593Smuzhiyun  * See file CREDITS for list of people who contributed to this
6*4882a593Smuzhiyun  * project.
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Licensed under the GPL-2 or later.
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #ifndef __ASM_SPI_H__
12*4882a593Smuzhiyun #define __ASM_SPI_H__
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun #include <linux/types.h>
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun /*
17*4882a593Smuzhiyun  * The interface between the SPI bus and the SPI client.  The bus will
18*4882a593Smuzhiyun  * instantiate a client, and that then call into it via these entry
19*4882a593Smuzhiyun  * points.  These should be enough for the client to emulate the SPI
20*4882a593Smuzhiyun  * device just like the real hardware.
21*4882a593Smuzhiyun  */
22*4882a593Smuzhiyun struct sandbox_spi_emu_ops {
23*4882a593Smuzhiyun 	/* The bus wants to instantiate a new client, so setup everything */
24*4882a593Smuzhiyun 	int (*setup)(void **priv, const char *spec);
25*4882a593Smuzhiyun 	/* The bus is done with us, so break things down */
26*4882a593Smuzhiyun 	void (*free)(void *priv);
27*4882a593Smuzhiyun 	/* The CS has been "activated" -- we won't worry about low/high */
28*4882a593Smuzhiyun 	void (*cs_activate)(void *priv);
29*4882a593Smuzhiyun 	/* The CS has been "deactivated" -- we won't worry about low/high */
30*4882a593Smuzhiyun 	void (*cs_deactivate)(void *priv);
31*4882a593Smuzhiyun 	/* The client is rx-ing bytes from the bus, so it should tx some */
32*4882a593Smuzhiyun 	int (*xfer)(void *priv, const u8 *rx, u8 *tx, uint bytes);
33*4882a593Smuzhiyun };
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun /*
36*4882a593Smuzhiyun  * Extract the bus/cs from the spi spec and return the start of the spi
37*4882a593Smuzhiyun  * client spec.  If the bus/cs are invalid for the current config, then
38*4882a593Smuzhiyun  * it returns NULL.
39*4882a593Smuzhiyun  *
40*4882a593Smuzhiyun  * Example: arg="0:1:foo" will set bus to 0, cs to 1, and return "foo"
41*4882a593Smuzhiyun  */
42*4882a593Smuzhiyun const char *sandbox_spi_parse_spec(const char *arg, unsigned long *bus,
43*4882a593Smuzhiyun 				   unsigned long *cs);
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun #endif
46