From patchwork Fri Jun 9 18:27:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Hackley X-Patchwork-Id: 105761 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1109266vqr; Fri, 9 Jun 2023 11:39:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6pcKAf6d7au+P/yx1b+Lx+b9nSPcOT88hh0mDS/JmBNB8k75pz/GeWkNJ5cV455lIvKD2K X-Received: by 2002:a17:902:bb10:b0:1b1:9069:db5f with SMTP id im16-20020a170902bb1000b001b19069db5fmr2879882plb.18.1686335940883; Fri, 09 Jun 2023 11:39:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686335940; cv=none; d=google.com; s=arc-20160816; b=Yp14yX6AXigxT+CNEue5D8OEjgEExVUlKXWm4fObVSsgHBqlQmABzGSndMXik/dGs2 y5WY2BpCoTj8zHPZ+U2LQfIdapc0ZjQuGjUb0NxL7zcqzUT7gOi5k0sChWtcP/Oo2GuS R2KemWam41mB1sezAdk4gWE2po15qw/kZ0/Osg0SpSMRU6H2EamaoburTgjCDaMhltI6 c/t8MBJaxfii6jhkvjIztZNypGUTd8vDSFgZOHVCeHCR4yzAeCVofA8OCXXxDD4DgZnF rytFuIWX0G13jRy/isDP1PnHI9t1SCk66nKtlNPGBFvzQbuwDjJRaLVjNCc8EyNQ5rqb dGjQ== 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=wC1Rmgh+rgTxPP6e+KYyVArj+O28ZKvzx3z/KBGoYTssXMbRdmgNxcoEu4MbxZltTb y5Il1PZuf+LtbFpRbFp4ANEvULW14OvDDhMaytrSAVGFSbnsdvI+XMw+odeSO87Z5Hr8 aVZajdM7ooif6h5HLbhhThXJhLdKKFQGHyyROnAUwQgQjFZizo44mdcV7iVV5/Q91UK8 GTwvKsHN3+C1M4OPdauV8/uBsqbP3mMPikK8XFzImkXmWj45z8zQs2nZrIzkSttFa/CK eClLQzfu379D/zvEMzmVsvpFZMJZ/q7GCqyvDVXVYCoKNvS0Zl7bC+k3aMoWuSTKQSeW rCpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=B9jtlHPi; 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 y15-20020a17090322cf00b001b055bd62f6si3148331plg.431.2023.06.09.11.38.47; Fri, 09 Jun 2023 11:39:00 -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=B9jtlHPi; 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 S229620AbjFIS2H (ORCPT + 99 others); Fri, 9 Jun 2023 14:28:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjFIS2G (ORCPT ); Fri, 9 Jun 2023 14:28:06 -0400 Received: from mail-40140.protonmail.ch (mail-40140.protonmail.ch [185.70.40.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDC1D35B3 for ; Fri, 9 Jun 2023 11:28:04 -0700 (PDT) Date: Fri, 09 Jun 2023 18:27:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1686335283; x=1686594483; 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=B9jtlHPiBJNgXuNZ4M/cV7hpj9h6PwzDPFawkPzc3uz/9RjAFfGgtOlYCslUKZVd2 +KRyrMahwbbs2y5DWBybGp2dcjYFDnoQIqnuPMF+tzO49HVSAmiAcQjpI/ZwChdYYR 6+swcSAHyLgAHl0S0QmE4YZ4aOuR31Y0yu91Ip747WFBGocP0S+Rz6UtxkqnY552zp hnpHKAX3fflk8SPsZk6u4VHDbJ0i9vng1sptm20jOD0+OnAInI9gVea6yC1q74Pkec gMDY9Xt1BFlHohrwNzk1CpA8QSI3dQrSpJwWpVA7t54LqFihKeX34GdXOELMXHxxX3 qJSVj5D+KFLpw== 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 v3 1/2] dt-bindings: nfc: nxp-nci: document pvdd-supply Message-ID: <20230609182729.85088-1-raymondhackley@protonmail.com> In-Reply-To: <20230609182639.85034-1-raymondhackley@protonmail.com> References: <20230609182639.85034-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=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?1768251395428009949?= X-GMAIL-MSGID: =?utf-8?q?1768251395428009949?= 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 18:28:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Hackley X-Patchwork-Id: 105762 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1109319vqr; Fri, 9 Jun 2023 11:39:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ55RjtM3k+R9lYq9B9Mo7pCzPQmRd13uU4cWo5qRZjRhomkPs/de6df/j3oUGgKjR4YIOc/ X-Received: by 2002:a05:6a00:ac3:b0:660:523a:8fef with SMTP id c3-20020a056a000ac300b00660523a8fefmr2181313pfl.13.1686335949487; Fri, 09 Jun 2023 11:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686335949; cv=none; d=google.com; s=arc-20160816; b=qwtmuiosBOGkOCkL8t45/TdU5OFu4IpIHLGqFGm8lYYT8LGYe51x/yCDCEPDbfiI/v LCtS/H+D/QH5Wk63TQ2g3URrIBxret+bRI+vSiDn2y4SlP4nqUEvx41XFlaEPIBP8grD CGDwQIVVX3Q+UBt37EqN9/0Kv3ehEwX++fAkSnWzNp8ZFpdMivU3KchY4wWO3zyrfAg6 CWJIv+SibSHzdLtNtQ6xF6whReAMzhQThU+Crn0J4qGC+ZdfAz5q0h5lVNBisaQO+4Bj fcbYI7dB6ixNkuEwbs4aesPViFP4OPisR4fDddrjUecjUJ5uAuyBj4bfBWj30ZYFr4QY zDNQ== 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=dB2CIMlIx8K8kX4QYd3DEOspDKK7Zaf5MnV9JTtqdRk=; b=fioB2x/atrw44CNLiqCacKL4SysvlvGuTV13Yc9ylVP5uI+laGBBsmeKAzgdG+orjF f1Xo0YMTXGRJ8ZTTCyIRF+lf1OOVqbl+Mo/WiMJWrLPFkER8yx55CeqaL3aneAReo/0B RNwCqUz1TLyx3TlcAKF4RK191afrgibCEVvN3zSWQYtGqHdYvkTYC0NO7I3dbN9pEmp2 4iviK4tWlVmttPzsGJeM4oEFysiiEXo/c0gPGFgq8P2KqqyXgINp5TK/tSI6tR4cqlQC tVYRnP2yxSM6a9Jl2+CQnfWHbGwlcx4Vp7xjqi6nTff67yoPtmWkuS1OyNgu5TzTZ4+k +LSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=hhNri5fq; 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 w201-20020a627bd2000000b00625559a78a2si2876773pfc.107.2023.06.09.11.38.57; Fri, 09 Jun 2023 11:39:09 -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=hhNri5fq; 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 S229523AbjFIS2Z (ORCPT + 99 others); Fri, 9 Jun 2023 14:28:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjFIS2W (ORCPT ); Fri, 9 Jun 2023 14:28:22 -0400 Received: from mail-4318.protonmail.ch (mail-4318.protonmail.ch [185.70.43.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39BBA35B6; Fri, 9 Jun 2023 11:28:21 -0700 (PDT) Date: Fri, 09 Jun 2023 18:28:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1686335299; x=1686594499; bh=dB2CIMlIx8K8kX4QYd3DEOspDKK7Zaf5MnV9JTtqdRk=; 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=hhNri5fqxPzEnbepKsXoEc5rD4h70EAkS3DQbu566g9behmySfkDJNbHIsqU6YLad n2UyPOMa0Ur9DnJWj5TKxThndAR+aYfTTDEYFo/0NTKZ4ZYaRQd3ieDOLeiuGT4S4X 1M3jkCJ1OCgeEpv0Enixze9tSSVM7v7OUSUjILYtec54W7TQq6XoohhbkzsNf7lw3R EgTWgj+N1K8U/ReM5q+HjyPN72kdWeaUT1YI3rkiUG2Gcs6ySLDTawkZSTnhERkarg H7rswzVmYYGR9ei2IMKleuJBSKKix0fK63anpen4ucNDv1cmIc8Oss1mkp4Nm5ZgeX xi26dTAcAYxRg== 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 v3 2/2] NFC: nxp-nci: Add pad supply voltage pvdd-supply Message-ID: <20230609182729.85088-2-raymondhackley@protonmail.com> In-Reply-To: <20230609182729.85088-1-raymondhackley@protonmail.com> References: <20230609182639.85034-1-raymondhackley@protonmail.com> <20230609182729.85088-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_MSPIKE_H5, RCVD_IN_MSPIKE_WL,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?1768251404895561044?= X-GMAIL-MSGID: =?utf-8?q?1768251404895561044?= 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 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c index d4c299be7949..6f01152d2c83 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,20 @@ 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 +313,25 @@ 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)