linux/drivers/nfc/microread/microread.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * HCI based Driver for Inside Secure microread NFC Chip
 *
 * Copyright (C) 2013  Intel Corporation. All rights reserved.
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/crc-ccitt.h>

#include <linux/nfc.h>
#include <net/nfc/nfc.h>
#include <net/nfc/hci.h>

#include "microread.h"

/* Proprietary gates, events, commands and registers */
/* Admin */
#define MICROREAD_GATE_ID_ADM
#define MICROREAD_GATE_ID_MGT
#define MICROREAD_GATE_ID_OS
#define MICROREAD_GATE_ID_TESTRF
#define MICROREAD_GATE_ID_LOOPBACK
#define MICROREAD_GATE_ID_IDT
#define MICROREAD_GATE_ID_LMS

/* Reader */
#define MICROREAD_GATE_ID_MREAD_GEN
#define MICROREAD_GATE_ID_MREAD_ISO_B
#define MICROREAD_GATE_ID_MREAD_NFC_T1
#define MICROREAD_GATE_ID_MREAD_ISO_A
#define MICROREAD_GATE_ID_MREAD_NFC_T3
#define MICROREAD_GATE_ID_MREAD_ISO_15_3
#define MICROREAD_GATE_ID_MREAD_ISO_15_2
#define MICROREAD_GATE_ID_MREAD_ISO_B_3
#define MICROREAD_GATE_ID_MREAD_BPRIME
#define MICROREAD_GATE_ID_MREAD_ISO_A_3

/* Card */
#define MICROREAD_GATE_ID_MCARD_GEN
#define MICROREAD_GATE_ID_MCARD_ISO_B
#define MICROREAD_GATE_ID_MCARD_BPRIME
#define MICROREAD_GATE_ID_MCARD_ISO_A
#define MICROREAD_GATE_ID_MCARD_NFC_T3
#define MICROREAD_GATE_ID_MCARD_ISO_15_3
#define MICROREAD_GATE_ID_MCARD_ISO_15_2
#define MICROREAD_GATE_ID_MCARD_ISO_B_2
#define MICROREAD_GATE_ID_MCARD_ISO_CUSTOM
#define MICROREAD_GATE_ID_SECURE_ELEMENT

/* P2P */
#define MICROREAD_GATE_ID_P2P_GEN
#define MICROREAD_GATE_ID_P2P_TARGET
#define MICROREAD_PAR_P2P_TARGET_MODE
#define MICROREAD_PAR_P2P_TARGET_GT
#define MICROREAD_GATE_ID_P2P_INITIATOR
#define MICROREAD_PAR_P2P_INITIATOR_GI
#define MICROREAD_PAR_P2P_INITIATOR_GT

/* Those pipes are created/opened by default in the chip */
#define MICROREAD_PIPE_ID_LMS
#define MICROREAD_PIPE_ID_ADMIN
#define MICROREAD_PIPE_ID_MGT
#define MICROREAD_PIPE_ID_OS
#define MICROREAD_PIPE_ID_HDS_LOOPBACK
#define MICROREAD_PIPE_ID_HDS_IDT
#define MICROREAD_PIPE_ID_HDS_MCARD_ISO_B
#define MICROREAD_PIPE_ID_HDS_MCARD_ISO_BPRIME
#define MICROREAD_PIPE_ID_HDS_MCARD_ISO_A
#define MICROREAD_PIPE_ID_HDS_MCARD_ISO_15_3
#define MICROREAD_PIPE_ID_HDS_MCARD_ISO_15_2
#define MICROREAD_PIPE_ID_HDS_MCARD_NFC_T3
#define MICROREAD_PIPE_ID_HDS_MCARD_ISO_B_2
#define MICROREAD_PIPE_ID_HDS_MCARD_CUSTOM
#define MICROREAD_PIPE_ID_HDS_MREAD_ISO_B
#define MICROREAD_PIPE_ID_HDS_MREAD_NFC_T1
#define MICROREAD_PIPE_ID_HDS_MREAD_ISO_A
#define MICROREAD_PIPE_ID_HDS_MREAD_ISO_15_3
#define MICROREAD_PIPE_ID_HDS_MREAD_ISO_15_2
#define MICROREAD_PIPE_ID_HDS_MREAD_NFC_T3
#define MICROREAD_PIPE_ID_HDS_MREAD_ISO_B_3
#define MICROREAD_PIPE_ID_HDS_MREAD_BPRIME
#define MICROREAD_PIPE_ID_HDS_MREAD_ISO_A_3
#define MICROREAD_PIPE_ID_HDS_MREAD_GEN
#define MICROREAD_PIPE_ID_HDS_STACKED_ELEMENT
#define MICROREAD_PIPE_ID_HDS_INSTANCES
#define MICROREAD_PIPE_ID_HDS_TESTRF
#define MICROREAD_PIPE_ID_HDS_P2P_TARGET
#define MICROREAD_PIPE_ID_HDS_P2P_INITIATOR

/* Events */
#define MICROREAD_EVT_MREAD_DISCOVERY_OCCURED
#define MICROREAD_EVT_MREAD_CARD_FOUND
#define MICROREAD_EMCF_A_ATQA
#define MICROREAD_EMCF_A_SAK
#define MICROREAD_EMCF_A_LEN
#define MICROREAD_EMCF_A_UID
#define MICROREAD_EMCF_A3_ATQA
#define MICROREAD_EMCF_A3_SAK
#define MICROREAD_EMCF_A3_LEN
#define MICROREAD_EMCF_A3_UID
#define MICROREAD_EMCF_B_UID
#define MICROREAD_EMCF_T1_ATQA
#define MICROREAD_EMCF_T1_UID
#define MICROREAD_EMCF_T3_UID
#define MICROREAD_EVT_MREAD_DISCOVERY_START
#define MICROREAD_EVT_MREAD_DISCOVERY_START_SOME
#define MICROREAD_EVT_MREAD_DISCOVERY_STOP
#define MICROREAD_EVT_MREAD_SIM_REQUESTS
#define MICROREAD_EVT_MCARD_EXCHANGE
#define MICROREAD_EVT_P2P_INITIATOR_EXCHANGE_TO_RF
#define MICROREAD_EVT_P2P_INITIATOR_EXCHANGE_FROM_RF
#define MICROREAD_EVT_MCARD_FIELD_ON
#define MICROREAD_EVT_P2P_TARGET_ACTIVATED
#define MICROREAD_EVT_P2P_TARGET_DEACTIVATED
#define MICROREAD_EVT_MCARD_FIELD_OFF

/* Commands */
#define MICROREAD_CMD_MREAD_EXCHANGE
#define MICROREAD_CMD_MREAD_SUBSCRIBE

/* Hosts IDs */
#define MICROREAD_ELT_ID_HDS
#define MICROREAD_ELT_ID_SIM
#define MICROREAD_ELT_ID_SE1
#define MICROREAD_ELT_ID_SE2
#define MICROREAD_ELT_ID_SE3

static const struct nfc_hci_gate microread_gates[] =;

/* Largest headroom needed for outgoing custom commands */
#define MICROREAD_CMDS_HEADROOM
#define MICROREAD_CMD_TAILROOM

struct microread_info {};

static int microread_open(struct nfc_hci_dev *hdev)
{}

static void microread_close(struct nfc_hci_dev *hdev)
{}

static int microread_hci_ready(struct nfc_hci_dev *hdev)
{}

static int microread_xmit(struct nfc_hci_dev *hdev, struct sk_buff *skb)
{}

static int microread_start_poll(struct nfc_hci_dev *hdev,
				u32 im_protocols, u32 tm_protocols)
{}

static int microread_dep_link_up(struct nfc_hci_dev *hdev,
				struct nfc_target *target, u8 comm_mode,
				u8 *gb, size_t gb_len)
{}

static int microread_dep_link_down(struct nfc_hci_dev *hdev)
{}

static int microread_target_from_gate(struct nfc_hci_dev *hdev, u8 gate,
				      struct nfc_target *target)
{}

static int microread_complete_target_discovered(struct nfc_hci_dev *hdev,
						u8 gate,
						struct nfc_target *target)
{}

#define MICROREAD_CB_TYPE_READER_ALL

static void microread_im_transceive_cb(void *context, struct sk_buff *skb,
				       int err)
{}

/*
 * Returns:
 * <= 0: driver handled the data exchange
 *    1: driver doesn't especially handle, please do standard processing
 */
static int microread_im_transceive(struct nfc_hci_dev *hdev,
				   struct nfc_target *target,
				   struct sk_buff *skb, data_exchange_cb_t cb,
				   void *cb_context)
{}

static int microread_tm_send(struct nfc_hci_dev *hdev, struct sk_buff *skb)
{}

static void microread_target_discovered(struct nfc_hci_dev *hdev, u8 gate,
					struct sk_buff *skb)
{}

static int microread_event_received(struct nfc_hci_dev *hdev, u8 pipe,
				     u8 event, struct sk_buff *skb)
{}

static const struct nfc_hci_ops microread_hci_ops =;

int microread_probe(void *phy_id, const struct nfc_phy_ops *phy_ops,
		    const char *llc_name, int phy_headroom, int phy_tailroom,
		    int phy_payload, struct nfc_hci_dev **hdev)
{}
EXPORT_SYMBOL();

void microread_remove(struct nfc_hci_dev *hdev)
{}
EXPORT_SYMBOL();

MODULE_LICENSE();
MODULE_DESCRIPTION();