Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp755037iog; Wed, 29 Jun 2022 09:30:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s6mtJXC39xCdw8AGlTmdQrFQPpa7rkMaMR03bX7PqjIiplAbWbQgEWt89e2dptJ5LYojoc X-Received: by 2002:a17:907:d05:b0:6f4:3729:8e36 with SMTP id gn5-20020a1709070d0500b006f437298e36mr4168140ejc.475.1656520245538; Wed, 29 Jun 2022 09:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656520245; cv=none; d=google.com; s=arc-20160816; b=NeriH8Yhk3GvPRj3Hfsl+5AaLDycsvtJQ0KrFE+HWRLQdu9z11pJA++Hk+dQuL9TUR J+MgRxYCThGSnUDvX9lrHlv0ZJ7+X/knd2ZhvdOeX2kzQMdThNxW98f5n6bHEyQbL5gy +gPrHVtDqkuFlpaPVnXg7mHksCXuPm9Fzk7bpoo2VdW5BV4np18aCYC7KqtsLo/FnWu5 qEF8kY8NcY4F1v10oYwvSR6eP9UpFixvRyfq5o3naLscTh2y8X6BLrntnKQOaUMK3mcg q+7e0uDJWV/BB1t+I0OCmqqANSfOS0ztl+3QAVn9kfG/0K8RMT42NolZz5G23oDFfjAU ZE3w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jjoZa4oRghyRXFlLw4DClOAhKTZMl2uJvOPWFlMMk24=; b=bsWExQb0eXW+xJArt+ZoDQgmn8KIH8CWETkvhCKkDa4smXUIwHm8RrVVNOwXrPaqXr 2SO9WqxvqCvRM1ToeRFSZb0z4e/OOhLL7LCIrjUOYvy5EWQhlp7aCas+eY1VcwHQnVtP t2ggCTaEnRaHBu2U+gyyRB+H61l9Q6e26wmRG3QA53GIBsH68YACpLft4Uzriv/s86Ln j3NtO5dX17o7xYsZuHN4xKfXPIbtgmyZkLaJ8nwaCII78qsENIjVrJ9DQPqYMwVWNG7c 2B8JXcjMBpdoT2OieBMb91+lEBS+2gLuOsRW/w5d2xCu+IdfFYV1FLxbGTN1ZtWNT6RK rynA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ci6b5plq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht19-20020a170907609300b006fef10b80f3si22817582ejc.112.2022.06.29.09.30.19; Wed, 29 Jun 2022 09:30:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ci6b5plq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233435AbiF2QG3 (ORCPT + 99 others); Wed, 29 Jun 2022 12:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233488AbiF2QGP (ORCPT ); Wed, 29 Jun 2022 12:06:15 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A04EB1004 for ; Wed, 29 Jun 2022 09:06:11 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id m14-20020a17090a668e00b001ee6ece8368so10642268pjj.3 for ; Wed, 29 Jun 2022 09:06:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jjoZa4oRghyRXFlLw4DClOAhKTZMl2uJvOPWFlMMk24=; b=ci6b5plqfpyMOn/13KVzANy4B4Rw1UFEP8CVEpPlw6wBopmzuXQme/cGfxNlpgxG1f mmTB4kdLCSpAEwAyqVvM0ReKyOuCbetN6Vtc9KdptUPJJU3JAorOKZ1fODsDgpTR3Hsh jFFDXR3iw4NZEsFlRNgMcRZUd3+U9jjmD8dz4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jjoZa4oRghyRXFlLw4DClOAhKTZMl2uJvOPWFlMMk24=; b=dcTKixUnt2wbrwYWO+jFvZzBg+oKYT+l35j+ygopi6UbnkkgcSI+S3Sm60V7E5Fjs0 HJcYZP/JNAKFRi3UyXPCi73Pf8HrMdyTsADoc5cjqnEBIvfL1EbOtki8qhf1gcHGtgmV ddcwe1ES2m+o1JQaXOslkS8ddxHJREM3cEFkG1NvZq55wkXWqp9pk7OI6fepwb35VUnX 8ZN4rbblJb5pm77je/mkfHy/w0BlX8puHia0RMXciyeHPl5RZI9bsqzuCIGrTM9ebgQt TUo7SuLc5NMeYNq4vyuiq3AdCNaSBdnK/RLEp2fRunT+IqhPieUJvcgdngHLmjikEIxw Dm8A== X-Gm-Message-State: AJIora/39/KVL2WFbrItOMAwifv6K23k99DqQRcjhDIITZ2OShMW3KGo +K2hKAtN40WnXJuTfjMEVIpv1g== X-Received: by 2002:a17:902:ef46:b0:168:bac3:2fd4 with SMTP id e6-20020a170902ef4600b00168bac32fd4mr11007834plx.132.1656518771029; Wed, 29 Jun 2022 09:06:11 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:9841:721:7d8b:4502]) by smtp.gmail.com with ESMTPSA id r19-20020a170902e3d300b00163f8ddf160sm11495350ple.161.2022.06.29.09.06.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 09:06:10 -0700 (PDT) From: Hsin-Yi Wang To: Robert Foss , Xin Ji Cc: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Sam Ravnborg , Thomas Zimmermann , Maxime Ripard , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] drm/bridge: anx7625: Add wait_hpd_asserted() callback Date: Thu, 30 Jun 2022 00:05:50 +0800 Message-Id: <20220629160550.433980-5-hsinyi@chromium.org> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220629160550.433980-1-hsinyi@chromium.org> References: <20220629160550.433980-1-hsinyi@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move hpd polling check into wait_hpd_asserted() callback. For the cases that aux transfer function wasn't used, do hpd polling check after pm runtime resume, which will power on the bridge. Signed-off-by: Hsin-Yi Wang --- drivers/gpu/drm/bridge/analogix/anx7625.c | 33 ++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index 59ddeba33652b..ea5a0b86fe52a 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -1443,23 +1443,24 @@ static int anx7625_read_hpd_status_p0(struct anx7625_data *ctx) return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, SYSTEM_STSTUS); } -static void anx7625_hpd_polling(struct anx7625_data *ctx) +static int _anx7625_hpd_polling(struct anx7625_data *ctx, + unsigned long wait_us) { int ret, val; struct device *dev = &ctx->client->dev; /* Interrupt mode, no need poll HPD status, just return */ if (ctx->pdata.intp_irq) - return; + return 0; ret = readx_poll_timeout(anx7625_read_hpd_status_p0, ctx, val, ((val & HPD_STATUS) || (val < 0)), - 5000, - 5000 * 100); + wait_us / 100, + wait_us); if (ret) { DRM_DEV_ERROR(dev, "no hpd.\n"); - return; + return ret; } DRM_DEV_DEBUG_DRIVER(dev, "system status: 0x%x. HPD raise up.\n", val); @@ -1472,6 +1473,23 @@ static void anx7625_hpd_polling(struct anx7625_data *ctx) if (!ctx->pdata.panel_bridge && ctx->bridge_attached) drm_helper_hpd_irq_event(ctx->bridge.dev); + + return 0; +} + +static int anx7625_wait_hpd_asserted(struct drm_dp_aux *aux, + unsigned long wait_us) +{ + struct anx7625_data *ctx = container_of(aux, struct anx7625_data, aux); + struct device *dev = &ctx->client->dev; + int ret; + + pm_runtime_get_sync(dev); + ret = _anx7625_hpd_polling(ctx, wait_us); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + + return ret; } static void anx7625_remove_edid(struct anx7625_data *ctx) @@ -1741,6 +1759,7 @@ static struct edid *anx7625_get_edid(struct anx7625_data *ctx) } pm_runtime_get_sync(dev); + _anx7625_hpd_polling(ctx, 5000 * 100); edid_num = sp_tx_edid_read(ctx, p_edid->edid_raw_data); pm_runtime_put_sync(dev); @@ -2378,6 +2397,7 @@ static void anx7625_bridge_atomic_enable(struct drm_bridge *bridge, ctx->connector = connector; pm_runtime_get_sync(dev); + _anx7625_hpd_polling(ctx, 5000 * 100); anx7625_dp_start(ctx); } @@ -2497,7 +2517,6 @@ static int __maybe_unused anx7625_runtime_pm_resume(struct device *dev) mutex_lock(&ctx->lock); anx7625_power_on_init(ctx); - anx7625_hpd_polling(ctx); mutex_unlock(&ctx->lock); @@ -2589,6 +2608,7 @@ static int anx7625_i2c_probe(struct i2c_client *client, platform->aux.name = "anx7625-aux"; platform->aux.dev = dev; platform->aux.transfer = anx7625_aux_transfer; + platform->aux.wait_hpd_asserted = anx7625_wait_hpd_asserted; drm_dp_aux_init(&platform->aux); if (anx7625_register_i2c_dummy_clients(platform, client) != 0) { @@ -2617,6 +2637,7 @@ static int anx7625_i2c_probe(struct i2c_client *client, if (!platform->pdata.low_power_mode) { anx7625_disable_pd_protocol(platform); pm_runtime_get_sync(dev); + _anx7625_hpd_polling(platform, 5000 * 100); } /* Add work function */ -- 2.37.0.rc0.161.g10f37bed90-goog