From patchwork Thu Mar 26 11:13:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 6097621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3E2FD9F350 for ; Thu, 26 Mar 2015 11:17:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5388E20155 for ; Thu, 26 Mar 2015 11:17:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 77A89200D4 for ; Thu, 26 Mar 2015 11:17:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yb5kc-0007TC-U2; Thu, 26 Mar 2015 11:15:02 +0000 Received: from mail-pd0-f180.google.com ([209.85.192.180]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yb5kC-0007HD-Ad for linux-arm-kernel@lists.infradead.org; Thu, 26 Mar 2015 11:14:37 +0000 Received: by pdbcz9 with SMTP id cz9so59650847pdb.3 for ; Thu, 26 Mar 2015 04:14:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=y0DgOTBsEbTMxdIbn5oScQaEK8oNXrumZCE2tpVjPkE=; b=SU5fkCy/tbFH5ZfJQueOEAd8FZslcJ0E1+f3riJjzmpQctIKLkLqOeEZGAV0s2ZXok 9AjB+Zhee4HQ/rYqkujQ9emCiln0P/YgC80NHhDiZxSkcvIqBXjFOrURV+U0QaAplNO7 SwIvVqS/DAzIVl+ugeaSLDWS4LRi147TcOFFTczj1fdAtl4jm9WP2+GU/gnREJ/4Pzbw 7AznM9N8x+lKjwBuvVH40CFvvCyPKZv1rFKbfJjNpdO0yev7WI88fOw5dhFbmQi2+o50 8K6RlCmF0aVGCHj1MRc15eMsLQmTk54aJcbg6JWjwkLdIM86y5xRZ046pGMkmGVJ0ycd aqUA== X-Gm-Message-State: ALoCoQkda66PG3zkJeUm/I3+AD+ZBlXQB4j4xZv6RO3g09I88U0VvYzwIoda3p5g2u8zXSEn0E7R X-Received: by 10.70.89.195 with SMTP id bq3mr25912773pdb.138.1427368455049; Thu, 26 Mar 2015 04:14:15 -0700 (PDT) Received: from localhost.localdomain ([211.79.119.21]) by mx.google.com with ESMTPSA id wg9sm1875069pab.17.2015.03.26.04.14.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Mar 2015 04:14:14 -0700 (PDT) From: Leo Yan To: Wei Xu , Dan Zhao , zhenwei.wang@hisilicon.com, Haojian Zhuang , Bintian Wang , mturquette@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCH 1/4] clk: hisi: add API for allocation clk data struct Date: Thu, 26 Mar 2015 19:13:36 +0800 Message-Id: <1427368419-22222-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427368419-22222-1-git-send-email-leo.yan@linaro.org> References: <1427368419-22222-1-git-send-email-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150326_041436_427376_0E22A6FE X-CRM114-Status: GOOD ( 12.90 ) X-Spam-Score: -0.7 (/) Cc: Leo Yan X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the old clk init function, it will read the register base address from dts and allocate the clk data structures. But for the some cases, the clock driver don't need init the reg's base address, which will directly access mmio region with syscon. So for clock's initialization, this patch adds one more API which is only for allocating clock data structure. Signed-off-by: Leo Yan --- drivers/clk/hisilicon/clk.c | 42 +++++++++++++++++++++++++++--------------- drivers/clk/hisilicon/clk.h | 2 ++ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/drivers/clk/hisilicon/clk.c b/drivers/clk/hisilicon/clk.c index a078e84..1e4c5c6 100644 --- a/drivers/clk/hisilicon/clk.c +++ b/drivers/clk/hisilicon/clk.c @@ -38,30 +38,17 @@ static DEFINE_SPINLOCK(hisi_clk_lock); -struct hisi_clock_data __init *hisi_clk_init(struct device_node *np, - int nr_clks) +struct hisi_clock_data __init *hisi_clk_alloc_data(struct device_node *np, + int nr_clks) { struct hisi_clock_data *clk_data; struct clk **clk_table; - void __iomem *base; - - if (np) { - base = of_iomap(np, 0); - if (!base) { - pr_err("failed to map Hisilicon clock registers\n"); - goto err; - } - } else { - pr_err("failed to find Hisilicon clock node in DTS\n"); - goto err; - } clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); if (!clk_data) { pr_err("%s: could not allocate clock data\n", __func__); goto err; } - clk_data->base = base; clk_table = kzalloc(sizeof(struct clk *) * nr_clks, GFP_KERNEL); if (!clk_table) { @@ -72,12 +59,37 @@ struct hisi_clock_data __init *hisi_clk_init(struct device_node *np, clk_data->clk_data.clk_num = nr_clks; of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data->clk_data); return clk_data; + err_data: kfree(clk_data); err: return NULL; } +struct hisi_clock_data __init *hisi_clk_init(struct device_node *np, + int nr_clks) +{ + struct hisi_clock_data *clk_data; + void __iomem *base; + + if (np) { + base = of_iomap(np, 0); + if (!base) { + pr_err("failed to map Hisilicon clock registers\n"); + return NULL; + } + printk("%s: base %p\n", __func__, base); + } else { + pr_err("failed to find Hisilicon clock node in DTS\n"); + return NULL; + } + + clk_data = hisi_clk_alloc_data(np, nr_clks); + if (clk_data) + clk_data->base = base; + return clk_data; +} + void __init hisi_clk_register_fixed_rate(struct hisi_fixed_rate_clock *clks, int nums, struct hisi_clock_data *data) { diff --git a/drivers/clk/hisilicon/clk.h b/drivers/clk/hisilicon/clk.h index 31083ff..624f608 100644 --- a/drivers/clk/hisilicon/clk.h +++ b/drivers/clk/hisilicon/clk.h @@ -96,6 +96,8 @@ struct clk *hisi_register_clkgate_sep(struct device *, const char *, u8, spinlock_t *); struct hisi_clock_data __init *hisi_clk_init(struct device_node *, int); +struct hisi_clock_data __init *hisi_clk_alloc_data(struct device_node *np, + int nr_clks); void __init hisi_clk_register_fixed_rate(struct hisi_fixed_rate_clock *, int, struct hisi_clock_data *); void __init hisi_clk_register_fixed_factor(struct hisi_fixed_factor_clock *,