Skip to contentSkip to conversation

Add Intel FieldsPeak NFC solution driver

PATCH New Robert Dolca 1 participant 11 messages Oct 22, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v4 cover Add Intel FieldsPeak NFC solution driver

These patches add support for Intel's FieldsPeak NFC solution.

Fields Peak complies with the ISO/IEC 14443A/B, 15693, 18092, and JIS X 6319-4. It is an NCI based controller.

RF Protocols supported:
- NFC Forum Type 1 Tags (Jewel, Topaz)
- NFC Forum Type 2 Tags (Mifare UL)
- NFC Forum Type 3 Tags (FeliCa)
- NFC Forum Type 4A (ISO/IEC 14443 A-4 106kbps to 848kbps)
- NFC Forum Type 4B (ISO/IEC 14443 B-4 106kbps to 848kbps)
- NFCIP in passive and active modes (ISO/IEC 18092 106kbps to 424kbps)
- B’ (based on ISO/IEC 14443 B-2)
- iCLASS (based on ISO/IEC 15693-2)
- Vicinity cards (ISO/IEC 15693-3)
- Kovio tags (NFC Forum Type 2)

The device can be enumerated using ACPI using the id INT339A. The 1st GPIO is the IRQ and the 2nd is the RESET pin.

Changes since v3:
- replace u32 with le32 where appropriate
- make nci_prop_ops struct instances static
- simplify return for fdp_nci_setup and fdp_nci_post_setup
- change return type from u8 to int for nci_conn_max_data_pkt_payload_size
- set FDP_NCI_I2C_MAX_PAYLOAD to 261 (255 + NCI header (3) + lrc(2) + size byte)
- add sleep during patching to make sure that the NFCC processed the last data packet
- patch droped "nfc: nci: Use a separate mutex for nci open and close"
- patch droped "nfc: nci: Add a parameter to get the new connection id"
- add patch "nfc: nci: fix possible crash in nci_core_conn_create"
- add patch "nfc: nci: add nci_get_conn_info_by_id function"
- add patch "nfc: nci: rename nci_prop_ops to nci_driver_ops"
- edit "ecee665 nfc: nci: Allow the driver to set handler for core nci ops" to add wrappers for core ops and prop ops in order to simplify the code
- removed "atomic_t intercept;" from fdp_nci_info struct
- make functions inline: fdp_nci_get_versions, fdp_nci_patch_cmd, fdp_nci_set_production_data
- moved otp and ram patching to separate functions that are called from fdp_nci_post_setup

Changes since v2:
- rename reset gpio to power gpio because it really is a power switch
- use named gpio for power with fallback to the indexed gpio 0
- use device managed gpio for power
- rely on the i2c subsystem to fill in the irq field of the i2c_client struct
- remove the internal driver state (the nfc subsystem takes care of what we need)
- removed the power status field (not needed any more)
- change i2c / device tree id name s/INT339A/int339a
- make clock type and clock frequency configurable with device properties (use defauls if not set)
- firmware vendor specific commands configurable with device properties (default none)
- other small fixes

Changes since v1:
- removed .owner
- made local functions static
- droped "NFC: NCI: Adds NCI init and reset API for drivers"
- replaced nfc_info with dev_dbg
- make controller setup possible without OTP patch
- retoved the commint that was adding nci_init/reset and using the newly added functions nci_core_init/reset
- fixed typo and use full controller name instead of abreviation in Kconfig
- added more info about the controller in the commit message
- moved NCI_OP_CORE_RESET_NTF, NCI_OP_CORE_GET_CONFIG_RSP and NCI_OP_CORE_GET_CONFIG_CMD into the core header files
- added MODULE_DEVICE_TABLE for ACPI
- defined FDP_FW_UPDATE_DEST 0xC2
- release the firmware buffers
- settings the vendor configuration and clock on post setup
- platform data enumerations removed (ACPI enumeration left)
- packet reception intercept logic remove
- nci: removed nci_send_cmd symbol export
- nci: removed nci_request_driver and nci_req_complete_driver
- removed mutex from driver (no need for it)
- nci: check the setup return code before callig post_setup
- nci: add function to allow sending core commands from driver
- nci: Use a separate mutex for nci open and close
- nci: mutex for: Adds a way to get the new connection ID
- nci: Allow the driver to set handler for core nci ops

Robert Dolca (10):
nfc: nci: Export nci data send API
nfc: nci: Add function to get max packet size for conn
nfc: nci: Introduce new core opcodes
nfc: nci: Do not call post_setup when setup fails
nfc: nci: Introduce nci_core_cmd
nfc: nci: Allow the driver to set handler for core nci ops
nfc: nci: rename nci_prop_ops to nci_driver_ops
nfc: nci: fix possible crash in nci_core_conn_create
nfc: nci: add nci_get_conn_info_by_id function
nfc: Add Intel Fields Peak NFC solution driver

 drivers/nfc/Kconfig        |   1 +
 drivers/nfc/Makefile       |   1 +
 drivers/nfc/fdp/Kconfig    |  23 ++
 drivers/nfc/fdp/Makefile   |   9 +
 drivers/nfc/fdp/fdp.c      | 817 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/nfc/fdp/fdp.h      |  38 +++
 drivers/nfc/fdp/i2c.c      | 388 +++++++++++++++++++++
 drivers/nfc/s3fwrn5/nci.c  |   4 +-
 drivers/nfc/st-nci/core.c  |   2 +-
 include/net/nfc/nci.h      |   7 +
 include/net/nfc/nci_core.h |  18 +-
 net/nfc/nci/core.c         | 120 +++++--
 net/nfc/nci/data.c         |  13 +
 net/nfc/nci/ntf.c          |   3 +-
 net/nfc/nci/rsp.c          |   1 +
 15 files changed, 1409 insertions(+), 36 deletions(-)
 create mode 100644 drivers/nfc/fdp/Kconfig
 create mode 100644 drivers/nfc/fdp/Makefile
 create mode 100644 drivers/nfc/fdp/fdp.c
 create mode 100644 drivers/nfc/fdp/fdp.h
 create mode 100644 drivers/nfc/fdp/i2c.c

--

1.9.1

#1 lore raw

PATCH v4 1/10 nfc: nci: Export nci data send API

For the firmware update the driver may use nci_send_data.

---
 net/nfc/nci/data.c | 1 +
 1 file changed, 1 insertion(+)
net/nfc/nci/data.c +1 -0
index 566466d..83acd18 100644
@@ -203,6 +203,7 @@ free_exit:
 exit:
 	return rc;
 }
+EXPORT_SYMBOL(nci_send_data);
 
 /* ----------------- NCI RX Data ----------------- */
 
Signature · 1 line
1.9.1
#2 lore raw

PATCH v4 2/10 nfc: nci: Add function to get max packet size for conn

In reply to Robert Dolca

FDP driver needs to send the firmware as regular packets (not fragmented). The driver should have a way to get the max packet size for a given connection.

---
 include/net/nfc/nci_core.h |  1 +
 net/nfc/nci/data.c         | 12 ++++++++++++
 2 files changed, 13 insertions(+)
include/net/nfc/nci_core.h +1 -0
index d0d0f1e..aaada20 100644
@@ -351,6 +351,7 @@ int nci_prop_ntf_packet(struct nci_dev *ndev, __u16 opcode,
 void nci_rx_data_packet(struct nci_dev *ndev, struct sk_buff *skb);
 int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload);
 int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb);
+int nci_conn_max_data_pkt_payload_size(struct nci_dev *ndev, __u8 conn_id);
 void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb,
 				__u8 conn_id, int err);
 void nci_hci_data_received_cb(void *context, struct sk_buff *skb, int err);
net/nfc/nci/data.c +12 -0
index 83acd18..dbd2425 100644
@@ -90,6 +90,18 @@ static inline void nci_push_data_hdr(struct nci_dev *ndev,
 	nci_pbf_set((__u8 *)hdr, pbf);
 }
 
+int nci_conn_max_data_pkt_payload_size(struct nci_dev *ndev, __u8 conn_id)
+{
+	struct nci_conn_info *conn_info;
+
+	conn_info = nci_get_conn_info_by_conn_id(ndev, conn_id);
+	if (!conn_info)
+		return -EPROTO;
+
+	return conn_info->max_pkt_payload_len;
+}
+EXPORT_SYMBOL(nci_conn_max_data_pkt_payload_size);
+
 static int nci_queue_tx_data_frags(struct nci_dev *ndev,
 				   __u8 conn_id,
 				   struct sk_buff *skb) {
Signature · 1 line
1.9.1
#3 lore raw

PATCH v4 3/10 nfc: nci: Introduce new core opcodes

In reply to Robert Dolca

Add NCI_OP_CORE_GET_CONFIG_CMD, NCI_OP_CORE_GET_CONFIG_RSP and NCI_OP_CORE_RESET_NTF.

---
 include/net/nfc/nci.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/net/nfc/nci.h +7 -0
index 75d2e18..b495825 100644
@@ -315,6 +315,8 @@ struct nci_nfcee_mode_set_cmd {
 	__u8	nfcee_mode;
 } __packed;
 
+#define NCI_OP_CORE_GET_CONFIG_CMD	nci_opcode_pack(NCI_GID_CORE, 0x03)
+
 /* ----------------------- */
 /* ---- NCI Responses ---- */
 /* ----------------------- */
@@ -375,6 +377,9 @@ struct nci_nfcee_discover_rsp {
 } __packed;
 
 #define NCI_OP_NFCEE_MODE_SET_RSP nci_opcode_pack(NCI_GID_NFCEE_MGMT, 0x01)
+
+#define NCI_OP_CORE_GET_CONFIG_RSP	nci_opcode_pack(NCI_GID_CORE, 0x03)
+
 /* --------------------------- */
 /* ---- NCI Notifications ---- */
 /* --------------------------- */
@@ -528,4 +533,6 @@ struct nci_nfcee_discover_ntf {
 	struct nci_nfcee_information_tlv	information_tlv;
 } __packed;
 
+#define NCI_OP_CORE_RESET_NTF		nci_opcode_pack(NCI_GID_CORE, 0x00)
+
 #endif /* __NCI_H */
Signature · 1 line
1.9.1
#4 lore raw

PATCH v4 4/10 nfc: nci: Do not call post_setup when setup fails

In reply to Robert Dolca

The driver should know that it can continue with post setup where setup left off. Being able to execute post_setup when setup fails may force the developer to keep this state in the driver.

---
 net/nfc/nci/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/nfc/nci/core.c +1 -2
index 0909720..5362d8f 100644
@@ -402,9 +402,8 @@ static int nci_open_device(struct nci_dev *ndev)
 				   msecs_to_jiffies(NCI_INIT_TIMEOUT));
 	}
 
-	if (ndev->ops->post_setup) {
+	if (!rc && ndev->ops->post_setup)
 		rc = ndev->ops->post_setup(ndev);
-	}
 
 	if (!rc) {
 		rc = __nci_request(ndev, nci_init_complete_req, 0,
Signature · 1 line
1.9.1
#5 lore raw

PATCH v4 5/10 nfc: nci: Introduce nci_core_cmd

In reply to Robert Dolca

This allows sending core commands from the driver. The driver should be able to send NCI core commands like CORE_GET_CONFIG_CMD.

---
 include/net/nfc/nci_core.h |  1 +
 net/nfc/nci/core.c         | 24 +++++++++++++++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)
include/net/nfc/nci_core.h +1 -0
index aaada20..4ca1b6d 100644
@@ -278,6 +278,7 @@ int nci_request(struct nci_dev *ndev,
 			    unsigned long opt),
 		unsigned long opt, __u32 timeout);
 int nci_prop_cmd(struct nci_dev *ndev, __u8 oid, size_t len, __u8 *payload);
+int nci_core_cmd(struct nci_dev *ndev, __u16 opcode, size_t len, __u8 *payload);
 int nci_core_reset(struct nci_dev *ndev);
 int nci_core_init(struct nci_dev *ndev);
 
net/nfc/nci/core.c +19 -5
index 5362d8f..5b4f48a 100644
@@ -325,32 +325,46 @@ static void nci_rf_deactivate_req(struct nci_dev *ndev, unsigned long opt)
 		     sizeof(struct nci_rf_deactivate_cmd), &cmd);
 }
 
-struct nci_prop_cmd_param {
+struct nci_cmd_param {
 	__u16 opcode;
 	size_t len;
 	__u8 *payload;
 };
 
-static void nci_prop_cmd_req(struct nci_dev *ndev, unsigned long opt)
+static void nci_generic_req(struct nci_dev *ndev, unsigned long opt)
 {
-	struct nci_prop_cmd_param *param = (struct nci_prop_cmd_param *)opt;
+	struct nci_cmd_param *param =
+		(struct nci_cmd_param *)opt;
 
 	nci_send_cmd(ndev, param->opcode, param->len, param->payload);
 }
 
 int nci_prop_cmd(struct nci_dev *ndev, __u8 oid, size_t len, __u8 *payload)
 {
-	struct nci_prop_cmd_param param;
+	struct nci_cmd_param param;
 
 	param.opcode = nci_opcode_pack(NCI_GID_PROPRIETARY, oid);
 	param.len = len;
 	param.payload = payload;
 
-	return __nci_request(ndev, nci_prop_cmd_req, (unsigned long)&param,
+	return __nci_request(ndev, nci_generic_req, (unsigned long)&param,
 			     msecs_to_jiffies(NCI_CMD_TIMEOUT));
 }
 EXPORT_SYMBOL(nci_prop_cmd);
 
+int nci_core_cmd(struct nci_dev *ndev, __u16 opcode, size_t len, __u8 *payload)
+{
+	struct nci_cmd_param param;
+
+	param.opcode = opcode;
+	param.len = len;
+	param.payload = payload;
+
+	return __nci_request(ndev, nci_generic_req, (unsigned long)&param,
+			     msecs_to_jiffies(NCI_CMD_TIMEOUT));
+}
+EXPORT_SYMBOL(nci_core_cmd);
+
 int nci_core_reset(struct nci_dev *ndev)
 {
 	return __nci_request(ndev, nci_reset_req, 0,
Signature · 1 line
1.9.1
#6 lore raw

PATCH v4 6/10 nfc: nci: Allow the driver to set handler for core nci ops

In reply to Robert Dolca

The driver may be required to act when some responses or notifications arrive. For example the NCI core does not have a handler for NCI_OP_CORE_GET_CONFIG_RSP. The NFCC can send a config response that has to be read by the driver and the packet may contain vendor specific data.

The Fields Peak driver needs to take certain actions when a reset notification arrives (packet also not handled by the nfc core).

The driver handlers do not interfere with the core and they are called after the core processes the packet.

---
 include/net/nfc/nci_core.h | 11 +++++--
 net/nfc/nci/core.c         | 71 +++++++++++++++++++++++++++++++++-------------
 net/nfc/nci/ntf.c          |  3 +-
 net/nfc/nci/rsp.c          |  1 +
 4 files changed, 63 insertions(+), 23 deletions(-)
include/net/nfc/nci_core.h +9 -2
index 4ca1b6d..d5a1caa 100644
@@ -96,6 +96,9 @@ struct nci_ops {
 
 	struct nci_prop_ops *prop_ops;
 	size_t n_prop_ops;
+
+	struct nci_prop_ops *core_ops;
+	size_t n_core_ops;
 };
 
 #define NCI_MAX_SUPPORTED_RF_INTERFACES		4
@@ -345,9 +348,13 @@ static inline int nci_set_vendor_cmds(struct nci_dev *ndev,
 
 void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb);
 void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb);
-int nci_prop_rsp_packet(struct nci_dev *ndev, __u16 opcode,
+inline int nci_prop_rsp_packet(struct nci_dev *ndev, __u16 opcode,
+			struct sk_buff *skb);
+inline int nci_prop_ntf_packet(struct nci_dev *ndev, __u16 opcode,
+			struct sk_buff *skb);
+inline int nci_core_rsp_packet(struct nci_dev *ndev, __u16 opcode,
 			struct sk_buff *skb);
-int nci_prop_ntf_packet(struct nci_dev *ndev, __u16 opcode,
+inline int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
 			struct sk_buff *skb);
 void nci_rx_data_packet(struct nci_dev *ndev, struct sk_buff *skb);
 int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload);
net/nfc/nci/core.c +51 -20

97 lines not on this page · raw message

net/nfc/nci/ntf.c +2 -1
index 5d1c2e3..2ada2b3 100644
@@ -759,7 +759,7 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
 	skb_pull(skb, NCI_CTRL_HDR_SIZE);
 
 	if (nci_opcode_gid(ntf_opcode) == NCI_GID_PROPRIETARY) {
-		if (nci_prop_ntf_packet(ndev, ntf_opcode, skb)) {
+		if (nci_prop_ntf_packet(ndev, ntf_opcode, skb) == -ENOTSUPP) {
 			pr_err("unsupported ntf opcode 0x%x\n",
 			       ntf_opcode);
 		}
@@ -805,6 +805,7 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
 		break;
 	}
 
+	nci_core_ntf_packet(ndev, ntf_opcode, skb);
 end:
 	kfree_skb(skb);
 }
net/nfc/nci/rsp.c +1 -0
index 408bd8f..9b6eb91 100644
@@ -355,6 +355,7 @@ void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
 		break;
 	}
 
+	nci_core_rsp_packet(ndev, rsp_opcode, skb);
 end:
 	kfree_skb(skb);
 
Signature · 1 line
1.9.1
#7 lore raw

PATCH v4 7/10 nfc: nci: rename nci_prop_ops to nci_driver_ops

In reply to Robert Dolca

Initially it was used to create hooks in the driver for proprietary operations. Currently it is being used for hooks for both proprietary and generic operations.

---
 drivers/nfc/s3fwrn5/nci.c  |  4 ++--
 drivers/nfc/st-nci/core.c  |  2 +-
 include/net/nfc/nci_core.h |  6 +++---
 net/nfc/nci/core.c         | 16 ++++++++--------
 4 files changed, 14 insertions(+), 14 deletions(-)
drivers/nfc/s3fwrn5/nci.c +2 -2
index ace0071..075e4e8 100644
@@ -31,7 +31,7 @@ static int s3fwrn5_nci_prop_rsp(struct nci_dev *ndev, struct sk_buff *skb)
 	return 0;
 }
 
-static struct nci_prop_ops s3fwrn5_nci_prop_ops[] = {
+static struct nci_driver_ops s3fwrn5_nci_prop_ops[] = {
 	{
 		.opcode = nci_opcode_pack(NCI_GID_PROPRIETARY,
 				NCI_PROP_AGAIN),
@@ -79,7 +79,7 @@ static struct nci_prop_ops s3fwrn5_nci_prop_ops[] = {
 	},
 };
 
-void s3fwrn5_nci_get_prop_ops(struct nci_prop_ops **ops, size_t *n)
+void s3fwrn5_nci_get_prop_ops(struct nci_driver_ops **ops, size_t *n)
 {
 	*ops = s3fwrn5_nci_prop_ops;
 	*n = ARRAY_SIZE(s3fwrn5_nci_prop_ops);
drivers/nfc/st-nci/core.c +1 -1
index c419d39..dd7b1c14 100644
@@ -98,7 +98,7 @@ static int st_nci_prop_rsp_packet(struct nci_dev *ndev,
 	return 0;
 }
 
-static struct nci_prop_ops st_nci_prop_ops[] = {
+static struct nci_driver_ops st_nci_prop_ops[] = {
 	{
 		.opcode = nci_opcode_pack(NCI_GID_PROPRIETARY,
 					  ST_NCI_CORE_PROP),
include/net/nfc/nci_core.h +3 -3
index d5a1caa..5daf004 100644
@@ -67,7 +67,7 @@ enum nci_state {
 
 struct nci_dev;
 
-struct nci_prop_ops {
+struct nci_driver_ops {
 	__u16 opcode;
 	int (*rsp)(struct nci_dev *dev, struct sk_buff *skb);
 	int (*ntf)(struct nci_dev *dev, struct sk_buff *skb);
@@ -94,10 +94,10 @@ struct nci_ops {
 	void  (*hci_cmd_received)(struct nci_dev *ndev, u8 pipe, u8 cmd,
 				  struct sk_buff *skb);
 
-	struct nci_prop_ops *prop_ops;
+	struct nci_driver_ops *prop_ops;
 	size_t n_prop_ops;
 
-	struct nci_prop_ops *core_ops;
+	struct nci_driver_ops *core_ops;
 	size_t n_core_ops;
 };
 
net/nfc/nci/core.c +8 -8
index 30c2708..f66a5da 100644
@@ -1242,12 +1242,12 @@ int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload)
 }
 
 /* Proprietary commands API */
-static struct nci_prop_ops *ops_cmd_lookup(struct nci_prop_ops *ops,
-					   size_t n_ops,
-					   __u16 opcode)
+static struct nci_driver_ops *ops_cmd_lookup(struct nci_driver_ops *ops,
+					     size_t n_ops,
+					     __u16 opcode)
 {
 	size_t i;
-	struct nci_prop_ops *op;
+	struct nci_driver_ops *op;
 
 	if (!ops || !n_ops)
 		return NULL;
@@ -1262,10 +1262,10 @@ static struct nci_prop_ops *ops_cmd_lookup(struct nci_prop_ops *ops,
 }
 
 static int nci_op_rsp_packet(struct nci_dev *ndev, __u16 rsp_opcode,
-			     struct sk_buff *skb, struct nci_prop_ops *ops,
+			     struct sk_buff *skb, struct nci_driver_ops *ops,
 			     size_t n_ops)
 {
-	struct nci_prop_ops *op;
+	struct nci_driver_ops *op;
 
 	op = ops_cmd_lookup(ops, n_ops, rsp_opcode);
 	if (!op || !op->rsp)
@@ -1275,10 +1275,10 @@ static int nci_op_rsp_packet(struct nci_dev *ndev, __u16 rsp_opcode,
 }
 
 static int nci_op_ntf_packet(struct nci_dev *ndev, __u16 ntf_opcode,
-			     struct sk_buff *skb, struct nci_prop_ops *ops,
+			     struct sk_buff *skb, struct nci_driver_ops *ops,
 			     size_t n_ops)
 {
-	struct nci_prop_ops *op;
+	struct nci_driver_ops *op;
 
 	op = ops_cmd_lookup(ops, n_ops, ntf_opcode);
 	if (!op || !op->ntf)
Signature · 1 line
1.9.1
#8 lore raw

PATCH v4 8/10 nfc: nci: fix possible crash in nci_core_conn_create

In reply to Robert Dolca

If the number of destination speific parameters supplied is 0 the call will fail. If the first destination specific parameter does not have a value, curr_id will be set to 0.

---
 net/nfc/nci/core.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
net/nfc/nci/core.c +8 -1
index f66a5da..9d5f7a2 100644
@@ -602,12 +602,19 @@ int nci_core_conn_create(struct nci_dev *ndev, u8 destination_type,
 	if (!cmd)
 		return -ENOMEM;
 
+	if (!number_destination_params)
+		return -EINVAL;
+
 	cmd->destination_type = destination_type;
 	cmd->number_destination_params = number_destination_params;
 	memcpy(cmd->params, params, params_len);
 
 	data.cmd = cmd;
-	ndev->cur_id = params->value[DEST_SPEC_PARAMS_ID_INDEX];
+
+	if (params->length > 0)
+		ndev->cur_id = params->value[DEST_SPEC_PARAMS_ID_INDEX];
+	else
+		ndev->cur_id = 0;
 
 	r = __nci_request(ndev, nci_core_conn_create_req,
 			  (unsigned long)&data,
Signature · 1 line
1.9.1
#9 lore raw

PATCH v4 9/10 nfc: nci: add nci_get_conn_info_by_id function

In reply to Robert Dolca

This functin takes as a parameter a pointer to the nci_dev struct and the first byte from the values of the first domain specific parameter that was used for the connection creation.

---
 include/net/nfc/nci_core.h |  1 +
 net/nfc/nci/core.c         | 13 +++++++++++++
 2 files changed, 14 insertions(+)
include/net/nfc/nci_core.h +1 -0
index 5daf004..0569cb2 100644
@@ -374,6 +374,7 @@ void nci_clear_target_list(struct nci_dev *ndev);
 void nci_req_complete(struct nci_dev *ndev, int result);
 struct nci_conn_info *nci_get_conn_info_by_conn_id(struct nci_dev *ndev,
 						   int conn_id);
+int nci_get_conn_info_by_id(struct nci_dev *ndev, u8 id);
 
 /* ----- NCI status code ----- */
 int nci_to_errno(__u8 code);
net/nfc/nci/core.c +13 -0
index 9d5f7a2..75bda34 100644
@@ -64,6 +64,19 @@ struct nci_conn_info *nci_get_conn_info_by_conn_id(struct nci_dev *ndev,
 	return NULL;
 }
 
+int nci_get_conn_info_by_id(struct nci_dev *ndev, u8 id)
+{
+	struct nci_conn_info *conn_info;
+
+	list_for_each_entry(conn_info, &ndev->conn_info_list, list) {
+		if (conn_info->id == id)
+			return conn_info->conn_id;
+	}
+
+	return -EINVAL;
+}
+EXPORT_SYMBOL(nci_get_conn_info_by_id);
+
 /* ---- NCI requests ---- */
 
 void nci_req_complete(struct nci_dev *ndev, int result)
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

PATCH v4 10/10 nfc: Add Intel Fields Peak NFC solution driver

In reply to Robert Dolca

Fields Peak complies with the ISO/IEC 14443A/B, 15693, 18092, and JIS X 6319-4. It is an NCI based controller.

RF Protocols supported:
- NFC Forum Type 1 Tags (Jewel, Topaz)
- NFC Forum Type 2 Tags (Mifare UL)
- NFC Forum Type 3 Tags (FeliCa)
- NFC Forum Type 4A (ISO/IEC 14443 A-4 106kbps to 848kbps)
- NFC Forum Type 4B (ISO/IEC 14443 B-4 106kbps to 848kbps)
- NFCIP in passive and active modes (ISO/IEC 18092 106kbps to 424kbps)
- B’ (based on ISO/IEC 14443 B-2)
- iCLASS (based on ISO/IEC 15693-2)
- Vicinity cards (ISO/IEC 15693-3)
- Kovio tags (NFC Forum Type 2)

The device can be enumerated using ACPI using the id INT339A. The 1st GPIO is the IRQ and the 2nd is the RESET pin.

---
 drivers/nfc/Kconfig      |   1 +
 drivers/nfc/Makefile     |   1 +
 drivers/nfc/fdp/Kconfig  |  23 ++
 drivers/nfc/fdp/Makefile |   9 +
 drivers/nfc/fdp/fdp.c    | 817 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/nfc/fdp/fdp.h    |  38 +++
 drivers/nfc/fdp/i2c.c    | 388 ++++++++++++++++++++++
 7 files changed, 1277 insertions(+)
 create mode 100644 drivers/nfc/fdp/Kconfig
 create mode 100644 drivers/nfc/fdp/Makefile
 create mode 100644 drivers/nfc/fdp/fdp.c
 create mode 100644 drivers/nfc/fdp/fdp.h
 create mode 100644 drivers/nfc/fdp/i2c.c
drivers/nfc/Kconfig +1 -0
index 6639cd1..0d6003d 100644
@@ -68,6 +68,7 @@ config NFC_PORT100
 
 	  If unsure, say N.
 
+source "drivers/nfc/fdp/Kconfig"
 source "drivers/nfc/pn544/Kconfig"
 source "drivers/nfc/microread/Kconfig"
 source "drivers/nfc/nfcmrvl/Kconfig"
drivers/nfc/Makefile +1 -0
index 2757fe1..e362141 100644
@@ -2,6 +2,7 @@
 # Makefile for nfc devices
 #
 
+obj-$(CONFIG_NFC_FDP)		+= fdp/
 obj-$(CONFIG_NFC_PN544)		+= pn544/
 obj-$(CONFIG_NFC_MICROREAD)	+= microread/
 obj-$(CONFIG_NFC_PN533)		+= pn533.o
drivers/nfc/fdp/Kconfig new file +23 -0
new file mode 100644
index 0000000..fbccd9d
@@ -0,0 +1,23 @@
+config NFC_FDP
+	tristate "Intel FDP NFC driver"
+	depends on NFC_NCI
+	select CRC_CCITT
+	default n
+	---help---
+	  Intel Fields Peak NFC controller core driver.
+	  This is a driver based on the NCI NFC kernel layers.
+
+	  To compile this driver as a module, choose m here. The module will
+	  be called fdp.
+	  Say N if unsure.
+
+config NFC_FDP_I2C
+	tristate "NFC FDP i2c support"
+	depends on NFC_FDP && I2C
+	---help---
+	  This module adds support for the Intel Fields Peak NFC controller
+	  i2c interface.
+	  Select this if your platform is using the i2c bus.
+
+	  If you choose to build a module, it'll be called fdp_i2c.
+	  Say N if unsure.
drivers/nfc/fdp/Makefile new file +9 -0
new file mode 100644
index 0000000..e79d51b
@@ -0,0 +1,9 @@
+#
+# Makefile for FDP NCI based NFC driver
+#
+
+obj-$(CONFIG_NFC_FDP)     += fdp.o
+obj-$(CONFIG_NFC_FDP_I2C) += fdp_i2c.o
+
+fdp_i2c-objs  = i2c.o
+
drivers/nfc/fdp/fdp.c new file +817 -0

817 lines not on this page · raw message

drivers/nfc/fdp/fdp.h new file +38 -0
new file mode 100644
index 0000000..0bd36c0
@@ -0,0 +1,38 @@
+/* -------------------------------------------------------------------------
+ * Copyright (C) 2014-2016, Intel Corporation
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that 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 __LOCAL_FDP_H_
+#define __LOCAL_FDP_H_
+
+#include <net/nfc/nci_core.h>
+#include <linux/gpio/consumer.h>
+
+struct fdp_i2c_phy {
+	struct i2c_client *i2c_dev;
+	struct gpio_desc *power_gpio;
+	struct nci_dev *ndev;
+
+	/* < 0 if i2c error occurred */
+	int hard_fault;
+	uint16_t next_read_size;
+};
+
+int fdp_nci_probe(struct fdp_i2c_phy *phy, struct nfc_phy_ops *phy_ops,
+		  struct nci_dev **ndev, int tx_headroom, int tx_tailroom,
+		  u8 clock_type, u32 clock_freq, u8 *fw_vsc_cfg);
+void fdp_nci_remove(struct nci_dev *ndev);
+int fdp_nci_recv_frame(struct nci_dev *ndev, struct sk_buff *skb);
+
+#endif /* __LOCAL_FDP_H_ */
drivers/nfc/fdp/i2c.c new file +388 -0

388 lines not on this page · raw message

Signature · 1 line
1.9.1