Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2835378pxv; Mon, 12 Jul 2021 03:07:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkpp8cRe3Q9o8dyFkeewR73ma6gzuKFnPiEvIOIjw7ESUC8QURpNV+F1BxdhfVEInNpBy9 X-Received: by 2002:a6b:1412:: with SMTP id 18mr23296707iou.33.1626084454755; Mon, 12 Jul 2021 03:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084454; cv=none; d=google.com; s=arc-20160816; b=PatntIVUI8mgJSEP5BA+oG/1fzMJeukaqyLMutjXO6mN8FcKmHTNNSgcTVrYB5Pc46 rurzfscNzyLb4yE1fiVQyVi1oANDqjIpD8QMldkSCNCQNI1hlsurEVtsG6Hr5BPXQAec FD/yTUHI9eibsKWnYKOUHB7uhJn9Chw8W4ouLgJPCSsVgP/oXFmjxmWoAtvEoJAUrX8l dmSYbzw5K7GM0lDl0sVSWBCu5S03q4Ea1uySx4c5Gz0wwaVQlVvCO0+3WsExzUNLlfOW sHRtMEsWrUQfWYq+Ix3pFyDdKz7VoPZgVUI9C4i6FgeTuvKh2/CAtKWFIFj9/96py1Av 9N/A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AzuP0vgLGIF2cVUCT0nQ4doEK+Ws7JQQ5896w4MCx58=; b=cExGTjufdgQADYcqLESwyuYrFHwgW72ggTka+dCSn6LIgIdXuDqAbCQUYf+JmcFx3Q eTCUfpj9vk6G8U9+PMs2jii8S+LMBOtG4G2Dqd0vuIXsRK1xDIqg/Qupy5AQOKlf8+6a 36BPbomv9kVrtcvxKZ/EdG2v6RQ8sx1TXBW40BMicEyTZx6WZZJP/3pb3+RkV8swW0ga PTxqtrgfz0besHBeBPg0r4gwi53kJfWJylFloHe/Oo+/hGcRMAfwH+i2nTb78hkWHOyW DgULQO97a7hEkU2GQARr1aQIpksc6E/OSK17GJn1ttyUDKeNOXv1BE3dsjbo4UoJQz7d YUTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="E2ILdOW/"; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si13394371ilm.159.2021.07.12.03.07.22; Mon, 12 Jul 2021 03:07:34 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b="E2ILdOW/"; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245352AbhGLHri (ORCPT + 99 others); Mon, 12 Jul 2021 03:47:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:46542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242575AbhGLHNd (ORCPT ); Mon, 12 Jul 2021 03:13:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 80A3A61153; Mon, 12 Jul 2021 07:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626073840; bh=5NTxDvKb2VWUSZrZE7MZDD9+AG0I9OzUGnP3AVsQbAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E2ILdOW/8rjAXCBQt+Knt6tknwV9pPT/OIj64tTii/hOCXnicVUD4X9SLiFaegWxt kYmN8k373XsU4Z9I/7/u1OVj+kT7a1Eg6kZOWZk99LV1qT/SH7YeNIVTPXkB83yOqf 96a5RNzSbsPzR4UtXP2VozBcVtbLs2CGKM/blHMw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Hebb , Jonathan Liu , Heiko Stuebner , Sasha Levin Subject: [PATCH 5.12 377/700] drm/rockchip: dsi: move all lane config except LCDC mux to bind() Date: Mon, 12 Jul 2021 08:07:40 +0200 Message-Id: <20210712061016.440236957@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Hebb [ Upstream commit 43c2de1002d2b70fb5941fa14e97a34e3dc214d4 ] 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 Tested-by: Jonathan Liu Signed-off-by: Heiko Stuebner Link: https://patchwork.freedesktop.org/patch/msgid/55fe7f3454d8c91dc3837ba5aa741d4a0e67378f.1618797813.git.tommyhebb@gmail.com Signed-off-by: Sasha Levin --- .../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 24a71091759c..d8c47ee3cad3 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c @@ -692,13 +692,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); @@ -712,6 +707,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, @@ -767,9 +769,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); } @@ -923,6 +925,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.30.2