Skip to content

Commit

Permalink
NFC: nci: Add support for proprietary RF Protocols
Browse files Browse the repository at this point in the history
In NFC Forum NCI specification, some RF Protocol values are
reserved for proprietary use (from 0x80 to 0xfe).
Some CLF vendor may need to use one value within this range
for specific technology.
Furthermore, some CLF may not becompliant with NFC Froum NCI
specification 2.0 and therefore will not support RF Protocol
value 0x06 for PROTOCOL_T5T as mention in a draft specification
and in a recent push.

Adding get_rf_protocol handle to the nci_ops structure will
help to set the correct technology to target.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
cricard13 authored and Samuel Ortiz committed Sep 24, 2014
1 parent fa0daa0 commit 9e87f9a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
10 changes: 10 additions & 0 deletions drivers/nfc/st21nfcb/st21nfcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#define DRIVER_DESC "NCI NFC driver for ST21NFCB"

#define ST21NFCB_NCI1_X_PROPRIETARY_ISO15693 0x83

static int st21nfcb_nci_open(struct nci_dev *ndev)
{
struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
Expand Down Expand Up @@ -64,10 +66,18 @@ static int st21nfcb_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
return ndlc_send(info->ndlc, skb);
}

static __u32 st21nfcb_nci_get_rfprotocol(struct nci_dev *ndev,
__u8 rf_protocol)
{
return rf_protocol == ST21NFCB_NCI1_X_PROPRIETARY_ISO15693 ?
NFC_PROTO_ISO15693_MASK : 0;
}

static struct nci_ops st21nfcb_nci_ops = {
.open = st21nfcb_nci_open,
.close = st21nfcb_nci_close,
.send = st21nfcb_nci_send,
.get_rfprotocol = st21nfcb_nci_get_rfprotocol,
};

int st21nfcb_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
Expand Down
9 changes: 5 additions & 4 deletions include/net/nfc/nci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ enum nci_state {
struct nci_dev;

struct nci_ops {
int (*open)(struct nci_dev *ndev);
int (*close)(struct nci_dev *ndev);
int (*send)(struct nci_dev *ndev, struct sk_buff *skb);
int (*setup)(struct nci_dev *ndev);
int (*open)(struct nci_dev *ndev);
int (*close)(struct nci_dev *ndev);
int (*send)(struct nci_dev *ndev, struct sk_buff *skb);
int (*setup)(struct nci_dev *ndev);
__u32 (*get_rfprotocol)(struct nci_dev *ndev, __u8 rf_protocol);
};

#define NCI_MAX_SUPPORTED_RF_INTERFACES 4
Expand Down
9 changes: 8 additions & 1 deletion net/nfc/nci/ntf.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ static __u8 *nci_extract_rf_params_nfcv_passive_poll(struct nci_dev *ndev,
return data;
}

__u32 nci_get_prop_rf_protocol(struct nci_dev *ndev, __u8 rf_protocol)
{
if (ndev->ops->get_rfprotocol)
return ndev->ops->get_rfprotocol(ndev, rf_protocol);
return 0;
}

static int nci_add_new_protocol(struct nci_dev *ndev,
struct nfc_target *target,
__u8 rf_protocol,
Expand Down Expand Up @@ -195,7 +202,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
else if (rf_protocol == NCI_RF_PROTOCOL_T5T)
protocol = NFC_PROTO_ISO15693_MASK;
else
protocol = 0;
protocol = nci_get_prop_rf_protocol(ndev, rf_protocol);

if (!(protocol & ndev->poll_prots)) {
pr_err("the target found does not have the desired protocol\n");
Expand Down

0 comments on commit 9e87f9a

Please sign in to comment.