Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6726263rwd; Tue, 6 Jun 2023 00:41:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5+SN3hK2fhqiXyd/e9RrLUHIkm+DyKmGbUpIGlxLO3uEtdry/OboPYF24xF1ggylug2ONk X-Received: by 2002:a54:4805:0:b0:398:2b60:dbf4 with SMTP id j5-20020a544805000000b003982b60dbf4mr1449104oij.19.1686037262010; Tue, 06 Jun 2023 00:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686037261; cv=none; d=google.com; s=arc-20160816; b=RXQihflElcNiVvOpcwz2gMLHmRwZAGz9fpNLeGPktzGL73XGo5aK6Au1wn02U07Jb6 JQ5w3adhD3cQvZwaNrrEC+1VW8htOzawdPew6G1Kyr5Jm0KOAzjLxor0nqPRzw6+X4rn EVBEnSt31fotqx6As3scyECgspyWKIyyZ0GKSUGARHiXV3Hp+ckeqX+3BNCzJLpc4ieB iTQQMRd/SsbT/5c8kRJEyJOFinX/nX4Febv7kblMdch4KfqE0CCDgAFdkArb1i+a+OWL xCwbbwh5Fo8xCzTyuvorG6o10EJnqyIka/utmcCPFKn19emxEpIMKKOiG8GqmljRoL7F uMEg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d19-20020a17090ac25300b0025350783742si7005327pjx.5.2023.06.06.00.40.50; Tue, 06 Jun 2023 00:41:01 -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 S234542AbjFFH0G (ORCPT + 99 others); Tue, 6 Jun 2023 03:26:06 -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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 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 { =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,34 @@ 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=09if (r !=3D -EPROBE_DEFER) +=09=09=09=09dev_err(dev, +=09=09=09=09=09"Failed to get regulator pvdd: %d\n", +=09=09=09=09=09r); +=09=09=09return r; +=09=09} +=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=09nxp_nci_i2c_poweroff(phy); +=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 +364,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