From patchwork Mon Feb 12 14:58:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 128128 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3288646ljc; Mon, 12 Feb 2018 07:00:16 -0800 (PST) X-Google-Smtp-Source: AH8x225IGyHGBzJrBP4i7E81QnUdyONP+ont5xTycb9nssA8/lZ2NwzA9r+fcV8LcFIzrNH4c0zx X-Received: by 2002:a17:902:8c8b:: with SMTP id t11-v6mr10812691plo.286.1518447616472; Mon, 12 Feb 2018 07:00:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518447616; cv=none; d=google.com; s=arc-20160816; b=e3sjykyo6Wc8K41vdc8iBcXgNLgWnml758SFiysWeoUB2TyZVa2jWOrkxcS0x0IlL+ XMOGrdyAPXuZOBLCipjqlOcxHT5KTSc4BrNAh+BGMSHIgf8ig6xtGDfub8Pk6xvFLweM NjbVxJdSGCo5RQtgG+SbqA/05N0oIGQis7lUkNSvYL8kNKJ8TkJ8IJCAVJN3mQijom38 RQ+/MjIsJCm7+2oa977FoGt9+S45eGcLszQewPZ6bB0Gh90Jdf538BkyW3wWaSE8imdf OIEK0lm6rgbdrep/vpbImlRP6sxMXNd0awLIIlDLT+WCVjhG0WRmJJiUihb4vLEWi9ou NrOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=czfjz1cEeXzagYpP/Xjtu3F6L2NWT8eXpRLEDzi8qMc=; b=iJ229qyx0ZK5qayHseu8DEiATETARlSuaM3g+VDL00kTTwwBev0AObNFveszuN4oMO KvfBNPWfLbNBbeaT73kBAEJNuO3U94lM++osA1csQKQluQSiCujGZaunv8gJcZStsXl0 HSc1thfuin9DOn+z6Ibf4mFFNlW1MqLOYtJ7wP5Q1dS5eC0hOfpcz45LtOspxNR9v09R aQLlvBa8HJzVkAwMjbTGRFFtOPKaeJc1PpqECbZvE2sF0ktenSNZ1fpBIlQ+KtCv+Bgz EH8SMT2ZgsahlIJP1c7xEBg7v55fo6gfN9mMhzYFHVsQ1cDy7w8VGLqf88rsYGM0eeZT tHXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=SWEfFn02; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj2-v6si3782431plb.404.2018.02.12.07.00.16; Mon, 12 Feb 2018 07:00:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=SWEfFn02; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751487AbeBLPAM (ORCPT + 15 others); Mon, 12 Feb 2018 10:00:12 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:54390 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932680AbeBLO7N (ORCPT ); Mon, 12 Feb 2018 09:59:13 -0500 Received: by mail-wm0-f65.google.com with SMTP id i186so10096580wmi.4 for ; Mon, 12 Feb 2018 06:59:12 -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=czfjz1cEeXzagYpP/Xjtu3F6L2NWT8eXpRLEDzi8qMc=; b=SWEfFn02sWx0BwGUCjlzOY8qwc4ld0j7Wlq9A15QM4tupujCfGgy8ceWAH8NEXlM8e Hh+pkwkValcqJgB9CG4ac/wPsEh+Xj3B6Cbp8f9iY1NslYd6bJyB3+fImjXVjDEVWQcL QX71h6cz7MHsQA42UKGrDDmb1sJ+aT+H1rhi5PrBhg/kqdFEi5VGvPCAr5KbAry7Pwax l4/mBM/zCUX+ouNMBJRwrhX68XSw9HzRLwT4tHrwyqtWl7Mz/AVrBAjg2UtFNJ3tucvm LOtgBDd4/BaMGv8B11hR9kMftb74qgrvHs+D2spx/xSpFhi65qUuRnEemjLkqHBkHo7i e4hQ== 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=czfjz1cEeXzagYpP/Xjtu3F6L2NWT8eXpRLEDzi8qMc=; b=ZsXdu7YEowEfFypnboRjxg2l7SiGQbW8xa38JqtwsvoEr3saEmAO3gvN8yXJsIM40h EwiGDm7uNuCl1U2GnMLz+ixdjFPB1AFQzSIxi2VFFI3WVJYl9+/zMMrbRnSgVWFHPi2Z ljOaf3ksH7rIipIM/v+cz63N0Di1GfSKRj3b6l60KuZrwEAQo6Sq2QklDWx4qg1Ebef6 32puXytSHpHfrcGASf9JO+IAOIwTMGG1YdwvsEN3rYm9s8Cxl3u90SFCFZRaTXyRIOEp mFUNxPYiNweg9FZlDc2BEQc5IfG8/e6+Mjorz4nwfwDbqMXUpspaADrvqMlwB5Vp6kXd heKw== X-Gm-Message-State: APf1xPDW4NtK4ZT8iB5zx/qIzc5JUKU6w/I0EOjnQFRFVtDPBWXo2w04 6CVjEP6FgyPffnYEkzG7yIUkdQ== X-Received: by 10.28.118.15 with SMTP id r15mr4237773wmc.88.1518447551737; Mon, 12 Feb 2018 06:59:11 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id p21sm4633218wmc.28.2018.02.12.06.59.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 06:59:11 -0800 (PST) From: Jerome Brunet To: Neil Armstrong , Kevin Hilman Cc: Jerome Brunet , Stephen Boyd , Michael Turquette , Carlo Caione , linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 19/19] clk: meson: use hhi syscon if available Date: Mon, 12 Feb 2018 15:58:46 +0100 Message-Id: <20180212145846.19380-20-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On gxbb and axg, try to get the hhi regmap from the parent DT node, which should be the HHI system controller once the necessary changes have been made in amlogic's DTs Until then, if getting regmap through the system controller fails, the clock controller will fall back to the old way, requesting memory region directly and then registering the regmap itself. This should allow a smooth transition to syscon Signed-off-by: Jerome Brunet --- drivers/clk/meson/Kconfig | 2 ++ drivers/clk/meson/axg.c | 43 ++++++++++++++++++++++++++++++------------- drivers/clk/meson/gxbb.c | 39 ++++++++++++++++++++++++++++----------- 3 files changed, 60 insertions(+), 24 deletions(-) -- 2.14.3 diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig index 936afddae406..d5cbec522aec 100644 --- a/drivers/clk/meson/Kconfig +++ b/drivers/clk/meson/Kconfig @@ -22,6 +22,7 @@ config COMMON_CLK_GXBB depends on COMMON_CLK_AMLOGIC select RESET_CONTROLLER select COMMON_CLK_REGMAP_MESON + select MFD_SYSCON help Support for the clock controller on AmLogic S905 devices, aka gxbb. Say Y if you want peripherals and CPU frequency scaling to work. @@ -31,6 +32,7 @@ config COMMON_CLK_AXG depends on COMMON_CLK_AMLOGIC select RESET_CONTROLLER select COMMON_CLK_REGMAP_MESON + select MFD_SYSCON 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 6813b632c1a9..acb63c8e0fd8 100644 --- a/drivers/clk/meson/axg.c +++ b/drivers/clk/meson/axg.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -850,25 +851,41 @@ static int axg_clkc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res; - void __iomem *clk_base; + void __iomem *clk_base = NULL; struct regmap *map; int ret, i; - /* Generic clocks and PLLs */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -EINVAL; + /* Get the hhi system controller node if available */ + map = syscon_node_to_regmap(of_get_parent(dev->of_node)); + if (IS_ERR(map)) { + dev_err(dev, + "failed to get HHI regmap - Trying obsolete regs\n"); + + /* + * FIXME: HHI registers should be accessed through + * the appropriate system controller. This is required because + * there is more than just clocks in this register space + * + * This fallback method is only provided temporarily until + * all the platform DTs are properly using the syscon node + */ + 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; + } - 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); } - map = devm_regmap_init_mmio(dev, clk_base, &clkc_regmap_config); - if (IS_ERR(map)) - return PTR_ERR(map); - /* Populate regmap for the regmap backed clocks */ for (i = 0; i < ARRAY_SIZE(axg_clk_regmaps); i++) axg_clk_regmaps[i]->map = map; diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c index 5ab8338eb894..bb0b0529ca81 100644 --- a/drivers/clk/meson/gxbb.c +++ b/drivers/clk/meson/gxbb.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -2045,19 +2046,35 @@ static int gxbb_clkc_probe(struct platform_device *pdev) if (!clkc_data) return -EINVAL; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -EINVAL; + /* Get the hhi system controller node if available */ + map = syscon_node_to_regmap(of_get_parent(dev->of_node)); + if (IS_ERR(map)) { + dev_err(dev, + "failed to get HHI regmap - Trying obsolete regs\n"); - 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; - } + /* + * FIXME: HHI registers should be accessed through + * the appropriate system controller. This is required because + * there is more than just clocks in this register space + * + * This fallback method is only provided temporarily until + * all the platform DTs are properly using the syscon node + */ + 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); + map = devm_regmap_init_mmio(dev, clk_base, + &clkc_regmap_config); + if (IS_ERR(map)) + return PTR_ERR(map); + } /* Populate regmap for the common regmap backed clocks */ for (i = 0; i < ARRAY_SIZE(gx_clk_regmaps); i++)