This is the first NFC pull request for the 3.13 kernel.
It's a fairly big one, with the following highlights: - NFC digital layer implementation: Most NFC chipsets implement the NFC digital layer in firmware, but others have more basic functionalities and expect the host to implement the digital layer. This layer sits below the NFC core. - Sony's port100 support: This is "soft" NFC USB dongle that expects the digital layer to be implemented on the host. This is the first user of our NFC digital stack implementation. - Secure element API: We now provide a netlink API for enabling, disabling and discovering NFC attached (embedded or UICC ones) secure elements. With some userspace help, this allows us to support NFC payments. Only the pn544 driver currently supports that API. - NCI SPI fixes and improvements: In order to support NCI devices over SPI, we fixed and improved our NCI/SPI implementation. The currently most deployed NFC NCI chipset, Broadcom's bcm2079x, supports that mode and we're planning to use our NCI/SPI framework to implement a driver for it. - pn533 fragmentation support in target mode: This was the only missing feature from our pn533 impementation. We now support fragmentation in both Tx and Rx modes, in target mode. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) iQIcBAABAgAGBQJSUqvzAAoJEIqAPN1PVmxKKHEP/1mK8kWx9ZZ8egkrkzaTw4lW J9uJq2kTGv5tfEfWjuigAhz5kHB6qLTJLx8FEBZAHazLfa4Az0Zm2G7I7+GTQAMV Mw+uAAI22GGnNgdTNzXDAqgS76Eul2PiWf2UwAbKFZWiyEj5Vf/eZBJAS9nTKLM3 En37wBjvMpVgj6ZwOHKsqPR801NSa3HiM653tkmgSsk3QVL3b7s+kynSuAtshsmA twzymUoJFfYePVnQNRnT3PVPR6w0tRNs4vdq8j5UUuoj1vgKC0/h6nIz2aCURwyE j1pQlSy4ykASM8QZNI2jv3VaOFxmASig2GOgzvCeBZOmCBdlNq13ZY/T0SmmiYES LTbg6Pmh5BXID95GqcFcJaC+iS+QNZK+RWhNYmj+JWCuqZ9Qcja3++IoQ7m/pAip WfyQsO7lD7wPhXUu4IMxfyKNu8u4nCiHdBMp7TBVXiWIVUMxIcoM0auNW4O1qSvW eLq0f1oqQXE9hIrJ4oYUZmn9D5CKRLIXr9SVcmat+VxmV/+jFgV5cMQIGRdDAEUq 4g5g7Avbpkkccn9wdFaIm0VpxMebaNFSWVfBOw4L7PF56lqns6shBcq3W3OvDf60 /Tn0oe9Qqvr17xarJackFkF8beBkJaKOJv9M5+KjlVgGexcNMMTIiwj8aPl6+mqC t5n6tCp0g941jB3qAV2G =K1A5 -----END PGP SIGNATURE----- Merge tag 'nfc-next-3.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/nfc-next Samuel Ortiz <sameo@linux.intel.com> says: "This is the first NFC pull request for the 3.13 kernel. It's a fairly big one, with the following highlights: - NFC digital layer implementation: Most NFC chipsets implement the NFC digital layer in firmware, but others have more basic functionalities and expect the host to implement the digital layer. This layer sits below the NFC core. - Sony's port100 support: This is "soft" NFC USB dongle that expects the digital layer to be implemented on the host. This is the first user of our NFC digital stack implementation. - Secure element API: We now provide a netlink API for enabling, disabling and discovering NFC attached (embedded or UICC ones) secure elements. With some userspace help, this allows us to support NFC payments. Only the pn544 driver currently supports that API. - NCI SPI fixes and improvements: In order to support NCI devices over SPI, we fixed and improved our NCI/SPI implementation. The currently most deployed NFC NCI chipset, Broadcom's bcm2079x, supports that mode and we're planning to use our NCI/SPI framework to implement a driver for it. - pn533 fragmentation support in target mode: This was the only missing feature from our pn533 impementation. We now support fragmentation in both Tx and Rx modes, in target mode." Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
commit
df3c2adea4
28 changed files with 5069 additions and 531 deletions
227
include/net/nfc/digital.h
Normal file
227
include/net/nfc/digital.h
Normal file
|
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* NFC Digital Protocol stack
|
||||
* Copyright (c) 2013, Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __NFC_DIGITAL_H
|
||||
#define __NFC_DIGITAL_H
|
||||
|
||||
#include <linux/skbuff.h>
|
||||
#include <net/nfc/nfc.h>
|
||||
|
||||
/**
|
||||
* Configuration types for in_configure_hw and tg_configure_hw.
|
||||
*/
|
||||
enum {
|
||||
NFC_DIGITAL_CONFIG_RF_TECH = 0,
|
||||
NFC_DIGITAL_CONFIG_FRAMING,
|
||||
};
|
||||
|
||||
/**
|
||||
* RF technology values passed as param argument to in_configure_hw and
|
||||
* tg_configure_hw for NFC_DIGITAL_CONFIG_RF_TECH configuration type.
|
||||
*/
|
||||
enum {
|
||||
NFC_DIGITAL_RF_TECH_106A = 0,
|
||||
NFC_DIGITAL_RF_TECH_212F,
|
||||
NFC_DIGITAL_RF_TECH_424F,
|
||||
|
||||
NFC_DIGITAL_RF_TECH_LAST,
|
||||
};
|
||||
|
||||
/**
|
||||
* Framing configuration passed as param argument to in_configure_hw and
|
||||
* tg_configure_hw for NFC_DIGITAL_CONFIG_FRAMING configuration type.
|
||||
*/
|
||||
enum {
|
||||
NFC_DIGITAL_FRAMING_NFCA_SHORT = 0,
|
||||
NFC_DIGITAL_FRAMING_NFCA_STANDARD,
|
||||
NFC_DIGITAL_FRAMING_NFCA_STANDARD_WITH_CRC_A,
|
||||
|
||||
NFC_DIGITAL_FRAMING_NFCA_T1T,
|
||||
NFC_DIGITAL_FRAMING_NFCA_T2T,
|
||||
NFC_DIGITAL_FRAMING_NFCA_NFC_DEP,
|
||||
|
||||
NFC_DIGITAL_FRAMING_NFCF,
|
||||
NFC_DIGITAL_FRAMING_NFCF_T3T,
|
||||
NFC_DIGITAL_FRAMING_NFCF_NFC_DEP,
|
||||
NFC_DIGITAL_FRAMING_NFC_DEP_ACTIVATED,
|
||||
|
||||
NFC_DIGITAL_FRAMING_LAST,
|
||||
};
|
||||
|
||||
#define DIGITAL_MDAA_NFCID1_SIZE 3
|
||||
|
||||
struct digital_tg_mdaa_params {
|
||||
u16 sens_res;
|
||||
u8 nfcid1[DIGITAL_MDAA_NFCID1_SIZE];
|
||||
u8 sel_res;
|
||||
|
||||
u8 nfcid2[NFC_NFCID2_MAXSIZE];
|
||||
u16 sc;
|
||||
};
|
||||
|
||||
struct nfc_digital_dev;
|
||||
|
||||
/**
|
||||
* nfc_digital_cmd_complete_t - Definition of command result callback
|
||||
*
|
||||
* @ddev: nfc_digital_device ref
|
||||
* @arg: user data
|
||||
* @resp: response data
|
||||
*
|
||||
* resp pointer can be an error code and will be checked with IS_ERR() macro.
|
||||
* The callback is responsible for freeing resp sk_buff.
|
||||
*/
|
||||
typedef void (*nfc_digital_cmd_complete_t)(struct nfc_digital_dev *ddev,
|
||||
void *arg, struct sk_buff *resp);
|
||||
|
||||
/**
|
||||
* Device side NFC Digital operations
|
||||
*
|
||||
* Initiator mode:
|
||||
* @in_configure_hw: Hardware configuration for RF technology and communication
|
||||
* framing in initiator mode. This is a synchronous function.
|
||||
* @in_send_cmd: Initiator mode data exchange using RF technology and framing
|
||||
* previously set with in_configure_hw. The peer response is returned
|
||||
* through callback cb. If an io error occurs or the peer didn't reply
|
||||
* within the specified timeout (ms), the error code is passed back through
|
||||
* the resp pointer. This is an asynchronous function.
|
||||
*
|
||||
* Target mode: Only NFC-DEP protocol is supported in target mode.
|
||||
* @tg_configure_hw: Hardware configuration for RF technology and communication
|
||||
* framing in target mode. This is a synchronous function.
|
||||
* @tg_send_cmd: Target mode data exchange using RF technology and framing
|
||||
* previously set with tg_configure_hw. The peer next command is returned
|
||||
* through callback cb. If an io error occurs or the peer didn't reply
|
||||
* within the specified timeout (ms), the error code is passed back through
|
||||
* the resp pointer. This is an asynchronous function.
|
||||
* @tg_listen: Put the device in listen mode waiting for data from the peer
|
||||
* device. This is an asynchronous function.
|
||||
* @tg_listen_mdaa: If supported, put the device in automatic listen mode with
|
||||
* mode detection and automatic anti-collision. In this mode, the device
|
||||
* automatically detects the RF technology and executes the anti-collision
|
||||
* detection using the command responses specified in mdaa_params. The
|
||||
* mdaa_params structure contains SENS_RES, NFCID1, and SEL_RES for 106A RF
|
||||
* tech. NFCID2 and system code (sc) for 212F and 424F. The driver returns
|
||||
* the NFC-DEP ATR_REQ command through cb. The digital stack deducts the RF
|
||||
* tech by analyzing the SoD of the frame containing the ATR_REQ command.
|
||||
* This is an asynchronous function.
|
||||
*
|
||||
* @switch_rf: Turns device radio on or off. The stack does not call explicitly
|
||||
* switch_rf to turn the radio on. A call to in|tg_configure_hw must turn
|
||||
* the device radio on.
|
||||
* @abort_cmd: Discard the last sent command.
|
||||
*/
|
||||
struct nfc_digital_ops {
|
||||
int (*in_configure_hw)(struct nfc_digital_dev *ddev, int type,
|
||||
int param);
|
||||
int (*in_send_cmd)(struct nfc_digital_dev *ddev, struct sk_buff *skb,
|
||||
u16 timeout, nfc_digital_cmd_complete_t cb,
|
||||
void *arg);
|
||||
|
||||
int (*tg_configure_hw)(struct nfc_digital_dev *ddev, int type,
|
||||
int param);
|
||||
int (*tg_send_cmd)(struct nfc_digital_dev *ddev, struct sk_buff *skb,
|
||||
u16 timeout, nfc_digital_cmd_complete_t cb,
|
||||
void *arg);
|
||||
int (*tg_listen)(struct nfc_digital_dev *ddev, u16 timeout,
|
||||
nfc_digital_cmd_complete_t cb, void *arg);
|
||||
int (*tg_listen_mdaa)(struct nfc_digital_dev *ddev,
|
||||
struct digital_tg_mdaa_params *mdaa_params,
|
||||
u16 timeout, nfc_digital_cmd_complete_t cb,
|
||||
void *arg);
|
||||
|
||||
int (*switch_rf)(struct nfc_digital_dev *ddev, bool on);
|
||||
void (*abort_cmd)(struct nfc_digital_dev *ddev);
|
||||
};
|
||||
|
||||
#define NFC_DIGITAL_POLL_MODE_COUNT_MAX 6 /* 106A, 212F, and 424F in & tg */
|
||||
|
||||
typedef int (*digital_poll_t)(struct nfc_digital_dev *ddev, u8 rf_tech);
|
||||
|
||||
struct digital_poll_tech {
|
||||
u8 rf_tech;
|
||||
digital_poll_t poll_func;
|
||||
};
|
||||
|
||||
/**
|
||||
* Driver capabilities - bit mask made of the following values
|
||||
*
|
||||
* @NFC_DIGITAL_DRV_CAPS_IN_CRC: The driver handles CRC calculation in initiator
|
||||
* mode.
|
||||
* @NFC_DIGITAL_DRV_CAPS_TG_CRC: The driver handles CRC calculation in target
|
||||
* mode.
|
||||
*/
|
||||
#define NFC_DIGITAL_DRV_CAPS_IN_CRC 0x0001
|
||||
#define NFC_DIGITAL_DRV_CAPS_TG_CRC 0x0002
|
||||
|
||||
struct nfc_digital_dev {
|
||||
struct nfc_dev *nfc_dev;
|
||||
struct nfc_digital_ops *ops;
|
||||
|
||||
u32 protocols;
|
||||
|
||||
int tx_headroom;
|
||||
int tx_tailroom;
|
||||
|
||||
u32 driver_capabilities;
|
||||
void *driver_data;
|
||||
|
||||
struct digital_poll_tech poll_techs[NFC_DIGITAL_POLL_MODE_COUNT_MAX];
|
||||
u8 poll_tech_count;
|
||||
u8 poll_tech_index;
|
||||
struct mutex poll_lock;
|
||||
|
||||
struct work_struct cmd_work;
|
||||
struct work_struct cmd_complete_work;
|
||||
struct list_head cmd_queue;
|
||||
struct mutex cmd_lock;
|
||||
|
||||
struct work_struct poll_work;
|
||||
|
||||
u8 curr_protocol;
|
||||
u8 curr_rf_tech;
|
||||
u8 curr_nfc_dep_pni;
|
||||
|
||||
int (*skb_check_crc)(struct sk_buff *skb);
|
||||
void (*skb_add_crc)(struct sk_buff *skb);
|
||||
};
|
||||
|
||||
struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops,
|
||||
__u32 supported_protocols,
|
||||
__u32 driver_capabilities,
|
||||
int tx_headroom,
|
||||
int tx_tailroom);
|
||||
void nfc_digital_free_device(struct nfc_digital_dev *ndev);
|
||||
int nfc_digital_register_device(struct nfc_digital_dev *ndev);
|
||||
void nfc_digital_unregister_device(struct nfc_digital_dev *ndev);
|
||||
|
||||
static inline void nfc_digital_set_parent_dev(struct nfc_digital_dev *ndev,
|
||||
struct device *dev)
|
||||
{
|
||||
nfc_set_parent_dev(ndev->nfc_dev, dev);
|
||||
}
|
||||
|
||||
static inline void nfc_digital_set_drvdata(struct nfc_digital_dev *dev,
|
||||
void *data)
|
||||
{
|
||||
dev->driver_data = data;
|
||||
}
|
||||
|
||||
static inline void *nfc_digital_get_drvdata(struct nfc_digital_dev *dev)
|
||||
{
|
||||
return dev->driver_data;
|
||||
}
|
||||
|
||||
#endif /* __NFC_DIGITAL_H */
|
||||
|
|
@ -24,12 +24,6 @@
|
|||
|
||||
#include <net/nfc/nfc.h>
|
||||
|
||||
struct nfc_phy_ops {
|
||||
int (*write)(void *dev_id, struct sk_buff *skb);
|
||||
int (*enable)(void *dev_id);
|
||||
void (*disable)(void *dev_id);
|
||||
};
|
||||
|
||||
struct nfc_hci_dev;
|
||||
|
||||
struct nfc_hci_ops {
|
||||
|
|
|
|||
|
|
@ -166,6 +166,10 @@
|
|||
#define NCI_GID_NFCEE_MGMT 0x2
|
||||
#define NCI_GID_PROPRIETARY 0xf
|
||||
|
||||
/* ----- NCI over SPI head/crc(tail) room needed for outgoing frames ----- */
|
||||
#define NCI_SPI_HDR_LEN 4
|
||||
#define NCI_SPI_CRC_LEN 2
|
||||
|
||||
/* ---- NCI Packet structures ---- */
|
||||
#define NCI_CTRL_HDR_SIZE 3
|
||||
#define NCI_DATA_HDR_SIZE 3
|
||||
|
|
|
|||
|
|
@ -207,19 +207,9 @@ int nci_to_errno(__u8 code);
|
|||
#define NCI_SPI_CRC_ENABLED 0x01
|
||||
|
||||
/* ----- NCI SPI structures ----- */
|
||||
struct nci_spi_dev;
|
||||
|
||||
struct nci_spi_ops {
|
||||
int (*open)(struct nci_spi_dev *ndev);
|
||||
int (*close)(struct nci_spi_dev *ndev);
|
||||
void (*assert_int)(struct nci_spi_dev *ndev);
|
||||
void (*deassert_int)(struct nci_spi_dev *ndev);
|
||||
};
|
||||
|
||||
struct nci_spi_dev {
|
||||
struct nci_dev *nci_dev;
|
||||
struct nci_spi {
|
||||
struct nci_dev *ndev;
|
||||
struct spi_device *spi;
|
||||
struct nci_spi_ops *ops;
|
||||
|
||||
unsigned int xfer_udelay; /* microseconds delay between
|
||||
transactions */
|
||||
|
|
@ -227,31 +217,15 @@ struct nci_spi_dev {
|
|||
|
||||
struct completion req_completion;
|
||||
u8 req_result;
|
||||
|
||||
void *driver_data;
|
||||
};
|
||||
|
||||
/* ----- NCI SPI Devices ----- */
|
||||
struct nci_spi_dev *nci_spi_allocate_device(struct spi_device *spi,
|
||||
struct nci_spi_ops *ops,
|
||||
u32 supported_protocols,
|
||||
u32 supported_se,
|
||||
u8 acknowledge_mode,
|
||||
unsigned int delay);
|
||||
void nci_spi_free_device(struct nci_spi_dev *ndev);
|
||||
int nci_spi_register_device(struct nci_spi_dev *ndev);
|
||||
void nci_spi_unregister_device(struct nci_spi_dev *ndev);
|
||||
int nci_spi_recv_frame(struct nci_spi_dev *ndev);
|
||||
|
||||
static inline void nci_spi_set_drvdata(struct nci_spi_dev *ndev,
|
||||
void *data)
|
||||
{
|
||||
ndev->driver_data = data;
|
||||
}
|
||||
|
||||
static inline void *nci_spi_get_drvdata(struct nci_spi_dev *ndev)
|
||||
{
|
||||
return ndev->driver_data;
|
||||
}
|
||||
/* ----- NCI SPI ----- */
|
||||
struct nci_spi *nci_spi_allocate_spi(struct spi_device *spi,
|
||||
u8 acknowledge_mode, unsigned int delay,
|
||||
struct nci_dev *ndev);
|
||||
int nci_spi_send(struct nci_spi *nspi,
|
||||
struct completion *write_handshake_completion,
|
||||
struct sk_buff *skb);
|
||||
struct sk_buff *nci_spi_read(struct nci_spi *nspi);
|
||||
|
||||
#endif /* __NCI_CORE_H */
|
||||
|
|
|
|||
|
|
@ -28,9 +28,14 @@
|
|||
#include <linux/device.h>
|
||||
#include <linux/skbuff.h>
|
||||
|
||||
#define nfc_dev_info(dev, fmt, arg...) dev_info((dev), "NFC: " fmt "\n", ## arg)
|
||||
#define nfc_dev_err(dev, fmt, arg...) dev_err((dev), "NFC: " fmt "\n", ## arg)
|
||||
#define nfc_dev_dbg(dev, fmt, arg...) dev_dbg((dev), fmt "\n", ## arg)
|
||||
#define nfc_info(dev, fmt, ...) dev_info((dev), "NFC: " fmt, ##__VA_ARGS__)
|
||||
#define nfc_err(dev, fmt, ...) dev_err((dev), "NFC: " fmt, ##__VA_ARGS__)
|
||||
|
||||
struct nfc_phy_ops {
|
||||
int (*write)(void *dev_id, struct sk_buff *skb);
|
||||
int (*enable)(void *dev_id);
|
||||
void (*disable)(void *dev_id);
|
||||
};
|
||||
|
||||
struct nfc_dev;
|
||||
|
||||
|
|
@ -48,6 +53,8 @@ struct nfc_dev;
|
|||
typedef void (*data_exchange_cb_t)(void *context, struct sk_buff *skb,
|
||||
int err);
|
||||
|
||||
typedef void (*se_io_cb_t)(void *context, u8 *apdu, size_t apdu_len, int err);
|
||||
|
||||
struct nfc_target;
|
||||
|
||||
struct nfc_ops {
|
||||
|
|
@ -74,12 +81,23 @@ struct nfc_ops {
|
|||
int (*discover_se)(struct nfc_dev *dev);
|
||||
int (*enable_se)(struct nfc_dev *dev, u32 se_idx);
|
||||
int (*disable_se)(struct nfc_dev *dev, u32 se_idx);
|
||||
int (*se_io) (struct nfc_dev *dev, u32 se_idx,
|
||||
u8 *apdu, size_t apdu_length,
|
||||
se_io_cb_t cb, void *cb_context);
|
||||
};
|
||||
|
||||
#define NFC_TARGET_IDX_ANY -1
|
||||
#define NFC_MAX_GT_LEN 48
|
||||
#define NFC_ATR_RES_GT_OFFSET 15
|
||||
|
||||
/**
|
||||
* struct nfc_target - NFC target descriptiom
|
||||
*
|
||||
* @sens_res: 2 bytes describing the target SENS_RES response, if the target
|
||||
* is a type A one. The %sens_res most significant byte must be byte 2
|
||||
* as described by the NFC Forum digital specification (i.e. the platform
|
||||
* configuration one) while %sens_res least significant byte is byte 1.
|
||||
*/
|
||||
struct nfc_target {
|
||||
u32 idx;
|
||||
u32 supported_protocols;
|
||||
|
|
@ -243,5 +261,6 @@ void nfc_driver_failure(struct nfc_dev *dev, int err);
|
|||
|
||||
int nfc_add_se(struct nfc_dev *dev, u32 se_idx, u16 type);
|
||||
int nfc_remove_se(struct nfc_dev *dev, u32 se_idx);
|
||||
struct nfc_se *nfc_find_se(struct nfc_dev *dev, u32 se_idx);
|
||||
|
||||
#endif /* __NET_NFC_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue