Linux Audio

Check our new training course

Loading...
v6.8
 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 */
29struct 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 */
37enum req_type {
38	SYNC,
39	ASYNC,
40};
41
42int st95hf_spi_send(struct st95hf_spi_context *spicontext,
43		    unsigned char *buffertx,
44		    int datalen,
45		    enum req_type reqtype);
46
47int st95hf_spi_recv_response(struct st95hf_spi_context *spicontext,
48			     unsigned char *receivebuff);
49
50int st95hf_spi_recv_echo_res(struct st95hf_spi_context *spicontext,
51			     unsigned char *receivebuff);
52
53#endif
v4.6
 
 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 */
40struct 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 */
48enum req_type {
49	SYNC,
50	ASYNC,
51};
52
53int st95hf_spi_send(struct st95hf_spi_context *spicontext,
54		    unsigned char *buffertx,
55		    int datalen,
56		    enum req_type reqtype);
57
58int st95hf_spi_recv_response(struct st95hf_spi_context *spicontext,
59			     unsigned char *receivebuff);
60
61int st95hf_spi_recv_echo_res(struct st95hf_spi_context *spicontext,
62			     unsigned char *receivebuff);
63
64#endif