Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp599673pxf; Wed, 17 Mar 2021 11:19:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOSbHEwGar+Y8uSFqP3G8pYy9N2Y/uxjqBq80OoUak3GMi1LjMTQegRtgy6bz6kzpBldy8 X-Received: by 2002:a17:906:26c9:: with SMTP id u9mr15608580ejc.520.1616005167026; Wed, 17 Mar 2021 11:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616005167; cv=none; d=google.com; s=arc-20160816; b=m4pDHENjHONAYxbSQj2rUo0zacTmDn55PQE0creBPCyb6rEo4jJFUk4pEMkXvnk3Rj DYfm99KNNrWz9Yy+UZyxmjcQLJ5BAexbKqhtT1uwMh3Cn6xtiIA4TGz1gWjxXx6ie09u cWOFIX4ZM3KilhZ9rpi6vOk0Jhy7zijANlfIkcpy8+uCvspWnAI0n9wfVZ8XsLzDqy1P vf/j+9DVsfbdZD2gQKC+04YW9oUbN5V3Em+IUBe5CgIcnr9LrdLlH8omfbMEPMm19hdd pGAoMi8t4FqBSX+maiJRCnLKNzyRB81IJ0Cs2plM83KBIyaRAiPi3U4Lxz470aKpk1Z+ me1Q== 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; bh=F/SFnAFQNlkp4KtwnMMpivWAA5XkTtq7PP8Omg5svoA=; b=u0lVlWyWLTfoCJaPXOe/m6s+zo8gqajCAGabGRzsFdtfRWlhL9ILVdqUaRqIkHBy1u Qkf6jTmHkQflFxWXCyWrW4guGT7BzQBphU2jP2jwPWK51IC4VIYQv34dKtXWK9Stxx2d RIuXDypq22FsDkfand+In+x5hWWQf5o4qkBxCHrFPHeLTw9ev/Ez3YtD8s1hRlYCF0nT kGUS23Lec5ml3H5TF1D+v7zhF/Bpvw20Uq7AdGpYWODJ0tUNVhZEwAzoqZunGsEmhy3V 7cWnDM0QarushAqWie/OL0Eyw9LA6ExO503/Oq1So4yZ9LUG92X5ej2trqxas4ZUXO4L f19g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ss17si17265490ejb.678.2021.03.17.11.19.03; Wed, 17 Mar 2021 11:19:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232950AbhCQSRj (ORCPT + 99 others); Wed, 17 Mar 2021 14:17:39 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59338 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232932AbhCQSRT (ORCPT ); Wed, 17 Mar 2021 14:17:19 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 4DC5F1F45485 From: Enric Balletbo i Serra To: linux-kernel@vger.kernel.org Cc: matthias.bgg@gmail.com, drinkcat@chromium.org, hsinyi@chromium.org, weiyi.lu@mediatek.com, Collabora Kernel ML , CK Hu , Chun-Kuang Hu , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 1/2] soc: mediatek: mmsys: Create struct mtk_mmsys to store context data Date: Wed, 17 Mar 2021 19:17:09 +0100 Message-Id: <20210317181711.795245-2-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210317181711.795245-1-enric.balletbo@collabora.com> References: <20210317181711.795245-1-enric.balletbo@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: CK Hu Apart from the driver data, in order to extend the driver to support more and more SoCs, we will need to store other configuration data. So, create a mtk_mmsys struct to encapsulate all that information. Signed-off-by: CK Hu Signed-off-by: Enric Balletbo i Serra Reviewed-by: Chun-Kuang Hu --- Changes in v2: None drivers/soc/mediatek/mtk-mmsys.c | 47 ++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c index 18f93979e14a..da2de8f6969e 100644 --- a/drivers/soc/mediatek/mtk-mmsys.c +++ b/drivers/soc/mediatek/mtk-mmsys.c @@ -101,6 +101,11 @@ static const struct mtk_mmsys_driver_data mt8183_mmsys_driver_data = { .clk_driver = "clk-mt8183-mm", }; +struct mtk_mmsys { + void __iomem *regs; + const struct mtk_mmsys_driver_data *data; +}; + static unsigned int mtk_mmsys_ddp_mout_en(enum mtk_ddp_comp_id cur, enum mtk_ddp_comp_id next, unsigned int *addr) @@ -259,21 +264,21 @@ void mtk_mmsys_ddp_connect(struct device *dev, enum mtk_ddp_comp_id cur, enum mtk_ddp_comp_id next) { - void __iomem *config_regs = dev_get_drvdata(dev); + struct mtk_mmsys *mmsys = dev_get_drvdata(dev); unsigned int addr, value, reg; value = mtk_mmsys_ddp_mout_en(cur, next, &addr); if (value) { - reg = readl_relaxed(config_regs + addr) | value; - writel_relaxed(reg, config_regs + addr); + reg = readl_relaxed(mmsys->regs + addr) | value; + writel_relaxed(reg, mmsys->regs + addr); } - mtk_mmsys_ddp_sout_sel(config_regs, cur, next); + mtk_mmsys_ddp_sout_sel(mmsys->regs, cur, next); value = mtk_mmsys_ddp_sel_in(cur, next, &addr); if (value) { - reg = readl_relaxed(config_regs + addr) | value; - writel_relaxed(reg, config_regs + addr); + reg = readl_relaxed(mmsys->regs + addr) | value; + writel_relaxed(reg, mmsys->regs + addr); } } EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_connect); @@ -282,44 +287,46 @@ void mtk_mmsys_ddp_disconnect(struct device *dev, enum mtk_ddp_comp_id cur, enum mtk_ddp_comp_id next) { - void __iomem *config_regs = dev_get_drvdata(dev); + struct mtk_mmsys *mmsys = dev_get_drvdata(dev); unsigned int addr, value, reg; value = mtk_mmsys_ddp_mout_en(cur, next, &addr); if (value) { - reg = readl_relaxed(config_regs + addr) & ~value; - writel_relaxed(reg, config_regs + addr); + reg = readl_relaxed(mmsys->regs + addr) & ~value; + writel_relaxed(reg, mmsys->regs + addr); } value = mtk_mmsys_ddp_sel_in(cur, next, &addr); if (value) { - reg = readl_relaxed(config_regs + addr) & ~value; - writel_relaxed(reg, config_regs + addr); + reg = readl_relaxed(mmsys->regs + addr) & ~value; + writel_relaxed(reg, mmsys->regs + addr); } } EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect); static int mtk_mmsys_probe(struct platform_device *pdev) { - const struct mtk_mmsys_driver_data *data; struct device *dev = &pdev->dev; struct platform_device *clks; struct platform_device *drm; - void __iomem *config_regs; + struct mtk_mmsys *mmsys; int ret; - config_regs = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(config_regs)) { - ret = PTR_ERR(config_regs); + mmsys = devm_kzalloc(dev, sizeof(*mmsys), GFP_KERNEL); + if (!mmsys) + return -ENOMEM; + + mmsys->regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(mmsys->regs)) { + ret = PTR_ERR(mmsys->regs); dev_err(dev, "Failed to ioremap mmsys registers: %d\n", ret); return ret; } - platform_set_drvdata(pdev, config_regs); - - data = of_device_get_match_data(&pdev->dev); + mmsys->data = of_device_get_match_data(&pdev->dev); + platform_set_drvdata(pdev, mmsys); - clks = platform_device_register_data(&pdev->dev, data->clk_driver, + clks = platform_device_register_data(&pdev->dev, mmsys->data->clk_driver, PLATFORM_DEVID_AUTO, NULL, 0); if (IS_ERR(clks)) return PTR_ERR(clks); -- 2.30.2