Skip to contentSkip to conversation

Initial support for the Pixel 3

PATCH In review Caleb Connolly 8 participants 18 messages Jul 18, 2022 – Oct 1, 2022

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

cover Initial support for the Pixel 3

This series adds an initial DTS and display panel driver for the Pixel 3. The Pixel 3 display uses DSC (Display Stream Compression) which has been supported in mainline for some time now.

Functionality includes:
- Display, GPU, venus video transcoder
- Modem/WiFi/Bluetooth - ModemManager seems to fail

The touchscreen uses some HEFTY downstream driver, hopefully we'll come up with an upstreamable solution for it soon and make this a bit more usable.

Amit Pundir (1):
arm64: dts: qcom: add sdm845-google-blueline (Pixel 3)

Caleb Connolly (1):
Documentation: dt-bindings: arm: qcom: add google,blueline

Sumit Semwal (2):
dt-bindings: panel: Add LG SW43408 MIPI-DSI panel
drm: panel: Add lg sw43408 panel driver

 .../devicetree/bindings/arm/qcom.yaml         |   1 +
 .../bindings/display/panel/lg,43408.yaml      |  41 ++
 .../display/panel/panel-simple-dsi.yaml       |   2 +
 MAINTAINERS                                   |   8 +
 arch/arm64/boot/dts/qcom/Makefile             |   1 +
 .../boot/dts/qcom/sdm845-google-blueline.dts  | 652 ++++++++++++++++++
 drivers/gpu/drm/panel/Kconfig                 |  11 +
 drivers/gpu/drm/panel/Makefile                |   1 +
 drivers/gpu/drm/panel/panel-lg-sw43408.c      | 586 ++++++++++++++++
 9 files changed, 1303 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/lg,43408.yaml
 create mode 100644 arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts
 create mode 100644 drivers/gpu/drm/panel/panel-lg-sw43408.c
Signature · 1 line
2.36.1
#1 lore raw

PATCH 1/4 Documentation: dt-bindings: arm: qcom: add google,blueline

Document the bindings for the Pixel 3

Based on https://lore.kernel.org/all/[email protected]/

---
 Documentation/devicetree/bindings/arm/qcom.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/arm/qcom.yaml +1 -0
index b727467e86c6..b3e1004673c7 100644
@@ -320,6 +320,7 @@ properties:
 
       - items:
           - enum:
+              - google,blueline
               - lenovo,yoga-c630
               - oneplus,enchilada
               - oneplus,fajita
Signature · 1 line
2.36.1
Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] Documentation: dt-bindings: arm: qcom: add google,blueline

Quoted 3 lines · Caleb Connolly

Document the bindings for the Pixel 3

Based on https://lore.kernel.org/all/[email protected]/

Thanks for mention dependency. However this should not go to the final commit, thus please put such references after '---' marker.

With that change:

Quoted 3 lines

---

Best regards,
Krzysztof

#3 lore raw

PATCH 2/4 arm64: dts: qcom: add sdm845-google-blueline (Pixel 3)

In reply to Caleb Connolly

From: Amit Pundir <[email protected]>

This adds an initial dts for the Blueline (Pixel 3). Supported functionality includes display, Debug UART, UFS, USB-C (peripheral), WiFi, Bluetooth and modem.

Bootloader compatible board and msm IDs are needed for the kernel to boot with Pixel3 bootloader, so those are added.

GPIOs 0 through 3 and 81 through 84 are configured to not be accessible from the application CPUs, so we mark them as reserved to allow the Pixel 3 to boot.

The reserved-memory locations where obtained from downstream using kernel logs:
https://gist.github.com/calebccff/090d10bfac3cb9e9bd98dda30b054c96

The rmtfs region is allocated with UIO, making it technically "dynamic". It's address and size can be read from sysfs:

blueline:/ # cat /sys/class/uio/uio0/name rmtfs
at /sys/class/uio/uio0/maps/map0/addr 0x00000000f2701000
blueline:/ # cat /sys/class/uio/uio0/maps/map0/size 0x0000000000200000

Like the OnePlus 6, it needs 1kB reserved on either side of the rmtfs memory to workaround some XPU bug which would otherwise cause erroneous XPU violations when accessing the rmtfs_mem region.

For wifi, the pixel 3 reports a board-id of 0xFF, and downstream only includes a single bdwlan file. The qcom,ath10k-calibration-variant property is set to ensure that the correct calibration data is used.

[AmitP: Cherry-picked and refactored from Bjorn's db845c dts

        ("arm64: dts: qcom: Add Dragonboard 845c") https://lkml.org/lkml/2019/6/6/7]

[sumits: merged commits to add board and msm ids, gpio range reservation,
ufs device-reset gpio and adaptation to v5.5+ changes]

[vinod: Add display nodes]
[caleb: remove db845c bits, cleanup, add reserved-memory for modem/wifi]
---
 arch/arm64/boot/dts/qcom/Makefile             |   1 +
 .../boot/dts/qcom/sdm845-google-blueline.dts  | 652 ++++++++++++++++++
 2 files changed, 653 insertions(+)
 create mode 100644 arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts
arch/arm64/boot/dts/qcom/Makefile +1 -0
index 2f8aec2cc6db..c151e17e6eb7 100644
@@ -100,6 +100,7 @@ dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-cheza-r1.dtb
 dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-cheza-r2.dtb
 dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-cheza-r3.dtb
 dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-db845c.dtb
+dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-google-blueline.dtb
 dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-mtp.dtb
 dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-oneplus-enchilada.dtb
 dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-oneplus-fajita.dtb
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +652 -0

652 lines not on this page · raw message

Signature · 1 line
2.36.1
#4 lore raw

Re: [PATCH 2/4] arm64: dts: qcom: add sdm845-google-blueline (Pixel 3)

Quoted 38 lines · Caleb Connolly

From: Amit Pundir <[email protected]>

This adds an initial dts for the Blueline (Pixel 3). Supported functionality includes display, Debug UART, UFS, USB-C (peripheral), WiFi, Bluetooth and modem.

Bootloader compatible board and msm IDs are needed for the kernel to boot with Pixel3 bootloader, so those are added.

GPIOs 0 through 3 and 81 through 84 are configured to not be accessible from the application CPUs, so we mark them as reserved to allow the Pixel 3 to boot.

The reserved-memory locations where obtained from downstream using kernel logs:
https://gist.github.com/calebccff/090d10bfac3cb9e9bd98dda30b054c96

The rmtfs region is allocated with UIO, making it technically "dynamic". It's address and size can be read from sysfs:

blueline:/ # cat /sys/class/uio/uio0/name rmtfs
at /sys/class/uio/uio0/maps/map0/addr 0x00000000f2701000
blueline:/ # cat /sys/class/uio/uio0/maps/map0/size 0x0000000000200000

Like the OnePlus 6, it needs 1kB reserved on either side of the rmtfs memory to workaround some XPU bug which would otherwise cause erroneous XPU violations when accessing the rmtfs_mem region.

For wifi, the pixel 3 reports a board-id of 0xFF, and downstream only includes a single bdwlan file. The qcom,ath10k-calibration-variant property is set to ensure that the correct calibration data is used.

[AmitP: Cherry-picked and refactored from Bjorn's db845c dts

         ("arm64: dts: qcom: Add Dragonboard 845c") https://lkml.org/lkml/2019/6/6/7]
Quoted 8 lines

[sumits: merged commits to add board and msm ids, gpio range reservation,
ufs device-reset gpio and adaptation to v5.5+ changes]

[vinod: Add display nodes]
[caleb: remove db845c bits, cleanup, add reserved-memory for modem/wifi]

Thanks for your patch, few minor items to improve.

Quoted 70 lines
---
  arch/arm64/boot/dts/qcom/Makefile             |   1 +
  .../boot/dts/qcom/sdm845-google-blueline.dts  | 652 ++++++++++++++++++
  2 files changed, 653 insertions(+)

create mode 100644 arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts

arch/arm64/boot/dts/qcom/Makefile +1 -0
index 2f8aec2cc6db..c151e17e6eb7 100644
@@ -100,6 +100,7 @@ dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-cheza-r1.dtb
  dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-cheza-r2.dtb
  dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-cheza-r3.dtb
  dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-db845c.dtb
+dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-google-blueline.dtb
  dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-mtp.dtb
  dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-oneplus-enchilada.dtb
  dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-oneplus-fajita.dtb
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +46 -0
new file mode 100644
index 000000000000..dec979ad9209
@@ -0,0 +1,652 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+
+#include <dt-bindings/dma/qcom-gpi.h>
+#include <dt-bindings/input/linux-event-codes.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
+
+#include "sdm845.dtsi"
+#include "pm8998.dtsi"
+#include "pmi8998.dtsi"
+
+/delete-node/ &mpss_region;
+/delete-node/ &venus_mem;
+/delete-node/ &cdsp_mem;
+/delete-node/ &mba_region;
+/delete-node/ &slpi_mem;
+/delete-node/ &spss_mem;
+/delete-node/ &rmtfs_mem;
+
+/ {
+	model = "Google Pixel 3";
+	compatible = "google,blueline", "qcom,sdm845";
+	qcom,board-id = <0x00021505 0>;
+	qcom,msm-id = <321 0x20001>;
+
+	aliases {
+		serial0 = &uart9;
+		serial1 = &uart6;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	volume-keys {
+		compatible = "gpio-keys";
+		label = "Volume keys";
+		autorepeat;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&volume_up_gpio>;
+
+		vol-up {
+			label = "Volume Up";

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 56

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+			linux,code = <KEY_VOLUMEUP>;
+			gpios = <&pm8998_gpio 6 GPIO_ACTIVE_LOW>;
+			debounce-interval = <15>;
+		};
+	};
+
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;

These properties are already part of the sdm845.dtsi, so no need to have them here.

Quoted 67 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +67 -0
+
+		mpss_region: memory@8e000000 {
+			reg = <0 0x8e000000 0 0x9800000>;
+			no-map;
+		};
+
+		venus_mem: venus@97800000 {
+			reg = <0 0x97800000 0 0x500000>;
+			no-map;
+		};
+
+		cdsp_mem: cdsp-mem@97D00000 {
+			reg = <0 0x97D00000 0 0x800000>;
+			no-map;
+		};
+
+		mba_region: mba@98500000 {
+			reg = <0 0x98500000 0 0x200000>;
+			no-map;
+		};
+
+		slpi_mem: slpi@98700000 {
+			reg = <0 0x98700000 0 0x1400000>;
+			no-map;
+		};
+
+		spss_mem: spss@99B00000 {
+			reg = <0 0x99B00000 0 0x100000>;
+			no-map;
+		};
+
+		/* rmtfs lower guard */
+		memory@f2700000 {
+			reg = <0 0xf2700000 0 0x1000>;
+			no-map;
+		};
+
+		rmtfs_mem: memory@f2701000 {
+			compatible = "qcom,rmtfs-mem";
+			reg = <0 0xf2701000 0 0x200000>;
+			no-map;
+
+			qcom,client-id = <1>;
+			qcom,vmid = <15>;
+		};
+
+		/* rmtfs upper guard */
+		memory@f2901000 {
+			reg = <0 0xf2901000 0 0x1000>;
+			no-map;
+		};
+	};
+
+	vph_pwr: vph-pwr-regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "vph_pwr";
+		regulator-min-microvolt = <3700000>;
+		regulator-max-microvolt = <3700000>;
+	};
+
+	vreg_s4a_1p8: vreg-s4a-1p8 {
+		compatible = "regulator-fixed";
+		regulator-name = "vreg_s4a_1p8";
+
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		regulator-always-on;

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 133

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+		regulator-boot-on;
+
+		vin-supply = <&vph_pwr>;
+	};
+};
+
+&adsp_pas {
+	status = "okay";
+
+	firmware-name = "qcom/sdm845/pixel3/adsp.mbn";

What about using "qcom/sdm845/blueline/adsp.mbn" instead?

Bjorn, Amit?

Quoted 40 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +40 -0
+};
+
+&apps_rsc {
+	pm8998-rpmh-regulators {
+		compatible = "qcom,pm8998-rpmh-regulators";
+		qcom,pmic-id = "a";
+		vdd-s1-supply = <&vph_pwr>;
+		vdd-s2-supply = <&vph_pwr>;
+		vdd-s3-supply = <&vph_pwr>;
+		vdd-s4-supply = <&vph_pwr>;
+		vdd-s5-supply = <&vph_pwr>;
+		vdd-s6-supply = <&vph_pwr>;
+		vdd-s7-supply = <&vph_pwr>;
+		vdd-s8-supply = <&vph_pwr>;
+		vdd-s9-supply = <&vph_pwr>;
+		vdd-s10-supply = <&vph_pwr>;
+		vdd-s11-supply = <&vph_pwr>;
+		vdd-s12-supply = <&vph_pwr>;
+		vdd-s13-supply = <&vph_pwr>;
+		vdd-l1-l27-supply = <&vreg_s7a_1p025>;
+		vdd-l2-l8-l17-supply = <&vreg_s3a_1p35>;
+		vdd-l3-l11-supply = <&vreg_s7a_1p025>;
+		vdd-l4-l5-supply = <&vreg_s7a_1p025>;
+		vdd-l6-supply = <&vph_pwr>;
+		vdd-l7-l12-l14-l15-supply = <&vreg_s5a_2p04>;
+		vdd-l9-supply = <&vreg_bob>;
+		vdd-l10-l23-l25-supply = <&vreg_bob>;
+		vdd-l13-l19-l21-supply = <&vreg_bob>;
+		vdd-l16-l28-supply = <&vreg_bob>;
+		vdd-l18-l22-supply = <&vreg_bob>;
+		vdd-l20-l24-supply = <&vreg_bob>;
+		vdd-l26-supply = <&vreg_s3a_1p35>;
+		vin-lvs-1-2-supply = <&vreg_s4a_1p8>;
+
+		vreg_s3a_1p35: smps3 {
+			regulator-min-microvolt = <1352000>;
+			regulator-max-microvolt = <1352000>;
+		};
+
+		vreg_s5a_2p04: smps5 {

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 183

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+			regulator-min-microvolt = <1904000>;
+			regulator-max-microvolt = <2040000>;
+		};
+
+		vreg_s7a_1p025: smps7 {
+			regulator-min-microvolt = <900000>;
+			regulator-max-microvolt = <1028000>;
+		};
+
+		vdda_mipi_dsi0_pll:

Do we need this alias?

Quoted 30 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +30 -0
+		vreg_l1a_0p875: ldo1 {
+			regulator-min-microvolt = <880000>;
+			regulator-max-microvolt = <880000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+			regulator-boot-on;
+		};
+
+		vreg_l5a_0p8: ldo5 {
+			regulator-min-microvolt = <800000>;
+			regulator-max-microvolt = <800000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l12a_1p8: ldo12 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l7a_1p8: ldo7 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l13a_2p95: ldo13 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <2960000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 223

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+
+		vreg_l14a_1p88: ldo14 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+			regulator-boot-on;
+			/*
+			 * We can't properly bring the panel back if it gets turned off
+			 * so keep it's regulators always on for now.
+			 */

Any idea, what is the issue here? Do you have the datasheet for the panel?

Quoted 37 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +37 -0
+			regulator-always-on;
+		};
+
+		vreg_l17a_1p3: ldo17 {
+			regulator-min-microvolt = <1304000>;
+			regulator-max-microvolt = <1304000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l19a_3p3: ldo19 {
+			regulator-min-microvolt = <3300000>;
+			regulator-max-microvolt = <3312000>;
+			qcom,init-voltage = <3300000>;
+			qcom,initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+			/*
+			 * The touchscreen needs this to be 3.3v, which is apparently
+			 * quite close to the hardware limit for this LDO (3.312v)
+			 * It must be kept in high power mode to prevent TS brownouts
+			 */
+			regulator-allowed-modes = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l20a_2p95: ldo20 {
+			regulator-min-microvolt = <2960000>;
+			regulator-max-microvolt = <2968000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l21a_2p95: ldo21 {
+			regulator-min-microvolt = <2960000>;
+			regulator-max-microvolt = <2968000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l24a_3p075: ldo24 {
+			regulator-min-microvolt = <3088000>;
+			regulator-max-microvolt = <3088000>;

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 270

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l25a_3p3: ldo25 {
+			regulator-min-microvolt = <3300000>;
+			regulator-max-microvolt = <3312000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vdda_mipi_dsi0_1p2:

Do we need this alias?

Quoted 135 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +135 -0
+		vreg_l26a_1p2: ldo26 {
+			regulator-min-microvolt = <1200000>;
+			regulator-max-microvolt = <1200000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+			regulator-boot-on;
+		};
+
+		vreg_l28a_3p0: ldo28 {
+			regulator-min-microvolt = <2856000>;
+			regulator-max-microvolt = <3008000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+			regulator-boot-on;
+			/*
+			 * We can't properly bring the panel back if it gets turned off
+			 * so keep it's regulators always on for now.
+			 */
+			regulator-always-on;
+		};
+	};
+
+	pmi8998-rpmh-regulators {
+		compatible = "qcom,pmi8998-rpmh-regulators";
+		qcom,pmic-id = "b";
+
+		vdd-bob-supply = <&vph_pwr>;
+
+		vreg_bob: bob {
+			regulator-min-microvolt = <3312000>;
+			regulator-max-microvolt = <3600000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_AUTO>;
+			regulator-allow-bypass;
+		};
+	};
+
+	pm8005-rpmh-regulators {
+		compatible = "qcom,pm8005-rpmh-regulators";
+		qcom,pmic-id = "c";
+
+		vdd-s1-supply = <&vph_pwr>;
+		vdd-s2-supply = <&vph_pwr>;
+		vdd-s3-supply = <&vph_pwr>;
+		vdd-s4-supply = <&vph_pwr>;
+
+		vreg_s3c_0p6: smps3 {
+			regulator-min-microvolt = <600000>;
+			regulator-max-microvolt = <600000>;
+		};
+	};
+};
+
+&cdsp_pas {
+	status = "okay";
+	firmware-name = "qcom/sdm845/pixel3/cdsp.mbn";
+};
+
+&dsi0 {
+	status = "okay";
+	vdda-supply = <&vdda_mipi_dsi0_1p2>;
+
+	ports {
+		port@1 {
+			endpoint {
+				remote-endpoint = <&lg_sw43408_in_0>;
+				data-lanes = <0 1 2 3>;
+			};
+		};
+	};
+
+	panel@0 {
+		compatible = "lg,sw43408";
+		reg = <0>;
+
+		vddi-supply = <&vreg_l14a_1p88>;
+		vpnl-supply = <&vreg_l28a_3p0>;
+
+		reset-gpios = <&tlmm 6 GPIO_ACTIVE_LOW>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&panel_reset_pins &panel_te_pin &panel_pmgpio_pins>;
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				lg_sw43408_in_0: endpoint {
+					remote-endpoint = <&dsi0_out>;
+				};
+			};
+		};
+	};
+};
+
+&dsi0_out {
+	remote-endpoint = <&lg_sw43408_in_0>;
+	data-lanes = <0 1 2 3>;
+};
+
+&dsi0_phy {
+	status = "okay";
+	vdds-supply = <&vdda_mipi_dsi0_pll>;
+};
+
+&gcc {
+	protected-clocks = <GCC_QSPI_CORE_CLK>,
+			   <GCC_QSPI_CORE_CLK_SRC>,
+			   <GCC_QSPI_CNOC_PERIPH_AHB_CLK>;
+};
+
+&gmu {
+	status = "okay";
+};
+
+&gpi_dma0 {
+	status = "okay";
+};
+
+&gpu {
+	status = "okay";
+
+	zap-shader {
+		memory-region = <&gpu_mem>;
+		firmware-name = "qcom/sdm845/pixel3/a630_zap.mbn";
+	};
+};
+
+&ipa {
+	status = "okay";
+
+	firmware-name = "qcom/sdm845/pixel3/ipa_fws.mbn";
+};
+
+&mss_pil {
+	status = "okay";

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 415

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+	firmware-name = "qcom/sdm845/pixel3/mba.mbn", "qcom/sdm845/pixel3/modem.mbn";
+};
+
+&mdss {
+	status = "okay";
+};
+
+&mdss_mdp {
+	status = "okay";
+};

Not necessary, it is a default state since the commit 4a5622c1d975 ("arm64: dts: qcom: sdm845: Don't disable MDP explicitly")

Quoted 17 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +17 -0
+
+&pm8998_gpio {
+	volume_up_gpio: vol-up-active {
+		pins = "gpio6";
+		function = "normal";
+		input-enable;
+		bias-pull-up;
+		qcom,drive-strength = <0>;
+	};
+
+	panel_pmgpio_pins: panel-pmgpio-active {
+		pins = "gpio2", "gpio5";
+		function = "normal";
+		input-enable;
+		bias-disable;
+		power-source = <0>;
+	};

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 442

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+};
+
+&pm8998_pon {
+	resin {
+		compatible = "qcom,pm8941-resin";
+		interrupts = <0x0 0x8 1 IRQ_TYPE_EDGE_BOTH>;
+		debounce = <15625>;
+		bias-pull-up;
+		linux,code = <KEY_VOLUMEDOWN>;
+	};

Please move the (disabled, labelled) resin device to pm8998.dtsi and just add status = "okay" here.

Quoted 75 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +75 -0
+};
+
+&qupv3_id_0 {
+	status = "okay";
+};
+
+&qupv3_id_1 {
+	status = "okay";
+};
+
+&qup_uart6_default {
+	pinmux {
+		pins = "gpio45", "gpio46", "gpio47", "gpio48";
+		function = "qup6";
+	};
+
+	cts {
+		pins = "gpio45";
+		bias-disable;
+	};
+
+	rts-tx {
+		pins = "gpio46", "gpio47";
+		drive-strength = <2>;
+		bias-disable;
+	};
+
+	rx {
+		pins = "gpio48";
+		bias-pull-up;
+	};
+};
+
+&qup_uart9_default {
+	pinconf-tx {
+		pins = "gpio4";
+		drive-strength = <2>;
+		bias-disable;
+	};
+
+	pinconf-rx {
+		pins = "gpio5";
+		drive-strength = <2>;
+		bias-pull-up;
+	};
+};
+
+&tlmm {
+	gpio-reserved-ranges = <0 4>, <81 4>;
+
+	panel_te_pin: panel-te {
+		mux {
+			pins = "gpio12";
+			function = "mdp_vsync";
+			drive-strength = <2>;
+			bias-disable;
+			input-enable;
+		};
+	};
+
+	panel_reset_pins: panel-active {
+		mux {
+			pins = "gpio6", "gpio52";
+			function = "gpio";
+			drive-strength = <8>;
+			bias-disable = <0>;
+		};
+	};
+
+	panel_suspend: panel-suspend {
+		mux {
+			pins = "gpio6", "gpio52";
+			function = "gpio";
+			drive-strength = <2>;
+			bias-pull-down;

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 527

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+		};
+	};
+
+	touchscreen_reset: ts-reset {
+		mux {
+			pins = "gpio99";
+			function = "gpio";
+			drive-strength = <8>;
+			bias-pull-up;
+			//output-high;

debug, can be removed?

Quoted 102 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +102 -0
+		};
+	};
+
+	touchscreen_pins: ts-pins {
+		mux {
+			pins = "gpio125";
+			function = "gpio";
+			drive-strength = <2>;
+			bias-disable;
+		};
+	};
+
+	touchscreen_i2c_pins: qup-i2c2-gpio {
+		pins = "gpio27", "gpio28";
+		function = "gpio";
+
+		drive-strength = <2>;
+		bias-disable;
+	};
+};
+
+&uart6 {
+	status = "okay";
+
+	bluetooth {
+		compatible = "qcom,wcn3990-bt";
+
+		vddio-supply = <&vreg_s4a_1p8>;
+		vddxo-supply = <&vreg_l7a_1p8>;
+		vddrf-supply = <&vreg_l17a_1p3>;
+		vddch0-supply = <&vreg_l25a_3p3>;
+		max-speed = <3200000>;
+	};
+};
+
+&uart9 {
+	status = "okay";
+};
+
+&usb_1 {
+	status = "okay";
+};
+
+&usb_1_dwc3 {
+	dr_mode = "peripheral";
+};
+
+&usb_1_hsphy {
+	status = "okay";
+
+	vdd-supply = <&vreg_l1a_0p875>;
+	vdda-pll-supply = <&vreg_l12a_1p8>;
+	vdda-phy-dpdm-supply = <&vreg_l24a_3p075>;
+
+	qcom,imp-res-offset-value = <8>;
+	qcom,hstx-trim-value = <QUSB2_V2_HSTX_TRIM_21_6_MA>;
+	qcom,preemphasis-level = <QUSB2_V2_PREEMPHASIS_5_PERCENT>;
+	qcom,preemphasis-width = <QUSB2_V2_PREEMPHASIS_WIDTH_HALF_BIT>;
+};
+
+&usb_1_qmpphy {
+	status = "okay";
+
+	vdda-phy-supply = <&vreg_l26a_1p2>;
+	vdda-pll-supply = <&vreg_l1a_0p875>;
+};
+
+&usb_2 {
+	status = "okay";
+};
+
+&usb_2_dwc3 {
+	dr_mode = "host";
+};
+
+&usb_2_hsphy {
+	status = "okay";
+
+	vdd-supply = <&vreg_l1a_0p875>;
+	vdda-pll-supply = <&vreg_l12a_1p8>;
+	vdda-phy-dpdm-supply = <&vreg_l24a_3p075>;
+
+	qcom,imp-res-offset-value = <8>;
+	qcom,hstx-trim-value = <QUSB2_V2_HSTX_TRIM_22_8_MA>;
+};
+
+&usb_2_qmpphy {
+	status = "okay";
+
+	vdda-phy-supply = <&vreg_l26a_1p2>;
+	vdda-pll-supply = <&vreg_l1a_0p875>;
+};
+
+&ufs_mem_hc {
+	status = "okay";
+
+	reset-gpios = <&tlmm 150 GPIO_ACTIVE_LOW>;
+
+	vcc-supply = <&vreg_l20a_2p95>;
+	vcc-max-microamp = <800000>;
+};
+

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 639

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+&ufs_mem_phy {
+	status = "okay";
+
+	vdda-phy-supply = <&vreg_l1a_0p875>;
+	vdda-pll-supply = <&vreg_l26a_1p2>;
+};
+
+&venus {
+	status = "okay";
+	firmware-name = "qcom/sdm845/oneplus6/venus.mbn";

Why are you using the oneplus6 here?

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 651

Quoted 12 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +12 -0
+};
+
+&wifi {
+	status = "okay";
+
+	vdd-0.8-cx-mx-supply = <&vreg_l5a_0p8>;
+	vdd-1.8-xo-supply = <&vreg_l7a_1p8>;
+	vdd-1.3-rfa-supply = <&vreg_l17a_1p3>;
+	vdd-3.3-ch0-supply = <&vreg_l25a_3p3>;
+
+	qcom,snoc-host-cap-8bit-quirk;
+	qcom,ath10k-calibration-variant = "google_blueline";

Ideally Kalle Valo should bless this string, added him to the Cc list. Could you please submit the board file to the ath10k (see [1] for the description and [2] for an example).

[1] https://wireless.wiki.kernel.org/en/users/drivers/ath10k/boardfiles
[2] https://lore.kernel.org/ath10k/CAA8EJpphUrxr5gtW0=-tZh-DrKXmHkfFxWMvYRpTUGuCesGCbw@mail.gmail.com/T/#u

Quoted 1 line
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +1 -0
+};
Signature · 2 lines
With best wishes
Dmitry
#5 lore raw

Re: [PATCH 2/4] arm64: dts: qcom: add sdm845-google-blueline (Pixel 3)

Quoted 214 lines · Dmitry Baryshkov
Quoted 38 lines · Caleb Connolly

From: Amit Pundir <[email protected]>

This adds an initial dts for the Blueline (Pixel 3). Supported functionality includes display, Debug UART, UFS, USB-C (peripheral), WiFi, Bluetooth and modem.

Bootloader compatible board and msm IDs are needed for the kernel to boot with Pixel3 bootloader, so those are added.

GPIOs 0 through 3 and 81 through 84 are configured to not be accessible from the application CPUs, so we mark them as reserved to allow the Pixel 3 to boot.

The reserved-memory locations where obtained from downstream using kernel logs:
https://gist.github.com/calebccff/090d10bfac3cb9e9bd98dda30b054c96

The rmtfs region is allocated with UIO, making it technically "dynamic". It's address and size can be read from sysfs:

blueline:/ # cat /sys/class/uio/uio0/name rmtfs
at /sys/class/uio/uio0/maps/map0/addr 0x00000000f2701000
blueline:/ # cat /sys/class/uio/uio0/maps/map0/size 0x0000000000200000

Like the OnePlus 6, it needs 1kB reserved on either side of the rmtfs memory to workaround some XPU bug which would otherwise cause erroneous XPU violations when accessing the rmtfs_mem region.

For wifi, the pixel 3 reports a board-id of 0xFF, and downstream only includes a single bdwlan file. The qcom,ath10k-calibration-variant property is set to ensure that the correct calibration data is used.

[AmitP: Cherry-picked and refactored from Bjorn's db845c dts

          ("arm64: dts: qcom: Add Dragonboard 845c") https://lkml.org/lkml/2019/6/6/7]
Quoted 8 lines

[sumits: merged commits to add board and msm ids, gpio range reservation,
ufs device-reset gpio and adaptation to v5.5+ changes]

[vinod: Add display nodes]
[caleb: remove db845c bits, cleanup, add reserved-memory for modem/wifi]

Thanks for your patch, few minor items to improve.

Quoted 70 lines
---
   arch/arm64/boot/dts/qcom/Makefile             |   1 +
   .../boot/dts/qcom/sdm845-google-blueline.dts  | 652 ++++++++++++++++++
   2 files changed, 653 insertions(+)

create mode 100644 arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts

arch/arm64/boot/dts/qcom/Makefile +1 -0
index 2f8aec2cc6db..c151e17e6eb7 100644
@@ -100,6 +100,7 @@ dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-cheza-r1.dtb
   dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-cheza-r2.dtb
   dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-cheza-r3.dtb
   dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-db845c.dtb
+dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-google-blueline.dtb
   dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-mtp.dtb
   dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-oneplus-enchilada.dtb
   dtb-$(CONFIG_ARCH_QCOM)	+= sdm845-oneplus-fajita.dtb
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +46 -0
new file mode 100644
index 000000000000..dec979ad9209
@@ -0,0 +1,652 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+
+#include <dt-bindings/dma/qcom-gpi.h>
+#include <dt-bindings/input/linux-event-codes.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
+
+#include "sdm845.dtsi"
+#include "pm8998.dtsi"
+#include "pmi8998.dtsi"
+
+/delete-node/ &mpss_region;
+/delete-node/ &venus_mem;
+/delete-node/ &cdsp_mem;
+/delete-node/ &mba_region;
+/delete-node/ &slpi_mem;
+/delete-node/ &spss_mem;
+/delete-node/ &rmtfs_mem;
+
+/ {
+	model = "Google Pixel 3";
+	compatible = "google,blueline", "qcom,sdm845";
+	qcom,board-id = <0x00021505 0>;
+	qcom,msm-id = <321 0x20001>;
+
+	aliases {
+		serial0 = &uart9;
+		serial1 = &uart6;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	volume-keys {
+		compatible = "gpio-keys";
+		label = "Volume keys";
+		autorepeat;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&volume_up_gpio>;
+
+		vol-up {
+			label = "Volume Up";

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 56

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+			linux,code = <KEY_VOLUMEUP>;
+			gpios = <&pm8998_gpio 6 GPIO_ACTIVE_LOW>;
+			debounce-interval = <15>;
+		};
+	};
+
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;

These properties are already part of the sdm845.dtsi, so no need to have them here.

Quoted 67 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +67 -0
+
+		mpss_region: memory@8e000000 {
+			reg = <0 0x8e000000 0 0x9800000>;
+			no-map;
+		};
+
+		venus_mem: venus@97800000 {
+			reg = <0 0x97800000 0 0x500000>;
+			no-map;
+		};
+
+		cdsp_mem: cdsp-mem@97D00000 {
+			reg = <0 0x97D00000 0 0x800000>;
+			no-map;
+		};
+
+		mba_region: mba@98500000 {
+			reg = <0 0x98500000 0 0x200000>;
+			no-map;
+		};
+
+		slpi_mem: slpi@98700000 {
+			reg = <0 0x98700000 0 0x1400000>;
+			no-map;
+		};
+
+		spss_mem: spss@99B00000 {
+			reg = <0 0x99B00000 0 0x100000>;
+			no-map;
+		};
+
+		/* rmtfs lower guard */
+		memory@f2700000 {
+			reg = <0 0xf2700000 0 0x1000>;
+			no-map;
+		};
+
+		rmtfs_mem: memory@f2701000 {
+			compatible = "qcom,rmtfs-mem";
+			reg = <0 0xf2701000 0 0x200000>;
+			no-map;
+
+			qcom,client-id = <1>;
+			qcom,vmid = <15>;
+		};
+
+		/* rmtfs upper guard */
+		memory@f2901000 {
+			reg = <0 0xf2901000 0 0x1000>;
+			no-map;
+		};
+	};
+
+	vph_pwr: vph-pwr-regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "vph_pwr";
+		regulator-min-microvolt = <3700000>;
+		regulator-max-microvolt = <3700000>;
+	};
+
+	vreg_s4a_1p8: vreg-s4a-1p8 {
+		compatible = "regulator-fixed";
+		regulator-name = "vreg_s4a_1p8";
+
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		regulator-always-on;

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 133

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+		regulator-boot-on;
+
+		vin-supply = <&vph_pwr>;
+	};
+};
+
+&adsp_pas {
+	status = "okay";
+
+	firmware-name = "qcom/sdm845/pixel3/adsp.mbn";

What about using "qcom/sdm845/blueline/adsp.mbn" instead?

Quoted 1 line

Bjorn, Amit?

I haven't verified it, but I'd assume that the firmware for bits like the remoteprocs are the same between the pixel 3 and 3 XL, hence using a common name (same as the approach taken on the OnePlus 6/6T)

Quoted 45 lines
Quoted 45 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +44 -0
+};
+
+&apps_rsc {
+	pm8998-rpmh-regulators {
+		compatible = "qcom,pm8998-rpmh-regulators";
+		qcom,pmic-id = "a";
+		vdd-s1-supply = <&vph_pwr>;
+		vdd-s2-supply = <&vph_pwr>;
+		vdd-s3-supply = <&vph_pwr>;
+		vdd-s4-supply = <&vph_pwr>;
+		vdd-s5-supply = <&vph_pwr>;
+		vdd-s6-supply = <&vph_pwr>;
+		vdd-s7-supply = <&vph_pwr>;
+		vdd-s8-supply = <&vph_pwr>;
+		vdd-s9-supply = <&vph_pwr>;
+		vdd-s10-supply = <&vph_pwr>;
+		vdd-s11-supply = <&vph_pwr>;
+		vdd-s12-supply = <&vph_pwr>;
+		vdd-s13-supply = <&vph_pwr>;
+		vdd-l1-l27-supply = <&vreg_s7a_1p025>;
+		vdd-l2-l8-l17-supply = <&vreg_s3a_1p35>;
+		vdd-l3-l11-supply = <&vreg_s7a_1p025>;
+		vdd-l4-l5-supply = <&vreg_s7a_1p025>;
+		vdd-l6-supply = <&vph_pwr>;
+		vdd-l7-l12-l14-l15-supply = <&vreg_s5a_2p04>;
+		vdd-l9-supply = <&vreg_bob>;
+		vdd-l10-l23-l25-supply = <&vreg_bob>;
+		vdd-l13-l19-l21-supply = <&vreg_bob>;
+		vdd-l16-l28-supply = <&vreg_bob>;
+		vdd-l18-l22-supply = <&vreg_bob>;
+		vdd-l20-l24-supply = <&vreg_bob>;
+		vdd-l26-supply = <&vreg_s3a_1p35>;
+		vin-lvs-1-2-supply = <&vreg_s4a_1p8>;
+
+		vreg_s3a_1p35: smps3 {
+			regulator-min-microvolt = <1352000>;
+			regulator-max-microvolt = <1352000>;
+		};
+
+		vreg_s5a_2p04: smps5 {
+			regulator-min-microvolt = <1904000>;
+			regulator-max-microvolt = <2040000>;
+		};
+
Quoted 8 lines

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 183

Quoted 6 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +6 -0
+		vreg_s7a_1p025: smps7 {
+			regulator-min-microvolt = <900000>;
+			regulator-max-microvolt = <1028000>;
+		};
+
+		vdda_mipi_dsi0_pll:

Do we need this alias?

No, will drop it.

Quoted 35 lines
Quoted 35 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +34 -0
+		vreg_l1a_0p875: ldo1 {
+			regulator-min-microvolt = <880000>;
+			regulator-max-microvolt = <880000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+			regulator-boot-on;
+		};
+
+		vreg_l5a_0p8: ldo5 {
+			regulator-min-microvolt = <800000>;
+			regulator-max-microvolt = <800000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l12a_1p8: ldo12 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l7a_1p8: ldo7 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l13a_2p95: ldo13 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <2960000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l14a_1p88: ldo14 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <1800000>;
Quoted 8 lines

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 223

Quoted 6 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +6 -0
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+			regulator-boot-on;
+			/*
+			 * We can't properly bring the panel back if it gets turned off
+			 * so keep it's regulators always on for now.
+			 */

Any idea, what is the issue here? Do you have the datasheet for the panel?

As Marijn just mentioned on IRC, the driver right now only calls drm_dsc_pps_payload_pack() but doesn't actually send it. I haven't investigated this myself but I'll look into it.

Unfortunately no datasheet afaik, they tend to be pretty elusive. The things I would do for a phone panel datasheet...

Quoted 42 lines
Quoted 42 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +41 -0
+			regulator-always-on;
+		};
+
+		vreg_l17a_1p3: ldo17 {
+			regulator-min-microvolt = <1304000>;
+			regulator-max-microvolt = <1304000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l19a_3p3: ldo19 {
+			regulator-min-microvolt = <3300000>;
+			regulator-max-microvolt = <3312000>;
+			qcom,init-voltage = <3300000>;
+			qcom,initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+			/*
+			 * The touchscreen needs this to be 3.3v, which is apparently
+			 * quite close to the hardware limit for this LDO (3.312v)
+			 * It must be kept in high power mode to prevent TS brownouts
+			 */
+			regulator-allowed-modes = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l20a_2p95: ldo20 {
+			regulator-min-microvolt = <2960000>;
+			regulator-max-microvolt = <2968000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l21a_2p95: ldo21 {
+			regulator-min-microvolt = <2960000>;
+			regulator-max-microvolt = <2968000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l24a_3p075: ldo24 {
+			regulator-min-microvolt = <3088000>;
+			regulator-max-microvolt = <3088000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vreg_l25a_3p3: ldo25 {
Quoted 8 lines

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 270

Quoted 6 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +6 -0
+			regulator-min-microvolt = <3300000>;
+			regulator-max-microvolt = <3312000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
+		vdda_mipi_dsi0_1p2:

Do we need this alias?

Ack

Quoted 141 lines
Quoted 141 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +140 -0
+		vreg_l26a_1p2: ldo26 {
+			regulator-min-microvolt = <1200000>;
+			regulator-max-microvolt = <1200000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+			regulator-boot-on;
+		};
+
+		vreg_l28a_3p0: ldo28 {
+			regulator-min-microvolt = <2856000>;
+			regulator-max-microvolt = <3008000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+			regulator-boot-on;
+			/*
+			 * We can't properly bring the panel back if it gets turned off
+			 * so keep it's regulators always on for now.
+			 */
+			regulator-always-on;
+		};
+	};
+
+	pmi8998-rpmh-regulators {
+		compatible = "qcom,pmi8998-rpmh-regulators";
+		qcom,pmic-id = "b";
+
+		vdd-bob-supply = <&vph_pwr>;
+
+		vreg_bob: bob {
+			regulator-min-microvolt = <3312000>;
+			regulator-max-microvolt = <3600000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_AUTO>;
+			regulator-allow-bypass;
+		};
+	};
+
+	pm8005-rpmh-regulators {
+		compatible = "qcom,pm8005-rpmh-regulators";
+		qcom,pmic-id = "c";
+
+		vdd-s1-supply = <&vph_pwr>;
+		vdd-s2-supply = <&vph_pwr>;
+		vdd-s3-supply = <&vph_pwr>;
+		vdd-s4-supply = <&vph_pwr>;
+
+		vreg_s3c_0p6: smps3 {
+			regulator-min-microvolt = <600000>;
+			regulator-max-microvolt = <600000>;
+		};
+	};
+};
+
+&cdsp_pas {
+	status = "okay";
+	firmware-name = "qcom/sdm845/pixel3/cdsp.mbn";
+};
+
+&dsi0 {
+	status = "okay";
+	vdda-supply = <&vdda_mipi_dsi0_1p2>;
+
+	ports {
+		port@1 {
+			endpoint {
+				remote-endpoint = <&lg_sw43408_in_0>;
+				data-lanes = <0 1 2 3>;
+			};
+		};
+	};
+
+	panel@0 {
+		compatible = "lg,sw43408";
+		reg = <0>;
+
+		vddi-supply = <&vreg_l14a_1p88>;
+		vpnl-supply = <&vreg_l28a_3p0>;
+
+		reset-gpios = <&tlmm 6 GPIO_ACTIVE_LOW>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&panel_reset_pins &panel_te_pin &panel_pmgpio_pins>;
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				lg_sw43408_in_0: endpoint {
+					remote-endpoint = <&dsi0_out>;
+				};
+			};
+		};
+	};
+};
+
+&dsi0_out {
+	remote-endpoint = <&lg_sw43408_in_0>;
+	data-lanes = <0 1 2 3>;
+};
+
+&dsi0_phy {
+	status = "okay";
+	vdds-supply = <&vdda_mipi_dsi0_pll>;
+};
+
+&gcc {
+	protected-clocks = <GCC_QSPI_CORE_CLK>,
+			   <GCC_QSPI_CORE_CLK_SRC>,
+			   <GCC_QSPI_CNOC_PERIPH_AHB_CLK>;
+};
+
+&gmu {
+	status = "okay";
+};
+
+&gpi_dma0 {
+	status = "okay";
+};
+
+&gpu {
+	status = "okay";
+
+	zap-shader {
+		memory-region = <&gpu_mem>;
+		firmware-name = "qcom/sdm845/pixel3/a630_zap.mbn";
+	};
+};
+
+&ipa {
+	status = "okay";
+
+	firmware-name = "qcom/sdm845/pixel3/ipa_fws.mbn";
+};
+
+&mss_pil {
+	status = "okay";
+	firmware-name = "qcom/sdm845/pixel3/mba.mbn", "qcom/sdm845/pixel3/modem.mbn";
+};
+
+&mdss {
+	status = "okay";
Quoted 8 lines

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 415

Quoted 5 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +5 -0
+};
+
+&mdss_mdp {
+	status = "okay";
+};

Not necessary, it is a default state since the commit 4a5622c1d975 ("arm64: dts: qcom: sdm845: Don't disable MDP explicitly")

thanks, will drop

Quoted 23 lines
Quoted 23 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +22 -0
+
+&pm8998_gpio {
+	volume_up_gpio: vol-up-active {
+		pins = "gpio6";
+		function = "normal";
+		input-enable;
+		bias-pull-up;
+		qcom,drive-strength = <0>;
+	};
+
+	panel_pmgpio_pins: panel-pmgpio-active {
+		pins = "gpio2", "gpio5";
+		function = "normal";
+		input-enable;
+		bias-disable;
+		power-source = <0>;
+	};
+};
+
+&pm8998_pon {
+	resin {
+		compatible = "qcom,pm8941-resin";
Quoted 8 lines

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 442

Quoted 5 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +5 -0
+		interrupts = <0x0 0x8 1 IRQ_TYPE_EDGE_BOTH>;
+		debounce = <15625>;
+		bias-pull-up;
+		linux,code = <KEY_VOLUMEDOWN>;
+	};

Please move the (disabled, labelled) resin device to pm8998.dtsi and just add status = "okay" here.

OK, will do.

Quoted 195 lines
Quoted 76 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +75 -0
+};
+
+&qupv3_id_0 {
+	status = "okay";
+};
+
+&qupv3_id_1 {
+	status = "okay";
+};
+
+&qup_uart6_default {
+	pinmux {
+		pins = "gpio45", "gpio46", "gpio47", "gpio48";
+		function = "qup6";
+	};
+
+	cts {
+		pins = "gpio45";
+		bias-disable;
+	};
+
+	rts-tx {
+		pins = "gpio46", "gpio47";
+		drive-strength = <2>;
+		bias-disable;
+	};
+
+	rx {
+		pins = "gpio48";
+		bias-pull-up;
+	};
+};
+
+&qup_uart9_default {
+	pinconf-tx {
+		pins = "gpio4";
+		drive-strength = <2>;
+		bias-disable;
+	};
+
+	pinconf-rx {
+		pins = "gpio5";
+		drive-strength = <2>;
+		bias-pull-up;
+	};
+};
+
+&tlmm {
+	gpio-reserved-ranges = <0 4>, <81 4>;
+
+	panel_te_pin: panel-te {
+		mux {
+			pins = "gpio12";
+			function = "mdp_vsync";
+			drive-strength = <2>;
+			bias-disable;
+			input-enable;
+		};
+	};
+
+	panel_reset_pins: panel-active {
+		mux {
+			pins = "gpio6", "gpio52";
+			function = "gpio";
+			drive-strength = <8>;
+			bias-disable = <0>;
+		};
+	};
+
+	panel_suspend: panel-suspend {
+		mux {
+			pins = "gpio6", "gpio52";
+			function = "gpio";
+			drive-strength = <2>;
+			bias-pull-down;

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 527

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+		};
+	};
+
+	touchscreen_reset: ts-reset {
+		mux {
+			pins = "gpio99";
+			function = "gpio";
+			drive-strength = <8>;
+			bias-pull-up;
+			//output-high;

debug, can be removed?

Quoted 106 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +106 -0
+		};
+	};
+
+	touchscreen_pins: ts-pins {
+		mux {
+			pins = "gpio125";
+			function = "gpio";
+			drive-strength = <2>;
+			bias-disable;
+		};
+	};
+
+	touchscreen_i2c_pins: qup-i2c2-gpio {
+		pins = "gpio27", "gpio28";
+		function = "gpio";
+
+		drive-strength = <2>;
+		bias-disable;
+	};
+};
+
+&uart6 {
+	status = "okay";
+
+	bluetooth {
+		compatible = "qcom,wcn3990-bt";
+
+		vddio-supply = <&vreg_s4a_1p8>;
+		vddxo-supply = <&vreg_l7a_1p8>;
+		vddrf-supply = <&vreg_l17a_1p3>;
+		vddch0-supply = <&vreg_l25a_3p3>;
+		max-speed = <3200000>;
+	};
+};
+
+&uart9 {
+	status = "okay";
+};
+
+&usb_1 {
+	status = "okay";
+};
+
+&usb_1_dwc3 {
+	dr_mode = "peripheral";
+};
+
+&usb_1_hsphy {
+	status = "okay";
+
+	vdd-supply = <&vreg_l1a_0p875>;
+	vdda-pll-supply = <&vreg_l12a_1p8>;
+	vdda-phy-dpdm-supply = <&vreg_l24a_3p075>;
+
+	qcom,imp-res-offset-value = <8>;
+	qcom,hstx-trim-value = <QUSB2_V2_HSTX_TRIM_21_6_MA>;
+	qcom,preemphasis-level = <QUSB2_V2_PREEMPHASIS_5_PERCENT>;
+	qcom,preemphasis-width = <QUSB2_V2_PREEMPHASIS_WIDTH_HALF_BIT>;
+};
+
+&usb_1_qmpphy {
+	status = "okay";
+
+	vdda-phy-supply = <&vreg_l26a_1p2>;
+	vdda-pll-supply = <&vreg_l1a_0p875>;
+};
+
+&usb_2 {
+	status = "okay";
+};
+
+&usb_2_dwc3 {
+	dr_mode = "host";
+};
+
+&usb_2_hsphy {
+	status = "okay";
+
+	vdd-supply = <&vreg_l1a_0p875>;
+	vdda-pll-supply = <&vreg_l12a_1p8>;
+	vdda-phy-dpdm-supply = <&vreg_l24a_3p075>;
+
+	qcom,imp-res-offset-value = <8>;
+	qcom,hstx-trim-value = <QUSB2_V2_HSTX_TRIM_22_8_MA>;
+};
+
+&usb_2_qmpphy {
+	status = "okay";
+
+	vdda-phy-supply = <&vreg_l26a_1p2>;
+	vdda-pll-supply = <&vreg_l1a_0p875>;
+};
+
+&ufs_mem_hc {
+	status = "okay";
+
+	reset-gpios = <&tlmm 150 GPIO_ACTIVE_LOW>;
+
+	vcc-supply = <&vreg_l20a_2p95>;
+	vcc-max-microamp = <800000>;
+};
+
+&ufs_mem_phy {
+	status = "okay";
+
+	vdda-phy-supply = <&vreg_l1a_0p875>;
Quoted 8 lines

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 639

Quoted 6 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +6 -0
+	vdda-pll-supply = <&vreg_l26a_1p2>;
+};
+
+&venus {
+	status = "okay";
+	firmware-name = "qcom/sdm845/oneplus6/venus.mbn";

Why are you using the oneplus6 here?

Oops! Will fix that.

Quoted 17 lines

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 651

Quoted 13 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +12 -0
+};
+
+&wifi {
+	status = "okay";
+
+	vdd-0.8-cx-mx-supply = <&vreg_l5a_0p8>;
+	vdd-1.8-xo-supply = <&vreg_l7a_1p8>;
+	vdd-1.3-rfa-supply = <&vreg_l17a_1p3>;
+	vdd-3.3-ch0-supply = <&vreg_l25a_3p3>;
+
+	qcom,snoc-host-cap-8bit-quirk;
+	qcom,ath10k-calibration-variant = "google_blueline";

Ideally Kalle Valo should bless this string, added him to the Cc list. Could you please submit the board file to the ath10k (see [1] for the description and [2] for an example).

Sure will do.

Quoted 8 lines

[1] https://wireless.wiki.kernel.org/en/users/drivers/ath10k/boardfiles
[2]
https://lore.kernel.org/ath10k/CAA8EJpphUrxr5gtW0=-tZh-DrKXmHkfFxWMvYRpTUGuCesGCbw@mail.gmail.com/T/#u

Quoted 1 line
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +1 -0
+};

Thanks a lot for the review!

Kind Regards,
Caleb

Quoted 4 lines

--
With best wishes
Dmitry

#6 lore raw

Re: [PATCH 2/4] arm64: dts: qcom: add sdm845-google-blueline (Pixel 3)

Quoted 10 lines · Caleb Connolly
Quoted 1 line · Dmitry Baryshkov

Any idea, what is the issue here? Do you have the datasheet for the panel?

As Marijn just mentioned on IRC, the driver right now only calls drm_dsc_pps_payload_pack() but doesn't actually send it. I haven't investigated this myself but I'll look into it.

Unfortunately no datasheet afaik, they tend to be pretty elusive. The things I would do for a phone panel datasheet...

as a side note: I checked the dtbo.img. There are three different versions of the panel programming sequences in the included dtb files. So you might want to check for the difference with linux-mdss-dsi-panel-driver-generator.

Signature · 2 lines
With best wishes
Dmitry
#7 lore raw

Re: [PATCH 2/4] arm64: dts: qcom: add sdm845-google-blueline (Pixel 3)

In reply to Dmitry Baryshkov

+ ath10k list

Quoted 50 lines · Dmitry Baryshkov
Quoted 38 lines · Caleb Connolly

From: Amit Pundir <[email protected]>

This adds an initial dts for the Blueline (Pixel 3). Supported functionality includes display, Debug UART, UFS, USB-C (peripheral), WiFi, Bluetooth and modem.

Bootloader compatible board and msm IDs are needed for the kernel to boot with Pixel3 bootloader, so those are added.

GPIOs 0 through 3 and 81 through 84 are configured to not be accessible from the application CPUs, so we mark them as reserved to allow the Pixel 3 to boot.

The reserved-memory locations where obtained from downstream using kernel logs:
https://gist.github.com/calebccff/090d10bfac3cb9e9bd98dda30b054c96

The rmtfs region is allocated with UIO, making it technically "dynamic". It's address and size can be read from sysfs:

blueline:/ # cat /sys/class/uio/uio0/name rmtfs
at /sys/class/uio/uio0/maps/map0/addr 0x00000000f2701000
blueline:/ # cat /sys/class/uio/uio0/maps/map0/size 0x0000000000200000

Like the OnePlus 6, it needs 1kB reserved on either side of the rmtfs memory to workaround some XPU bug which would otherwise cause erroneous XPU violations when accessing the rmtfs_mem region.

For wifi, the pixel 3 reports a board-id of 0xFF, and downstream only includes a single bdwlan file. The qcom,ath10k-calibration-variant property is set to ensure that the correct calibration data is used.

[AmitP: Cherry-picked and refactored from Bjorn's db845c dts

         ("arm64: dts: qcom: Add Dragonboard 845c") https://lkml.org/lkml/2019/6/6/7]
Quoted 8 lines

[sumits: merged commits to add board and msm ids, gpio range reservation,
ufs device-reset gpio and adaptation to v5.5+ changes]

[vinod: Add display nodes]
[caleb: remove db845c bits, cleanup, add reserved-memory for modem/wifi]

Thanks for your patch, few minor items to improve.

[...]

Quoted 6 lines
Quoted 6 lines

+&wifi {

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +5 -0
+	status = "okay";
+
+	vdd-0.8-cx-mx-supply = <&vreg_l5a_0p8>;
+	vdd-1.8-xo-supply = <&vreg_l7a_1p8>;
+	vdd-1.3-rfa-supply = <&vreg_l17a_1p3>;
Quoted 8 lines

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 651

Quoted 4 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +4 -0
+	vdd-3.3-ch0-supply = <&vreg_l25a_3p3>;
+
+	qcom,snoc-host-cap-8bit-quirk;
+	qcom,ath10k-calibration-variant = "google_blueline";

Ideally Kalle Valo should bless this string, added him to the Cc list. Could you please submit the board file to the ath10k (see [1] for the description and [2] for an example).

Thanks for CC. I prefer "google-blueline" but that's really a cosmetic issue.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#8 lore raw

Re: [PATCH 2/4] arm64: dts: qcom: add sdm845-google-blueline (Pixel 3)

In reply to Dmitry Baryshkov

n Tue, 19 Jul 2022 at 03:43, Dmitry Baryshkov

Quoted 215 lines · <[email protected]> wrote:
Quoted 38 lines · Caleb Connolly

From: Amit Pundir <[email protected]>

This adds an initial dts for the Blueline (Pixel 3). Supported functionality includes display, Debug UART, UFS, USB-C (peripheral), WiFi, Bluetooth and modem.

Bootloader compatible board and msm IDs are needed for the kernel to boot with Pixel3 bootloader, so those are added.

GPIOs 0 through 3 and 81 through 84 are configured to not be accessible from the application CPUs, so we mark them as reserved to allow the Pixel 3 to boot.

The reserved-memory locations where obtained from downstream using kernel logs:
https://gist.github.com/calebccff/090d10bfac3cb9e9bd98dda30b054c96

The rmtfs region is allocated with UIO, making it technically "dynamic". It's address and size can be read from sysfs:

blueline:/ # cat /sys/class/uio/uio0/name rmtfs
at /sys/class/uio/uio0/maps/map0/addr 0x00000000f2701000
blueline:/ # cat /sys/class/uio/uio0/maps/map0/size 0x0000000000200000

Like the OnePlus 6, it needs 1kB reserved on either side of the rmtfs memory to workaround some XPU bug which would otherwise cause erroneous XPU violations when accessing the rmtfs_mem region.

For wifi, the pixel 3 reports a board-id of 0xFF, and downstream only includes a single bdwlan file. The qcom,ath10k-calibration-variant property is set to ensure that the correct calibration data is used.

[AmitP: Cherry-picked and refactored from Bjorn's db845c dts

         ("arm64: dts: qcom: Add Dragonboard 845c") https://lkml.org/lkml/2019/6/6/7]
Quoted 8 lines

[sumits: merged commits to add board and msm ids, gpio range reservation,
ufs device-reset gpio and adaptation to v5.5+ changes]

[vinod: Add display nodes]
[caleb: remove db845c bits, cleanup, add reserved-memory for modem/wifi]

Thanks for your patch, few minor items to improve.

Quoted 70 lines
---
  arch/arm64/boot/dts/qcom/Makefile             |   1 +
  .../boot/dts/qcom/sdm845-google-blueline.dts  | 652 ++++++++++++++++++
  2 files changed, 653 insertions(+)

create mode 100644 arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts

arch/arm64/boot/dts/qcom/Makefile +1 -0
index 2f8aec2cc6db..c151e17e6eb7 100644
@@ -100,6 +100,7 @@ dtb-$(CONFIG_ARCH_QCOM)   += sdm845-cheza-r1.dtb
  dtb-$(CONFIG_ARCH_QCOM)     += sdm845-cheza-r2.dtb
  dtb-$(CONFIG_ARCH_QCOM)     += sdm845-cheza-r3.dtb
  dtb-$(CONFIG_ARCH_QCOM)     += sdm845-db845c.dtb
+dtb-$(CONFIG_ARCH_QCOM)      += sdm845-google-blueline.dtb
  dtb-$(CONFIG_ARCH_QCOM)     += sdm845-mtp.dtb
  dtb-$(CONFIG_ARCH_QCOM)     += sdm845-oneplus-enchilada.dtb
  dtb-$(CONFIG_ARCH_QCOM)     += sdm845-oneplus-fajita.dtb
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +46 -0
new file mode 100644
index 000000000000..dec979ad9209
@@ -0,0 +1,652 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+
+#include <dt-bindings/dma/qcom-gpi.h>
+#include <dt-bindings/input/linux-event-codes.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
+
+#include "sdm845.dtsi"
+#include "pm8998.dtsi"
+#include "pmi8998.dtsi"
+
+/delete-node/ &mpss_region;
+/delete-node/ &venus_mem;
+/delete-node/ &cdsp_mem;
+/delete-node/ &mba_region;
+/delete-node/ &slpi_mem;
+/delete-node/ &spss_mem;
+/delete-node/ &rmtfs_mem;
+
+/ {
+     model = "Google Pixel 3";
+     compatible = "google,blueline", "qcom,sdm845";
+     qcom,board-id = <0x00021505 0>;
+     qcom,msm-id = <321 0x20001>;
+
+     aliases {
+             serial0 = &uart9;
+             serial1 = &uart6;
+     };
+
+     chosen {
+             stdout-path = "serial0:115200n8";
+     };
+
+     volume-keys {
+             compatible = "gpio-keys";
+             label = "Volume keys";
+             autorepeat;
+
+             pinctrl-names = "default";
+             pinctrl-0 = <&volume_up_gpio>;
+
+             vol-up {
+                     label = "Volume Up";

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 56

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+                     linux,code = <KEY_VOLUMEUP>;
+                     gpios = <&pm8998_gpio 6 GPIO_ACTIVE_LOW>;
+                     debounce-interval = <15>;
+             };
+     };
+
+     reserved-memory {
+             #address-cells = <2>;
+             #size-cells = <2>;
+             ranges;

These properties are already part of the sdm845.dtsi, so no need to have them here.

Quoted 67 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +67 -0
+
+             mpss_region: memory@8e000000 {
+                     reg = <0 0x8e000000 0 0x9800000>;
+                     no-map;
+             };
+
+             venus_mem: venus@97800000 {
+                     reg = <0 0x97800000 0 0x500000>;
+                     no-map;
+             };
+
+             cdsp_mem: cdsp-mem@97D00000 {
+                     reg = <0 0x97D00000 0 0x800000>;
+                     no-map;
+             };
+
+             mba_region: mba@98500000 {
+                     reg = <0 0x98500000 0 0x200000>;
+                     no-map;
+             };
+
+             slpi_mem: slpi@98700000 {
+                     reg = <0 0x98700000 0 0x1400000>;
+                     no-map;
+             };
+
+             spss_mem: spss@99B00000 {
+                     reg = <0 0x99B00000 0 0x100000>;
+                     no-map;
+             };
+
+             /* rmtfs lower guard */
+             memory@f2700000 {
+                     reg = <0 0xf2700000 0 0x1000>;
+                     no-map;
+             };
+
+             rmtfs_mem: memory@f2701000 {
+                     compatible = "qcom,rmtfs-mem";
+                     reg = <0 0xf2701000 0 0x200000>;
+                     no-map;
+
+                     qcom,client-id = <1>;
+                     qcom,vmid = <15>;
+             };
+
+             /* rmtfs upper guard */
+             memory@f2901000 {
+                     reg = <0 0xf2901000 0 0x1000>;
+                     no-map;
+             };
+     };
+
+     vph_pwr: vph-pwr-regulator {
+             compatible = "regulator-fixed";
+             regulator-name = "vph_pwr";
+             regulator-min-microvolt = <3700000>;
+             regulator-max-microvolt = <3700000>;
+     };
+
+     vreg_s4a_1p8: vreg-s4a-1p8 {
+             compatible = "regulator-fixed";
+             regulator-name = "vreg_s4a_1p8";
+
+             regulator-min-microvolt = <1800000>;
+             regulator-max-microvolt = <1800000>;
+             regulator-always-on;

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 133

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+             regulator-boot-on;
+
+             vin-supply = <&vph_pwr>;
+     };
+};
+
+&adsp_pas {
+     status = "okay";
+
+     firmware-name = "qcom/sdm845/pixel3/adsp.mbn";

What about using "qcom/sdm845/blueline/adsp.mbn" instead?

Quoted 1 line

Bjorn, Amit?

qcom/sdm845/blueline/adsp.mbn seems more apt.

Quoted 558 lines
Quoted 41 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +40 -0
+};
+
+&apps_rsc {
+     pm8998-rpmh-regulators {
+             compatible = "qcom,pm8998-rpmh-regulators";
+             qcom,pmic-id = "a";
+             vdd-s1-supply = <&vph_pwr>;
+             vdd-s2-supply = <&vph_pwr>;
+             vdd-s3-supply = <&vph_pwr>;
+             vdd-s4-supply = <&vph_pwr>;
+             vdd-s5-supply = <&vph_pwr>;
+             vdd-s6-supply = <&vph_pwr>;
+             vdd-s7-supply = <&vph_pwr>;
+             vdd-s8-supply = <&vph_pwr>;
+             vdd-s9-supply = <&vph_pwr>;
+             vdd-s10-supply = <&vph_pwr>;
+             vdd-s11-supply = <&vph_pwr>;
+             vdd-s12-supply = <&vph_pwr>;
+             vdd-s13-supply = <&vph_pwr>;
+             vdd-l1-l27-supply = <&vreg_s7a_1p025>;
+             vdd-l2-l8-l17-supply = <&vreg_s3a_1p35>;
+             vdd-l3-l11-supply = <&vreg_s7a_1p025>;
+             vdd-l4-l5-supply = <&vreg_s7a_1p025>;
+             vdd-l6-supply = <&vph_pwr>;
+             vdd-l7-l12-l14-l15-supply = <&vreg_s5a_2p04>;
+             vdd-l9-supply = <&vreg_bob>;
+             vdd-l10-l23-l25-supply = <&vreg_bob>;
+             vdd-l13-l19-l21-supply = <&vreg_bob>;
+             vdd-l16-l28-supply = <&vreg_bob>;
+             vdd-l18-l22-supply = <&vreg_bob>;
+             vdd-l20-l24-supply = <&vreg_bob>;
+             vdd-l26-supply = <&vreg_s3a_1p35>;
+             vin-lvs-1-2-supply = <&vreg_s4a_1p8>;
+
+             vreg_s3a_1p35: smps3 {
+                     regulator-min-microvolt = <1352000>;
+                     regulator-max-microvolt = <1352000>;
+             };
+
+             vreg_s5a_2p04: smps5 {

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 183

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+                     regulator-min-microvolt = <1904000>;
+                     regulator-max-microvolt = <2040000>;
+             };
+
+             vreg_s7a_1p025: smps7 {
+                     regulator-min-microvolt = <900000>;
+                     regulator-max-microvolt = <1028000>;
+             };
+
+             vdda_mipi_dsi0_pll:

Do we need this alias?

Quoted 30 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +30 -0
+             vreg_l1a_0p875: ldo1 {
+                     regulator-min-microvolt = <880000>;
+                     regulator-max-microvolt = <880000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+                     regulator-boot-on;
+             };
+
+             vreg_l5a_0p8: ldo5 {
+                     regulator-min-microvolt = <800000>;
+                     regulator-max-microvolt = <800000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+             };
+
+             vreg_l12a_1p8: ldo12 {
+                     regulator-min-microvolt = <1800000>;
+                     regulator-max-microvolt = <1800000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+             };
+
+             vreg_l7a_1p8: ldo7 {
+                     regulator-min-microvolt = <1800000>;
+                     regulator-max-microvolt = <1800000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+             };
+
+             vreg_l13a_2p95: ldo13 {
+                     regulator-min-microvolt = <1800000>;
+                     regulator-max-microvolt = <2960000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+             };

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 223

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+
+             vreg_l14a_1p88: ldo14 {
+                     regulator-min-microvolt = <1800000>;
+                     regulator-max-microvolt = <1800000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+                     regulator-boot-on;
+                     /*
+                      * We can't properly bring the panel back if it gets turned off
+                      * so keep it's regulators always on for now.
+                      */

Any idea, what is the issue here? Do you have the datasheet for the panel?

Quoted 37 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +37 -0
+                     regulator-always-on;
+             };
+
+             vreg_l17a_1p3: ldo17 {
+                     regulator-min-microvolt = <1304000>;
+                     regulator-max-microvolt = <1304000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+             };
+
+             vreg_l19a_3p3: ldo19 {
+                     regulator-min-microvolt = <3300000>;
+                     regulator-max-microvolt = <3312000>;
+                     qcom,init-voltage = <3300000>;
+                     qcom,initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+                     /*
+                      * The touchscreen needs this to be 3.3v, which is apparently
+                      * quite close to the hardware limit for this LDO (3.312v)
+                      * It must be kept in high power mode to prevent TS brownouts
+                      */
+                     regulator-allowed-modes = <RPMH_REGULATOR_MODE_HPM>;
+             };
+
+             vreg_l20a_2p95: ldo20 {
+                     regulator-min-microvolt = <2960000>;
+                     regulator-max-microvolt = <2968000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+             };
+
+             vreg_l21a_2p95: ldo21 {
+                     regulator-min-microvolt = <2960000>;
+                     regulator-max-microvolt = <2968000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+             };
+
+             vreg_l24a_3p075: ldo24 {
+                     regulator-min-microvolt = <3088000>;
+                     regulator-max-microvolt = <3088000>;

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 270

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+             };
+
+             vreg_l25a_3p3: ldo25 {
+                     regulator-min-microvolt = <3300000>;
+                     regulator-max-microvolt = <3312000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+             };
+
+             vdda_mipi_dsi0_1p2:

Do we need this alias?

Quoted 135 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +135 -0
+             vreg_l26a_1p2: ldo26 {
+                     regulator-min-microvolt = <1200000>;
+                     regulator-max-microvolt = <1200000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+                     regulator-boot-on;
+             };
+
+             vreg_l28a_3p0: ldo28 {
+                     regulator-min-microvolt = <2856000>;
+                     regulator-max-microvolt = <3008000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+                     regulator-boot-on;
+                     /*
+                      * We can't properly bring the panel back if it gets turned off
+                      * so keep it's regulators always on for now.
+                      */
+                     regulator-always-on;
+             };
+     };
+
+     pmi8998-rpmh-regulators {
+             compatible = "qcom,pmi8998-rpmh-regulators";
+             qcom,pmic-id = "b";
+
+             vdd-bob-supply = <&vph_pwr>;
+
+             vreg_bob: bob {
+                     regulator-min-microvolt = <3312000>;
+                     regulator-max-microvolt = <3600000>;
+                     regulator-initial-mode = <RPMH_REGULATOR_MODE_AUTO>;
+                     regulator-allow-bypass;
+             };
+     };
+
+     pm8005-rpmh-regulators {
+             compatible = "qcom,pm8005-rpmh-regulators";
+             qcom,pmic-id = "c";
+
+             vdd-s1-supply = <&vph_pwr>;
+             vdd-s2-supply = <&vph_pwr>;
+             vdd-s3-supply = <&vph_pwr>;
+             vdd-s4-supply = <&vph_pwr>;
+
+             vreg_s3c_0p6: smps3 {
+                     regulator-min-microvolt = <600000>;
+                     regulator-max-microvolt = <600000>;
+             };
+     };
+};
+
+&cdsp_pas {
+     status = "okay";
+     firmware-name = "qcom/sdm845/pixel3/cdsp.mbn";
+};
+
+&dsi0 {
+     status = "okay";
+     vdda-supply = <&vdda_mipi_dsi0_1p2>;
+
+     ports {
+             port@1 {
+                     endpoint {
+                             remote-endpoint = <&lg_sw43408_in_0>;
+                             data-lanes = <0 1 2 3>;
+                     };
+             };
+     };
+
+     panel@0 {
+             compatible = "lg,sw43408";
+             reg = <0>;
+
+             vddi-supply = <&vreg_l14a_1p88>;
+             vpnl-supply = <&vreg_l28a_3p0>;
+
+             reset-gpios = <&tlmm 6 GPIO_ACTIVE_LOW>;
+
+             pinctrl-names = "default";
+             pinctrl-0 = <&panel_reset_pins &panel_te_pin &panel_pmgpio_pins>;
+
+             ports {
+                     #address-cells = <1>;
+                     #size-cells = <0>;
+
+                     port@0 {
+                             reg = <0>;
+                             lg_sw43408_in_0: endpoint {
+                                     remote-endpoint = <&dsi0_out>;
+                             };
+                     };
+             };
+     };
+};
+
+&dsi0_out {
+     remote-endpoint = <&lg_sw43408_in_0>;
+     data-lanes = <0 1 2 3>;
+};
+
+&dsi0_phy {
+     status = "okay";
+     vdds-supply = <&vdda_mipi_dsi0_pll>;
+};
+
+&gcc {
+     protected-clocks = <GCC_QSPI_CORE_CLK>,
+                        <GCC_QSPI_CORE_CLK_SRC>,
+                        <GCC_QSPI_CNOC_PERIPH_AHB_CLK>;
+};
+
+&gmu {
+     status = "okay";
+};
+
+&gpi_dma0 {
+     status = "okay";
+};
+
+&gpu {
+     status = "okay";
+
+     zap-shader {
+             memory-region = <&gpu_mem>;
+             firmware-name = "qcom/sdm845/pixel3/a630_zap.mbn";
+     };
+};
+
+&ipa {
+     status = "okay";
+
+     firmware-name = "qcom/sdm845/pixel3/ipa_fws.mbn";
+};
+
+&mss_pil {
+     status = "okay";

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 415

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+     firmware-name = "qcom/sdm845/pixel3/mba.mbn", "qcom/sdm845/pixel3/modem.mbn";
+};
+
+&mdss {
+     status = "okay";
+};
+
+&mdss_mdp {
+     status = "okay";
+};

Not necessary, it is a default state since the commit 4a5622c1d975 ("arm64: dts: qcom: sdm845: Don't disable MDP explicitly")

Quoted 17 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +17 -0
+
+&pm8998_gpio {
+     volume_up_gpio: vol-up-active {
+             pins = "gpio6";
+             function = "normal";
+             input-enable;
+             bias-pull-up;
+             qcom,drive-strength = <0>;
+     };
+
+     panel_pmgpio_pins: panel-pmgpio-active {
+             pins = "gpio2", "gpio5";
+             function = "normal";
+             input-enable;
+             bias-disable;
+             power-source = <0>;
+     };

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 442

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+};
+
+&pm8998_pon {
+     resin {
+             compatible = "qcom,pm8941-resin";
+             interrupts = <0x0 0x8 1 IRQ_TYPE_EDGE_BOTH>;
+             debounce = <15625>;
+             bias-pull-up;
+             linux,code = <KEY_VOLUMEDOWN>;
+     };

Please move the (disabled, labelled) resin device to pm8998.dtsi and just add status = "okay" here.

Quoted 75 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +75 -0
+};
+
+&qupv3_id_0 {
+     status = "okay";
+};
+
+&qupv3_id_1 {
+     status = "okay";
+};
+
+&qup_uart6_default {
+     pinmux {
+             pins = "gpio45", "gpio46", "gpio47", "gpio48";
+             function = "qup6";
+     };
+
+     cts {
+             pins = "gpio45";
+             bias-disable;
+     };
+
+     rts-tx {
+             pins = "gpio46", "gpio47";
+             drive-strength = <2>;
+             bias-disable;
+     };
+
+     rx {
+             pins = "gpio48";
+             bias-pull-up;
+     };
+};
+
+&qup_uart9_default {
+     pinconf-tx {
+             pins = "gpio4";
+             drive-strength = <2>;
+             bias-disable;
+     };
+
+     pinconf-rx {
+             pins = "gpio5";
+             drive-strength = <2>;
+             bias-pull-up;
+     };
+};
+
+&tlmm {
+     gpio-reserved-ranges = <0 4>, <81 4>;
+
+     panel_te_pin: panel-te {
+             mux {
+                     pins = "gpio12";
+                     function = "mdp_vsync";
+                     drive-strength = <2>;
+                     bias-disable;
+                     input-enable;
+             };
+     };
+
+     panel_reset_pins: panel-active {
+             mux {
+                     pins = "gpio6", "gpio52";
+                     function = "gpio";
+                     drive-strength = <8>;
+                     bias-disable = <0>;
+             };
+     };
+
+     panel_suspend: panel-suspend {
+             mux {
+                     pins = "gpio6", "gpio52";
+                     function = "gpio";
+                     drive-strength = <2>;
+                     bias-pull-down;

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 527

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+             };
+     };
+
+     touchscreen_reset: ts-reset {
+             mux {
+                     pins = "gpio99";
+                     function = "gpio";
+                     drive-strength = <8>;
+                     bias-pull-up;
+                     //output-high;

debug, can be removed?

Quoted 102 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +102 -0
+             };
+     };
+
+     touchscreen_pins: ts-pins {
+             mux {
+                     pins = "gpio125";
+                     function = "gpio";
+                     drive-strength = <2>;
+                     bias-disable;
+             };
+     };
+
+     touchscreen_i2c_pins: qup-i2c2-gpio {
+             pins = "gpio27", "gpio28";
+             function = "gpio";
+
+             drive-strength = <2>;
+             bias-disable;
+     };
+};
+
+&uart6 {
+     status = "okay";
+
+     bluetooth {
+             compatible = "qcom,wcn3990-bt";
+
+             vddio-supply = <&vreg_s4a_1p8>;
+             vddxo-supply = <&vreg_l7a_1p8>;
+             vddrf-supply = <&vreg_l17a_1p3>;
+             vddch0-supply = <&vreg_l25a_3p3>;
+             max-speed = <3200000>;
+     };
+};
+
+&uart9 {
+     status = "okay";
+};
+
+&usb_1 {
+     status = "okay";
+};
+
+&usb_1_dwc3 {
+     dr_mode = "peripheral";
+};
+
+&usb_1_hsphy {
+     status = "okay";
+
+     vdd-supply = <&vreg_l1a_0p875>;
+     vdda-pll-supply = <&vreg_l12a_1p8>;
+     vdda-phy-dpdm-supply = <&vreg_l24a_3p075>;
+
+     qcom,imp-res-offset-value = <8>;
+     qcom,hstx-trim-value = <QUSB2_V2_HSTX_TRIM_21_6_MA>;
+     qcom,preemphasis-level = <QUSB2_V2_PREEMPHASIS_5_PERCENT>;
+     qcom,preemphasis-width = <QUSB2_V2_PREEMPHASIS_WIDTH_HALF_BIT>;
+};
+
+&usb_1_qmpphy {
+     status = "okay";
+
+     vdda-phy-supply = <&vreg_l26a_1p2>;
+     vdda-pll-supply = <&vreg_l1a_0p875>;
+};
+
+&usb_2 {
+     status = "okay";
+};
+
+&usb_2_dwc3 {
+     dr_mode = "host";
+};
+
+&usb_2_hsphy {
+     status = "okay";
+
+     vdd-supply = <&vreg_l1a_0p875>;
+     vdda-pll-supply = <&vreg_l12a_1p8>;
+     vdda-phy-dpdm-supply = <&vreg_l24a_3p075>;
+
+     qcom,imp-res-offset-value = <8>;
+     qcom,hstx-trim-value = <QUSB2_V2_HSTX_TRIM_22_8_MA>;
+};
+
+&usb_2_qmpphy {
+     status = "okay";
+
+     vdda-phy-supply = <&vreg_l26a_1p2>;
+     vdda-pll-supply = <&vreg_l1a_0p875>;
+};
+
+&ufs_mem_hc {
+     status = "okay";
+
+     reset-gpios = <&tlmm 150 GPIO_ACTIVE_LOW>;
+
+     vcc-supply = <&vreg_l20a_2p95>;
+     vcc-max-microamp = <800000>;
+};
+

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 639

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+&ufs_mem_phy {
+     status = "okay";
+
+     vdda-phy-supply = <&vreg_l1a_0p875>;
+     vdda-pll-supply = <&vreg_l26a_1p2>;
+};
+
+&venus {
+     status = "okay";
+     firmware-name = "qcom/sdm845/oneplus6/venus.mbn";

Why are you using the oneplus6 here?

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 651

Quoted 12 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +12 -0
+};
+
+&wifi {
+     status = "okay";
+
+     vdd-0.8-cx-mx-supply = <&vreg_l5a_0p8>;
+     vdd-1.8-xo-supply = <&vreg_l7a_1p8>;
+     vdd-1.3-rfa-supply = <&vreg_l17a_1p3>;
+     vdd-3.3-ch0-supply = <&vreg_l25a_3p3>;
+
+     qcom,snoc-host-cap-8bit-quirk;
+     qcom,ath10k-calibration-variant = "google_blueline";

Ideally Kalle Valo should bless this string, added him to the Cc list. Could you please submit the board file to the ath10k (see [1] for the description and [2] for an example).

[1] https://wireless.wiki.kernel.org/en/users/drivers/ath10k/boardfiles
[2]
https://lore.kernel.org/ath10k/CAA8EJpphUrxr5gtW0=-tZh-DrKXmHkfFxWMvYRpTUGuCesGCbw@mail.gmail.com/T/#u

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 652

Quoted 1 line
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +1 -0
+};

--
With best wishes
Dmitry

#9 lore raw

Re: [PATCH 2/4] arm64: dts: qcom: add sdm845-google-blueline (Pixel 3)

In reply to Caleb Connolly
Quoted 6 lines · Caleb Connolly

From: Amit Pundir <[email protected]>

This adds an initial dts for the Blueline (Pixel 3). Supported functionality includes display, Debug UART, UFS, USB-C (peripheral), WiFi, Bluetooth and modem.

Thank you for your patch. There is something to discuss/improve.

(...)

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 45

Quoted 9 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +9 -0
+	volume-keys {
+		compatible = "gpio-keys";
+		label = "Volume keys";
+		autorepeat;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&volume_up_gpio>;
+
+		vol-up {

key-vol-up
(DT schema requires it now)

Quoted 62 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +62 -0
+			label = "Volume Up";
+			linux,code = <KEY_VOLUMEUP>;
+			gpios = <&pm8998_gpio 6 GPIO_ACTIVE_LOW>;
+			debounce-interval = <15>;
+		};
+	};
+
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		mpss_region: memory@8e000000 {
+			reg = <0 0x8e000000 0 0x9800000>;
+			no-map;
+		};
+
+		venus_mem: venus@97800000 {
+			reg = <0 0x97800000 0 0x500000>;
+			no-map;
+		};
+
+		cdsp_mem: cdsp-mem@97D00000 {
+			reg = <0 0x97D00000 0 0x800000>;
+			no-map;
+		};
+
+		mba_region: mba@98500000 {
+			reg = <0 0x98500000 0 0x200000>;
+			no-map;
+		};
+
+		slpi_mem: slpi@98700000 {
+			reg = <0 0x98700000 0 0x1400000>;
+			no-map;
+		};
+
+		spss_mem: spss@99B00000 {
+			reg = <0 0x99B00000 0 0x100000>;
+			no-map;
+		};
+
+		/* rmtfs lower guard */
+		memory@f2700000 {
+			reg = <0 0xf2700000 0 0x1000>;
+			no-map;
+		};
+
+		rmtfs_mem: memory@f2701000 {
+			compatible = "qcom,rmtfs-mem";
+			reg = <0 0xf2701000 0 0x200000>;
+			no-map;
+
+			qcom,client-id = <1>;
+			qcom,vmid = <15>;
+		};
+
+		/* rmtfs upper guard */
+		memory@f2901000 {
+			reg = <0 0xf2901000 0 0x1000>;
+			no-map;
+		};

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 117

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+	};
+
+	vph_pwr: vph-pwr-regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "vph_pwr";
+		regulator-min-microvolt = <3700000>;
+		regulator-max-microvolt = <3700000>;
+	};
+
+	vreg_s4a_1p8: vreg-s4a-1p8 {

Please use consistent naming, so if previous was "xxx-regulator", keep similar pattern here.

Quoted 13 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +13 -0
+		compatible = "regulator-fixed";
+		regulator-name = "vreg_s4a_1p8";
+
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		regulator-always-on;
+		regulator-boot-on;
+
+		vin-supply = <&vph_pwr>;
+	};
+};
+
+&adsp_pas {

(...)

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 418

Quoted 3 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +3 -0
+
+&pm8998_gpio {
+	volume_up_gpio: vol-up-active {

The bindings require node name to finish with "-state"

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 426

Quoted 8 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +8 -0
+		pins = "gpio6";
+		function = "normal";
+		input-enable;
+		bias-pull-up;
+		qcom,drive-strength = <0>;
+	};
+
+	panel_pmgpio_pins: panel-pmgpio-active {

Ditto.

Quoted 8 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +8 -0
+		pins = "gpio2", "gpio5";
+		function = "normal";
+		input-enable;
+		bias-disable;
+		power-source = <0>;
+	};
+};
+

arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts line 444

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts new file +10 -0
+&pm8998_pon {
+	resin {
+		compatible = "qcom,pm8941-resin";
+		interrupts = <0x0 0x8 1 IRQ_TYPE_EDGE_BOTH>;
+		debounce = <15625>;
+		bias-pull-up;
+		linux,code = <KEY_VOLUMEDOWN>;
+	};
+};
+

Best regards,
Krzysztof

#10 lore raw

PATCH 3/4 dt-bindings: panel: Add LG SW43408 MIPI-DSI panel

In reply to Caleb Connolly

From: Sumit Semwal <[email protected]>

LG SW43408 is 1080x2160, 4-lane MIPI-DSI panel.

[caleb: convert to yaml]
---
 .../bindings/display/panel/lg,43408.yaml      | 41 +++++++++++++++++++
 .../display/panel/panel-simple-dsi.yaml       |  2 +
 2 files changed, 43 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/lg,43408.yaml
Documentation/devicetree/bindings/display/panel/lg,43408.yaml new file +41 -0
new file mode 100644
index 000000000000..0529a3aa2692
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/panel-lvds.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: LG SW43408 1080x2160 DSI panel
+
+maintainers:
+  - Caleb Connolly <[email protected]>
+
+description: |
+  This panel is used on the Pixel 3, it is a 60hz OLED panel which
+  required DSC (Display Stream Compression) and has rounded corners.
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+  compatible:
+    items:
+      - const: lg,sw43408
+
+  vddi-supply: true
+  vpnl-supply: true
+  reset-gpios: true
+
+  backlight: false
+  power-supply: false
+
+additionalProperties: false
+
+required:
+  - compatible
+  - data-mapping
+  - width-mm
+  - height-mm
+  - panel-timing
+  - port
+
+...
Documentation/devicetree/bindings/display/panel/panel-simple-dsi.yaml +2 -0
index 2c00813f5d20..4498078cb1ee 100644
@@ -45,6 +45,8 @@ properties:
       - lg,acx467akm-7
         # LG Corporation 7" WXGA TFT LCD panel
       - lg,ld070wx3-sl01
+        # LG Corporation sw43408 1080x2160 OLED
+      - lg,sw43408
         # One Stop Displays OSD101T2587-53TS 10.1" 1920x1200 panel
       - osddisplays,osd101t2587-53ts
         # Panasonic 10" WUXGA TFT LCD panel
Signature · 1 line
2.36.1
#11 lore raw

Re: [PATCH 3/4] dt-bindings: panel: Add LG SW43408 MIPI-DSI panel

Hi Caleb,

Quoted 3 lines · Caleb Connolly

From: Sumit Semwal <[email protected]>

LG SW43408 is 1080x2160, 4-lane MIPI-DSI panel.

A few things to improve to this binding.

Sam

Quoted 36 lines
[caleb: convert to yaml]
---
 .../bindings/display/panel/lg,43408.yaml      | 41 +++++++++++++++++++
 .../display/panel/panel-simple-dsi.yaml       |  2 +
 2 files changed, 43 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/lg,43408.yaml
Documentation/devicetree/bindings/display/panel/lg,43408.yaml new file +19 -0
new file mode 100644
index 000000000000..0529a3aa2692
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/panel-lvds.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: LG SW43408 1080x2160 DSI panel
+
+maintainers:
+  - Caleb Connolly <[email protected]>
+
+description: |
+  This panel is used on the Pixel 3, it is a 60hz OLED panel which
+  required DSC (Display Stream Compression) and has rounded corners.
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:

Documentation/devicetree/bindings/display/panel/lg,43408.yaml line 29

Quoted 10 lines
Documentation/devicetree/bindings/display/panel/lg,43408.yaml new file +10 -0
+  compatible:
+    items:
+      - const: lg,sw43408
+
+  vddi-supply: true
+  vpnl-supply: true
+  reset-gpios: true
+
+  backlight: false
+  power-supply: false

No need to say anything is false, this is covered by the statement below. Also, the driver uses backlight, so it should be true?

Quoted 17 lines
Documentation/devicetree/bindings/display/panel/lg,43408.yaml new file +12 -0
+
+additionalProperties: false
+
+required:
+  - compatible
+  - data-mapping
+  - width-mm
+  - height-mm
+  - panel-timing
+  - port
+
+...
Documentation/devicetree/bindings/display/panel/panel-simple-dsi.yaml +0 -0
index 2c00813f5d20..4498078cb1ee 100644

Documentation/devicetree/bindings/display/panel/panel-simple-dsi.yaml properties: · line 49

Quoted 5 lines
Documentation/devicetree/bindings/display/panel/panel-simple-dsi.yaml +2 -0
@@ -45,6 +45,8 @@ properties:
       - lg,acx467akm-7
         # LG Corporation 7" WXGA TFT LCD panel
       - lg,ld070wx3-sl01
+        # LG Corporation sw43408 1080x2160 OLED
+      - lg,sw43408

The panel uses three power-supplies, so it is not a "panel-simple" binding. And we cannot have the same compatible twice, so this must be dropped.

Sam

#12 lore raw

Re: [PATCH 3/4] dt-bindings: panel: Add LG SW43408 MIPI-DSI panel

Hi Caleb,

Quoted 49 lines · Sam Ravnborg

Hi Caleb,

Quoted 3 lines · Caleb Connolly

From: Sumit Semwal <[email protected]>

LG SW43408 is 1080x2160, 4-lane MIPI-DSI panel.

A few things to improve to this binding.

Sam

Quoted 40 lines
[caleb: convert to yaml]
---
 .../bindings/display/panel/lg,43408.yaml      | 41 +++++++++++++++++++
 .../display/panel/panel-simple-dsi.yaml       |  2 +
 2 files changed, 43 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/lg,43408.yaml
Documentation/devicetree/bindings/display/panel/lg,43408.yaml new file +23 -0
new file mode 100644
index 000000000000..0529a3aa2692
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/panel-lvds.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: LG SW43408 1080x2160 DSI panel
+
+maintainers:
+  - Caleb Connolly <[email protected]>
+
+description: |
+  This panel is used on the Pixel 3, it is a 60hz OLED panel which
+  required DSC (Display Stream Compression) and has rounded corners.
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+  compatible:
+    items:
+      - const: lg,sw43408
+
Quoted 8 lines

Documentation/devicetree/bindings/display/panel/lg,43408.yaml line 29

Quoted 6 lines
Documentation/devicetree/bindings/display/panel/lg,43408.yaml new file +6 -0
+  vddi-supply: true
+  vpnl-supply: true
+  reset-gpios: true
+
+  backlight: false
+  power-supply: false

No need to say anything is false, this is covered by the statement below. Also, the driver uses backlight, so it should be true?

The driver do not use backlight from the DT so disregard the last comment.

Sam

maintainer
#13 lore raw

Re: [PATCH 3/4] dt-bindings: panel: Add LG SW43408 MIPI-DSI panel

In reply to Caleb Connolly
Quoted 8 lines · Caleb Connolly

From: Sumit Semwal <[email protected]>

LG SW43408 is 1080x2160, 4-lane MIPI-DSI panel.

[caleb: convert to yaml]
Quoted 6 lines
---
 .../bindings/display/panel/lg,43408.yaml      | 41 +++++++++++++++++++
 .../display/panel/panel-simple-dsi.yaml       |  2 +
 2 files changed, 43 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/panel/lg,43408.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
./Documentation/devicetree/bindings/display/panel/lg,43408.yaml: $id: relative path/filename doesn't match actual path or filename
expected: http://devicetree.org/schemas/display/panel/lg,43408.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/panel/lg,43408.yaml: duplicate '$id' value 'http://devicetree.org/schemas/display/panel/panel-lvds.yaml#'

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

#14 lore raw

PATCH 4/4 drm: panel: Add lg sw43408 panel driver

In reply to Caleb Connolly

From: Sumit Semwal <[email protected]>

LG SW43408 is 1080x2160, 4-lane MIPI-DSI panel, used in some Pixel3 phones.

Whatever init sequence we have for this panel isn't capable of initialising it completely, toggling the reset gpio ever causes the panel to die. Until this is resolved we avoid resetting the panel. The disable/unprepare functions only put the panel to sleep mode and disable the backlight.

[vinod: Add DSC support]
[caleb: cleanup and support turning off the panel]
---
 MAINTAINERS                              |   8 +
 drivers/gpu/drm/panel/Kconfig            |  11 +
 drivers/gpu/drm/panel/Makefile           |   1 +
 drivers/gpu/drm/panel/panel-lg-sw43408.c | 586 +++++++++++++++++++++++
 4 files changed, 606 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-lg-sw43408.c
MAINTAINERS +8 -0
index f679152bdbad..8a2b954ad140 100644
@@ -6376,6 +6376,14 @@ S:	Orphan / Obsolete
 F:	drivers/gpu/drm/i810/
 F:	include/uapi/drm/i810_drm.h
 
+DRM DRIVER FOR LG SW43408 PANELS
+M:	Sumit Semwal <[email protected]>
+M:	Caleb Connolly <[email protected]>
+S:	Maintained
+T:	git git://anongit.freedesktop.org/drm/drm-misc
+F:	Documentation/devicetree/bindings/display/panel/lg,sw43408-panel.txt
+F:	drivers/gpu/drm/panel/panel-lg-sw43408.c
+
 DRM DRIVER FOR LVDS PANELS
 M:	Laurent Pinchart <[email protected]>
 L:	[email protected]
drivers/gpu/drm/panel/Kconfig +11 -0
index 38799effd00a..706b112794b9 100644
@@ -256,6 +256,17 @@ config DRM_PANEL_LEADTEK_LTK500HD1829
 	  24 bit RGB per pixel. It provides a MIPI DSI interface to
 	  the host and has a built-in LED backlight.
 
+config DRM_PANEL_LG_SW43408
+	tristate "LG SW43408 panel"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  Say Y here if you want to enable support for LG sw43408 panel.
+	  The panel has a 1080x2160 resolution and uses
+	  24 bit RGB per pixel. It provides a MIPI DSI interface to
+	  the host and has a built-in LED backlight.
+
 config DRM_PANEL_SAMSUNG_LD9040
 	tristate "Samsung LD9040 RGB/SPI panel"
 	depends on OF && SPI
drivers/gpu/drm/panel/Makefile +1 -0
index 42a7ab54234b..ba26a69b74e7 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK050H3146W) += panel-leadtek-ltk050h3146w.o
 obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK500HD1829) += panel-leadtek-ltk500hd1829.o
 obj-$(CONFIG_DRM_PANEL_LG_LB035Q02) += panel-lg-lb035q02.o
 obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
+obj-$(CONFIG_DRM_PANEL_LG_SW43408) += panel-lg-sw43408.o
 obj-$(CONFIG_DRM_PANEL_NEC_NL8048HL11) += panel-nec-nl8048hl11.o
 obj-$(CONFIG_DRM_PANEL_NEWVISION_NV3052C) += panel-newvision-nv3052c.o
 obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +586 -0

586 lines not on this page · raw message

Signature · 1 line
2.36.1
#15 lore raw

Re: [PATCH 4/4] drm: panel: Add lg sw43408 panel driver

Quoted 144 lines · Caleb Connolly

From: Sumit Semwal <[email protected]>

LG SW43408 is 1080x2160, 4-lane MIPI-DSI panel, used in some Pixel3 phones.

Whatever init sequence we have for this panel isn't capable of initialising it completely, toggling the reset gpio ever causes the panel to die. Until this is resolved we avoid resetting the panel. The disable/unprepare functions only put the panel to sleep mode and disable the backlight.

[vinod: Add DSC support]
[caleb: cleanup and support turning off the panel]
---
  MAINTAINERS                              |   8 +
  drivers/gpu/drm/panel/Kconfig            |  11 +
  drivers/gpu/drm/panel/Makefile           |   1 +
  drivers/gpu/drm/panel/panel-lg-sw43408.c | 586 +++++++++++++++++++++++
  4 files changed, 606 insertions(+)

create mode 100644 drivers/gpu/drm/panel/panel-lg-sw43408.c

MAINTAINERS +8 -0
index f679152bdbad..8a2b954ad140 100644
@@ -6376,6 +6376,14 @@ S:	Orphan / Obsolete
  F:	drivers/gpu/drm/i810/
  F:	include/uapi/drm/i810_drm.h
 
+DRM DRIVER FOR LG SW43408 PANELS
+M:	Sumit Semwal <[email protected]>
+M:	Caleb Connolly <[email protected]>
+S:	Maintained
+T:	git git://anongit.freedesktop.org/drm/drm-misc
+F:	Documentation/devicetree/bindings/display/panel/lg,sw43408-panel.txt
+F:	drivers/gpu/drm/panel/panel-lg-sw43408.c
+
  DRM DRIVER FOR LVDS PANELS
  M:	Laurent Pinchart <[email protected]>
  L:	[email protected]
drivers/gpu/drm/panel/Kconfig +11 -0
index 38799effd00a..706b112794b9 100644
@@ -256,6 +256,17 @@ config DRM_PANEL_LEADTEK_LTK500HD1829
  	  24 bit RGB per pixel. It provides a MIPI DSI interface to
  	  the host and has a built-in LED backlight.
 
+config DRM_PANEL_LG_SW43408
+	tristate "LG SW43408 panel"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  Say Y here if you want to enable support for LG sw43408 panel.
+	  The panel has a 1080x2160 resolution and uses
+	  24 bit RGB per pixel. It provides a MIPI DSI interface to
+	  the host and has a built-in LED backlight.
+
  config DRM_PANEL_SAMSUNG_LD9040
  	tristate "Samsung LD9040 RGB/SPI panel"
  	depends on OF && SPI
drivers/gpu/drm/panel/Makefile +1 -0
index 42a7ab54234b..ba26a69b74e7 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK050H3146W) += panel-leadtek-ltk050h3146w.o
  obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK500HD1829) += panel-leadtek-ltk500hd1829.o
  obj-$(CONFIG_DRM_PANEL_LG_LB035Q02) += panel-lg-lb035q02.o
  obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
+obj-$(CONFIG_DRM_PANEL_LG_SW43408) += panel-lg-sw43408.o
  obj-$(CONFIG_DRM_PANEL_NEC_NL8048HL11) += panel-nec-nl8048hl11.o
  obj-$(CONFIG_DRM_PANEL_NEWVISION_NV3052C) += panel-newvision-nv3052c.o
  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +61 -0
new file mode 100644
index 000000000000..c7b8ec7b970d
@@ -0,0 +1,586 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Linaro Ltd
+ * Author: Sumit Semwal <[email protected]>
+ */
+
+#include <linux/backlight.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include <linux/gpio/consumer.h>
+#include <linux/regulator/consumer.h>
+
+#include <drm/drm_device.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_panel.h>
+#include <drm/drm_print.h>
+#include <drm/display/drm_dsc.h>
+#include <drm/display/drm_dsc_helper.h>
+
+#include <video/mipi_display.h>
+
+struct panel_cmd {
+	size_t len;
+	const char *data;
+};
+
+#define _INIT_CMD(...)                                                   \
+	{                                                                \
+		.len = sizeof((char[]){ __VA_ARGS__ }), .data = (char[]) \
+		{                                                        \
+			__VA_ARGS__                                      \
+		}                                                        \
+	}
+
+static const char *const regulator_names[] = {
+	"vddi",
+	"vpnl",
+};
+
+static const unsigned long regulator_enable_loads[] = {
+	62000,
+	857000,
+};
+
+static const unsigned long regulator_disable_loads[] = {
+	80,
+	0,
+};
+
+struct sw43408_panel {
+	struct drm_panel base;
+	struct mipi_dsi_device *link;
+
+	const struct drm_display_mode *mode;
+	struct backlight_device *backlight;
+

drivers/gpu/drm/panel/panel-lg-sw43408.c line 71

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+	struct regulator_bulk_data supplies[ARRAY_SIZE(regulator_names)];
+
+	struct gpio_desc *reset_gpio;
+
+	bool prepared;
+	bool enabled;
+};
+
+static const struct panel_cmd lg_sw43408_on_cmds_1[] = {
+	_INIT_CMD(0x00, 0x53, 0x0C, 0x30),

Please use the lower case for hex numbers.

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+	_INIT_CMD(0x00, 0x55, 0x00, 0x70, 0xDF, 0x00, 0x70, 0xDF),
+	_INIT_CMD(0x00, 0xF7, 0x01, 0x49, 0x0C),
+
+	{},
+};
+
+static const struct panel_cmd lg_sw43408_on_cmds_2[] = {
+	_INIT_CMD(0x00, 0xB0, 0xAC),
+	_INIT_CMD(0x00, 0xCD, 0x00, 0x00, 0x00, 0x19, 0x19, 0x19, 0x19, 0x19,
+		  0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x16, 0x16),

drivers/gpu/drm/panel/panel-lg-sw43408.c line 91

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+	_INIT_CMD(0x00, 0xCB, 0x80, 0x5C, 0x07, 0x03, 0x28),
+	_INIT_CMD(0x00, 0xC0, 0x02, 0x02, 0x0F),
+	_INIT_CMD(0x00, 0xE5, 0x00, 0x3A, 0x00, 0x3A, 0x00, 0x0E, 0x10),
+	_INIT_CMD(0x00, 0xB5, 0x75, 0x60, 0x2D, 0x5D, 0x80, 0x00, 0x0A, 0x0B,
+		  0x00, 0x05, 0x0B, 0x00, 0x80, 0x0D, 0x0E, 0x40, 0x00, 0x0C,
+		  0x00, 0x16, 0x00, 0xB8, 0x00, 0x80, 0x0D, 0x0E, 0x40, 0x00,
+		  0x0C, 0x00, 0x16, 0x00, 0xB8, 0x00, 0x81, 0x00, 0x03, 0x03,
+		  0x03, 0x01, 0x01),
+	_INIT_CMD(0x00, 0x55, 0x04, 0x61, 0xDB, 0x04, 0x70, 0xDB),
+	_INIT_CMD(0x00, 0xB0, 0xCA),

The dtbo from the latest firware uses a bit different sequence here:

0xb0, 0xac
0xe5, 0x00....
0xb5, 0x75.....
msleep(85);
0xcd, 0x00.....
0xcb, 0x80...
0x55, 0x04...
0xb0, 0xca

I'm not sure, but granted that you have issues with panel reinit, maybe that would make any difference.

Quoted 27 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +27 -0
+
+	{},
+};
+
+static inline struct sw43408_panel *to_panel_info(struct drm_panel *panel)
+{
+	return container_of(panel, struct sw43408_panel, base);
+}
+
+/*
+ * Currently unable to bring up the panel after resetting, must be missing
+ * some init commands somewhere.
+ */
+static __always_unused int panel_reset(struct sw43408_panel *ctx)
+{
+	int ret = 0, i;
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		ret = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_enable_loads[i]);
+		if (ret)
+			return ret;
+	}
+
+	ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (ret < 0)
+		return ret;

drivers/gpu/drm/panel/panel-lg-sw43408.c line 128

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		ret = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_disable_loads[i]);
+		if (ret) {
+			DRM_DEV_ERROR(ctx->base.dev,
+				      "regulator_set_load failed %d\n", ret);
+			return ret;
+		}
+	}

If I remember correctly, there is no need to set loads before disabling the regulator.

drivers/gpu/drm/panel/panel-lg-sw43408.c line 132

Quoted 4 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +4 -0
+
+	ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (ret < 0)
+		return ret;

So, you bump & disable regulators before playing with the reset GPIO. Does the panel honour reset GPIO while being powered down?

Quoted 101 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +101 -0
+
+	gpiod_set_value(ctx->reset_gpio, 0);
+	usleep_range(9000, 10000);
+	gpiod_set_value(ctx->reset_gpio, 1);
+	usleep_range(1000, 2000);
+	gpiod_set_value(ctx->reset_gpio, 0);
+	usleep_range(9000, 10000);
+
+	return 0;
+}
+
+static int send_mipi_cmds(struct drm_panel *panel, const struct panel_cmd *cmds)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	unsigned int i = 0;
+	int err;
+
+	if (!cmds)
+		return -EFAULT;
+
+	for (i = 0; cmds[i].len != 0; i++) {
+		const struct panel_cmd *cmd = &cmds[i];
+
+		if (cmd->len == 2)
+			err = mipi_dsi_dcs_write(ctx->link, cmd->data[1], NULL,
+						 0);
+		else
+			err = mipi_dsi_dcs_write(ctx->link, cmd->data[1],
+						 cmd->data + 2, cmd->len - 2);
+
+		if (err < 0)
+			return err;
+
+		usleep_range((cmd->data[0]) * 1000, (1 + cmd->data[0]) * 1000);
+	}
+
+	return 0;
+}
+
+static int lg_panel_disable(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+
+	backlight_disable(ctx->backlight);
+	ctx->enabled = false;
+
+	return 0;
+}
+
+/*
+ * We can't currently re-initialise the panel properly after powering off.
+ * This function will be used when this is resolved.
+ */
+static __always_unused int lg_panel_power_off(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	int i, ret = 0;
+
+	gpiod_set_value(ctx->reset_gpio, 1);
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		ret = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_disable_loads[i]);
+		if (ret) {
+			DRM_DEV_ERROR(panel->dev,
+				      "regulator_set_load failed %d\n", ret);
+			return ret;
+		}
+	}
+
+	ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (ret) {
+		DRM_DEV_ERROR(panel->dev, "regulator_bulk_disable failed %d\n",
+			      ret);
+	}
+	return ret;
+}
+
+static int lg_panel_unprepare(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	int ret, i;
+
+	if (!ctx->prepared)
+		return 0;
+
+	ret = mipi_dsi_dcs_set_display_off(ctx->link);
+	if (ret < 0) {
+		DRM_DEV_ERROR(panel->dev,
+			      "set_display_off cmd failed ret = %d\n", ret);
+	}
+
+	msleep(120);
+
+	ret = mipi_dsi_dcs_enter_sleep_mode(ctx->link);
+	if (ret < 0) {
+		DRM_DEV_ERROR(panel->dev, "enter_sleep cmd failed ret = %d\n",
+			      ret);
+	}
+
+	/* Would call panel_power_off() */

drivers/gpu/drm/panel/panel-lg-sw43408.c line 243

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		ret = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_disable_loads[i]);
+		if (ret) {
+			DRM_DEV_ERROR(panel->dev,
+				      "regulator_set_load failed %d\n", ret);
+			return ret;
+		}
+	}

Do you need to disable regulators instead?
Also would you need to pull the reset gpio?

Quoted 18 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +18 -0
+
+	ctx->prepared = false;
+
+	return ret;
+}
+
+static int lg_panel_prepare(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	int err, i;
+
+	if (ctx->prepared)
+		return 0;
+
+	/* Would call panel_reset() */
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		err = regulator_set_load(ctx->supplies[i].consumer,

drivers/gpu/drm/panel/panel-lg-sw43408.c line 271

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+					 regulator_enable_loads[i]);
+		if (err)
+			return err;
+	}
+
+	err = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (err < 0)
+		return err;
+
+	usleep_range(9000, 10000);

Reset the panel here?

Quoted 25 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +25 -0
+
+	err = mipi_dsi_dcs_write(ctx->link, MIPI_DCS_SET_GAMMA_CURVE,
+				 (u8[]){ 0x02 }, 1);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev, "failed to set gamma curve: %d\n",
+			      err);
+		goto poweroff;
+	}
+
+	err = mipi_dsi_dcs_set_tear_on(ctx->link,
+				       MIPI_DSI_DCS_TEAR_MODE_VBLANK);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev, "failed to set tear on: %d\n", err);
+		goto poweroff;
+	}
+
+	err = send_mipi_cmds(panel, &lg_sw43408_on_cmds_1[0]);
+
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev,
+			      "failed to send DCS Init 1st Code: %d\n", err);
+		goto poweroff;
+	}
+
+	err = mipi_dsi_dcs_exit_sleep_mode(ctx->link);

drivers/gpu/drm/panel/panel-lg-sw43408.c line 306

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev, "failed to exit sleep mode: %d\n",
+			      err);
+		goto poweroff;
+	}
+
+	msleep(135);
+
+	err = mipi_dsi_dcs_write(ctx->link, MIPI_DSI_COMPRESSION_MODE,
+				 (u8[]){ 0x11 }, 0);

Please adjust mipi_dsi_compression_mode() instead. Do you really need 0x11 here? Does 0x1 work? You might want to adjust the mentioned function.

Quoted 38 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +38 -0
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev,
+			      "failed to set compression mode: %d\n", err);
+		goto poweroff;
+	}
+
+	err = send_mipi_cmds(panel, &lg_sw43408_on_cmds_2[0]);
+
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev,
+			      "failed to send DCS Init 2nd Code: %d\n", err);
+		goto poweroff;
+	}
+
+	err = mipi_dsi_dcs_set_display_on(ctx->link);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev, "failed to Set Display ON: %d\n",
+			      err);
+		goto poweroff;
+	}
+
+	msleep(120);
+
+	ctx->prepared = true;
+
+	return 0;
+
+poweroff:
+	gpiod_set_value(ctx->reset_gpio, 1);
+	regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	return err;
+}
+
+static int lg_panel_enable(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	struct drm_dsc_picture_parameter_set pps;
+	int ret;

drivers/gpu/drm/panel/panel-lg-sw43408.c line 354

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+
+	if (ctx->enabled)
+		return 0;
+
+	ret = backlight_enable(ctx->backlight);
+	if (ret) {
+		DRM_DEV_ERROR(panel->dev, "Failed to enable backlight %d\n",
+			      ret);
+		return ret;
+	}

Do you need to enable the backlight beforehand (well, before sending the pps?) drm_panel_enable() would enable the backlight for you.

drivers/gpu/drm/panel/panel-lg-sw43408.c line 361

Quoted 7 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +7 -0
+
+	if (!panel->dsc) {
+		DRM_DEV_ERROR(panel->dev, "Can't find DSC\n");
+		return -ENODEV;
+	}
+
+	drm_dsc_pps_payload_pack(&pps, panel->dsc);

Do you need to call mipi_dsi_picture_parameter_set() here? Otherwise genrated pps is not used at all.

Quoted 24 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +24 -0
+
+	ctx->enabled = true;
+
+	return 0;
+}
+
+static int lg_panel_get_modes(struct drm_panel *panel,
+			      struct drm_connector *connector)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	const struct drm_display_mode *m = ctx->mode;
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_duplicate(connector->dev, m);
+	if (!mode) {
+		DRM_DEV_ERROR(panel->dev, "failed to add mode %ux%u\n",
+			      m->hdisplay, m->vdisplay);
+		return -ENOMEM;
+	}
+
+	connector->display_info.width_mm = m->width_mm;
+	connector->display_info.height_mm = m->height_mm;
+
+	drm_mode_set_name(mode);

drivers/gpu/drm/panel/panel-lg-sw43408.c line 395

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+	drm_mode_probed_add(connector, mode);
+
+	return 1;
+}
+
+static int lg_panel_backlight_update_status(struct backlight_device *bl)
+{
+	struct mipi_dsi_device *dsi = bl_get_data(bl);
+	int ret = 0;
+	uint16_t brightness;

u16

drivers/gpu/drm/panel/panel-lg-sw43408.c line 397

Quoted 2 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +2 -0
+
+	brightness = (uint16_t)backlight_get_brightness(bl);

Probably no need to cast here.

drivers/gpu/drm/panel/panel-lg-sw43408.c line 401

Quoted 4 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +4 -0
+	/* Brightness is sent in big-endian */
+	brightness = cpu_to_be16(brightness);
+
+	ret = mipi_dsi_dcs_set_display_brightness(dsi, brightness);

lmdpdg.py suggest that this (and get_display_brightnees()) should be wrapped into disabling and reenabling MIPI_DSI_MODE_LPM in dsi->mode_flags.

Quoted 4 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +4 -0
+	return ret;
+}
+
+static int lg_panel_backlight_get_brightness(struct backlight_device *bl)

drivers/gpu/drm/panel/panel-lg-sw43408.c line 415

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+{
+	struct mipi_dsi_device *dsi = bl_get_data(bl);
+	int ret = 0;
+	u16 brightness = 0;
+
+	ret = mipi_dsi_dcs_get_display_brightness(dsi, &brightness);
+	if (ret < 0)
+		return ret;
+
+	return brightness & 0xff;

So the brighness is sent as be16, but doesn't require handling on get_brightness?

Quoted 4 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +4 -0
+}
+
+const struct backlight_ops lg_panel_backlight_ops = {
+	.update_status = lg_panel_backlight_update_status,

drivers/gpu/drm/panel/panel-lg-sw43408.c line 429

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+	.get_brightness = lg_panel_backlight_get_brightness,
+};
+
+static int lg_panel_backlight_init(struct sw43408_panel *ctx)
+{
+	struct device *dev = &ctx->link->dev;
+	const struct backlight_properties props = {
+		.type = BACKLIGHT_PLATFORM,
+		.brightness = 255,
+		.max_brightness = 255,

900, according to the dtsi

Quoted 105 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +105 -0
+	};
+
+	ctx->backlight = devm_backlight_device_register(dev, dev_name(dev), dev,
+							ctx->link,
+							&lg_panel_backlight_ops,
+							&props);
+
+	if (IS_ERR(ctx->backlight))
+		return dev_err_probe(dev, PTR_ERR(ctx->backlight),
+				     "Failed to create backlight\n");
+
+	return 0;
+}
+
+static const struct drm_panel_funcs panel_funcs = {
+	.disable = lg_panel_disable,
+	.unprepare = lg_panel_unprepare,
+	.prepare = lg_panel_prepare,
+	.enable = lg_panel_enable,
+	.get_modes = lg_panel_get_modes,
+};
+
+static const struct drm_display_mode sw43408_default_mode = {
+	.clock = 152340,
+
+	.hdisplay = 1080,
+	.hsync_start = 1080 + 20,
+	.hsync_end = 1080 + 20 + 32,
+	.htotal = 1080 + 20 + 32 + 20,
+
+	.vdisplay = 2160,
+	.vsync_start = 2160 + 20,
+	.vsync_end = 2160 + 20 + 4,
+	.vtotal = 2160 + 20 + 4 + 20,
+
+	.width_mm = 62,
+	.height_mm = 124,
+
+	.type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+};
+
+static const struct of_device_id panel_of_match[] = {
+	{ .compatible = "lg,sw43408", .data = &sw43408_default_mode },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, panel_of_match);
+
+static int panel_add(struct sw43408_panel *ctx)
+{
+	struct device *dev = &ctx->link->dev;
+	int i, ret;
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++)
+		ctx->supplies[i].supply = regulator_names[i];
+
+	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies),
+				      ctx->supplies);
+	if (ret < 0)
+		return ret;
+
+	ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
+	if (IS_ERR(ctx->reset_gpio)) {
+		DRM_DEV_ERROR(dev, "cannot get reset gpio %ld\n",
+			      PTR_ERR(ctx->reset_gpio));
+		return PTR_ERR(ctx->reset_gpio);
+	}
+
+	ret = lg_panel_backlight_init(ctx);
+	if (ret < 0)
+		return ret;
+
+	drm_panel_init(&ctx->base, dev, &panel_funcs, DRM_MODE_CONNECTOR_DSI);
+
+	drm_panel_add(&ctx->base);
+	return ret;
+}
+
+static int panel_probe(struct mipi_dsi_device *dsi)
+{
+	struct sw43408_panel *ctx;
+	struct drm_dsc_config *dsc;
+	int err;
+
+	ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+
+	ctx->mode = of_device_get_match_data(&dsi->dev);
+	dsi->mode_flags = MIPI_DSI_MODE_LPM;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->lanes = 4;
+
+	ctx->link = dsi;
+	mipi_dsi_set_drvdata(dsi, ctx);
+
+	err = panel_add(ctx);
+	if (err < 0)
+		return err;
+
+	/* The panel is DSC panel only, set the dsc params */
+	dsc = devm_kzalloc(&dsi->dev, sizeof(*dsc), GFP_KERNEL);
+	if (!dsc)
+		return -ENOMEM;
+
+	dsc->dsc_version_major = 0x1;

drivers/gpu/drm/panel/panel-lg-sw43408.c line 544

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+	dsc->dsc_version_minor = 0x1;
+
+	dsc->slice_height = 16;
+	dsc->slice_width = 540;
+	dsc->slice_count = 1;
+	dsc->bits_per_component = 8;
+	dsc->bits_per_pixel = 8;
+	dsc->block_pred_enable = true;
+
+	ctx->base.dsc = dsc;

I was really hoping to move DSC PPS data to struct mipi_dsi_device, before DSC panel drivers start to pop up.

See https://lore.kernel.org/linux-arm-msm/[email protected]/

Quoted 42 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +42 -0
+
+	return mipi_dsi_attach(dsi);
+}
+
+static int panel_remove(struct mipi_dsi_device *dsi)
+{
+	struct sw43408_panel *ctx = mipi_dsi_get_drvdata(dsi);
+	int err;
+
+	err = lg_panel_unprepare(&ctx->base);
+	if (err < 0)
+		DRM_DEV_ERROR(&dsi->dev, "failed to unprepare panel: %d\n",
+			      err);
+
+	err = lg_panel_disable(&ctx->base);
+	if (err < 0)
+		DRM_DEV_ERROR(&dsi->dev, "failed to disable panel: %d\n", err);
+
+	err = mipi_dsi_detach(dsi);
+	if (err < 0)
+		DRM_DEV_ERROR(&dsi->dev, "failed to detach from DSI host: %d\n",
+			      err);
+
+	if (ctx->base.dev)
+		drm_panel_remove(&ctx->base);
+
+	return 0;
+}
+
+static struct mipi_dsi_driver panel_driver = {
+	.driver = {
+		.name = "panel-lg-sw43408",
+		.of_match_table = panel_of_match,
+	},
+	.probe = panel_probe,
+	.remove = panel_remove,
+};
+module_mipi_dsi_driver(panel_driver);
+
+MODULE_AUTHOR("Sumit Semwal <[email protected]>");
+MODULE_DESCRIPTION("LG SW436408 MIPI-DSI LED panel");
+MODULE_LICENSE("GPL");
Signature · 2 lines
With best wishes
Dmitry
#16 lore raw

Re: [PATCH 4/4] drm: panel: Add lg sw43408 panel driver

In reply to Caleb Connolly

Hi Caleb,

Quoted 4 lines · Caleb Connolly

From: Sumit Semwal <[email protected]>

LG SW43408 is 1080x2160, 4-lane MIPI-DSI panel, used in some Pixel3 phones.

Thanks for submitting this.

When reading the code it is obvious that this was based on an older panel and there is a few things to improve to get it on on same level as the other panel drivers today.

I will comment in the following.

Sam

Quoted 25 lines

Whatever init sequence we have for this panel isn't capable of initialising it completely, toggling the reset gpio ever causes the panel to die. Until this is resolved we avoid resetting the panel. The disable/unprepare functions only put the panel to sleep mode and disable the backlight.

[vinod: Add DSC support]
[caleb: cleanup and support turning off the panel]
---
 MAINTAINERS                              |   8 +
 drivers/gpu/drm/panel/Kconfig            |  11 +
 drivers/gpu/drm/panel/Makefile           |   1 +
 drivers/gpu/drm/panel/panel-lg-sw43408.c | 586 +++++++++++++++++++++++
 4 files changed, 606 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-lg-sw43408.c
MAINTAINERS +0 -0
index f679152bdbad..8a2b954ad140 100644

MAINTAINERS S: Orphan / Obsolete · line 6382

Quoted 7 lines
MAINTAINERS +4 -0
@@ -6376,6 +6376,14 @@ S:	Orphan / Obsolete
 F:	drivers/gpu/drm/i810/
 F:	include/uapi/drm/i810_drm.h
 
+DRM DRIVER FOR LG SW43408 PANELS
+M:	Sumit Semwal <[email protected]>
+M:	Caleb Connolly <[email protected]>
+S:	Maintained

m +T: git git://anongit.freedesktop.org/drm/drm-misc

Quoted 15 lines
MAINTAINERS +3 -0
+F:	Documentation/devicetree/bindings/display/panel/lg,sw43408-panel.txt
+F:	drivers/gpu/drm/panel/panel-lg-sw43408.c
+
 DRM DRIVER FOR LVDS PANELS
 M:	Laurent Pinchart <[email protected]>
 L:	[email protected]
drivers/gpu/drm/panel/Kconfig +1 -0
index 38799effd00a..706b112794b9 100644
@@ -256,6 +256,17 @@ config DRM_PANEL_LEADTEK_LTK500HD1829
 	  24 bit RGB per pixel. It provides a MIPI DSI interface to
 	  the host and has a built-in LED backlight.
 
+config DRM_PANEL_LG_SW43408

drivers/gpu/drm/panel/Kconfig config DRM_PANEL_LEADTEK_LTK500HD1829 · line 269

Quoted 10 lines
drivers/gpu/drm/panel/Kconfig +10 -0
+	tristate "LG SW43408 panel"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  Say Y here if you want to enable support for LG sw43408 panel.
+	  The panel has a 1080x2160 resolution and uses
+	  24 bit RGB per pixel. It provides a MIPI DSI interface to
+	  the host and has a built-in LED backlight.
+

Hrmpf, the DRM_PANEL_SAMSUNG_LD9040 config entry is not placed in alphabetic order. Can you move it or put you config optiosn with the other LG config options?

Quoted 21 lines
drivers/gpu/drm/panel/Kconfig +0 -0
 config DRM_PANEL_SAMSUNG_LD9040
 	tristate "Samsung LD9040 RGB/SPI panel"
 	depends on OF && SPI
drivers/gpu/drm/panel/Makefile +1 -0
index 42a7ab54234b..ba26a69b74e7 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK050H3146W) += panel-leadtek-ltk050h3146w.o
 obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK500HD1829) += panel-leadtek-ltk500hd1829.o
 obj-$(CONFIG_DRM_PANEL_LG_LB035Q02) += panel-lg-lb035q02.o
 obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
+obj-$(CONFIG_DRM_PANEL_LG_SW43408) += panel-lg-sw43408.o
 obj-$(CONFIG_DRM_PANEL_NEC_NL8048HL11) += panel-nec-nl8048hl11.o
 obj-$(CONFIG_DRM_PANEL_NEWVISION_NV3052C) += panel-newvision-nv3052c.o
 obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +0 -0
new file mode 100644
index 000000000000..c7b8ec7b970d

drivers/gpu/drm/panel/panel-lg-sw43408.c line 3

Quoted 3 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +3 -0
@@ -0,0 +1,586 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Linaro Ltd

Update to 2022?

Quoted 25 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +25 -0
+ * Author: Sumit Semwal <[email protected]>
+ */
+
+#include <linux/backlight.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include <linux/gpio/consumer.h>
+#include <linux/regulator/consumer.h>
+
+#include <drm/drm_device.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_panel.h>
+#include <drm/drm_print.h>
+#include <drm/display/drm_dsc.h>
+#include <drm/display/drm_dsc_helper.h>
+
+#include <video/mipi_display.h>
+
+struct panel_cmd {
+	size_t len;

drivers/gpu/drm/panel/panel-lg-sw43408.c line 38

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+	const char *data;
+};
+
+#define _INIT_CMD(...)                                                   \
+	{                                                                \
+		.len = sizeof((char[]){ __VA_ARGS__ }), .data = (char[]) \
+		{                                                        \
+			__VA_ARGS__                                      \
+		}                                                        \
+	}

Other panel drivers do:

#define _INIT_DCS_CMD(...) { \
        .type = INIT_DCS_CMD, \
        .len = sizeof((char[]){__VA_ARGS__}), \
        .data = (char[]){__VA_ARGS__} }

See for example panel-boe-tv101wum-nl6.c This makes the init sequences a tad more readable.

Quoted 9 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +9 -0
+
+static const char *const regulator_names[] = {
+	"vddi",
+	"vpnl",
+};
+
+static const unsigned long regulator_enable_loads[] = {
+	62000,
+	857000,

drivers/gpu/drm/panel/panel-lg-sw43408.c line 57

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+};
+
+static const unsigned long regulator_disable_loads[] = {
+	80,
+	0,
+};
+
+struct sw43408_panel {
+	struct drm_panel base;
+	struct mipi_dsi_device *link;

This is often named "dsi"

drivers/gpu/drm/panel/panel-lg-sw43408.c line 60

Quoted 3 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +3 -0
+
+	const struct drm_display_mode *mode;
+	struct backlight_device *backlight;

Unless there are specific needs, use the drm_panel provided backlight.

Quoted 55 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +55 -0
+
+	struct regulator_bulk_data supplies[ARRAY_SIZE(regulator_names)];
+
+	struct gpio_desc *reset_gpio;
+
+	bool prepared;
+	bool enabled;
+};
+
+static const struct panel_cmd lg_sw43408_on_cmds_1[] = {
+	_INIT_CMD(0x00, 0x53, 0x0C, 0x30),
+	_INIT_CMD(0x00, 0x55, 0x00, 0x70, 0xDF, 0x00, 0x70, 0xDF),
+	_INIT_CMD(0x00, 0xF7, 0x01, 0x49, 0x0C),
+
+	{},
+};
+
+static const struct panel_cmd lg_sw43408_on_cmds_2[] = {
+	_INIT_CMD(0x00, 0xB0, 0xAC),
+	_INIT_CMD(0x00, 0xCD, 0x00, 0x00, 0x00, 0x19, 0x19, 0x19, 0x19, 0x19,
+		  0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x16, 0x16),
+	_INIT_CMD(0x00, 0xCB, 0x80, 0x5C, 0x07, 0x03, 0x28),
+	_INIT_CMD(0x00, 0xC0, 0x02, 0x02, 0x0F),
+	_INIT_CMD(0x00, 0xE5, 0x00, 0x3A, 0x00, 0x3A, 0x00, 0x0E, 0x10),
+	_INIT_CMD(0x00, 0xB5, 0x75, 0x60, 0x2D, 0x5D, 0x80, 0x00, 0x0A, 0x0B,
+		  0x00, 0x05, 0x0B, 0x00, 0x80, 0x0D, 0x0E, 0x40, 0x00, 0x0C,
+		  0x00, 0x16, 0x00, 0xB8, 0x00, 0x80, 0x0D, 0x0E, 0x40, 0x00,
+		  0x0C, 0x00, 0x16, 0x00, 0xB8, 0x00, 0x81, 0x00, 0x03, 0x03,
+		  0x03, 0x01, 0x01),
+	_INIT_CMD(0x00, 0x55, 0x04, 0x61, 0xDB, 0x04, 0x70, 0xDB),
+	_INIT_CMD(0x00, 0xB0, 0xCA),
+
+	{},
+};
+
+static inline struct sw43408_panel *to_panel_info(struct drm_panel *panel)
+{
+	return container_of(panel, struct sw43408_panel, base);
+}
+
+/*
+ * Currently unable to bring up the panel after resetting, must be missing
+ * some init commands somewhere.
+ */
+static __always_unused int panel_reset(struct sw43408_panel *ctx)
+{
+	int ret = 0, i;
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		ret = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_enable_loads[i]);
+		if (ret)
+			return ret;
+	}
+

drivers/gpu/drm/panel/panel-lg-sw43408.c line 125

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+	ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (ret < 0)
+		return ret;
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		ret = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_disable_loads[i]);
+		if (ret) {
+			DRM_DEV_ERROR(ctx->base.dev,
+				      "regulator_set_load failed %d\n", ret);

panels do not use DRM_DEV_ERROR() these days. Use dev_err() or pr_err().

Quoted 23 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +23 -0
+			return ret;
+		}
+	}
+
+	ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (ret < 0)
+		return ret;
+
+	gpiod_set_value(ctx->reset_gpio, 0);
+	usleep_range(9000, 10000);
+	gpiod_set_value(ctx->reset_gpio, 1);
+	usleep_range(1000, 2000);
+	gpiod_set_value(ctx->reset_gpio, 0);
+	usleep_range(9000, 10000);
+
+	return 0;
+}
+
+static int send_mipi_cmds(struct drm_panel *panel, const struct panel_cmd *cmds)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	unsigned int i = 0;
+	int err;

drivers/gpu/drm/panel/panel-lg-sw43408.c line 158

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+
+	if (!cmds)
+		return -EFAULT;
+
+	for (i = 0; cmds[i].len != 0; i++) {
+		const struct panel_cmd *cmd = &cmds[i];
+
+		if (cmd->len == 2)
+			err = mipi_dsi_dcs_write(ctx->link, cmd->data[1], NULL,
+						 0);

Do not wrap lines like this, up to 100 chars is ok.

There is no use of len == 2 - as there is none with this length. Maybe error out there is one as this is likely a bug?

drivers/gpu/drm/panel/panel-lg-sw43408.c line 162

Quoted 4 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +4 -0
+		else
+			err = mipi_dsi_dcs_write(ctx->link, cmd->data[1],
+						 cmd->data + 2, cmd->len - 2);
+

Consider to use mipi_dsi_dcs_write_buffer

drivers/gpu/drm/panel/panel-lg-sw43408.c line 166

Quoted 4 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +4 -0
+		if (err < 0)
+			return err;
+
+		usleep_range((cmd->data[0]) * 1000, (1 + cmd->data[0]) * 1000);

So there is always a usleep_range(0, 1000) after each write - is this really required?
Also, it is non-obvious that the first byte in the arry is a delay parameter, this can be done better. See panel-boe-tv101wum-nl6.c as one example - there may be betters ways to do it.

Quoted 4 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +4 -0
+	}
+
+	return 0;
+}

drivers/gpu/drm/panel/panel-lg-sw43408.c line 180

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+
+static int lg_panel_disable(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+
+	backlight_disable(ctx->backlight);
+	ctx->enabled = false;
+
+	return 0;
+}

Let drm_panel handle backlight, then you can drop the disable method.

Quoted 43 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +43 -0
+
+/*
+ * We can't currently re-initialise the panel properly after powering off.
+ * This function will be used when this is resolved.
+ */
+static __always_unused int lg_panel_power_off(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	int i, ret = 0;
+
+	gpiod_set_value(ctx->reset_gpio, 1);
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		ret = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_disable_loads[i]);
+		if (ret) {
+			DRM_DEV_ERROR(panel->dev,
+				      "regulator_set_load failed %d\n", ret);
+			return ret;
+		}
+	}
+
+	ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (ret) {
+		DRM_DEV_ERROR(panel->dev, "regulator_bulk_disable failed %d\n",
+			      ret);
+	}
+	return ret;
+}
+
+static int lg_panel_unprepare(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	int ret, i;
+
+	if (!ctx->prepared)
+		return 0;
+
+	ret = mipi_dsi_dcs_set_display_off(ctx->link);
+	if (ret < 0) {
+		DRM_DEV_ERROR(panel->dev,
+			      "set_display_off cmd failed ret = %d\n", ret);
+	}

drivers/gpu/drm/panel/panel-lg-sw43408.c line 233

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+
+	msleep(120);
+
+	ret = mipi_dsi_dcs_enter_sleep_mode(ctx->link);
+	if (ret < 0) {
+		DRM_DEV_ERROR(panel->dev, "enter_sleep cmd failed ret = %d\n",
+			      ret);
+	}
+
+	/* Would call panel_power_off() */

And please do so.
If the reset code is not OK then comment it out in power_off(), but do not duplicate all the regulator handling - it is very confusing to read.
Same with the other commented out functions.

I did not look at the unprepare code - this will wait until next iteration of the driver where the power supply stuff is cleaned up.

Quoted 118 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +118 -0
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		ret = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_disable_loads[i]);
+		if (ret) {
+			DRM_DEV_ERROR(panel->dev,
+				      "regulator_set_load failed %d\n", ret);
+			return ret;
+		}
+	}
+
+	ctx->prepared = false;
+
+	return ret;
+}
+
+static int lg_panel_prepare(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	int err, i;
+
+	if (ctx->prepared)
+		return 0;
+
+	/* Would call panel_reset() */
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		err = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_enable_loads[i]);
+		if (err)
+			return err;
+	}
+
+	err = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (err < 0)
+		return err;
+
+	usleep_range(9000, 10000);
+
+	err = mipi_dsi_dcs_write(ctx->link, MIPI_DCS_SET_GAMMA_CURVE,
+				 (u8[]){ 0x02 }, 1);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev, "failed to set gamma curve: %d\n",
+			      err);
+		goto poweroff;
+	}
+
+	err = mipi_dsi_dcs_set_tear_on(ctx->link,
+				       MIPI_DSI_DCS_TEAR_MODE_VBLANK);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev, "failed to set tear on: %d\n", err);
+		goto poweroff;
+	}
+
+	err = send_mipi_cmds(panel, &lg_sw43408_on_cmds_1[0]);
+
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev,
+			      "failed to send DCS Init 1st Code: %d\n", err);
+		goto poweroff;
+	}
+
+	err = mipi_dsi_dcs_exit_sleep_mode(ctx->link);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev, "failed to exit sleep mode: %d\n",
+			      err);
+		goto poweroff;
+	}
+
+	msleep(135);
+
+	err = mipi_dsi_dcs_write(ctx->link, MIPI_DSI_COMPRESSION_MODE,
+				 (u8[]){ 0x11 }, 0);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev,
+			      "failed to set compression mode: %d\n", err);
+		goto poweroff;
+	}
+
+	err = send_mipi_cmds(panel, &lg_sw43408_on_cmds_2[0]);
+
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev,
+			      "failed to send DCS Init 2nd Code: %d\n", err);
+		goto poweroff;
+	}
+
+	err = mipi_dsi_dcs_set_display_on(ctx->link);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev, "failed to Set Display ON: %d\n",
+			      err);
+		goto poweroff;
+	}
+
+	msleep(120);
+
+	ctx->prepared = true;
+
+	return 0;
+
+poweroff:
+	gpiod_set_value(ctx->reset_gpio, 1);
+	regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	return err;
+}
+
+static int lg_panel_enable(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	struct drm_dsc_picture_parameter_set pps;
+	int ret;
+
+	if (ctx->enabled)
+		return 0;
+
+	ret = backlight_enable(ctx->backlight);
+	if (ret) {
+		DRM_DEV_ERROR(panel->dev, "Failed to enable backlight %d\n",

drivers/gpu/drm/panel/panel-lg-sw43408.c line 361

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+			      ret);
+		return ret;
+	}
+
+	if (!panel->dsc) {
+		DRM_DEV_ERROR(panel->dev, "Can't find DSC\n");
+		return -ENODEV;
+	}
+
+	drm_dsc_pps_payload_pack(&pps, panel->dsc);

There is nothing in disable about pps_payload - so they are not symmetrical. Check if this is OK.

Quoted 28 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +28 -0
+
+	ctx->enabled = true;
+
+	return 0;
+}
+
+static int lg_panel_get_modes(struct drm_panel *panel,
+			      struct drm_connector *connector)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	const struct drm_display_mode *m = ctx->mode;
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_duplicate(connector->dev, m);
+	if (!mode) {
+		DRM_DEV_ERROR(panel->dev, "failed to add mode %ux%u\n",
+			      m->hdisplay, m->vdisplay);
+		return -ENOMEM;
+	}
+
+	connector->display_info.width_mm = m->width_mm;
+	connector->display_info.height_mm = m->height_mm;
+
+	drm_mode_set_name(mode);
+	drm_mode_probed_add(connector, mode);
+
+	return 1;
+}

drivers/gpu/drm/panel/panel-lg-sw43408.c line 399

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+
+static int lg_panel_backlight_update_status(struct backlight_device *bl)
+{
+	struct mipi_dsi_device *dsi = bl_get_data(bl);
+	int ret = 0;
+	uint16_t brightness;
+
+	brightness = (uint16_t)backlight_get_brightness(bl);
+	/* Brightness is sent in big-endian */
+	brightness = cpu_to_be16(brightness);

This cpu_to_be16() looks wrong - the mipi_dsi_dcs_set_display_brightness() takes care.

Quoted 6 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +6 -0
+
+	ret = mipi_dsi_dcs_set_display_brightness(dsi, brightness);
+	return ret;
+}
+
+static int lg_panel_backlight_get_brightness(struct backlight_device *bl)

drivers/gpu/drm/panel/panel-lg-sw43408.c line 415

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+{
+	struct mipi_dsi_device *dsi = bl_get_data(bl);
+	int ret = 0;
+	u16 brightness = 0;
+
+	ret = mipi_dsi_dcs_get_display_brightness(dsi, &brightness);
+	if (ret < 0)
+		return ret;
+
+	return brightness & 0xff;

The truncation to 8 bit is not needed unless the HW is buggy. And since the brightness value is not adjusted, there is no need to add the get_brightness() method, it will just return what was written earlier anyway. Most panels get away without it.

drivers/gpu/drm/panel/panel-lg-sw43408.c line 427

Quoted 12 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +12 -0
+}
+
+const struct backlight_ops lg_panel_backlight_ops = {
+	.update_status = lg_panel_backlight_update_status,
+	.get_brightness = lg_panel_backlight_get_brightness,
+};
+
+static int lg_panel_backlight_init(struct sw43408_panel *ctx)
+{
+	struct device *dev = &ctx->link->dev;
+	const struct backlight_properties props = {
+		.type = BACKLIGHT_PLATFORM,

This is not a PLATFORM backlight, RAW it the right choice here.

drivers/gpu/drm/panel/panel-lg-sw43408.c line 429

Quoted 2 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +2 -0
+		.brightness = 255,
+		.max_brightness = 255,

Is 255 the correct max here? Check the HW specs.

drivers/gpu/drm/panel/panel-lg-sw43408.c line 435

Quoted 6 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +6 -0
+	};
+
+	ctx->backlight = devm_backlight_device_register(dev, dev_name(dev), dev,
+							ctx->link,
+							&lg_panel_backlight_ops,
+							&props);

Use panel->backlight here.

Quoted 50 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +50 -0
+
+	if (IS_ERR(ctx->backlight))
+		return dev_err_probe(dev, PTR_ERR(ctx->backlight),
+				     "Failed to create backlight\n");
+
+	return 0;
+}
+
+static const struct drm_panel_funcs panel_funcs = {
+	.disable = lg_panel_disable,
+	.unprepare = lg_panel_unprepare,
+	.prepare = lg_panel_prepare,
+	.enable = lg_panel_enable,
+	.get_modes = lg_panel_get_modes,
+};
+
+static const struct drm_display_mode sw43408_default_mode = {
+	.clock = 152340,
+
+	.hdisplay = 1080,
+	.hsync_start = 1080 + 20,
+	.hsync_end = 1080 + 20 + 32,
+	.htotal = 1080 + 20 + 32 + 20,
+
+	.vdisplay = 2160,
+	.vsync_start = 2160 + 20,
+	.vsync_end = 2160 + 20 + 4,
+	.vtotal = 2160 + 20 + 4 + 20,
+
+	.width_mm = 62,
+	.height_mm = 124,
+
+	.type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+};
+
+static const struct of_device_id panel_of_match[] = {
+	{ .compatible = "lg,sw43408", .data = &sw43408_default_mode },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, panel_of_match);
+
+static int panel_add(struct sw43408_panel *ctx)
+{
+	struct device *dev = &ctx->link->dev;
+	int i, ret;
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++)
+		ctx->supplies[i].supply = regulator_names[i];
+
+	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies),

drivers/gpu/drm/panel/panel-lg-sw43408.c line 495

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+				      ctx->supplies);
+	if (ret < 0)
+		return ret;
+
+	ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
+	if (IS_ERR(ctx->reset_gpio)) {
+		DRM_DEV_ERROR(dev, "cannot get reset gpio %ld\n",
+			      PTR_ERR(ctx->reset_gpio));
+		return PTR_ERR(ctx->reset_gpio);
+	}

Use dev_err_probe() here.

drivers/gpu/drm/panel/panel-lg-sw43408.c line 501

Quoted 6 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +6 -0
+
+	ret = lg_panel_backlight_init(ctx);
+	if (ret < 0)
+		return ret;
+
+	drm_panel_init(&ctx->base, dev, &panel_funcs, DRM_MODE_CONNECTOR_DSI);

Init backlight after panel init.

Quoted 21 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +21 -0
+
+	drm_panel_add(&ctx->base);
+	return ret;
+}
+
+static int panel_probe(struct mipi_dsi_device *dsi)
+{
+	struct sw43408_panel *ctx;
+	struct drm_dsc_config *dsc;
+	int err;
+
+	ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+
+	ctx->mode = of_device_get_match_data(&dsi->dev);
+	dsi->mode_flags = MIPI_DSI_MODE_LPM;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->lanes = 4;
+
+	ctx->link = dsi;

drivers/gpu/drm/panel/panel-lg-sw43408.c line 532

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+	mipi_dsi_set_drvdata(dsi, ctx);
+
+	err = panel_add(ctx);
+	if (err < 0)
+		return err;
+
+	/* The panel is DSC panel only, set the dsc params */
+	dsc = devm_kzalloc(&dsi->dev, sizeof(*dsc), GFP_KERNEL);
+	if (!dsc)
+		return -ENOMEM;

The drm_dsc_config could be embedded in sw43408_panel, so there was not two allocations to track but with devm_kzalloc this is not a big win.

Quoted 15 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +15 -0
+
+	dsc->dsc_version_major = 0x1;
+	dsc->dsc_version_minor = 0x1;
+
+	dsc->slice_height = 16;
+	dsc->slice_width = 540;
+	dsc->slice_count = 1;
+	dsc->bits_per_component = 8;
+	dsc->bits_per_pixel = 8;
+	dsc->block_pred_enable = true;
+
+	ctx->base.dsc = dsc;
+
+	return mipi_dsi_attach(dsi);
+}

drivers/gpu/drm/panel/panel-lg-sw43408.c line 557

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+
+static int panel_remove(struct mipi_dsi_device *dsi)
+{
+	struct sw43408_panel *ctx = mipi_dsi_get_drvdata(dsi);
+	int err;
+
+	err = lg_panel_unprepare(&ctx->base);
+	if (err < 0)
+		DRM_DEV_ERROR(&dsi->dev, "failed to unprepare panel: %d\n",
+			      err);

Use the drm_panel() functions here, do not call your own. See for example: y030xx067a_remove()

drivers/gpu/drm/panel/panel-lg-sw43408.c line 566

Quoted 9 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +9 -0
+
+	err = lg_panel_disable(&ctx->base);
+	if (err < 0)
+		DRM_DEV_ERROR(&dsi->dev, "failed to disable panel: %d\n", err);
+
+	err = mipi_dsi_detach(dsi);
+	if (err < 0)
+		DRM_DEV_ERROR(&dsi->dev, "failed to detach from DSI host: %d\n",
+			      err);

mipi_dsi_detach() is needed here.

drivers/gpu/drm/panel/panel-lg-sw43408.c line 568

Quoted 2 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +2 -0
+
+	if (ctx->base.dev)

No need to check, the pointer must be valid.

Quoted 20 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +18 -0
+		drm_panel_remove(&ctx->base);
+
+	return 0;
+}
+
+static struct mipi_dsi_driver panel_driver = {
+	.driver = {
+		.name = "panel-lg-sw43408",
+		.of_match_table = panel_of_match,
+	},
+	.probe = panel_probe,
+	.remove = panel_remove,
+};
+module_mipi_dsi_driver(panel_driver);
+
+MODULE_AUTHOR("Sumit Semwal <[email protected]>");
+MODULE_DESCRIPTION("LG SW436408 MIPI-DSI LED panel");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.36.1
#17 lore raw

Re: [PATCH 4/4] drm: panel: Add lg sw43408 panel driver

In reply to Caleb Connolly
Quoted 614 lines · Caleb Connolly

From: Sumit Semwal <[email protected]>

LG SW43408 is 1080x2160, 4-lane MIPI-DSI panel, used in some Pixel3 phones.

Whatever init sequence we have for this panel isn't capable of initialising it completely, toggling the reset gpio ever causes the panel to die. Until this is resolved we avoid resetting the panel. The disable/unprepare functions only put the panel to sleep mode and disable the backlight.

[vinod: Add DSC support]
[caleb: cleanup and support turning off the panel]
---
 MAINTAINERS                              |   8 +
 drivers/gpu/drm/panel/Kconfig            |  11 +
 drivers/gpu/drm/panel/Makefile           |   1 +
 drivers/gpu/drm/panel/panel-lg-sw43408.c | 586 +++++++++++++++++++++++
 4 files changed, 606 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-lg-sw43408.c
MAINTAINERS +8 -0
index f679152bdbad..8a2b954ad140 100644
@@ -6376,6 +6376,14 @@ S:	Orphan / Obsolete
 F:	drivers/gpu/drm/i810/
 F:	include/uapi/drm/i810_drm.h
 
+DRM DRIVER FOR LG SW43408 PANELS
+M:	Sumit Semwal <[email protected]>
+M:	Caleb Connolly <[email protected]>
+S:	Maintained
+T:	git git://anongit.freedesktop.org/drm/drm-misc
+F:	Documentation/devicetree/bindings/display/panel/lg,sw43408-panel.txt
+F:	drivers/gpu/drm/panel/panel-lg-sw43408.c
+
 DRM DRIVER FOR LVDS PANELS
 M:	Laurent Pinchart <[email protected]>
 L:	[email protected]
drivers/gpu/drm/panel/Kconfig +11 -0
index 38799effd00a..706b112794b9 100644
@@ -256,6 +256,17 @@ config DRM_PANEL_LEADTEK_LTK500HD1829
 	  24 bit RGB per pixel. It provides a MIPI DSI interface to
 	  the host and has a built-in LED backlight.
 
+config DRM_PANEL_LG_SW43408
+	tristate "LG SW43408 panel"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  Say Y here if you want to enable support for LG sw43408 panel.
+	  The panel has a 1080x2160 resolution and uses
+	  24 bit RGB per pixel. It provides a MIPI DSI interface to
+	  the host and has a built-in LED backlight.
+
 config DRM_PANEL_SAMSUNG_LD9040
 	tristate "Samsung LD9040 RGB/SPI panel"
 	depends on OF && SPI
drivers/gpu/drm/panel/Makefile +1 -0
index 42a7ab54234b..ba26a69b74e7 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK050H3146W) += panel-leadtek-ltk050h3146w.o
 obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK500HD1829) += panel-leadtek-ltk500hd1829.o
 obj-$(CONFIG_DRM_PANEL_LG_LB035Q02) += panel-lg-lb035q02.o
 obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
+obj-$(CONFIG_DRM_PANEL_LG_SW43408) += panel-lg-sw43408.o
 obj-$(CONFIG_DRM_PANEL_NEC_NL8048HL11) += panel-nec-nl8048hl11.o
 obj-$(CONFIG_DRM_PANEL_NEWVISION_NV3052C) += panel-newvision-nv3052c.o
 obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +531 -0
new file mode 100644
index 000000000000..c7b8ec7b970d
@@ -0,0 +1,586 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Linaro Ltd
+ * Author: Sumit Semwal <[email protected]>
+ */
+
+#include <linux/backlight.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include <linux/gpio/consumer.h>
+#include <linux/regulator/consumer.h>
+
+#include <drm/drm_device.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_panel.h>
+#include <drm/drm_print.h>
+#include <drm/display/drm_dsc.h>
+#include <drm/display/drm_dsc_helper.h>
+
+#include <video/mipi_display.h>
+
+struct panel_cmd {
+	size_t len;
+	const char *data;
+};
+
+#define _INIT_CMD(...)                                                   \
+	{                                                                \
+		.len = sizeof((char[]){ __VA_ARGS__ }), .data = (char[]) \
+		{                                                        \
+			__VA_ARGS__                                      \
+		}                                                        \
+	}
+
+static const char *const regulator_names[] = {
+	"vddi",
+	"vpnl",
+};
+
+static const unsigned long regulator_enable_loads[] = {
+	62000,
+	857000,
+};
+
+static const unsigned long regulator_disable_loads[] = {
+	80,
+	0,
+};
+
+struct sw43408_panel {
+	struct drm_panel base;
+	struct mipi_dsi_device *link;
+
+	const struct drm_display_mode *mode;
+	struct backlight_device *backlight;
+
+	struct regulator_bulk_data supplies[ARRAY_SIZE(regulator_names)];
+
+	struct gpio_desc *reset_gpio;
+
+	bool prepared;
+	bool enabled;
+};
+
+static const struct panel_cmd lg_sw43408_on_cmds_1[] = {
+	_INIT_CMD(0x00, 0x53, 0x0C, 0x30),
+	_INIT_CMD(0x00, 0x55, 0x00, 0x70, 0xDF, 0x00, 0x70, 0xDF),
+	_INIT_CMD(0x00, 0xF7, 0x01, 0x49, 0x0C),
+
+	{},
+};
+
+static const struct panel_cmd lg_sw43408_on_cmds_2[] = {
+	_INIT_CMD(0x00, 0xB0, 0xAC),
+	_INIT_CMD(0x00, 0xCD, 0x00, 0x00, 0x00, 0x19, 0x19, 0x19, 0x19, 0x19,
+		  0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x16, 0x16),
+	_INIT_CMD(0x00, 0xCB, 0x80, 0x5C, 0x07, 0x03, 0x28),
+	_INIT_CMD(0x00, 0xC0, 0x02, 0x02, 0x0F),
+	_INIT_CMD(0x00, 0xE5, 0x00, 0x3A, 0x00, 0x3A, 0x00, 0x0E, 0x10),
+	_INIT_CMD(0x00, 0xB5, 0x75, 0x60, 0x2D, 0x5D, 0x80, 0x00, 0x0A, 0x0B,
+		  0x00, 0x05, 0x0B, 0x00, 0x80, 0x0D, 0x0E, 0x40, 0x00, 0x0C,
+		  0x00, 0x16, 0x00, 0xB8, 0x00, 0x80, 0x0D, 0x0E, 0x40, 0x00,
+		  0x0C, 0x00, 0x16, 0x00, 0xB8, 0x00, 0x81, 0x00, 0x03, 0x03,
+		  0x03, 0x01, 0x01),
+	_INIT_CMD(0x00, 0x55, 0x04, 0x61, 0xDB, 0x04, 0x70, 0xDB),
+	_INIT_CMD(0x00, 0xB0, 0xCA),
+
+	{},
+};
+
+static inline struct sw43408_panel *to_panel_info(struct drm_panel *panel)
+{
+	return container_of(panel, struct sw43408_panel, base);
+}
+
+/*
+ * Currently unable to bring up the panel after resetting, must be missing
+ * some init commands somewhere.
+ */
+static __always_unused int panel_reset(struct sw43408_panel *ctx)
+{
+	int ret = 0, i;
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		ret = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_enable_loads[i]);
+		if (ret)
+			return ret;
+	}
+
+	ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (ret < 0)
+		return ret;
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		ret = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_disable_loads[i]);
+		if (ret) {
+			DRM_DEV_ERROR(ctx->base.dev,
+				      "regulator_set_load failed %d\n", ret);
+			return ret;
+		}
+	}
+
+	ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (ret < 0)
+		return ret;
+
+	gpiod_set_value(ctx->reset_gpio, 0);
+	usleep_range(9000, 10000);
+	gpiod_set_value(ctx->reset_gpio, 1);
+	usleep_range(1000, 2000);
+	gpiod_set_value(ctx->reset_gpio, 0);
+	usleep_range(9000, 10000);
+
+	return 0;
+}
+
+static int send_mipi_cmds(struct drm_panel *panel, const struct panel_cmd *cmds)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	unsigned int i = 0;
+	int err;
+
+	if (!cmds)
+		return -EFAULT;
+
+	for (i = 0; cmds[i].len != 0; i++) {
+		const struct panel_cmd *cmd = &cmds[i];
+
+		if (cmd->len == 2)
+			err = mipi_dsi_dcs_write(ctx->link, cmd->data[1], NULL,
+						 0);
+		else
+			err = mipi_dsi_dcs_write(ctx->link, cmd->data[1],
+						 cmd->data + 2, cmd->len - 2);
+
+		if (err < 0)
+			return err;
+
+		usleep_range((cmd->data[0]) * 1000, (1 + cmd->data[0]) * 1000);
+	}
+
+	return 0;
+}
+
+static int lg_panel_disable(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+
+	backlight_disable(ctx->backlight);
+	ctx->enabled = false;
+
+	return 0;
+}
+
+/*
+ * We can't currently re-initialise the panel properly after powering off.
+ * This function will be used when this is resolved.
+ */
+static __always_unused int lg_panel_power_off(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	int i, ret = 0;
+
+	gpiod_set_value(ctx->reset_gpio, 1);
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		ret = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_disable_loads[i]);
+		if (ret) {
+			DRM_DEV_ERROR(panel->dev,
+				      "regulator_set_load failed %d\n", ret);
+			return ret;
+		}
+	}
+
+	ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (ret) {
+		DRM_DEV_ERROR(panel->dev, "regulator_bulk_disable failed %d\n",
+			      ret);
+	}
+	return ret;
+}
+
+static int lg_panel_unprepare(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	int ret, i;
+
+	if (!ctx->prepared)
+		return 0;
+
+	ret = mipi_dsi_dcs_set_display_off(ctx->link);
+	if (ret < 0) {
+		DRM_DEV_ERROR(panel->dev,
+			      "set_display_off cmd failed ret = %d\n", ret);
+	}
+
+	msleep(120);
+
+	ret = mipi_dsi_dcs_enter_sleep_mode(ctx->link);
+	if (ret < 0) {
+		DRM_DEV_ERROR(panel->dev, "enter_sleep cmd failed ret = %d\n",
+			      ret);
+	}
+
+	/* Would call panel_power_off() */
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		ret = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_disable_loads[i]);
+		if (ret) {
+			DRM_DEV_ERROR(panel->dev,
+				      "regulator_set_load failed %d\n", ret);
+			return ret;
+		}
+	}
+
+	ctx->prepared = false;
+
+	return ret;
+}
+
+static int lg_panel_prepare(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	int err, i;
+
+	if (ctx->prepared)
+		return 0;
+
+	/* Would call panel_reset() */
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
+		err = regulator_set_load(ctx->supplies[i].consumer,
+					 regulator_enable_loads[i]);
+		if (err)
+			return err;
+	}
+
+	err = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (err < 0)
+		return err;
+
+	usleep_range(9000, 10000);
+
+	err = mipi_dsi_dcs_write(ctx->link, MIPI_DCS_SET_GAMMA_CURVE,
+				 (u8[]){ 0x02 }, 1);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev, "failed to set gamma curve: %d\n",
+			      err);
+		goto poweroff;
+	}
+
+	err = mipi_dsi_dcs_set_tear_on(ctx->link,
+				       MIPI_DSI_DCS_TEAR_MODE_VBLANK);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev, "failed to set tear on: %d\n", err);
+		goto poweroff;
+	}
+
+	err = send_mipi_cmds(panel, &lg_sw43408_on_cmds_1[0]);
+
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev,
+			      "failed to send DCS Init 1st Code: %d\n", err);
+		goto poweroff;
+	}
+
+	err = mipi_dsi_dcs_exit_sleep_mode(ctx->link);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev, "failed to exit sleep mode: %d\n",
+			      err);
+		goto poweroff;
+	}
+
+	msleep(135);
+
+	err = mipi_dsi_dcs_write(ctx->link, MIPI_DSI_COMPRESSION_MODE,
+				 (u8[]){ 0x11 }, 0);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev,
+			      "failed to set compression mode: %d\n", err);
+		goto poweroff;
+	}
+
+	err = send_mipi_cmds(panel, &lg_sw43408_on_cmds_2[0]);
+
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev,
+			      "failed to send DCS Init 2nd Code: %d\n", err);
+		goto poweroff;
+	}
+
+	err = mipi_dsi_dcs_set_display_on(ctx->link);
+	if (err < 0) {
+		DRM_DEV_ERROR(panel->dev, "failed to Set Display ON: %d\n",
+			      err);
+		goto poweroff;
+	}
+
+	msleep(120);
+
+	ctx->prepared = true;
+
+	return 0;
+
+poweroff:
+	gpiod_set_value(ctx->reset_gpio, 1);
+	regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	return err;
+}
+
+static int lg_panel_enable(struct drm_panel *panel)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	struct drm_dsc_picture_parameter_set pps;
+	int ret;
+
+	if (ctx->enabled)
+		return 0;
+
+	ret = backlight_enable(ctx->backlight);
+	if (ret) {
+		DRM_DEV_ERROR(panel->dev, "Failed to enable backlight %d\n",
+			      ret);
+		return ret;
+	}
+
+	if (!panel->dsc) {
+		DRM_DEV_ERROR(panel->dev, "Can't find DSC\n");
+		return -ENODEV;
+	}
+
+	drm_dsc_pps_payload_pack(&pps, panel->dsc);
+
+	ctx->enabled = true;
+
+	return 0;
+}
+
+static int lg_panel_get_modes(struct drm_panel *panel,
+			      struct drm_connector *connector)
+{
+	struct sw43408_panel *ctx = to_panel_info(panel);
+	const struct drm_display_mode *m = ctx->mode;
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_duplicate(connector->dev, m);
+	if (!mode) {
+		DRM_DEV_ERROR(panel->dev, "failed to add mode %ux%u\n",
+			      m->hdisplay, m->vdisplay);
+		return -ENOMEM;
+	}
+
+	connector->display_info.width_mm = m->width_mm;
+	connector->display_info.height_mm = m->height_mm;
+
+	drm_mode_set_name(mode);
+	drm_mode_probed_add(connector, mode);
+
+	return 1;
+}
+
+static int lg_panel_backlight_update_status(struct backlight_device *bl)
+{
+	struct mipi_dsi_device *dsi = bl_get_data(bl);
+	int ret = 0;
+	uint16_t brightness;
+
+	brightness = (uint16_t)backlight_get_brightness(bl);
+	/* Brightness is sent in big-endian */
+	brightness = cpu_to_be16(brightness);
+
+	ret = mipi_dsi_dcs_set_display_brightness(dsi, brightness);
+	return ret;
+}
+
+static int lg_panel_backlight_get_brightness(struct backlight_device *bl)
+{
+	struct mipi_dsi_device *dsi = bl_get_data(bl);
+	int ret = 0;
+	u16 brightness = 0;
+
+	ret = mipi_dsi_dcs_get_display_brightness(dsi, &brightness);
+	if (ret < 0)
+		return ret;
+
+	return brightness & 0xff;
+}
+
+const struct backlight_ops lg_panel_backlight_ops = {
+	.update_status = lg_panel_backlight_update_status,
+	.get_brightness = lg_panel_backlight_get_brightness,
+};
+
+static int lg_panel_backlight_init(struct sw43408_panel *ctx)
+{
+	struct device *dev = &ctx->link->dev;
+	const struct backlight_properties props = {
+		.type = BACKLIGHT_PLATFORM,
+		.brightness = 255,
+		.max_brightness = 255,
+	};
+
+	ctx->backlight = devm_backlight_device_register(dev, dev_name(dev), dev,
+							ctx->link,
+							&lg_panel_backlight_ops,
+							&props);
+
+	if (IS_ERR(ctx->backlight))
+		return dev_err_probe(dev, PTR_ERR(ctx->backlight),
+				     "Failed to create backlight\n");
+
+	return 0;
+}
+
+static const struct drm_panel_funcs panel_funcs = {
+	.disable = lg_panel_disable,
+	.unprepare = lg_panel_unprepare,
+	.prepare = lg_panel_prepare,
+	.enable = lg_panel_enable,
+	.get_modes = lg_panel_get_modes,
+};
+
+static const struct drm_display_mode sw43408_default_mode = {
+	.clock = 152340,
+
+	.hdisplay = 1080,
+	.hsync_start = 1080 + 20,
+	.hsync_end = 1080 + 20 + 32,
+	.htotal = 1080 + 20 + 32 + 20,
+
+	.vdisplay = 2160,
+	.vsync_start = 2160 + 20,
+	.vsync_end = 2160 + 20 + 4,
+	.vtotal = 2160 + 20 + 4 + 20,
+
+	.width_mm = 62,
+	.height_mm = 124,
+
+	.type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+};
+
+static const struct of_device_id panel_of_match[] = {
+	{ .compatible = "lg,sw43408", .data = &sw43408_default_mode },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, panel_of_match);
+
+static int panel_add(struct sw43408_panel *ctx)
+{
+	struct device *dev = &ctx->link->dev;
+	int i, ret;
+
+	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++)
+		ctx->supplies[i].supply = regulator_names[i];
+
+	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies),
+				      ctx->supplies);
+	if (ret < 0)
+		return ret;
+
+	ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
+	if (IS_ERR(ctx->reset_gpio)) {
+		DRM_DEV_ERROR(dev, "cannot get reset gpio %ld\n",
+			      PTR_ERR(ctx->reset_gpio));
+		return PTR_ERR(ctx->reset_gpio);
+	}
+
+	ret = lg_panel_backlight_init(ctx);
+	if (ret < 0)
+		return ret;
+
+	drm_panel_init(&ctx->base, dev, &panel_funcs, DRM_MODE_CONNECTOR_DSI);
+
+	drm_panel_add(&ctx->base);
+	return ret;
+}
+
+static int panel_probe(struct mipi_dsi_device *dsi)
+{
+	struct sw43408_panel *ctx;
+	struct drm_dsc_config *dsc;
+	int err;
+
+	ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+
+	ctx->mode = of_device_get_match_data(&dsi->dev);
+	dsi->mode_flags = MIPI_DSI_MODE_LPM;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->lanes = 4;
+
+	ctx->link = dsi;
+	mipi_dsi_set_drvdata(dsi, ctx);
+
+	err = panel_add(ctx);
+	if (err < 0)
+		return err;
+
+	/* The panel is DSC panel only, set the dsc params */
+	dsc = devm_kzalloc(&dsi->dev, sizeof(*dsc), GFP_KERNEL);
+	if (!dsc)

drivers/gpu/drm/panel/panel-lg-sw43408.c line 541

Quoted 10 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +10 -0
+		return -ENOMEM;
+
+	dsc->dsc_version_major = 0x1;
+	dsc->dsc_version_minor = 0x1;
+
+	dsc->slice_height = 16;
+	dsc->slice_width = 540;
+	dsc->slice_count = 1;
+	dsc->bits_per_component = 8;
+	dsc->bits_per_pixel = 8;

Note that this field holds 4 fractional bits, this should be 8 << 4.

That's what drm_dsc_pps_payload_pack() expects and returns, but not what the DSC implementation in DSI nor DPU1 expects until this lands:

https://lore.kernel.org/linux-arm-msm/[email protected]/

- Marijn

Quoted 48 lines
drivers/gpu/drm/panel/panel-lg-sw43408.c new file +45 -0
+	dsc->block_pred_enable = true;
+
+	ctx->base.dsc = dsc;
+
+	return mipi_dsi_attach(dsi);
+}
+
+static int panel_remove(struct mipi_dsi_device *dsi)
+{
+	struct sw43408_panel *ctx = mipi_dsi_get_drvdata(dsi);
+	int err;
+
+	err = lg_panel_unprepare(&ctx->base);
+	if (err < 0)
+		DRM_DEV_ERROR(&dsi->dev, "failed to unprepare panel: %d\n",
+			      err);
+
+	err = lg_panel_disable(&ctx->base);
+	if (err < 0)
+		DRM_DEV_ERROR(&dsi->dev, "failed to disable panel: %d\n", err);
+
+	err = mipi_dsi_detach(dsi);
+	if (err < 0)
+		DRM_DEV_ERROR(&dsi->dev, "failed to detach from DSI host: %d\n",
+			      err);
+
+	if (ctx->base.dev)
+		drm_panel_remove(&ctx->base);
+
+	return 0;
+}
+
+static struct mipi_dsi_driver panel_driver = {
+	.driver = {
+		.name = "panel-lg-sw43408",
+		.of_match_table = panel_of_match,
+	},
+	.probe = panel_probe,
+	.remove = panel_remove,
+};
+module_mipi_dsi_driver(panel_driver);
+
+MODULE_AUTHOR("Sumit Semwal <[email protected]>");
+MODULE_DESCRIPTION("LG SW436408 MIPI-DSI LED panel");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.36.1