From patchwork Mon Mar 30 05:24:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 6118501 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 09A159F2EC for ; Mon, 30 Mar 2015 05:28:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C29A203A0 for ; Mon, 30 Mar 2015 05:28:30 +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 E64AF20374 for ; Mon, 30 Mar 2015 05:28:28 +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 1YcSCr-000081-99; Mon, 30 Mar 2015 05:25:49 +0000 Received: from mail-yh0-f43.google.com ([209.85.213.43]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YcSCN-0007I5-JE for linux-arm-kernel@lists.infradead.org; Mon, 30 Mar 2015 05:25:20 +0000 Received: by yhch68 with SMTP id h68so54579521yhc.1 for ; Sun, 29 Mar 2015 22:24:57 -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=6lXoTwk+PYNayBJwwpq4xzQUIQAqa2TBTK52MpZMm9w=; b=K9/2sXoJMrlQl504DU7WvasMHKP8UCX0515rOfDGoCOZTabFECvHqsmg+LmXcBof5I BLSeB7iXy0My2TsQ6vpm52Oz0HEa9aZ3XO5FkJ8FJbDB2K7Gx/JoRfscQ7z0CveGgIM1 8JFKBLPI4xofSpWRwiL4OZlQFCiXwkiMF/+7UVWRrEjnIqEyTblrx/fagTuEz6SCG1Xb 9INGbRRRqvwtBijnefuvZYwGoo5h+msuyPyrEYs/EwYpXzgN2MWD59XqDbk3ATXg61v/ sT+kty1BoLT0jDX+Ppa9xI0mK44uxZ6QOvjnek59KRYNuqzWGEDEZEgKfUXV+5oXw/eA K8lw== X-Gm-Message-State: ALoCoQnejt7T2sFoEzAivG8/c0x2SF5gvDPv0GwfuScBzN902ZREccxW0IRchhlWPMIxy+JMFY4y X-Received: by 10.170.149.194 with SMTP id q185mr36314195ykc.90.1427693097299; Sun, 29 Mar 2015 22:24:57 -0700 (PDT) Received: from localhost.localdomain ([104.207.83.1]) by mx.google.com with ESMTPSA id g46sm9852584yhd.42.2015.03.29.22.24.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 29 Mar 2015 22:24:56 -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 v2 2/5] clk: hisi: add API for allocation clk data struct Date: Mon, 30 Mar 2015 13:24:21 +0800 Message-Id: <1427693064-11062-3-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427693064-11062-1-git-send-email-leo.yan@linaro.org> References: <1427693064-11062-1-git-send-email-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150329_222519_756811_387A8A40 X-CRM114-Status: GOOD ( 13.21 ) 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 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 | 30 +++++++++++++++++++++++------- drivers/clk/hisilicon/clk.h | 2 ++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/clk/hisilicon/clk.c b/drivers/clk/hisilicon/clk.c index 1951b37..87f8173 100644 --- a/drivers/clk/hisilicon/clk.c +++ b/drivers/clk/hisilicon/clk.c @@ -38,16 +38,14 @@ 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; - base = of_iomap(np, 0); - if (!base) { - pr_err("%s: failed to map clock registers\n", __func__); + if (!np) { + pr_err("%s: invalid device node handler\n", __func__); goto err; } @@ -56,7 +54,6 @@ struct hisi_clock_data __init *hisi_clk_init(struct device_node *np, 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) { @@ -67,12 +64,31 @@ 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; + + base = of_iomap(np, 0); + if (!base) { + pr_err("%s: failed to map clock registers\n", __func__); + 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 *,