From patchwork Thu Jun 22 00:05:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Meng-Bo" X-Patchwork-Id: 696061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56DA0EB64D8 for ; Thu, 22 Jun 2023 00:15:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229837AbjFVAP1 (ORCPT ); Wed, 21 Jun 2023 20:15:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229843AbjFVAPY (ORCPT ); Wed, 21 Jun 2023 20:15:24 -0400 X-Greylist: delayed 471 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 21 Jun 2023 17:15:22 PDT Received: from mail-41104.protonmail.ch (mail-41104.protonmail.ch [185.70.41.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9561D122 for ; Wed, 21 Jun 2023 17:15:21 -0700 (PDT) Date: Thu, 22 Jun 2023 00:05:33 +0000 Authentication-Results: mail-41104.protonmail.ch; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="TYl9sBM/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1687392349; x=1687651549; bh=4SJtCK0x5F//Ag420gz6tCmHCCiBdGr2OH4BylyuTHc=; 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=TYl9sBM/w6FRIJndST1C0wRCDk4EYlMAdB8YxoBzIVFSXuVr0u+3ooYLZuU64sTUy u5ZstxgXTukjqkbEuC9mkfXU7r0hZf5tSrRlmtLr2VaTc/yo6rJNj4Pre9QqCZLFwR jf8QMkePu/6Co2y+IXSrIGd8FGUBmAFBgT0KCGPTCD2IWlqB5OJcZ/iD4IrNRTNHBx lRu5xVmd6naYQ6BkaFEmWauIFP2eyTDR0PMO16QhIyQK+DtQypj+rM4STpqy+ANWt3 y9SD9HRwY0cqq8/FtNskLqmBG/n0biIConVB2l20mxwsXW/vEtaZ2Uv9G2hsyKYMYO LOTBtvbXN/rmw== To: linux-kernel@vger.kernel.org From: "Lin, Meng-Bo" Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Arnd Bergmann , Olof Johansson , Stephan Gerhold , Nikita Travkin , soc@kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ~postmarketos/upstreaming@lists.sr.ht, Joe Mason , "Lin, Meng-Bo" Subject: [PATCH 7/7] arm64: dts: qcom: msm8916-samsung-fortuna: Add NFC Message-ID: <20230622000437.48367-1-linmengbo0689@protonmail.com> In-Reply-To: <20230622000007.48219-1-linmengbo0689@protonmail.com> References: <20230622000007.48219-1-linmengbo0689@protonmail.com> Feedback-ID: 40467236:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Joe Mason The Samsung Galaxy Ace 4, Core Prime and some Grand Prime have a Samsung S3FWRN5 NFC chip that works quite well with the s3fwrn5 driver in the Linux NFC subsystem. The clock setup for the NFC chip is a bit special (although this seems to be a common approach used for Qualcomm devices with NFC): The NFC chip has an output GPIO that is asserted whenever the clock is needed to function properly. On the A3/A5 this is wired up to PM8916 GPIO2, which is then configured with a special function (NFC_CLK_REQ or BB_CLK2_REQ). Enabling the rpmcc RPM_SMD_BB_CLK2_PIN clock will then instruct PM8916 to automatically enable the clock whenever the NFC chip requests it. The advantage is that the clock is only enabled when needed and we don't need to manage it ourselves from the NFC driver. Grand Prime SM-G530Y (fortunaltezt) has a NXP PN547, which is supported by the nxp-nci-i2c driver in mainline. It seems to detect NFC tags using "nfctool" just fine, although more testing is difficult given there seem to be very few useful applications making use of the Linux NFC subsystem. Signed-off-by: Joe Mason [Put i2c-nfc and NFC pinctrl into fortuna.dtsi to share it with other variants] Signed-off-by: Stephan Gerhold [Add pn547_nfc] Signed-off-by: Lin, Meng-Bo --- .../dts/qcom/msm8216-samsung-fortuna3g.dts | 5 ++ .../qcom/msm8916-samsung-fortuna-common.dtsi | 81 +++++++++++++++++++ .../dts/qcom/msm8916-samsung-fortunaltezt.dts | 4 + .../dts/qcom/msm8916-samsung-gprimeltecan.dts | 25 ++++++ .../qcom/msm8916-samsung-grandprimelte.dts | 4 + .../qcom/msm8916-samsung-rossa-common.dtsi | 4 + 6 files changed, 123 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/msm8216-samsung-fortuna3g.dts b/arch/arm64/boot/dts/qcom/msm8216-samsung-fortuna3g.dts index e7f6df229f9a..694a9962ee22 100644 --- a/arch/arm64/boot/dts/qcom/msm8216-samsung-fortuna3g.dts +++ b/arch/arm64/boot/dts/qcom/msm8216-samsung-fortuna3g.dts @@ -10,6 +10,11 @@ / { chassis-type = "handset"; }; +&i2c_nfc { + /* 3G variant doesn't have NFC */ + status = "disabled"; +}; + &st_accel { status = "okay"; }; diff --git a/arch/arm64/boot/dts/qcom/msm8916-samsung-fortuna-common.dtsi b/arch/arm64/boot/dts/qcom/msm8916-samsung-fortuna-common.dtsi index 0436b8ccc3e8..e58cce5d1879 100644 --- a/arch/arm64/boot/dts/qcom/msm8916-samsung-fortuna-common.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8916-samsung-fortuna-common.dtsi @@ -4,6 +4,7 @@ #include #include #include +#include / { aliases { @@ -52,6 +53,53 @@ haptic { max-microvolt = <3300000>; }; + i2c_nfc: i2c-nfc { + compatible = "i2c-gpio"; + sda-gpios = <&tlmm 0 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; + scl-gpios = <&tlmm 1 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; + + pinctrl-0 = <&nfc_i2c_default>; + pinctrl-names = "default"; + + #address-cells = <1>; + #size-cells = <0>; + + /* Available NFC chip varies depending on model variant */ + pn547_nfc: nfc@2b { + compatible = "nxp,pn547", "nxp,nxp-nci-i2c"; + reg = <0x2b>; + + interrupt-parent = <&tlmm>; + interrupts = <21 IRQ_TYPE_EDGE_RISING>; + + enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + firmware-gpios = <&tlmm 49 GPIO_ACTIVE_HIGH>; + + pinctrl-0 = <&nfc_default>; + pinctrl-names = "default"; + + status = "disabled"; + }; + + s3fwrn5_nfc: nfc@27 { + compatible = "samsung,s3fwrn5-i2c"; + reg = <0x27>; + + interrupt-parent = <&tlmm>; + interrupts = <21 IRQ_TYPE_EDGE_RISING>; + + en-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + wake-gpios = <&tlmm 49 GPIO_ACTIVE_HIGH>; + + clocks = <&rpmcc RPM_SMD_BB_CLK2_PIN>; + + pinctrl-0 = <&nfc_default>, <&nfc_clk_req>; + pinctrl-names = "default"; + + status = "disabled"; + }; + }; + reg_motor_vdd: regulator-motor-vdd { compatible = "regulator-fixed"; regulator-name = "motor_vdd"; @@ -286,6 +334,29 @@ muic_int_default: muic-int-default-state { bias-disable; }; + nfc_default: nfc-default-state { + nfc-pins { + pins = "gpio20", "gpio49"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + }; + + irq-pins { + pins = "gpio21"; + function = "gpio"; + drive-strength = <2>; + bias-pull-down; + }; + }; + + nfc_i2c_default: nfc-i2c-default-state { + pins = "gpio0", "gpio1"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + }; + sdc2_cd_default: sdc2-cd-default-state { pins = "gpio38"; function = "gpio"; @@ -307,3 +378,13 @@ tsp_int_default: tsp-int-default-state { bias-disable; }; }; + +&pm8916_gpios { + nfc_clk_req: nfc-clk-req-state { + pins = "gpio2"; + function = "func1"; + power-source = ; + bias-disable; + input-enable; + }; +}; diff --git a/arch/arm64/boot/dts/qcom/msm8916-samsung-fortunaltezt.dts b/arch/arm64/boot/dts/qcom/msm8916-samsung-fortunaltezt.dts index 0716ef577df1..eb033f555184 100644 --- a/arch/arm64/boot/dts/qcom/msm8916-samsung-fortunaltezt.dts +++ b/arch/arm64/boot/dts/qcom/msm8916-samsung-fortunaltezt.dts @@ -22,6 +22,10 @@ / { chassis-type = "handset"; }; +&pn547_nfc { + status = "okay"; +}; + &st_accel { compatible = "st,lis2hh12"; mount-matrix = "1", "0", "0", diff --git a/arch/arm64/boot/dts/qcom/msm8916-samsung-gprimeltecan.dts b/arch/arm64/boot/dts/qcom/msm8916-samsung-gprimeltecan.dts index b0d8ac3d6ce9..1a24e00e2024 100644 --- a/arch/arm64/boot/dts/qcom/msm8916-samsung-gprimeltecan.dts +++ b/arch/arm64/boot/dts/qcom/msm8916-samsung-gprimeltecan.dts @@ -21,6 +21,26 @@ tz-apps@85500000 { }; }; +&blsp_i2c6 { + status = "okay"; + + nfc@27 { + compatible = "samsung,s3fwrn5-i2c"; + reg = <0x27>; + + interrupt-parent = <&tlmm>; + interrupts = <21 IRQ_TYPE_EDGE_RISING>; + + en-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + wake-gpios = <&tlmm 49 GPIO_ACTIVE_HIGH>; + + clocks = <&rpmcc RPM_SMD_BB_CLK2_PIN>; + + pinctrl-0 = <&nfc_default>, <&nfc_clk_req>; + pinctrl-names = "default"; + }; +}; + &bosch_accel { status = "okay"; }; @@ -28,3 +48,8 @@ &bosch_accel { &bosch_magn { status = "okay"; }; + +&i2c_nfc { + /* Used for MFD instead. NFC is on i2c6 */ + status = "disabled"; +}; diff --git a/arch/arm64/boot/dts/qcom/msm8916-samsung-grandprimelte.dts b/arch/arm64/boot/dts/qcom/msm8916-samsung-grandprimelte.dts index f7fc538fda04..090b8fb6b444 100644 --- a/arch/arm64/boot/dts/qcom/msm8916-samsung-grandprimelte.dts +++ b/arch/arm64/boot/dts/qcom/msm8916-samsung-grandprimelte.dts @@ -17,3 +17,7 @@ &bosch_accel { &bosch_magn { status = "okay"; }; + +&s3fwrn5_nfc { + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/qcom/msm8916-samsung-rossa-common.dtsi b/arch/arm64/boot/dts/qcom/msm8916-samsung-rossa-common.dtsi index 39f99b5030e5..dbc4ee8719a6 100644 --- a/arch/arm64/boot/dts/qcom/msm8916-samsung-rossa-common.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8916-samsung-rossa-common.dtsi @@ -23,6 +23,10 @@ &blsp_i2c5 { /delete-node/ touchscreen@20; }; +&s3fwrn5_nfc { + status = "okay"; +}; + &st_accel { compatible = "st,lis2hh12"; mount-matrix = "1", "0", "0",