xref: /openbmc/linux/drivers/nfc/st95hf/spi.h (revision c4f7ac64)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * ---------------------------------------------------------------------------
4  * drivers/nfc/st95hf/spi.h functions declarations for SPI communication
5  * ---------------------------------------------------------------------------
6  * Copyright (C) 2015 STMicroelectronics – All Rights Reserved
7  */
8 
9 #ifndef __LINUX_ST95HF_SPI_H
10 #define __LINUX_ST95HF_SPI_H
11 
12 #include <linux/spi/spi.h>
13 
14 /* Basic ST95HF SPI CMDs */
15 #define ST95HF_COMMAND_SEND	0x0
16 #define ST95HF_COMMAND_RESET	0x1
17 #define ST95HF_COMMAND_RECEIVE	0x2
18 
19 #define ST95HF_RESET_CMD_LEN	0x1
20 
21 /*
22  * structure to contain st95hf spi communication specific information.
23  * @req_issync: true for synchronous calls.
24  * @spidev: st95hf spi device object.
25  * @done: completion structure to wait for st95hf response
26  *	for synchronous calls.
27  * @spi_lock: mutex to allow only one spi transfer at a time.
28  */
29 struct st95hf_spi_context {
30 	bool req_issync;
31 	struct spi_device *spidev;
32 	struct completion done;
33 	struct mutex spi_lock;
34 };
35 
36 /* flag to differentiate synchronous & asynchronous spi request */
37 enum req_type {
38 	SYNC,
39 	ASYNC,
40 };
41 
42 int st95hf_spi_send(struct st95hf_spi_context *spicontext,
43 		    unsigned char *buffertx,
44 		    int datalen,
45 		    enum req_type reqtype);
46 
47 int st95hf_spi_recv_response(struct st95hf_spi_context *spicontext,
48 			     unsigned char *receivebuff);
49 
50 int st95hf_spi_recv_echo_res(struct st95hf_spi_context *spicontext,
51 			     unsigned char *receivebuff);
52 
53 #endif
54