From patchwork Tue Jun 6 07:25:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Hackley X-Patchwork-Id: 103620 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3219456vqr; Tue, 6 Jun 2023 00:54:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6+ai0+OqrFNDY1tFVOtDZD68SGSVLZn82mqjR/o7S++NE/elRvND3Hfl53CGe6ZrfLIqfJ X-Received: by 2002:a05:6a00:1302:b0:64b:f03b:2642 with SMTP id j2-20020a056a00130200b0064bf03b2642mr1556091pfu.23.1686038086282; Tue, 06 Jun 2023 00:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686038086; cv=none; d=google.com; s=arc-20160816; b=vL4VdCF7E2reoC2R3B7CAGva7wiid4qjNZWGXLcwse1G7XamjfKIJbSThwEOFxQBBk 6TBgVzRXjrQp6KghsTlwwv0y1fso2ftqiHBjlQ0VuVh1nhobNL/fRBO4AkJZAcA0EO7p aHUnYG6kC7QZKTtz4IA+ockKlhR7O/uALROTE0ppetzvyYJ4hAQq1rwz7iInElkrN6Td 4rSsqx+FPiTNG8JJkN7e3dATzJbrAdOrKp1Gsk1v/qd53TmmEB/LlKx9QXf8hTy2sWeZ 7Yczor8570NW2RtKcQiUSusxO9lQv8muCZATdvXAk0kjYVFf8VaGOqTIKkRC5+vPzwji qwgg== 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=P4Wx2qvAAGGzjyPeKsXmzDzNNX/HqQrOzB6zsSqnNZE=; b=HZ5pkgW3A8mLtoKpjglSq9EJwIGVUaA/K+Q/mQ+FL/seJxnHSja7mEuJE6C2/i/tut ggsO8vGQfWyXMpLd0wai1tJv9zV1Z58haSfJSevs+6EdBqsXiiunX0az8Wt8Sj3BN9R9 h1+rF6+F5Cf/j1E373mUox2CrJ/n6jyuVr7cSAcSSwDSE4xuy3glPK69FlkhWcbFBKBt q0LWKfuWo+A1rgLkGU5ftTd54nOEb3+HbmT/HbCezymPvExZDRLnnCVm9u86i48mfCBH 0mSWteXZ4rJ1nkAdPyzdIC1YDvIbyz7uFXfalIGsd9dH1rGkyKOX8qo8byTmOBUCQ+q8 rYTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=Rs1CMEu8; 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 67-20020a621746000000b006600f3102cesi880923pfx.188.2023.06.06.00.54.32; Tue, 06 Jun 2023 00:54:46 -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=Rs1CMEu8; 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 S236126AbjFFHZr (ORCPT + 99 others); Tue, 6 Jun 2023 03:25:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236064AbjFFHZo (ORCPT ); Tue, 6 Jun 2023 03:25:44 -0400 Received: from mail-4027.protonmail.ch (mail-4027.protonmail.ch [185.70.40.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9654F7 for ; Tue, 6 Jun 2023 00:25:43 -0700 (PDT) Date: Tue, 06 Jun 2023 07:25:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1686036341; x=1686295541; bh=P4Wx2qvAAGGzjyPeKsXmzDzNNX/HqQrOzB6zsSqnNZE=; 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=Rs1CMEu8rUhp+hQKy/O5SmQ/y/rXLmmAIWxEjAJ4hfzSTZIMDGxbUPDAkqNrRbbs9 rNHBSp6XtY4+yAmjk5YHxjilxk2kBHVVRL0I7iyOeXMQ31uGGpchY/f2idgaX/32Uu FizC+kRNuHjov6zWjI/ad9ux7pN9UBw1P5+F0uoXlfd/ENgG5Cbveh/cMiFrprrc4l dACYjlxft9nYSqRsNGqCnmiBDQQb2sQVDohUeNpYVLVlGIWbjRUgQtCiHdkKN0pYPH 17cCJjTjDRt5rMbMMoZynZajB5wXXV8GqQnLKct7sWS+xuaT/yWrUwWdyrgGyqRNv/ uJoC9PZK+naGQ== 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 1/2] dt-bindings: nfc: nxp-nci: document pvdd-supply Message-ID: <20230606072437.145052-1-raymondhackley@protonmail.com> In-Reply-To: <20230606071824.144990-1-raymondhackley@protonmail.com> References: <20230606071824.144990-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?1767939072317068595?= X-GMAIL-MSGID: =?utf-8?q?1767939072317068595?= 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 Tue Jun 6 07:25:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Hackley X-Patchwork-Id: 103619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3219401vqr; Tue, 6 Jun 2023 00:54:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zCseNpwU7ndw0yXk/gMrtecQLApU5hcCL/ddZuHM1YONBJqBfj3m4jb7w8zJw7YeKWpwJ X-Received: by 2002:a0d:dec7:0:b0:569:770d:c9be with SMTP id h190-20020a0ddec7000000b00569770dc9bemr1362298ywe.41.1686038078596; Tue, 06 Jun 2023 00:54:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686038078; cv=none; d=google.com; s=arc-20160816; b=ejAYGS/CvDVDdzrR008vEZpsiAA5yfOM+ZsWoeu+aY0gpMBMU+Ugxe0IvwoQvIFOPM uID581eO2L77h32T8ayOJJ7ujcBZrW3zraGGUxPibTaze6OMj8onxVEXETXvAdvg3o4F lwxdwy09zJ6wSVkv17Bn53eJD56ScE92rUD+OAhDBSBXB238TRhW3pu6lJ03XQOqXOgu m5Ywc+TMQD/Yh0szDCUIO3BCoyyAr72vSNlGhbKMKS/znzKOl1mojrKNIPwVvYjUybtK MovvPT+JYs9U00id3PtgfIPVxI1T85HSmfAKL3UIoMyW3LGBQFzeEobijvXq4bK8ODfs 5Ppw== 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=cqi05JE2UZTUwpQahBrP8KQeeAYBK+IxnIt+uQJM6Ig=; b=FxZmG7JMQcNo6ZOUMJzNtg3tmttOxjalzurReQ2vg7mKRf1tPCAc3ixyn/w1SJ5WMZ Lgj6jaxfMVQW8AOZu4wx5JutaEP0B0Xrjn7k03k+d6NSiOs37m+ijmBbJcyeiLgx32Uo OQdlzY0/YiYfB7DGrHhCZ2ebA6NENkhHCL3PrMFiZIvYI+qy2A7UK23aV5ZnOxt7dhg2 YDz8zUEP97607mXulehBLjEvJcqQn9Qmf3rlQcL3XdC84HKgg+RyQj2Oge84XdgxAUP9 FhIW9/shsGXEBzB3xNBnPna11xRZFeTNOV2AS3AG6V3J4rqed+hyp3AA/0wtBGgxkouZ LBIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=OerX7hRk; 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 iz7-20020a170902ef8700b001a6565a16c4si6760734plb.493.2023.06.06.00.54.25; Tue, 06 Jun 2023 00:54:38 -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=OerX7hRk; 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 S235356AbjFFH0H (ORCPT + 99 others); Tue, 6 Jun 2023 03:26:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236064AbjFFH0C (ORCPT ); Tue, 6 Jun 2023 03:26:02 -0400 Received: from mail-0201.mail-europe.com (mail-0201.mail-europe.com [51.77.79.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 562F4EC; Tue, 6 Jun 2023 00:26:00 -0700 (PDT) Date: Tue, 06 Jun 2023 07:25:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1686036357; x=1686295557; bh=cqi05JE2UZTUwpQahBrP8KQeeAYBK+IxnIt+uQJM6Ig=; 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=OerX7hRkQirL5keZ8U3FyWNueZuOrBWokhHYxJLwqcMEjFo0SP3I1Bj/5sn7ie02n a2M/Smgyx9xoOvkEnYQrqQSMHvDjjkaiK6nZHeFxU0pNZUNXUrrC2vfqn/lLybKVAl 7sx19Kpumd8jpHndie6IdAt4/ZgQhHhQsOU1zHwC2BT3sPRvOvMoQDmGXUChjZ9vqz mpPvowqh4JKzSTmsZbzkC2WxsNe7xISJg4oR+NS0COLdzlyo0Py40kHmCqy8ugTKpf 6lwvxchTbyOBuE5xneDKLXvCIboO/Fc/ZM6hTmbNnK5PfzF579szw718DGiknxf7o/ HV+VS2DBCfOwg== 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 2/2] NFC: nxp-nci: Add pad supply voltage pvdd-supply Message-ID: <20230606072454.145106-1-raymondhackley@protonmail.com> In-Reply-To: <20230606071824.144990-1-raymondhackley@protonmail.com> References: <20230606071824.144990-1-raymondhackley@protonmail.com> Feedback-ID: 49437091:user:proton MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,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?1767938060508553721?= X-GMAIL-MSGID: =?utf-8?q?1767939064535231032?= 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 | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c index d4c299be7949..e2d16111daa4 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,34 @@ 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) { + if (r != -EPROBE_DEFER) + dev_err(dev, + "Failed to get regulator pvdd: %d\n", + r); + return r; + } + } 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); + nxp_nci_i2c_poweroff(phy); + return r; + } + r = nxp_nci_probe(phy, &client->dev, &i2c_phy_ops, NXP_NCI_I2C_MAX_PAYLOAD, &phy->ndev); if (r < 0) @@ -319,6 +364,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[] = {