Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2470357rwd; Fri, 9 Jun 2023 11:40:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6arCDlsX3PxZHNiDaVEVnR7aXJWGAPhThQhBfJ/OJkz1z2ZKeQN1u+LbGzEVnfwKcyTb+P X-Received: by 2002:a17:902:e884:b0:1b2:61eb:a735 with SMTP id w4-20020a170902e88400b001b261eba735mr1671217plg.38.1686336038584; Fri, 09 Jun 2023 11:40:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686336038; cv=none; d=google.com; s=arc-20160816; b=hqU5oQFHUQeXYIgqAHgadF+6CeYiFqUxQ+Eb5ftt0LBAIyyBsb74bSU9+lQebxBhmv QRcFLnXazzRmNqspv7FidFJarbYVJhy3Bft3mpoO1fZwTjURJ2bm3hBInSccvjuiLFN/ NMQQwLm9Zs+mQJvF6JZdQW5TGlFZXj+0Ma345XMbg54kccWYTDYwR4B9bQ2BX5lQzAJa SNS68eXZrarftDXN1Z2Ak9j08O7W/C3o1TeJddoDFQYQB3ELX7v/Bk8GCn8Y4QOV+NBr mSbtMYWZB6Qt3ILNT0GkamOzT9qXArXQj5vdXNNdtNAqMXlwawC83HwHjKeFB56Xc3RR UIpA== 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 Return-Path: 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.40.26; Fri, 09 Jun 2023 11:40: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=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 S229888AbjFIS2Y (ORCPT + 99 others); Fri, 9 Jun 2023 14:28:24 -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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 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 { =20 =09struct gpio_desc *gpiod_en; =09struct gpio_desc *gpiod_fw; +=09struct regulator *pvdd; =20 =09int hard_fault; /* =09=09=09 * < 0 if hardware error occurred (e.g. i2c err) @@ -263,6 +264,20 @@ static const struct acpi_gpio_mapping acpi_nxp_nci_gpi= os[] =3D { =09{ } }; =20 +static void nxp_nci_i2c_poweroff(void *data) +{ +=09struct nxp_nci_i2c_phy *phy =3D data; +=09struct device *dev =3D &phy->i2c_dev->dev; +=09struct regulator *pvdd =3D phy->pvdd; +=09int r; + +=09if (!IS_ERR(pvdd) && regulator_is_enabled(pvdd)) { +=09=09r =3D regulator_disable(pvdd); +=09=09if (r < 0) +=09=09=09dev_warn(dev, "Failed to disable regulator pvdd: %d\n", r); +=09} +} + static int nxp_nci_i2c_probe(struct i2c_client *client) { =09struct device *dev =3D &client->dev; @@ -298,6 +313,25 @@ static int nxp_nci_i2c_probe(struct i2c_client *client= ) =09=09return PTR_ERR(phy->gpiod_fw); =09} =20 +=09phy->pvdd =3D devm_regulator_get_optional(dev, "pvdd"); +=09if (IS_ERR(phy->pvdd)) { +=09=09r =3D PTR_ERR(phy->pvdd); +=09=09if (r !=3D -ENODEV) +=09=09=09return dev_err_probe(dev, r, "Failed to get regulator pvdd\n"); +=09} else { +=09=09r =3D regulator_enable(phy->pvdd); +=09=09if (r < 0) { +=09=09=09nfc_err(dev, "Failed to enable regulator pvdd: %d\n", r); +=09=09=09return r; +=09=09} +=09} + +=09r =3D devm_add_action_or_reset(dev, nxp_nci_i2c_poweroff, phy); +=09if (r < 0) { +=09=09nfc_err(dev, "Failed to install poweroff handler: %d\n", r); +=09=09return r; +=09} + =09r =3D nxp_nci_probe(phy, &client->dev, &i2c_phy_ops, =09=09=09 NXP_NCI_I2C_MAX_PAYLOAD, &phy->ndev); =09if (r < 0) --=20 2.30.2