From patchwork Sun Aug 9 21:51:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 11706835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E0F9913 for ; Sun, 9 Aug 2020 21:52:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5C3C320709 for ; Sun, 9 Aug 2020 21:52:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hS0SjdPK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C3C320709 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9D19E6E133; Sun, 9 Aug 2020 21:52:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1202E6E133 for ; Sun, 9 Aug 2020 21:51:59 +0000 (UTC) Received: by mail-lj1-x243.google.com with SMTP id t23so7539684ljc.3 for ; Sun, 09 Aug 2020 14:51:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f2zW0kVKZw0Q6+2fznTr2R798o2bszAlCE1c0i0bfQ8=; b=hS0SjdPKscry2rWAA4o7k8T5BOFFcgP0QfAdRsDr29xMRFR0lwCN3uQ4jLkAWfSao+ xir7589ytdBcQrIR6NxIN0Nz0qlHdmUhBQv09xvFOqrQF2KVvxFzuLtFvPUf5ndsRe8W NgbRjI4L5TRWB7sJpp19Guxce9Lp6ZnT3+PhEpBQsqa4h7tB+47Nq35hlMNXXUjrUOKc hqbYTjMHMmWu+N4YEgNzIvtzHkVXquY1vtmCm3+NmG/+sDnFFhPmoaBchG/KGl7t9cWo m2Q4qW4hCNK5zQmSi5JiuJHSBqUnfOEocNnbyoA+OwwhlnEzwUqyjpdLVEuiaMTGn9Vu z2pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f2zW0kVKZw0Q6+2fznTr2R798o2bszAlCE1c0i0bfQ8=; b=GHtiQH6Io3wJncDYZwgmP9NDqsBpNcyKwkxHi2VhVFnfbouMkfYpzPE1PhewhniYKv MauRAs1djc7rLfaiqjSMqhYULNmLa7trQXHlelZXvtFA7uNzBPLesggqyLxqExfaBtw6 pooHSlp36lZsWAbg71lBCffNPi+VfXBLjqg7p9avFmdUcnWMTPBd+3ftldLClygiZjMV iySFPwJXpcM3/34C3t87NHQPqvLpZL6evW9k2gKjKyQuoGN+In5GUZoG69QBsV/fbylS 1kSpv8uiL404OJ6WbjorzwKEoJCj27tga9aIrobHr74qKbduqNSAL7AOAbLsTw76hrX6 ljlg== X-Gm-Message-State: AOAM532d8bdZLPdNrhZJtu6B92t+p7MCIzfwQzn+NDnmK2WVbNJNHU9+ pC1FOXdOcBYnifRYKzCmhOErEg== X-Google-Smtp-Source: ABdhPJzIgq8D/ril5g++ZBvw/J39NKpixMJgqCX9fqCI3bqpFxlTlPSP/t57T5fXM1zS7PGzh+vO+w== X-Received: by 2002:a2e:b607:: with SMTP id r7mr10101008ljn.356.1597009917475; Sun, 09 Aug 2020 14:51:57 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id t20sm8277045ljd.12.2020.08.09.14.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 14:51:56 -0700 (PDT) From: Linus Walleij To: Thierry Reding , Sam Ravnborg , Stephan Gerhold , =?utf-8?q?Pawe=C5=82_Chmiel?= Subject: [PATCH 4/4] drm/panel: s6e63m0: Add code to identify panel Date: Sun, 9 Aug 2020 23:51:04 +0200 Message-Id: <20200809215104.1830206-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200809215104.1830206-1-linus.walleij@linaro.org> References: <20200809215104.1830206-1-linus.walleij@linaro.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We add code to identify a few different panels mounted on the s6e63m0 controller. This is necessary to achieve the proper biasing with DSI versions of the panel. Cc: Stephan Gerhold Cc: Paweł Chmiel Signed-off-by: Linus Walleij --- drivers/gpu/drm/panel/panel-samsung-s6e63m0.c | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c index b25021bdd724..0b22e382b80f 100644 --- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c +++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c @@ -26,12 +26,21 @@ #define MCS_ELVSS_ON 0xb1 #define MCS_MIECTL1 0xc0 #define MCS_BCMODE 0xc1 +#define MCS_READ_ID1 0xda +#define MCS_READ_ID2 0xdb +#define MCS_READ_ID3 0xdc +#define MCS_LEVEL_2_KEY 0xf0 +#define MCS_MTP_KEY 0xf1 #define MCS_DISCTL 0xf2 #define MCS_SRCCTL 0xf6 #define MCS_IFCTL 0xf7 #define MCS_PANELCTL 0xF8 #define MCS_PGAMMACTL 0xfa +#define S6E63M0_LCD_ID_VALUE_M2 0xA4 +#define S6E63M0_LCD_ID_VALUE_SM2 0xB4 +#define S6E63M0_LCD_ID_VALUE_SM2_1 0xB6 + #define NUM_GAMMA_LEVELS 11 #define GAMMA_TABLE_COUNT 23 @@ -91,6 +100,7 @@ struct s6e63m0 { int (*dcs_write)(struct device *dev, const u8 *data, size_t len); struct drm_panel panel; struct backlight_device *bl_dev; + u8 lcd_type; struct regulator_bulk_data supplies[2]; struct gpio_desc *reset_gpio; @@ -159,6 +169,48 @@ static void s6e63m0_dcs_write(struct s6e63m0 *ctx, const u8 *data, size_t len) s6e63m0_dcs_write(ctx, d, ARRAY_SIZE(d)); \ }) + +static int s6e63m0_check_lcd_type(struct s6e63m0 *ctx) +{ + u8 id1, id2, id3; + int ret; + + s6e63m0_dcs_read(ctx, MCS_READ_ID1, &id1); + s6e63m0_dcs_read(ctx, MCS_READ_ID2, &id2); + s6e63m0_dcs_read(ctx, MCS_READ_ID3, &id3); + + ret = s6e63m0_clear_error(ctx); + if (ret) { + DRM_DEV_ERROR(ctx->dev, "error checking LCD type (%d)\n", + ret); + ctx->lcd_type = 0x00; + return ret; + } + + DRM_DEV_INFO(ctx->dev, "MTP ID: %02x %02x %02x\n", id1, id2, id3); + + /* We attempt to detect what panel is mounted on the controller */ + switch (id2) { + case S6E63M0_LCD_ID_VALUE_M2: + DRM_DEV_INFO(ctx->dev, + "detected LCD panel AMS397GE MIPI M2\n"); + break; + case S6E63M0_LCD_ID_VALUE_SM2: + case S6E63M0_LCD_ID_VALUE_SM2_1: + DRM_DEV_INFO(ctx->dev, + "detected LCD panel AMS397GE MIPI SM2\n"); + break; + default: + DRM_DEV_INFO(ctx->dev, + "unknown LCD panel type %02x\n", id2); + break; + } + + ctx->lcd_type = id2; + + return 0; +} + static void s6e63m0_init(struct s6e63m0 *ctx) { s6e63m0_dcs_write_seq_static(ctx, MCS_PANELCTL, @@ -312,6 +364,15 @@ static int s6e63m0_prepare(struct drm_panel *panel) if (ret < 0) return ret; + /* Magic to unlock level 2 control of the display */ + s6e63m0_dcs_write_seq_static(ctx, MCS_LEVEL_2_KEY, 0x5a, 0x5a); + /* Magic to unlock MTP reading */ + s6e63m0_dcs_write_seq_static(ctx, MCS_MTP_KEY, 0x5a, 0x5a); + + ret = s6e63m0_check_lcd_type(ctx); + if (ret < 0) + return ret; + s6e63m0_init(ctx); ret = s6e63m0_clear_error(ctx);