From patchwork Mon Apr 10 08:47:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brandon Cheo Fusi X-Patchwork-Id: 13206197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B2F5C77B61 for ; Mon, 10 Apr 2023 08:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dm07Q7DwdyEFrDakQS7c7RQdVLng/WwlGN4mviHnWTE=; b=IDIDUkuQjQyVHY DHC1ppSZAr0pNC6BhnKwdHIH/wvduX1H8IJ6Dm5ZyFH2Lag7uyDdV6+u4yQTMNtH9PkTUh4q6U7nC abfgSO1ayjl0WQ+IhHCYvLlrzlrAMSyXB6Gm+bUFssgYBkHzfDHA+qvwEfr3mejNuyeGJjXlZYGa8 orPDkMmIkjZ84cX0SDehKeywiqPUKe1uoUhAHwhIyOUm4Uy1MGm+8Om/L+93RNg81aLCGNpAN1OH4 VyrxW5TB6dCwIgX17jskwSdiabb5Sy0zEbh/QI2tRj9NjGgTda/TSvfUmhkNNDjX9BEGTo1b+jQqk /iF/x4+p2N+G5V9SZXCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1plnE7-00EpaX-0A; Mon, 10 Apr 2023 08:50:15 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1plnE3-00EpZo-1m for linux-arm-kernel@lists.infradead.org; Mon, 10 Apr 2023 08:50:13 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-50479981ed6so1643150a12.0 for ; Mon, 10 Apr 2023 01:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681116610; x=1683708610; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w1PPutowbE1ddcNuSAkCSkroxKYobdEeWd9KbxPUEEU=; b=LGokBRfwoSyZtR+ih01/in6zmOZnvXuD0gRgan30Ovo+XaSic5WzY5NP0OsgxDn2BD AQFQUcqrQGq4Y4LxFytV9jBA+GuNfiKUMpcHpw8SY+VcyHINzPe7SZuN1CRF4KdQtYci 1zbPaxCZQgEletquEAe90/xgnK4r7T51t4hs2NEloEKXpbjRj94RMFM9nBDsM0U10Gbj cL3SNK11tuZF2nvLlVNm19bOmr6Meku4x7yt7EEvnlPnM0tR8Rk2saCNs95CwiBi5Nyw hBfasGfcB0buCGwQo0Tprro2EnXeLsKORetkxx1xrP9jG+h/G1KDeknmZtRH2nKqAmVj 95dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681116610; x=1683708610; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w1PPutowbE1ddcNuSAkCSkroxKYobdEeWd9KbxPUEEU=; b=FZ7SYadof+XsfzftxiJa4QUEh0inIexsimupJrfmu8b/spnrQFCXGlbw7iPnHlyKdo rFu1HKpEkUS32Aj86DvVe+/Dk6TtxArf6oHlbQXcBhMl5UZjT9opPdaRQM+3rBFlT89j jB4gvekDjGGWvBDcQNEqDpjk/VQwbWkTBQPq3WYcmNGAavVQ3Wv/4x2Kv1kNtbVy0l4Z GJ5jgCNHzfIsbjLihewNxCxaaSaAF2cJZLpxjh3V+hjJvwGW+BSX4RvS5VUYAHxD2I4j qG8wVDX0pGeqFz2t3hwekZnEGNo7jwJLPpR/OEqn/vkUVXEaV990w5HjXgaOt86muCiC mcLg== X-Gm-Message-State: AAQBX9dcsW++RJKPD+SPwWt3HDLzw+NrRK/dUYpc5vg0lPmO7/D9Q5Bw j2uJ+OTpYt9raYpFYcSaiX4= X-Google-Smtp-Source: AKy350b5k9AR/6UulnkpYaBxALJEatRglMDChZn26EjA3zlioQLSx33nmJs40SAHZ2UuLARzkJjy8w== X-Received: by 2002:aa7:d697:0:b0:504:852a:6856 with SMTP id d23-20020aa7d697000000b00504852a6856mr7280281edr.16.1681116609374; Mon, 10 Apr 2023 01:50:09 -0700 (PDT) Received: from localhost.localdomain ([154.72.161.184]) by smtp.gmail.com with ESMTPSA id v13-20020a50954d000000b004fc649481basm4709962eda.58.2023.04.10.01.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 01:50:08 -0700 (PDT) From: Brandon Cheo Fusi To: maxime@cerno.tech Cc: airlied@gmail.com, andrzej.hajda@intel.com, daniel@ffwll.ch, dave.stevenson@raspberrypi.com, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, jagan@amarulasolutions.com, jernej.skrabec@gmail.com, krzysztof.kozlowski+dt@linaro.org, linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, maarten.lankhorst@linux.intel.com, marex@denx.de, neil.armstrong@linaro.org, rfoss@kernel.org, robh+dt@kernel.org, sam@ravnborg.org, samuel@sholland.org, tzimmermann@suse.de, wens@csie.org, Brandon Cheo Fusi Subject: [PATCH 1/2] drm: sun4i/dsi: factor out DSI PHY poweron and poweroff Date: Mon, 10 Apr 2023 09:47:49 +0100 Message-Id: <20230410084750.164016-2-fusibrandon13@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230410084750.164016-1-fusibrandon13@gmail.com> References: <20230410084750.164016-1-fusibrandon13@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230410_015011_592178_944664A5 X-CRM114-Status: GOOD ( 17.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Factor out PHY poweron and poweroff sequences from sun6i_dsi_encoder_enable and sun6i_dsi_encoder_disable.This leaves nothing to be be done in sun6i_dsi_encoder_disable, so get rid of that. Also remove drm_panel_ as these would be invoked the modeset helpers. Signed-off-by: Brandon Cheo Fusi --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 64 ++++++++++++-------------- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 4 ++ 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 760ff05ea..4dc92109e 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -713,7 +713,7 @@ static int sun6i_dsi_start(struct sun6i_dsi *dsi, return 0; } -static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) +void sun6i_dsi_phy_power_on(const struct drm_encoder *encoder) { struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; struct sun6i_dsi *dsi = encoder_to_sun6i_dsi(encoder); @@ -768,43 +768,12 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) phy_set_mode(dsi->dphy, PHY_MODE_MIPI_DPHY); phy_configure(dsi->dphy, &opts); phy_power_on(dsi->dphy); - - if (dsi->panel) - drm_panel_prepare(dsi->panel); - - /* - * FIXME: This should be moved after the switch to HS mode. - * - * Unfortunately, once in HS mode, it seems like we're not - * able to send DCS commands anymore, which would prevent any - * panel to send any DCS command as part as their enable - * method, which is quite common. - * - * I haven't seen any artifact due to that sub-optimal - * ordering on the panels I've tested it with, so I guess this - * will do for now, until that IP is better understood. - */ - if (dsi->panel) - drm_panel_enable(dsi->panel); - - sun6i_dsi_start(dsi, DSI_START_HSC); - - udelay(1000); - - sun6i_dsi_start(dsi, DSI_START_HSD); } -static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) +void sun6i_dsi_phy_power_off(const struct drm_encoder *encoder) { struct sun6i_dsi *dsi = encoder_to_sun6i_dsi(encoder); - DRM_DEBUG_DRIVER("Disabling DSI output\n"); - - if (dsi->panel) { - drm_panel_disable(dsi->panel); - drm_panel_unprepare(dsi->panel); - } - phy_power_off(dsi->dphy); phy_exit(dsi->dphy); @@ -813,6 +782,34 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) regulator_disable(dsi->regulator); } +static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder, struct drm_atomic_state *old_state) +{ + struct sun6i_dsi *dsi = encoder_to_sun6i_dsi(encoder); + + DRM_DEBUG_DRIVER("Enabling DSI output\n"); + + sun6i_dsi_start(dsi, DSI_START_HSC); + + udelay(1000); + + sun6i_dsi_start(dsi, DSI_START_HSD); + + /* + * NOTE + * + * Unfortunately, once in HS mode, it seems like we're not + * able to send DCS commands anymore, which would prevent any + * panel to send any DCS command as part as their enable + * method, which is quite common. + * + * So maybe panels/bridges should send any init DCS commands in their + * prepare/pre_enable methods? This should work as the DSI PHY is active + * before those hooks are called. + * + * This will do for now, until that IP is better understood. + */ +} + static int sun6i_dsi_get_modes(struct drm_connector *connector) { struct sun6i_dsi *dsi = connector_to_sun6i_dsi(connector); @@ -843,7 +840,6 @@ static const struct drm_connector_funcs sun6i_dsi_connector_funcs = { }; static const struct drm_encoder_helper_funcs sun6i_dsi_enc_helper_funcs = { - .disable = sun6i_dsi_encoder_disable, .enable = sun6i_dsi_encoder_enable, }; diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h index f1ddefe0f..a0b541f48 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h @@ -40,6 +40,10 @@ struct sun6i_dsi { const struct sun6i_dsi_variant *variant; }; +void sun6i_dsi_phy_power_on(const struct drm_encoder *encoder); + +void sun6i_dsi_phy_power_off(const struct drm_encoder *encoder); + static inline struct sun6i_dsi *host_to_sun6i_dsi(struct mipi_dsi_host *host) { return container_of(host, struct sun6i_dsi, host);