From patchwork Thu Dec 15 22:30:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Lansberry X-Patchwork-Id: 9477055 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 EE0D760571 for ; Thu, 15 Dec 2016 22:31:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0C9025F3E for ; Thu, 15 Dec 2016 22:31:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D571528868; Thu, 15 Dec 2016 22:31:58 +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=unavailable 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 718CF25F3E for ; Thu, 15 Dec 2016 22:31:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754477AbcLOWaz (ORCPT ); Thu, 15 Dec 2016 17:30:55 -0500 Received: from mail-qk0-f173.google.com ([209.85.220.173]:35691 "EHLO mail-qk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753772AbcLOWax (ORCPT ); Thu, 15 Dec 2016 17:30:53 -0500 Received: by mail-qk0-f173.google.com with SMTP id n204so73052324qke.2 for ; Thu, 15 Dec 2016 14:30:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kuvee-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=moYhG0lXm05c4p32dG1GdISF3tyMvzckJ5loLrOmU/8=; b=gisK9yhS2TTc3FwvkHcawI58TEtY+NC6ntlXcKkJ5ZZnBrLmzGRXoCJr6VPvh7Jita a6ovqdBkzl6ti/yZ9+3zukGMvuDBaS2c1V/nIehAKOwkIyNoyuGlYyNgyhUsfsPc4ek1 /jjBXifDS0q3dLAkRcHlu73gFEqiWm7yStcnOZCT76uu9F+3aHVN8TOWNuJHfj83mI8j HqW+CejT2hvCxII3h6EaalZbi+GuyYMQy3FY76jMMyO59rCg6x/YLchvvXnwyaDNS8ZR Fki4jyX0jUzH5DNRmMZ8QZTZqCmAFnysR2ddySRGsdpUKKNLN4x7xCgK1GWIuTHLzj8J m6pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=moYhG0lXm05c4p32dG1GdISF3tyMvzckJ5loLrOmU/8=; b=NdsVaSfbxvNuDF3+YKwplB07hiXSczXtRvLmDcLtEynpuGxR/wT1IWFgEOPH3L2aCR Jt8VUTKtmOVppaNHHZAJ1c11dE088yMbefW+R6cpcRM9aWMdSySdj77NcQxEEImejitf nd/6GSEorULcVvQnxMl04/J1lR8YCsPZj/rjwOWQomTaGg7yMJHED5OS8mzCP702+iCR /0gBwOYNYtBg6TuKxtoas1X7WCMnP1xKBruNIY5GMkmKBtLNEK/HnS951fPUeT8kV8vn DpD21KbxXfgL5J+pdeeSwmGH3F7DHq53MpCnZQTyRgp3wyzhlB/gROrJ8dkXNZuNWp/g 8cGA== X-Gm-Message-State: AIkVDXLn5RfzlNqsPdlX6pha+Kd3Pa8qfIp9NvK4mVG+9CxrN0VeTZnzrq443kE6RFMXHQ== X-Received: by 10.55.170.206 with SMTP id t197mr801527qke.154.1481841051488; Thu, 15 Dec 2016 14:30:51 -0800 (PST) Received: from localhost.localdomain (c-73-119-141-105.hsd1.ma.comcast.net. [73.119.141.105]) by smtp.googlemail.com with ESMTPSA id f36sm2166515qkf.43.2016.12.15.14.30.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Dec 2016 14:30:50 -0800 (PST) From: Geoff Lansberry X-Google-Original-From: Geoff Lansberry To: linux-wireless@vger.kernel.org Cc: lauro.venancio@openbossa.org, aloisio.almeida@openbossa.org, sameo@linux.intel.com, robh+dt@kernel.org, mark.rutland@arm.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, mgreer@animalcreek.com, justin@kuvee.com, Geoff Lansberry Subject: [PATCH 1/3] NFC: trf7970a: add device tree option for 27MHz clock Date: Thu, 15 Dec 2016 17:30:42 -0500 Message-Id: <1481841044-4314-1-git-send-email-glansberry@gmail.com> X-Mailer: git-send-email 2.7.4 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 From: Geoff Lansberry --- .../devicetree/bindings/net/nfc/trf7970a.txt | 3 ++ drivers/nfc/trf7970a.c | 42 ++++++++++++++++------ 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/net/nfc/trf7970a.txt b/Documentation/devicetree/bindings/net/nfc/trf7970a.txt index 32b35a0..9dda879 100644 --- a/Documentation/devicetree/bindings/net/nfc/trf7970a.txt +++ b/Documentation/devicetree/bindings/net/nfc/trf7970a.txt @@ -21,6 +21,8 @@ Optional SoC Specific Properties: - t5t-rmb-extra-byte-quirk: Specify that the trf7970a has the erratum where an extra byte is returned by Read Multiple Block commands issued to Type 5 tags. +- crystal_27mhz: Set to specify that the input frequency to the trf7970a is 27.12MHz + Example (for ARM-based BeagleBone with TRF7970A on SPI1): @@ -43,6 +45,7 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1): irq-status-read-quirk; en2-rf-quirk; t5t-rmb-extra-byte-quirk; + crystal_27mhz; status = "okay"; }; }; diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c index 26c9dbb..2d2a077 100644 --- a/drivers/nfc/trf7970a.c +++ b/drivers/nfc/trf7970a.c @@ -1056,12 +1056,11 @@ static int trf7970a_init(struct trf7970a *trf) trf->chip_status_ctrl &= ~TRF7970A_CHIP_STATUS_RF_ON; - ret = trf7970a_write(trf, TRF7970A_MODULATOR_SYS_CLK_CTRL, 0); + ret = trf7970a_write(trf, TRF7970A_MODULATOR_SYS_CLK_CTRL, + trf->modulator_sys_clk_ctrl); if (ret) goto err_out; - trf->modulator_sys_clk_ctrl = 0; - ret = trf7970a_write(trf, TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS, TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLH_96 | TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLL_32); @@ -1181,27 +1180,37 @@ static int trf7970a_in_config_rf_tech(struct trf7970a *trf, int tech) switch (tech) { case NFC_DIGITAL_RF_TECH_106A: trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_14443A_106; - trf->modulator_sys_clk_ctrl = TRF7970A_MODULATOR_DEPTH_OOK; + trf->modulator_sys_clk_ctrl = + (trf->modulator_sys_clk_ctrl & 0xF8) | + TRF7970A_MODULATOR_DEPTH_OOK; trf->guard_time = TRF7970A_GUARD_TIME_NFCA; break; case NFC_DIGITAL_RF_TECH_106B: trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_14443B_106; - trf->modulator_sys_clk_ctrl = TRF7970A_MODULATOR_DEPTH_ASK10; + trf->modulator_sys_clk_ctrl = + (trf->modulator_sys_clk_ctrl & 0xF8) | + TRF7970A_MODULATOR_DEPTH_ASK10; trf->guard_time = TRF7970A_GUARD_TIME_NFCB; break; case NFC_DIGITAL_RF_TECH_212F: trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_FELICA_212; - trf->modulator_sys_clk_ctrl = TRF7970A_MODULATOR_DEPTH_ASK10; + trf->modulator_sys_clk_ctrl = + (trf->modulator_sys_clk_ctrl & 0xF8) | + TRF7970A_MODULATOR_DEPTH_ASK10; trf->guard_time = TRF7970A_GUARD_TIME_NFCF; break; case NFC_DIGITAL_RF_TECH_424F: trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_FELICA_424; - trf->modulator_sys_clk_ctrl = TRF7970A_MODULATOR_DEPTH_ASK10; + trf->modulator_sys_clk_ctrl = + (trf->modulator_sys_clk_ctrl & 0xF8) | + TRF7970A_MODULATOR_DEPTH_ASK10; trf->guard_time = TRF7970A_GUARD_TIME_NFCF; break; case NFC_DIGITAL_RF_TECH_ISO15693: trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_15693_SGL_1OF4_2648; - trf->modulator_sys_clk_ctrl = TRF7970A_MODULATOR_DEPTH_OOK; + trf->modulator_sys_clk_ctrl = + (trf->modulator_sys_clk_ctrl & 0xF8) | + TRF7970A_MODULATOR_DEPTH_OOK; trf->guard_time = TRF7970A_GUARD_TIME_15693; break; default: @@ -1571,17 +1580,23 @@ static int trf7970a_tg_config_rf_tech(struct trf7970a *trf, int tech) trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_NFC_NFC_CE_MODE | TRF7970A_ISO_CTRL_NFC_CE | TRF7970A_ISO_CTRL_NFC_CE_14443A; - trf->modulator_sys_clk_ctrl = TRF7970A_MODULATOR_DEPTH_OOK; + trf->modulator_sys_clk_ctrl = + (trf->modulator_sys_clk_ctrl & 0xF8) | + TRF7970A_MODULATOR_DEPTH_OOK; break; case NFC_DIGITAL_RF_TECH_212F: trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_NFC_NFC_CE_MODE | TRF7970A_ISO_CTRL_NFC_NFCF_212; - trf->modulator_sys_clk_ctrl = TRF7970A_MODULATOR_DEPTH_ASK10; + trf->modulator_sys_clk_ctrl = + (trf->modulator_sys_clk_ctrl & 0xF8) | + TRF7970A_MODULATOR_DEPTH_ASK10; break; case NFC_DIGITAL_RF_TECH_424F: trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_NFC_NFC_CE_MODE | TRF7970A_ISO_CTRL_NFC_NFCF_424; - trf->modulator_sys_clk_ctrl = TRF7970A_MODULATOR_DEPTH_ASK10; + trf->modulator_sys_clk_ctrl = + (trf->modulator_sys_clk_ctrl & 0xF8) | + TRF7970A_MODULATOR_DEPTH_ASK10; break; default: dev_dbg(trf->dev, "Unsupported rf technology: %d\n", tech); @@ -2043,6 +2058,11 @@ static int trf7970a_probe(struct spi_device *spi) return ret; } + if (of_property_read_bool(np, "crystal_27mhz")) { + trf->modulator_sys_clk_ctrl = TRF7970A_MODULATOR_27MHZ; + dev_dbg(trf->dev, "trf7970a configure crystal_27mhz\n"); + } + if (of_property_read_bool(np, "en2-rf-quirk")) trf->quirks |= TRF7970A_QUIRK_EN2_MUST_STAY_LOW;