From nobody Sun Nov 24 18:22:19 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CF12218D62D for ; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702646; cv=none; b=AmRbOUg+0dblhoo3HHgiB52jFPDBK5Bcv803ZeSBb25LPHBEnewmxhRUfok+JyXDcqiov6+hZmYqqcInH7BDgjgH4FhX8s9Fom9l8JJ+IiUEStWbZB2r1hxpCg750LL/8wTaVPMSk+BPQRUfPf9uvhqXuZW8UelO69fyeZMpqlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730702646; c=relaxed/simple; bh=jebMeVHnxHKhzdHUo8lgZOGGKX3f7GBIrJuL6SI9xIc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Cn0Ex39SaiWAtofQE4SsqjN0GSS766kUXwN9ETlQm8GzeeW4vsZpZpxCiIO9KkI5R88oLqGbkbzLnFR/ushTvYTU5avt6EJ9iuhpyewHJTjTlENyfx+h8ejsouzaZy03+0AWxZjXjf1dVXihMXypHHDltHrfwJ6Ry+B5cAEDYl4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Uq6V8Ihm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Uq6V8Ihm" Received: by smtp.kernel.org (Postfix) with ESMTPS id 72464C4CED2; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730702646; bh=jebMeVHnxHKhzdHUo8lgZOGGKX3f7GBIrJuL6SI9xIc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Uq6V8IhmI/nfhDHJTGxnBU8TijQikYASs8X2pAL7ih2k6Q7hIbLxzdQsL0dyIgTDS 9UeJeEmRBESJC4/cdH7IIImeTCqaTDAFJlvsuQfTxyiog1GAmDURhWlNxceU1p/9T7 PYWBQiAJfOE9tfQiiDhnmmvjxIGI5tFlC7LALJ8aj2VZOII9Ve5N3eV9+MXeEYrbPW X/L3yOzMyZ7I4UsT3cHmUpEMvmte2qmikhCb0ypYCaUxwLOoZOwrv6rUuAQWTbfZqA eMnP101kB3adkoB0KuGTjUtOgx1V5/qnunfSiJeRgwD7jR+2B1RrQX1yF4eMM+8uZE LqrmSIV000NUA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63FD2D111B3; Mon, 4 Nov 2024 06:44:06 +0000 (UTC) From: Hermes Wu via B4 Relay Date: Mon, 04 Nov 2024 14:43:33 +0800 Subject: [PATCH v7 03/10] drm/bridge: it6505: add AUX operation for HDCP KSV list read Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241104-v7-upstream-v7-3-8b71fd0f1d2d@ite.com.tw> References: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@ite.com.tw> In-Reply-To: <20241104-v7-upstream-v7-0-8b71fd0f1d2d@ite.com.tw> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Hermes Wu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Pin-yen Lin , Kenneth Hung , Pet Weng , Hermes Wu , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730702658; l=3615; i=Hermes.wu@ite.com.tw; s=20241101; h=from:subject:message-id; bh=Qm0Yg8xBTZewdPuvHcs5ADcGIPqmFgB/FG4kqG8Nqvw=; b=Vdbj/KgQsW9ht3RTek7Bd8aNOnnJVm2T9jt3MjZM46NOGiIyDqpfLlK8EFuVsq4rA9bmeyoGU jxJ8gg1DjsCDfP3qVKUAzyV9LOPZvUuOTLg3OaJ9MxUXvfwfeUPvyHu X-Developer-Key: i=Hermes.wu@ite.com.tw; a=ed25519; pk=FOYYbsP2Nlw6mjB3rLFYSLmAiENzj4AWQly5XTcDuMM= X-Endpoint-Received: by B4 Relay for Hermes.wu@ite.com.tw/20241101 with auth_id=268 X-Original-From: Hermes Wu Reply-To: Hermes.wu@ite.com.tw From: Hermes Wu HDCP KSV list readback can choose to use AUX FIFO or general data register. For some DisplayPort devices, the KSV list must be read in 5 byte boundaries. The original AUX read command does not support these devices. The AUX command operation control register "REG_AUX_CMD_REQ" uses b[3:0] as AUX operacion control, and b[7:4] are status bits and read only. To change KSV read operation uses "CMD_AUX_NATIVE_READ" from using the data registers to using AUX FIFO. The extended command "CMD_AUX_GET_KSV_LIST" is added as "CMD_AUX_NATIVE_READ" with the 0x10 flag which selects AUX FIFO mode. Reviewed-by: Dmitry Baryshkov Signed-off-by: Hermes Wu --- drivers/gpu/drm/bridge/ite-it6505.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/i= te-it6505.c index 9747d7ccf435d536da55c6a3ff79e504b7c724f0..ba37974967767a17b7025595f68= 64f057174efb9 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -19,6 +19,7 @@ #include #include #include +#include =20 #include =20 @@ -126,6 +127,7 @@ #define REG_AUX_OUT_DATA0 0x27 =20 #define REG_AUX_CMD_REQ 0x2B +#define M_AUX_REQ_CMD 0x0F #define AUX_BUSY BIT(5) =20 #define REG_AUX_DATA_0_7 0x2C @@ -324,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, + + /* KSV read with AUX FIFO extend from CMD_AUX_NATIVE_READ*/ + CMD_AUX_GET_KSV_LIST =3D 0x10, }; =20 enum aux_cmd_reply { @@ -965,7 +970,8 @@ 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) { + /* HW AUX FIFO supports only EDID and DCPD KSV FIFO area */ + 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 */ @@ -996,7 +1002,7 @@ static ssize_t it6505_aux_operation(struct it6505 *it6= 505, size); =20 /* Aux Fire */ - it6505_write(it6505, REG_AUX_CMD_REQ, cmd); + it6505_write(it6505, REG_AUX_CMD_REQ, FIELD_GET(M_AUX_REQ_CMD, cmd)); =20 ret =3D it6505_aux_wait(it6505); if (ret < 0) @@ -1030,7 +1036,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) @@ -1055,7 +1061,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, @@ -1076,7 +1082,8 @@ 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; - int fifo_max_size =3D (cmd =3D=3D CMD_AUX_I2C_EDID_READ) ? AUX_FIFO_MAX_S= IZE : 4; + int fifo_max_size =3D (cmd =3D=3D CMD_AUX_I2C_EDID_READ || cmd =3D=3D CMD= _AUX_GET_KSV_LIST) ? + AUX_FIFO_MAX_SIZE : 4; =20 mutex_lock(&it6505->aux_lock); i =3D 0; --=20 2.34.1