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: 2852 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id F21FE3F25A for ; Mon, 10 Apr 2023 10:50:11 +0200 (CEST) Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-946832a17f9sf206140066b.2 for ; Mon, 10 Apr 2023 01:50:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1681116611; cv=pass; d=google.com; s=arc-20160816; b=kss7orx+cz3hb7z0fU8mE8itHNDzjyqCwJwFqG+cQ83r8j1WMkGx+fky1OxR9TTjRj oQDMIT4B4VcS5mxi6N6X2PA7QIs3cLRoTf1FEIn+ql7Un5dgZAaY7xjtL17cvWMULSqZ UOFgw5hmQJioClGqJE0VWZc+vKFMdo1lg55Q9OYoRFmZ7dvTIWvJ/eWqWyTQVDrtn1Hm qBk6HNSoYviP8oU0OQ4mzEHxIYAU0Fs7SFPvz/5SFs1sd8veoGO+UWz2+YjbuH6J/MwR ec/pxXNl0WNDPg+wt0JFDaAj0ZVDpu5urs4fHi+Rym1dl2TwQ2kOouJjccT0v1I/k/lX hkcw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=OUl5Eft7bSmi5+Ec9VRLE3axJG21ZHkfDxUJ5g5/pGE=; b=EWlKysKsyXKpXuWz6GFIy7VZB2siAxY3A1t6ralUvSIy8XpT9UHyJ9vlwJGOEHdsZN 6U97TufcqH8ZScHssHY4JE+lVC5Ru3WCmNGh9PlgETGvrylRiQa6W3d7m14plQZMah97 0kOvns1nf8TdngB5Pc6zdR2HsGZbN1/DfVI0s6V1aFKU+b1sIL5Ea2UY6h8QIwcQdr7G 1Ro3UT7lDq9ewy0oG079mHL82xkR4XYsP36dwe+0gNe5qxuPJFBpfBFzrr1G3YJLy5DQ wi0gdKVUPWHJw7PlfU2nKEPimesx+zWm1C+UutqShZnw3bY1qLR+Bxk7mbld1EmwnzA/ pf6Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LGokBRfw; spf=pass (google.com: domain of fusibrandon13@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=fusibrandon13@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1681116611; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=OUl5Eft7bSmi5+Ec9VRLE3axJG21ZHkfDxUJ5g5/pGE=; b=JPkEzIV/jt3IaoFTb1cQcM8dvEFKNAcmvfrVRUC3q5e2Gf//5FxjAk4PeyjgVOesso TKLmmVr4UbdU4fZKiowBFsAJbsLH4dJLpp5hCtZuEda1zAGYieMUkV73GnPsdZGw9IDW zNjDRQNeKLdGh5LbOpK1dljICFZ0VN7O462Y4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681116611; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=OUl5Eft7bSmi5+Ec9VRLE3axJG21ZHkfDxUJ5g5/pGE=; b=0xh89d8W10RgHrQ4vFgEKKI8TRPFuq0/lKWmKsZhjungW6i+dSa3LKQQCxEJfOSp1R bjbarSUNByl0NJ0GyJtz8/giYAEq+ribHhq2q1WS+snDWcOALsZMZp9ayLVIiCkm7pfi HaELJjU9DRlFODhls96ivlH4PNxU5DDsvx/4/F5Nd8xeFWfrnHVFZXP4I5wphhXV33Pp NwBTAExNT/YGu0swRlY9Bwe+LLI+xqDN21s8eQSY617453s9CjyeTXuGgTZ8VNST+YkM 5d1DpWaKW/dI+3rm/vJPId8CSMiYKy3AA65JwNP6MeX/vXv17cqsXpY8/H2GUepViY79 +qvg== Sender: linux-amarula@amarulasolutions.com X-Gm-Message-State: AAQBX9eDs9vLR3v5Wd2MbToQKxDIivrzgJK9GvXsrkbxRM24l5PGPKgS eTq9z1KPf1IteFYtuKX6MWPI8aM3 X-Google-Smtp-Source: AKy350a94YuHA/uTJ6hCp4Zo6T22tdZDqozwY655b/4VQIJQIF+XbvTeU0N/M4wln5HNdlEw6L4AWg== X-Received: by 2002:a50:d71e:0:b0:504:9c1f:1c65 with SMTP id t30-20020a50d71e000000b005049c1f1c65mr1598275edi.6.1681116611800; Mon, 10 Apr 2023 01:50:11 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:b1d4:b0:931:f9f8:d13e with SMTP id bv20-20020a170906b1d400b00931f9f8d13els17963959ejb.8.-pod-prod-gmail; Mon, 10 Apr 2023 01:50:10 -0700 (PDT) X-Received: by 2002:a17:906:68d3:b0:94a:8ada:d109 with SMTP id y19-20020a17090668d300b0094a8adad109mr2153789ejr.77.1681116610223; Mon, 10 Apr 2023 01:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681116610; cv=none; d=google.com; s=arc-20160816; b=JbJFmtoQU2rzgVv2L/BJFP/oPfMuN4nY4yAK2Z5jppQuoPQyQisR+Ny5m3yhzFONO9 1tdyNLANlMbvAp3Zg20sQLNSICdivk+oG27CubVzefFF8urA0RzQH2jI303LH5Cnjb1B Q0WcHykeGZ0mg9RQL+iQaVR177QziGiOoIWl/q09ZG4pVLSxzaWziX6hyuMYkt08Ms3y xUrl0AEDJVbrybrMjKBdB6wXOTbscKBsn6XWmYrGMUCD84QmkNHuwOkXcXR7jbOjCXq4 qT1PgTqvHRUE2xZjty6w3VGFBYKonWOPKKwUZub1Y8SCLWR7y614qysbizGTJe/HQR2a LwiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=w1PPutowbE1ddcNuSAkCSkroxKYobdEeWd9KbxPUEEU=; b=MJSW3hKEfeccp8n73i+OwFWXVsGR0u/brRciA7U50H0DscXpRDqZqRzvIkJSoJnohy /Azf+sw9uCi8vGLInaDhVdRxAGDdTZrju+xLSUI6TDB1CGf6xLHP/p/E3q5k5+51hnOQ qbav8eQmIPSlgwJjIOhxuJJMb0E0ONpB4I9flgdYIuJ09j+g4KryYbfSl6Ycs4S8stN7 mGB34NlJN2E11NNVv/DlpyQytZFhIPYEbbQ8YNIJ/AerdIxz+GaDmwHKj3vUAa/idu/Y tVMWjCD/A6SFv6C+FKpoOr+dp8AyisHxl/h8bqmN4rjMlwPdkrCq1mO+psqrFtmeQ8j/ B7cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LGokBRfw; spf=pass (google.com: domain of fusibrandon13@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=fusibrandon13@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id c15-20020a50f60f000000b005047dd10142sor2903126edn.4.2023.04.10.01.50.10 (Google Transport Security); Mon, 10 Apr 2023 01:50:10 -0700 (PDT) Received-SPF: pass (google.com: domain of fusibrandon13@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; 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-Original-Sender: fusibrandon13@gmail.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LGokBRfw; spf=pass (google.com: domain of fusibrandon13@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=fusibrandon13@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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);