Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp414806lqc; Fri, 8 Mar 2024 00:55:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUZhLyJDeBAFBg3+yE8rzemYzubOcLiz11zhj2kzLCH6Khu3NvLIEO4Piu43AzpUwgY/KMVykL/CmL3+r7DiucFlFyRtADf+reghsVcgA== X-Google-Smtp-Source: AGHT+IGpYFmwgDFumP6JcXdfXa9mRE0+ILni3/AoGgbdDmtOrdg4dTmxtWf+qjTA9xu5LrgItOuq X-Received: by 2002:a17:902:6509:b0:1dd:69b4:25 with SMTP id b9-20020a170902650900b001dd69b40025mr785362plk.9.1709888108237; Fri, 08 Mar 2024 00:55:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709888108; cv=pass; d=google.com; s=arc-20160816; b=bLFlzLUdueDMi+7wQvkboDWxffLJaQolYEiykGcBO0JyURrRel154eM1eVpvkEb1X8 c+RNJM3SqgYFB3vqtXJHPMxEZcRuqLeAGqsBMw43ObedRFJVWRvBW35HZb5Emua3EF/p S1tf+Od78+z/xq6rdnbSaUi1s15Ry12VJN9OLjBDz8Fh87QFPwHJW81WyyzvzGbDXPcC Gv9PjjjiKkgx+xzOSFXF34tsSRTAxYnnqFvKfDhp9uYrF7qQsR7o/o8Tvr4MGVzCIoWU lu+cbZe+wzVZnqg6nSH1+TM/evk/o5r0sWWtPEyM7e31BwKMEa3X/HnZxlhxwL7PCbaY JPrw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GVSSVuZtAslYXBWR2N1FxKhBCkRJWSsnxUyCWiH7rAw=; fh=B4p7XphEqWTY2f7wIHnSV52avrLEmNmdcjxrC5oxmDQ=; b=aYrgTbk1i2cwfP3CPzdonNWslhiBnp2P2Mpk0I92brdsr7uxdm36smy94wSlvJme29 jjK4Ls1S/6FmhRidx+04gR7b1pecPK//0ZYoR6PuxTx25trEeT/7peP6PaPXsnKGPcX+ X9Ayoz9d6goMCZdKWUWb/xZyZyqeCRkWAoAa2jnocz+r5Vhb8tbUxe+qKRhC9Vvdsq6r 8QpBMknGbs/cBMztAgMU+UkI6mvHa0ioX2W+zJyRidtdYrxSuc1KDazbKvp8wTILYgXG UA2NorlaqMg7qz0r/Z3Ri+mTDWRH00VCA1c15Z7PXrQjdck/CQVR5GPXhiwfJova2yta txAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=temperror (no key for signature) header.i=@ite.com.tw header.s=dkim header.b=bvJnkLYJ; arc=pass (i=1 spf=pass spfdomain=ite.com.tw dmarc=pass fromdomain=ite.com.tw); spf=pass (google.com: domain of linux-kernel+bounces-96709-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96709-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=ite.com.tw Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w6-20020a170902904600b001dc8dc26d73si15432104plz.435.2024.03.08.00.55.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 00:55:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96709-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@ite.com.tw header.s=dkim header.b=bvJnkLYJ; arc=pass (i=1 spf=pass spfdomain=ite.com.tw dmarc=pass fromdomain=ite.com.tw); spf=pass (google.com: domain of linux-kernel+bounces-96709-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96709-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=ite.com.tw Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E44AD2821D3 for ; Fri, 8 Mar 2024 08:55:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABA4A52F62; Fri, 8 Mar 2024 08:54:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=ite.com.tw header.i=@ite.com.tw header.b="bvJnkLYJ" Received: from ironport.ite.com.tw (60-251-196-230.hinet-ip.hinet.net [60.251.196.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 259024EB33 for ; Fri, 8 Mar 2024 08:54:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.251.196.230 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709888087; cv=none; b=bJ9x9tkMAqEImS07VWH66hoGrQ6+YoBvAOjzqCz7SCeBz1L75i5d88zfL/50Tw/NZT6PVzgWWF1R03QcqPLWj8O08kH26SDwLeH+F9JCLBP8nvN9wGxB0+BJPH2d2P2ywTmGlj4CAwX2nF8ZpuRyt9ObwUkQhKWjTRplsaI62HI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709888087; c=relaxed/simple; bh=PJcdeq00L6n6qQP8j0RGP/kSyPQda/Xh4ikbNIP4+8I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tXQseeiLaBzJ1K5cYOPY6LNiNQmL/dmmdwEsTd/eolsztX0Pzp+3XyOjbh3FPAGpX7n/sXiE6k7Sf1YTJd9x/AHzC3q7CISS+dgVj9pROI5lB5hV3YsFYT0EVVKHXVuQNPIIt//Uqmw+h2K15B1XvPLCb9R2i+jw015b9ORpXho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ite.com.tw; spf=pass smtp.mailfrom=ite.com.tw; dkim=fail (0-bit key) header.d=ite.com.tw header.i=@ite.com.tw header.b=bvJnkLYJ reason="key not found in DNS"; arc=none smtp.client-ip=60.251.196.230 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ite.com.tw Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ite.com.tw DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ite.com.tw; s=dkim; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GVSSVuZtAslYXBWR2N1FxKhBCkRJWSsnxUyCWiH7rAw=; b=bvJnkLYJervNjpM+fNmDYGK7POTNBqTeFjV/g4cDwgyUlEl4RnrDRYGl eBXLVKUQe8PccU/TaqemK3NtJiZ8Nk2nEfLEpAY0FORz8QnmbqdaTEzto 8bfR9xpZhKHsQ24nP7tUY+Dp2/UyhBVE7fLnyQMahT22s2fL6L2zA9f2y D544kWp/pUIiYCg9g18xF2uydWhU6AD0+ur0Z+/udOvpmj/RSGIV9ppeU iFHjRtjl4nOM20C/aa+3LC13XWj7QpohBxLs776kWUOkPFNf9ElshQRma qfJXX10XBYLK4dQwIG0sXh6vSrgj77rKSVDN6NeGl5msD+fsHMSG/yjFz A==; Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 08 Mar 2024 16:54:33 +0800 Received: from CSBMAIL1.internal.ite.com.tw (CSBMAIL1.internal.ite.com.tw [192.168.65.58]) by mse.ite.com.tw with ESMTP id 4288sT4O079656; Fri, 8 Mar 2024 16:54:29 +0800 (GMT-8) (envelope-from kuro.chung@ite.com.tw) Received: from ite-XPS-13-9360.internal.ite.com.tw (192.168.72.42) by CSBMAIL1.internal.ite.com.tw (192.168.65.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 8 Mar 2024 16:54:30 +0800 From: kuro To: CC: Allen Chen , Pin-yen Lin , Kuro Chung , Kenneth Haung , Kuro Chung , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list Subject: [PATCH v4 1/1] drm/bridge: it6505: fix hibernate to resume no display issue Date: Fri, 8 Mar 2024 17:05:47 +0800 Message-ID: <20240308090548.269625-2-kuro.chung@ite.com.tw> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240308090548.269625-1-kuro.chung@ite.com.tw> References: <20240308090548.269625-1-kuro.chung@ite.com.tw> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: CSBMAIL1.internal.ite.com.tw (192.168.65.58) To CSBMAIL1.internal.ite.com.tw (192.168.65.58) X-TM-SNTS-SMTP: 7AA9027160530C4E41B22743E60C314331AB9F7662D3442BF604A05768ECE31A2002:8 X-MAIL:mse.ite.com.tw 4288sT4O079656 From: Kuro ITE added a FIFO reset bit for input video. When system power resume, the TTL input of it6505 may get some noise before video signal stable and the hardware function reset is required. But the input FIFO reset will also trigger error interrupts of output module rising. Thus, it6505 have to wait a period can clear those expected error interrupts caused by manual hardware reset in one interrupt handler calling to avoid interrupt looping. Signed-off-by: Kuro Chung --- drivers/gpu/drm/bridge/ite-it6505.c | 50 ++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index b53da9bb65a16..eff888fe7c2e7 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -1318,6 +1318,8 @@ static void it6505_video_reset(struct it6505 *it6505) it6505_set_bits(it6505, REG_DATA_MUTE_CTRL, EN_VID_MUTE, EN_VID_MUTE); it6505_set_bits(it6505, REG_INFOFRAME_CTRL, EN_VID_CTRL_PKT, 0x00); it6505_set_bits(it6505, REG_RESET_CTRL, VIDEO_RESET, VIDEO_RESET); + it6505_set_bits(it6505, REG_VID_BUS_CTRL1, TX_FIFO_RESET, 0x02); + it6505_set_bits(it6505, REG_VID_BUS_CTRL1, TX_FIFO_RESET, 0x00); it6505_set_bits(it6505, REG_501_FIFO_CTRL, RST_501_FIFO, RST_501_FIFO); it6505_set_bits(it6505, REG_501_FIFO_CTRL, RST_501_FIFO, 0x00); it6505_set_bits(it6505, REG_RESET_CTRL, VIDEO_RESET, 0x00); @@ -2475,31 +2477,49 @@ static void it6505_irq_link_train_fail(struct it6505 *it6505) schedule_work(&it6505->link_works); } -static void it6505_irq_video_fifo_error(struct it6505 *it6505) +static bool it6505_test_bit(unsigned int bit, const unsigned int *addr) { - struct device *dev = &it6505->client->dev; + return 1 & (addr[bit / BITS_PER_BYTE] >> (bit % BITS_PER_BYTE)); +} - DRM_DEV_DEBUG_DRIVER(dev, "video fifo overflow interrupt"); - it6505->auto_train_retry = AUTO_TRAIN_RETRY; - flush_work(&it6505->link_works); - it6505_stop_hdcp(it6505); - it6505_video_reset(it6505); +static bool it6505_is_video_error_int(const int *int_status) +{ + if ((it6505_test_bit(BIT_INT_VID_FIFO_ERROR, (unsigned int *)int_status)) || (it6505_test_bit(BIT_INT_IO_FIFO_OVERFLOW, (unsigned int *)int_status))) + return 1; + return 0; } -static void it6505_irq_io_latch_fifo_overflow(struct it6505 *it6505) +static void it6505_irq_video_error_handler(struct it6505 *it6505) { struct device *dev = &it6505->client->dev; + int int_status[3] = {0}; + int reg_0d; + int i; - DRM_DEV_DEBUG_DRIVER(dev, "IO latch fifo overflow interrupt"); it6505->auto_train_retry = AUTO_TRAIN_RETRY; flush_work(&it6505->link_works); it6505_stop_hdcp(it6505); it6505_video_reset(it6505); -} -static bool it6505_test_bit(unsigned int bit, const unsigned int *addr) -{ - return 1 & (addr[bit / BITS_PER_BYTE] >> (bit % BITS_PER_BYTE)); + DRM_DEV_DEBUG_DRIVER(dev, "Video Error reset wait video..."); + + for (i = 0; i < 10; i++) { + usleep_range(10000, 11000); + int_status[2] = it6505_read(it6505, INT_STATUS_03); + reg_0d = it6505_read(it6505, REG_SYSTEM_STS); + it6505_write(it6505, INT_STATUS_03, int_status[2]); + + DRM_DEV_DEBUG_DRIVER(dev, "reg08 = 0x%02x", int_status[2]); + DRM_DEV_DEBUG_DRIVER(dev, "reg0D = 0x%02x", reg_0d); + + if ((reg_0d & VIDEO_STB) && (reg_0d >= 0)) + break; + + if (it6505_is_video_error_int(int_status)) { + it6505_video_reset(it6505); + DRM_DEV_DEBUG_DRIVER(dev, "Video Error reset wait video (%d)", i); + } + } } static irqreturn_t it6505_int_threaded_handler(int unused, void *data) @@ -2519,8 +2539,6 @@ static irqreturn_t it6505_int_threaded_handler(int unused, void *data) { BIT_INT_HDCP_KSV_CHECK, it6505_irq_hdcp_ksv_check }, { BIT_INT_AUDIO_FIFO_ERROR, it6505_irq_audio_fifo_error }, { BIT_INT_LINK_TRAIN_FAIL, it6505_irq_link_train_fail }, - { BIT_INT_VID_FIFO_ERROR, it6505_irq_video_fifo_error }, - { BIT_INT_IO_FIFO_OVERFLOW, it6505_irq_io_latch_fifo_overflow }, }; int int_status[3], i; @@ -2550,6 +2568,8 @@ static irqreturn_t it6505_int_threaded_handler(int unused, void *data) if (it6505_test_bit(irq_vec[i].bit, (unsigned int *)int_status)) irq_vec[i].handler(it6505); } + if (it6505_is_video_error_int(int_status)) + it6505_irq_video_error_handler(it6505); } pm_runtime_put_sync(dev); -- 2.25.1