xref: /openbmc/linux/drivers/nfc/st95hf/spi.h (revision 78700c0a)
1 /*
2  * ---------------------------------------------------------------------------
3  * drivers/nfc/st95hf/spi.h functions declarations for SPI communication
4  * ---------------------------------------------------------------------------
5  * Copyright (C) 2015 STMicroelectronics – All Rights Reserved
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms and conditions of the GNU General Public License,
9  * version 2, as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __LINUX_ST95HF_SPI_H
21 #define __LINUX_ST95HF_SPI_H
22 
23 #include <linux/spi/spi.h>
24 
25 /* Basic ST95HF SPI CMDs */
26 #define ST95HF_COMMAND_SEND	0x0
27 #define ST95HF_COMMAND_RESET	0x1
28 #define ST95HF_COMMAND_RECEIVE	0x2
29 
30 #define ST95HF_RESET_CMD_LEN	0x1
31 
32 /*
33  * structure to contain st95hf spi communication specific information.
34  * @req_issync: true for synchronous calls.
35  * @spidev: st95hf spi device object.
36  * @done: completion structure to wait for st95hf response
37  *	for synchronous calls.
38  * @spi_lock: mutex to allow only one spi transfer at a time.
39  */
40 struct st95hf_spi_context {
41 	bool req_issync;
42 	struct spi_device *spidev;
43 	struct completion done;
44 	struct mutex spi_lock;
45 };
46 
47 /* flag to differentiate synchronous & asynchronous spi request */
48 enum req_type {
49 	SYNC,
50 	ASYNC,
51 };
52 
53 int st95hf_spi_send(struct st95hf_spi_context *spicontext,
54 		    unsigned char *buffertx,
55 		    int datalen,
56 		    enum req_type reqtype);
57 
58 int st95hf_spi_recv_response(struct st95hf_spi_context *spicontext,
59 			     unsigned char *receivebuff);
60 
61 int st95hf_spi_recv_echo_res(struct st95hf_spi_context *spicontext,
62 			     unsigned char *receivebuff);
63 
64 #endif
65