From patchwork Tue Mar 19 10:41:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 160558 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp3712186jad; Tue, 19 Mar 2019 03:43:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmQ/2tm1/nAfemdrmZr4clLmrowV1NrrVeyGg+pAM0b5FoIkQibon3KFASFGtaej6xRbog X-Received: by 2002:a63:4962:: with SMTP id y34mr1202258pgk.425.1552992182069; Tue, 19 Mar 2019 03:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552992182; cv=none; d=google.com; s=arc-20160816; b=CSweWW2XyahEpq3f31fCWtTRhbxhrxdq2m3vbeFksjzfmDhSfbaAZAloNm/ZqaVVgf 1nBC7mC8/uZbOvVSPkPMUGhK0/qxrM4Bk83P2Mzq1GRKgmENagUzsQ2i7A/v27Mis/D0 oGmARKOuPlko5+S4ktKk2T8l+56WBFtSQLTzHIRyt4pO465pQT1wkTt/DkK84/vcP27r nQYTS44vG93HeM07rfCgjTyiT4ktAIfhS0Pco5sxOmErqNU6p6F8ry8HaAxKbmn6HWRx wrQDvdcNKP7w6hRexQ3bbilbniwAVqe5izF7eRwMZjbL/vAxeE3g0g6LLSSAXA29Uy6A ts5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=wZzHakwczeQRpEyIWy+F+x2yVDft59ybik1hq6CoWEQ=; b=Mu9Z/Po8eTTYcRR91jW1Qiz0UMe1tg+ALphLSzwo+Y2qIwJyyZEQ9SNhyXTRJOcjh6 FsGo2YRv4d4k0YO90qObx4hvq6VdLY0rL6zfw1msNbNgp325LZtMqh5/hJIALzs3G3dE FmA7yNPPjBKfQeArjU2ZT4iALPuspeueNLqMbzmRkGfRH9EekwLOm7qjIJ8LiLHTEFj1 aYBfGZ3on2izMvKmrmJ8G7ct1sUYdSldC3p1tRXr7JsqPrvru2ZQCOKWNvu07bJa79Pm ojdfmCdEhtRjWSop2c6EBYYNCrTqD05lqOxKBoqBK1c33ndJkWmq+t8E15F2B68Gdqdf f6WA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id d2si9697752pld.110.2019.03.19.03.43.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 03:43:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 75CC989AEB; Tue, 19 Mar 2019 10:43:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9813C89ACD for ; Tue, 19 Mar 2019 10:42:54 +0000 (UTC) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x2JAgqPa076891; Tue, 19 Mar 2019 05:42:52 -0500 Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x2JAgqCJ024006 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 19 Mar 2019 05:42:52 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 19 Mar 2019 05:42:51 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5 via Frontend Transport; Tue, 19 Mar 2019 05:42:51 -0500 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x2JAfxle019091; Tue, 19 Mar 2019 05:42:49 -0500 From: Tomi Valkeinen To: Andrzej Hajda , Laurent Pinchart , , Lucas Stach , Andrey Gusakov , Philipp Zabel , Jyri Sarha , Peter Ujfalusi , Benoit Parrot Subject: [PATCH 21/21] drm/bridge: tc358767: implement naive HPD handling Date: Tue, 19 Mar 2019 12:41:14 +0200 Message-ID: <20190319104114.12077-22-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190319104114.12077-1-tomi.valkeinen@ti.com> References: <20190319104114.12077-1-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1552992172; bh=oADHOaYal2MBC3/6GIpkyHXwdR0PthH2HCsAbNc+B98=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=FpF5X79mo1XeEu7Vn/ASihxzmXmKlXNhun3rqJeOmxd771EXQrFZ6CB6afNbv/8Fi 6Q5fllXfcJQv6IAFbk4k4LrM7BeCElb8m98jdnId3M1PgA1gFPvr6efLx5HYbw/8+G 9jDDn6LdoVeGd02TwTFbnnYOe9wGApijx/Cibgk0= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomi Valkeinen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" tc358767 driver doesn't have any HPD handling at the moment, as it was originally developed to support only eDP. This patch implements a naive, polling-based HPD handling, which is used when the driver is in DP mode. Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/bridge/tc358767.c | 56 +++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 8606de29c9b2..2b252f7ac070 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -1095,6 +1095,12 @@ static void tc_bridge_enable(struct drm_bridge *bridge) struct tc_data *tc = bridge_to_tc(bridge); int ret; + ret = tc_get_display_props(tc); + if (ret < 0) { + dev_err(tc->dev, "failed to read display props: %d\n", ret); + return; + } + ret = tc_main_link_enable(tc); if (ret < 0) { dev_err(tc->dev, "main link enable error: %d\n", ret); @@ -1200,19 +1206,35 @@ static int tc_connector_get_modes(struct drm_connector *connector) return count; } -static void tc_connector_set_polling(struct tc_data *tc, - struct drm_connector *connector) -{ - /* TODO: add support for HPD */ - connector->polled = DRM_CONNECTOR_POLL_CONNECT | - DRM_CONNECTOR_POLL_DISCONNECT; -} - static const struct drm_connector_helper_funcs tc_connector_helper_funcs = { .get_modes = tc_connector_get_modes, }; +static enum drm_connector_status tc_connector_detect(struct drm_connector *connector, bool force) +{ + struct tc_data *tc = connector_to_tc(connector); + u32 val; + int ret; + bool conn; + + tc_read(GPIOI, &val); + + conn = val & BIT(0); + + if (force && conn) + tc_get_display_props(tc); + + if (conn) + return connector_status_connected; + else + return connector_status_disconnected; + +err: + return connector_status_unknown; +} + static const struct drm_connector_funcs tc_connector_funcs = { + .detect = tc_connector_detect, .fill_modes = drm_helper_probe_single_connector_modes, .destroy = drm_connector_cleanup, .reset = drm_atomic_helper_connector_reset, @@ -1227,7 +1249,7 @@ static int tc_bridge_attach(struct drm_bridge *bridge) struct drm_device *drm = bridge->dev; int ret; - /* Create eDP connector */ + /* Create DP/eDP connector */ drm_connector_helper_add(&tc->connector, &tc_connector_helper_funcs); ret = drm_connector_init(drm, &tc->connector, &tc_connector_funcs, tc->panel ? DRM_MODE_CONNECTOR_eDP : @@ -1235,6 +1257,13 @@ static int tc_bridge_attach(struct drm_bridge *bridge) if (ret) return ret; + /* Don't poll if we have eDP panel */ + if (!tc->panel) { + /* TODO: add support for HPD */ + tc->connector.polled = DRM_CONNECTOR_POLL_CONNECT | + DRM_CONNECTOR_POLL_DISCONNECT; + } + if (tc->panel) drm_panel_attach(tc->panel, &tc->connector); @@ -1377,12 +1406,6 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) if (ret) return ret; - ret = tc_get_display_props(tc); - if (ret) - goto err_unregister_aux; - - tc_connector_set_polling(tc, &tc->connector); - tc->bridge.funcs = &tc_bridge_funcs; tc->bridge.of_node = dev->of_node; drm_bridge_add(&tc->bridge); @@ -1390,9 +1413,6 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) i2c_set_clientdata(client, tc); return 0; -err_unregister_aux: - drm_dp_aux_unregister(&tc->aux); - return ret; } static int tc_remove(struct i2c_client *client)