linux/drivers/nfc/st95hf/core.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * --------------------------------------------------------------------
 * Driver for ST NFC Transceiver ST95HF
 * --------------------------------------------------------------------
 * Copyright (C) 2015 STMicroelectronics Pvt. Ltd. All rights reserved.
 */

#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/nfc.h>
#include <linux/of.h>
#include <linux/property.h>
#include <linux/regulator/consumer.h>
#include <linux/wait.h>
#include <net/nfc/digital.h>
#include <net/nfc/nfc.h>

#include "spi.h"

/* supported protocols */
#define ST95HF_SUPPORTED_PROT
/* driver capabilities */
#define ST95HF_CAPABILITIES

/* Command Send Interface */
/* ST95HF_COMMAND_SEND CMD Ids */
#define ECHO_CMD
#define WRITE_REGISTER_CMD
#define PROTOCOL_SELECT_CMD
#define SEND_RECEIVE_CMD

/* Select protocol codes */
#define ISO15693_PROTOCOL_CODE
#define ISO14443A_PROTOCOL_CODE
#define ISO14443B_PROTOCOL_CODE

/*
 * head room len is 3
 * 1 byte for control byte
 * 1 byte for cmd
 * 1 byte for size
 */
#define ST95HF_HEADROOM_LEN

/*
 * tailroom is 1 for ISO14443A
 * and 0 for ISO14443B/ISO15693,
 * hence the max value 1 should be
 * taken.
 */
#define ST95HF_TAILROOM_LEN

/* Command Response interface */
#define MAX_RESPONSE_BUFFER_SIZE
#define ECHORESPONSE
#define ST95HF_ERR_MASK
#define ST95HF_TIMEOUT_ERROR
#define ST95HF_NFCA_CRC_ERR_MASK
#define ST95HF_NFCB_CRC_ERR_MASK

/* ST95HF transmission flag values */
#define TRFLAG_NFCA_SHORT_FRAME
#define TRFLAG_NFCA_STD_FRAME
#define TRFLAG_NFCA_STD_FRAME_CRC

/* Misc defs */
#define HIGH
#define LOW
#define ISO14443A_RATS_REQ
#define RATS_TB1_PRESENT_MASK
#define RATS_TA1_PRESENT_MASK
#define TB1_FWI_MASK
#define WTX_REQ_FROM_TAG

#define MAX_CMD_LEN

#define MAX_CMD_PARAMS
struct cmd {};

struct param_list {};

/*
 * List of top-level cmds to be used internally by the driver.
 * All these commands are build on top of ST95HF basic commands
 * such as SEND_RECEIVE_CMD, PROTOCOL_SELECT_CMD, etc.
 * These top level cmds are used internally while implementing various ops of
 * digital layer/driver probe or extending the digital framework layer for
 * features that are not yet implemented there, for example, WTX cmd handling.
 */
enum st95hf_cmd_list {};

static const struct cmd cmd_array[] =;

/* st95_digital_cmd_complete_arg stores client context */
struct st95_digital_cmd_complete_arg {};

/*
 * structure containing ST95HF driver specific data.
 * @spicontext: structure containing information required
 *	for spi communication between st95hf and host.
 * @ddev: nfc digital device object.
 * @nfcdev: nfc device object.
 * @enable_gpiod: gpio used to enable st95hf transceiver.
 * @complete_cb_arg: structure to store various context information
 *	that is passed from nfc requesting thread to the threaded ISR.
 * @st95hf_supply: regulator "consumer" for NFC device.
 * @sendrcv_trflag: last byte of frame send by sendrecv command
 *	of st95hf. This byte contains transmission flag info.
 * @exchange_lock: semaphore used for signaling the st95hf_remove
 *	function that the last outstanding async nfc request is finished.
 * @rm_lock: mutex for ensuring safe access of nfc digital object
 *	from threaded ISR. Usage of this mutex avoids any race between
 *	deletion of the object from st95hf_remove() and its access from
 *	the threaded ISR.
 * @nfcdev_free: flag to have the state of nfc device object.
 *	[alive | died]
 * @current_protocol: current nfc protocol.
 * @current_rf_tech: current rf technology.
 * @fwi: frame waiting index, received in reply of RATS according to
 *	digital protocol.
 */
struct st95hf_context {};

/*
 * st95hf_send_recv_cmd() is for sending commands to ST95HF
 * that are described in the cmd_array[]. It can optionally
 * receive the response if the cmd request is of type
 * SYNC. For that to happen caller must pass true to recv_res.
 * For ASYNC request, recv_res is ignored and the
 * function will never try to receive the response on behalf
 * of the caller.
 */
static int st95hf_send_recv_cmd(struct st95hf_context *st95context,
				enum st95hf_cmd_list cmd,
				int no_modif,
				struct param_list *list_array,
				bool recv_res)
{}

static int st95hf_echo_command(struct st95hf_context *st95context)
{}

static int secondary_configuration_type4a(struct st95hf_context *stcontext)
{}

static int secondary_configuration_type4b(struct st95hf_context *stcontext)
{}

static int st95hf_select_protocol(struct st95hf_context *stcontext, int type)
{}

static void st95hf_send_st95enable_negativepulse(struct st95hf_context *st95con)
{}

/*
 * Send a reset sequence over SPI bus (Reset command + wait 3ms +
 * negative pulse on st95hf enable gpio
 */
static int st95hf_send_spi_reset_sequence(struct st95hf_context *st95context)
{}

static int st95hf_por_sequence(struct st95hf_context *st95context)
{}

static int iso14443_config_fdt(struct st95hf_context *st95context, int wtxm)
{}

static int st95hf_handle_wtx(struct st95hf_context *stcontext,
			     bool new_wtx,
			     int wtx_val)
{}

static int st95hf_error_handling(struct st95hf_context *stcontext,
				 struct sk_buff *skb_resp,
				 int res_len)
{}

static int st95hf_response_handler(struct st95hf_context *stcontext,
				   struct sk_buff *skb_resp,
				   int res_len)
{}

static irqreturn_t st95hf_irq_handler(int irq, void  *st95hfcontext)
{}

static irqreturn_t st95hf_irq_thread_handler(int irq, void  *st95hfcontext)
{}

/* NFC ops functions definition */
static int st95hf_in_configure_hw(struct nfc_digital_dev *ddev,
				  int type,
				  int param)
{}

static int rf_off(struct st95hf_context *stcontext)
{}

static int st95hf_in_send_cmd(struct nfc_digital_dev *ddev,
			      struct sk_buff *skb,
			      u16 timeout,
			      nfc_digital_cmd_complete_t cb,
			      void *arg)
{}

/* p2p will be supported in a later release ! */
static int st95hf_tg_configure_hw(struct nfc_digital_dev *ddev,
				  int type,
				  int param)
{}

static int st95hf_tg_send_cmd(struct nfc_digital_dev *ddev,
			      struct sk_buff *skb,
			      u16 timeout,
			      nfc_digital_cmd_complete_t cb,
			      void *arg)
{}

static int st95hf_tg_listen(struct nfc_digital_dev *ddev,
			    u16 timeout,
			    nfc_digital_cmd_complete_t cb,
			    void *arg)
{}

static int st95hf_tg_get_rf_tech(struct nfc_digital_dev *ddev, u8 *rf_tech)
{}

static int st95hf_switch_rf(struct nfc_digital_dev *ddev, bool on)
{}

/* TODO st95hf_abort_cmd */
static void st95hf_abort_cmd(struct nfc_digital_dev *ddev)
{}

static const struct nfc_digital_ops st95hf_nfc_digital_ops =;

static const struct spi_device_id st95hf_id[] =;
MODULE_DEVICE_TABLE(spi, st95hf_id);

static const struct of_device_id st95hf_spi_of_match[] __maybe_unused =;
MODULE_DEVICE_TABLE(of, st95hf_spi_of_match);

static int st95hf_probe(struct spi_device *nfc_spi_dev)
{}

static void st95hf_remove(struct spi_device *nfc_spi_dev)
{}

/* Register as SPI protocol driver */
static struct spi_driver st95hf_driver =;

module_spi_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();