Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp989770imu; Fri, 11 Jan 2019 12:49:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN74AHa7Y1WGAj+dEXLnxen0fze0eC1lQwaiToaFGdAP6beYBcdqQplWZ0yJXB8hoBXedq86 X-Received: by 2002:a63:104d:: with SMTP id 13mr14819487pgq.303.1547239783508; Fri, 11 Jan 2019 12:49:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547239783; cv=none; d=google.com; s=arc-20160816; b=jdDtutjJUgrMl6Q5Kr/CrB6apajtjgdlOc8D0ciBH2DGVtigs6I60GaYKBeXcJ1Jw3 DphOEaMCoDDw9JQnRAFFc5lrmo/rJ729u9QR6IOKqKuG/abh+p0see4DYadR3PRxXlGR T5s8VrENBE2itR55ORkFU5UxcabHnC5SuxKst3PUG3EphXTeIH2uNulKb7grmkgtQ5wi 7QBUykEBPIhhtvl0GFepfK3Ub3XF/lykVX/21PSog2z4Ejjkj6OrweRWpU6mQuMHBNdO YE/93WGnWFC8mdvPAOveEAvAZ1JZHf7YES9aZLVb7KphkSOpuxJvnrdQK37uJA6ImJ3O Wmpw== 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:cc:to:from; bh=YXWIsOjJxIqCANDa9WZY27dxxW0f5+wPMswHdyQ5Vnk=; b=BBEoC87FuMy4k0X416EFAXZhzMb0lGEOzJwQBXVA7pQgQc0LP+X0YpqtUyegfqZ3BY EuD8JrW6ZfhkNTM2js96ycYdqx1E9jpJgLgA50sa5JEZxP93hTy5Mkh6362WZBUhPzUj GPIQ8zwpyT/TMZadUgQdQDMXwxUr8qMnzRAYy0DnrJNTDSoGdFl1OQPYHoGS3ib0vUO1 uztRw/bHZ+y+Z+ofwcB7wSsE0iWczhDw+ruz2lTmw80BXp2HV13ugOWGAQ/HcwfYJk1A t8FVxg1e87qmr3f/6GA6eKFNSN6HIqpSxwvq5eaR6XTsLAuZej7N4f1N3KR9+CiZym+b EN7Q== 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 h191si57641821pgc.302.2019.01.11.12.49.28; Fri, 11 Jan 2019 12:49:43 -0800 (PST) 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 S2391964AbfAKPMU (ORCPT + 99 others); Fri, 11 Jan 2019 10:12:20 -0500 Received: from smtp3.goneo.de ([85.220.129.37]:49212 "EHLO smtp3.goneo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731050AbfAKPMS (ORCPT ); Fri, 11 Jan 2019 10:12:18 -0500 Received: from localhost (localhost [127.0.0.1]) by smtp3.goneo.de (Postfix) with ESMTP id 3AF0B240000; Fri, 11 Jan 2019 16:12:15 +0100 (CET) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -3.078 X-Spam-Level: X-Spam-Status: No, score=-3.078 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.178, 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 glWbOeY2Eqlb; Fri, 11 Jan 2019 16:12:14 +0100 (CET) Received: from lem-wkst-02.lemonage.de. (hq.lemonage.de [87.138.178.34]) by smtp3.goneo.de (Postfix) with ESMTPA id 1AF9124001C; Fri, 11 Jan 2019 16:12:14 +0100 (CET) From: Lars Poeschel To: devicetree@vger.kernel.org, Samuel Ortiz , "GitAuthor: Lars Poeschel" , linux-wireless@vger.kernel.org (open list:NFC SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Cc: Johan Hovold Subject: [PATCH v5 3/7] nfc: pn533: Add dev_up/dev_down hooks to phy_ops Date: Fri, 11 Jan 2019 17:18:06 +0100 Message-Id: <20190111161812.26325-3-poeschel@lemonage.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111161812.26325-1-poeschel@lemonage.de> References: <20190111161812.26325-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. Cc: Johan Hovold Signed-off-by: Lars Poeschel --- Changes in v5: - (dev->phy_ops->dev_up) instead (dev->phy_ops) 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..1bc097d03789 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_up) + 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->dev_down && !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.20.1