From patchwork Wed Jan 31 11:34:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 194707 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1826053dyb; Wed, 31 Jan 2024 03:41:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKxpZ1fa6vpaMJDDS0+O3kpIaHP1AHaeyRaL1ubMus2Gz+bI12hasBbZfP7M3FNx9jhRpo X-Received: by 2002:a05:6820:1ca7:b0:599:be65:a3b4 with SMTP id ct39-20020a0568201ca700b00599be65a3b4mr1385175oob.5.1706701319680; Wed, 31 Jan 2024 03:41:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706701319; cv=pass; d=google.com; s=arc-20160816; b=x9HVt9ZcIisyB2++zoFs2lOr3pIctiTb8B5R1jvgWVYmC3++RwRA6avkJ3/NZWawQT LTJu1g/DDn8SHrPPldy4EUIPkRyTflpA63ng4wRXgmyV9HeQKQyyMwRwmdWiq2Fo0YUd gEHZsVEfqyr8D55OLKU/7z6LJhbpoCa+egTCgrjB8YinV68vmDpaZFdRlDL99njZz0ar ZekuYmXO6q5dq7Zp2RcnPUT7fWnrh4+m/URMHNRjdkK0tjzXlLvneH7U1SLLAg7VPiiM sM8EFj+angKapiXNTiUbjmuJa4lzkn+DkdtLIYUBLWlMSygNz1M9uNSdE6wMEl4xRMik 0D7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xp8fWXzlCcc9CfHkatiavM+nU6T1cSXygb2Jp7jqRy0=; fh=5Z+G70wV5P5F6XZo+32wsymCboBlLwGz9176ygetU/Q=; b=fFaP4SpZF4xYW+egPnwW9J1cTLdcS2f9cMimftYRL5axLGR88K47UAJU3eDL1rHG96 LYayoypEop7918GNR6Rm+apOmCI0sE/AWfo2smX1oPAm7toRg4OLheY0r/pvbiemhytB e8ibK/xRegU9VEwr8XWDgwfKw3FSKiWlPnBBJ25OhH+X5mgjNfYzM7Ba//K4bB91cKjl bcgt9hR70OPcW6cm5FRz/oESWS+Lf/hJ/KKoWwM9BgQ+0udeJfhbHVwSlGKqpLm2beHV INb1odEy4x9vfYnzvYhRcjrlymY5XFm7BQ97fvhZerZH+Hhi0ehGdFwqC1FZHYOuZG75 vs8w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=pZ4KNsSB; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-46355-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46355-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com X-Forwarded-Encrypted: i=1; AJvYcCXjfUKrK+4a4ft9B3Dqsk0QlpxdvqFU+GcIekES18GRsfIXNXQmDrytr9nKapocqtsYohZC5W54Y4GEmaccUNtI2g0S5Q== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x23-20020a63b217000000b005ceb4a8475esi9355529pge.401.2024.01.31.03.41.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:41:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46355-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=pZ4KNsSB; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-46355-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46355-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6CBBA288EF5 for ; Wed, 31 Jan 2024 11:35:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E722C78694; Wed, 31 Jan 2024 11:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="pZ4KNsSB" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 A741569E08 for ; Wed, 31 Jan 2024 11:34:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706700885; cv=none; b=GmksXtLwDG8US1ehnS8Jk6OgHB6gEPfltUHC04Bpqjuux9znHPy80Cv6UcoqE82Mkuvw0ldn0uFmo29+AYySIvH+lzdMcQ2wXv6j4ENUr3idi3alpxD+GrFwLwJJJ2C7b0FlK++21MT+L33qGmh3/nfNBdX+WJIVSWI8+dU1XbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706700885; c=relaxed/simple; bh=T7wyLM2XaOr0LZopSINK1iR5VVf323V2jZ2xWU3QUPI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S2Zge35xcDiWrEQQP0DiB/9j2q6Y1Fpe3okiuNsFTde5iikL9Zed7dCya6SWelzYEmUO8VbcP9G9UL775VC3zo2/sWQ1B2PCZYsKyL3gbmTbZ23D0w1mR7aRzcmANtUiQd/NoLfNWN7d1YRua87qXZxyt/7b7OFAh3QvkxzGVmY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=pZ4KNsSB; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706700881; bh=T7wyLM2XaOr0LZopSINK1iR5VVf323V2jZ2xWU3QUPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pZ4KNsSBKFixh/3NFT+/dPC3BceUxhRWuFAeRVrfK63AmErPDPjb1H0VsB+4yLelY C346QSdfY1nf6BvgkOQvGKWFrpN0HRfj0Vjd9zHwwGIO59Ic5YvPWnGbSgDvHC7L90 BmvVZEuL/OLCEv4Z2NzcC1yCQoiCDkFTSXQHZrhcgpjkQeTiZKCBSZvuP2Ts7qH6MW 6EO/9z2/vuoolTRkGSKCLYmGsKeakG7pHb8ORXrrzxE5eBWUihUBziYlj9PECKmdNr 5+j2k8P/qZevQ8MY3O4rE9fywGUZSAp3CZbBosSXhSNduShiwV/sPrAnu18CQ9d4/L ZlOiuFUOzYW5Q== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 129AF3781FE1; Wed, 31 Jan 2024 11:34:41 +0000 (UTC) From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: fshao@chromium.org, p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com Subject: [PATCH v3 1/7] drm/mediatek: dsi: Use GENMASK() for register mask definitions Date: Wed, 31 Jan 2024 12:34:28 +0100 Message-ID: <20240131113434.241929-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131113434.241929-1-angelogioacchino.delregno@collabora.com> References: <20240131113434.241929-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789606042781457955 X-GMAIL-MSGID: 1789606042781457955 Change magic numerical masks with usage of the GENMASK() macro to improve readability. While at it, also fix the DSI_PS_SEL mask to include all bits instead of just a subset of them. This commit brings no functional changes. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dsi.c | 45 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index a2fdfc8ddb15..3b7392c03b4d 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -58,18 +58,18 @@ #define DSI_TXRX_CTRL 0x18 #define VC_NUM BIT(1) -#define LANE_NUM (0xf << 2) +#define LANE_NUM GENMASK(5, 2) #define DIS_EOT BIT(6) #define NULL_EN BIT(7) #define TE_FREERUN BIT(8) #define EXT_TE_EN BIT(9) #define EXT_TE_EDGE BIT(10) -#define MAX_RTN_SIZE (0xf << 12) +#define MAX_RTN_SIZE GENMASK(15, 12) #define HSTX_CKLP_EN BIT(16) #define DSI_PSCTRL 0x1c -#define DSI_PS_WC 0x3fff -#define DSI_PS_SEL (3 << 16) +#define DSI_PS_WC GENMASK(14, 0) +#define DSI_PS_SEL GENMASK(19, 16) #define PACKED_PS_16BIT_RGB565 (0 << 16) #define LOOSELY_PS_18BIT_RGB666 (1 << 16) #define PACKED_PS_18BIT_RGB666 (2 << 16) @@ -109,26 +109,26 @@ #define LD0_WAKEUP_EN BIT(2) #define DSI_PHY_TIMECON0 0x110 -#define LPX (0xff << 0) -#define HS_PREP (0xff << 8) -#define HS_ZERO (0xff << 16) -#define HS_TRAIL (0xff << 24) +#define LPX GENMASK(7, 0) +#define HS_PREP GENMASK(15, 8) +#define HS_ZERO GENMASK(23, 16) +#define HS_TRAIL GENMASK(31, 24) #define DSI_PHY_TIMECON1 0x114 -#define TA_GO (0xff << 0) -#define TA_SURE (0xff << 8) -#define TA_GET (0xff << 16) -#define DA_HS_EXIT (0xff << 24) +#define TA_GO GENMASK(7, 0) +#define TA_SURE GENMASK(15, 8) +#define TA_GET GENMASK(23, 16) +#define DA_HS_EXIT GENMASK(31, 24) #define DSI_PHY_TIMECON2 0x118 -#define CONT_DET (0xff << 0) -#define CLK_ZERO (0xff << 16) -#define CLK_TRAIL (0xff << 24) +#define CONT_DET GENMASK(7, 0) +#define CLK_ZERO GENMASK(23, 16) +#define CLK_TRAIL GENMASK(31, 24) #define DSI_PHY_TIMECON3 0x11c -#define CLK_HS_PREP (0xff << 0) -#define CLK_HS_POST (0xff << 8) -#define CLK_HS_EXIT (0xff << 16) +#define CLK_HS_PREP GENMASK(7, 0) +#define CLK_HS_POST GENMASK(15, 8) +#define CLK_HS_EXIT GENMASK(23, 16) #define DSI_VM_CMD_CON 0x130 #define VM_CMD_EN BIT(0) @@ -138,13 +138,14 @@ #define FORCE_COMMIT BIT(0) #define BYPASS_SHADOW BIT(1) -#define CONFIG (0xff << 0) +/* CMDQ related bits */ +#define CONFIG GENMASK(7, 0) #define SHORT_PACKET 0 #define LONG_PACKET 2 #define BTA BIT(2) -#define DATA_ID (0xff << 8) -#define DATA_0 (0xff << 16) -#define DATA_1 (0xff << 24) +#define DATA_ID GENMASK(15, 8) +#define DATA_0 GENMASK(23, 16) +#define DATA_1 GENMASK(31, 24) #define NS_TO_CYCLE(n, c) ((n) / (c) + (((n) % (c)) ? 1 : 0)) From patchwork Wed Jan 31 11:34:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 194708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1826121dyb; Wed, 31 Jan 2024 03:42:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbGSZMYvi0ywimMI95M7IF4dkWeWeJEg0+9H/3eB+SNe15I9GvYqo55hq5T2hACr+SznvL X-Received: by 2002:a05:6a00:1c92:b0:6dd:dbb2:8ee9 with SMTP id y18-20020a056a001c9200b006dddbb28ee9mr1187968pfw.6.1706701328102; Wed, 31 Jan 2024 03:42:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706701328; cv=pass; d=google.com; s=arc-20160816; b=lbUwkiHHiPFIVwiQZL611VOfRUuw+MiFkYPbWLJ4qmSoFDOOmNNN7UHmzJ/qzO6HJw 6Uo4vIBhq4z4rjDuIxstvEa0DLoyDrYy/k/ZLmhcBeZ2Yi6V7r37msqWF41gT63vNh+K mV68sVyC3vFfo2vnFU+sipvdLRcwOdGxDyE3Zk/UwtjUAc2408Tp1Xc3q53Yxt64Hq9O AieU2pIOQxNKwvAHJEnVsyPWMAIx3a7azZ9lrLVN8IXJj5wxBgRwq8GM3nVsh3NU+d74 uuOlWUjevGcESqkhjsOncyBKrW3KCrtnFOCLTpUCEHcUZTq+OswHVGO+j2Wb0V+C1bw2 hetg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QfqR9u3XwXlGUjQlmuP4SZo/1RksuEgMYRsxq46AWiI=; fh=+oT9AGxP1fP1nYjRg2OHWgmIHb8HFT+Mc0FBGH3bPYo=; b=cZWhpuoWsRMfYQxRtyLpnJ65AoHHNLbFrXWbWlTShbPFkgdfzcdgbJEhZbqPnaAnKf nNYKbyP2zwdvB3n/qFJHVPhV5Clx3lWs95n/P+PsoRepl8NqqTNWhcsjtvfdcxgTfsEK MkK9e7N9o+TpBmlk185w777tw2Zt1A/7XGkbDShX9qn6bslS1DZAzO2lb7Tn/Eghd2zY CJHn6CTf0cNmM2PX3qHBHwbsmBNWsAg8VtpfM0e9NemHcLdJgOimkFtZTQanQRR5zmER EsKTy3uTb1Ksn7dU+hbdNaNQAelgsZ0IaDTugyVacH94otnAJhB2bFu5aDAWUCme2Fw2 N89Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=gxsDWFAr; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-46356-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46356-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com X-Forwarded-Encrypted: i=1; AJvYcCWGO5iUGI79OG8PeA6H6jlE9z0ZINosdLPrTVb7AZRRKqc/VCr07KWVthvgHJ8sTONP1Pci130M+M7yMexrAr+An6Vbkw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p9-20020a056a0026c900b006dfdfc0366asi182462pfw.107.2024.01.31.03.42.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:42:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46356-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=gxsDWFAr; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-46356-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46356-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 907AA2927D4 for ; Wed, 31 Jan 2024 11:35:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C4A679943; Wed, 31 Jan 2024 11:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="gxsDWFAr" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 8BD95745E7 for ; Wed, 31 Jan 2024 11:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706700886; cv=none; b=XA8wvdt0QsolKuJ6ldVpD4cf7lbObxnxR/kVaobrBOVCzj9yYY0k8e5F+Ao5ErCSNSz4X1c/STteEk3wtqFgT64zpSkpxHFzRV12E66cZDjnW4eaLO7ZJSDrmOmzhy/jDxZYY872jLrI8PRpUfHDX6nQdTvtgV9bUoEoW/icHLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706700886; c=relaxed/simple; bh=j/2ny5Y8DyyuhjfBUyl+Wn3ma9b5f2x2Zt+jtkjquuQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hFBjYJeLdZx2d3CPLTZRCVlKieJcda8gRrUXF+hmVL8z47FFOSQTzXoB4dnJRY9zdu5p8Qxn+0bEk8YTNtsbzlpcEcjbVxugBk4/0NaIY46GyPxnyjTMcJv9vEGjXiTqkKxzy1Yue/mx6+7zDLBHJMy5Bh8ZdpB3ZodUL6Ang8Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=gxsDWFAr; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706700882; bh=j/2ny5Y8DyyuhjfBUyl+Wn3ma9b5f2x2Zt+jtkjquuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gxsDWFArIlHi4qwvZ6rZXoBdVYA2HN5umf1ZsoYTcohnu2NWTj+nD/Q2Z+KWy1B3P wt5N/5Z9tVsIwChL/ESE+yMp+Q3GIU24g0TOHlBaFKSK/uMtrtczbDtwXXCM/Qe5eS ByM1mXZKyKw+ikwKScQF7/vnGOpIf7KFA1QoqIwH/CFqx/+13jyWBToissFpOuPj2H mDvwkFB23vL5v1l8mJjyjvtUhNl/eB50kgQooiDEZpi/3ZrTqFxywrBtjbNgRIwDA8 1Wt2E/avFg8F215I1mCKItvbtJtjwmRoaoiOM4OMOlSo+pkOx93wv1yGP4LOXspBkb m4Ix63AF1wTsQ== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 1008E3782067; Wed, 31 Jan 2024 11:34:42 +0000 (UTC) From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: fshao@chromium.org, p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com Subject: [PATCH v3 2/7] drm/mediatek: dsi: Cleanup functions mtk_dsi_ps_control{_vact}() Date: Wed, 31 Jan 2024 12:34:29 +0100 Message-ID: <20240131113434.241929-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131113434.241929-1-angelogioacchino.delregno@collabora.com> References: <20240131113434.241929-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789606051813954645 X-GMAIL-MSGID: 1789606051813954645 Function mtk_dsi_ps_control() is a subset of mtk_dsi_ps_control_vact(): merge the two in one mtk_dsi_ps_control() function by adding one function parameter `config_vact` which, when true, writes the VACT related registers. Reviewed-by: Fei Shao Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dsi.c | 76 +++++++++--------------------- 1 file changed, 23 insertions(+), 53 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index 3b7392c03b4d..8414ce73ce9f 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -351,40 +351,6 @@ static void mtk_dsi_set_vm_cmd(struct mtk_dsi *dsi) mtk_dsi_mask(dsi, DSI_VM_CMD_CON, TS_VFP_EN, TS_VFP_EN); } -static void mtk_dsi_ps_control_vact(struct mtk_dsi *dsi) -{ - struct videomode *vm = &dsi->vm; - u32 dsi_buf_bpp, ps_wc; - u32 ps_bpp_mode; - - if (dsi->format == MIPI_DSI_FMT_RGB565) - dsi_buf_bpp = 2; - else - dsi_buf_bpp = 3; - - ps_wc = vm->hactive * dsi_buf_bpp; - ps_bpp_mode = ps_wc; - - switch (dsi->format) { - case MIPI_DSI_FMT_RGB888: - ps_bpp_mode |= PACKED_PS_24BIT_RGB888; - break; - case MIPI_DSI_FMT_RGB666: - ps_bpp_mode |= PACKED_PS_18BIT_RGB666; - break; - case MIPI_DSI_FMT_RGB666_PACKED: - ps_bpp_mode |= LOOSELY_PS_18BIT_RGB666; - break; - case MIPI_DSI_FMT_RGB565: - ps_bpp_mode |= PACKED_PS_16BIT_RGB565; - break; - } - - writel(vm->vactive, dsi->regs + DSI_VACT_NL); - writel(ps_bpp_mode, dsi->regs + DSI_PSCTRL); - writel(ps_wc, dsi->regs + DSI_HSTX_CKL_WC); -} - static void mtk_dsi_rxtx_control(struct mtk_dsi *dsi) { u32 tmp_reg; @@ -416,36 +382,40 @@ static void mtk_dsi_rxtx_control(struct mtk_dsi *dsi) writel(tmp_reg, dsi->regs + DSI_TXRX_CTRL); } -static void mtk_dsi_ps_control(struct mtk_dsi *dsi) +static void mtk_dsi_ps_control(struct mtk_dsi *dsi, bool config_vact) { - u32 dsi_tmp_buf_bpp; - u32 tmp_reg; + struct videomode *vm = &dsi->vm; + u32 dsi_buf_bpp, ps_wc; + u32 ps_bpp_mode; + + if (dsi->format == MIPI_DSI_FMT_RGB565) + dsi_buf_bpp = 2; + else + dsi_buf_bpp = 3; + + ps_wc = vm->hactive * dsi_buf_bpp; + ps_bpp_mode = ps_wc; switch (dsi->format) { case MIPI_DSI_FMT_RGB888: - tmp_reg = PACKED_PS_24BIT_RGB888; - dsi_tmp_buf_bpp = 3; + ps_bpp_mode |= PACKED_PS_24BIT_RGB888; break; case MIPI_DSI_FMT_RGB666: - tmp_reg = LOOSELY_PS_18BIT_RGB666; - dsi_tmp_buf_bpp = 3; + ps_bpp_mode |= PACKED_PS_18BIT_RGB666; break; case MIPI_DSI_FMT_RGB666_PACKED: - tmp_reg = PACKED_PS_18BIT_RGB666; - dsi_tmp_buf_bpp = 3; + ps_bpp_mode |= LOOSELY_PS_18BIT_RGB666; break; case MIPI_DSI_FMT_RGB565: - tmp_reg = PACKED_PS_16BIT_RGB565; - dsi_tmp_buf_bpp = 2; - break; - default: - tmp_reg = PACKED_PS_24BIT_RGB888; - dsi_tmp_buf_bpp = 3; + ps_bpp_mode |= PACKED_PS_16BIT_RGB565; break; } - tmp_reg += dsi->vm.hactive * dsi_tmp_buf_bpp & DSI_PS_WC; - writel(tmp_reg, dsi->regs + DSI_PSCTRL); + if (config_vact) { + writel(vm->vactive, dsi->regs + DSI_VACT_NL); + writel(ps_wc, dsi->regs + DSI_HSTX_CKL_WC); + } + writel(ps_bpp_mode, dsi->regs + DSI_PSCTRL); } static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) @@ -521,7 +491,7 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) writel(horizontal_backporch_byte, dsi->regs + DSI_HBP_WC); writel(horizontal_frontporch_byte, dsi->regs + DSI_HFP_WC); - mtk_dsi_ps_control(dsi); + mtk_dsi_ps_control(dsi, false); } static void mtk_dsi_start(struct mtk_dsi *dsi) @@ -666,7 +636,7 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi) mtk_dsi_reset_engine(dsi); mtk_dsi_phy_timconfig(dsi); - mtk_dsi_ps_control_vact(dsi); + mtk_dsi_ps_control(dsi, true); mtk_dsi_set_vm_cmd(dsi); mtk_dsi_config_vdo_timing(dsi); mtk_dsi_set_interrupt_enable(dsi); From patchwork Wed Jan 31 11:34:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 194710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1826200dyb; Wed, 31 Jan 2024 03:42:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3AVv8YzUMQeT7/52o2ZUde5jhVLWxKhcvlZAcqeJgDFf+ZQ7QAThR/zhLLD5qkTefg5U8 X-Received: by 2002:a05:6a20:4c24:b0:19c:8974:8bed with SMTP id fm36-20020a056a204c2400b0019c89748bedmr1085091pzb.58.1706701341354; Wed, 31 Jan 2024 03:42:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706701341; cv=pass; d=google.com; s=arc-20160816; b=lhT/6EDwqpxn91wBnr78zmU8C0EARlAiRA5JkaJF4Zqct3N39iw+S+pXxQrkzzXWg4 73TO9qI9ybXjrjQcZycLuzscr6T1j1sqaN+/R804ET/M95BM63ZrGGL1PL26wQ5puW2c BwvHb2yJbcoqxK8hRexQvRxBmGQmq3PRwB7jm4c2J9+UM7oyZQt1i/k9AQ0jk9tvWN5n eWbcZBslKqMvhtmnkhyxbKXK8P615tkoJ2/RQ8TNpKALQrNm9DGkfdJKyXemnbzk/opT lF3cB8aK0vDAXskQLNvKg+d7E4KO3+aABa1HFIE1BTX8xmaLe9NOdr2ty8DVN0NEh0aB MR5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=DHSUX4KHPWpMJlFuo0eszFkppjd3x/GSxlVUJ4bY8gE=; fh=R8kHI6Nthy7wxkvN5IBo0oWU3i2GPARjeT16/ZHozps=; b=DiCBNIR5Z8EG/ql4JT1Kn4rYCJpWsE6t/i10uItddqphNoAB8+447V8R/MGYbs6Uno hJnA71WbgAzIvLnVqR/jhe5tU/rTOnGgrn8YWhCVwCHCOUdK2AOOA7mO1rqOeT9yIc/o aFFvx2dZ43iWDtXhRq4t2UU7vAXhLapJuklNsbKS435yn/sftpbFRVMnXZZmNKFYQ+CB 9q3nHZ1ngS23ribjbJ+Q5/TsyGstidoZ3zLaiFRJcIshOI264r3tDLNjKzQMy1VAlvVR sCSY66Qd5ps152r2Q8mWKLWXRAQiNx83vGNnZjHn052mjB+RpOzG64sQ/NJa3/hOsCui Y8YA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MviYUze4; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-46357-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46357-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com X-Forwarded-Encrypted: i=1; AJvYcCWbhxn9h/7ceMy19f6MENixzUTiOArU2sIBJsyqtFTxdA2AluR9oLZ+WMA/xb2uhnnGKD2pfpKys0qvzeJcDusQPa5FFg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p10-20020a17090a868a00b00290cdc04acbsi1026063pjn.187.2024.01.31.03.42.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:42:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46357-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MviYUze4; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-46357-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46357-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B9852293644 for ; Wed, 31 Jan 2024 11:36:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A40DF79DDF; Wed, 31 Jan 2024 11:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="MviYUze4" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 8226A76023 for ; Wed, 31 Jan 2024 11:34:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706700887; cv=none; b=iT4IlgdCtVUwkjH3P/t8iZTFm+FV91E1/9UPFR2plTAn9ByrwuDkyysfA6U4I4sBAe7nPfJMs3VI3KzTX3gD0G2WIA9eGJiCE1BwrqtOmS0ynSh4jo8GxGIa+9NOFQkER3ikQA3pCasCF770UgMZY772/caf1gYei/Sos/CAsNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706700887; c=relaxed/simple; bh=JY1iMd8qOfsdbrHbfu30Unsdv6pQvJsZX6iF7UtrCEE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r41nzQNp+hhucVbZ6OjEvMHLET0pS2qBWsyUqKcuO+p3yPWH2hxly2gtGkBuiungyKZ/qMaSw2Fw3BncICtfjJUVYWlKOqIMRI3KPxy/EOh4tkc53jb3joQ3l0CzdFVo5ABF7B/DqMtr21QmOQFkYdo/OOvb1OcRP2OQ70NIf/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=MviYUze4; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706700883; bh=JY1iMd8qOfsdbrHbfu30Unsdv6pQvJsZX6iF7UtrCEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MviYUze4wBFc3uSP+ufe2apG6Ydm/2PuHwte2EKSmXbuRRo8rw4VlUGlOWl8z1VHF QN437ye6zDvRpWC45xzzYXm8tG3Nlii8mmvP9IWxJTFCZ5av3/PXhArLSVVLTmHLfd bPhfvgL2OGEGXg7BpLsOjaatxszSDm+14dv/MoCJXKnUOUjmQI7x4LSMHNV5Vnsuan MsQqQtjwIIHS7A+gkIfAbO4bCdStKKP+VhOMjAtp0RzNmij/vgNSpZxnPG/W0izLCl 07le++ei+yVLd/st0tPU86AQ78kINc3wmRdpZBK1zKM+m6mNtU0bYFveApWCFC66xF 8Ucjn2blKKYCw== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 172FE3782079; Wed, 31 Jan 2024 11:34:43 +0000 (UTC) From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: fshao@chromium.org, p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com Subject: [PATCH v3 3/7] drm/mediatek: dsi: Use bitfield macros where useful Date: Wed, 31 Jan 2024 12:34:30 +0100 Message-ID: <20240131113434.241929-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131113434.241929-1-angelogioacchino.delregno@collabora.com> References: <20240131113434.241929-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789606065917606338 X-GMAIL-MSGID: 1789606065917606338 Instead of open coding bitshifting for various register fields, use the bitfield macro FIELD_PREP(): this allows to enhance the human readability, decrease likeliness of mistakes (and register field overflowing) and also to simplify the code. The latter is especially seen in mtk_dsi_rxtx_control(), where it was possible to change a switch to a short for loop and to also remove the need to check for maximum DSI lanes == 4 thanks to the FIELD_PREP macro masking the value. While at it, also add the missing DA_HS_SYNC bitmask, used in mtk_dsi_phy_timconfig(). Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dsi.c | 97 ++++++++++++++++-------------- 1 file changed, 52 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index 8414ce73ce9f..cba63de5092d 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -3,6 +3,7 @@ * Copyright (c) 2015 MediaTek Inc. */ +#include #include #include #include @@ -70,16 +71,19 @@ #define DSI_PSCTRL 0x1c #define DSI_PS_WC GENMASK(14, 0) #define DSI_PS_SEL GENMASK(19, 16) -#define PACKED_PS_16BIT_RGB565 (0 << 16) -#define LOOSELY_PS_18BIT_RGB666 (1 << 16) -#define PACKED_PS_18BIT_RGB666 (2 << 16) -#define PACKED_PS_24BIT_RGB888 (3 << 16) +#define PACKED_PS_16BIT_RGB565 0 +#define LOOSELY_PS_18BIT_RGB666 1 +#define PACKED_PS_18BIT_RGB666 2 +#define PACKED_PS_24BIT_RGB888 3 #define DSI_VSA_NL 0x20 #define DSI_VBP_NL 0x24 #define DSI_VFP_NL 0x28 #define DSI_VACT_NL 0x2C +#define VACT_NL GENMASK(14, 0) #define DSI_SIZE_CON 0x38 +#define DSI_HEIGHT GENMASK(30, 16) +#define DSI_WIDTH GENMASK(14, 0) #define DSI_HSA_WC 0x50 #define DSI_HBP_WC 0x54 #define DSI_HFP_WC 0x58 @@ -122,6 +126,7 @@ #define DSI_PHY_TIMECON2 0x118 #define CONT_DET GENMASK(7, 0) +#define DA_HS_SYNC GENMASK(15, 8) #define CLK_ZERO GENMASK(23, 16) #define CLK_TRAIL GENMASK(31, 24) @@ -253,14 +258,23 @@ static void mtk_dsi_phy_timconfig(struct mtk_dsi *dsi) timing->clk_hs_zero = timing->clk_hs_trail * 4; timing->clk_hs_exit = 2 * timing->clk_hs_trail; - timcon0 = timing->lpx | timing->da_hs_prepare << 8 | - timing->da_hs_zero << 16 | timing->da_hs_trail << 24; - timcon1 = timing->ta_go | timing->ta_sure << 8 | - timing->ta_get << 16 | timing->da_hs_exit << 24; - timcon2 = 1 << 8 | timing->clk_hs_zero << 16 | - timing->clk_hs_trail << 24; - timcon3 = timing->clk_hs_prepare | timing->clk_hs_post << 8 | - timing->clk_hs_exit << 16; + timcon0 = FIELD_PREP(LPX, timing->lpx) | + FIELD_PREP(HS_PREP, timing->da_hs_prepare) | + FIELD_PREP(HS_ZERO, timing->da_hs_zero) | + FIELD_PREP(HS_TRAIL, timing->da_hs_trail); + + timcon1 = FIELD_PREP(TA_GO, timing->ta_go) | + FIELD_PREP(TA_SURE, timing->ta_sure) | + FIELD_PREP(TA_GET, timing->ta_get) | + FIELD_PREP(DA_HS_EXIT, timing->da_hs_exit); + + timcon2 = FIELD_PREP(DA_HS_SYNC, 1) | + FIELD_PREP(CLK_ZERO, timing->clk_hs_zero) | + FIELD_PREP(CLK_TRAIL, timing->clk_hs_trail); + + timcon3 = FIELD_PREP(CLK_HS_PREP, timing->clk_hs_prepare) | + FIELD_PREP(CLK_HS_POST, timing->clk_hs_post) | + FIELD_PREP(CLK_HS_EXIT, timing->clk_hs_exit); writel(timcon0, dsi->regs + DSI_PHY_TIMECON0); writel(timcon1, dsi->regs + DSI_PHY_TIMECON1); @@ -353,69 +367,61 @@ static void mtk_dsi_set_vm_cmd(struct mtk_dsi *dsi) static void mtk_dsi_rxtx_control(struct mtk_dsi *dsi) { - u32 tmp_reg; + u32 regval, tmp_reg = 0; + u8 i; - switch (dsi->lanes) { - case 1: - tmp_reg = 1 << 2; - break; - case 2: - tmp_reg = 3 << 2; - break; - case 3: - tmp_reg = 7 << 2; - break; - case 4: - tmp_reg = 0xf << 2; - break; - default: - tmp_reg = 0xf << 2; - break; - } + /* Number of DSI lanes (max 4 lanes), each bit enables one DSI lane. */ + for (i = 0; i < dsi->lanes; i++) + tmp_reg |= BIT(i); + + regval = FIELD_PREP(LANE_NUM, tmp_reg); if (dsi->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS) - tmp_reg |= HSTX_CKLP_EN; + regval |= HSTX_CKLP_EN; if (dsi->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET) - tmp_reg |= DIS_EOT; + regval |= DIS_EOT; - writel(tmp_reg, dsi->regs + DSI_TXRX_CTRL); + writel(regval, dsi->regs + DSI_TXRX_CTRL); } static void mtk_dsi_ps_control(struct mtk_dsi *dsi, bool config_vact) { - struct videomode *vm = &dsi->vm; - u32 dsi_buf_bpp, ps_wc; - u32 ps_bpp_mode; + u32 dsi_buf_bpp, ps_val, ps_wc, vact_nl; if (dsi->format == MIPI_DSI_FMT_RGB565) dsi_buf_bpp = 2; else dsi_buf_bpp = 3; - ps_wc = vm->hactive * dsi_buf_bpp; - ps_bpp_mode = ps_wc; + /* Word count */ + ps_wc = FIELD_PREP(DSI_PS_WC, dsi->vm.hactive * dsi_buf_bpp); + ps_val = ps_wc; + /* Pixel Stream type */ switch (dsi->format) { + default: + fallthrough; case MIPI_DSI_FMT_RGB888: - ps_bpp_mode |= PACKED_PS_24BIT_RGB888; + ps_val |= FIELD_PREP(DSI_PS_SEL, PACKED_PS_24BIT_RGB888); break; case MIPI_DSI_FMT_RGB666: - ps_bpp_mode |= PACKED_PS_18BIT_RGB666; + ps_val |= FIELD_PREP(DSI_PS_SEL, PACKED_PS_18BIT_RGB666); break; case MIPI_DSI_FMT_RGB666_PACKED: - ps_bpp_mode |= LOOSELY_PS_18BIT_RGB666; + ps_val |= FIELD_PREP(DSI_PS_SEL, LOOSELY_PS_18BIT_RGB666); break; case MIPI_DSI_FMT_RGB565: - ps_bpp_mode |= PACKED_PS_16BIT_RGB565; + ps_val |= FIELD_PREP(DSI_PS_SEL, PACKED_PS_16BIT_RGB565); break; } if (config_vact) { - writel(vm->vactive, dsi->regs + DSI_VACT_NL); + vact_nl = FIELD_PREP(VACT_NL, dsi->vm.vactive); + writel(vact_nl, dsi->regs + DSI_VACT_NL); writel(ps_wc, dsi->regs + DSI_HSTX_CKL_WC); } - writel(ps_bpp_mode, dsi->regs + DSI_PSCTRL); + writel(ps_val, dsi->regs + DSI_PSCTRL); } static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) @@ -442,7 +448,8 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) writel(vm->vactive, dsi->regs + DSI_VACT_NL); if (dsi->driver_data->has_size_ctl) - writel(vm->vactive << 16 | vm->hactive, + writel(FIELD_PREP(DSI_HEIGHT, vm->vactive) | + FIELD_PREP(DSI_WIDTH, vm->hactive), dsi->regs + DSI_SIZE_CON); horizontal_sync_active_byte = (vm->hsync_len * dsi_tmp_buf_bpp - 10); From patchwork Wed Jan 31 11:34:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 194709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1826201dyb; Wed, 31 Jan 2024 03:42:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGd0Hq2toKU9ahBKm67IirecTNOdTjA/GIFaZ6J1Y99svD2H1Gnx4j+7F+3p/mU48UTXukC X-Received: by 2002:a05:6808:e8d:b0:3bc:3d7a:48c1 with SMTP id k13-20020a0568080e8d00b003bc3d7a48c1mr1381244oil.54.1706701341558; Wed, 31 Jan 2024 03:42:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706701341; cv=pass; d=google.com; s=arc-20160816; b=tj6uvIdrhxo7zFbvPriMNM8+vqNi1NWKWP3kUj/X8qn3yFhHCxDAJum0MRVv4LDEks IlXyL+69FU0OmhN8y5Iq3WVv5uzrv0bJFbzsLgsAJiKoXSVv0hXqPALsScv7KU47x6+K wKJ1W8mFw4AwbY6ATnamkCFxMQozXtcHiZ4I4RNuoVnkIlVobUhVTdUSuwf1eyxs2Px3 IPLPfuLz3SVjpV1AGnF4Bq+nJJCV26I5xkNtSn2hRfAcX7PGNbCUucH5HihGkc538b91 1jzhQTxVevlKrh4j70Fw4ao58mS61PH/mXrGpMZ8WqJMjQB6G6EI0EZJ+Tb7Gaie4AmS oYIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FdWfbaioGYtrLXt4q9whTZECZW+rVOFh54QnV0U1+K4=; fh=UD3x1EdRmHmfQe8SipOJCJs2Zr84G3s1dvUkxHZqKQc=; b=FmWuIZf/PtjbfI71yfwTSr7PmZfHfbK42omaSMP0dss0vDedQe08Gr92ru4zSv0g7k 5kWudm95daSndMIPCQKdI/P9DygIgTunAneXLezQsmsEG1RzVJgtj8FQnCI9vfa1PqET 0g7MhdLGcXZln0UAGtnwzE0e+SKGqJh+JMK3RT/+48xtfVn1d0r37ngyqiJbXbuDawz0 2rAhdh/UrHbyTyRq6+XmV5OSkxUMdxXLu9KUNFiJke7NIkz/1VnDr02+EfTkWe/VgnOq Cnj1qq9EY3ZOz2iKH+RZDCSkntOv3dtzF5dB88E0n5ogpDkSnUBiTjwXZpHzx9eesiFr jIuw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=5dr1dfI9; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-46358-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46358-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com X-Forwarded-Encrypted: i=1; AJvYcCWfZN5oxPYUJ+1z0JN2Z1rYUo2VVNAka9ELQWNJmFqh/rslDtUcRHpHfcu+7sZZczYUWpwHHBECbYfN9rBcUIj/FpLO2w== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p9-20020a056a0026c900b006dfdfc0366asi182462pfw.107.2024.01.31.03.42.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:42:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46358-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=5dr1dfI9; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-46358-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46358-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 64751293678 for ; Wed, 31 Jan 2024 11:36:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B80047A712; Wed, 31 Jan 2024 11:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="5dr1dfI9" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 7C4CA76906 for ; Wed, 31 Jan 2024 11:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706700888; cv=none; b=ijHMLC+fIGZnhgUi4pR3aSLlRcIs20WFlmHtuMmNBVAemGu9cGYPavG8jUgFEzDTo7NGjRVgpAF6eFR5L8FIWor2VlHP9LJc70kFm241SHh8DcphDVapP9OTXLVyxdY+ZpBDZd2a3z73ha8jvth2JD9nuy1UBE/sHInIXbUcA4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706700888; c=relaxed/simple; bh=zbzMnTpoZSIYlb8jiO31bv5oIKyPpIebAKdElYE+AVE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OdW2pgDT5sua1NOma1Z+Yf8Mwc5cJbQ9T3BLxeFny3W9Xnwi7/YC2gcA5/QWxMMXiuA5KPAgdYB7HPlRa/hsghgxnMefg7OwKGP+s2F9phgM5YJZUepwBUIe3t2xYaM1ueswVOg9owohJXJDqAchJEtUuIErEZpK45KBih3gG5M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=5dr1dfI9; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706700884; bh=zbzMnTpoZSIYlb8jiO31bv5oIKyPpIebAKdElYE+AVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=5dr1dfI92989qfXEE0vyDLv888ezBDSodGehkNXNu0kz/KOLNI2QAPbV94iem1CV7 1vb+GpQyeTrowvnxj+NHPGxupHSIFm9halBaUDvBp+FjeD4AiKxwk1yFbm1dlWIIas 3qUGHF7gp5zBt7P1ubh4rZ4YI5FISupAKiOIYlW4H7KpKp2huSfWFrCsXRHFtTi/WL oCIopRbWxre6xzV5+CPcruTcOSPt1ezSlcARcAYaUnQL0gAUbfe09BU1mSJ+0ViV1z bFfUCRJXYpMlcRFQ2MiwVynywKnp8KsUxzo2Zbd6NqXORJOwCij/MZgeoPmGmCpN5n SVEoPacPM0w9Q== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 17D033782084; Wed, 31 Jan 2024 11:34:44 +0000 (UTC) From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: fshao@chromium.org, p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com Subject: [PATCH v3 4/7] drm/mediatek: dsi: Replace open-coded instance of HZ_PER_MHZ Date: Wed, 31 Jan 2024 12:34:31 +0100 Message-ID: <20240131113434.241929-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131113434.241929-1-angelogioacchino.delregno@collabora.com> References: <20240131113434.241929-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789606065575822520 X-GMAIL-MSGID: 1789606065575822520 In mtk_dsi_phy_timconfig(), we're dividing the `data_rate` variable, expressed in Hz to retrieve a value in MHz: instead of open-coding, use the HZ_PER_MHZ definition, available in linux/units.h. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index cba63de5092d..cc625febe6c8 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -13,6 +13,7 @@ #include #include #include +#include #include