From patchwork Wed May 24 09:34:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 98409 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2715992vqo; Wed, 24 May 2023 02:39:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7SGa27HctpcpWXwrb1epFbf5bCwPh1wRjzAJeOnUWcH45mAKLFuQn39AYdGZTrtmD4U1+R X-Received: by 2002:a05:6a00:1493:b0:64a:ede1:13fb with SMTP id v19-20020a056a00149300b0064aede113fbmr2584598pfu.9.1684921179363; Wed, 24 May 2023 02:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684921179; cv=none; d=google.com; s=arc-20160816; b=FPfYSlHaqp+b0psh64YHJMNFVgsK6V3qDhoJfvmeg3CIzOTaWp/6G9HnaOGwJ7kcRe ruuR5YKqWevSNAv1TwMFbvQVlU2/HfKFsPBwDkmG2h69v9GcLLyCmOq7uLho/UhvhkDn Cts7KSCKtQ8z0uNE8fk+3ywrE/mTMhTVPYyPm7K0oN14J9n8rS5Z4BBmIUMF85qOhO/Q Xgttu95AOFjwj/BMLOUvtKNkk8tADCltgyd5pzpbD38WXLbH1m3XJXoGQ59ugAhqPT+Q 8Wwj0WPasPoP7yY7b9VvczDnmHqyOGztM2TzXCjo5X0Lfai+UFe9FmXS37tkg0qUr5qZ i0+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aL0m7WL0ExPspavdK/SPFUO+XFX8Ua0+/VJ1q9J/2IM=; b=LFz4GXgIBmMvgTBo8cpfQrzUTd7G1yDNSzeywqzeEtWhGW1gPPLhKjsR+LpzgKIMcU W3FOwBzL1wrUGXoNTmChVbGIq/XKwbfNn/33gG946EDO83jukXMiG4calSPjV3ZTr6br 5OVf0opt6prH+sZ1steWg2lOrZyv8c9frXJj30WcNMEEwtfWDxLRt5I351gFnS3mCoX0 l3WzBKVcUo0nYrvQVJ2WkoGmBeh8XeOYVWP8QoV+vJW/V5sEJDqr1mRMQjIwVK/bDAfM 68KAmX1Zy6DVv8r7Vx50ZNSxtnTj4Tx28NpD7lJVTAebkzfwJvsXBdmYFfAM4oJ2SfTB 8ZYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=mNexC93a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n13-20020a63b44d000000b005250385bfdbsi3981989pgu.549.2023.05.24.02.39.26; Wed, 24 May 2023 02:39:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=mNexC93a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbjEXJec (ORCPT + 99 others); Wed, 24 May 2023 05:34:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbjEXJeZ (ORCPT ); Wed, 24 May 2023 05:34:25 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F91EC0 for ; Wed, 24 May 2023 02:34:23 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:a962:cd4d:a84:1eab]) (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 madras.collabora.co.uk (Postfix) with ESMTPSA id 3BAC66602F6A; Wed, 24 May 2023 10:34:21 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1684920861; bh=UhPYkAXn11l5HCs1IddO+VQSqgiY8B30l4baBYtD728=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mNexC93aSqJBpRp6DYVULa3o+B7m+hMQ3jSt0/oPR0RDVbV9u0CES21Nom15ed6bP 9vNoLpGVJHJbsZ3A83ziBnLYDd4ZFAYMl/5S/yjb2EXGkFLLpCqJIqZ2SH/9d/BExx 694NRclPSEpbEoRQlxISYRJmfv9d/KUeLKtZXlGrkoRch0q16JhKLzLG/8S4JjI6i2 CKS5SoDACM7uSZXW/gjHkyuqOtrW5L40455nYFnAhyX7lsyOGXW8dlkgSpUqmIOg68 Gvz1CeyfXmuWTYEh2Y5/5uYboVFeQd9e0OmPLsvkmuhxQ0enLDbz8y8eaMYV0AjzxK dLwhCY2THXETA== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: 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 v1 1/4] drm/mediatek: dsi: Use GENMASK() for register mask definitions Date: Wed, 24 May 2023 11:34:09 +0200 Message-Id: <20230524093412.92211-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524093412.92211-1-angelogioacchino.delregno@collabora.com> References: <20230524093412.92211-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766767910690700187?= X-GMAIL-MSGID: =?utf-8?q?1766767910690700187?= Change magic numerical masks with usage of the GENMASK() macro to improve readability. This commit brings no functional changes. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dsi.c | 46 ++++++++++++++++-------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index b0ab38e59db9..246a3a338c1e 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) @@ -108,26 +108,27 @@ #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 DA_HS_SYNC GENMASK(15, 8) +#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) @@ -137,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 May 24 09:34:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 98411 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2716088vqo; Wed, 24 May 2023 02:39:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6uXzpgdnTZDOGjTnA1rEBuDfeD6Ij3RMUxTPn5oo4ksV5X0Ba8q3KNtNv5L+oxmR3rkYBx X-Received: by 2002:a17:902:d2ca:b0:1ae:8fa:cd4c with SMTP id n10-20020a170902d2ca00b001ae08facd4cmr24762923plc.7.1684921193294; Wed, 24 May 2023 02:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684921193; cv=none; d=google.com; s=arc-20160816; b=nMcqTrqWaUuHqg2p/yMfJ0A+uzAH9WgFxcJK31+DXqR5vsH4gtl9HLLjB4pcq+TtST rvEV3EnoJtDC9K3SAVUPaRfx65a8t6msoIG+3d3l/l1wSmhRUlyCLhdC+84afr6s7LK3 BW166Alfkp5/fvwpyPMSlDHmp/jlJ+VnuDA9vMcEQJ7cdc9mAidFgWq7/UHFdn+jVQfx vs+kOMziJgyKh3grYZN+lXeCv4IrfKQ1SysGoavo+Ugy98yijIJVavYUGtqaATgliIaf 2whvdgTcte4+BYvyzLpesne11kc5+X7elZQJMKJhckRwENUF/5dMxU3b3OwDKRbYdz9k Klnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SG8RplzxmWn1wdoKnjKHOZqYv8KlBqP6fp2K7XxXdx0=; b=nQsayE8jv/iqKyhbiG2U38Hs43Q21joqHHl/Rl3vSdU0fJi47RNIgwQwtKyJKWGQm9 1IMg2NNp/R4FBbOkUahBNgFXSNxSWeP3cmW9as/SPdouPiE56ir52QiejckL2MFNWAa2 8Ishuu97aOEZ2IpawYE9Eb5YqPbSYNeK7G3iizdasO0g/4ckaKUWxjssPZ5TZzu1KvcQ j1mc5V34c4O2QlswnLdqFUuQhAxh+AvbfZtX5+72VvfHOgHwA+LaWR/FHyqrD/11G5MY 8yANJIcGZ/xnTv/uGnSkMaZfJuehv6POvd2liPALxnp0sVMoWcEN4RzPB0e9rz+J0I6Y vV4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=OugGCOpF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x6-20020a170902ea8600b001a2513b8e14si3730487plb.84.2023.05.24.02.39.41; Wed, 24 May 2023 02:39:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=OugGCOpF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbjEXJeg (ORCPT + 99 others); Wed, 24 May 2023 05:34:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjEXJeZ (ORCPT ); Wed, 24 May 2023 05:34:25 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40F3993 for ; Wed, 24 May 2023 02:34:24 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:a962:cd4d:a84:1eab]) (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 madras.collabora.co.uk (Postfix) with ESMTPSA id 0E54866031B5; Wed, 24 May 2023 10:34:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1684920862; bh=AF3G+Ay1qVP5IzxZeph5rM6hzV1JNEhtA1DrPHYLiqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OugGCOpFY54lbwjNzJQJiM8JFbU00DKYcvd4pl9j8/D0gKxbP/MhLhSt3/ebjUoey qr54Etmah/yFx7zQ2q6o9QdUSZQp7RIZi5Jvz+/ihnlwgQlGToWZGaR9X6BVDIykF5 eZdAf3MUmP3RHwlcd1WC5eWg9P/p9k+MBqqY75D7e90E4gIOf9TD3BtjJ0lvt2N+hh 1SIC9EZ3NW7MAvoJcb8HDETnurF0WBS1nwYT/DIdN6zbkp+AVZGve0OhcQLWwvSa4F xQ6Fh235PzeyK7FJc0wu3SRyjIGRGnNXQN0oWiJ5bl/7cknW1L6naB3YRZx+RUWfQo Zido2mMFKMt9w== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: 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 v1 2/4] drm/mediatek: dsi: Cleanup functions mtk_dsi_ps_control{_vact}() Date: Wed, 24 May 2023 11:34:10 +0200 Message-Id: <20230524093412.92211-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524093412.92211-1-angelogioacchino.delregno@collabora.com> References: <20230524093412.92211-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766767924847204346?= X-GMAIL-MSGID: =?utf-8?q?1766767924847204346?= 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. 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 246a3a338c1e..97d5b3083057 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -350,40 +350,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; @@ -415,36 +381,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) @@ -520,7 +490,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) @@ -665,7 +635,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 May 24 09:34:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 98410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2716090vqo; Wed, 24 May 2023 02:39:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4sbhjnoGzKmPavMcdYujBHruOjN7f8U+4tsgpljuu+D95S305xKoYqL37oJEfowSzOykou X-Received: by 2002:a05:6a20:258c:b0:fa:1f3a:8f56 with SMTP id k12-20020a056a20258c00b000fa1f3a8f56mr18923118pzd.12.1684921193238; Wed, 24 May 2023 02:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684921193; cv=none; d=google.com; s=arc-20160816; b=yBLHihug9TgtAEIMajhrogYkO/T9j1o2qoZCNfEwaBsxIOkrbyRhxdPcqIThx9igRL 7Z/erA53xnwMc+ti/7xWrJVcUnKio0Ws8yidKdC1+5V1Cf7ihbSRGCIFYxMMnGs1xSWF XWcjbRVEiCbqKNxbrucEx5oSA1wtiSXYoczvYqU1RHgwr8U7GUM++1/S4nsha73+OZh8 eChQbL4IbFobhcF+ZEx8supy4fHA6G/4Rvy0vLsshDVp1Y7OI1frbdkyfdO19Y8IDC5R cpv9XkzJ8hIHpEJsTRDAatoycBV1fIUkLPpf1nKKZhJTzw9RT7G2zt7zqpesevh+U6A+ aI1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3tqfuCo5DNn/wXi41LQ223toHVJtS8luDz3YbhcWPWY=; b=QtRqZzftjYFnO+TFaCWX8vbvwDJz0DoHcC3qzzbvrBTDY8MnB65XlGTKSrAXMrBpe7 oWFucpLBYK/NxxombxWYv21genYJLB2C1K0BPHzKn4HykpclVFY/a2QmqB47Rzx8typz 7J5jmB5lwcu2pOHtDPx4zO7kK7orroxLmiM1VXq7vn+5bewdaY/OcoaRbHD58jjyX47u OpKcdtGKsINyv3A0VJx0mRfWR6wQeeAvePCIVWCtHfdniSODGMeX8yYv+mhMKyNHd0Gv YlmdlXHtv9FK+4AxBBOoSQKKfuH/sApdi8u+ggRi5M0jEjvmgwwYMkqk+LX3FvXaHGfj 9gfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iXe0vHth; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a637b06000000b0051f0bd1b159si6459995pgc.718.2023.05.24.02.39.41; Wed, 24 May 2023 02:39:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iXe0vHth; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229605AbjEXJei (ORCPT + 99 others); Wed, 24 May 2023 05:34:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbjEXJe0 (ORCPT ); Wed, 24 May 2023 05:34:26 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFCE2A7 for ; Wed, 24 May 2023 02:34:24 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:a962:cd4d:a84:1eab]) (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 madras.collabora.co.uk (Postfix) with ESMTPSA id D80A0660572A; Wed, 24 May 2023 10:34:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1684920863; bh=6tPVqjGG3ALTeNS4ASDNy61pD3smgtM4CAEyiOJLuOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iXe0vHth5hK9XGCqsdEQzvtqR130hTrxudQHlDJYSt7mzYwtv2iL0PwtQj0EgLHkU wmmExLBUs7RQ+yOyXdlDNC4cjvFqqFWPw7G61leDsI+7eP9sKAi8YovHo2TLf3WU1r uHRZj9Vci84UU7tgdmtb3PHXeDVru4zhYXLDMIL+GcNExvuAtjh60ynXlZXyAQ3nA+ 1+eJNHRvKTJUrJzXLrkbmQR3G/QN+wHNJLdPWHn71iZpxUYeMdU9YB0LKp7khqugT4 uc/Qr7fWesuJpuD+8FlcedvGFkPvO77K7pDIv6W5mghpO5b8U6wklkcHJGvMjuTJQ7 F5/F3xBrCnD/g== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: 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 v1 3/4] drm/mediatek: dsi: Use bitfield macros where useful Date: Wed, 24 May 2023 11:34:11 +0200 Message-Id: <20230524093412.92211-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524093412.92211-1-angelogioacchino.delregno@collabora.com> References: <20230524093412.92211-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766767925109682638?= X-GMAIL-MSGID: =?utf-8?q?1766767925109682638?= 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. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dsi.c | 95 ++++++++++++++++-------------- 1 file changed, 50 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index 97d5b3083057..fbf1c232107d 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -70,16 +70,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 @@ -252,14 +255,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); @@ -352,69 +364,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) @@ -441,7 +445,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 May 24 09:34:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 98412 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2716560vqo; Wed, 24 May 2023 02:41:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5+9HxokRp3qzrHPpIVayfseeUIMIEDvrU4Gy3q8lbYcNdRR7j2WcJK8WU1WDxxciZoERD7 X-Received: by 2002:a17:902:e808:b0:1a6:9cb3:5b30 with SMTP id u8-20020a170902e80800b001a69cb35b30mr25128922plg.8.1684921266368; Wed, 24 May 2023 02:41:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684921266; cv=none; d=google.com; s=arc-20160816; b=uylmUhBFbVo7QAjcuAIwT+25HXhFknW09QSq6qZiTSMTS857bFc13UezefgSES2QvK 39PplmmQEcMgqm1iX5kmSRnRmMK9TMRyX6nkEXAkMQDmq0JaQCH1EAHVcBo8LxslqrU4 r6laanT5Cyrp8rVOjECv8J606Xx7P/VQL42WCeKhnmf27SMox/5sdWBOPMKhd6Usg8LO 5FOGUMWArpxEW34Uta7EvRZlFa03BdhdIKzsT3vKkqEROz9Mf/Kl59e8nlXPcsvpHN6S 0CE6+PckNm1dl+K0r4S+ZFgiHmDQm8b+57CWXxePDnBRyDNswh3wgpKe/TdjXM3t7WM8 08jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=H826kt0kQLxoUVgkxlMf0iwYK4GNnc8J2Oazq9yqCB0=; b=TzJBU/tRACxtmqur7JCAQp64oTy7ly1gkh1zpp4bg1cCUWORaUQrqWPVwh5lAjUbOZ 8wO6rmuzTPn5xLHKF1wblNCU79VF7f3Lg5vNXot/iNvrtPAhx+tAltb+3Cz4T6341wmR 7aIatD5B0kcboPi38CUbFoYHZ+qrTBX25fri7T3Q4v6gudUC7Y4ebo87LMnoKXGiGUyk F6sNrNJvhFFKI3ga5EVnwymKApyIFbLB6j3Uz0Q0xhm9u554ETn8zebvvP5D9b/BVMi9 L3hmghA4eT8ZKkJTaubivGxYidqgO8KcPv8axteLhN5vdFXFg1rWKjW9x6dOmoWaFc2l Zn3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=AwUM2x1g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a170903110c00b001ae8c269c76si8056819plh.638.2023.05.24.02.40.54; Wed, 24 May 2023 02:41:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=AwUM2x1g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229824AbjEXJem (ORCPT + 99 others); Wed, 24 May 2023 05:34:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbjEXJe1 (ORCPT ); Wed, 24 May 2023 05:34:27 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EC1CFC for ; Wed, 24 May 2023 02:34:25 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:a962:cd4d:a84:1eab]) (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 madras.collabora.co.uk (Postfix) with ESMTPSA id ACF446605907; Wed, 24 May 2023 10:34:23 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1684920864; bh=2Hsz2EJdS4VRyzmFM2xYr8U8SP0LYcUFtMd/nf9GRoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AwUM2x1gqbCnMltEdDDWXJkmqEpaWuDHJ9+w6dLrM2HWUxM9b7/McSlJDGk0gUk7c Jbj8aYRiG388X8EhLCNpu8jRi/q7C01Kax39aLm9YxGAUlxq3X59eyp5ftLF6wpmkN roYpXEIL8tf1SdPlC/2pnR87JSOTRAvX0YIrNFMAuAV4BIwIHH1C3CkjBc7R71pRjL S1oMvYK6SpHtYTNFiGC3xCRuZZeygJzKRYyxSS3SgDKwwToq5RSw5WazR/fzPsX21g zOWF+Af22teRcjLBhBXy/T7Sbm+S13nN5IOAPXvDEs0GwPuswuEfW0voB7nrcYH4LM ApX7Kynr53w1g== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: 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 v1 4/4] drm/mediatek: dsi: Replace open-coded instance of HZ_PER_MHZ Date: Wed, 24 May 2023 11:34:12 +0200 Message-Id: <20230524093412.92211-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524093412.92211-1-angelogioacchino.delregno@collabora.com> References: <20230524093412.92211-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766768001635177019?= X-GMAIL-MSGID: =?utf-8?q?1766768001635177019?= 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 fbf1c232107d..19e2b042c9d5 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include