From patchwork Tue Sep 3 15:31:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3411 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 61F823F228 for ; Tue, 3 Sep 2024 17:32:10 +0200 (CEST) Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-53341ed074dsf4504072e87.0 for ; Tue, 03 Sep 2024 08:32:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1725377530; cv=pass; d=google.com; s=arc-20240605; b=GLKWeHWxtPNmTnBcAIGlOVMZCEgQ/ZfM/ekkwPAdVFBUTzQsQZ0SpcRZ06+BOxWiSZ bJkDs7wq0OusBb1UOpGQGqjWS4gINNz1Tks+hjNvDyB7jqAjdx3jV85LylWetDDDiVCV jMlOYMxPVuWmBZc3A5EmNI6yqaM+MQsNqk5L9jwQt1EOQWkYLwII4FF4oJZqRxdktAGv AOZdv8gLXXc3XQS7Un0wB0MgGibXS1tFBEWV6LHfrfVsBkp707SyF6e008SVmEYgEGk9 1N8VY7x40gJ/5PueEvWVFS1i7+WJvTcPJ5qfNfAeAG22p91/HP4htn1BziE2jJlCtfEl Itxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=0jft7jo+HXDb2ADjz6VuaiX8peINmMFdwJgyB7iJbeg=; fh=A91S+IZDi9N4xJlp9cEvL4jXkDOWSe8woRqigL1H020=; b=eV5U7WfEjJRD0/cxCjuOJ+BOueFvenWF88iH1hd8NLTG7uzqmMPXKHin2bJR2b44E6 1PK0x1LTEVwVGaMDuYXXKHmVEVZxMLrhlLJYr6ylI1mtWSIpB9aSKnVfUTWj1LO4P9Up q/qTlR2RjzEpXHW3KOZ6PYPRCVbsWpSxi+nG2/07BXx0oc1Sk31+q2KFHeeAqyb798MP afunJLrVggz7oCPZwwBsf99nltHJeFBMtH4VIdyHc+vVw4lXKgK8st/5CHJs2y4/kcFL C5OS/eYbOQdHGVMg23bC01JwVXM1Ciu7vdJyOU1mLhmZYnuwYO5Uj12yVPKSCBUXZAmT Au5A==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RWd8ZSrF; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1725377530; x=1725982330; darn=patchwork.amarulasolutions.com; 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:to:from:from:to:cc:subject:date:message-id:reply-to; bh=0jft7jo+HXDb2ADjz6VuaiX8peINmMFdwJgyB7iJbeg=; b=XrWu1GY773fLUdgiVxX18o5oXyHd8GYh5Y7nlcmCoPJLJpQYPxpylYgvICyUUlJO10 p+hoyM/C40eQPRAOoF/rGBznmH7Q7MI8znuaI1AJaUiZ9JpOnhU2qZaerHHPK49vXvCq rGsiJdMAyJj6W+1zA6ea2tzyhjxA3QQpsEXzY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725377530; x=1725982330; 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:to:from:x-beenthere :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0jft7jo+HXDb2ADjz6VuaiX8peINmMFdwJgyB7iJbeg=; b=o6vglSBL0BGeAtG9bJ+IpLXFmX+zP698JXEgkPyJBVq8ODVKuTFtGKjN1Ic7xl4lVg W95x1YYzZLVaE6b7xzWAmCezPBdmC67KW8rZOPJvNgWy2Jgx6IjxvYFfDpFHh1VyZfxN j1gahVimGF5F181Stcbpr9dKbA2TuFkqbRTQOPnekZ5Ha9pb50AyKwYDZfuZj8r4pL7v RtH/gnSp0oxvV+CYjC5flRbA+K97LAcEVNrGyj6GsAx/gIY/TH8EaOnyhwzYX12sVZ9Q MefR6Rg/yHqDDgtL5BrfsjL725s2pjEktf3ED9ui7xUvSQ0PJp9ohyhXSkqaLXUKPatX pEng== X-Forwarded-Encrypted: i=2; AJvYcCWZbYWp50fNnGmQb8uUfzHhzHMwSGwWP2fHYD6G1eNJgcNAuGjQkc33C9hQLay7Ggc2EaRiYm8FylEHhwyX@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YwO7hoMP5yMyeFBMunHmgD1pXU2VL0p37R/lQ5dhix7YEZhNhEb h3LL0EoXAw+q57wMeXZYe9C0RejpOgd1C8rRYYLjPo+F95eoLvsFC1g60V2MBAihzg== X-Google-Smtp-Source: AGHT+IF7MrNdzYA5prw7rx+U1pjwBK5ETjdRqEBFc8If7H9XtHgIwJEKwykvTO9A6ovFcdIxqUjbnQ== X-Received: by 2002:a05:6512:b1b:b0:52e:7ef1:7c6e with SMTP id 2adb3069b0e04-53546ba8dcemr10342211e87.51.1725377529725; Tue, 03 Sep 2024 08:32:09 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6512:ac1:b0:52e:9923:a1c2 with SMTP id 2adb3069b0e04-5353d71b5efls703650e87.1.-pod-prod-03-eu; Tue, 03 Sep 2024 08:32:08 -0700 (PDT) X-Received: by 2002:a05:6512:4011:b0:52c:8df9:2e6f with SMTP id 2adb3069b0e04-53546b8d860mr9826048e87.42.1725377528061; Tue, 03 Sep 2024 08:32:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725377528; cv=none; d=google.com; s=arc-20160816; b=0tr8mdeRvntkgK0rfa5MagEuveWWmkDinQJQH22IQCYnu5WLBESIbmsIKLtKD16vnw RsEurf78XeDzpDDXErBLwF6bUSLFdvUeQrqq3UPC1o+qEnGAYUZRGuiDF/yMLOQoWgas 3GDiIeRoVGWKmVrE13aN/tEnookpn+ohtHGRtIQ/hJfGcdqi9dz+fbLWjvASVKf15Vh3 onkhYvEOhQl8DrUpaPfWPOg+okQvE4JnaTEoMmtqXomRkzb9r8ekyXyxz2wvRRki6OvL 8/25HYuxUZzf9S/vySFSxj0iP/WuodZvXnqIRdExYAmHirCO1OLADk2XVnXmAZuZXDfz eOaQ== 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:to:from:dkim-signature; bh=RWJPfLCxbl6+QjQBWhBo1ziXJWqUMrvYN9J9zHLb7L8=; fh=FtQepR0uNoeKT2PVdKfTKOkvEYfwbRmoVE9BmlYw3tk=; b=IWbNYX4ZdvT92rWm9lNB7Pn7w3Q8JdAynBTMIna6NsDTkIXMw4tHLqFK7YENK1CBom wcDpU6o8mWuxZg0NjeS2T/sQBS3UBSOIiQ/1vg5X/RBCbm4rfueHqEKmNMYBNV1X0+YW MslHmRxfHs4ySumEz71ggO3IADiA+R76+rW/a5l7uHzRcfPL0BF2nLEO9BywnbMAoCCK y3OrJNJ+Qhzk10xLuitrGUb8VrDy2w7cmO4gSMLfArPY+ByfeUgWRnDvzPp9cLrlCJrK lpArND+9DswIhAhFSHXfipAUMJUoo+nUd/oW49SfdeDIaRKfZUTFH1qo8+uHxsssoLFM ATYg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RWd8ZSrF; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 5b1f17b1804b1-42bb70af19asor47053365e9.11.2024.09.03.08.32.07 for (Google Transport Security); Tue, 03 Sep 2024 08:32:08 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:600c:190a:b0:426:63b8:2cce with SMTP id 5b1f17b1804b1-42c880ec215mr31133575e9.7.1725377527399; Tue, 03 Sep 2024 08:32:07 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.42.65]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42baf1b0c18sm192963055e9.37.2024.09.03.08.32.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:32:07 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Subject: [PATCH 10/10] drm/mxsfb: stop controller and drain FIFOs if already initialized Date: Tue, 3 Sep 2024 17:31:57 +0200 Message-ID: <20240903153157.918185-10-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240903153157.918185-1-dario.binacchi@amarulasolutions.com> References: <20240903153157.918185-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RWd8ZSrF; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.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: , You can't re-program the controller if it is still running. This may lead to shifted pictures (FIFO issue?), so stop the controller and drain its FIFOs in case it's already properly setup. This patch is crucial when supporting the simple framebuffer, as the controller has already been initialized by the bootloader. Signed-off-by: Dario Binacchi --- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 3 +++ drivers/gpu/drm/mxsfb/mxsfb_drv.h | 1 + drivers/gpu/drm/mxsfb/mxsfb_kms.c | 24 +++++++++++++++++++----- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c index 1d8dcfd629e1..408b7a113906 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -222,6 +223,8 @@ static int mxsfb_load(struct drm_device *drm, if (!mxsfb) return -ENOMEM; + mxsfb->enabled = + of_property_read_bool(drm->dev->of_node, "fsl,boot-on"); mxsfb->drm = drm; drm->dev_private = mxsfb; mxsfb->devdata = devdata; diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.h b/drivers/gpu/drm/mxsfb/mxsfb_drv.h index d160d921b25f..0f9ae4ce450c 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.h +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.h @@ -47,6 +47,7 @@ struct mxsfb_drm_private { struct drm_bridge *bridge; bool crc_active; + bool enabled; }; static inline struct mxsfb_drm_private * diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c index 7ed2516b6de0..9b453b0100d1 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c @@ -202,9 +202,11 @@ static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb) writel(reg, mxsfb->base + LCDC_CTRL1); writel(CTRL_RUN, mxsfb->base + LCDC_CTRL + REG_SET); + + mxsfb->enabled = true; } -static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) +static void _mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) { u32 reg; @@ -221,6 +223,13 @@ static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) reg &= ~VDCTRL4_SYNC_SIGNALS_ON; writel(reg, mxsfb->base + LCDC_VDCTRL4); + mxsfb->enabled = false; +} + +static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) +{ + _mxsfb_disable_controller(mxsfb); + clk_disable_unprepare(mxsfb->clk); if (mxsfb->clk_disp_axi) clk_disable_unprepare(mxsfb->clk_disp_axi); @@ -296,10 +305,14 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb, bus_flags); DRM_DEV_DEBUG_DRIVER(drm->dev, "Mode flags: 0x%08X\n", m->flags); - /* Mandatory eLCDIF reset as per the Reference Manual */ - err = mxsfb_reset_block(mxsfb); - if (err) - return; + if (mxsfb->enabled) { + _mxsfb_disable_controller(mxsfb); + } else { + /* Mandatory eLCDIF reset as per the Reference Manual */ + err = mxsfb_reset_block(mxsfb); + if (err) + return; + } mxsfb_set_formats(mxsfb, bus_format); @@ -418,6 +431,7 @@ static void mxsfb_crtc_atomic_disable(struct drm_crtc *crtc, mxsfb_disable_axi_clk(mxsfb); pm_runtime_put_sync(drm->dev); + mxsfb->enabled = false; } static int mxsfb_crtc_enable_vblank(struct drm_crtc *crtc)