xref: /kernel/linux/linux-5.10/drivers/nfc/st95hf/spi.h (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * ---------------------------------------------------------------------------
48c2ecf20Sopenharmony_ci * drivers/nfc/st95hf/spi.h functions declarations for SPI communication
58c2ecf20Sopenharmony_ci * ---------------------------------------------------------------------------
68c2ecf20Sopenharmony_ci * Copyright (C) 2015 STMicroelectronics – All Rights Reserved
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __LINUX_ST95HF_SPI_H
108c2ecf20Sopenharmony_ci#define __LINUX_ST95HF_SPI_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/spi/spi.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/* Basic ST95HF SPI CMDs */
158c2ecf20Sopenharmony_ci#define ST95HF_COMMAND_SEND	0x0
168c2ecf20Sopenharmony_ci#define ST95HF_COMMAND_RESET	0x1
178c2ecf20Sopenharmony_ci#define ST95HF_COMMAND_RECEIVE	0x2
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define ST95HF_RESET_CMD_LEN	0x1
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci/*
228c2ecf20Sopenharmony_ci * structure to contain st95hf spi communication specific information.
238c2ecf20Sopenharmony_ci * @req_issync: true for synchronous calls.
248c2ecf20Sopenharmony_ci * @spidev: st95hf spi device object.
258c2ecf20Sopenharmony_ci * @done: completion structure to wait for st95hf response
268c2ecf20Sopenharmony_ci *	for synchronous calls.
278c2ecf20Sopenharmony_ci * @spi_lock: mutex to allow only one spi transfer at a time.
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_cistruct st95hf_spi_context {
308c2ecf20Sopenharmony_ci	bool req_issync;
318c2ecf20Sopenharmony_ci	struct spi_device *spidev;
328c2ecf20Sopenharmony_ci	struct completion done;
338c2ecf20Sopenharmony_ci	struct mutex spi_lock;
348c2ecf20Sopenharmony_ci};
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/* flag to differentiate synchronous & asynchronous spi request */
378c2ecf20Sopenharmony_cienum req_type {
388c2ecf20Sopenharmony_ci	SYNC,
398c2ecf20Sopenharmony_ci	ASYNC,
408c2ecf20Sopenharmony_ci};
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ciint st95hf_spi_send(struct st95hf_spi_context *spicontext,
438c2ecf20Sopenharmony_ci		    unsigned char *buffertx,
448c2ecf20Sopenharmony_ci		    int datalen,
458c2ecf20Sopenharmony_ci		    enum req_type reqtype);
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ciint st95hf_spi_recv_response(struct st95hf_spi_context *spicontext,
488c2ecf20Sopenharmony_ci			     unsigned char *receivebuff);
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ciint st95hf_spi_recv_echo_res(struct st95hf_spi_context *spicontext,
518c2ecf20Sopenharmony_ci			     unsigned char *receivebuff);
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#endif
54