Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp630093imd; Thu, 1 Nov 2018 03:04:14 -0700 (PDT) X-Google-Smtp-Source: AJdET5fmHP24c2+x3D6U2rGxsPzipzcApikTIbf/qiFCOQiWwGEtXHq67WWhJMCBtf4Eki5RQMaT X-Received: by 2002:a63:f30d:: with SMTP id l13mr6609292pgh.399.1541066654122; Thu, 01 Nov 2018 03:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541066654; cv=none; d=google.com; s=arc-20160816; b=rVRdXScObJ8hY/auHsjU/c4cy0/QqERVRGXTRuyqRE42W+HBGuh9Qs3zhs4l0BXU/3 mzcicrwK0o05teALlf8CH3/cqQn7eK+5glX8Bn64yLt4RBWxOC98qY5j9Fe41Aj0VH19 yyBS5cIlbQWEI4E472X+Xep2WzTabr7mJDoYNExNZOu6hP8EY+hBRrm4hNPkNPZ2OHVz G+4QoSdrk8IKnQ/sTWkYRpz/Mlg10N4HVAlSTqAIxStacrYt39aWRAvhykqAU6Q9zLqx FolyuoDFByVND2ZtIU1IHoIOymZe03hlqzaDL695OKa5PXkSmKCw1txQRmBXVhUo0Nns QnQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=LZSmhuyFmgg30OovAgr+s4fVioqLdBmiyZN9Oo6gFG0=; b=HxO49+dwCUtAyQ7OZipZ4uX/yrpH/q4nPfMF+506N/3mlCMwXvAcwBEnac1n7AhDmt MD1j+ZtsXu5BqHvorp+PXh1tVBNROp/3rDYQil4/ut5Ou8sA/sSaanR0Fz2dpjSHVP/j o0Q1NTVp+C6FnLNK2QTveqoJz5ZUmnw173EXeiV+0Dax+qwE4remPK4tHkI8JJXl1s2d qtr1lMOf5mNAbOHqgGiarHI0IvVjNigYFujryeulcCsEF2gPFtA8h4yPv15UGT6XWJ4T UVcVb1VFrvsFiLVcL5A3rS6xI+CkW3R7EmXqnMTx/ZK+D5rHO5CDEdVdlw3WLYeoyo++ Jofw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n78-v6si19568861pfi.171.2018.11.01.03.03.59; Thu, 01 Nov 2018 03:04:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728268AbeKATFp (ORCPT + 99 others); Thu, 1 Nov 2018 15:05:45 -0400 Received: from smtp3-1.goneo.de ([85.220.129.38]:35258 "EHLO smtp3-1.goneo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726320AbeKATFp (ORCPT ); Thu, 1 Nov 2018 15:05:45 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp3.goneo.de (Postfix) with ESMTP id 581E723F83E; Thu, 1 Nov 2018 11:03:25 +0100 (CET) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -3.105 X-Spam-Level: X-Spam-Status: No, score=-3.105 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.205, BAYES_00=-1.9] autolearn=ham Received: from smtp3.goneo.de ([127.0.0.1]) by localhost (smtp3.goneo.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RgZlqvnTZ_oD; Thu, 1 Nov 2018 11:03:24 +0100 (CET) Received: from lem-wkst-02.lemonage.de. (hq.lemonage.de [87.138.178.34]) by smtp3.goneo.de (Postfix) with ESMTPA id 3263B23F486; Thu, 1 Nov 2018 11:03:24 +0100 (CET) From: Lars Poeschel To: devicetree@vger.kernel.org, Samuel Ortiz , Kees Cook , Lars Poeschel , linux-wireless@vger.kernel.org (open list:NFC SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 3/6] nfc: pn533: Add dev_up/dev_down hooks to phy_ops Date: Thu, 1 Nov 2018 11:02:11 +0100 Message-Id: <20181101100216.613-3-poeschel@lemonage.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181101100216.613-1-poeschel@lemonage.de> References: <20181101100216.613-1-poeschel@lemonage.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds hooks for dev_up and dev_down to the phy_ops. They are optional. The idea is to inform the phy driver when the nfc chip is really going to be used. When it is not used, the phy driver can suspend it's interface to the nfc chip to save some power. The nfc chip is considered not in use before dev_up and after dev_down. Signed-off-by: Lars Poeschel --- Changes in v4: - This patch is new in v4 drivers/nfc/pn533/pn533.c | 12 +++++++++++- drivers/nfc/pn533/pn533.h | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c index a0cc1cc45292..f0c541152777 100644 --- a/drivers/nfc/pn533/pn533.c +++ b/drivers/nfc/pn533/pn533.c @@ -2468,6 +2468,9 @@ static int pn533_dev_up(struct nfc_dev *nfc_dev) { struct pn533 *dev = nfc_get_drvdata(nfc_dev); + if (dev->phy_ops) + dev->phy_ops->dev_up(dev); + if (dev->device_type == PN533_DEVICE_PN532) { int rc = pn532_sam_configuration(nfc_dev); @@ -2480,7 +2483,14 @@ static int pn533_dev_up(struct nfc_dev *nfc_dev) static int pn533_dev_down(struct nfc_dev *nfc_dev) { - return pn533_rf_field(nfc_dev, 0); + struct pn533 *dev = nfc_get_drvdata(nfc_dev); + int ret; + + ret = pn533_rf_field(nfc_dev, 0); + if (dev->phy_ops && !ret) + dev->phy_ops->dev_down(dev); + + return ret; } static struct nfc_ops pn533_nfc_ops = { diff --git a/drivers/nfc/pn533/pn533.h b/drivers/nfc/pn533/pn533.h index 88d569666c51..eb5ccefc32e5 100644 --- a/drivers/nfc/pn533/pn533.h +++ b/drivers/nfc/pn533/pn533.h @@ -219,6 +219,15 @@ struct pn533_phy_ops { struct sk_buff *out); int (*send_ack)(struct pn533 *dev, gfp_t flags); void (*abort_cmd)(struct pn533 *priv, gfp_t flags); + /* + * dev_up and dev_down are optional. + * They are used to inform the phy layer that the nfc chip + * is going to be really used very soon. The phy layer can then + * bring up it's interface to the chip and have it suspended for power + * saving reasons otherwise. + */ + void (*dev_up)(struct pn533 *priv); + void (*dev_down)(struct pn533 *priv); }; -- 2.19.1