From patchwork Fri Jun 9 15:42:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Hackley X-Patchwork-Id: 105720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1045775vqr; Fri, 9 Jun 2023 09:03:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6DL6HPI23TIKCZjF46Wf9GOhqDsXt+H+Lw+SewyEpfLnsmf3gYorBvtDnlJsCR20dltChy X-Received: by 2002:a05:6a00:1c83:b0:64d:42b9:6895 with SMTP id y3-20020a056a001c8300b0064d42b96895mr6213218pfw.5.1686326635780; Fri, 09 Jun 2023 09:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686326635; cv=none; d=google.com; s=arc-20160816; b=URPjBCw+bRnzCm9pDmSaENkBVWGMoXeN2FNqCQuCPTUdLjJOIlQS+Th14VfjUdnhg5 ljk5g2ULJ3QzQyHPbkmJjM2yRJTwqo+3QMPoKCypOtZo5I/cG5gu6/4C0Z8cfhK3f8z6 kLxlr3qBUqWZJXSkRGGhB2u9yVjypPlvgMZbbXG97Fw4LO1VklEeuamaqiIZTAdLLDWv eKwYyszv/ZVM2crAGN/1BCUxg71tw5RjcVN2mlpZuVcrSaQOeBx39x/tNhDvMP+u0/IF mFv0bQdTpjK5Nk6T31RKnRkNod8t9oY+g/Y1qE+Dc9LLCXARVaEyaVfXPHbVXfBMFZKQ D26w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :dkim-signature:date; bh=0ZCYTq1OJ9ne6rrLmF3n5ebjjUoiWyyt/yw2i6ZwXrY=; b=gGDAVEwfJF/Eg+AxVU4LNIfeRJipvH6Vd1h+TaudC5fpptBBP9YXRXE3JLT8nPHamM RAVDyNWUMumirVyLSLybnYGEyWCIW35Dxhb06Ut8OsFGfUdXsHfJxkl3qIOglWFDhqmz uOwWYYJQE2LwFFnhFbTpGRJIUH/LLjTfDrcs4l/9lTeZ1W87Lx7hHUx9nqZ6N1kJNJyB cqHNm3Wt/ziATn+XyQbaLDnGg15XOYXM3NfomzrQwsUlbnPIieevb7TQ8hdLoCcgiN3O cp8jqi4UL/4TAh/eTR7yb9NO9DLbVhraPHUoMuztAd0vwupmHtA0exutI+CLy2WCUMjh z8LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=Nd4w57Qn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k11-20020aa790cb000000b0066022ba7f10si2711703pfk.100.2023.06.09.09.03.36; Fri, 09 Jun 2023 09:03:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=Nd4w57Qn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241849AbjFIPmm (ORCPT + 99 others); Fri, 9 Jun 2023 11:42:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241861AbjFIPmO (ORCPT ); Fri, 9 Jun 2023 11:42:14 -0400 Received: from mail-0301.mail-europe.com (mail-0301.mail-europe.com [188.165.51.139]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 017C830F7; Fri, 9 Jun 2023 08:42:14 -0700 (PDT) Date: Fri, 09 Jun 2023 15:42:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1686325330; x=1686584530; bh=0ZCYTq1OJ9ne6rrLmF3n5ebjjUoiWyyt/yw2i6ZwXrY=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Nd4w57QnR41eHmiT2b0ea9VYXdx4NEBAIhXQ2hEAK929KC4yoByAbx3V1+lgVghkr UQyuS1ErwU7pXLBvAaI4JJ97HzQC3VK6ayzRC5o7/ltIcCd6LiQn52oSAxZx8qRPfR Yx7NF5xYmYTfcwan7W7rLGW8fAbILEBB0qK2a8Hbl61OYcz7IKRfKGpYZo6bot6Lhl 7mZ2xwMdvo5T6nhbXQLNWJCrMsqypStot1tvSQMV1KEi3Hu6p9fwGV0bQ7lmxeEeHW 7kLF56mONnpkcXqr6RjYRqRZ8h7G18hkJ3GOHAnFxXxkSsBQ7v8DRI8PZjzKj6tq1E d87F1EkSLOM9g== To: linux-kernel@vger.kernel.org From: Raymond Hackley Cc: Krzysztof Kozlowski , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Liam Girdwood , Mark Brown , Michael Walle , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Jeremy Kerr , Raymond Hackley , netdev@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 1/2] dt-bindings: nfc: nxp-nci: document pvdd-supply Message-ID: <20230609154139.3566-1-raymondhackley@protonmail.com> In-Reply-To: <20230609154033.3511-1-raymondhackley@protonmail.com> References: <20230609154033.3511-1-raymondhackley@protonmail.com> Feedback-ID: 49437091:user:proton MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768241638250483240?= X-GMAIL-MSGID: =?utf-8?q?1768241638250483240?= PN547/553, QN310/330 chips on some devices require a pad supply voltage (PVDD). Otherwise, the NFC won't power up. Document support for pad supply voltage pvdd-supply that is enabled by the nxp-nci driver so that the regulator gets enabled when needed. Signed-off-by: Raymond Hackley Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/net/nfc/nxp,nci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/net/nfc/nxp,nci.yaml b/Documentation/devicetree/bindings/net/nfc/nxp,nci.yaml index 6924aff0b2c5..d5a4f935c2ce 100644 --- a/Documentation/devicetree/bindings/net/nfc/nxp,nci.yaml +++ b/Documentation/devicetree/bindings/net/nfc/nxp,nci.yaml @@ -25,6 +25,11 @@ properties: firmware-gpios: description: Output GPIO pin used to enter firmware download mode + pvdd-supply: + description: | + Optional regulator that provides pad supply voltage for some + controllers + interrupts: maxItems: 1 From patchwork Fri Jun 9 15:42:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Hackley X-Patchwork-Id: 105719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1042759vqr; Fri, 9 Jun 2023 09:00:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7T3Yow+gfySrJ5dsQi6wEVsmHAYBOF3Q4NqApLuOlYwr6NXSsdBDsOrdgELz6xH032+FjP X-Received: by 2002:a05:6a21:99a5:b0:10c:62b3:7dc4 with SMTP id ve37-20020a056a2199a500b0010c62b37dc4mr1415263pzb.55.1686326447677; Fri, 09 Jun 2023 09:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686326447; cv=none; d=google.com; s=arc-20160816; b=llphQORFi2hd9dVFmAdNiBG0pMwgaTta+nbwz07n4/KQnDGHwAtwXCXS8b09433YWq bmU+7HvDyCEpi4pblqE6zBgz2uW0YkVtwMMUIdtKbaLBklSsP8V4f84jaWrL3bfnHIIa aWZcfjJnu8z6WM3LweXvpyYqsJ4Iq8NkWOaAkc+qErn3Jg+S+h4KgQfxCnefG/QbEyzJ xJa250fKDM5Pw5f3Jz64vmVBa4hYPkkaEvHRUzTlK3Chm15mJgsyO4zIFL8H9IMztAjH YBW6kNbPx+6hkpOFPnFHo84twGlHsTLfBf3V+YRPBRKGOxIDlzu6ee+3SQRnE2+hCnqZ 8uvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :dkim-signature:date; bh=xadFqMnNfgl6gT0vaVLmkE//dImhTGrrvi/LgkS3A0c=; b=jzKLJwE/YDnNhKDqf4o2mgzRzAp9pxmLBGbWseSoM6ezLgYgMPldsB+Qod93mPtEX6 LRtihKP3P6Q9uu+IpNE8j3Qr67WGLcYBd5ef6G7IhF/QM179/slbEMuaJ2Z0+H0pFezz 7DnUDDT/o9xmJQDQ7BTjxaDF1TnfmzPYwhFXtVq2y0xlhnb4PqEz9KaT+ST2LHdbOBez eq0gsfukNIb4TwQbgVkPTKcw6Cleleb/svzAWhpVt4iYGseB750QXSO3LrJQ+HDLABjo 331yHl13f6vcJLZx+UNg7JAHAE6oqSksiq+peD01D5DTDqynZS0ffUsrmq38tAdxxqTV 5wMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=eM8aZ7y+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b142-20020a621b94000000b0064f735aef04si2624999pfb.209.2023.06.09.09.00.23; Fri, 09 Jun 2023 09:00:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=eM8aZ7y+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241866AbjFIPmp (ORCPT + 99 others); Fri, 9 Jun 2023 11:42:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241900AbjFIPmc (ORCPT ); Fri, 9 Jun 2023 11:42:32 -0400 Received: from mail-40138.protonmail.ch (mail-40138.protonmail.ch [185.70.40.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A1CE30F7 for ; Fri, 9 Jun 2023 08:42:31 -0700 (PDT) Date: Fri, 09 Jun 2023 15:42:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1686325349; x=1686584549; bh=xadFqMnNfgl6gT0vaVLmkE//dImhTGrrvi/LgkS3A0c=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=eM8aZ7y+NM3rLwsevMhMxoeqKFgofaRbvBfA1ynKoGI8Oykbrfy6mIfE5ahu+SvWa xjwl76l4Bkqg6hiGtbDzfAJrnovcwfOFSTJugu/P9xK7W8QfKrc8Vw+mzFk6GvaIUR 91Dl98z0l7AAGCsKtC1OGNdv2tj48u+7LInVGv18OW+11cAo+SKAMB8esB9kD+XDuK 7Anic43oM4dz0RtpOnWpwksrVOrSvMvS6+6zjsQf6EWO4uLjGSzZVJ5LRCHouvaYz3 xF9Jk6wqpm+TeOUcF4DsyhyHMeGKhReUpAgEwPgFoGwVHylaEBkCJ3x2RcNAfsNng2 PtWc9X6Ru8UDg== To: linux-kernel@vger.kernel.org From: Raymond Hackley Cc: Krzysztof Kozlowski , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Liam Girdwood , Mark Brown , Michael Walle , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Jeremy Kerr , Raymond Hackley , netdev@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 2/2] NFC: nxp-nci: Add pad supply voltage pvdd-supply Message-ID: <20230609154200.3620-1-raymondhackley@protonmail.com> In-Reply-To: <20230609154033.3511-1-raymondhackley@protonmail.com> References: <20230609154033.3511-1-raymondhackley@protonmail.com> Feedback-ID: 49437091:user:proton MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768241441435732038?= X-GMAIL-MSGID: =?utf-8?q?1768241441435732038?= PN547/553, QN310/330 chips on some devices require a pad supply voltage (PVDD). Otherwise, the NFC won't power up. Implement support for pad supply voltage pvdd-supply that is enabled by the nxp-nci driver so that the regulator gets enabled when needed. Signed-off-by: Raymond Hackley --- drivers/nfc/nxp-nci/i2c.c | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c index d4c299be7949..1b8877757cee 100644 --- a/drivers/nfc/nxp-nci/i2c.c +++ b/drivers/nfc/nxp-nci/i2c.c @@ -35,6 +35,7 @@ struct nxp_nci_i2c_phy { struct gpio_desc *gpiod_en; struct gpio_desc *gpiod_fw; + struct regulator *pvdd; int hard_fault; /* * < 0 if hardware error occurred (e.g. i2c err) @@ -263,6 +264,22 @@ static const struct acpi_gpio_mapping acpi_nxp_nci_gpios[] = { { } }; +static void nxp_nci_i2c_poweroff(void *data) +{ + struct nxp_nci_i2c_phy *phy = data; + struct device *dev = &phy->i2c_dev->dev; + struct regulator *pvdd = phy->pvdd; + int r; + + if (!IS_ERR(pvdd) && regulator_is_enabled(pvdd)) { + r = regulator_disable(pvdd); + if (r < 0) + dev_warn(dev, + "Failed to disable regulator pvdd: %d\n", + r); + } +} + static int nxp_nci_i2c_probe(struct i2c_client *client) { struct device *dev = &client->dev; @@ -298,6 +315,29 @@ static int nxp_nci_i2c_probe(struct i2c_client *client) return PTR_ERR(phy->gpiod_fw); } + phy->pvdd = devm_regulator_get_optional(dev, "pvdd"); + if (IS_ERR(phy->pvdd)) { + r = PTR_ERR(phy->pvdd); + if (r != -ENODEV) + return dev_err_probe(dev, r, + "Failed to get regulator pvdd\n"); + } else { + r = regulator_enable(phy->pvdd); + if (r < 0) { + nfc_err(dev, + "Failed to enable regulator pvdd: %d\n", + r); + return r; + } + } + + r = devm_add_action_or_reset(dev, nxp_nci_i2c_poweroff, phy); + if (r < 0) { + nfc_err(dev, "Failed to install poweroff handler: %d\n", + r); + return r; + } + r = nxp_nci_probe(phy, &client->dev, &i2c_phy_ops, NXP_NCI_I2C_MAX_PAYLOAD, &phy->ndev); if (r < 0) @@ -319,6 +359,8 @@ static void nxp_nci_i2c_remove(struct i2c_client *client) nxp_nci_remove(phy->ndev); free_irq(client->irq, phy); + + nxp_nci_i2c_poweroff(phy); } static const struct i2c_device_id nxp_nci_i2c_id_table[] = {