Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/panel: s6e3ha2: Add support for s6e3hf2 panel on TM2e board

This patch supports TM2e panel and the panel has 1600x2560 resolution
in 5.65" physical.

This identify panel type with compatibility string, also invoke
display mode that matches the type. So add the check code for s6e3ha2
compatibility and s6e3hf2 type and select the drm_display_mode of
default and edge type.

Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
Reviewed-by: Inki Dae <inki.dae@samsung.com>
[treding@nvidia.com: fixup checkpatch warnings]
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1492504836-19225-3-git-send-email-hoegeun.kwon@samsung.com

authored by

Hoegeun Kwon and committed by
Thierry Reding
e2af12bf 60ee02bf

+57 -7
+57 -7
drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
··· 16 16 #include <drm/drm_panel.h> 17 17 #include <linux/backlight.h> 18 18 #include <linux/gpio/consumer.h> 19 + #include <linux/of_device.h> 19 20 #include <linux/regulator/consumer.h> 20 21 21 22 #define S6E3HA2_MIN_BRIGHTNESS 0 ··· 219 218 0x1d, 0x1e, 0x1f, 0x20, 0x21 220 219 }; 221 220 221 + enum s6e3ha2_type { 222 + HA2_TYPE, 223 + HF2_TYPE, 224 + }; 225 + 226 + struct s6e3ha2_panel_desc { 227 + const struct drm_display_mode *mode; 228 + enum s6e3ha2_type type; 229 + }; 230 + 222 231 struct s6e3ha2 { 223 232 struct device *dev; 224 233 struct drm_panel panel; ··· 237 226 struct regulator_bulk_data supplies[2]; 238 227 struct gpio_desc *reset_gpio; 239 228 struct gpio_desc *enable_gpio; 229 + 230 + const struct s6e3ha2_panel_desc *desc; 240 231 }; 241 232 242 233 static int s6e3ha2_dcs_write(struct s6e3ha2 *ctx, const void *data, size_t len) ··· 296 283 static int s6e3ha2_freq_calibration(struct s6e3ha2 *ctx) 297 284 { 298 285 s6e3ha2_dcs_write_seq_static(ctx, 0xfd, 0x1c); 286 + if (ctx->desc->type == HF2_TYPE) 287 + s6e3ha2_dcs_write_seq_static(ctx, 0xf2, 0x67, 0x40, 0xc5); 299 288 s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x20, 0x39); 300 289 s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0xa0); 301 290 s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x20); 302 - s6e3ha2_dcs_write_seq_static(ctx, 0xce, 0x03, 0x3b, 0x12, 0x62, 0x40, 303 - 0x80, 0xc0, 0x28, 0x28, 0x28, 0x28, 0x39, 0xc5); 291 + 292 + if (ctx->desc->type == HA2_TYPE) 293 + s6e3ha2_dcs_write_seq_static(ctx, 0xce, 0x03, 0x3b, 0x12, 0x62, 294 + 0x40, 0x80, 0xc0, 0x28, 0x28, 295 + 0x28, 0x28, 0x39, 0xc5); 296 + else 297 + s6e3ha2_dcs_write_seq_static(ctx, 0xce, 0x03, 0x3b, 0x14, 0x6d, 298 + 0x40, 0x80, 0xc0, 0x28, 0x28, 299 + 0x28, 0x28, 0x39, 0xc5); 300 + 304 301 return 0; 305 302 } 306 303 ··· 606 583 return 0; 607 584 } 608 585 609 - static const struct drm_display_mode default_mode = { 586 + static const struct drm_display_mode s6e3ha2_mode = { 610 587 .clock = 222372, 611 588 .hdisplay = 1440, 612 589 .hsync_start = 1440 + 1, ··· 620 597 .flags = 0, 621 598 }; 622 599 600 + static const struct s6e3ha2_panel_desc samsung_s6e3ha2 = { 601 + .mode = &s6e3ha2_mode, 602 + .type = HA2_TYPE, 603 + }; 604 + 605 + static const struct drm_display_mode s6e3hf2_mode = { 606 + .clock = 247856, 607 + .hdisplay = 1600, 608 + .hsync_start = 1600 + 1, 609 + .hsync_end = 1600 + 1 + 1, 610 + .htotal = 1600 + 1 + 1 + 1, 611 + .vdisplay = 2560, 612 + .vsync_start = 2560 + 1, 613 + .vsync_end = 2560 + 1 + 1, 614 + .vtotal = 2560 + 1 + 1 + 15, 615 + .vrefresh = 60, 616 + .flags = 0, 617 + }; 618 + 619 + static const struct s6e3ha2_panel_desc samsung_s6e3hf2 = { 620 + .mode = &s6e3hf2_mode, 621 + .type = HF2_TYPE, 622 + }; 623 + 623 624 static int s6e3ha2_get_modes(struct drm_panel *panel) 624 625 { 625 626 struct drm_connector *connector = panel->connector; 627 + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel); 626 628 struct drm_display_mode *mode; 627 629 628 - mode = drm_mode_duplicate(panel->drm, &default_mode); 630 + mode = drm_mode_duplicate(panel->drm, ctx->desc->mode); 629 631 if (!mode) { 630 632 DRM_ERROR("failed to add mode %ux%ux@%u\n", 631 - default_mode.hdisplay, default_mode.vdisplay, 632 - default_mode.vrefresh); 633 + ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay, 634 + ctx->desc->mode->vrefresh); 633 635 return -ENOMEM; 634 636 } 635 637 ··· 690 642 mipi_dsi_set_drvdata(dsi, ctx); 691 643 692 644 ctx->dev = dev; 645 + ctx->desc = of_device_get_match_data(dev); 693 646 694 647 dsi->lanes = 4; 695 648 dsi->format = MIPI_DSI_FMT_RGB888; ··· 766 717 } 767 718 768 719 static const struct of_device_id s6e3ha2_of_match[] = { 769 - { .compatible = "samsung,s6e3ha2" }, 720 + { .compatible = "samsung,s6e3ha2", .data = &samsung_s6e3ha2 }, 721 + { .compatible = "samsung,s6e3hf2", .data = &samsung_s6e3hf2 }, 770 722 { } 771 723 }; 772 724 MODULE_DEVICE_TABLE(of, s6e3ha2_of_match);