phone-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/4] support the Librem 5 front camera
@ 2021-10-15  8:35 Martin Kepplinger
  2021-10-15  8:35 ` [RFC PATCH v1 1/4] arm64: dts: split out a shared imx8mq-librem5-r3.dtsi description Martin Kepplinger
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Martin Kepplinger @ 2021-10-15  8:35 UTC (permalink / raw)
  To: robh, shawnguo, festevam, krzk
  Cc: kernel, linux-imx, kernel, devicetree, linux-arm-kernel,
	linux-kernel, phone-devel, Martin Kepplinger

The first patch adds a shared "r3.dtsi" and is only refactoring.

The is an RFC because of patch 2 that describes the power supplies as
regulators. Suggestions are very welcome.

Patch 3 and 4 should be straight forward camera descriptions according to
the drivers.

thank you,
                             martin

Martin Kepplinger (4):
  arm64: dts: split out a shared imx8mq-librem5-r3.dtsi description
  arm64: dts: imx8mq-librem5: describe power supply for cameras
  arm64: dts: imx8mq-librem5: describe the selfie cam
  arm64: dts: imx8mq-librem5-r3.dtsi: describe selfie cam XSHUTDOWN pin

 .../boot/dts/freescale/imx8mq-librem5-r3.dts  | 25 +----
 .../boot/dts/freescale/imx8mq-librem5-r3.dtsi | 45 +++++++++
 .../boot/dts/freescale/imx8mq-librem5-r4.dts  | 16 +---
 .../boot/dts/freescale/imx8mq-librem5.dtsi    | 96 ++++++++++++++++++-
 4 files changed, 144 insertions(+), 38 deletions(-)
 create mode 100644 arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dtsi

-- 
2.30.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC PATCH v1 1/4] arm64: dts: split out a shared imx8mq-librem5-r3.dtsi description
  2021-10-15  8:35 [RFC PATCH v1 0/4] support the Librem 5 front camera Martin Kepplinger
@ 2021-10-15  8:35 ` Martin Kepplinger
  2021-10-15  8:35 ` [RFC PATCH v1 2/4] arm64: dts: imx8mq-librem5: describe power supply for cameras Martin Kepplinger
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Martin Kepplinger @ 2021-10-15  8:35 UTC (permalink / raw)
  To: robh, shawnguo, festevam, krzk
  Cc: kernel, linux-imx, kernel, devicetree, linux-arm-kernel,
	linux-kernel, phone-devel, Martin Kepplinger

The Librem 5 r3 ("Dogwood") and r4 ("Evergreen") revisions are quite
similar. Add a shared imx8mq-librem5-r3.dtsi description to be included
in r3 and later dts files in order to avoid duplication.

This is no change in the descriptions but only refactoring.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
---
 .../boot/dts/freescale/imx8mq-librem5-r3.dts  | 25 ++-------------
 .../boot/dts/freescale/imx8mq-librem5-r3.dtsi | 32 +++++++++++++++++++
 .../boot/dts/freescale/imx8mq-librem5-r4.dts  | 16 ++--------
 3 files changed, 36 insertions(+), 37 deletions(-)
 create mode 100644 arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dtsi

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
index cd3c3edd48fa..4533a84fb0b9 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dts
@@ -1,14 +1,9 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
-// Copyright (C) 2020 Purism SPC <kernel@puri.sm>
+// Copyright (C) 2021 Purism SPC <kernel@puri.sm>
 
 /dts-v1/;
 
-#include "imx8mq-librem5.dtsi"
-
-/ {
-	model = "Purism Librem 5r3";
-	compatible = "purism,librem5r3", "purism,librem5", "fsl,imx8mq";
-};
+#include "imx8mq-librem5-r3.dtsi"
 
 &a53_opp_table {
 	opp-1000000000 {
@@ -16,22 +11,6 @@ opp-1000000000 {
 	};
 };
 
-&accel_gyro {
-	mount-matrix =  "1",  "0",  "0",
-			"0",  "1",  "0",
-			"0",  "0", "-1";
-};
-
-&bq25895 {
-	ti,battery-regulation-voltage = <4200000>; /* uV */
-	ti,charge-current = <1500000>; /* uA */
-	ti,termination-current = <144000>;  /* uA */
-};
-
 &buck3_reg {
 	regulator-always-on;
 };
-
-&proximity {
-	proximity-near-level = <25>;
-};
diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dtsi b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dtsi
new file mode 100644
index 000000000000..e872eb4b1cf9
--- /dev/null
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dtsi
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+// Copyright (C) 2021 Purism SPC <kernel@puri.sm>
+
+/dts-v1/;
+
+/*
+ * This file describes hardware that is shared among r3 ("Dogwood") and
+ * later revisions of the Librem 5 so it has to be included in dts there.
+ */
+
+#include "imx8mq-librem5.dtsi"
+
+/ {
+	model = "Purism Librem 5r3";
+	compatible = "purism,librem5r3", "purism,librem5", "fsl,imx8mq";
+};
+
+&accel_gyro {
+	mount-matrix =  "1",  "0",  "0",
+			"0",  "1",  "0",
+			"0",  "0", "-1";
+};
+
+&bq25895 {
+	ti,battery-regulation-voltage = <4200000>; /* uV */
+	ti,charge-current = <1500000>; /* uA */
+	ti,termination-current = <144000>;  /* uA */
+};
+
+&proximity {
+	proximity-near-level = <25>;
+};
diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts
index cbfb49aa2563..30d65bef6939 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r4.dts
@@ -1,31 +1,19 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
-// Copyright (C) 2020 Purism SPC <kernel@puri.sm>
+// Copyright (C) 2021 Purism SPC <kernel@puri.sm>
 
 /dts-v1/;
 
-#include "imx8mq-librem5.dtsi"
+#include "imx8mq-librem5-r3.dtsi"
 
 / {
 	model = "Purism Librem 5r4";
 	compatible = "purism,librem5r4", "purism,librem5", "fsl,imx8mq";
 };
 
-&accel_gyro {
-	mount-matrix =  "1",  "0",  "0",
-			"0",  "1",  "0",
-			"0",  "0", "-1";
-};
-
 &bat {
 	maxim,rsns-microohm = <1667>;
 };
 
-&bq25895 {
-	ti,battery-regulation-voltage = <4200000>; /* uV */
-	ti,charge-current = <1500000>; /* uA */
-	ti,termination-current = <144000>;  /* uA */
-};
-
 &led_backlight {
 	led-max-microamp = <25000>;
 };
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH v1 2/4] arm64: dts: imx8mq-librem5: describe power supply for cameras
  2021-10-15  8:35 [RFC PATCH v1 0/4] support the Librem 5 front camera Martin Kepplinger
  2021-10-15  8:35 ` [RFC PATCH v1 1/4] arm64: dts: split out a shared imx8mq-librem5-r3.dtsi description Martin Kepplinger
@ 2021-10-15  8:35 ` Martin Kepplinger
  2021-10-15  8:35 ` [RFC PATCH v1 3/4] arm64: dts: imx8mq-librem5: describe the selfie cam Martin Kepplinger
  2021-10-15  8:35 ` [RFC PATCH v1 4/4] arm64: dts: imx8mq-librem5-r3.dtsi: describe selfie cam XSHUTDOWN pin Martin Kepplinger
  3 siblings, 0 replies; 5+ messages in thread
From: Martin Kepplinger @ 2021-10-15  8:35 UTC (permalink / raw)
  To: robh, shawnguo, festevam, krzk
  Cc: kernel, linux-imx, kernel, devicetree, linux-arm-kernel,
	linux-kernel, phone-devel, Martin Kepplinger

CAMERA_PWR_EN controls two different power supplies that cameras will use.
The hardware killswitch controls a third one. Describe that appropriately.

The pinctrl that describes the gpio that is used in 2 places here is added
to the pmic. The pmic is powered early enough to make sure this will work.

this patch is not ideal and hence an RFC I'm not yet signing-off on: When
putting the same pinctrl property into the 2 regulator nodes (instead of the
pmic), we get:

imx8mq-pinctrl 30330000.pinctrl: pin MX8MQ_IOMUXC_GPIO1_IO00 already requested by regulator-csi-1v8; cannot claim for regulator-vcam-2v8
imx8mq-pinctrl 30330000.pinctrl: pin-10 (regulator-vcam-2v8) status -22
imx8mq-pinctrl 30330000.pinctrl: could not request pin 10 (MX8MQ_IOMUXC_GPIO1_IO00) from group camerapwrgrp  on device 30330000.pinctrl

so that's a limitation to use the pinctrl only in one place. Is that
intended or am I missing something?

The one other possibility I see is to add *another* regulator that looks
something like so - that would be the only one controlling the gpio and having
the pinctrl property:

	reg_camera_pwr_en: regulator-camera-pwr-en {
		compatible = "regulator-fixed";
		regulator-name = "CAMERA_PWR_EN";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_camera_pwr>;
		gpio = <&gpio1 0 GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};

and the regulators I actually *want* to describe would all include

		vin-supply = <&reg_camera_pwr_en>;

My problem with that alternative is that I basically describe a regulator that
doesn't really exist in hardware. Do you know what's the prefererred way to
describe our hardware here?

thank you very much!

                                martin
---
 .../boot/dts/freescale/imx8mq-librem5.dtsi    | 50 ++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 3f7524400a63..c385f9e0d5f7 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -60,6 +60,40 @@ reg_aud_1v8: regulator-audio-1v8 {
 		enable-active-high;
 	};
 
+	/*
+	 * the pinctrl for reg_csi_1v8 and reg_vcam_1v8 is added to the PMIC
+	 * since we can't have it twice in the 2 different regulator nodes.
+	 */
+	reg_csi_1v8: regulator-csi-1v8 {
+		compatible = "regulator-fixed";
+		regulator-name = "CAMERA_VDDIO_1V8";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		vin-supply = <&reg_vdd_3v3>;
+		gpio = <&gpio1 0 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+	};
+
+	/* controlled by the CAMERA_POWER_KEY HKS */
+	reg_vcam_1v2: regulator-vcam-1v2 {
+		compatible = "regulator-fixed";
+		regulator-name = "CAMERA_VDDD_1V2";
+		regulator-min-microvolt = <1200000>;
+		regulator-max-microvolt = <1200000>;
+		vin-supply = <&reg_vdd_1v8>;
+		enable-active-high;
+	};
+
+	reg_vcam_2v8: regulator-vcam-2v8 {
+		compatible = "regulator-fixed";
+		regulator-name = "CAMERA_VDDA_2V8";
+		regulator-min-microvolt = <2800000>;
+		regulator-max-microvolt = <2800000>;
+		vin-supply = <&reg_vdd_3v3>;
+		gpio = <&gpio1 0 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+	};
+
 	reg_gnss: regulator-gnss {
 		compatible = "regulator-fixed";
 		pinctrl-names = "default";
@@ -307,6 +341,20 @@ MX8MQ_IOMUXC_NAND_DQS_GPIO3_IO14	0x83
 		>;
 	};
 
+	pinctrl_camera_pwr: camerapwrgrp {
+		fsl,pins = <
+			/* CAMERA_PWR_EN_3V3 */
+			MX8MQ_IOMUXC_GPIO1_IO00_GPIO1_IO0	0x83
+		>;
+	};
+
+	pinctrl_csi1: csi1grp {
+		fsl,pins = <
+			/* CSI1_NRST */
+			MX8MQ_IOMUXC_ENET_RXC_GPIO1_IO25	0x83
+		>;
+	};
+
 	pinctrl_charger_in: chargeringrp {
 		fsl,pins = <
 			/* CHRG_INT */
@@ -689,7 +737,7 @@ pmic: pmic@4b {
 		compatible = "rohm,bd71837";
 		reg = <0x4b>;
 		pinctrl-names = "default";
-		pinctrl-0 = <&pinctrl_pmic>;
+		pinctrl-0 = <&pinctrl_pmic>, <&pinctrl_camera_pwr>;
 		clocks = <&pmic_osc>;
 		clock-names = "osc";
 		clock-output-names = "pmic_clk";
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH v1 3/4] arm64: dts: imx8mq-librem5: describe the selfie cam
  2021-10-15  8:35 [RFC PATCH v1 0/4] support the Librem 5 front camera Martin Kepplinger
  2021-10-15  8:35 ` [RFC PATCH v1 1/4] arm64: dts: split out a shared imx8mq-librem5-r3.dtsi description Martin Kepplinger
  2021-10-15  8:35 ` [RFC PATCH v1 2/4] arm64: dts: imx8mq-librem5: describe power supply for cameras Martin Kepplinger
@ 2021-10-15  8:35 ` Martin Kepplinger
  2021-10-15  8:35 ` [RFC PATCH v1 4/4] arm64: dts: imx8mq-librem5-r3.dtsi: describe selfie cam XSHUTDOWN pin Martin Kepplinger
  3 siblings, 0 replies; 5+ messages in thread
From: Martin Kepplinger @ 2021-10-15  8:35 UTC (permalink / raw)
  To: robh, shawnguo, festevam, krzk
  Cc: kernel, linux-imx, kernel, devicetree, linux-arm-kernel,
	linux-kernel, phone-devel, Martin Kepplinger

Enable the CSI1 MIPI RX controller and CSI1 bridge on the SoC. Describe
the Librem 5 front-facing camera, connected to the CSI1 MIPI.

the following sets formats, streams 10 frames and saves one:

	#!/bin/bash
	WIDTH=1632
	HEIGHT=1224
	SKIP=10

	media-ctl -d "platform:30a90000.csi" --set-v4l2 "'csi':0 [fmt:SGBRG10/${WIDTH}x${HEIGHT} colorspace:raw]"
	media-ctl -d "platform:30a90000.csi" --set-v4l2 "'imx8mq-mipi-csi2 30a70000.csi':0 [fmt:SGBRG10/${WIDTH}x${HEIGHT} colorspace:raw]"
	media-ctl -d "platform:30a90000.csi" --set-v4l2 "'hi846 2-0020':0 [fmt:SGBRG10/${WIDTH}x${HEIGHT} colorspace:raw]"
	media-ctl -d "platform:30a90000.csi" -l "'hi846 2-0020':0 -> 'imx8mq-mipi-csi2 30a70000.csi':0 [1]"
	v4l2-ctl -d "/dev/v4l/by-path/platform-30a90000.csi-video-index0" --set-fmt-video=width=${WIDTH},height=${HEIGHT},pixelformat=GB16 --stream-mmap --stream-to=$WIDTH.raw --stream-skip=$SKIP --stream-count=1

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
---
 .../boot/dts/freescale/imx8mq-librem5.dtsi    | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index c385f9e0d5f7..42e318d663e5 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -256,6 +256,10 @@ &A53_3 {
 	cpu-supply = <&buck2_reg>;
 };
 
+&csi1 {
+	status = "okay";
+};
+
 &ddrc {
 	operating-points-v2 = <&ddrc_opp_table>;
 
@@ -970,6 +974,31 @@ codec: audio-codec@1a {
 		>;
 	};
 
+	camera_front: camera@20 {
+		compatible = "hynix,hi846";
+		reg = <0x20>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_csi1>;
+		clocks = <&clk IMX8MQ_CLK_CLKO2>;
+		assigned-clocks = <&clk IMX8MQ_CLK_CLKO2>;
+		assigned-clock-rates = <25000000>;
+		reset-gpios = <&gpio1 25 GPIO_ACTIVE_LOW>;
+		vdda-supply = <&reg_vcam_2v8>;
+		vddd-supply = <&reg_vcam_1v2>;
+		vddio-supply = <&reg_csi_1v8>;
+		rotation = <90>;
+		orientation = <0>;
+
+		port {
+			camera1_ep: endpoint {
+				data-lanes = <1 2>;
+				link-frequencies = /bits/ 64
+					<80000000 200000000 300000000>;
+				remote-endpoint = <&mipi1_sensor_ep>;
+			};
+		};
+	};
+
 	backlight@36 {
 		compatible = "ti,lm36922";
 		reg = <0x36>;
@@ -1043,6 +1072,23 @@ &lcdif {
 	status = "okay";
 };
 
+&mipi_csi1 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	status = "okay";
+
+	ports {
+		port@1 {
+			reg = <1>;
+
+			mipi1_sensor_ep: endpoint {
+				remote-endpoint = <&camera1_ep>;
+				data-lanes = <1 2>;
+			};
+		};
+	};
+};
+
 &mipi_dsi {
 	#address-cells = <1>;
 	#size-cells = <0>;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH v1 4/4] arm64: dts: imx8mq-librem5-r3.dtsi: describe selfie cam XSHUTDOWN pin
  2021-10-15  8:35 [RFC PATCH v1 0/4] support the Librem 5 front camera Martin Kepplinger
                   ` (2 preceding siblings ...)
  2021-10-15  8:35 ` [RFC PATCH v1 3/4] arm64: dts: imx8mq-librem5: describe the selfie cam Martin Kepplinger
@ 2021-10-15  8:35 ` Martin Kepplinger
  3 siblings, 0 replies; 5+ messages in thread
From: Martin Kepplinger @ 2021-10-15  8:35 UTC (permalink / raw)
  To: robh, shawnguo, festevam, krzk
  Cc: kernel, linux-imx, kernel, devicetree, linux-arm-kernel,
	linux-kernel, phone-devel, Martin Kepplinger

The r3 and later revisions of the Librem 5 phone include an additional switch
to control the hi846 XSHUTDOWN pin. Describe it.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
---
 .../arm64/boot/dts/freescale/imx8mq-librem5-r3.dtsi | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dtsi b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dtsi
index e872eb4b1cf9..e4f8b47cce4f 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dtsi
@@ -27,6 +27,19 @@ &bq25895 {
 	ti,termination-current = <144000>;  /* uA */
 };
 
+&camera_front {
+	pinctrl-0 = <&pinctrl_csi1>, <&pinctrl_r3_camera_pwr>;
+	shutdown-gpios = <&gpio5 4 GPIO_ACTIVE_LOW>;
+};
+
+&iomuxc {
+	pinctrl_r3_camera_pwr: r3camerapwrgrp {
+		fsl,pins = <
+			MX8MQ_IOMUXC_SPDIF_RX_GPIO5_IO4		0x83
+		>;
+	};
+};
+
 &proximity {
 	proximity-near-level = <25>;
 };
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-15  8:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15  8:35 [RFC PATCH v1 0/4] support the Librem 5 front camera Martin Kepplinger
2021-10-15  8:35 ` [RFC PATCH v1 1/4] arm64: dts: split out a shared imx8mq-librem5-r3.dtsi description Martin Kepplinger
2021-10-15  8:35 ` [RFC PATCH v1 2/4] arm64: dts: imx8mq-librem5: describe power supply for cameras Martin Kepplinger
2021-10-15  8:35 ` [RFC PATCH v1 3/4] arm64: dts: imx8mq-librem5: describe the selfie cam Martin Kepplinger
2021-10-15  8:35 ` [RFC PATCH v1 4/4] arm64: dts: imx8mq-librem5-r3.dtsi: describe selfie cam XSHUTDOWN pin Martin Kepplinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).