From: "Lin, Meng-Bo" <linmengbo0689@protonmail.com>
To: linux-kernel@vger.kernel.org
Cc: Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Olof Johansson <olof@lixom.net>,
Stephan Gerhold <stephan@gerhold.net>,
Nikita Travkin <nikita@trvn.ru>,
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 <buddyjojo06@outlook.com>,
"Lin, Meng-Bo" <linmengbo0689@protonmail.com>
Subject: [PATCH 7/7] arm64: dts: qcom: msm8916-samsung-fortuna: Add NFC
Date: Thu, 22 Jun 2023 00:05:33 +0000 [thread overview]
Message-ID: <20230622000437.48367-1-linmengbo0689@protonmail.com> (raw)
In-Reply-To: <20230622000007.48219-1-linmengbo0689@protonmail.com>
From: Joe Mason <buddyjojo06@outlook.com>
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 <buddyjojo06@outlook.com>
[Put i2c-nfc and NFC pinctrl into fortuna.dtsi to share it with other variants]
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
[Add pn547_nfc]
Signed-off-by: Lin, Meng-Bo <linmengbo0689@protonmail.com>
---
.../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 <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
/ {
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 = <PM8916_GPIO_L2>;
+ 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",
--
2.39.2
next prev parent reply other threads:[~2023-06-22 0:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-22 0:00 [PATCH 0/7] arm64: dts: qcom: msm8916-samsung-fortuna: Add initial device trees Lin, Meng-Bo
2023-06-22 0:03 ` [PATCH 1/7] dt-bindings: qcom: Document new msm8916-samsung devices Lin, Meng-Bo
2023-06-22 8:31 ` Krzysztof Kozlowski
2023-06-22 14:40 ` Rob Herring
2023-06-22 15:04 ` Krzysztof Kozlowski
2023-06-22 0:03 ` [PATCH 2/7] arm64: dts: qcom: msm8916-samsung-fortuna: Add initial device trees Lin, Meng-Bo
2023-06-22 0:04 ` [PATCH 3/7] ARM: dts: qcom-msm8916-samsung-fortuna: Include dts from arm64 Lin, Meng-Bo
2023-06-22 0:04 ` [PATCH 4/7] arm64: dts: qcom: msm8916-samsung-fortuna: Add rt5033 battery Lin, Meng-Bo
2023-06-22 0:04 ` [PATCH 5/7] arm64: dts: qcom: msm8916-samsung-fortuna: Add touchscreen Lin, Meng-Bo
2023-06-22 0:05 ` [PATCH 6/7] arm64: dts: qcom: msm8916-samsung-fortuna: Add accelerometer/magnetometer Lin, Meng-Bo
2023-06-22 15:17 ` Krzysztof Kozlowski
2023-06-22 0:05 ` Lin, Meng-Bo [this message]
2023-06-22 15:20 ` [PATCH 7/7] arm64: dts: qcom: msm8916-samsung-fortuna: Add NFC Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230622000437.48367-1-linmengbo0689@protonmail.com \
--to=linmengbo0689@protonmail.com \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=arnd@arndb.de \
--cc=buddyjojo06@outlook.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nikita@trvn.ru \
--cc=olof@lixom.net \
--cc=robh+dt@kernel.org \
--cc=soc@kernel.org \
--cc=stephan@gerhold.net \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®