Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2412451pxu; Mon, 14 Dec 2020 01:27:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtnGI5SJu2zAhtplbnDLInpWusIMGsmhohlMv5JeXG34z4bSR2gP9IaMesMS0/tBQ/i1B3 X-Received: by 2002:a17:907:20a6:: with SMTP id pw6mr22407734ejb.73.1607938057420; Mon, 14 Dec 2020 01:27:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607938057; cv=none; d=google.com; s=arc-20160816; b=R1RF69UaeUAED3Yup+6iq7OPA6qn/XeEz6pFSlFZsZ8ZNkE7t6VJ/5McoLUfgsvNmg 3moc9wRKj3Dnx9DZXGvSTTZFMjsrR/Ci1CAPhRJecRIWYAjIRU01sUujpm3T/1vOhGff k/oHPGDV4GcK5MPGu+0UOHGUzkvdva3eJ1Z4144blg48FZAO0ZQLN+wwkaQ76ESE1jQP lfe75Q4TWpDXc8DqE1GpFmS8qgbRhPGdzx2mX1qIgxS1RaozpFG1Wp+BgM26GSNIKoRh +Mkch6+LQwhbX7ae+oaGyMraN7dR93NAkOMvT4UTkTsEuAv8YObvVtlIfHHgnN2/vHQ6 yt6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=jvKjXHeKYG4rw3Vizc9nWj33YjCQBp4adDcRZBt8deI=; b=tXFQqLkI9tD4gkVjPmvUoO3mtxSAR1YPNOdGqaphfluFXzCnhk/6dw7yKdcQQ2tyuq S/IIagEGOdPXMslTMdWDD2rcEGlT0CpeqFbOq9pVhoScaugYEIjKb35Esc0R4rmtgLlH 84zuz0eXtRoKTOD06pR9/QjQHB+vcU56WMyLi6s1qu6b9vEuobqzPmvHJrJCGgSEm1WJ xx0eiGq2XIFJhu4f2obcAq9/WKeRGAJnTcfAfeR0GyhOwqYUTM0ZDH9M1NzEM4IiIi/K fcKG7EPbyYlnyIyaymaUh2zjPqhPyOFzCZKh0sYCkTTsU/HaP9sNwGMqNLnexgOvBIjz lUbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WUd0JDQq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si9321446edi.2.2020.12.14.01.27.14; Mon, 14 Dec 2020 01:27:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WUd0JDQq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406040AbgLMUp2 (ORCPT + 99 others); Sun, 13 Dec 2020 15:45:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726069AbgLMUpM (ORCPT ); Sun, 13 Dec 2020 15:45:12 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29DD4C0613CF for ; Sun, 13 Dec 2020 12:44:32 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id g18so11112756pgk.1 for ; Sun, 13 Dec 2020 12:44:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jvKjXHeKYG4rw3Vizc9nWj33YjCQBp4adDcRZBt8deI=; b=WUd0JDQqJOsJbG8wM5hvHVXSPoqsnAIOkGX93riI/lYfTHBaTAcJK/ZY3Vq7Q2sxLa oLGgqrufgmKM7Bcw6IIa+IIqYtZzE3AEOqsI9LAHeN7HbUHYSBiGTT5unkmVNdaMRekn YbGi5E+2Nod4zDkfs8z1qTKlAHraPbXPeltiKC+G5ipwpm2+QLP+EXfWjn8TWQF1OHcB Y16QQiv+U7DFozk358ELVDMC9RPJsGpnvbWsiWl42DMPuBSs09MGdScLmNJ5C9QbeIZ1 /gvPakpraO6zA6maHDgZU07t5Wz0NJCLNd95Af8Bsefv6NPg44SYGFj0GWiED9mjBdnV r0ow== 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:mime-version :content-transfer-encoding; bh=jvKjXHeKYG4rw3Vizc9nWj33YjCQBp4adDcRZBt8deI=; b=UBFEO6Fo7OvmZZqtq0wSpexiGut0Do9LmYuo5vwb+2o6bIPgxbvxj/JL126D4a8znF VBqd7gFU9K5f2LpzI7Ftukf0QEYWaRQgqVJdTbRRSZFIeSNK7DkUDIFwYqa4kOYcREb1 Ehb/TsvIxTh1PtgQyqN446wYkVoPgO3epCjSfMX1vJ8nCePUysnQ791DDbQYrxu4XJt6 sxNQGP/MTOEHzZ0cau8HXnn2nx5LuMqDuS+dbWHIWxn6y63fbvYeZ69LHy8KvA6cagEf qZY9Zcca7wGBk1gfpCr10AhfQE/ygM3JFtp1RrUIpnLOwomsOHfZEizyJ6v7dXx68nzK YdGA== X-Gm-Message-State: AOAM532+vzeBy+Acy3GsHkShEGH4oL5yFax0YLE5PPysGX4mTbcPoMLz AKddkUSLrkXb64HhiyPsYioy7LtsgUwmue08 X-Received: by 2002:a63:e246:: with SMTP id y6mr10695796pgj.412.1607892271435; Sun, 13 Dec 2020 12:44:31 -0800 (PST) Received: from glados.. ([2601:647:6000:3e5b::a27]) by smtp.gmail.com with ESMTPSA id h32sm18411821pgl.36.2020.12.13.12.44.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Dec 2020 12:44:31 -0800 (PST) From: Thomas Hebb To: linux-kernel@vger.kernel.org, Nickey Yang , Heiko Stuebner , Andrzej Hajda Cc: Thomas Hebb , Archit Taneja , Brian Norris , Daniel Vetter , David Airlie , Sandy Huang , Sean Paul , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH] drm/rockchip: dsi: move all lane config except LCDC mux to bind() Date: Sun, 13 Dec 2020 12:44:26 -0800 Message-Id: <95f16906d654057c912f089d286bd51856ee3bdf.1607892237.git.tommyhebb@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we first enable the DSI encoder, we currently program some per-chip configuration that we look up in rk3399_chip_data based on the device tree compatible we match. This data configures various parameters of the MIPI lanes, including on RK3399 whether DSI1 is slaved to DSI0 in a dual-mode configuration. It also selects which LCDC (i.e. VOP) to scan out from. This causes a problem in RK3399 dual-mode configurations, though: panel prepare() callbacks run before the encoder gets enabled and expect to be able to write commands to the DSI bus, but the bus isn't fully functional until the lane and master/slave configuration have been programmed. As a result, dual-mode panels (and possibly others too) fail to turn on when the rockchipdrm driver is initially loaded. Because the LCDC mux is the only thing we don't know until enable time (and is the only thing that can ever change), we can actually move most of the initialization to bind() and get it out of the way early. That's what this change does. (Rockchip's 4.4 BSP kernel does it in mode_set(), which also avoids the issue, but bind() seems like the more correct place to me.) Tested on a Google Scarlet board (Acer Chromebook Tab 10), which has a Kingdisplay KD097D04 dual-mode panel. Prior to this change, the panel's backlight would turn on but no image would appear when initially loading rockchipdrm. If I kept rockchipdrm loaded and reloaded the panel driver, it would come on. With this change, the panel successfully turns on during initial rockchipdrm load as expected. Fixes: 2d4f7bdafd70 ("drm/rockchip: dsi: migrate to use dw-mipi-dsi bridge driver") Signed-off-by: Thomas Hebb --- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c index ce044db8c97e..d0c9610ad220 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c @@ -691,13 +691,8 @@ static const struct dw_mipi_dsi_phy_ops dw_mipi_dsi_rockchip_phy_ops = { .get_timing = dw_mipi_dsi_phy_get_timing, }; -static void dw_mipi_dsi_rockchip_config(struct dw_mipi_dsi_rockchip *dsi, - int mux) +static void dw_mipi_dsi_rockchip_config(struct dw_mipi_dsi_rockchip *dsi) { - if (dsi->cdata->lcdsel_grf_reg) - regmap_write(dsi->grf_regmap, dsi->cdata->lcdsel_grf_reg, - mux ? dsi->cdata->lcdsel_lit : dsi->cdata->lcdsel_big); - if (dsi->cdata->lanecfg1_grf_reg) regmap_write(dsi->grf_regmap, dsi->cdata->lanecfg1_grf_reg, dsi->cdata->lanecfg1); @@ -711,6 +706,13 @@ static void dw_mipi_dsi_rockchip_config(struct dw_mipi_dsi_rockchip *dsi, dsi->cdata->enable); } +static void dw_mipi_dsi_rockchip_set_lcdsel(struct dw_mipi_dsi_rockchip *dsi, + int mux) +{ + regmap_write(dsi->grf_regmap, dsi->cdata->lcdsel_grf_reg, + mux ? dsi->cdata->lcdsel_lit : dsi->cdata->lcdsel_big); +} + static int dw_mipi_dsi_encoder_atomic_check(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state, @@ -766,9 +768,9 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) return; } - dw_mipi_dsi_rockchip_config(dsi, mux); + dw_mipi_dsi_rockchip_set_lcdsel(dsi, mux); if (dsi->slave) - dw_mipi_dsi_rockchip_config(dsi->slave, mux); + dw_mipi_dsi_rockchip_set_lcdsel(dsi->slave, mux); clk_disable_unprepare(dsi->grf_clk); } @@ -922,6 +924,24 @@ static int dw_mipi_dsi_rockchip_bind(struct device *dev, return ret; } + /* + * With the GRF clock running, write lane and dual-mode configurations + * that won't change immediately. If we waited until enable() to do + * this, things like panel preparation would not be able to send + * commands over DSI. + */ + ret = clk_prepare_enable(dsi->grf_clk); + if (ret) { + DRM_DEV_ERROR(dsi->dev, "Failed to enable grf_clk: %d\n", ret); + return ret; + } + + dw_mipi_dsi_rockchip_config(dsi); + if (dsi->slave) + dw_mipi_dsi_rockchip_config(dsi->slave); + + clk_disable_unprepare(dsi->grf_clk); + ret = rockchip_dsi_drm_create_encoder(dsi, drm_dev); if (ret) { DRM_DEV_ERROR(dev, "Failed to create drm encoder\n"); -- 2.29.2