diff --git a/Documentation/devicetree/bindings/display/panel/google,hk3.yaml b/Documentation/devicetree/bindings/display/panel/google,hk3.yaml new file mode 100644 index 0000000000..1548826727 --- /dev/null +++ b/Documentation/devicetree/bindings/display/panel/google,hk3.yaml @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/panel/google,hk3.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Google HK3 AMOLED DSI panel + +description: + The HK3 is the 1344x2992 command-mode AMOLED panel of the Google Pixel + 8 Pro. It takes DSC 1.2 compressed pixel data (two 672x187 slices at 8 + bits per pixel) over four MIPI DSI lanes, reports its refresh timing on + a tearing effect (TE) line and runs at 60 or 120 Hz. + +maintainers: + - Brett-Michael Green + +allOf: + - $ref: panel-common.yaml# + +properties: + compatible: + const: google,hk3 + + reg: + maxItems: 1 + + reset-gpios: true + + vddi-supply: + description: I/O supply + + vddd-supply: + description: Digital core supply + + vci-supply: + description: Analog supply + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include + + dsi { + #address-cells = <1>; + #size-cells = <0>; + + panel@0 { + compatible = "google,hk3"; + reg = <0>; + reset-gpios = <&gpp0 0 GPIO_ACTIVE_LOW>; + vci-supply = <&vci>; + vddi-supply = <&vddi>; + vddd-supply = <&vddd>; + }; + }; + +... diff --git a/Documentation/devicetree/bindings/display/samsung/google,gs201-decon.yaml b/Documentation/devicetree/bindings/display/samsung/google,gs201-decon.yaml index 58709681c6..baf0a8b90c 100644 --- a/Documentation/devicetree/bindings/display/samsung/google,gs201-decon.yaml +++ b/Documentation/devicetree/bindings/display/samsung/google,gs201-decon.yaml @@ -10,9 +10,9 @@ maintainers: - Derek Ross description: - The DECON is the display controller of the gs201 (Tensor G2) and zumapro - (Tensor G4) display pipelines. It blends up to six or fourteen windows, - respectively, each fed by a DPP read DMA + The DECON is the display controller of the gs201 (Tensor G2), zuma + (Tensor G3) and zumapro (Tensor G4) display pipelines. It blends up to + six (gs201) or fourteen windows, each fed by a DPP read DMA channel, compresses the result with DSC and hands it to a DSIM. In command mode a frame is sent on each tearing effect (TE) pulse of the panel; register writes are double-buffered and take effect at the @@ -22,6 +22,7 @@ properties: compatible: enum: - google,gs201-decon + - google,zuma-decon - google,zumapro-decon reg: diff --git a/Documentation/devicetree/bindings/display/samsung/google,gs201-dsim.yaml b/Documentation/devicetree/bindings/display/samsung/google,gs201-dsim.yaml index e70bda177c..db2f48a8cb 100644 --- a/Documentation/devicetree/bindings/display/samsung/google,gs201-dsim.yaml +++ b/Documentation/devicetree/bindings/display/samsung/google,gs201-dsim.yaml @@ -14,8 +14,8 @@ description: pipeline. It takes pixel data from a DECON and drives up to four data lanes through a combined D-PHY/C-PHY, in video or command mode, with DSC slice packing and TE-based command scheduling. Panels are described - as child nodes. The Tensor G4 (zumapro) has the same DSIM, at the same - register layout. + as child nodes. The Tensor G3 (zuma) and Tensor G4 (zumapro) have the + same DSIM, at the same register layout. allOf: - $ref: /schemas/display/dsi-controller.yaml# @@ -25,7 +25,9 @@ properties: oneOf: - const: google,gs201-dsim - items: - - const: google,zumapro-dsim + - enum: + - google,zuma-dsim + - google,zumapro-dsim - const: google,gs201-dsim reg: diff --git a/MAINTAINERS b/MAINTAINERS index 1a68316b1c..a41d259607 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8148,6 +8148,12 @@ T: git https://gitlab.freedesktop.org/drm/misc/kernel.git F: drivers/gpu/drm/gud/ F: include/drm/gud.h +DRM DRIVER FOR GOOGLE HK3 PANELS +M: Brett-Michael Green +S: Maintained +F: Documentation/devicetree/bindings/display/panel/google,hk3.yaml +F: drivers/gpu/drm/panel/panel-google-hk3.c + DRM DRIVER FOR GOOGLE TG4C PANELS M: W4HO <87742609+W4HO-ham@users.noreply.github.com> S: Maintained diff --git a/arch/arm64/boot/dts/exynos/google/zuma-husky.dts b/arch/arm64/boot/dts/exynos/google/zuma-husky.dts index b822ba3077..58f8f90924 100644 --- a/arch/arm64/boot/dts/exynos/google/zuma-husky.dts +++ b/arch/arm64/boot/dts/exynos/google/zuma-husky.dts @@ -168,6 +168,18 @@ no-map; }; + /* + * DECON's scanout buffers, below 4 GiB for DPP0's 32-bit DMA, + * in RAM that stock leaves free. + */ + display_pool: display-pool { + compatible = "shared-dma-pool"; + reusable; + size = <0x04000000>; + alignment = <0x0 0x00200000>; + alloc-ranges = <0x0 0xc4000000 0x10000000>; + }; + /* * All of the Wi-Fi chip's DMA buffers come from this pool, below * 4 GiB, as on the Pixel 7 Pro: it keeps driver bugs and stray @@ -207,6 +219,39 @@ }; }; +/* + * DECON0 takes the display over from simple-framebuffer and flips DPP0 + * between scanout buffers. It scans out to DSIM0, so gs-decon can switch + * the link and the panel between 60 and 120 Hz. + */ +&decon0 { + memory-region = <&display_pool>, <&cont_splash_mem>; + memory-region-names = "pool", "boot-framebuffer"; + status = "okay"; + + port { + decon0_out: endpoint { + remote-endpoint = <&dsi0_in>; + }; + }; +}; + +/* The HK3, running as the bootloader left it: no reset or supply control. */ +&dsi0 { + status = "okay"; + + panel@0 { + compatible = "google,hk3"; + reg = <0>; + }; + + port { + dsi0_in: endpoint { + remote-endpoint = <&decon0_out>; + }; + }; +}; + /* * Wi-Fi: the BCM4398 on pcie_1, one Gen3 lane as on stock. Its DMA * buffers come from wifi_dma_pool. diff --git a/arch/arm64/boot/dts/exynos/google/zuma.dtsi b/arch/arm64/boot/dts/exynos/google/zuma.dtsi index 3e7f5ce278..209e23b744 100644 --- a/arch/arm64/boot/dts/exynos/google/zuma.dtsi +++ b/arch/arm64/boot/dts/exynos/google/zuma.dtsi @@ -879,6 +879,29 @@ }; }; + dsi0: dsi@19440000 { + compatible = "google,zuma-dsim", "google,gs201-dsim"; + reg = <0x19440000 0x300>, <0x19460100 0x700>, + <0x19460000 0x100>; + reg-names = "dsi", "dphy", "dphy-extra"; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + /* Scans out what the bootloader set up; no panel or clock control. */ + decon0: display-controller@19470000 { + compatible = "google,zuma-decon"; + reg = <0x19470000 0x2000>, <0x19900000 0x1000>; + reg-names = "main", "dma"; + interrupts = , + , + ; + interrupt-names = "frame_start", "frame_done", "extra"; + status = "disabled"; + }; + cmu_top: clock-controller@26040000 { compatible = "google,zuma-cmu-top"; reg = <0x26040000 0x8000>; diff --git a/drivers/gpu/drm/google/gs-decon.c b/drivers/gpu/drm/google/gs-decon.c index 4d686e0e91..cbeeddc11d 100644 --- a/drivers/gpu/drm/google/gs-decon.c +++ b/drivers/gpu/drm/google/gs-decon.c @@ -33,8 +33,9 @@ * * Register layout from Google's GPL display driver * (google-modules/display/samsung/cal_9845/regs-decon.h and regs-dpp.h), - * which gs201 shares with gs101. G4 offsets and the fourteen-window mask - * follow cal_9865/regs-decon.h and regs-dpp.h in the same GPL driver. + * which gs201 shares with gs101. G3 and G4 offsets and the fourteen-window + * mask follow cal_9865/regs-decon.h and regs-dpp.h in the same GPL driver, + * which builds that CAL for both. */ #include @@ -232,6 +233,30 @@ static const struct drm_display_mode tegu_decon_modes[] = { TEGU_DECON_MODE(120), }; +/* + * The Pixel 8 Pro's HK3 at 1344x2992, from panel-gs-hk3.c, at 60 Hz (the + * bootloader's) and 120 Hz. + */ +#define HK3_DECON_MODE(hz) { \ + .clock = (1344 + 80 + 24 + 42) * (2992 + 12 + 4 + 22) * (hz) / 1000, \ + .hdisplay = 1344, \ + .hsync_start = 1344 + 80, \ + .hsync_end = 1344 + 80 + 24, \ + .htotal = 1344 + 80 + 24 + 42, \ + .vdisplay = 2992, \ + .vsync_start = 2992 + 12, \ + .vsync_end = 2992 + 12 + 4, \ + .vtotal = 2992 + 12 + 4 + 22, \ + .width_mm = 70, \ + .height_mm = 155, \ + .type = DRM_MODE_TYPE_DRIVER, \ +} + +static const struct drm_display_mode hk3_decon_modes[] = { + HK3_DECON_MODE(60), + HK3_DECON_MODE(120), +}; + struct gs_decon_soc_data { const struct drm_display_mode *modes; unsigned int num_modes; @@ -265,6 +290,19 @@ static const struct gs_decon_soc_data zumapro_decon_data = { .floors_optional = true, }; +/* G3 shares G4's CAL (cal_9865) and DECON0 registers. */ +static const struct gs_decon_soc_data zuma_decon_data = { + .modes = hk3_decon_modes, + .num_modes = ARRAY_SIZE(hk3_decon_modes), + .image_size_reg = 0x001c, + .source_offset_reg = 0x0018, + .shadow_update_mask = SHD_REG_UP_REQ_FLIP(0x3fff), + .separate_source_height = true, + .padded_pitch = true, + .start_hw_trigger = true, + .floors_optional = true, +}; + #define GS_DECON_BOOT_HZ 60 struct gs_decon { @@ -1542,6 +1580,7 @@ static void gs_decon_shutdown(struct platform_device *pdev) static const struct of_device_id gs_decon_of_match[] = { { .compatible = "google,gs201-decon", .data = &gs201_decon_data }, + { .compatible = "google,zuma-decon", .data = &zuma_decon_data }, { .compatible = "google,zumapro-decon", .data = &zumapro_decon_data }, { /* sentinel */ } }; diff --git a/drivers/gpu/drm/google/gs-dsim-cmd.c b/drivers/gpu/drm/google/gs-dsim-cmd.c index a332f8b0fd..cdb67ffd0c 100644 --- a/drivers/gpu/drm/google/gs-dsim-cmd.c +++ b/drivers/gpu/drm/google/gs-dsim-cmd.c @@ -123,6 +123,16 @@ static const struct gs_dsim_rate gs_dsim_rates[][2] = { { .hz = 60, .underrun = 0x18c8, .te_ctrl1 = 0x2a82306d }, { .hz = 120, .underrun = 0x02a0, .te_ctrl1 = 0x15411836 }, }, + /* + * Pixel 8 Pro, HK3: 4 lanes at 1368 Mbit/s (word clock 85.5 MHz), + * DSC 3:1, 1344x2992, TE idle 350 us. Google's dsim_calc_underrun() + * gives the bootloader's 60 Hz value exactly at that rate, so the + * 120 Hz one is the formula's too. + */ + { + { .hz = 60, .underrun = 0x2235, .te_ctrl1 = 0x34c53c1e }, + { .hz = 120, .underrun = 0x06a7, .te_ctrl1 = 0x1a621e0f }, + }, }; struct gs_dsim { diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig index f094fcda72..625290c7fa 100644 --- a/drivers/gpu/drm/panel/Kconfig +++ b/drivers/gpu/drm/panel/Kconfig @@ -213,6 +213,18 @@ config DRM_PANEL_DSI_CM DRM panel driver for DSI command mode panels with support for embedded and external backlights. +config DRM_PANEL_GOOGLE_HK3 + tristate "Google HK3 DSI command mode panel" + depends on OF + depends on DRM_MIPI_DSI + depends on BACKLIGHT_CLASS_DEVICE + help + Say Y or M here if you want to enable support for the Google + HK3 1344x2992 command-mode AMOLED panel, found in the Google + Pixel 8 Pro. The driver takes over the panel the bootloader left + running, switches it between 60 and 120 Hz, puts it to sleep and + exposes its brightness as a backlight. + config DRM_PANEL_GOOGLE_TG4C tristate "Google TG4C DSI command mode panel" depends on OF diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile index 23955a31d9..93ed5eecea 100644 --- a/drivers/gpu/drm/panel/Makefile +++ b/drivers/gpu/drm/panel/Makefile @@ -14,6 +14,7 @@ obj-$(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6) += panel-boe-tv101wum-nl6.o obj-$(CONFIG_DRM_PANEL_CHIPONE_ICNA35XX) += panel-chipone-icna35xx.o obj-$(CONFIG_DRM_PANEL_CHIPWEALTH_CH13726A) += panel-chipwealth-ch13726a.o obj-$(CONFIG_DRM_PANEL_DSI_CM) += panel-dsi-cm.o +obj-$(CONFIG_DRM_PANEL_GOOGLE_HK3) += panel-google-hk3.o obj-$(CONFIG_DRM_PANEL_GOOGLE_TG4C) += panel-google-tg4c.o obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o diff --git a/drivers/gpu/drm/panel/panel-google-hk3.c b/drivers/gpu/drm/panel/panel-google-hk3.c new file mode 100644 index 0000000000..e1842d92fc --- /dev/null +++ b/drivers/gpu/drm/panel/panel-google-hk3.c @@ -0,0 +1,381 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Google HK3 DSI command-mode AMOLED panel (Google Pixel 8 Pro) + * + * Command sequences from Google's MIT-licensed panel driver + * (kernel/devices/google/shusky/display/panel-gs-hk3.c). + * + * The bootloader powers the panel on, initialises it and leaves it running + * at 60 Hz. The driver takes it over as it is and never resets it or + * touches its supplies: it puts it to sleep and wakes it (sleep in/out, + * the panel keeps its registers), switches it between 60 and 120 Hz in + * high-speed (HS) manual mode and sets its brightness. A panel without + * the bootloader's initialisation is not handled. + */ + +#include +#include +#include +#include + +#include