From patchwork Thu Jun 15 18:25:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Greer X-Patchwork-Id: 9789795 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8EB5B60325 for ; Thu, 15 Jun 2017 18:25:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88027284B0 for ; Thu, 15 Jun 2017 18:25:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CEBE28620; Thu, 15 Jun 2017 18:25:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2489A284B0 for ; Thu, 15 Jun 2017 18:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752700AbdFOSZg (ORCPT ); Thu, 15 Jun 2017 14:25:36 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:41667 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753195AbdFOSZb (ORCPT ); Thu, 15 Jun 2017 14:25:31 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 97B6720A95; Thu, 15 Jun 2017 14:25:19 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Thu, 15 Jun 2017 14:25:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=animalcreek.com; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=LFD p307roHZVwLDyy3qA2VOtlSDgCw8yT/fdxMqL+Yw=; b=ktTHtg47oJApcOD4Mlj JOIHcOtjbur1qyGyiWeE4KsAEz/1jrv0NMhV5D7Nn9+/w6kEsOuGDI9bZxB0WSpd Dml8QtCOzdEvoB1MjIFyjzdORHmhMwt4s6cCSmWGa1ezutBh0YauFpwdBXbqC+Ii tzryL17wp/0+lIeIfKroLVdM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=LFDp307roHZVwLDyy3qA2VOtlSDgCw8yT/fdxMqL+ Yw=; b=mVkOT4msgn6MGEc5KHAO6H0bCzfbp2FViDZKRzFiA+VsLYcFftrOxYQQF 7ooDOgLnSiqzaQ3GMiWvtFrbTNtt95VgxDUYj+9jtIssueA8Rwiht1rkMt90MczD 1x4w73F/icrlS2TyrjWbxktOz3XKhpkVKVFu/38vvSt4/oP+kF3Yp3JLWQ44O1It uspu1cUZgznoMejD6kiOIbv7DcC69Pq3LqdeSW3QdNjLPWqvn3zBVZ5HPmDyS3s2 mZ5QLONa3ahlnRDBtiM4jGGbjna97UmSfmuYYjuW/+rCuk6TgNWAxzPEV5uTkXRR rCdDMCA0RTsth1bZ8vtun2fBQ9tgA== X-ME-Sender: X-Sasl-enc: GJkSzVrzaQUFj9M01kMCVXTrjBHToFb0Ue7zboi8IvZT 1497551119 Received: from blue.animalcreek.com (ip68-2-81-12.ph.ph.cox.net [68.2.81.12]) by mail.messagingengine.com (Postfix) with ESMTPA id 2AC667E99A; Thu, 15 Jun 2017 14:25:19 -0400 (EDT) Received: from blue.animalcreek.com (localhost [127.0.0.1]) by blue.animalcreek.com (Postfix) with ESMTP id 2B8A1A20602; Thu, 15 Jun 2017 11:25:18 -0700 (MST) From: Mark Greer To: Samuel Ortiz Cc: linux-wireless@vger.kernel.org, linux-nfc@lists.01.org, Mark Greer Subject: [PATCH 17/23] nfctype5: Add support for TI Standard and Pro Type 5 tag Date: Thu, 15 Jun 2017 11:25:10 -0700 Message-Id: <20170615182516.4508-18-mgreer@animalcreek.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170615182516.4508-1-mgreer@animalcreek.com> References: <20170615182516.4508-1-mgreer@animalcreek.com> Organization: Animal Creek Technologies, Inc. Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Standard and Pro Type 5 tags from Texas Instruments do not support the Get System Information command which means they cannot be read with the current neard code. Fortunately, both types of tags have eight, 4-byte blocks so that information can be filled in instead of issuing the Get System Information command to get it. With this change, Standard and Pro tags can now be formatted, read, and written. Signed-off-by: Mark Greer --- plugins/nfctype5.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/plugins/nfctype5.c b/plugins/nfctype5.c index 689dec3..f26d8fa 100644 --- a/plugins/nfctype5.c +++ b/plugins/nfctype5.c @@ -117,6 +117,7 @@ #define TYPE5_UID_MANUFAC_IDX 0x06 #define TYPE5_UID_MANUFAC_ID_STMICRO 0x02 +#define TYPE5_UID_MANUFAC_ID_TI 0x07 struct type5_cmd_hdr { uint8_t flags; @@ -217,6 +218,49 @@ static bool t5_manufacturer_is_stmicro(struct near_tag *tag) return t5_manufacturer_is(tag, TYPE5_UID_MANUFAC_ID_STMICRO); } +static bool t5_manufacturer_is_ti(struct near_tag *tag) +{ + return t5_manufacturer_is(tag, TYPE5_UID_MANUFAC_ID_TI); +} + +static bool t5_tag_is_ti_std(struct near_tag *tag) +{ + uint8_t *uid; + bool ret = false; + + uid = near_tag_get_iso15693_uid(near_tag_get_adapter_idx(tag), + near_tag_get_target_idx(tag)); + if (!uid) { + near_error("No type 5 UID"); + return false; + } + + if ((uid[5] == 0xc0) || (uid[5] == 0xc1)) + ret = true; + + g_free(uid); + return ret; +} + +static bool t5_tag_is_ti_pro(struct near_tag *tag) +{ + uint8_t *uid; + bool ret; + + uid = near_tag_get_iso15693_uid(near_tag_get_adapter_idx(tag), + near_tag_get_target_idx(tag)); + if (!uid) { + near_error("No type 5 UID"); + return false; + } + + if ((uid[5] == 0xc4) || (uid[5] == 0xc5)) + ret = true; + + g_free(uid); + return ret; +} + static int t5_cmd_hdr_init(struct near_tag *tag, struct type5_cmd_hdr *cmd_hdr, int cmd) { @@ -851,10 +895,23 @@ static int nfctype5_read(uint32_t adapter_idx, uint32_t target_idx, * num_blks once. near_tag_get_blk_size() will return 0 if * t5_get_sys_info() hasn't been called yet. */ - if (near_tag_get_blk_size(tag)) + if (near_tag_get_blk_size(tag)) { err = t5_read_meta(tag, cookie); - else + } else if (t5_manufacturer_is_ti(tag) && + (t5_tag_is_ti_std(tag) || t5_tag_is_ti_pro(tag))) { + /* + * TI Standard and Pro tags do not support the Get System + * Information command but are known to have eight, 4-byte + * blocks so we can fill that info in and call t5_read_meta() + * here. + */ + near_tag_set_blk_size(tag, 4); + near_tag_set_num_blks(tag, 8); + + err = t5_read_meta(tag, cookie); + } else { err = t5_get_sys_info(tag, cookie); + } if (err < 0) err = t5_cookie_release(err, cookie);