2 * ---------------------------------------------------------------------------
3 * drivers/nfc/st95hf/spi.h functions declarations for SPI communication
4 * ---------------------------------------------------------------------------
5 * Copyright (C) 2015 STMicroelectronics – All Rights Reserved
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.
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.
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/>.
20 #ifndef __LINUX_ST95HF_SPI_H
21 #define __LINUX_ST95HF_SPI_H
23 #include <linux/spi/spi.h>
25 /* Basic ST95HF SPI CMDs */
26 #define ST95HF_COMMAND_SEND 0x0
27 #define ST95HF_COMMAND_RESET 0x1
28 #define ST95HF_COMMAND_RECEIVE 0x2
30 #define ST95HF_RESET_CMD_LEN 0x1
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.
40 struct st95hf_spi_context
{
42 struct spi_device
*spidev
;
43 struct completion done
;
44 struct mutex spi_lock
;
47 /* flag to differentiate synchronous & asynchronous spi request */
53 int st95hf_spi_send(struct st95hf_spi_context
*spicontext
,
54 unsigned char *buffertx
,
56 enum req_type reqtype
);
58 int st95hf_spi_recv_response(struct st95hf_spi_context
*spicontext
,
59 unsigned char *receivebuff
);
61 int st95hf_spi_recv_echo_res(struct st95hf_spi_context
*spicontext
,
62 unsigned char *receivebuff
);