diff --git a/Documentation/devicetree/bindings/display/panel/samsung,s6e3fc5.yaml b/Documentation/devicetree/bindings/display/panel/samsung,s6e3fc5.yaml new file mode 100644 index 0000000000..5d13b1885e --- /dev/null +++ b/Documentation/devicetree/bindings/display/panel/samsung,s6e3fc5.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/samsung,s6e3fc5.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S6E3FC5 AMOLED DSI panel + +description: + The S6E3FC5 is a display driver IC from Samsung Mobile Display, driving + the 1080x2400 command-mode AMOLED panel of the Google Pixel 7a. The panel + takes DSC-compressed pixel data over four MIPI DSI lanes and reports its + refresh timing on a tearing effect (TE) line. + +maintainers: + - Derek Ross + - cx3301J + +allOf: + - $ref: panel-common.yaml# + +properties: + compatible: + const: samsung,s6e3fc5 + + reg: + maxItems: 1 + + reset-gpios: true + + vci-supply: + description: Analog supply + + vddi-supply: + description: I/O supply + +required: + - compatible + - reg + - reset-gpios + +unevaluatedProperties: false + +examples: + - | + #include + + dsi { + #address-cells = <1>; + #size-cells = <0>; + + panel@0 { + compatible = "samsung,s6e3fc5"; + reg = <0>; + reset-gpios = <&gpa7 1 GPIO_ACTIVE_LOW>; + vci-supply = <&panel_vci>; + vddi-supply = <&panel_vddi>; + width-mm = <64>; + height-mm = <141>; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index a44d4a1fbe..1444c986bd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8498,6 +8498,12 @@ S: Maintained F: Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml F: drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c +DRM DRIVER FOR SAMSUNG S6E3FC5 PANELS +M: cx3301J +S: Maintained +F: Documentation/devicetree/bindings/display/panel/samsung,s6e3fc5.yaml +F: drivers/gpu/drm/panel/panel-samsung-s6e3fc5.c + DRM DRIVER FOR SAMSUNG S6E3HC3 PANELS M: saiththerobo S: Maintained diff --git a/arch/arm64/boot/dts/exynos/google/gs201-lynx.dts b/arch/arm64/boot/dts/exynos/google/gs201-lynx.dts index b43ff60bad..e97b412a5f 100644 --- a/arch/arm64/boot/dts/exynos/google/gs201-lynx.dts +++ b/arch/arm64/boot/dts/exynos/google/gs201-lynx.dts @@ -41,8 +41,8 @@ /* * ABL leaves DECON0 -> DSIM0 -> panel (sdc-s6e3fc5) running in * command mode with DPP0 scanning 0xfac00000 (RDMA_BASEADDR_Y8, - * read on this phone). There is no panel driver, so no panel - * phandle; the size comes from this node. + * read on this phone). The panel driver is not a phandle here; the + * size comes from this node. */ framebuffer0: framebuffer@fac00000 { compatible = "simple-framebuffer"; @@ -67,6 +67,29 @@ regulator-boot-on; }; + /* + * Panel rails: vci is S2MPG12 LDO27M and vddi is S2MPG13 BUCKA. + * Neither PMIC has a regulator driver yet, so these stay as the + * bootloader left them (always on, no control). + */ + panel_vddi: regulator-panel-vddi { + compatible = "regulator-fixed"; + regulator-name = "panel-vddi"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + }; + + panel_vci: regulator-panel-vci { + compatible = "regulator-fixed"; + regulator-name = "panel-vci"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + regulator-boot-on; + }; + /* * ABL adds sec_dram, sec_pt and pkvm_guest_firmware to this tree * itself. Stock's tui, mfc_fw and famodel are pools the kernel @@ -91,6 +114,19 @@ reg = <0x0 0xfac00000 (1080 * 2400 * 4)>; no-map; }; + + /* + * Scanout buffers for gs-decon. Inside the c3080000-d80fffff + * System RAM block from /proc/iomem on the phone; below 4 GiB + * because DPP0 takes 32-bit addresses. + */ + display_pool: display-pool { + compatible = "shared-dma-pool"; + reusable; + size = <0x5c00000>; + alignment = <0x0 0x200000>; + alloc-ranges = <0x0 0xc4000000 0x5c00000>; + }; }; }; @@ -305,3 +341,24 @@ &usi_apm1 { status = "okay"; }; + +&dsi0 { + status = "disabled"; + panel: panel@0 { + compatible = "samsung,s6e3fc5"; + reg = <0>; + reset-gpios = <&gpa7 1 GPIO_ACTIVE_LOW>; + vci-supply = <&panel_vci>; + vddi-supply = <&panel_vddi>; + width-mm = <64>; + height-mm = <141>; + }; +}; + +&decon0 { + memory-region = <&display_pool>, <&cont_splash_mem>; + memory-region-names = "pool", "boot-framebuffer"; + status = "disabled"; +}; + +&gpu { status = "okay"; }; diff --git a/drivers/gpu/drm/google/gs-decon.c b/drivers/gpu/drm/google/gs-decon.c index 1a5dd8c216..5e30006f8d 100644 --- a/drivers/gpu/drm/google/gs-decon.c +++ b/drivers/gpu/drm/google/gs-decon.c @@ -274,6 +274,8 @@ struct gs_decon_soc_data { bool hold_boot_fb; /* a VT switch around system sleep only with the fbdev console */ bool vt_switch_fbdev_only; + /* the panel driver owns the modes, not this table */ + bool panel_modes; }; static const struct gs_decon_soc_data gs201_decon_data = { @@ -323,6 +325,37 @@ static const struct gs_decon_soc_data zuma_decon_data = { .floors_optional = true, }; +/* + * Pixel 7a: 1080x2400, 32/12/26 horizontal and 12/4/26 vertical blanks. + * Same register layout as gs201_decon_data; only the mode differs. + */ +static const struct drm_display_mode gs201_lynx_decon_modes[] = { + { + .clock = (1080 + 32 + 12 + 26) * (2400 + 12 + 4 + 26) * 60 / 1000, + .hdisplay = 1080, + .hsync_start = 1080 + 32, + .hsync_end = 1080 + 32 + 12, + .htotal = 1080 + 32 + 12 + 26, + .vdisplay = 2400, + .vsync_start = 2400 + 12, + .vsync_end = 2400 + 12 + 4, + .vtotal = 2400 + 12 + 4 + 26, + .width_mm = 64, + .height_mm = 141, + .type = DRM_MODE_TYPE_DRIVER, + }, +}; + +static const struct gs_decon_soc_data gs201_lynx_decon_data = { + .padded_pitch = true, + .modes = gs201_lynx_decon_modes, + .num_modes = ARRAY_SIZE(gs201_lynx_decon_modes), + .panel_modes = true, + .image_size_reg = RDMA_IMG_SIZE, + .source_offset_reg = RDMA_SRC_OFFSET, + .shadow_update_mask = SHD_REG_UP_REQ_FLIP(SHD_REG_UP_REQ_ALL_WIN), +}; + #define GS_DECON_BOOT_HZ 60 struct gs_decon { @@ -445,6 +478,20 @@ static void gs_decon_dump(struct gs_decon *dc) readl(dc->dma + RDMA_SRC_HEIGHT_G4)); } +static void gs_decon_pick_lynx_soc(struct gs_decon *dc) +{ + struct device_node *dsim, *panel; + + dsim = of_graph_get_remote_node(dc->dev->of_node, 0, 0); + if (!dsim) + return; + panel = of_get_compatible_child(dsim, "samsung,s6e3fc5"); + if (panel) + dc->soc = &gs201_lynx_decon_data; + of_node_put(panel); + of_node_put(dsim); +} + /* * Checks that the pipeline is the one this driver knows how to drive: * DECON on in command mode, DPP0 scanning a linear 8888 buffer, full @@ -1129,8 +1176,22 @@ static const struct drm_crtc_funcs gs_decon_crtc_funcs = { static int gs_decon_connector_get_modes(struct drm_connector *connector) { struct gs_decon *dc = drm_to_decon(connector->dev); - int i, count = 0; + int i, count; + + if (dc->dsim && dc->soc->panel_modes) { + count = gs_dsim_panel_get_modes(dc->dsim, connector); + if (count > 0) { + struct drm_display_mode *mode; + + mode = list_first_entry(&connector->probed_modes, + struct drm_display_mode, head); + connector->display_info.width_mm = mode->width_mm; + connector->display_info.height_mm = mode->height_mm; + return count; + } + } + count = 0; for (i = 0; i < dc->soc->num_modes; i++) { unsigned int hz = drm_mode_vrefresh(&dc->soc->modes[i]); struct drm_display_mode *mode; @@ -1437,6 +1498,7 @@ static int gs_decon_probe(struct platform_device *pdev) dc->soc = device_get_match_data(dev); if (!dc->soc) return -ENODEV; + gs_decon_pick_lynx_soc(dc); dc->hz = GS_DECON_BOOT_HZ; dc->max_hz = GS_DECON_BOOT_HZ; spin_lock_init(&dc->lock); diff --git a/drivers/gpu/drm/google/gs-dsim-cmd.c b/drivers/gpu/drm/google/gs-dsim-cmd.c index cdb67ffd0c..58d0fd999a 100644 --- a/drivers/gpu/drm/google/gs-dsim-cmd.c +++ b/drivers/gpu/drm/google/gs-dsim-cmd.c @@ -598,6 +598,16 @@ int gs_dsim_set_refresh_rate(struct gs_dsim *dsim, unsigned int hz) } EXPORT_SYMBOL_GPL(gs_dsim_set_refresh_rate); +int gs_dsim_panel_get_modes(struct gs_dsim *dsim, + struct drm_connector *connector) +{ + if (!dsim->panel) + return 0; + + return drm_panel_get_modes(dsim->panel, connector); +} +EXPORT_SYMBOL_GPL(gs_dsim_panel_get_modes); + /** * gs_dsim_panel_sleep - switch the panel off and put it to sleep * @dsim: the DSIM diff --git a/drivers/gpu/drm/google/gs-dsim.h b/drivers/gpu/drm/google/gs-dsim.h index 3ee23574db..08282dcadc 100644 --- a/drivers/gpu/drm/google/gs-dsim.h +++ b/drivers/gpu/drm/google/gs-dsim.h @@ -20,6 +20,8 @@ unsigned int gs_dsim_refresh_rate(struct gs_dsim *dsim); bool gs_dsim_can_set_refresh_rate(struct gs_dsim *dsim, unsigned int hz); int gs_dsim_set_refresh_rate(struct gs_dsim *dsim, unsigned int hz); +int gs_dsim_panel_get_modes(struct gs_dsim *dsim, + struct drm_connector *connector); int gs_dsim_panel_sleep(struct gs_dsim *dsim); int gs_dsim_panel_wake(struct gs_dsim *dsim, bool enable); diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig index d82882275e..a1738e4f47 100644 --- a/drivers/gpu/drm/panel/Kconfig +++ b/drivers/gpu/drm/panel/Kconfig @@ -1097,6 +1097,20 @@ config DRM_PANEL_SAMSUNG_S6E3HC3 left it running: the driver sends no initialisation sequence, and the display modes come from the display controller's driver. +config DRM_PANEL_SAMSUNG_S6E3FC5 + tristate "Samsung S6E3FC5 DSI panel" + depends on GPIOLIB + depends on OF + depends on DRM_MIPI_DSI + depends on BACKLIGHT_CLASS_DEVICE + select DRM_DISPLAY_HELPER + select DRM_DISPLAY_DSC_HELPER + help + Say Y here to enable support for the Samsung S6E3FC5 panel used + on the Pixel 7a (lynx). It is a command-mode AMOLED panel with + runtime DSC configuration and two refresh rates. To compile this + driver as a module, choose M here. + config DRM_PANEL_SAMSUNG_S6E3HC4 tristate "Samsung S6E3HC4 DSI command mode panel" depends on GPIOLIB diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile index e9506c1721..69bb6ac982 100644 --- a/drivers/gpu/drm/panel/Makefile +++ b/drivers/gpu/drm/panel/Makefile @@ -105,6 +105,7 @@ obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA8) += panel-samsung-s6e3ha8.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HC3) += panel-samsung-s6e3hc3.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HC4) += panel-samsung-s6e3hc4.o +obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3FC5) += panel-samsung-s6e3fc5.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03) += panel-samsung-s6e63j0x03.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0) += panel-samsung-s6e63m0.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_SPI) += panel-samsung-s6e63m0-spi.o diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3fc5.c b/drivers/gpu/drm/panel/panel-samsung-s6e3fc5.c new file mode 100644 index 0000000000..86b60e834a --- /dev/null +++ b/drivers/gpu/drm/panel/panel-samsung-s6e3fc5.c @@ -0,0 +1,730 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Samsung S6E3FC5 DSI command-mode AMOLED panel (Google Pixel 7a) + * + * Copyright (c) 2022 Google LLC + * + * Command sequences from Google's GPL panel driver + * (google-modules/display/samsung/panel/panel-samsung-s6e3fc5.c), + * restricted to the PVT and later panels that ship in phones. + * + * The bootloader powers the panel on and leaves it running. When the + * reset line is released at probe, the driver takes the panel over as it + * is: it sends nothing until the brightness or the power state changes. + * + * Local high brightness mode (LHBM) lights a bright circle over the + * under-display fingerprint sensor. It is controlled through the backlight + * device's local_hbm_mode attribute, named as in Google's driver, and + * switches itself off after local_hbm_max_timeout milliseconds. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include