From patchwork Fri Dec 6 07:40:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jian Hu X-Patchwork-Id: 11275681 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9311A14BD for ; Fri, 6 Dec 2019 07:41:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 762012467B for ; Fri, 6 Dec 2019 07:41:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726665AbfLFHlO (ORCPT ); Fri, 6 Dec 2019 02:41:14 -0500 Received: from mail-sz.amlogic.com ([211.162.65.117]:26913 "EHLO mail-sz.amlogic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726483AbfLFHlO (ORCPT ); Fri, 6 Dec 2019 02:41:14 -0500 Received: from droid15-sz.amlogic.com (10.28.8.25) by mail-sz.amlogic.com (10.28.11.5) with Microsoft SMTP Server id 15.1.1591.10; Fri, 6 Dec 2019 15:41:36 +0800 From: Jian Hu To: Jerome Brunet , Neil Armstrong CC: Jian Hu , Kevin Hilman , Rob Herring , Martin Blumenstingl , Michael Turquette , Stephen Boyd , Qiufang Dai , Jianxin Pan , Victor Wan , Chandle Zou , , , , Subject: [PATCH v4 3/6] clk: meson: eeclk: refactor eeclk common driver to support A1 Date: Fri, 6 Dec 2019 15:40:49 +0800 Message-ID: <20191206074052.15557-4-jian.hu@amlogic.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206074052.15557-1-jian.hu@amlogic.com> References: <20191206074052.15557-1-jian.hu@amlogic.com> MIME-Version: 1.0 X-Originating-IP: [10.28.8.25] Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org Introduce a common probe function for A1 series, the way to get regmap is different between A1 series and the previous series. The register region is only for one clock driver, the function of meson_eeclkc_probe is not fit for A1, So it is necessary to introduce a new function. Signed-off-by: Jian Hu --- drivers/clk/meson/meson-eeclk.c | 59 +++++++++++++++++++++++++++------ drivers/clk/meson/meson-eeclk.h | 1 + 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/drivers/clk/meson/meson-eeclk.c b/drivers/clk/meson/meson-eeclk.c index a7cb1e7aedc4..12ceb1caabd8 100644 --- a/drivers/clk/meson/meson-eeclk.c +++ b/drivers/clk/meson/meson-eeclk.c @@ -13,25 +13,37 @@ #include "clk-regmap.h" #include "meson-eeclk.h" -int meson_eeclkc_probe(struct platform_device *pdev) +static struct regmap_config clkc_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + +static struct regmap *meson_regmap_resource(struct platform_device *pdev) +{ + struct resource *res; + void __iomem *base; + struct device *dev = &pdev->dev; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + base = devm_ioremap_resource(dev, res); + if (IS_ERR(base)) + return ERR_CAST(base); + + return devm_regmap_init_mmio(dev, base, &clkc_regmap_config); +} + +static int meson_common_probe(struct platform_device *pdev, struct regmap *map) { const struct meson_eeclkc_data *data; struct device *dev = &pdev->dev; - struct regmap *map; int ret, i; data = of_device_get_match_data(dev); if (!data) return -EINVAL; - /* Get the hhi system controller node */ - map = syscon_node_to_regmap(of_get_parent(dev->of_node)); - if (IS_ERR(map)) { - dev_err(dev, - "failed to get HHI regmap\n"); - return PTR_ERR(map); - } - if (data->init_count) regmap_multi_reg_write(map, data->init_regs, data->init_count); @@ -54,3 +66,30 @@ int meson_eeclkc_probe(struct platform_device *pdev) return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, data->hw_onecell_data); } + +int meson_eeclkc_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct regmap *map; + + /* Get the hhi system controller node */ + map = syscon_node_to_regmap(of_get_parent(dev->of_node)); + if (IS_ERR(map)) { + dev_err(dev, + "failed to get HHI regmap\n"); + return PTR_ERR(map); + } + + return meson_common_probe(pdev, map); +} + +int meson_clkc_probe(struct platform_device *pdev) +{ + struct regmap *map; + + map = meson_regmap_resource(pdev); + if (IS_ERR(map)) + return PTR_ERR(map); + + return meson_common_probe(pdev, map); +} diff --git a/drivers/clk/meson/meson-eeclk.h b/drivers/clk/meson/meson-eeclk.h index 77316207bde1..a2e9ab3a4f6b 100644 --- a/drivers/clk/meson/meson-eeclk.h +++ b/drivers/clk/meson/meson-eeclk.h @@ -21,5 +21,6 @@ struct meson_eeclkc_data { }; int meson_eeclkc_probe(struct platform_device *pdev); +int meson_clkc_probe(struct platform_device *pdev); #endif /* __MESON_CLKC_H */