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