From patchwork Fri Jun 9 18:37:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Hackley X-Patchwork-Id: 105787 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1139598vqr; Fri, 9 Jun 2023 12:36:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ745PPSc+69I2x2bJYF0KWQHv7IAGxYq6aa8VBcCmqQiPtrRXJdaFd7GT7SLUGjza6xaCrR X-Received: by 2002:a05:6808:23c2:b0:38c:c177:a6bb with SMTP id bq2-20020a05680823c200b0038cc177a6bbmr2912127oib.23.1686339419569; Fri, 09 Jun 2023 12:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686339419; cv=none; d=google.com; s=arc-20160816; b=BaCV1g+oJDOt/RNry8E/e0919OzNYac8xQjlP3vxcULFHY3LPBLDz8K1nXVjNzGEKs UvO3cGit3n06fbQGl8KZVyQAghGdEXnBTMyqgOh3zMcKQ/tc5dZnpp0DcHlqboA6DSpX vKuLmavkWvA54uU5P8qpfL83Agqf+7jYYubFzfCDnVU66jDZrzemeLP6s8GVbhR+2+jo BmvcP3drgtE21NOh7+TC6ePRuqO740pngjMBGHlQRqsocAOOdvWwrNDUaHD7Bylrlrc2 Ru4tToE4yenvjWZdjRk321t6rmpwcJr/0C269GL7YWfjOsXv7GokOIU7Em/HUhL8NqDH A4Yw== 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=hXRwSPc7XGWtBPc09QmUZJzC48xRLRIDqDxiSM9jYkRIKY/CmEM7nXf83Y6ush1l2X zdzsuFgTPke9E2smzhUrb/A5jhgwXx5urGIdVy5XoYBlbbo0ibR57rpt9Yq97rd7pGGh qwUHpoxFIDXXARymElHkrBRdsVF/5C+P6EdygPhjhHoXbv430ryCOQrfr4V2PfoHCVoz b5WIq6lzYEeh7l5wun0gLcMFVte8Zdp7q6iK3p4ZlKw0292uObzSeqDfJ1wZ52lITQrv H5IL7e0ks4v7LXPP59tUAdbz+M/HxxWVjAeWHPKNXRHOW364zzUN0rw0kAq2XD3g+3Gn twGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=YW64GUaS; 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 p9-20020a17090a74c900b002563c39f342si3167134pjl.110.2023.06.09.12.36.43; Fri, 09 Jun 2023 12:36:59 -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=YW64GUaS; 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 S232210AbjFISiR (ORCPT + 99 others); Fri, 9 Jun 2023 14:38:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231871AbjFIShw (ORCPT ); Fri, 9 Jun 2023 14:37:52 -0400 Received: from mail-40130.protonmail.ch (mail-40130.protonmail.ch [185.70.40.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8742E3A87 for ; Fri, 9 Jun 2023 11:37:28 -0700 (PDT) Date: Fri, 09 Jun 2023 18:37:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1686335846; x=1686595046; 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=YW64GUaSrg4gs+Di+BfHM9HeAXjL0xIj+exj36pAl1uKr3cqKobVSCLHYZ2+ONL0w CXe3bOuWGjEUU2LjGZh7A4C80UyG6noiJO75lR5vG9a2XCazSDCBxfO5olUYv9s92m ZZ/dtBUYpDx7GHmjlWCSuti0k2DNuWqHQ3FjuUN/IibAeocMZIlMbXAkz/2wmk4CEg bbRL61OmWUMF9kVnMykJX4j1R2zgh7LJ+NAQAMuU0g7e89XtgdtzNxFnxDruuTuer5 ram2Lwd4BhGtYAUoZp3ydBoZ4CUIzxyZvViMFFKHfM5o6/7bQGy73JHUjX2UrCzqmn Yal6uGfKf3a7A== 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: [RESEND PATCH v3 1/2] dt-bindings: nfc: nxp-nci: document pvdd-supply Message-ID: <20230609183639.85221-2-raymondhackley@protonmail.com> In-Reply-To: <20230609183639.85221-1-raymondhackley@protonmail.com> References: <20230609183639.85221-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?1768255042941797702?= X-GMAIL-MSGID: =?utf-8?q?1768255042941797702?= 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:37:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Hackley X-Patchwork-Id: 105781 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1127447vqr; Fri, 9 Jun 2023 12:13:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ62cG32JrfMHe899/cSJpdKXdOB78Rad5nplWJK0Me4Nz0p5ZqxFOVmcy9mkhioIo3OeELu X-Received: by 2002:a05:6a20:e614:b0:10f:52e2:49ec with SMTP id my20-20020a056a20e61400b0010f52e249ecmr1542791pzb.53.1686338029691; Fri, 09 Jun 2023 12:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686338029; cv=none; d=google.com; s=arc-20160816; b=rwVovR0pl7qj60oRFm1yDu4R8lroNtnR+CNQZ/G6oaPBbbD5HfJEwd6e99Sn3ZPAcE lHVIHxiC0z3afjD5hWQ5TsG0ThKRIY5vwzbTYGxIMVyoCPejTleT9ycmzfqz3GFdX3jm POVObvdrrvku/GtvP7DWf2OnUT9gJrbkj8R/y9UtvIgjpzOW4LIDPf1+Ug7As8bPQe07 qWomR8rICKncHKuZ3b1+oTTPextK0/gtM4Gz9Twg5w5dw3gOwPfDNmz5D3pWJVf+7GpO OD6f5q4kMwpaGcITKrJXw8nN+IcW9r5B6YFghuOI9vpzuvdaiFpGr/kDJOasgC48rqm/ UqBA== 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=Fa9p46NsDZhrA3AbGozHqUwDR+eXV/ivduVt5zkRFytIIxOaRAOZUtQ24JB07n+iAY X3lDW9qipLl2XXaklrWJhhP/LOzfN221KVYI0ocBRmQu8ztEbZ91KKSurz7AKCIgmIRX JGAZ7125lk3yo9SSGHXC3KytQAC0XTugiZSRuQ7WnMGX+k1VO6PkktWH82Jex8EFsH36 8MurFnMYYPHSzM31wUOuA+jXhTHe6E2D/qoF1yA3HncIeUtlm54xnEKKfsjvUz8Xw8LO DQFxar0sD5BCpPQTz9s3P9qYzb6MN2hOekk6XMthKoHQjBlXqtIPNgjzZCxsMBYEC0DW 1YcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=rEs1VWEq; 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 r84-20020a632b57000000b00542b5336becsi61471pgr.663.2023.06.09.12.12.39; Fri, 09 Jun 2023 12:13:49 -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=rEs1VWEq; 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 S229482AbjFISjT (ORCPT + 99 others); Fri, 9 Jun 2023 14:39:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232711AbjFISip (ORCPT ); Fri, 9 Jun 2023 14:38:45 -0400 Received: from mail-40132.protonmail.ch (mail-40132.protonmail.ch [185.70.40.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 991B23C07 for ; Fri, 9 Jun 2023 11:38:23 -0700 (PDT) Date: Fri, 09 Jun 2023 18:37:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1686335871; x=1686595071; 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=rEs1VWEqzi3BYNp4F7JKYlxwGw0By9u3Hjidp1S/qiIAyvxxZC1gsVCf+vpedFInY D3zndYbcwwdFQdfv+0qBvb5v7iM5bfz81N0zicbcqAYb+y/WVrZAQU7t1rCgSTWZyb nQY5EJRzP0Byoyq1O4/rPx2ZrQSKY7Vh4yBHoPCGqCVWAK9XHJqYeIbToe2TDaxqlB Gck2tBbtQAv2sBK3pEkVbzIH+NMaGRPwTaOs0DzZjG1hUC90XX0Fh5Whd+DVRbh0ph a1yRHIKMfb8XMDuWXgISWaS8ZTe15FvSJpYlIaDFljszJk2dpmGiqUX4DgHDAWtMZF xamb1SYlJOwOw== 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: [RESEND PATCH v3 2/2] NFC: nxp-nci: Add pad supply voltage pvdd-supply Message-ID: <20230609183639.85221-3-raymondhackley@protonmail.com> In-Reply-To: <20230609183639.85221-1-raymondhackley@protonmail.com> References: <20230609183639.85221-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?1768251404895561044?= X-GMAIL-MSGID: =?utf-8?q?1768253585856215086?= 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)