From patchwork Fri Oct 14 15:15:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Ranquet X-Patchwork-Id: 13007194 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0EC1C4332F for ; Fri, 14 Oct 2022 16:31:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uwfvFQHKGa62eRjp70p24UFxkPrBUR+rMtBHPWoBJWg=; b=Gd2ghSM8Kbw9w3 6xsaYHenZwqxvyU1Hg6sBSNet+EL5udTewvE1d6bpVfSr67X6ERy4bD/2H7wXgcJ2v73mU6mF7sd+ KuybR0mJsAySimcCx49MYbmnn5zeSsd1gkSaHdxQf0IJqVmnn+jm4SAYnQUZI/PWIMCp2K28JTLHA W8R3LFLm7eCVkZQyIXwltwdM7tu3LHfQXmkFitXCI4+meO1ZXSlH2PFykP0KSkqG2vpVlJBv5Yuc8 AwBBjrv9CZXsr9UoOXUm7pxzLzsdgji6OBDwSRdHFa9uLpFCBJR1F8Ad6GCvg0TUnJjgDcQXSgxUw ARh6z96NOdZ94/zVCSeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojNaR-00FLlm-8K; Fri, 14 Oct 2022 16:31:03 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojMTq-00F9eI-0N for linux-phy@lists.infradead.org; Fri, 14 Oct 2022 15:20:12 +0000 Received: by mail-wm1-x336.google.com with SMTP id c7-20020a05600c0ac700b003c6cad86f38so5589922wmr.2 for ; Fri, 14 Oct 2022 08:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=WD3SWI1ZQbB56NbLV6ErcIYLgxudB79QnGxHT/OO1/A=; b=xvuyHsGSe72rLdUihhIBroS2wQfyS10y9SL3x7bwkMz7yNpMbKWFfQk4EJbX/Zo372 PwscucOiJJKImb6RHp2IR7put5ZYBb8UBgWTLnZ4JnhUxaO5x/c0uvLkidJ+dPGP+TPm iaDvm1ZRslxLAS8nhDnYVmkYjvIjuvrkZPzZXqn4K8bWCGldqzeMX0SNR+uEL06+sPvE Q8vIN7a9fiz+fqqONarnApyHicElt5yUzQMXVOtF0ydXRndURCyICzKHciuwELNEDhWE l1/+Fsza7f6d+lB92wDKYxEkL4DbyK/62lJf1Z1GtjJW6HF5KCWym+cyOHtkmzmw9Ib9 BrSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WD3SWI1ZQbB56NbLV6ErcIYLgxudB79QnGxHT/OO1/A=; b=DtC/44puMZPSpNsoG+s7ZfOilBaBsmV9u6QBOFTwoDSdI6dJ/etxW2AylYCzktzjvi z7sMDKMrmrZhumNgvYhkixeKmxhHxS0RtPDo6liYp4mmRP1XeoYWuQoI/yXlcsq3iQEG H+mUfB7CRnWgitfu+PNGdPqlfAc4XnM7wXLGImW/YbjqnwMP6aJY1VuHWY0p5Mxt9Nj+ ocUISNN6Uc6JuJn9SouZSShRVGaUf3q5tuVaNWXxKP704pcdVDmDjo/MZUeRbDwM7onP XBT5Dp1ZQz9LJ33V0UEN8+V8Lja8ZWW0mD30vrTV/4dFUJdE9EL4oB4iJY2910ndz3Qk 9htQ== X-Gm-Message-State: ACrzQf1qvphzeNYkRw89DoZwaGFqsvLhfajDCeRQk8pDj85b+CkWFaPe N5RnZjkTTzc5JzxIT0InCLLnrQ== X-Google-Smtp-Source: AMsMyM7f1Cxdv0i/Y3UH5OsNKg6jf7wGcVPESpSUScbeO0dlFszQv0PQ/gafOm4z2H3jH5fpfnYUnw== X-Received: by 2002:a05:600c:3d8e:b0:3c6:e58d:354f with SMTP id bi14-20020a05600c3d8e00b003c6e58d354fmr3131064wmb.176.1665760807236; Fri, 14 Oct 2022 08:20:07 -0700 (PDT) Received: from [127.0.0.1] (2a02-8440-6241-7429-3074-96af-9642-0004.rev.sfr.net. [2a02:8440:6241:7429:3074:96af:9642:4]) by smtp.gmail.com with ESMTPSA id z11-20020a05600c0a0b00b003c6bd91caa5sm2818223wmp.17.2022.10.14.08.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 08:20:06 -0700 (PDT) From: Guillaume Ranquet Date: Fri, 14 Oct 2022 17:15:56 +0200 Subject: [PATCH v2 03/12] drm/mediatek: hdmi: use a regmap instead of iomem MIME-Version: 1.0 Message-Id: <20220919-v2-3-8419dcf4f09d@baylibre.com> References: <20220919-v2-0-8419dcf4f09d@baylibre.com> In-Reply-To: <20220919-v2-0-8419dcf4f09d@baylibre.com> To: Chunfeng Yun , David Airlie , Philipp Zabel , Jitao shi , CK Hu , Rob Herring , Krzysztof Kozlowski , Vinod Koul , Kishon Vijay Abraham I , Matthias Brugger , Daniel Vetter , Chun-Kuang Hu Cc: Guillaume Ranquet , stuart.lee@mediatek.com, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, Krzysztof Kozlowski , mac.shen@mediatek.com, linux-mediatek@lists.infradead.org, dri-devel@lists.freedesktop.org X-Mailer: b4 0.11.0-dev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_082010_060559_BC630DB2 X-CRM114-Status: GOOD ( 12.23 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org To prepare support for newer chips that need to share their address range with a dedicated ddc driver, use a regmap. Signed-off-by: Guillaume Ranquet --- drivers/gpu/drm/mediatek/mtk_hdmi.c | 43 +++++++++++-------------------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c index 4c80b6896dc3..9b02b30a193a 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c @@ -171,7 +171,7 @@ struct mtk_hdmi { u32 ibias_up; struct regmap *sys_regmap; unsigned int sys_offset; - void __iomem *regs; + struct regmap *regs; enum hdmi_colorspace csp; struct hdmi_audio_param aud_param; bool audio_enable; @@ -187,44 +187,29 @@ static inline struct mtk_hdmi *hdmi_ctx_from_bridge(struct drm_bridge *b) return container_of(b, struct mtk_hdmi, bridge); } -static u32 mtk_hdmi_read(struct mtk_hdmi *hdmi, u32 offset) +static int mtk_hdmi_read(struct mtk_hdmi *hdmi, u32 offset, u32 *val) { - return readl(hdmi->regs + offset); + return regmap_read(hdmi->regs, offset, val); } static void mtk_hdmi_write(struct mtk_hdmi *hdmi, u32 offset, u32 val) { - writel(val, hdmi->regs + offset); + regmap_write(hdmi->regs, offset, val); } static void mtk_hdmi_clear_bits(struct mtk_hdmi *hdmi, u32 offset, u32 bits) { - void __iomem *reg = hdmi->regs + offset; - u32 tmp; - - tmp = readl(reg); - tmp &= ~bits; - writel(tmp, reg); + regmap_clear_bits(hdmi->regs, offset, bits); } static void mtk_hdmi_set_bits(struct mtk_hdmi *hdmi, u32 offset, u32 bits) { - void __iomem *reg = hdmi->regs + offset; - u32 tmp; - - tmp = readl(reg); - tmp |= bits; - writel(tmp, reg); + regmap_set_bits(hdmi->regs, offset, bits); } static void mtk_hdmi_mask(struct mtk_hdmi *hdmi, u32 offset, u32 val, u32 mask) { - void __iomem *reg = hdmi->regs + offset; - u32 tmp; - - tmp = readl(reg); - tmp = (tmp & ~mask) | (val & mask); - writel(tmp, reg); + regmap_update_bits(hdmi->regs, offset, mask, val); } static void mtk_hdmi_hw_vid_black(struct mtk_hdmi *hdmi, bool black) @@ -473,7 +458,7 @@ static void mtk_hdmi_hw_aud_set_i2s_fmt(struct mtk_hdmi *hdmi, { u32 val; - val = mtk_hdmi_read(hdmi, GRL_CFG0); + mtk_hdmi_read(hdmi, GRL_CFG0, &val); val &= ~(CFG0_W_LENGTH_MASK | CFG0_I2S_MODE_MASK); switch (i2s_fmt) { @@ -565,7 +550,7 @@ static void mtk_hdmi_hw_aud_set_input_type(struct mtk_hdmi *hdmi, { u32 val; - val = mtk_hdmi_read(hdmi, GRL_CFG1); + mtk_hdmi_read(hdmi, GRL_CFG1, &val); if (input_type == HDMI_AUD_INPUT_I2S && (val & CFG1_SPDIF) == CFG1_SPDIF) { val &= ~CFG1_SPDIF; @@ -596,7 +581,7 @@ static void mtk_hdmi_hw_aud_src_reenable(struct mtk_hdmi *hdmi) { u32 val; - val = mtk_hdmi_read(hdmi, GRL_MIX_CTRL); + mtk_hdmi_read(hdmi, GRL_MIX_CTRL, &val); if (val & MIX_CTRL_SRC_EN) { val &= ~MIX_CTRL_SRC_EN; mtk_hdmi_write(hdmi, GRL_MIX_CTRL, val); @@ -610,7 +595,7 @@ static void mtk_hdmi_hw_aud_src_disable(struct mtk_hdmi *hdmi) { u32 val; - val = mtk_hdmi_read(hdmi, GRL_MIX_CTRL); + mtk_hdmi_read(hdmi, GRL_MIX_CTRL, &val); val &= ~MIX_CTRL_SRC_EN; mtk_hdmi_write(hdmi, GRL_MIX_CTRL, val); mtk_hdmi_write(hdmi, GRL_SHIFT_L1, 0x00); @@ -621,7 +606,7 @@ static void mtk_hdmi_hw_aud_set_mclk(struct mtk_hdmi *hdmi, { u32 val; - val = mtk_hdmi_read(hdmi, GRL_CFG5); + mtk_hdmi_read(hdmi, GRL_CFG5, &val); val &= CFG5_CD_RATIO_MASK; switch (mclk) { @@ -1427,7 +1412,6 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, struct device_node *cec_np, *remote, *i2c_np; struct platform_device *cec_pdev; struct regmap *regmap; - struct resource *mem; int ret; ret = mtk_hdmi_get_all_clk(hdmi, np); @@ -1473,8 +1457,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, } hdmi->sys_regmap = regmap; - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - hdmi->regs = devm_ioremap_resource(dev, mem); + hdmi->regs = device_node_to_regmap(dev->of_node); if (IS_ERR(hdmi->regs)) { ret = PTR_ERR(hdmi->regs); goto put_device;