#include <linux/module.h>
#include <linux/device.h>
#include <linux/netdevice.h>
#include <linux/interrupt.h>
#include <linux/pm_runtime.h>
#include <linux/nfc.h>
#include <linux/skbuff.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/of.h>
#include <linux/spi/spi.h>
#include <linux/regulator/consumer.h>
#include <net/nfc/nfc.h>
#include <net/nfc/digital.h>
#define TRF7970A_SUPPORTED_PROTOCOLS …
#define TRF7970A_AUTOSUSPEND_DELAY …
#define TRF7970A_13MHZ_CLOCK_FREQUENCY …
#define TRF7970A_27MHZ_CLOCK_FREQUENCY …
#define TRF7970A_RX_SKB_ALLOC_SIZE …
#define TRF7970A_FIFO_SIZE …
#define TRF7970A_TX_MAX …
#define TRF7970A_WAIT_FOR_TX_IRQ …
#define TRF7970A_WAIT_FOR_RX_DATA_TIMEOUT …
#define TRF7970A_WAIT_FOR_FIFO_DRAIN_TIMEOUT …
#define TRF7970A_WAIT_TO_ISSUE_ISO15693_EOF …
#define TRF7970A_GUARD_TIME_NFCA …
#define TRF7970A_GUARD_TIME_NFCB …
#define TRF7970A_GUARD_TIME_NFCF …
#define TRF7970A_GUARD_TIME_15693 …
#define TRF7970A_QUIRK_IRQ_STATUS_READ …
#define TRF7970A_QUIRK_EN2_MUST_STAY_LOW …
#define TRF7970A_CMD_IDLE …
#define TRF7970A_CMD_SOFT_INIT …
#define TRF7970A_CMD_RF_COLLISION …
#define TRF7970A_CMD_RF_COLLISION_RESPONSE_N …
#define TRF7970A_CMD_RF_COLLISION_RESPONSE_0 …
#define TRF7970A_CMD_FIFO_RESET …
#define TRF7970A_CMD_TRANSMIT_NO_CRC …
#define TRF7970A_CMD_TRANSMIT …
#define TRF7970A_CMD_DELAY_TRANSMIT_NO_CRC …
#define TRF7970A_CMD_DELAY_TRANSMIT …
#define TRF7970A_CMD_EOF …
#define TRF7970A_CMD_CLOSE_SLOT …
#define TRF7970A_CMD_BLOCK_RX …
#define TRF7970A_CMD_ENABLE_RX …
#define TRF7970A_CMD_TEST_INT_RF …
#define TRF7970A_CMD_TEST_EXT_RF …
#define TRF7970A_CMD_RX_GAIN_ADJUST …
#define TRF7970A_CMD_BIT_CTRL …
#define TRF7970A_CMD_BIT_RW …
#define TRF7970A_CMD_BIT_CONTINUOUS …
#define TRF7970A_CMD_BIT_OPCODE(opcode) …
#define TRF7970A_CHIP_STATUS_CTRL …
#define TRF7970A_ISO_CTRL …
#define TRF7970A_ISO14443B_TX_OPTIONS …
#define TRF7970A_ISO14443A_HIGH_BITRATE_OPTIONS …
#define TRF7970A_TX_TIMER_SETTING_H_BYTE …
#define TRF7970A_TX_TIMER_SETTING_L_BYTE …
#define TRF7970A_TX_PULSE_LENGTH_CTRL …
#define TRF7970A_RX_NO_RESPONSE_WAIT …
#define TRF7970A_RX_WAIT_TIME …
#define TRF7970A_MODULATOR_SYS_CLK_CTRL …
#define TRF7970A_RX_SPECIAL_SETTINGS …
#define TRF7970A_REG_IO_CTRL …
#define TRF7970A_IRQ_STATUS …
#define TRF7970A_COLLISION_IRQ_MASK …
#define TRF7970A_COLLISION_POSITION …
#define TRF7970A_RSSI_OSC_STATUS …
#define TRF7970A_SPECIAL_FCN_REG1 …
#define TRF7970A_SPECIAL_FCN_REG2 …
#define TRF7970A_RAM1 …
#define TRF7970A_RAM2 …
#define TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS …
#define TRF7970A_NFC_LOW_FIELD_LEVEL …
#define TRF7970A_NFCID1 …
#define TRF7970A_NFC_TARGET_LEVEL …
#define TRF79070A_NFC_TARGET_PROTOCOL …
#define TRF7970A_TEST_REGISTER1 …
#define TRF7970A_TEST_REGISTER2 …
#define TRF7970A_FIFO_STATUS …
#define TRF7970A_TX_LENGTH_BYTE1 …
#define TRF7970A_TX_LENGTH_BYTE2 …
#define TRF7970A_FIFO_IO_REGISTER …
#define TRF7970A_CHIP_STATUS_VRS5_3 …
#define TRF7970A_CHIP_STATUS_REC_ON …
#define TRF7970A_CHIP_STATUS_AGC_ON …
#define TRF7970A_CHIP_STATUS_PM_ON …
#define TRF7970A_CHIP_STATUS_RF_PWR …
#define TRF7970A_CHIP_STATUS_RF_ON …
#define TRF7970A_CHIP_STATUS_DIRECT …
#define TRF7970A_CHIP_STATUS_STBY …
#define TRF7970A_ISO_CTRL_15693_SGL_1OF4_662 …
#define TRF7970A_ISO_CTRL_15693_SGL_1OF256_662 …
#define TRF7970A_ISO_CTRL_15693_SGL_1OF4_2648 …
#define TRF7970A_ISO_CTRL_15693_SGL_1OF256_2648 …
#define TRF7970A_ISO_CTRL_15693_DBL_1OF4_667a …
#define TRF7970A_ISO_CTRL_15693_DBL_1OF256_667 …
#define TRF7970A_ISO_CTRL_15693_DBL_1OF4_2669 …
#define TRF7970A_ISO_CTRL_15693_DBL_1OF256_2669 …
#define TRF7970A_ISO_CTRL_14443A_106 …
#define TRF7970A_ISO_CTRL_14443A_212 …
#define TRF7970A_ISO_CTRL_14443A_424 …
#define TRF7970A_ISO_CTRL_14443A_848 …
#define TRF7970A_ISO_CTRL_14443B_106 …
#define TRF7970A_ISO_CTRL_14443B_212 …
#define TRF7970A_ISO_CTRL_14443B_424 …
#define TRF7970A_ISO_CTRL_14443B_848 …
#define TRF7970A_ISO_CTRL_FELICA_212 …
#define TRF7970A_ISO_CTRL_FELICA_424 …
#define TRF7970A_ISO_CTRL_NFC_NFCA_106 …
#define TRF7970A_ISO_CTRL_NFC_NFCF_212 …
#define TRF7970A_ISO_CTRL_NFC_NFCF_424 …
#define TRF7970A_ISO_CTRL_NFC_CE_14443A …
#define TRF7970A_ISO_CTRL_NFC_CE_14443B …
#define TRF7970A_ISO_CTRL_NFC_CE …
#define TRF7970A_ISO_CTRL_NFC_ACTIVE …
#define TRF7970A_ISO_CTRL_NFC_INITIATOR …
#define TRF7970A_ISO_CTRL_NFC_NFC_CE_MODE …
#define TRF7970A_ISO_CTRL_RFID …
#define TRF7970A_ISO_CTRL_DIR_MODE …
#define TRF7970A_ISO_CTRL_RX_CRC_N …
#define TRF7970A_ISO_CTRL_RFID_SPEED_MASK …
#define TRF7970A_MODULATOR_DEPTH(n) …
#define TRF7970A_MODULATOR_DEPTH_ASK10 …
#define TRF7970A_MODULATOR_DEPTH_OOK …
#define TRF7970A_MODULATOR_DEPTH_ASK7 …
#define TRF7970A_MODULATOR_DEPTH_ASK8_5 …
#define TRF7970A_MODULATOR_DEPTH_ASK13 …
#define TRF7970A_MODULATOR_DEPTH_ASK16 …
#define TRF7970A_MODULATOR_DEPTH_ASK22 …
#define TRF7970A_MODULATOR_DEPTH_ASK30 …
#define TRF7970A_MODULATOR_EN_ANA …
#define TRF7970A_MODULATOR_CLK(n) …
#define TRF7970A_MODULATOR_CLK_DISABLED …
#define TRF7970A_MODULATOR_CLK_3_6 …
#define TRF7970A_MODULATOR_CLK_6_13 …
#define TRF7970A_MODULATOR_CLK_13_27 …
#define TRF7970A_MODULATOR_EN_OOK …
#define TRF7970A_MODULATOR_27MHZ …
#define TRF7970A_RX_SPECIAL_SETTINGS_NO_LIM …
#define TRF7970A_RX_SPECIAL_SETTINGS_AGCR …
#define TRF7970A_RX_SPECIAL_SETTINGS_GD_0DB …
#define TRF7970A_RX_SPECIAL_SETTINGS_GD_5DB …
#define TRF7970A_RX_SPECIAL_SETTINGS_GD_10DB …
#define TRF7970A_RX_SPECIAL_SETTINGS_GD_15DB …
#define TRF7970A_RX_SPECIAL_SETTINGS_HBT …
#define TRF7970A_RX_SPECIAL_SETTINGS_M848 …
#define TRF7970A_RX_SPECIAL_SETTINGS_C424 …
#define TRF7970A_RX_SPECIAL_SETTINGS_C212 …
#define TRF7970A_REG_IO_CTRL_VRS(v) …
#define TRF7970A_REG_IO_CTRL_IO_LOW …
#define TRF7970A_REG_IO_CTRL_EN_EXT_PA …
#define TRF7970A_REG_IO_CTRL_AUTO_REG …
#define TRF7970A_IRQ_STATUS_NORESP …
#define TRF7970A_IRQ_STATUS_NFC_COL_ERROR …
#define TRF7970A_IRQ_STATUS_COL …
#define TRF7970A_IRQ_STATUS_FRAMING_EOF_ERROR …
#define TRF7970A_IRQ_STATUS_NFC_RF …
#define TRF7970A_IRQ_STATUS_PARITY_ERROR …
#define TRF7970A_IRQ_STATUS_NFC_SDD …
#define TRF7970A_IRQ_STATUS_CRC_ERROR …
#define TRF7970A_IRQ_STATUS_NFC_PROTO_ERROR …
#define TRF7970A_IRQ_STATUS_FIFO …
#define TRF7970A_IRQ_STATUS_SRX …
#define TRF7970A_IRQ_STATUS_TX …
#define TRF7970A_IRQ_STATUS_ERROR …
#define TRF7970A_RSSI_OSC_STATUS_RSSI_MASK …
#define TRF7970A_RSSI_OSC_STATUS_RSSI_X_MASK …
#define TRF7970A_RSSI_OSC_STATUS_RSSI_OSC_OK …
#define TRF7970A_SPECIAL_FCN_REG1_COL_7_6 …
#define TRF7970A_SPECIAL_FCN_REG1_14_ANTICOLL …
#define TRF7970A_SPECIAL_FCN_REG1_4_BIT_RX …
#define TRF7970A_SPECIAL_FCN_REG1_SP_DIR_MODE …
#define TRF7970A_SPECIAL_FCN_REG1_NEXT_SLOT_37US …
#define TRF7970A_SPECIAL_FCN_REG1_PAR43 …
#define TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLH_124 …
#define TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLH_120 …
#define TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLH_112 …
#define TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLH_96 …
#define TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLL_4 …
#define TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLL_8 …
#define TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLL_16 …
#define TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLL_32 …
#define TRF7970A_NFC_LOW_FIELD_LEVEL_RFDET(v) …
#define TRF7970A_NFC_LOW_FIELD_LEVEL_CLEX_DIS …
#define TRF7970A_NFC_TARGET_LEVEL_RFDET(v) …
#define TRF7970A_NFC_TARGET_LEVEL_HI_RF …
#define TRF7970A_NFC_TARGET_LEVEL_SDD_EN …
#define TRF7970A_NFC_TARGET_LEVEL_LD_S_4BYTES …
#define TRF7970A_NFC_TARGET_LEVEL_LD_S_7BYTES …
#define TRF7970A_NFC_TARGET_LEVEL_LD_S_10BYTES …
#define TRF79070A_NFC_TARGET_PROTOCOL_NFCBR_106 …
#define TRF79070A_NFC_TARGET_PROTOCOL_NFCBR_212 …
#define TRF79070A_NFC_TARGET_PROTOCOL_NFCBR_424 …
#define TRF79070A_NFC_TARGET_PROTOCOL_PAS_14443B …
#define TRF79070A_NFC_TARGET_PROTOCOL_PAS_106 …
#define TRF79070A_NFC_TARGET_PROTOCOL_FELICA …
#define TRF79070A_NFC_TARGET_PROTOCOL_RF_L …
#define TRF79070A_NFC_TARGET_PROTOCOL_RF_H …
#define TRF79070A_NFC_TARGET_PROTOCOL_106A …
#define TRF79070A_NFC_TARGET_PROTOCOL_106B …
#define TRF79070A_NFC_TARGET_PROTOCOL_212F …
#define TRF79070A_NFC_TARGET_PROTOCOL_424F …
#define TRF7970A_FIFO_STATUS_OVERFLOW …
#define NFC_T2T_CMD_READ …
#define ISO15693_CMD_INVENTORY …
#define ISO15693_CMD_READ_SINGLE_BLOCK …
#define ISO15693_CMD_WRITE_SINGLE_BLOCK …
#define ISO15693_CMD_LOCK_BLOCK …
#define ISO15693_CMD_READ_MULTIPLE_BLOCK …
#define ISO15693_CMD_WRITE_MULTIPLE_BLOCK …
#define ISO15693_CMD_SELECT …
#define ISO15693_CMD_RESET_TO_READY …
#define ISO15693_CMD_WRITE_AFI …
#define ISO15693_CMD_LOCK_AFI …
#define ISO15693_CMD_WRITE_DSFID …
#define ISO15693_CMD_LOCK_DSFID …
#define ISO15693_CMD_GET_SYSTEM_INFO …
#define ISO15693_CMD_GET_MULTIPLE_BLOCK_SECURITY_STATUS …
#define ISO15693_REQ_FLAG_SUB_CARRIER …
#define ISO15693_REQ_FLAG_DATA_RATE …
#define ISO15693_REQ_FLAG_INVENTORY …
#define ISO15693_REQ_FLAG_PROTOCOL_EXT …
#define ISO15693_REQ_FLAG_SELECT …
#define ISO15693_REQ_FLAG_AFI …
#define ISO15693_REQ_FLAG_ADDRESS …
#define ISO15693_REQ_FLAG_NB_SLOTS …
#define ISO15693_REQ_FLAG_OPTION …
#define ISO15693_REQ_FLAG_SPEED_MASK …
enum trf7970a_state { … };
struct trf7970a { … };
static int trf7970a_cmd(struct trf7970a *trf, u8 opcode)
{ … }
static int trf7970a_read(struct trf7970a *trf, u8 reg, u8 *val)
{ … }
static int trf7970a_read_cont(struct trf7970a *trf, u8 reg, u8 *buf,
size_t len)
{ … }
static int trf7970a_write(struct trf7970a *trf, u8 reg, u8 val)
{ … }
static int trf7970a_read_irqstatus(struct trf7970a *trf, u8 *status)
{ … }
static int trf7970a_read_target_proto(struct trf7970a *trf, u8 *target_proto)
{ … }
static int trf7970a_mode_detect(struct trf7970a *trf, u8 *rf_tech)
{ … }
static void trf7970a_send_upstream(struct trf7970a *trf)
{ … }
static void trf7970a_send_err_upstream(struct trf7970a *trf, int errno)
{ … }
static int trf7970a_transmit(struct trf7970a *trf, struct sk_buff *skb,
unsigned int len, const u8 *prefix,
unsigned int prefix_len)
{ … }
static void trf7970a_fill_fifo(struct trf7970a *trf)
{ … }
static void trf7970a_drain_fifo(struct trf7970a *trf, u8 status)
{ … }
static irqreturn_t trf7970a_irq(int irq, void *dev_id)
{ … }
static void trf7970a_issue_eof(struct trf7970a *trf)
{ … }
static void trf7970a_timeout_work_handler(struct work_struct *work)
{ … }
static int trf7970a_init(struct trf7970a *trf)
{ … }
static void trf7970a_switch_rf_off(struct trf7970a *trf)
{ … }
static int trf7970a_switch_rf_on(struct trf7970a *trf)
{ … }
static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
{ … }
static int trf7970a_in_config_rf_tech(struct trf7970a *trf, int tech)
{ … }
static int trf7970a_is_rf_field(struct trf7970a *trf, bool *is_rf_field)
{ … }
static int trf7970a_in_config_framing(struct trf7970a *trf, int framing)
{ … }
static int trf7970a_in_configure_hw(struct nfc_digital_dev *ddev, int type,
int param)
{ … }
static int trf7970a_is_iso15693_write_or_lock(u8 cmd)
{ … }
static int trf7970a_per_cmd_config(struct trf7970a *trf,
const struct sk_buff *skb)
{ … }
static int trf7970a_send_cmd(struct nfc_digital_dev *ddev,
struct sk_buff *skb, u16 timeout,
nfc_digital_cmd_complete_t cb, void *arg)
{ … }
static int trf7970a_tg_config_rf_tech(struct trf7970a *trf, int tech)
{ … }
static int trf7970a_tg_config_framing(struct trf7970a *trf, int framing)
{ … }
static int trf7970a_tg_configure_hw(struct nfc_digital_dev *ddev, int type,
int param)
{ … }
static int _trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,
nfc_digital_cmd_complete_t cb, void *arg,
bool mode_detect)
{ … }
static int trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,
nfc_digital_cmd_complete_t cb, void *arg)
{ … }
static int trf7970a_tg_listen_md(struct nfc_digital_dev *ddev,
u16 timeout, nfc_digital_cmd_complete_t cb,
void *arg)
{ … }
static int trf7970a_tg_get_rf_tech(struct nfc_digital_dev *ddev, u8 *rf_tech)
{ … }
static void trf7970a_abort_cmd(struct nfc_digital_dev *ddev)
{ … }
static const struct nfc_digital_ops trf7970a_nfc_ops = …;
static int trf7970a_power_up(struct trf7970a *trf)
{ … }
static int trf7970a_power_down(struct trf7970a *trf)
{ … }
static int trf7970a_startup(struct trf7970a *trf)
{ … }
static void trf7970a_shutdown(struct trf7970a *trf)
{ … }
static int trf7970a_get_autosuspend_delay(const struct device_node *np)
{ … }
static int trf7970a_probe(struct spi_device *spi)
{ … }
static void trf7970a_remove(struct spi_device *spi)
{ … }
#ifdef CONFIG_PM_SLEEP
static int trf7970a_suspend(struct device *dev)
{ … }
static int trf7970a_resume(struct device *dev)
{ … }
#endif
#ifdef CONFIG_PM
static int trf7970a_pm_runtime_suspend(struct device *dev)
{ … }
static int trf7970a_pm_runtime_resume(struct device *dev)
{ … }
#endif
static const struct dev_pm_ops trf7970a_pm_ops = …;
static const struct of_device_id trf7970a_of_match[] __maybe_unused = …;
MODULE_DEVICE_TABLE(of, trf7970a_of_match);
static const struct spi_device_id trf7970a_id_table[] = …;
MODULE_DEVICE_TABLE(spi, trf7970a_id_table);
static struct spi_driver trf7970a_spi_driver = …;
module_spi_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;
MODULE_DESCRIPTION(…) …;