Skip to contentSkip to conversation

arm64: dts: qcom: msm8916-samsung-fortuna: Add msm8916-samsung-fortuna/rossa: Add S3FWRN5 NFC and RT5033 PMIC/charger

PATCH Applied Raymond Hackley 2 participants 5 messages Jun 1, 2024 – Jun 6, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover arm64: dts: qcom: msm8916-samsung-fortuna: Add msm8916-samsung-fortuna/rossa: Add S3FWRN5 NFC and RT5033 PMIC/charger

Some variants of Samsung Galaxy Core Prime LTE / Grand Prime LTE have a Samsung S3FWRN5 NFC chip that works quite well with the s3fwrn5 driver in the Linux NFC subsystem.

All of Samsung Galaxy Core Prime LTE/ Grand Prime have Richtek RT5033 PMIC and charger.

Add support for them.

#1 lore raw

PATCH 1/3 arm64: dts: qcom: msm8916-samsung-gprimeltecan: Add NFC

From: Joe Mason <[email protected]>

The Samsung Galaxy Grand Prime CAN has 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.

[Stephan: Put NFC pinctrl into common dtsi to share it with other variants]
[Raymond: Use interrupts-extended. Keep &blsp_i2c6 enabled by default]
---
 .../qcom/msm8916-samsung-fortuna-common.dtsi  | 38 +++++++++++++++++++
 .../dts/qcom/msm8916-samsung-gprimeltecan.dts | 17 +++++++++
 2 files changed, 55 insertions(+)
arch/arm64/boot/dts/qcom/msm8916-samsung-fortuna-common.dtsi +38 -0
index 4f05cae68b37..4cc83b64e256 100644
@@ -6,6 +6,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 {
@@ -227,6 +228,10 @@ touchscreen: touchscreen@20 {
 	};
 };
 
+&blsp_i2c6 {
+	status = "okay";
+};
+
 &blsp_uart2 {
 	status = "okay";
 };
@@ -346,6 +351,29 @@ muic_int_default: muic-int-default-state {
 		bias-disable;
 	};
 
+	nfc_default: nfc-default-state {
+		irq-pins {
+			pins = "gpio21";
+			function = "gpio";
+			drive-strength = <2>;
+			bias-pull-down;
+		};
+
+		nfc-pins {
+			pins = "gpio20", "gpio49";
+			function = "gpio";
+			drive-strength = <2>;
+			bias-disable;
+		};
+	};
+
+	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";
@@ -367,3 +395,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;
+	};
+};
arch/arm64/boot/dts/qcom/msm8916-samsung-gprimeltecan.dts +17 -0
index 4dc74e8bf1d8..7ac86fd3c703 100644
@@ -29,6 +29,23 @@ &bosch_magn {
 	status = "okay";
 };
 
+&blsp_i2c6 {
+	nfc@27 {
+		compatible = "samsung,s3fwrn5-i2c";
+		reg = <0x27>;
+
+		interrupts-extended = <&tlmm 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";
+	};
+};
+
 &mpss_mem {
 	/* Firmware for gprimeltecan needs more space */
 	reg = <0x0 0x86800000 0x0 0x5400000>;
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/3 arm64: dts: qcom: msm8916-samsung-fortuna/rossa: Add S3FWRN5 NFC

In reply to Raymond Hackley

Some variants of Samsung Galaxy Core Prime LTE / Grand Prime LTE 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.

---
 .../qcom/msm8916-samsung-fortuna-common.dtsi  | 29 +++++++++++++++++++
 .../dts/qcom/msm8916-samsung-gprimeltecan.dts |  4 +++
 .../qcom/msm8916-samsung-rossa-common.dtsi    |  4 +++
 3 files changed, 37 insertions(+)
arch/arm64/boot/dts/qcom/msm8916-samsung-fortuna-common.dtsi +29 -0
index 4cc83b64e256..b5b7beab2209 100644
@@ -79,6 +79,35 @@ 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>;
+
+		s3fwrn5_nfc: nfc@27 {
+			compatible = "samsung,s3fwrn5-i2c";
+			reg = <0x27>;
+
+			interrupts-extended = <&tlmm 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";
arch/arm64/boot/dts/qcom/msm8916-samsung-gprimeltecan.dts +4 -0
index 7ac86fd3c703..589dd006a746 100644
@@ -46,6 +46,10 @@ nfc@27 {
 	};
 };
 
+&i2c_nfc {
+	/* nfc@27 is on &blsp_i2c6 */
+};
+
 &mpss_mem {
 	/* Firmware for gprimeltecan needs more space */
 	reg = <0x0 0x86800000 0x0 0x5400000>;
arch/arm64/boot/dts/qcom/msm8916-samsung-rossa-common.dtsi +4 -0
index 13a848d97b9d..e7f265e3c2ab 100644
@@ -33,6 +33,10 @@ &clk_pwm_backlight {
 	status = "disabled";
 };
 
+&s3fwrn5_nfc {
+	status = "okay";
+};
+
 &st_accel {
 	compatible = "st,lis2hh12";
 	mount-matrix = "1",  "0", "0",
Signature · 1 line
2.39.2
#3 lore raw

PATCH 3/3 arm64: dts: qcom: msm8916-samsung-fortuna/rossa: Add PMIC and charger

In reply to Raymond Hackley

The phones listed below have Richtek RT5033 PMIC and charger. Add them to the device trees.
- Samsung Galaxy Core Prime LTE
- Samsung Galaxy Grand Prime

---
 .../dts/qcom/msm8216-samsung-fortuna3g.dts    |  6 +++
 .../qcom/msm8916-samsung-fortuna-common.dtsi  | 47 +++++++++++++++++++
 .../dts/qcom/msm8916-samsung-gprimeltecan.dts | 41 ++++++++++++++++
 .../qcom/msm8916-samsung-grandprimelte.dts    |  6 +++
 .../boot/dts/qcom/msm8916-samsung-rossa.dts   |  6 +++
 5 files changed, 106 insertions(+)
arch/arm64/boot/dts/qcom/msm8216-samsung-fortuna3g.dts +6 -0
index e7f6df229f9a..fba68bf8bf79 100644
@@ -10,6 +10,12 @@ / {
 	chassis-type = "handset";
 };
 
+&battery {
+	charge-term-current-microamp = <200000>;
+	constant-charge-current-max-microamp = <1000000>;
+	constant-charge-voltage-max-microvolt = <4350000>;
+};
+
 &st_accel {
 	status = "okay";
 };
arch/arm64/boot/dts/qcom/msm8916-samsung-fortuna-common.dtsi +47 -0

71 lines not on this page · raw message

arch/arm64/boot/dts/qcom/msm8916-samsung-gprimeltecan.dts +41 -0

59 lines not on this page · raw message

arch/arm64/boot/dts/qcom/msm8916-samsung-grandprimelte.dts +6 -0
index cffad734c4df..582bfcb09684 100644
@@ -10,6 +10,12 @@ / {
 	chassis-type = "handset";
 };
 
+&battery {
+	charge-term-current-microamp = <200000>;
+	constant-charge-current-max-microamp = <1000000>;
+	constant-charge-voltage-max-microvolt = <4350000>;
+};
+
 &bosch_accel {
 	status = "okay";
 };
arch/arm64/boot/dts/qcom/msm8916-samsung-rossa.dts +6 -0
index ebaa13c6b016..1981bb71f6a9 100644
@@ -10,6 +10,12 @@ / {
 	chassis-type = "handset";
 };
 
+&battery {
+	charge-term-current-microamp = <150000>;
+	constant-charge-current-max-microamp = <700000>;
+	constant-charge-voltage-max-microvolt = <4400000>;
+};
+
 &mpss_mem {
 	/* Firmware for rossa needs more space */
 	reg = <0x0 0x86800000 0x0 0x5800000>;
Signature · 1 line
2.39.2
maintainer Applied
#4 lore raw
In reply to Raymond Hackley
Quoted 8 lines · Raymond Hackley

Some variants of Samsung Galaxy Core Prime LTE / Grand Prime LTE have a Samsung S3FWRN5 NFC chip that works quite well with the s3fwrn5 driver in the Linux NFC subsystem.

All of Samsung Galaxy Core Prime LTE/ Grand Prime have Richtek RT5033 PMIC and charger.

[...]

Applied, thanks!

[1/3] arm64: dts: qcom: msm8916-samsung-gprimeltecan: Add NFC

      commit: 62ae64ceb9a55333f3b259fef8acd0bf1598638a
[2/3] arm64: dts: qcom: msm8916-samsung-fortuna/rossa: Add S3FWRN5 NFC
      commit: 834cfba67835ff2440ef7402e1448a40d3c61250
[3/3] arm64: dts: qcom: msm8916-samsung-fortuna/rossa: Add PMIC and charger
      commit: ca4afdfdbbbd64cc08eee834bee97596bb649413

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>