Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2271107rwd; Fri, 9 Jun 2023 08:55:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5H0zoJi8A7n1a+EsnocgO1Nv6xQwPzywX3gcJTJC82WOVC8uZcc1noNEwH+DlxjcNjGKnY X-Received: by 2002:a05:6359:20f:b0:129:cce3:a877 with SMTP id ej15-20020a056359020f00b00129cce3a877mr1718139rwb.1.1686326111701; Fri, 09 Jun 2023 08:55:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686326111; cv=none; d=google.com; s=arc-20160816; b=IO7BI0W/nU3pwo981JCiC3Z+inQkPQ25PqXZpADZ2SQIWKocxAQ8OMloduC67c/wPi aeKSjc47Hwtb//IUwfvfIKe0i7XL8B3SDjGqbt2YlYn8Wadfc2AdULjvWBCIMm1c12PA Brs+USXiertu9OIVwWkBVznuQu+DnW/bAZVrSzTgrE+Lk79Tdgjr8cumYc1YUEE49tGx lszbGyIKGoJL4KKpA2JaRjJH5t/CE9S2++TibgMmf+P+b/B8ebhl9/C2eXa1PDFqvTNp dhQoMa4UJDXJemj40mJkUybbFpWxru7f0QRd2eRVYUMgIUGO1tNhU81ucONpVPSqkf3V PXww== 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=xadFqMnNfgl6gT0vaVLmkE//dImhTGrrvi/LgkS3A0c=; b=jzKLJwE/YDnNhKDqf4o2mgzRzAp9pxmLBGbWseSoM6ezLgYgMPldsB+Qod93mPtEX6 LRtihKP3P6Q9uu+IpNE8j3Qr67WGLcYBd5ef6G7IhF/QM179/slbEMuaJ2Z0+H0pFezz 7DnUDDT/o9xmJQDQ7BTjxaDF1TnfmzPYwhFXtVq2y0xlhnb4PqEz9KaT+ST2LHdbOBez eq0gsfukNIb4TwQbgVkPTKcw6Cleleb/svzAWhpVt4iYGseB750QXSO3LrJQ+HDLABjo 331yHl13f6vcJLZx+UNg7JAHAE6oqSksiq+peD01D5DTDqynZS0ffUsrmq38tAdxxqTV 5wMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=eM8aZ7y+; 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 z72-20020a63334b000000b00543cc95d776si2680571pgz.660.2023.06.09.08.54.57; Fri, 09 Jun 2023 08:55:11 -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=eM8aZ7y+; 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 S241865AbjFIPmp (ORCPT + 99 others); Fri, 9 Jun 2023 11:42:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241900AbjFIPmc (ORCPT ); Fri, 9 Jun 2023 11:42:32 -0400 Received: from mail-40138.protonmail.ch (mail-40138.protonmail.ch [185.70.40.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A1CE30F7 for ; Fri, 9 Jun 2023 08:42:31 -0700 (PDT) Date: Fri, 09 Jun 2023 15:42:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1686325349; x=1686584549; bh=xadFqMnNfgl6gT0vaVLmkE//dImhTGrrvi/LgkS3A0c=; 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=eM8aZ7y+NM3rLwsevMhMxoeqKFgofaRbvBfA1ynKoGI8Oykbrfy6mIfE5ahu+SvWa xjwl76l4Bkqg6hiGtbDzfAJrnovcwfOFSTJugu/P9xK7W8QfKrc8Vw+mzFk6GvaIUR 91Dl98z0l7AAGCsKtC1OGNdv2tj48u+7LInVGv18OW+11cAo+SKAMB8esB9kD+XDuK 7Anic43oM4dz0RtpOnWpwksrVOrSvMvS6+6zjsQf6EWO4uLjGSzZVJ5LRCHouvaYz3 xF9Jk6wqpm+TeOUcF4DsyhyHMeGKhReUpAgEwPgFoGwVHylaEBkCJ3x2RcNAfsNng2 PtWc9X6Ru8UDg== 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 v2 2/2] NFC: nxp-nci: Add pad supply voltage pvdd-supply Message-ID: <20230609154200.3620-1-raymondhackley@protonmail.com> In-Reply-To: <20230609154033.3511-1-raymondhackley@protonmail.com> References: <20230609154033.3511-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,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 | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c index d4c299be7949..1b8877757cee 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,22 @@ 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, +=09=09=09=09 "Failed to disable regulator pvdd: %d\n", +=09=09=09=09 r); +=09} +} + static int nxp_nci_i2c_probe(struct i2c_client *client) { =09struct device *dev =3D &client->dev; @@ -298,6 +315,29 @@ 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, +=09=09=09=09=09 "Failed to get regulator pvdd\n"); +=09} else { +=09=09r =3D regulator_enable(phy->pvdd); +=09=09if (r < 0) { +=09=09=09nfc_err(dev, +=09=09=09=09"Failed to enable regulator pvdd: %d\n", +=09=09=09=09r); +=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", +=09=09=09r); +=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) @@ -319,6 +359,8 @@ static void nxp_nci_i2c_remove(struct i2c_client *clien= t) =20 =09nxp_nci_remove(phy->ndev); =09free_irq(client->irq, phy); + +=09nxp_nci_i2c_poweroff(phy); } =20 static const struct i2c_device_id nxp_nci_i2c_id_table[] =3D { --=20 2.30.2