From nobody Fri Nov 29 11:51:14 2024 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 C875513A878 for ; Fri, 20 Sep 2024 08:25:17 +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=1726820721; cv=none; b=RpTTWDnBBH5WJ88tX5k2zQ9tjZLhHM214AeTxXyzsiL988tA0pK+1EmZ4bt30iO5dvy2TxpInA+AHNygdG134aGitM0XST76kJYfQk4P0fyuSA3mzi4oJhhw5shw2rV4n83rMmHYkfMVMmncS4l2OpmgTyiwS2awi1ZpxEHsAgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726820721; c=relaxed/simple; bh=nLY3n5jB8XvNVzTG/BGB3lwiPc0znOmCxCaW0ezcgfw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZQjfuvisPCQa7CK3mva49JMt/At2eSbM1D0qU39cvPwF5ooOutgE44tRCHBOLVQx2WTYFghykgMWZDQ2KOubuGbz0DrWeX9RyjDU6Dpz9nUIeknvATy4gDcjObc889tGRUyH5tcZVMLguCSXoBFfwasPdvv/upntfZmnE4D14x0= 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=mxGh6bdd 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 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="mxGh6bdd" 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=bdZHu3fJZOTkEdz/Z/q678RDF08HxD3urzMMTex6bzs=; b=mxGh6bddRWrpeIfdPucd/mrf6kLf4nnQ1U+ruZYQMMFoo6SEnBLg6jpZ wSI6HMt/7Jbz6xMIpF9jy0khtfGqCx3f/68QLu981H/VIc8norXebojNM DLGtiLOhvy5OEYeg4kc3hAtfGvEU8yzqngREQwcrg346TT3W58d93lv8e MGiIEyAUCOantIfGxHa6c1thOKOSmuP4Hv6Tt8g4f4aYERP8cZy0WJeDV 2AoGoqxqPGOg61HuiQ7NVcIgNfhYHqaptTG0J4Dha88Z5aYIkDiXFFGah lE7wGFP3MTMq4EZMDVUZHxUKgV7/eLaP0fbxhvyF0+eSMoJJ+h/C7ErdL g==; X-CSE-ConnectionGUID: Zi4bjZ7BQv2JeOrpXR46aA== X-CSE-MsgGUID: NkXj8ooeSeO6l47fHX6cQQ== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 20 Sep 2024 16:25:08 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48K8P38W024271; Fri, 20 Sep 2024 16:25:03 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Sep 2024 16:25:03 +0800 From: Hermes Wu To: Pin-yen Lin , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list CC: Kenneth Hung , allen chen , Hermes Wu Subject: [PATCH v1 1/2] drm/bridge: it6505: HDCP CTS fail on repeater items Date: Fri, 20 Sep 2024 16:24:46 +0800 Message-ID: <20240920082451.9240-2-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240920082451.9240-1-Hermes.Wu@ite.com.tw> References: <20240920082451.9240-1-Hermes.Wu@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: quoted-printable X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: 6A1D97EBAE6E06EA4FEE044141B53E20E90583D7A00CA3BA8C2A80893D2E5F5D2002:8 X-MAIL: mse.ite.com.tw 48K8P38W024271 Content-Type: text/plain; charset="utf-8" From: allen chen Fix HDCP CTS items on UNIGRAF DPR-100. Change-Id: I03f0758779f73164c8ae2fdf61e41dc693e27605 Change-Id: Ib7a8fabaeccd56d3bd7c8adc7384a363b0f7b88d Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 152 ++++++++++++++++++---------- 1 file changed, 101 insertions(+), 51 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index 7a4608844de3..cef02c8c363e 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -298,11 +298,11 @@ #define MAX_LANE_COUNT 4 #define MAX_LINK_RATE HBR #define AUTO_TRAIN_RETRY 3 -#define MAX_HDCP_DOWN_STREAM_COUNT 10 +#define MAX_HDCP_DOWN_STREAM_COUNT 127 #define MAX_CR_LEVEL 0x03 #define MAX_EQ_LEVEL 0x03 #define AUX_WAIT_TIMEOUT_MS 15 -#define AUX_FIFO_MAX_SIZE 32 +#define AUX_FIFO_MAX_SIZE 16 #define PIXEL_CLK_DELAY 1 #define PIXEL_CLK_INVERSE 0 #define ADJUST_PHASE_THRESHOLD 80000 @@ -326,6 +326,9 @@ enum aux_cmd_type { CMD_AUX_NATIVE_READ =3D 0x0, CMD_AUX_NATIVE_WRITE =3D 0x5, CMD_AUX_I2C_EDID_READ =3D 0xB, + + /*extend read ncommand */ + CMD_AUX_GET_KSV_LIST =3D 0x10, }; =20 enum aux_cmd_reply { @@ -973,7 +976,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it65= 05, it6505_set_bits(it6505, REG_AUX_CTRL, AUX_USER_MODE, AUX_USER_MODE); =20 aux_op_start: - if (cmd =3D=3D CMD_AUX_I2C_EDID_READ) { + if (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD_AUX_GET_KSV_LIST) { /* AUX EDID FIFO has max length of AUX_FIFO_MAX_SIZE bytes. */ size =3D min_t(size_t, size, AUX_FIFO_MAX_SIZE); /* Enable AUX FIFO read back and clear FIFO */ @@ -1004,7 +1007,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it= 6505, size); =20 /* Aux Fire */ - it6505_write(it6505, REG_AUX_CMD_REQ, cmd); + it6505_write(it6505, REG_AUX_CMD_REQ, (cmd & 0x0F)); =20 ret =3D it6505_aux_wait(it6505); if (ret < 0) @@ -1038,7 +1041,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it= 6505, goto aux_op_start; } =20 - if (cmd =3D=3D CMD_AUX_I2C_EDID_READ) { + if (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD_AUX_GET_KSV_LIST) { for (i =3D 0; i < size; i++) { ret =3D it6505_read(it6505, REG_AUX_DATA_FIFO); if (ret < 0) @@ -1063,7 +1066,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it= 6505, ret =3D i; =20 aux_op_err: - if (cmd =3D=3D CMD_AUX_I2C_EDID_READ) { + if (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD_AUX_GET_KSV_LIST) { /* clear AUX FIFO */ it6505_set_bits(it6505, REG_AUX_CTRL, AUX_EN_FIFO_READ | CLR_EDID_FIFO, @@ -1084,18 +1087,25 @@ static ssize_t it6505_aux_do_transfer(struct it6505= *it6505, size_t size, enum aux_cmd_reply *reply) { int i, ret_size, ret =3D 0, request_size; + struct device *dev =3D &it6505->client->dev; =20 mutex_lock(&it6505->aux_lock); - for (i =3D 0; i < size; i +=3D 4) { - request_size =3D min((int)size - i, 4); + for (i =3D 0; i < size; ) { + if (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD_AUX_GET_KSV_LIST) + request_size =3D min((int)size - i, AUX_FIFO_MAX_SIZE); + else + request_size =3D min((int)size - i, 4); + ret_size =3D it6505_aux_operation(it6505, cmd, address + i, buffer + i, request_size, reply); + if (ret_size < 0) { ret =3D ret_size; goto aux_op_err; } =20 + i +=3D request_size; ret +=3D ret_size; } =20 @@ -1186,6 +1196,35 @@ static int it6505_get_edid_block(void *data, u8 *buf= , unsigned int block, return 0; } =20 +static int it6505_get_ksvlist(struct it6505 *it6505, u8 *buf, size_t len) +{ + int i, request_size, ret; + struct device *dev =3D &it6505->client->dev; + enum aux_cmd_reply reply; + + for (i =3D 0; i < len; ) { + request_size =3D min((int)len - i, 15); + + ret =3D it6505_aux_do_transfer(it6505, CMD_AUX_GET_KSV_LIST, + DP_AUX_HDCP_KSV_FIFO, + buf + i, request_size, &reply); + + DRM_DEV_DEBUG_DRIVER(dev, "request_size =3D %d, ret =3D%d", request_size= , ret); + if (ret < 0) + return ret; + + i +=3D request_size; + } + + DRM_DEV_DEBUG_DRIVER(dev, "ksv read cnt =3D %d down_stream_cnt=3D%d ", i,= i/5); + + for (i =3D 0 ; i < len; i +=3D 5) + DRM_DEV_DEBUG_DRIVER(dev, "ksv[%d] =3D %02X%02X%02X%02X%02X", + i/5, buf[i], buf[i + 1], buf[i + 2], buf[i + 3], buf[i + 4]); + + return len; +} + static void it6505_variable_config(struct it6505 *it6505) { it6505->link_rate_bw_code =3D HBR; @@ -1927,6 +1966,7 @@ static void it6505_hdcp_part1_auth(struct it6505 *it6= 505) it6505_set_bits(it6505, REG_HDCP_TRIGGER, HDCP_TRIGGER_START, HDCP_TRIGGER_START); =20 + it6505->is_repeater =3D (hdcp_bcaps & DP_BCAPS_REPEATER_PRESENT); it6505->hdcp_status =3D HDCP_AUTH_GOING; } =20 @@ -1963,7 +2003,7 @@ static int it6505_setup_sha1_input(struct it6505 *it6= 505, u8 *sha1_input) { struct device *dev =3D &it6505->client->dev; u8 binfo[2]; - int down_stream_count, i, err, msg_count =3D 0; + int down_stream_count, err, msg_count =3D 0; =20 err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_BINFO, binfo, ARRAY_SIZE(binfo)); @@ -1989,17 +2029,12 @@ static int it6505_setup_sha1_input(struct it6505 *i= t6505, u8 *sha1_input) return 0; } =20 - for (i =3D 0; i < down_stream_count; i++) { - err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_KSV_FIFO + - (i % 3) * DRM_HDCP_KSV_LEN, - sha1_input + msg_count, - DRM_HDCP_KSV_LEN); =20 - if (err < 0) - return err; + err =3D it6505_get_ksvlist(it6505, sha1_input, down_stream_count * 5); + if (err < 0) + return err; =20 - msg_count +=3D 5; - } + msg_count +=3D down_stream_count * 5; =20 it6505->hdcp_down_stream_count =3D down_stream_count; sha1_input[msg_count++] =3D binfo[0]; @@ -2027,7 +2062,7 @@ static bool it6505_hdcp_part2_ksvlist_check(struct it= 6505 *it6505) { struct device *dev =3D &it6505->client->dev; u8 av[5][4], bv[5][4]; - int i, err; + int i, err, retry; =20 i =3D it6505_setup_sha1_input(it6505, it6505->sha1_input); if (i <=3D 0) { @@ -2037,21 +2072,28 @@ static bool it6505_hdcp_part2_ksvlist_check(struct = it6505 *it6505) =20 it6505_sha1_digest(it6505, it6505->sha1_input, i, (u8 *)av); =20 - err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_V_PRIME(0), (u8 *)bv, - sizeof(bv)); + for (retry =3D 0; retry < 3; retry++) { =20 - if (err < 0) { - dev_err(dev, "Read V' value Fail"); - return false; - } + err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_V_PRIME(0), (u8 *)bv, + sizeof(bv)); =20 - for (i =3D 0; i < 5; i++) - if (bv[i][3] !=3D av[i][0] || bv[i][2] !=3D av[i][1] || - bv[i][1] !=3D av[i][2] || bv[i][0] !=3D av[i][3]) - return false; + if (err < 0) { + dev_err(dev, "Read V' value Fail %d", retry); + continue; + } =20 - DRM_DEV_DEBUG_DRIVER(dev, "V' all match!!"); - return true; + for (i =3D 0; i < 5; i++) { + if (bv[i][3] !=3D av[i][0] || bv[i][2] !=3D av[i][1] || + bv[i][1] !=3D av[i][2] || bv[i][0] !=3D av[i][3]) + break; + + DRM_DEV_DEBUG_DRIVER(dev, "V' all match!! %d, %d", retry, i); + return true; + } + } + + DRM_DEV_DEBUG_DRIVER(dev, "V' NOT match!! %d", retry); + return false; } =20 static void it6505_hdcp_wait_ksv_list(struct work_struct *work) @@ -2059,7 +2101,7 @@ static void it6505_hdcp_wait_ksv_list(struct work_str= uct *work) struct it6505 *it6505 =3D container_of(work, struct it6505, hdcp_wait_ksv_list); struct device *dev =3D &it6505->client->dev; - unsigned int timeout =3D 5000; + unsigned int timeout =3D 2000; u8 bstatus =3D 0; bool ksv_list_check; =20 @@ -2079,21 +2121,18 @@ static void it6505_hdcp_wait_ksv_list(struct work_s= truct *work) =20 if (timeout =3D=3D 0) { DRM_DEV_DEBUG_DRIVER(dev, "timeout and ksv list wait failed"); - goto timeout; + goto hdcp_ksvlist_fail; } =20 ksv_list_check =3D it6505_hdcp_part2_ksvlist_check(it6505); DRM_DEV_DEBUG_DRIVER(dev, "ksv list ready, ksv list check %s", - ksv_list_check ? "pass" : "fail"); - if (ksv_list_check) { - it6505_set_bits(it6505, REG_HDCP_TRIGGER, - HDCP_TRIGGER_KSV_DONE, HDCP_TRIGGER_KSV_DONE); + ksv_list_check ? "pass" : "fail"); + + if (ksv_list_check) return; - } -timeout: - it6505_set_bits(it6505, REG_HDCP_TRIGGER, - HDCP_TRIGGER_KSV_DONE | HDCP_TRIGGER_KSV_FAIL, - HDCP_TRIGGER_KSV_DONE | HDCP_TRIGGER_KSV_FAIL); + +hdcp_ksvlist_fail: + it6505_start_hdcp(it6505); } =20 static void it6505_hdcp_work(struct work_struct *work) @@ -2139,7 +2178,7 @@ static void it6505_hdcp_work(struct work_struct *work) it6505_hdcp_part1_auth(it6505); } =20 -static void it6505_show_hdcp_info(struct it6505 *it6505) +static void it6505_show_hdcp_info(struct it6505 *it6505, bool repeater_inf= o) { struct device *dev =3D &it6505->client->dev; int i; @@ -2150,7 +2189,7 @@ static void it6505_show_hdcp_info(struct it6505 *it65= 05) DRM_DEV_DEBUG_DRIVER(dev, "bksv =3D 0x%*ph", (int)ARRAY_SIZE(it6505->bksvs), it6505->bksvs); =20 - if (it6505->is_repeater) { + if ((repeater_info) && (it6505->is_repeater)) { DRM_DEV_DEBUG_DRIVER(dev, "hdcp_down_stream_count: %d", it6505->hdcp_down_stream_count); DRM_DEV_DEBUG_DRIVER(dev, "sha1_input: 0x%*ph", @@ -2251,12 +2290,11 @@ static void it6505_link_training_work(struct work_s= truct *work) if (ret) { it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; it6505_link_train_ok(it6505); - return; } else { it6505->auto_train_retry--; + it6505_dump(it6505); } =20 - it6505_dump(it6505); } =20 static void it6505_plugged_status_to_codec(struct it6505 *it6505) @@ -2311,14 +2349,22 @@ static int it6505_process_hpd_irq(struct it6505 *it= 6505) DRM_DEV_DEBUG_DRIVER(dev, "dp_irq_vector =3D 0x%02x", dp_irq_vector); =20 if (dp_irq_vector & DP_CP_IRQ) { - it6505_set_bits(it6505, REG_HDCP_TRIGGER, HDCP_TRIGGER_CPIRQ, - HDCP_TRIGGER_CPIRQ); =20 bstatus =3D it6505_dpcd_read(it6505, DP_AUX_HDCP_BSTATUS); if (bstatus < 0) return bstatus; =20 DRM_DEV_DEBUG_DRIVER(dev, "Bstatus =3D 0x%02x", bstatus); + + /*1B-02 ignore when bstatus is 0 */ + if ((bstatus & DP_BSTATUS_R0_PRIME_READY) && + (it6505->hdcp_status =3D=3D HDCP_AUTH_GOING)) + it6505_set_bits(it6505, REG_HDCP_TRIGGER, HDCP_TRIGGER_CPIRQ, + HDCP_TRIGGER_CPIRQ); + else if ((bstatus & (DP_BSTATUS_REAUTH_REQ | DP_BSTATUS_LINK_FAILURE)) && + (it6505->hdcp_status =3D=3D HDCP_AUTH_DONE)) + it6505_start_hdcp(it6505); + } =20 ret =3D drm_dp_dpcd_read_link_status(&it6505->aux, link_status); @@ -2431,7 +2477,7 @@ static void it6505_irq_hdcp_done(struct it6505 *it650= 5) =20 DRM_DEV_DEBUG_DRIVER(dev, "hdcp done interrupt"); it6505->hdcp_status =3D HDCP_AUTH_DONE; - it6505_show_hdcp_info(it6505); + it6505_show_hdcp_info(it6505, false); } =20 static void it6505_irq_hdcp_fail(struct it6505 *it6505) @@ -2440,7 +2486,7 @@ static void it6505_irq_hdcp_fail(struct it6505 *it650= 5) =20 DRM_DEV_DEBUG_DRIVER(dev, "hdcp fail interrupt"); it6505->hdcp_status =3D HDCP_AUTH_IDLE; - it6505_show_hdcp_info(it6505); + it6505_show_hdcp_info(it6505, true); it6505_start_hdcp(it6505); } =20 @@ -2455,7 +2501,11 @@ static void it6505_irq_hdcp_ksv_check(struct it6505 = *it6505) { struct device *dev =3D &it6505->client->dev; =20 - DRM_DEV_DEBUG_DRIVER(dev, "HDCP event Interrupt"); + DRM_DEV_DEBUG_DRIVER(dev, "HDCP repeater R0 event Interrupt"); + + it6505_set_bits(it6505, REG_HDCP_TRIGGER, + HDCP_TRIGGER_KSV_DONE, HDCP_TRIGGER_KSV_DONE); + schedule_work(&it6505->hdcp_wait_ksv_list); } =20 --=20 2.34.1 From nobody Fri Nov 29 11:51:14 2024 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 341861428E3 for ; Fri, 20 Sep 2024 08:25:24 +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=1726820726; cv=none; b=Qkh/Lm98ht8PpPqe9eyOz/mctS6UH/Cwt+8yEtZFjcC17iM+1WgDOmCSscqgemF06TB9tDQ9SWHGP3XNbiM5kknm0jOZfvYo8DBzSC8NOXhGLtitynel7FIKKvglAGITTiBwnQ0ZVVxkr+A1ZtqelN+G6/58gR1iSHVIoCD5II0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726820726; c=relaxed/simple; bh=0Hi92K2eNfUO6gp3VVENifkz/DtzOvaySvv1fHcWtLs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VaVMW5dFcAtTt4AX89tJ3b4QyZVp0GEgGiR366O4lT55NanqufiFJ+RU5lTnU/Spqz6weICyMHRxJi/vjNZyEvgZr3MYQd5fsxrCDUyXJ67MzvUYw2pLoBywCdLDgbNTIyUPSEQOytxU5xW/dt7uvS2AhfqwaLSQK0+y1jYU1f8= 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=g1Clok1b 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 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="g1Clok1b" 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=kxv6XIW0XqSH04P9Ee5p6gPpAZLINsmYVj9xYMLqSdw=; b=g1Clok1bv3e+cKeHVOZZ07S50X3jwLWLhRId0ZWPD5URTzC6bsX55SuY MWq55gHbgTmBXlGH5R+JGC8i0uVuyGVUS238TZuB6T42JPIh1SfuoXIJd xXdHd9DgrERsB+LFmoN/GYMpOJGDljAgyuzisuoq4qMbO2AyGmtXAeQ21 nFT5H1kOdt3sQS94y1RgS+a/2xE9uGRllXbggiLSdfzZ7xXMHmB78cs3t 0ofT7f/QP4CopxFyCUYsnU/tL0qsj5f2upAbORLIqMt28fOOoNwkVUGut dQFDK2++SkrLV+pPBLOjQPdwZFyumvLUUvr99FwcSYqp2qBCIv37rTMj6 w==; X-CSE-ConnectionGUID: sBgUl2LAQ0utM6vKrqWV8g== X-CSE-MsgGUID: 4AKL5Fj/ReimPE1InGcEpQ== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 20 Sep 2024 16:25:12 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48K8P5QZ024299; Fri, 20 Sep 2024 16:25:05 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Sep 2024 16:25:05 +0800 From: Hermes Wu To: Pin-yen Lin , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list CC: Kenneth Hung , Hermes Wu Subject: [PATCH v2 1/2] drm/bridge: it6505: HDCP CTS fail on repeater Date: Fri, 20 Sep 2024 16:24:50 +0800 Message-ID: <20240920082451.9240-6-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240920082451.9240-1-Hermes.Wu@ite.com.tw> References: <20240920082451.9240-1-Hermes.Wu@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: quoted-printable X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: 1D9FB2EFC60E5A84FF29CD7FC87FCB5C429BB40FB509DA0286F40653CBD9025C2002:8 X-MAIL: mse.ite.com.tw 48K8P5QZ024299 Content-Type: text/plain; charset="utf-8" From: Hermes Wu Fix HDCP CTS items on UNIGRAF DPR-100 Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 152 ++++++++++++++++++---------- 1 file changed, 101 insertions(+), 51 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index 7a4608844de3..cef02c8c363e 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -298,11 +298,11 @@ #define MAX_LANE_COUNT 4 #define MAX_LINK_RATE HBR #define AUTO_TRAIN_RETRY 3 -#define MAX_HDCP_DOWN_STREAM_COUNT 10 +#define MAX_HDCP_DOWN_STREAM_COUNT 127 #define MAX_CR_LEVEL 0x03 #define MAX_EQ_LEVEL 0x03 #define AUX_WAIT_TIMEOUT_MS 15 -#define AUX_FIFO_MAX_SIZE 32 +#define AUX_FIFO_MAX_SIZE 16 #define PIXEL_CLK_DELAY 1 #define PIXEL_CLK_INVERSE 0 #define ADJUST_PHASE_THRESHOLD 80000 @@ -326,6 +326,9 @@ enum aux_cmd_type { CMD_AUX_NATIVE_READ =3D 0x0, CMD_AUX_NATIVE_WRITE =3D 0x5, CMD_AUX_I2C_EDID_READ =3D 0xB, + + /*extend read ncommand */ + CMD_AUX_GET_KSV_LIST =3D 0x10, }; =20 enum aux_cmd_reply { @@ -973,7 +976,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it65= 05, it6505_set_bits(it6505, REG_AUX_CTRL, AUX_USER_MODE, AUX_USER_MODE); =20 aux_op_start: - if (cmd =3D=3D CMD_AUX_I2C_EDID_READ) { + if (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD_AUX_GET_KSV_LIST) { /* AUX EDID FIFO has max length of AUX_FIFO_MAX_SIZE bytes. */ size =3D min_t(size_t, size, AUX_FIFO_MAX_SIZE); /* Enable AUX FIFO read back and clear FIFO */ @@ -1004,7 +1007,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it= 6505, size); =20 /* Aux Fire */ - it6505_write(it6505, REG_AUX_CMD_REQ, cmd); + it6505_write(it6505, REG_AUX_CMD_REQ, (cmd & 0x0F)); =20 ret =3D it6505_aux_wait(it6505); if (ret < 0) @@ -1038,7 +1041,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it= 6505, goto aux_op_start; } =20 - if (cmd =3D=3D CMD_AUX_I2C_EDID_READ) { + if (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD_AUX_GET_KSV_LIST) { for (i =3D 0; i < size; i++) { ret =3D it6505_read(it6505, REG_AUX_DATA_FIFO); if (ret < 0) @@ -1063,7 +1066,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it= 6505, ret =3D i; =20 aux_op_err: - if (cmd =3D=3D CMD_AUX_I2C_EDID_READ) { + if (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD_AUX_GET_KSV_LIST) { /* clear AUX FIFO */ it6505_set_bits(it6505, REG_AUX_CTRL, AUX_EN_FIFO_READ | CLR_EDID_FIFO, @@ -1084,18 +1087,25 @@ static ssize_t it6505_aux_do_transfer(struct it6505= *it6505, size_t size, enum aux_cmd_reply *reply) { int i, ret_size, ret =3D 0, request_size; + struct device *dev =3D &it6505->client->dev; =20 mutex_lock(&it6505->aux_lock); - for (i =3D 0; i < size; i +=3D 4) { - request_size =3D min((int)size - i, 4); + for (i =3D 0; i < size; ) { + if (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD_AUX_GET_KSV_LIST) + request_size =3D min((int)size - i, AUX_FIFO_MAX_SIZE); + else + request_size =3D min((int)size - i, 4); + ret_size =3D it6505_aux_operation(it6505, cmd, address + i, buffer + i, request_size, reply); + if (ret_size < 0) { ret =3D ret_size; goto aux_op_err; } =20 + i +=3D request_size; ret +=3D ret_size; } =20 @@ -1186,6 +1196,35 @@ static int it6505_get_edid_block(void *data, u8 *buf= , unsigned int block, return 0; } =20 +static int it6505_get_ksvlist(struct it6505 *it6505, u8 *buf, size_t len) +{ + int i, request_size, ret; + struct device *dev =3D &it6505->client->dev; + enum aux_cmd_reply reply; + + for (i =3D 0; i < len; ) { + request_size =3D min((int)len - i, 15); + + ret =3D it6505_aux_do_transfer(it6505, CMD_AUX_GET_KSV_LIST, + DP_AUX_HDCP_KSV_FIFO, + buf + i, request_size, &reply); + + DRM_DEV_DEBUG_DRIVER(dev, "request_size =3D %d, ret =3D%d", request_size= , ret); + if (ret < 0) + return ret; + + i +=3D request_size; + } + + DRM_DEV_DEBUG_DRIVER(dev, "ksv read cnt =3D %d down_stream_cnt=3D%d ", i,= i/5); + + for (i =3D 0 ; i < len; i +=3D 5) + DRM_DEV_DEBUG_DRIVER(dev, "ksv[%d] =3D %02X%02X%02X%02X%02X", + i/5, buf[i], buf[i + 1], buf[i + 2], buf[i + 3], buf[i + 4]); + + return len; +} + static void it6505_variable_config(struct it6505 *it6505) { it6505->link_rate_bw_code =3D HBR; @@ -1927,6 +1966,7 @@ static void it6505_hdcp_part1_auth(struct it6505 *it6= 505) it6505_set_bits(it6505, REG_HDCP_TRIGGER, HDCP_TRIGGER_START, HDCP_TRIGGER_START); =20 + it6505->is_repeater =3D (hdcp_bcaps & DP_BCAPS_REPEATER_PRESENT); it6505->hdcp_status =3D HDCP_AUTH_GOING; } =20 @@ -1963,7 +2003,7 @@ static int it6505_setup_sha1_input(struct it6505 *it6= 505, u8 *sha1_input) { struct device *dev =3D &it6505->client->dev; u8 binfo[2]; - int down_stream_count, i, err, msg_count =3D 0; + int down_stream_count, err, msg_count =3D 0; =20 err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_BINFO, binfo, ARRAY_SIZE(binfo)); @@ -1989,17 +2029,12 @@ static int it6505_setup_sha1_input(struct it6505 *i= t6505, u8 *sha1_input) return 0; } =20 - for (i =3D 0; i < down_stream_count; i++) { - err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_KSV_FIFO + - (i % 3) * DRM_HDCP_KSV_LEN, - sha1_input + msg_count, - DRM_HDCP_KSV_LEN); =20 - if (err < 0) - return err; + err =3D it6505_get_ksvlist(it6505, sha1_input, down_stream_count * 5); + if (err < 0) + return err; =20 - msg_count +=3D 5; - } + msg_count +=3D down_stream_count * 5; =20 it6505->hdcp_down_stream_count =3D down_stream_count; sha1_input[msg_count++] =3D binfo[0]; @@ -2027,7 +2062,7 @@ static bool it6505_hdcp_part2_ksvlist_check(struct it= 6505 *it6505) { struct device *dev =3D &it6505->client->dev; u8 av[5][4], bv[5][4]; - int i, err; + int i, err, retry; =20 i =3D it6505_setup_sha1_input(it6505, it6505->sha1_input); if (i <=3D 0) { @@ -2037,21 +2072,28 @@ static bool it6505_hdcp_part2_ksvlist_check(struct = it6505 *it6505) =20 it6505_sha1_digest(it6505, it6505->sha1_input, i, (u8 *)av); =20 - err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_V_PRIME(0), (u8 *)bv, - sizeof(bv)); + for (retry =3D 0; retry < 3; retry++) { =20 - if (err < 0) { - dev_err(dev, "Read V' value Fail"); - return false; - } + err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_V_PRIME(0), (u8 *)bv, + sizeof(bv)); =20 - for (i =3D 0; i < 5; i++) - if (bv[i][3] !=3D av[i][0] || bv[i][2] !=3D av[i][1] || - bv[i][1] !=3D av[i][2] || bv[i][0] !=3D av[i][3]) - return false; + if (err < 0) { + dev_err(dev, "Read V' value Fail %d", retry); + continue; + } =20 - DRM_DEV_DEBUG_DRIVER(dev, "V' all match!!"); - return true; + for (i =3D 0; i < 5; i++) { + if (bv[i][3] !=3D av[i][0] || bv[i][2] !=3D av[i][1] || + bv[i][1] !=3D av[i][2] || bv[i][0] !=3D av[i][3]) + break; + + DRM_DEV_DEBUG_DRIVER(dev, "V' all match!! %d, %d", retry, i); + return true; + } + } + + DRM_DEV_DEBUG_DRIVER(dev, "V' NOT match!! %d", retry); + return false; } =20 static void it6505_hdcp_wait_ksv_list(struct work_struct *work) @@ -2059,7 +2101,7 @@ static void it6505_hdcp_wait_ksv_list(struct work_str= uct *work) struct it6505 *it6505 =3D container_of(work, struct it6505, hdcp_wait_ksv_list); struct device *dev =3D &it6505->client->dev; - unsigned int timeout =3D 5000; + unsigned int timeout =3D 2000; u8 bstatus =3D 0; bool ksv_list_check; =20 @@ -2079,21 +2121,18 @@ static void it6505_hdcp_wait_ksv_list(struct work_s= truct *work) =20 if (timeout =3D=3D 0) { DRM_DEV_DEBUG_DRIVER(dev, "timeout and ksv list wait failed"); - goto timeout; + goto hdcp_ksvlist_fail; } =20 ksv_list_check =3D it6505_hdcp_part2_ksvlist_check(it6505); DRM_DEV_DEBUG_DRIVER(dev, "ksv list ready, ksv list check %s", - ksv_list_check ? "pass" : "fail"); - if (ksv_list_check) { - it6505_set_bits(it6505, REG_HDCP_TRIGGER, - HDCP_TRIGGER_KSV_DONE, HDCP_TRIGGER_KSV_DONE); + ksv_list_check ? "pass" : "fail"); + + if (ksv_list_check) return; - } -timeout: - it6505_set_bits(it6505, REG_HDCP_TRIGGER, - HDCP_TRIGGER_KSV_DONE | HDCP_TRIGGER_KSV_FAIL, - HDCP_TRIGGER_KSV_DONE | HDCP_TRIGGER_KSV_FAIL); + +hdcp_ksvlist_fail: + it6505_start_hdcp(it6505); } =20 static void it6505_hdcp_work(struct work_struct *work) @@ -2139,7 +2178,7 @@ static void it6505_hdcp_work(struct work_struct *work) it6505_hdcp_part1_auth(it6505); } =20 -static void it6505_show_hdcp_info(struct it6505 *it6505) +static void it6505_show_hdcp_info(struct it6505 *it6505, bool repeater_inf= o) { struct device *dev =3D &it6505->client->dev; int i; @@ -2150,7 +2189,7 @@ static void it6505_show_hdcp_info(struct it6505 *it65= 05) DRM_DEV_DEBUG_DRIVER(dev, "bksv =3D 0x%*ph", (int)ARRAY_SIZE(it6505->bksvs), it6505->bksvs); =20 - if (it6505->is_repeater) { + if ((repeater_info) && (it6505->is_repeater)) { DRM_DEV_DEBUG_DRIVER(dev, "hdcp_down_stream_count: %d", it6505->hdcp_down_stream_count); DRM_DEV_DEBUG_DRIVER(dev, "sha1_input: 0x%*ph", @@ -2251,12 +2290,11 @@ static void it6505_link_training_work(struct work_s= truct *work) if (ret) { it6505->auto_train_retry =3D AUTO_TRAIN_RETRY; it6505_link_train_ok(it6505); - return; } else { it6505->auto_train_retry--; + it6505_dump(it6505); } =20 - it6505_dump(it6505); } =20 static void it6505_plugged_status_to_codec(struct it6505 *it6505) @@ -2311,14 +2349,22 @@ static int it6505_process_hpd_irq(struct it6505 *it= 6505) DRM_DEV_DEBUG_DRIVER(dev, "dp_irq_vector =3D 0x%02x", dp_irq_vector); =20 if (dp_irq_vector & DP_CP_IRQ) { - it6505_set_bits(it6505, REG_HDCP_TRIGGER, HDCP_TRIGGER_CPIRQ, - HDCP_TRIGGER_CPIRQ); =20 bstatus =3D it6505_dpcd_read(it6505, DP_AUX_HDCP_BSTATUS); if (bstatus < 0) return bstatus; =20 DRM_DEV_DEBUG_DRIVER(dev, "Bstatus =3D 0x%02x", bstatus); + + /*1B-02 ignore when bstatus is 0 */ + if ((bstatus & DP_BSTATUS_R0_PRIME_READY) && + (it6505->hdcp_status =3D=3D HDCP_AUTH_GOING)) + it6505_set_bits(it6505, REG_HDCP_TRIGGER, HDCP_TRIGGER_CPIRQ, + HDCP_TRIGGER_CPIRQ); + else if ((bstatus & (DP_BSTATUS_REAUTH_REQ | DP_BSTATUS_LINK_FAILURE)) && + (it6505->hdcp_status =3D=3D HDCP_AUTH_DONE)) + it6505_start_hdcp(it6505); + } =20 ret =3D drm_dp_dpcd_read_link_status(&it6505->aux, link_status); @@ -2431,7 +2477,7 @@ static void it6505_irq_hdcp_done(struct it6505 *it650= 5) =20 DRM_DEV_DEBUG_DRIVER(dev, "hdcp done interrupt"); it6505->hdcp_status =3D HDCP_AUTH_DONE; - it6505_show_hdcp_info(it6505); + it6505_show_hdcp_info(it6505, false); } =20 static void it6505_irq_hdcp_fail(struct it6505 *it6505) @@ -2440,7 +2486,7 @@ static void it6505_irq_hdcp_fail(struct it6505 *it650= 5) =20 DRM_DEV_DEBUG_DRIVER(dev, "hdcp fail interrupt"); it6505->hdcp_status =3D HDCP_AUTH_IDLE; - it6505_show_hdcp_info(it6505); + it6505_show_hdcp_info(it6505, true); it6505_start_hdcp(it6505); } =20 @@ -2455,7 +2501,11 @@ static void it6505_irq_hdcp_ksv_check(struct it6505 = *it6505) { struct device *dev =3D &it6505->client->dev; =20 - DRM_DEV_DEBUG_DRIVER(dev, "HDCP event Interrupt"); + DRM_DEV_DEBUG_DRIVER(dev, "HDCP repeater R0 event Interrupt"); + + it6505_set_bits(it6505, REG_HDCP_TRIGGER, + HDCP_TRIGGER_KSV_DONE, HDCP_TRIGGER_KSV_DONE); + schedule_work(&it6505->hdcp_wait_ksv_list); } =20 --=20 2.34.1 From nobody Fri Nov 29 11:51:14 2024 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 8F3E613C827 for ; Fri, 20 Sep 2024 08:25:19 +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=1726820722; cv=none; b=HsnK0S5ufgvn8dc9RA75z+pZ2NAEYh8iWCjHU7z6M8cg6m07pP0g4/Q+Q8ciRcqB5TiAPuhiC7E0JMo/Dyqsnq1N+mpK3f0lorVf18eytU4SXfq9hgIWvls608Mh12m7cHLifi7BGiCMcOxT+Wc7CIR+vFzlV7roKaEaEJvfoXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726820722; c=relaxed/simple; bh=0pYi2Ni0VLg4Q2jL0VHsJ0rBYp+TMB0afkc/uJHrl6A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Bl7TO1/CZGXRXGBIf34IZTFz87bX7cV6RE2HlXOs1cb/KYO8TXlbGj13vumQbBVKoiLnKXR4Uxi2w1qon8puOHuWbJ5nCEBR4X7Ls6gfnEXQljK6ToFmsE5W3ar6LS+dcZZYesj5DMme/ff/YEpvbDXHeihb1ReB7KBYDEXkHPc= 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=lCdjeSIG 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 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="lCdjeSIG" 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=9z9UGdgk9MPxd1ynPoki1CPpX1B3DsdgFQ83VM+CmXk=; b=lCdjeSIGoJN1tPWv3PMdzg+6UcuD+XtNYoQxjBaoAKmljR6Mfm6Gfs0j 4FwAKpzv4xcLt2qmS/1cVKgpwV5zPpaIGDeDpv2RXUjZEnuSABJnkKQ0l cSwpTl9a/8vsxEKbhqkYW3Tfr3FQ/gGghpP+QyZ6er3eidoy+S4dFl3LG 065KiMZe+4qwkdykf8oFMVpFVlKh9jApFAd7WOWDv6pw0wekO6rvPMmiU Xq/nAjzCUJRqk6urEDUUGdA2BNklq+r9OMWqHf3CofuYs12QE1yG1E5wu LdCpuBj7ayuTNIrb5b03H4keayjSeNIvMv2hG0DRrgy9wvYg1TWDtRo/X Q==; X-CSE-ConnectionGUID: LcuEqNKkReGHpFOh6zpF8Q== X-CSE-MsgGUID: uCr+x7XfSJqIsspO+mJfFQ== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 20 Sep 2024 16:25:08 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48K8P3ib024272; Fri, 20 Sep 2024 16:25:03 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Sep 2024 16:25:04 +0800 From: Hermes Wu To: Pin-yen Lin , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list CC: Kenneth Hung , "Hermes.Wu" Subject: [PATCH v1 2/2] drm/bridge: it6505: Add MSSC suport Date: Fri, 20 Sep 2024 16:24:47 +0800 Message-ID: <20240920082451.9240-3-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240920082451.9240-1-Hermes.Wu@ite.com.tw> References: <20240920082451.9240-1-Hermes.Wu@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: quoted-printable X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: 388D328793418E230CC7EE2FD6ECDCBA220317C431FE6CACFE729420A1BDB04D2002:8 X-MAIL: mse.ite.com.tw 48K8P3ib024272 Content-Type: text/plain; charset="utf-8" From: "Hermes.Wu" add AUX-I2C functionality to support MCCS.=20 Change-Id: I63e1a0e5da67526f89f35605a82944be67dee8ac Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 209 ++++++++++++++++++++++++++-- 1 file changed, 200 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index cef02c8c363e..1a272c67e82b 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -127,6 +127,9 @@ #define REG_AUX_ADR_16_19 0x26 #define REG_AUX_OUT_DATA0 0x27 =20 +#define REG_AUX_I2C_ADR 0x25 +#define REG_AUX_I2C_OP 0x26 + #define REG_AUX_CMD_REQ 0x2B #define AUX_BUSY BIT(5) =20 @@ -268,6 +271,19 @@ #define REG_SSC_CTRL1 0x189 #define REG_SSC_CTRL2 0x18A =20 +#define REG_AUX_USER_CTRL 0x190 +#define EN_USER_AUX BIT(0) +#define USER_AUX_DONE BIT(1) +#define AUX_EVENT BIT(4) + +#define REG_AUX_USER_DATA_REC 0x191 +#define M_AUX_IN_REC 0xF0 +#define M_AUX_OUT_REC 0x0F + +#define REG_AUX_USER_TXB 0x190 +#define REG_AUX_USER_REPLY 0x19A +#define REG_AUX_USER_RXB(n) (n + 0x19B) + #define RBR DP_LINK_BW_1_62 #define HBR DP_LINK_BW_2_7 #define HBR2 DP_LINK_BW_5_4 @@ -303,6 +319,8 @@ #define MAX_EQ_LEVEL 0x03 #define AUX_WAIT_TIMEOUT_MS 15 #define AUX_FIFO_MAX_SIZE 16 +#define AUX_I2C_MAX_SIZE 4 +#define AUX_I2C_DEFER_RETRY 4 #define PIXEL_CLK_DELAY 1 #define PIXEL_CLK_INVERSE 0 #define ADJUST_PHASE_THRESHOLD 80000 @@ -325,7 +343,12 @@ enum aux_cmd_type { CMD_AUX_NATIVE_READ =3D 0x0, CMD_AUX_NATIVE_WRITE =3D 0x5, + CMD_AUX_GI2C_ADR =3D 0x08, + CMD_AUX_GI2C_READ =3D 0x09, + CMD_AUX_GI2C_WRITE =3D 0x0A, CMD_AUX_I2C_EDID_READ =3D 0xB, + CMD_AUX_I2C_READ =3D 0x0D, + CMD_AUX_I2C_WRITE =3D 0x0C, =20 /*extend read ncommand */ CMD_AUX_GET_KSV_LIST =3D 0x10, @@ -333,8 +356,11 @@ enum aux_cmd_type { =20 enum aux_cmd_reply { REPLY_ACK, - REPLY_NACK, - REPLY_DEFER, + REPLY_NACK =3D 1, + REPLY_DEFER =3D 2, + + REPLY_I2C_NACK =3D 4, + REPLY_I2C_DEFER =3D 8, }; =20 enum link_train_status { @@ -1087,7 +1113,6 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *= it6505, size_t size, enum aux_cmd_reply *reply) { int i, ret_size, ret =3D 0, request_size; - struct device *dev =3D &it6505->client->dev; =20 mutex_lock(&it6505->aux_lock); for (i =3D 0; i < size; ) { @@ -1114,6 +1139,168 @@ static ssize_t it6505_aux_do_transfer(struct it6505= *it6505, return ret; } =20 + +static int it6505_aux_i2c_wait(struct it6505 *it6505, u8 *reply) +{ + int err =3D 0; + unsigned long timeout; + struct device *dev =3D &it6505->client->dev; + + timeout =3D jiffies + msecs_to_jiffies(AUX_WAIT_TIMEOUT_MS) + 1; + + do { + if (it6505_read(it6505, REG_AUX_USER_CTRL) & AUX_EVENT) + break; + if (time_after(jiffies, timeout)) { + dev_err(dev, "Timed out waiting AUX I2C, BUSY =3D %X\n", + it6505_aux_op_finished(it6505)); + err =3D -ETIMEDOUT; + goto end_aux_i2c_wait; + } + usleep_range(300, 800); + + } while (!it6505_aux_op_finished(it6505)); + + if (reply =3D=3D NULL) + goto end_aux_i2c_wait; + + *reply =3D it6505_read(it6505, REG_AUX_USER_REPLY) >> 4; + + if (*reply =3D=3D 0) + goto end_aux_i2c_wait; + + if ((*reply =3D=3D DP_AUX_NATIVE_REPLY_DEFER) || + (*reply =3D=3D DP_AUX_I2C_REPLY_DEFER)) + err =3D -EBUSY; + else if ((*reply =3D=3D DP_AUX_NATIVE_REPLY_NACK) || + (*reply =3D=3D DP_AUX_I2C_REPLY_NACK)) + err =3D -ENXIO; + +end_aux_i2c_wait: + it6505_set_bits(it6505, REG_AUX_USER_CTRL, USER_AUX_DONE, USER_AUX_DONE); + return err; +} + +static int it6505_aux_i2c_readb(struct it6505 *it6505, u8 *buf, size_t siz= e, u8 *reply) +{ + int ret, i; + int retry =3D 0; + + for (retry =3D 0; retry < AUX_I2C_DEFER_RETRY; retry++) { + + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_READ); + + ret =3D it6505_aux_i2c_wait(it6505, reply); + + if ((*reply =3D=3D DP_AUX_NATIVE_REPLY_DEFER) || + (*reply =3D=3D DP_AUX_I2C_REPLY_DEFER)) + continue; + + if (ret >=3D 0) + break; + } + + for (i =3D 0; i < size; i++) + buf[i] =3D (u8) it6505_read(it6505, REG_AUX_USER_RXB(0 + i)); + + return size; +} + +static int it6505_aux_i2c_writeb(struct it6505 *it6505, u8 *buf, size_t si= ze, u8 *reply) +{ + int i, ret; + int retry =3D 0; + + for (i =3D 0; i < size; i++) + it6505_write(it6505, REG_AUX_OUT_DATA0 + i, buf[i]); + + for (retry =3D 0; retry < AUX_I2C_DEFER_RETRY; retry++) { + + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_WRITE); + + ret =3D it6505_aux_i2c_wait(it6505, reply); + + if ((*reply =3D=3D DP_AUX_NATIVE_REPLY_DEFER) || + (*reply =3D=3D DP_AUX_I2C_REPLY_DEFER)) + continue; + + if (ret >=3D 0) + break; + } + return size; +} + +static ssize_t it6505_aux_i2c_operation(struct it6505 *it6505, + struct drm_dp_aux_msg *msg) +{ + int ret; + ssize_t request_size, data_cnt =3D 0; + struct device *dev =3D &it6505->client->dev; + u8 *buffer =3D msg->buffer; + + /* set AUX user mode */ + it6505_set_bits(it6505, REG_AUX_CTRL, + AUX_USER_MODE | AUX_NO_SEGMENT_WR, AUX_USER_MODE); + it6505_set_bits(it6505, REG_AUX_USER_CTRL, EN_USER_AUX, EN_USER_AUX); + /* clear AUX FIFO */ + it6505_set_bits(it6505, REG_AUX_CTRL, + AUX_EN_FIFO_READ | CLR_EDID_FIFO, + AUX_EN_FIFO_READ | CLR_EDID_FIFO); + + it6505_set_bits(it6505, REG_AUX_CTRL, + AUX_EN_FIFO_READ | CLR_EDID_FIFO, 0x00); + + it6505_write(it6505, REG_AUX_ADR_0_7, 0x00); + it6505_write(it6505, REG_AUX_I2C_ADR, msg->address << 1); + + if (msg->size =3D=3D 0) { + /* IIC Start/STOP dummy write */ + it6505_write(it6505, REG_AUX_I2C_OP, msg->request); + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_ADR); + ret =3D it6505_aux_i2c_wait(it6505, &msg->reply); + goto end_aux_i2c_transfer; + } + + /* IIC data transfer */ + for (data_cnt =3D 0; data_cnt < msg->size; ) { + request_size =3D min(msg->size - data_cnt, AUX_I2C_MAX_SIZE); + it6505_write(it6505, REG_AUX_I2C_OP, + (msg->request) | ((request_size - 1) << 4)); + + if ((msg->request & DP_AUX_I2C_READ) =3D=3D DP_AUX_I2C_READ) + ret =3D it6505_aux_i2c_readb(it6505, &buffer[data_cnt], + request_size, &msg->reply); + else + ret =3D it6505_aux_i2c_writeb(it6505, &buffer[data_cnt], + request_size, &msg->reply); + + if (ret < 0) + goto end_aux_i2c_transfer; + + data_cnt +=3D request_size; + } + ret =3D data_cnt; +end_aux_i2c_transfer: + + it6505_set_bits(it6505, REG_AUX_USER_CTRL, EN_USER_AUX, 0); + it6505_set_bits(it6505, REG_AUX_CTRL, AUX_USER_MODE, 0); + return ret; +} + + +static ssize_t it6505_aux_i2c_transfer(struct drm_dp_aux *aux, + struct drm_dp_aux_msg *msg) +{ + struct it6505 *it6505 =3D container_of(aux, struct it6505, aux); + int ret; + + mutex_lock(&it6505->aux_lock); + ret =3D it6505_aux_i2c_operation(it6505, msg); + mutex_unlock(&it6505->aux_lock); + return ret; +} + + static ssize_t it6505_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) { @@ -1125,7 +1312,7 @@ static ssize_t it6505_aux_transfer(struct drm_dp_aux = *aux, =20 /* IT6505 doesn't support arbitrary I2C read / write. */ if (is_i2c) - return -EINVAL; + return it6505_aux_i2c_transfer(aux, msg); =20 switch (msg->request) { case DP_AUX_NATIVE_READ: @@ -1153,6 +1340,8 @@ static ssize_t it6505_aux_transfer(struct drm_dp_aux = *aux, case REPLY_DEFER: msg->reply =3D DP_AUX_NATIVE_REPLY_DEFER; break; + default: + break; } =20 return ret; @@ -1180,7 +1369,7 @@ static int it6505_get_edid_block(void *data, u8 *buf,= unsigned int block, switch (reply) { case REPLY_ACK: DRM_DEV_DEBUG_DRIVER(dev, "[0x%02x]: %8ph", offset, - buf + offset); + uf + offset); offset +=3D 8; aux_retry =3D 100; break; @@ -1190,6 +1379,8 @@ static int it6505_get_edid_block(void *data, u8 *buf,= unsigned int block, msleep(20); if (!(--aux_retry)) return -EIO; + default: + break; } } =20 @@ -2031,8 +2222,8 @@ static int it6505_setup_sha1_input(struct it6505 *it6= 505, u8 *sha1_input) =20 =20 err =3D it6505_get_ksvlist(it6505, sha1_input, down_stream_count * 5); - if (err < 0) - return err; + if (err < 0) + return err; =20 msg_count +=3D down_stream_count * 5; =20 @@ -2075,7 +2266,7 @@ static bool it6505_hdcp_part2_ksvlist_check(struct it= 6505 *it6505) for (retry =3D 0; retry < 3; retry++) { =20 err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_V_PRIME(0), (u8 *)bv, - sizeof(bv)); + sizeof(bv)); =20 if (err < 0) { dev_err(dev, "Read V' value Fail %d", retry); @@ -2126,7 +2317,7 @@ static void it6505_hdcp_wait_ksv_list(struct work_str= uct *work) =20 ksv_list_check =3D it6505_hdcp_part2_ksvlist_check(it6505); DRM_DEV_DEBUG_DRIVER(dev, "ksv list ready, ksv list check %s", - ksv_list_check ? "pass" : "fail"); + ksv_list_check ? "pass" : "fail"); =20 if (ksv_list_check) return; --=20 2.34.1 From nobody Fri Nov 29 11:51:14 2024 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 7090913D8A4 for ; Fri, 20 Sep 2024 08:25:21 +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=1726820723; cv=none; b=PmVzIVn4KRNTgTg9yZSuoDVHJ24E7fqM3dZFAwMq/3IbYE5Wzgd3R9cJ33nmi3EsYI9iKIOSA1sUSQn09I6EWBkeVQGffaYZD9vc8WsffhEtk+uZCRlu1c33JtiGcvFu6jT//Rhl38e5MmeumIDEvGmQG6SyR+xXojgktcsMfEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726820723; c=relaxed/simple; bh=BnUK6/AoCSS6+O2NC8KhIqCyJ/Ezt5/FTV26j/3uaAw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UhUckjf+xLg9YBlKYfkJv8cNIYsaCsUm3ps70mG2y7tXdHRbn0vJ5oZu3xIw4TBghcXiN6rnc/n20uXS0w8PnwwSMaZPG1ARUUKi2cLo/QAuVls1snizJaZUa3WpQaq0OOhGmNkcRQYkEmRKnuvgOVWf/ekVOIF7bpclQpQfjqI= 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=i4beTXzH 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 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="i4beTXzH" 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=m2FJTguNPM0THfwZyeppm7yUQmpKnPmqDkBNYjXFk08=; b=i4beTXzHZPrysr6836nslFnuTU4MIPZFHs1NkBC/dDFAssezICe1e4vy zX25oUeqb4ubgnDy0BQogQtaIqtHxKfW+oq2n1uzbwcUT4qL5zXxYN5FR M8KX2kOAJhCYVE0h+uYJy6iNFF/MHk418HDEH9kyJs3JOJP4VcJuO/6Xl 5W644oxETpluDYGFKbXVqCMdtofBSQrfJ709xDbPb+J7j+XmW3+dBn9TJ Bu5dXw/EPJdeQU4h5EczN3c+/HBs8gKBmZ30wNg17fQoCnf3DfZuBhowm S81matCcLfTFPuMe8ysR5gsHjETY3jnwlmTPMIQpQPXtTNV04XrHLmMTy A==; X-CSE-ConnectionGUID: 58PhIuTHTrOtM3xlhW6+aA== X-CSE-MsgGUID: ocB2NheZTeOGG9eH2YSvAA== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 20 Sep 2024 16:25:09 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48K8P4iR024273; Fri, 20 Sep 2024 16:25:04 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Sep 2024 16:25:04 +0800 From: Hermes Wu To: Pin-yen Lin , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list CC: Kenneth Hung , "Hermes.Wu" Subject: [PATCH v2 2/2] drm/bridge: it6505: Add MSSC suport Date: Fri, 20 Sep 2024 16:24:48 +0800 Message-ID: <20240920082451.9240-4-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240920082451.9240-1-Hermes.Wu@ite.com.tw> References: <20240920082451.9240-1-Hermes.Wu@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: quoted-printable X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: B69D8071F0782D9708C9AAB0DB9B6309E3A7F78D96604FD3BB10CE79014CF0BD2002:8 X-MAIL: mse.ite.com.tw 48K8P4iR024273 Content-Type: text/plain; charset="utf-8" From: "Hermes.Wu" Add AUX i2c funtion for MCCS Change-Id: Ia8952f3cde4d9610d6f8a0c3915fc6ffefc6da22 Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 209 ++++++++++++++++++++++++++-- 1 file changed, 200 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index cef02c8c363e..1a272c67e82b 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -127,6 +127,9 @@ #define REG_AUX_ADR_16_19 0x26 #define REG_AUX_OUT_DATA0 0x27 =20 +#define REG_AUX_I2C_ADR 0x25 +#define REG_AUX_I2C_OP 0x26 + #define REG_AUX_CMD_REQ 0x2B #define AUX_BUSY BIT(5) =20 @@ -268,6 +271,19 @@ #define REG_SSC_CTRL1 0x189 #define REG_SSC_CTRL2 0x18A =20 +#define REG_AUX_USER_CTRL 0x190 +#define EN_USER_AUX BIT(0) +#define USER_AUX_DONE BIT(1) +#define AUX_EVENT BIT(4) + +#define REG_AUX_USER_DATA_REC 0x191 +#define M_AUX_IN_REC 0xF0 +#define M_AUX_OUT_REC 0x0F + +#define REG_AUX_USER_TXB 0x190 +#define REG_AUX_USER_REPLY 0x19A +#define REG_AUX_USER_RXB(n) (n + 0x19B) + #define RBR DP_LINK_BW_1_62 #define HBR DP_LINK_BW_2_7 #define HBR2 DP_LINK_BW_5_4 @@ -303,6 +319,8 @@ #define MAX_EQ_LEVEL 0x03 #define AUX_WAIT_TIMEOUT_MS 15 #define AUX_FIFO_MAX_SIZE 16 +#define AUX_I2C_MAX_SIZE 4 +#define AUX_I2C_DEFER_RETRY 4 #define PIXEL_CLK_DELAY 1 #define PIXEL_CLK_INVERSE 0 #define ADJUST_PHASE_THRESHOLD 80000 @@ -325,7 +343,12 @@ enum aux_cmd_type { CMD_AUX_NATIVE_READ =3D 0x0, CMD_AUX_NATIVE_WRITE =3D 0x5, + CMD_AUX_GI2C_ADR =3D 0x08, + CMD_AUX_GI2C_READ =3D 0x09, + CMD_AUX_GI2C_WRITE =3D 0x0A, CMD_AUX_I2C_EDID_READ =3D 0xB, + CMD_AUX_I2C_READ =3D 0x0D, + CMD_AUX_I2C_WRITE =3D 0x0C, =20 /*extend read ncommand */ CMD_AUX_GET_KSV_LIST =3D 0x10, @@ -333,8 +356,11 @@ enum aux_cmd_type { =20 enum aux_cmd_reply { REPLY_ACK, - REPLY_NACK, - REPLY_DEFER, + REPLY_NACK =3D 1, + REPLY_DEFER =3D 2, + + REPLY_I2C_NACK =3D 4, + REPLY_I2C_DEFER =3D 8, }; =20 enum link_train_status { @@ -1087,7 +1113,6 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *= it6505, size_t size, enum aux_cmd_reply *reply) { int i, ret_size, ret =3D 0, request_size; - struct device *dev =3D &it6505->client->dev; =20 mutex_lock(&it6505->aux_lock); for (i =3D 0; i < size; ) { @@ -1114,6 +1139,168 @@ static ssize_t it6505_aux_do_transfer(struct it6505= *it6505, return ret; } =20 + +static int it6505_aux_i2c_wait(struct it6505 *it6505, u8 *reply) +{ + int err =3D 0; + unsigned long timeout; + struct device *dev =3D &it6505->client->dev; + + timeout =3D jiffies + msecs_to_jiffies(AUX_WAIT_TIMEOUT_MS) + 1; + + do { + if (it6505_read(it6505, REG_AUX_USER_CTRL) & AUX_EVENT) + break; + if (time_after(jiffies, timeout)) { + dev_err(dev, "Timed out waiting AUX I2C, BUSY =3D %X\n", + it6505_aux_op_finished(it6505)); + err =3D -ETIMEDOUT; + goto end_aux_i2c_wait; + } + usleep_range(300, 800); + + } while (!it6505_aux_op_finished(it6505)); + + if (reply =3D=3D NULL) + goto end_aux_i2c_wait; + + *reply =3D it6505_read(it6505, REG_AUX_USER_REPLY) >> 4; + + if (*reply =3D=3D 0) + goto end_aux_i2c_wait; + + if ((*reply =3D=3D DP_AUX_NATIVE_REPLY_DEFER) || + (*reply =3D=3D DP_AUX_I2C_REPLY_DEFER)) + err =3D -EBUSY; + else if ((*reply =3D=3D DP_AUX_NATIVE_REPLY_NACK) || + (*reply =3D=3D DP_AUX_I2C_REPLY_NACK)) + err =3D -ENXIO; + +end_aux_i2c_wait: + it6505_set_bits(it6505, REG_AUX_USER_CTRL, USER_AUX_DONE, USER_AUX_DONE); + return err; +} + +static int it6505_aux_i2c_readb(struct it6505 *it6505, u8 *buf, size_t siz= e, u8 *reply) +{ + int ret, i; + int retry =3D 0; + + for (retry =3D 0; retry < AUX_I2C_DEFER_RETRY; retry++) { + + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_READ); + + ret =3D it6505_aux_i2c_wait(it6505, reply); + + if ((*reply =3D=3D DP_AUX_NATIVE_REPLY_DEFER) || + (*reply =3D=3D DP_AUX_I2C_REPLY_DEFER)) + continue; + + if (ret >=3D 0) + break; + } + + for (i =3D 0; i < size; i++) + buf[i] =3D (u8) it6505_read(it6505, REG_AUX_USER_RXB(0 + i)); + + return size; +} + +static int it6505_aux_i2c_writeb(struct it6505 *it6505, u8 *buf, size_t si= ze, u8 *reply) +{ + int i, ret; + int retry =3D 0; + + for (i =3D 0; i < size; i++) + it6505_write(it6505, REG_AUX_OUT_DATA0 + i, buf[i]); + + for (retry =3D 0; retry < AUX_I2C_DEFER_RETRY; retry++) { + + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_WRITE); + + ret =3D it6505_aux_i2c_wait(it6505, reply); + + if ((*reply =3D=3D DP_AUX_NATIVE_REPLY_DEFER) || + (*reply =3D=3D DP_AUX_I2C_REPLY_DEFER)) + continue; + + if (ret >=3D 0) + break; + } + return size; +} + +static ssize_t it6505_aux_i2c_operation(struct it6505 *it6505, + struct drm_dp_aux_msg *msg) +{ + int ret; + ssize_t request_size, data_cnt =3D 0; + struct device *dev =3D &it6505->client->dev; + u8 *buffer =3D msg->buffer; + + /* set AUX user mode */ + it6505_set_bits(it6505, REG_AUX_CTRL, + AUX_USER_MODE | AUX_NO_SEGMENT_WR, AUX_USER_MODE); + it6505_set_bits(it6505, REG_AUX_USER_CTRL, EN_USER_AUX, EN_USER_AUX); + /* clear AUX FIFO */ + it6505_set_bits(it6505, REG_AUX_CTRL, + AUX_EN_FIFO_READ | CLR_EDID_FIFO, + AUX_EN_FIFO_READ | CLR_EDID_FIFO); + + it6505_set_bits(it6505, REG_AUX_CTRL, + AUX_EN_FIFO_READ | CLR_EDID_FIFO, 0x00); + + it6505_write(it6505, REG_AUX_ADR_0_7, 0x00); + it6505_write(it6505, REG_AUX_I2C_ADR, msg->address << 1); + + if (msg->size =3D=3D 0) { + /* IIC Start/STOP dummy write */ + it6505_write(it6505, REG_AUX_I2C_OP, msg->request); + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_ADR); + ret =3D it6505_aux_i2c_wait(it6505, &msg->reply); + goto end_aux_i2c_transfer; + } + + /* IIC data transfer */ + for (data_cnt =3D 0; data_cnt < msg->size; ) { + request_size =3D min(msg->size - data_cnt, AUX_I2C_MAX_SIZE); + it6505_write(it6505, REG_AUX_I2C_OP, + (msg->request) | ((request_size - 1) << 4)); + + if ((msg->request & DP_AUX_I2C_READ) =3D=3D DP_AUX_I2C_READ) + ret =3D it6505_aux_i2c_readb(it6505, &buffer[data_cnt], + request_size, &msg->reply); + else + ret =3D it6505_aux_i2c_writeb(it6505, &buffer[data_cnt], + request_size, &msg->reply); + + if (ret < 0) + goto end_aux_i2c_transfer; + + data_cnt +=3D request_size; + } + ret =3D data_cnt; +end_aux_i2c_transfer: + + it6505_set_bits(it6505, REG_AUX_USER_CTRL, EN_USER_AUX, 0); + it6505_set_bits(it6505, REG_AUX_CTRL, AUX_USER_MODE, 0); + return ret; +} + + +static ssize_t it6505_aux_i2c_transfer(struct drm_dp_aux *aux, + struct drm_dp_aux_msg *msg) +{ + struct it6505 *it6505 =3D container_of(aux, struct it6505, aux); + int ret; + + mutex_lock(&it6505->aux_lock); + ret =3D it6505_aux_i2c_operation(it6505, msg); + mutex_unlock(&it6505->aux_lock); + return ret; +} + + static ssize_t it6505_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) { @@ -1125,7 +1312,7 @@ static ssize_t it6505_aux_transfer(struct drm_dp_aux = *aux, =20 /* IT6505 doesn't support arbitrary I2C read / write. */ if (is_i2c) - return -EINVAL; + return it6505_aux_i2c_transfer(aux, msg); =20 switch (msg->request) { case DP_AUX_NATIVE_READ: @@ -1153,6 +1340,8 @@ static ssize_t it6505_aux_transfer(struct drm_dp_aux = *aux, case REPLY_DEFER: msg->reply =3D DP_AUX_NATIVE_REPLY_DEFER; break; + default: + break; } =20 return ret; @@ -1180,7 +1369,7 @@ static int it6505_get_edid_block(void *data, u8 *buf,= unsigned int block, switch (reply) { case REPLY_ACK: DRM_DEV_DEBUG_DRIVER(dev, "[0x%02x]: %8ph", offset, - buf + offset); + uf + offset); offset +=3D 8; aux_retry =3D 100; break; @@ -1190,6 +1379,8 @@ static int it6505_get_edid_block(void *data, u8 *buf,= unsigned int block, msleep(20); if (!(--aux_retry)) return -EIO; + default: + break; } } =20 @@ -2031,8 +2222,8 @@ static int it6505_setup_sha1_input(struct it6505 *it6= 505, u8 *sha1_input) =20 =20 err =3D it6505_get_ksvlist(it6505, sha1_input, down_stream_count * 5); - if (err < 0) - return err; + if (err < 0) + return err; =20 msg_count +=3D down_stream_count * 5; =20 @@ -2075,7 +2266,7 @@ static bool it6505_hdcp_part2_ksvlist_check(struct it= 6505 *it6505) for (retry =3D 0; retry < 3; retry++) { =20 err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_V_PRIME(0), (u8 *)bv, - sizeof(bv)); + sizeof(bv)); =20 if (err < 0) { dev_err(dev, "Read V' value Fail %d", retry); @@ -2126,7 +2317,7 @@ static void it6505_hdcp_wait_ksv_list(struct work_str= uct *work) =20 ksv_list_check =3D it6505_hdcp_part2_ksvlist_check(it6505); DRM_DEV_DEBUG_DRIVER(dev, "ksv list ready, ksv list check %s", - ksv_list_check ? "pass" : "fail"); + ksv_list_check ? "pass" : "fail"); =20 if (ksv_list_check) return; --=20 2.34.1 From nobody Fri Nov 29 11:51:14 2024 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 2B17213F431 for ; Fri, 20 Sep 2024 08:25:22 +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=1726820725; cv=none; b=Q0NETWuQck6Ou/03dF3vY283H9baH11mi6ECLRi+L2S0ATevyDw7gXKkLOTtTHPrYk96qCv13StS5GVYCojJ0J1p+lpjvYeS7GSxzltDkP2ErLUgD1DPhtpw//71xifxx3YgUZWJ1sBICUtC7z+KmVJVm+uXy/+G8N0dJS+Z+jI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726820725; c=relaxed/simple; bh=7Z9TBY9r35/xIbDqPqsS5oQyJcGpyxP7sz9snC/1b/Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ODbazMB2KmyjNJZseRiBIxSH02x+v8Syu2POz4Mbps79aVPVk3gSNJonmDYDsGjp57+qoyNhl30ykcaUxqrpmlwcSJsklWgMEq6lD753BxuPAwrRUbEIBo4KQaFf+SfgFc2FYq54K5hM0UjuTQXy15R31GzMoorWeCY7VwTB3Fc= 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=raYL+J1L 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 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="raYL+J1L" 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=bTDzqOS47QQw0H5HnXPUclM1b17EzbnVmqfdMQjEfc0=; b=raYL+J1L9EKLvygJla840e85nw3gQXuPKNJDEoQ/BE8CP6bcI+xWy+1C mer378T323BCHkJ6ABmc1JGUXMe0smeh+9Jj1pC2x7ZT/iJ4wAsJ5hq+v zYobq+cPQM8zpla2Bvmt7Z8mO6GRn8VH3mJ8HzYCslJbffvuy6cIOnsY3 8x/zumkAF3kyX4uNu59oP9SdXOpqx2FBGqN4R8mDvvltXgfCd3jfZp+ij OOie2J2mfdJ5Ts86J3AJKGbiPTX5IQnC6mTSrX9GBwGuNtaLW2mEJRmSE CFff654UpA4+hwvKyiHyYJ/mV2YwSUm4EmdwR7yArQfShKu9okZo8cLkO Q==; X-CSE-ConnectionGUID: YQ6cslkHT8eTX8x/PkZXgA== X-CSE-MsgGUID: Q3nt34DVSjaUUA5dKNT9xA== Received: from unknown (HELO mse.ite.com.tw) ([192.168.35.30]) by ironport.ite.com.tw with ESMTP; 20 Sep 2024 16:25:11 +0800 Received: from tpemail1.internal.ite.com.tw (TPEMAIL1.internal.ite.com.tw [192.168.15.58]) by mse.ite.com.tw with ESMTP id 48K8P5vw024311; Fri, 20 Sep 2024 16:25:05 +0800 (GMT-8) (envelope-from Hermes.Wu@ite.com.tw) Received: from LAPTOP-C4GM1L3U.localdomain (192.168.82.6) by TPEMAIL1.internal.ite.com.tw (192.168.15.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Sep 2024 16:25:06 +0800 From: Hermes Wu To: Pin-yen Lin , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list CC: Kenneth Hung , Hermes Wu Subject: [PATCH v2 2/2] drm/bridge: it6505: Add MCCS support Date: Fri, 20 Sep 2024 16:24:51 +0800 Message-ID: <20240920082451.9240-7-Hermes.Wu@ite.com.tw> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240920082451.9240-1-Hermes.Wu@ite.com.tw> References: <20240920082451.9240-1-Hermes.Wu@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: quoted-printable X-ClientProxiedBy: TPEMAIL1.internal.ite.com.tw (192.168.15.58) To TPEMAIL1.internal.ite.com.tw (192.168.15.58) X-TM-SNTS-SMTP: C6DFD326E296B29C3DA7A0BAB263AE5FE650988372D7E9840CB33A4DF2B581EA2002:8 X-MAIL: mse.ite.com.tw 48K8P5vw024311 Content-Type: text/plain; charset="utf-8" From: Hermes Wu add AUX-I2C functionality to support MCCS Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 209 ++++++++++++++++++++++++++-- 1 file changed, 200 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index cef02c8c363e..1a272c67e82b 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -127,6 +127,9 @@ #define REG_AUX_ADR_16_19 0x26 #define REG_AUX_OUT_DATA0 0x27 =20 +#define REG_AUX_I2C_ADR 0x25 +#define REG_AUX_I2C_OP 0x26 + #define REG_AUX_CMD_REQ 0x2B #define AUX_BUSY BIT(5) =20 @@ -268,6 +271,19 @@ #define REG_SSC_CTRL1 0x189 #define REG_SSC_CTRL2 0x18A =20 +#define REG_AUX_USER_CTRL 0x190 +#define EN_USER_AUX BIT(0) +#define USER_AUX_DONE BIT(1) +#define AUX_EVENT BIT(4) + +#define REG_AUX_USER_DATA_REC 0x191 +#define M_AUX_IN_REC 0xF0 +#define M_AUX_OUT_REC 0x0F + +#define REG_AUX_USER_TXB 0x190 +#define REG_AUX_USER_REPLY 0x19A +#define REG_AUX_USER_RXB(n) (n + 0x19B) + #define RBR DP_LINK_BW_1_62 #define HBR DP_LINK_BW_2_7 #define HBR2 DP_LINK_BW_5_4 @@ -303,6 +319,8 @@ #define MAX_EQ_LEVEL 0x03 #define AUX_WAIT_TIMEOUT_MS 15 #define AUX_FIFO_MAX_SIZE 16 +#define AUX_I2C_MAX_SIZE 4 +#define AUX_I2C_DEFER_RETRY 4 #define PIXEL_CLK_DELAY 1 #define PIXEL_CLK_INVERSE 0 #define ADJUST_PHASE_THRESHOLD 80000 @@ -325,7 +343,12 @@ enum aux_cmd_type { CMD_AUX_NATIVE_READ =3D 0x0, CMD_AUX_NATIVE_WRITE =3D 0x5, + CMD_AUX_GI2C_ADR =3D 0x08, + CMD_AUX_GI2C_READ =3D 0x09, + CMD_AUX_GI2C_WRITE =3D 0x0A, CMD_AUX_I2C_EDID_READ =3D 0xB, + CMD_AUX_I2C_READ =3D 0x0D, + CMD_AUX_I2C_WRITE =3D 0x0C, =20 /*extend read ncommand */ CMD_AUX_GET_KSV_LIST =3D 0x10, @@ -333,8 +356,11 @@ enum aux_cmd_type { =20 enum aux_cmd_reply { REPLY_ACK, - REPLY_NACK, - REPLY_DEFER, + REPLY_NACK =3D 1, + REPLY_DEFER =3D 2, + + REPLY_I2C_NACK =3D 4, + REPLY_I2C_DEFER =3D 8, }; =20 enum link_train_status { @@ -1087,7 +1113,6 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *= it6505, size_t size, enum aux_cmd_reply *reply) { int i, ret_size, ret =3D 0, request_size; - struct device *dev =3D &it6505->client->dev; =20 mutex_lock(&it6505->aux_lock); for (i =3D 0; i < size; ) { @@ -1114,6 +1139,168 @@ static ssize_t it6505_aux_do_transfer(struct it6505= *it6505, return ret; } =20 + +static int it6505_aux_i2c_wait(struct it6505 *it6505, u8 *reply) +{ + int err =3D 0; + unsigned long timeout; + struct device *dev =3D &it6505->client->dev; + + timeout =3D jiffies + msecs_to_jiffies(AUX_WAIT_TIMEOUT_MS) + 1; + + do { + if (it6505_read(it6505, REG_AUX_USER_CTRL) & AUX_EVENT) + break; + if (time_after(jiffies, timeout)) { + dev_err(dev, "Timed out waiting AUX I2C, BUSY =3D %X\n", + it6505_aux_op_finished(it6505)); + err =3D -ETIMEDOUT; + goto end_aux_i2c_wait; + } + usleep_range(300, 800); + + } while (!it6505_aux_op_finished(it6505)); + + if (reply =3D=3D NULL) + goto end_aux_i2c_wait; + + *reply =3D it6505_read(it6505, REG_AUX_USER_REPLY) >> 4; + + if (*reply =3D=3D 0) + goto end_aux_i2c_wait; + + if ((*reply =3D=3D DP_AUX_NATIVE_REPLY_DEFER) || + (*reply =3D=3D DP_AUX_I2C_REPLY_DEFER)) + err =3D -EBUSY; + else if ((*reply =3D=3D DP_AUX_NATIVE_REPLY_NACK) || + (*reply =3D=3D DP_AUX_I2C_REPLY_NACK)) + err =3D -ENXIO; + +end_aux_i2c_wait: + it6505_set_bits(it6505, REG_AUX_USER_CTRL, USER_AUX_DONE, USER_AUX_DONE); + return err; +} + +static int it6505_aux_i2c_readb(struct it6505 *it6505, u8 *buf, size_t siz= e, u8 *reply) +{ + int ret, i; + int retry =3D 0; + + for (retry =3D 0; retry < AUX_I2C_DEFER_RETRY; retry++) { + + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_READ); + + ret =3D it6505_aux_i2c_wait(it6505, reply); + + if ((*reply =3D=3D DP_AUX_NATIVE_REPLY_DEFER) || + (*reply =3D=3D DP_AUX_I2C_REPLY_DEFER)) + continue; + + if (ret >=3D 0) + break; + } + + for (i =3D 0; i < size; i++) + buf[i] =3D (u8) it6505_read(it6505, REG_AUX_USER_RXB(0 + i)); + + return size; +} + +static int it6505_aux_i2c_writeb(struct it6505 *it6505, u8 *buf, size_t si= ze, u8 *reply) +{ + int i, ret; + int retry =3D 0; + + for (i =3D 0; i < size; i++) + it6505_write(it6505, REG_AUX_OUT_DATA0 + i, buf[i]); + + for (retry =3D 0; retry < AUX_I2C_DEFER_RETRY; retry++) { + + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_WRITE); + + ret =3D it6505_aux_i2c_wait(it6505, reply); + + if ((*reply =3D=3D DP_AUX_NATIVE_REPLY_DEFER) || + (*reply =3D=3D DP_AUX_I2C_REPLY_DEFER)) + continue; + + if (ret >=3D 0) + break; + } + return size; +} + +static ssize_t it6505_aux_i2c_operation(struct it6505 *it6505, + struct drm_dp_aux_msg *msg) +{ + int ret; + ssize_t request_size, data_cnt =3D 0; + struct device *dev =3D &it6505->client->dev; + u8 *buffer =3D msg->buffer; + + /* set AUX user mode */ + it6505_set_bits(it6505, REG_AUX_CTRL, + AUX_USER_MODE | AUX_NO_SEGMENT_WR, AUX_USER_MODE); + it6505_set_bits(it6505, REG_AUX_USER_CTRL, EN_USER_AUX, EN_USER_AUX); + /* clear AUX FIFO */ + it6505_set_bits(it6505, REG_AUX_CTRL, + AUX_EN_FIFO_READ | CLR_EDID_FIFO, + AUX_EN_FIFO_READ | CLR_EDID_FIFO); + + it6505_set_bits(it6505, REG_AUX_CTRL, + AUX_EN_FIFO_READ | CLR_EDID_FIFO, 0x00); + + it6505_write(it6505, REG_AUX_ADR_0_7, 0x00); + it6505_write(it6505, REG_AUX_I2C_ADR, msg->address << 1); + + if (msg->size =3D=3D 0) { + /* IIC Start/STOP dummy write */ + it6505_write(it6505, REG_AUX_I2C_OP, msg->request); + it6505_write(it6505, REG_AUX_CMD_REQ, CMD_AUX_GI2C_ADR); + ret =3D it6505_aux_i2c_wait(it6505, &msg->reply); + goto end_aux_i2c_transfer; + } + + /* IIC data transfer */ + for (data_cnt =3D 0; data_cnt < msg->size; ) { + request_size =3D min(msg->size - data_cnt, AUX_I2C_MAX_SIZE); + it6505_write(it6505, REG_AUX_I2C_OP, + (msg->request) | ((request_size - 1) << 4)); + + if ((msg->request & DP_AUX_I2C_READ) =3D=3D DP_AUX_I2C_READ) + ret =3D it6505_aux_i2c_readb(it6505, &buffer[data_cnt], + request_size, &msg->reply); + else + ret =3D it6505_aux_i2c_writeb(it6505, &buffer[data_cnt], + request_size, &msg->reply); + + if (ret < 0) + goto end_aux_i2c_transfer; + + data_cnt +=3D request_size; + } + ret =3D data_cnt; +end_aux_i2c_transfer: + + it6505_set_bits(it6505, REG_AUX_USER_CTRL, EN_USER_AUX, 0); + it6505_set_bits(it6505, REG_AUX_CTRL, AUX_USER_MODE, 0); + return ret; +} + + +static ssize_t it6505_aux_i2c_transfer(struct drm_dp_aux *aux, + struct drm_dp_aux_msg *msg) +{ + struct it6505 *it6505 =3D container_of(aux, struct it6505, aux); + int ret; + + mutex_lock(&it6505->aux_lock); + ret =3D it6505_aux_i2c_operation(it6505, msg); + mutex_unlock(&it6505->aux_lock); + return ret; +} + + static ssize_t it6505_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) { @@ -1125,7 +1312,7 @@ static ssize_t it6505_aux_transfer(struct drm_dp_aux = *aux, =20 /* IT6505 doesn't support arbitrary I2C read / write. */ if (is_i2c) - return -EINVAL; + return it6505_aux_i2c_transfer(aux, msg); =20 switch (msg->request) { case DP_AUX_NATIVE_READ: @@ -1153,6 +1340,8 @@ static ssize_t it6505_aux_transfer(struct drm_dp_aux = *aux, case REPLY_DEFER: msg->reply =3D DP_AUX_NATIVE_REPLY_DEFER; break; + default: + break; } =20 return ret; @@ -1180,7 +1369,7 @@ static int it6505_get_edid_block(void *data, u8 *buf,= unsigned int block, switch (reply) { case REPLY_ACK: DRM_DEV_DEBUG_DRIVER(dev, "[0x%02x]: %8ph", offset, - buf + offset); + uf + offset); offset +=3D 8; aux_retry =3D 100; break; @@ -1190,6 +1379,8 @@ static int it6505_get_edid_block(void *data, u8 *buf,= unsigned int block, msleep(20); if (!(--aux_retry)) return -EIO; + default: + break; } } =20 @@ -2031,8 +2222,8 @@ static int it6505_setup_sha1_input(struct it6505 *it6= 505, u8 *sha1_input) =20 =20 err =3D it6505_get_ksvlist(it6505, sha1_input, down_stream_count * 5); - if (err < 0) - return err; + if (err < 0) + return err; =20 msg_count +=3D down_stream_count * 5; =20 @@ -2075,7 +2266,7 @@ static bool it6505_hdcp_part2_ksvlist_check(struct it= 6505 *it6505) for (retry =3D 0; retry < 3; retry++) { =20 err =3D it6505_get_dpcd(it6505, DP_AUX_HDCP_V_PRIME(0), (u8 *)bv, - sizeof(bv)); + sizeof(bv)); =20 if (err < 0) { dev_err(dev, "Read V' value Fail %d", retry); @@ -2126,7 +2317,7 @@ static void it6505_hdcp_wait_ksv_list(struct work_str= uct *work) =20 ksv_list_check =3D it6505_hdcp_part2_ksvlist_check(it6505); DRM_DEV_DEBUG_DRIVER(dev, "ksv list ready, ksv list check %s", - ksv_list_check ? "pass" : "fail"); + ksv_list_check ? "pass" : "fail"); =20 if (ksv_list_check) return; --=20 2.34.1