From patchwork Fri Jun 9 18:33:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Hackley X-Patchwork-Id: 105770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1110868vqr; Fri, 9 Jun 2023 11:42:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6SHWVuf2In2BDkSqBGUGOtRznW1fFsBCHJEnCGXt7RBHzF5oX65cTUnUGpB1yJaYIbvAQB X-Received: by 2002:a17:902:c40d:b0:1b0:307c:e706 with SMTP id k13-20020a170902c40d00b001b0307ce706mr2012085plk.45.1686336147915; Fri, 09 Jun 2023 11:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686336147; cv=none; d=google.com; s=arc-20160816; b=XgI5RbegwW1eKe318ISLSinRRCL6Dndgzgzc4SMXTmDSidtru6WJ7SZ+7Yl3DxqYdX pZtOWxAKe8tDh5WQN0cEVWJQBYR5TcsrMqGNT5fZ50d/zh0O5GZGuLEMdSrbYiVGrEy9 EQrSUWcy307yJNPFU7ApS78EOvl9aNw2EsDA7Aup2Oa1araeBzBVL3c/HQg31qk18gNY /Mb0fpkVV75x2YwBEeQGJlk8tt+P2HZnw3Dj7TJY9axITWaUjCevxTO/OnpDmiV3TFFx P+Z/gfRIHkWvkKyWLa8GUy/jOE6x287u/V+a8P2PZzkml8lom53H3jiW+QqVD2/ni3Pn 5J9g== 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=mHZaexbu1Si6DBs5v21vEX5xDFGNLf4mDv71qBPoPtjcHtj+ZwiaW203cDYih6jVN3 z0DRdExyGwWtSUCU7Lb+T48sbRdPUet5oc9RPgAODs7siK/H32Y+wj4FhH0wWg9W5kLn J0gdybpCUrcuXXCSkUQhQv8tH7GWaL4G3O1yJ3kmFwiim3yoz3goB9jmaAt5fEjONQDx W7cS7QgRIlCkPOMZcmeBdjkTKC/JQUtbbn1kEV7hHGnOP/v0Gn/u8iNAaYhwMnuKe86S lE6gEKXKzfc/RAGBu/NSJQeaCss8RON8uBoWnZNVX/J+xpvDRAxHHQqfBXoBGZY7WFli mRFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=sLmtgWG6; 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 kx13-20020a170902f94d00b001a95b85b070si2888362plb.604.2023.06.09.11.42.13; Fri, 09 Jun 2023 11:42:27 -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=sLmtgWG6; 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 S230477AbjFISdn (ORCPT + 99 others); Fri, 9 Jun 2023 14:33:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231748AbjFISd3 (ORCPT ); Fri, 9 Jun 2023 14:33:29 -0400 X-Greylist: delayed 353 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 09 Jun 2023 11:33:08 PDT Received: from mail-4325.protonmail.ch (mail-4325.protonmail.ch [185.70.43.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90AE3421A; Fri, 9 Jun 2023 11:33:08 -0700 (PDT) Date: Fri, 09 Jun 2023 18:33:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1686335586; x=1686594786; 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=sLmtgWG6fOTMDKCVT0jmK2nNcZiqy9q6l8VJlQVfilK3fiIK+7gHxk/GelNS96VyW Usyxpvlp/9CnCV5pTkiE7AWHiLxE+QDMdQ4kLC5Ie6INx3PDydMKKd9cml6Etuk43K NjVFQtV8c4nW11aju7EHGTXpNhOcsHV+jLHqPJhVD+cDPks3RSrHnw+jdcaYV9vGrg y1Jb5BzXhT4+GezwFe/EobeqC/22E/PTnB6VvPvAnnmu1tpsulhINDoK56mg1ymAdN /d9AijJ7qMnW1UXtyzyFjijzPq6hUCGCrGbcoSbs+4RF8Og4dDsAROTEKT/wi8AAy8 vUpeCxVvSxX0Q== 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: <20230609183235.85160-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,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?1768251612621413064?= 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)