From patchwork Mon Feb 12 14:58:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10213217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E6B1560329 for ; Mon, 12 Feb 2018 15:02:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D89C128786 for ; Mon, 12 Feb 2018 15:02:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD722287AA; Mon, 12 Feb 2018 15:02:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BF46428786 for ; Mon, 12 Feb 2018 15:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uMB0YFqepoGCChIPMHt0HXkVrg2ZvFzNHLJClp/6kb0=; b=XaLlcF5bWhlXKMXzRas74BYCF1 7Nn2XBDRFkmTnWbu8o5u5K11sh513rjdRELc3i0vEli9ehDm48inwO3NWxbNExxFVDh5iDmbMX31g Ada6cnwa6zGSIt+5ytgWtVwTJ3MoATaqzTEEL/y5eOcr94VkMHA0lzuBfRusYXmOX03uuipM/F3lA n+yBW8YegiKCrHwBri42RqRnXx0u4kSHpCIRGLMBTG73ojnG6uTtiqbZqKST6C3MinHmxdy8b5N6D pwhQrCYduNDV0rPk4fJcbKr0sahSF8GMIV/GT3IgAvaT0sAsJrsiSEx004SE25UfNZXivJCCRDxW8 ijQ5uJ0g==; Received: from [198.137.202.133] (helo=bombadil.infradead.org) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1elFct-0003Tk-49 for patchwork-linux-amlogic@patchwork.kernel.org; Mon, 12 Feb 2018 15:02:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=uMB0YFqepoGCChIPMHt0HXkVrg2ZvFzNHLJClp/6kb0=; b=IzjYWULNgHgFpS8df5hkE+8dXL fsPO2vrTv7yfwiqK5JLXIUFch9t119zJb/29bnmvBnS2Sp+1ntDJcDPYml4cWoIzJiQ5OaACd+cLJ OAH5jPFthSg26AzMhb6oFf6I+TxUSKjjl/oK0oAPxkdWGZKc83Pd7j9porjBVFGp34FuIcRhzGKT9 rIpRFuzmOt/uhimLAjLz3LFtqNews28GgGyS1DrOAHfSKT15yN8IjZxOJUDzbvR4kj3ZOp1Y4axgG MGoZyHqCUwUTaA/MeRvE6kJwQ2/bv9thrqxc52Q4g4ZvEc/OSVgZAKAGSVyDWq2aETHqBQ+E37EoZ finSbpWA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1elFa1-0001wF-Ae; Mon, 12 Feb 2018 14:59:41 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1elFZW-0000gT-Cs for linux-amlogic@lists.infradead.org; Mon, 12 Feb 2018 14:59:14 +0000 Received: by mail-wr0-x243.google.com with SMTP id h9so15499895wre.12 for ; Mon, 12 Feb 2018 06:59:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1wUMCY+kedNfElCuZfI9lQUkyD2Z2xVbBtYM+bsQBVg=; b=OxZZxhVXOZGoCbXUrDAVTGLbGSX1aSBNhXkXBWrfZTqmFoW0A6F2GS3blo5N7v6TUz 04kR36MCZr9Y+31cnxWkVebcXg1KSBniblV3yC0EEKJVVEEnl0B8H7rVq6zIdzjYm5JN CahV9M3+BrwBaMGlm+MgzqQjarXd6wz2NaODw3SWnFlLofKG/00/eDrZ5r5BEFEPqMYN 3pGtdRGx+f+BRtMDha7JgeUxBs/nDpN3e6u/F8s3a7856+zfqt5Oz9g2reTtdVll41wG MGHVEa9sSBYXTCy4K8HXFrplbP2lIrd7Oy+QqABlaq5dWbg+FJmqi9iHhnkX5iVI+OTa Uwjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1wUMCY+kedNfElCuZfI9lQUkyD2Z2xVbBtYM+bsQBVg=; b=Ml+8gFn4NEXZW919sN+yHjGN0POTNODEgSAwwNYi2ZcXStock/0EYhr73Qk5LQ7Owx uP89kjgCjZSPlHBo5Hbk541gNBQ/U45nPC772nn2VupHhLgzYCmFNFQG9gcSeC1++UjS n6QeL90UarPOuAecbF8e+7KJWpxqurgZTUTEj9/vhKc5h4xpCHWOBhH9NehzdMq6Yx6n KCXVWTfetXrLqUPMeSr+DOuEVJAWQJX9KESxeUFHJXZbn1NiyxltK28ID1KJlKDDMSI9 clC/h1EIEVtS98g3Ph/WbvO5u/xRXIzjOnDS9MHYzKvsvWfMrg9vlIRBhIlBSAYhqMUI JeNQ== X-Gm-Message-State: APf1xPDJJw8CstG7L3Ak5tR26NfBK6pSIOAsva2dincB0jROWTkNkX29 NyQUCqy+o2fGqv+SNSSZmYKcVg== X-Google-Smtp-Source: AH8x2276irC6PecncSiqAhKsf1tBtVv9tUyuG9qvRDBuqvsu1rIJf7eF/LetYMErwspygyf3SdJCMw== X-Received: by 10.223.134.237 with SMTP id 42mr10950425wry.283.1518447538899; Mon, 12 Feb 2018 06:58:58 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id p21sm4633218wmc.28.2018.02.12.06.58.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 06:58:58 -0800 (PST) From: Jerome Brunet To: Neil Armstrong , Kevin Hilman Subject: [PATCH v2 08/19] clk: meson: add regmap to the clock controllers Date: Mon, 12 Feb 2018 15:58:35 +0100 Message-Id: <20180212145846.19380-9-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212145846.19380-1-jbrunet@baylibre.com> References: <20180212145846.19380-1-jbrunet@baylibre.com> X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, Carlo Caione , linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This change registers a regmap in meson8b, gxbb and axg controllers. The clock are still accessing their registers directly through iomem. Once all clocks handled by these controllers have been move to regmap, the regmap register will be removed and replaced with a syscon request. This is needed because other drivers, such as the HDMI driver, need to access the HHI register region Acked-by: Martin Blumenstingl Signed-off-by: Jerome Brunet --- drivers/clk/meson/Kconfig | 2 ++ drivers/clk/meson/axg.c | 15 ++++++++++++++- drivers/clk/meson/gxbb.c | 33 +++++++++++++++++++++++---------- drivers/clk/meson/meson8b.c | 14 +++++++++++++- 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig index 33d148e19066..9735335b17a9 100644 --- a/drivers/clk/meson/Kconfig +++ b/drivers/clk/meson/Kconfig @@ -11,6 +11,7 @@ config COMMON_CLK_MESON8B bool depends on COMMON_CLK_AMLOGIC select RESET_CONTROLLER + select REGMAP help Support for the clock controller on AmLogic S802 (Meson8), S805 (Meson8b) and S812 (Meson8m2) devices. Say Y if you @@ -29,6 +30,7 @@ config COMMON_CLK_AXG bool depends on COMMON_CLK_AMLOGIC select RESET_CONTROLLER + select REGMAP help Support for the clock controller on AmLogic A113D devices, aka axg. Say Y if you want peripherals and CPU frequency scaling to work. diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c index bc5c29f13282..aed0f9e64f71 100644 --- a/drivers/clk/meson/axg.c +++ b/drivers/clk/meson/axg.c @@ -11,10 +11,11 @@ #include #include +#include #include #include #include -#include +#include #include "clkc.h" #include "axg.h" @@ -791,12 +792,19 @@ static const struct of_device_id clkc_match_table[] = { {} }; +static const struct regmap_config clkc_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + static int axg_clkc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; const struct clkc_data *clkc_data; struct resource *res; void __iomem *clk_base; + struct regmap *map; int ret, i; clkc_data = of_device_get_match_data(dev); @@ -807,12 +815,17 @@ static int axg_clkc_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -EINVAL; + clk_base = devm_ioremap(dev, res->start, resource_size(res)); if (!clk_base) { dev_err(dev, "Unable to map clk base\n"); return -ENXIO; } + map = devm_regmap_init_mmio(dev, clk_base, &clkc_regmap_config); + if (IS_ERR(map)) + return PTR_ERR(map); + /* Populate base address for PLLs */ for (i = 0; i < clkc_data->clk_plls_count; i++) clkc_data->clk_plls[i]->base = clk_base; diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c index 6609024eee00..e3faf0a0fdb7 100644 --- a/drivers/clk/meson/gxbb.c +++ b/drivers/clk/meson/gxbb.c @@ -19,10 +19,11 @@ #include #include +#include #include #include #include -#include +#include #include "clkc.h" #include "gxbb.h" @@ -1937,10 +1938,18 @@ static const struct of_device_id clkc_match_table[] = { {}, }; +static const struct regmap_config clkc_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + static int gxbb_clkc_probe(struct platform_device *pdev) { const struct clkc_data *clkc_data; + struct resource *res; void __iomem *clk_base; + struct regmap *map; int ret, i; struct device *dev = &pdev->dev; @@ -1948,13 +1957,20 @@ static int gxbb_clkc_probe(struct platform_device *pdev) if (!clkc_data) return -EINVAL; - /* Generic clocks and PLLs */ - clk_base = of_iomap(dev->of_node, 0); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; + + clk_base = devm_ioremap(dev, res->start, resource_size(res)); if (!clk_base) { pr_err("%s: Unable to map clk base\n", __func__); return -ENXIO; } + map = devm_regmap_init_mmio(dev, clk_base, &clkc_regmap_config); + if (IS_ERR(map)) + return PTR_ERR(map); + /* Populate base address for PLLs */ for (i = 0; i < clkc_data->clk_plls_count; i++) clkc_data->clk_plls[i]->base = clk_base; @@ -1991,17 +2007,14 @@ static int gxbb_clkc_probe(struct platform_device *pdev) ret = devm_clk_hw_register(dev, clkc_data->hw_onecell_data->hws[i]); - if (ret) - goto iounmap; + if (ret) { + dev_err(dev, "Clock registration failed\n"); + return ret; + } } - return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clkc_data->hw_onecell_data); - -iounmap: - iounmap(clk_base); - return ret; } static struct platform_driver gxbb_driver = { diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c index db017c29a84c..0981e970de3d 100644 --- a/drivers/clk/meson/meson8b.c +++ b/drivers/clk/meson/meson8b.c @@ -23,11 +23,12 @@ #include #include +#include #include #include #include #include -#include +#include #include "clkc.h" #include "meson8b.h" @@ -804,16 +805,27 @@ static const struct reset_control_ops meson8b_clk_reset_ops = { .deassert = meson8b_clk_reset_deassert, }; +static const struct regmap_config clkc_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + static int meson8b_clkc_probe(struct platform_device *pdev) { int ret, i; struct clk_hw *parent_hw; struct clk *parent_clk; struct device *dev = &pdev->dev; + struct regmap *map; if (!clk_base) return -ENXIO; + map = devm_regmap_init_mmio(dev, clk_base, &clkc_regmap_config); + if (IS_ERR(map)) + return PTR_ERR(map); + /* Populate base address for PLLs */ for (i = 0; i < ARRAY_SIZE(meson8b_clk_plls); i++) meson8b_clk_plls[i]->base = clk_base;