linux/drivers/nfc/pn533/pn533.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Driver for NXP PN533 NFC Chip - core functions
 *
 * Copyright (C) 2011 Instituto Nokia de Tecnologia
 * Copyright (C) 2012-2013 Tieto Poland
 */

#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/nfc.h>
#include <linux/netdevice.h>
#include <net/nfc/nfc.h>
#include "pn533.h"

#define VERSION

/* How much time we spend listening for initiators */
#define PN533_LISTEN_TIME
/* Delay between each poll frame (ms) */
#define PN533_POLL_INTERVAL

/* structs for pn533 commands */

/* PN533_CMD_GET_FIRMWARE_VERSION */
struct pn533_fw_version {};

/* PN533_CMD_RF_CONFIGURATION */
#define PN533_CFGITEM_RF_FIELD
#define PN533_CFGITEM_TIMING
#define PN533_CFGITEM_MAX_RETRIES
#define PN533_CFGITEM_PASORI

#define PN533_CFGITEM_RF_FIELD_AUTO_RFCA
#define PN533_CFGITEM_RF_FIELD_ON
#define PN533_CFGITEM_RF_FIELD_OFF

#define PN533_CONFIG_TIMING_102
#define PN533_CONFIG_TIMING_204
#define PN533_CONFIG_TIMING_409
#define PN533_CONFIG_TIMING_819

#define PN533_CONFIG_MAX_RETRIES_NO_RETRY
#define PN533_CONFIG_MAX_RETRIES_ENDLESS

struct pn533_config_max_retries {} __packed;

struct pn533_config_timing {} __packed;

/* PN533_CMD_IN_LIST_PASSIVE_TARGET */

/* felica commands opcode */
#define PN533_FELICA_OPC_SENSF_REQ
#define PN533_FELICA_OPC_SENSF_RES
/* felica SENSF_REQ parameters */
#define PN533_FELICA_SENSF_SC_ALL
#define PN533_FELICA_SENSF_RC_NO_SYSTEM_CODE
#define PN533_FELICA_SENSF_RC_SYSTEM_CODE
#define PN533_FELICA_SENSF_RC_ADVANCED_PROTOCOL

/* type B initiator_data values */
#define PN533_TYPE_B_AFI_ALL_FAMILIES
#define PN533_TYPE_B_POLL_METHOD_TIMESLOT
#define PN533_TYPE_B_POLL_METHOD_PROBABILISTIC

pn533_cmd_poll_initdata;

struct pn533_poll_modulations {};

static const struct pn533_poll_modulations poll_mod[] =;

/* PN533_CMD_IN_ATR */

struct pn533_cmd_activate_response {} __packed;

struct pn533_cmd_jump_dep_response {} __packed;

struct pn532_autopoll_resp {};

/* PN532_CMD_IN_AUTOPOLL */
#define PN532_AUTOPOLL_POLLNR_INFINITE
#define PN532_AUTOPOLL_PERIOD

#define PN532_AUTOPOLL_TYPE_GENERIC_106
#define PN532_AUTOPOLL_TYPE_GENERIC_212
#define PN532_AUTOPOLL_TYPE_GENERIC_424
#define PN532_AUTOPOLL_TYPE_JEWEL
#define PN532_AUTOPOLL_TYPE_MIFARE
#define PN532_AUTOPOLL_TYPE_FELICA212
#define PN532_AUTOPOLL_TYPE_FELICA424
#define PN532_AUTOPOLL_TYPE_ISOA
#define PN532_AUTOPOLL_TYPE_ISOB
#define PN532_AUTOPOLL_TYPE_DEP_PASSIVE_106
#define PN532_AUTOPOLL_TYPE_DEP_PASSIVE_212
#define PN532_AUTOPOLL_TYPE_DEP_PASSIVE_424
#define PN532_AUTOPOLL_TYPE_DEP_ACTIVE_106
#define PN532_AUTOPOLL_TYPE_DEP_ACTIVE_212
#define PN532_AUTOPOLL_TYPE_DEP_ACTIVE_424

/* PN533_TG_INIT_AS_TARGET */
#define PN533_INIT_TARGET_PASSIVE
#define PN533_INIT_TARGET_DEP

#define PN533_INIT_TARGET_RESP_FRAME_MASK
#define PN533_INIT_TARGET_RESP_ACTIVE
#define PN533_INIT_TARGET_RESP_DEP

/* The rule: value(high byte) + value(low byte) + checksum = 0 */
static inline u8 pn533_ext_checksum(u16 value)
{}

/* The rule: value + checksum = 0 */
static inline u8 pn533_std_checksum(u8 value)
{}

/* The rule: sum(data elements) + checksum = 0 */
static u8 pn533_std_data_checksum(u8 *data, int datalen)
{}

static void pn533_std_tx_frame_init(void *_frame, u8 cmd_code)
{}

static void pn533_std_tx_frame_finish(void *_frame)
{}

static void pn533_std_tx_update_payload_len(void *_frame, int len)
{}

static bool pn533_std_rx_frame_is_valid(void *_frame, struct pn533 *dev)
{}

bool pn533_rx_frame_is_ack(void *_frame)
{}
EXPORT_SYMBOL_GPL();

static inline int pn533_std_rx_frame_size(void *frame)
{}

static u8 pn533_std_get_cmd_code(void *frame)
{}

bool pn533_rx_frame_is_cmd_response(struct pn533 *dev, void *frame)
{}
EXPORT_SYMBOL_GPL();


static struct pn533_frame_ops pn533_std_frame_ops =;

static void pn533_build_cmd_frame(struct pn533 *dev, u8 cmd_code,
				  struct sk_buff *skb)
{}

static int pn533_send_async_complete(struct pn533 *dev)
{}

static int __pn533_send_async(struct pn533 *dev, u8 cmd_code,
			      struct sk_buff *req,
			      pn533_send_async_complete_t complete_cb,
			      void *complete_cb_context)
{}

static int pn533_send_data_async(struct pn533 *dev, u8 cmd_code,
				 struct sk_buff *req,
				 pn533_send_async_complete_t complete_cb,
				 void *complete_cb_context)
{}

static int pn533_send_cmd_async(struct pn533 *dev, u8 cmd_code,
				struct sk_buff *req,
				pn533_send_async_complete_t complete_cb,
				void *complete_cb_context)
{}

/*
 * pn533_send_cmd_direct_async
 *
 * The function sends a priority cmd directly to the chip omitting the cmd
 * queue. It's intended to be used by chaining mechanism of received responses
 * where the host has to request every single chunk of data before scheduling
 * next cmd from the queue.
 */
static int pn533_send_cmd_direct_async(struct pn533 *dev, u8 cmd_code,
				       struct sk_buff *req,
				       pn533_send_async_complete_t complete_cb,
				       void *complete_cb_context)
{}

static void pn533_wq_cmd_complete(struct work_struct *work)
{}

static void pn533_wq_cmd(struct work_struct *work)
{}

struct pn533_sync_cmd_response {};

static int pn533_send_sync_complete(struct pn533 *dev, void *_arg,
				    struct sk_buff *resp)
{}

/*  pn533_send_cmd_sync
 *
 *  Please note the req parameter is freed inside the function to
 *  limit a number of return value interpretations by the caller.
 *
 *  1. negative in case of error during TX path -> req should be freed
 *
 *  2. negative in case of error during RX path -> req should not be freed
 *     as it's been already freed at the beginning of RX path by
 *     async_complete_cb.
 *
 *  3. valid pointer in case of successful RX path
 *
 *  A caller has to check a return value with IS_ERR macro. If the test pass,
 *  the returned pointer is valid.
 *
 */
static struct sk_buff *pn533_send_cmd_sync(struct pn533 *dev, u8 cmd_code,
					       struct sk_buff *req)
{}

static struct sk_buff *pn533_alloc_skb(struct pn533 *dev, unsigned int size)
{}

struct pn533_target_type_a {} __packed;


#define PN533_TYPE_A_SENS_RES_NFCID1(x)
#define PN533_TYPE_A_SENS_RES_SSD(x)
#define PN533_TYPE_A_SENS_RES_PLATCONF(x)

#define PN533_TYPE_A_SENS_RES_SSD_JEWEL
#define PN533_TYPE_A_SENS_RES_PLATCONF_JEWEL

#define PN533_TYPE_A_SEL_PROT(x)
#define PN533_TYPE_A_SEL_CASCADE(x)

#define PN533_TYPE_A_SEL_PROT_MIFARE
#define PN533_TYPE_A_SEL_PROT_ISO14443
#define PN533_TYPE_A_SEL_PROT_DEP
#define PN533_TYPE_A_SEL_PROT_ISO14443_DEP

static bool pn533_target_type_a_is_valid(struct pn533_target_type_a *type_a,
							int target_data_len)
{}

static int pn533_target_found_type_a(struct nfc_target *nfc_tgt, u8 *tgt_data,
							int tgt_data_len)
{}

struct pn533_target_felica {} __packed;

#define PN533_FELICA_SENSF_NFCID2_DEP_B1
#define PN533_FELICA_SENSF_NFCID2_DEP_B2

static bool pn533_target_felica_is_valid(struct pn533_target_felica *felica,
							int target_data_len)
{}

static int pn533_target_found_felica(struct nfc_target *nfc_tgt, u8 *tgt_data,
							int tgt_data_len)
{}

struct pn533_target_jewel {} __packed;

static bool pn533_target_jewel_is_valid(struct pn533_target_jewel *jewel,
							int target_data_len)
{}

static int pn533_target_found_jewel(struct nfc_target *nfc_tgt, u8 *tgt_data,
							int tgt_data_len)
{}

struct pn533_type_b_prot_info {} __packed;

#define PN533_TYPE_B_PROT_FCSI(x)
#define PN533_TYPE_B_PROT_TYPE(x)
#define PN533_TYPE_B_PROT_TYPE_RFU_MASK

struct pn533_type_b_sens_res {} __packed;

#define PN533_TYPE_B_OPC_SENSB_RES

struct pn533_target_type_b {} __packed;

static bool pn533_target_type_b_is_valid(struct pn533_target_type_b *type_b,
							int target_data_len)
{}

static int pn533_target_found_type_b(struct nfc_target *nfc_tgt, u8 *tgt_data,
							int tgt_data_len)
{}

static void pn533_poll_reset_mod_list(struct pn533 *dev);
static int pn533_target_found(struct pn533 *dev, u8 tg, u8 *tgdata,
			      int tgdata_len)
{}

static inline void pn533_poll_next_mod(struct pn533 *dev)
{}

static void pn533_poll_reset_mod_list(struct pn533 *dev)
{}

static void pn533_poll_add_mod(struct pn533 *dev, u8 mod_index)
{}

static void pn533_poll_create_mod_list(struct pn533 *dev,
				       u32 im_protocols, u32 tm_protocols)
{}

static int pn533_start_poll_complete(struct pn533 *dev, struct sk_buff *resp)
{}

static struct sk_buff *pn533_alloc_poll_tg_frame(struct pn533 *dev)
{}

static void pn533_wq_tm_mi_recv(struct work_struct *work);
static struct sk_buff *pn533_build_response(struct pn533 *dev);

static int pn533_tm_get_data_complete(struct pn533 *dev, void *arg,
				      struct sk_buff *resp)
{}

static void pn533_wq_tm_mi_recv(struct work_struct *work)
{}

static int pn533_tm_send_complete(struct pn533 *dev, void *arg,
				  struct sk_buff *resp);
static void pn533_wq_tm_mi_send(struct work_struct *work)
{}

static void pn533_wq_tg_get_data(struct work_struct *work)
{}

#define ATR_REQ_GB_OFFSET
static int pn533_init_target_complete(struct pn533 *dev, struct sk_buff *resp)
{}

static void pn533_listen_mode_timer(struct timer_list *t)
{}

static int pn533_rf_complete(struct pn533 *dev, void *arg,
			     struct sk_buff *resp)
{}

static void pn533_wq_rf(struct work_struct *work)
{}

static int pn533_poll_dep_complete(struct pn533 *dev, void *arg,
				   struct sk_buff *resp)
{}

#define PASSIVE_DATA_LEN
static int pn533_poll_dep(struct nfc_dev *nfc_dev)
{}

static int pn533_autopoll_complete(struct pn533 *dev, void *arg,
			       struct sk_buff *resp)
{}

static int pn533_poll_complete(struct pn533 *dev, void *arg,
			       struct sk_buff *resp)
{}

static struct sk_buff *pn533_alloc_poll_in_frame(struct pn533 *dev,
					struct pn533_poll_modulations *mod)
{}

static int pn533_send_poll_frame(struct pn533 *dev)
{}

static void pn533_wq_poll(struct work_struct *work)
{}

static int pn533_start_poll(struct nfc_dev *nfc_dev,
			    u32 im_protocols, u32 tm_protocols)
{}

static void pn533_stop_poll(struct nfc_dev *nfc_dev)
{}

static int pn533_activate_target_nfcdep(struct pn533 *dev)
{}

static int pn533_activate_target(struct nfc_dev *nfc_dev,
				 struct nfc_target *target, u32 protocol)
{}

static int pn533_deactivate_target_complete(struct pn533 *dev, void *arg,
			     struct sk_buff *resp)
{}

static void pn533_deactivate_target(struct nfc_dev *nfc_dev,
				    struct nfc_target *target, u8 mode)
{}


static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg,
					 struct sk_buff *resp)
{}

static int pn533_rf_field(struct nfc_dev *nfc_dev, u8 rf);
static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
			     u8 comm_mode, u8 *gb, size_t gb_len)
{}

static int pn533_dep_link_down(struct nfc_dev *nfc_dev)
{}

struct pn533_data_exchange_arg {};

static struct sk_buff *pn533_build_response(struct pn533 *dev)
{}

static int pn533_data_exchange_complete(struct pn533 *dev, void *_arg,
					struct sk_buff *resp)
{}

/*
 * Receive an incoming pn533 frame. skb contains only header and payload.
 * If skb == NULL, it is a notification that the link below is dead.
 */
void pn533_recv_frame(struct pn533 *dev, struct sk_buff *skb, int status)
{}
EXPORT_SYMBOL();

/* Split the Tx skb into small chunks */
static int pn533_fill_fragment_skbs(struct pn533 *dev, struct sk_buff *skb)
{}

static int pn533_transceive(struct nfc_dev *nfc_dev,
			    struct nfc_target *target, struct sk_buff *skb,
			    data_exchange_cb_t cb, void *cb_context)
{}

static int pn533_tm_send_complete(struct pn533 *dev, void *arg,
				  struct sk_buff *resp)
{}

static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb)
{}

static void pn533_wq_mi_recv(struct work_struct *work)
{}

static void pn533_wq_mi_send(struct work_struct *work)
{}

static int pn533_set_configuration(struct pn533 *dev, u8 cfgitem, u8 *cfgdata,
								u8 cfgdata_len)
{}

static int pn533_get_firmware_version(struct pn533 *dev,
				      struct pn533_fw_version *fv)
{}

static int pn533_pasori_fw_reset(struct pn533 *dev)
{}

static int pn533_rf_field(struct nfc_dev *nfc_dev, u8 rf)
{}

static int pn532_sam_configuration(struct nfc_dev *nfc_dev)
{}

static int pn533_dev_up(struct nfc_dev *nfc_dev)
{}

static int pn533_dev_down(struct nfc_dev *nfc_dev)
{}

static const struct nfc_ops pn533_nfc_ops =;

static int pn533_setup(struct pn533 *dev)
{}

int pn533_finalize_setup(struct pn533 *dev)
{}
EXPORT_SYMBOL_GPL();

struct pn533 *pn53x_common_init(u32 device_type,
				enum pn533_protocol_type protocol_type,
				void *phy,
				const struct pn533_phy_ops *phy_ops,
				struct pn533_frame_ops *fops,
				struct device *dev)
{}
EXPORT_SYMBOL_GPL();

void pn53x_common_clean(struct pn533 *priv)
{}
EXPORT_SYMBOL_GPL();

int pn532_i2c_nfc_alloc(struct pn533 *priv, u32 protocols,
			struct device *parent)
{}
EXPORT_SYMBOL_GPL();

int pn53x_register_nfc(struct pn533 *priv, u32 protocols,
			struct device *parent)
{}
EXPORT_SYMBOL_GPL();

void pn53x_unregister_nfc(struct pn533 *priv)
{}
EXPORT_SYMBOL_GPL();

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