Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * ---------------------------------------------------------------------------
0004  * drivers/nfc/st95hf/spi.h functions declarations for SPI communication
0005  * ---------------------------------------------------------------------------
0006  * Copyright (C) 2015 STMicroelectronics – All Rights Reserved
0007  */
0008 
0009 #ifndef __LINUX_ST95HF_SPI_H
0010 #define __LINUX_ST95HF_SPI_H
0011 
0012 #include <linux/spi/spi.h>
0013 
0014 /* Basic ST95HF SPI CMDs */
0015 #define ST95HF_COMMAND_SEND 0x0
0016 #define ST95HF_COMMAND_RESET    0x1
0017 #define ST95HF_COMMAND_RECEIVE  0x2
0018 
0019 #define ST95HF_RESET_CMD_LEN    0x1
0020 
0021 /*
0022  * structure to contain st95hf spi communication specific information.
0023  * @req_issync: true for synchronous calls.
0024  * @spidev: st95hf spi device object.
0025  * @done: completion structure to wait for st95hf response
0026  *  for synchronous calls.
0027  * @spi_lock: mutex to allow only one spi transfer at a time.
0028  */
0029 struct st95hf_spi_context {
0030     bool req_issync;
0031     struct spi_device *spidev;
0032     struct completion done;
0033     struct mutex spi_lock;
0034 };
0035 
0036 /* flag to differentiate synchronous & asynchronous spi request */
0037 enum req_type {
0038     SYNC,
0039     ASYNC,
0040 };
0041 
0042 int st95hf_spi_send(struct st95hf_spi_context *spicontext,
0043             unsigned char *buffertx,
0044             int datalen,
0045             enum req_type reqtype);
0046 
0047 int st95hf_spi_recv_response(struct st95hf_spi_context *spicontext,
0048                  unsigned char *receivebuff);
0049 
0050 int st95hf_spi_recv_echo_res(struct st95hf_spi_context *spicontext,
0051                  unsigned char *receivebuff);
0052 
0053 #endif