Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9876611imu; Wed, 5 Dec 2018 11:50:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/UEIuvBUHNsY3+58I5bQigrqLqKReINIKQeiE3lqCK8QipBUEASsAKb2Jm4JVo3uSKRufSO X-Received: by 2002:a62:4714:: with SMTP id u20mr25393063pfa.144.1544039444597; Wed, 05 Dec 2018 11:50:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544039444; cv=none; d=google.com; s=arc-20160816; b=mskn6vJZQe4Vb+eZUzSBTLdmMoMQSgIrrl2jayzXYaX3/hhHKj1cnwm4L7q4xmuha7 cVj5D/MnlI7vBBgqrxeZWRi9DgbPZYz6sgAVJWsWB3pGrdXoem4kLs4hFycqbzQe11vh LKk8lxFEqQiZk6aUET1bleBeKmCrSSptHD4YJaTzp8UnvzNkp0ePa4F8MjBu6F6rDZM2 lq2+CwIUla4Ryl/mDCjQs8W7vgSs65Q3Q3GqvWLsUIis0S1nrKH6LMraa8Wb/LpzuM5B Zydi2zSz9lJSWCRUM6J9034rvNFXP3qwBMCfiYne7SyK8gWopy7c9vvA95cNu7mVXuzG OiUQ== 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; bh=GojD+KC94ULKa4mLHCamSlIgFIJNqeeelB0FahQHMjg=; b=eUGYN5tpOWANzJ8HYr/fKB1MKijUA602gQYx21fjvWg07EoCThEoRJxNtVyyxa6U2B 31D8gTcCGoqHCaDURGRIub3U2pOHcd6RTcxXmhnv8e/uQhYWbUbdsRuvT7ESWgal8LlD cl4Bqhi1uX5SCekyvaiw9tVNgqp1MMGn/SyC58rWyHOl3zx58LzsH0eTTJ72ZjnBbtE+ KJBpRe2SZnyIBD0GhQJPWiUiVXgsUEvi6SKYaNYjmIl2wfMxj+rTD79UCf27SRYegnpj U6quZf/6Dg5//PsA1IkU5cUkQ+XLZbA+fyWAt64Y3xKtdczCKDLg8+5OBYOvTxJdLjC8 +/2g== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 205si20612427pfa.199.2018.12.05.11.50.29; Wed, 05 Dec 2018 11:50:44 -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; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728701AbeLETsO (ORCPT + 99 others); Wed, 5 Dec 2018 14:48:14 -0500 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:55911 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728653AbeLETru (ORCPT ); Wed, 5 Dec 2018 14:47:50 -0500 Received: from taln60.nuvoton.co.il (ntil-fw [212.199.177.25]) by herzl.nuvoton.co.il (8.13.8/8.13.8) with ESMTP id wB5JHVXm013011; Wed, 5 Dec 2018 21:17:31 +0200 Received: by taln60.nuvoton.co.il (Postfix, from userid 20088) id 5C5F162DA6; Wed, 5 Dec 2018 21:47:29 +0200 (IST) From: Tali Perry To: avifishman70@gmail.com, tmaimon77@gmail.com, venture@google.com, yuenn@google.com, brendanhiggins@google.com, mturquette@baylibre.com, sboyd@kernel.org Cc: openbmc@lists.ozlabs.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Tali Perry Subject: [PATCH v1 1/1] clk: npcm: get fixed input clks from DT Date: Wed, 5 Dec 2018 21:47:02 +0200 Message-Id: <20181205194702.257430-3-tali.perry1@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20181205194702.257430-1-tali.perry1@gmail.com> References: <20181205194702.257430-1-tali.perry1@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --- drivers/clk/clk-npcm7xx.c | 64 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/drivers/clk/clk-npcm7xx.c b/drivers/clk/clk-npcm7xx.c index 27a86b7a34db..25f8ccaa3d2f 100644 --- a/drivers/clk/clk-npcm7xx.c +++ b/drivers/clk/clk-npcm7xx.c @@ -8,17 +8,23 @@ */ #include +#include #include +#include #include #include #include +#include +#include #include +#include #include #include +#include #include - #include + struct npcm7xx_clk_pll { struct clk_hw hw; void __iomem *pllcon; @@ -44,7 +50,8 @@ static unsigned long npcm7xx_clk_pll_recalc_rate(struct clk_hw *hw, u64 ret; if (parent_rate == 0) { - pr_err("%s: parent rate is zero", __func__); + pr_err("%s: parent rate is zero. reg=%s\n", __func__, + hw->init->name); return 0; } @@ -65,9 +72,10 @@ static const struct clk_ops npcm7xx_clk_pll_ops = { .recalc_rate = npcm7xx_clk_pll_recalc_rate, }; -static struct clk_hw * -npcm7xx_clk_register_pll(void __iomem *pllcon, const char *name, - const char *parent_name, unsigned long flags) +static struct clk_hw *npcm7xx_clk_register_pll(void __iomem *pllcon, + const char *name, + const char *parent_name, + unsigned long flags) { struct npcm7xx_clk_pll *pll; struct clk_init_data init; @@ -544,12 +552,14 @@ static void __init npcm7xx_clk_init(struct device_node *clk_np) void __iomem *clk_base; struct resource res; struct clk_hw *hw; + struct clk *clk; int ret; int i; + clk_base = NULL; ret = of_address_to_resource(clk_np, 0, &res); if (ret) { - pr_err("%pOFn: failed to get resource, ret %d\n", clk_np, + pr_err("%s: failed to get resource, ret %d\n", clk_np->name, ret); return; } @@ -558,9 +568,10 @@ static void __init npcm7xx_clk_init(struct device_node *clk_np) if (!clk_base) goto npcm7xx_init_error; - npcm7xx_clk_data = kzalloc(struct_size(npcm7xx_clk_data, hws, - NPCM7XX_NUM_CLOCKS), GFP_KERNEL); - if (!npcm7xx_clk_data) + npcm7xx_clk_data = kzalloc(sizeof(*npcm7xx_clk_data->hws) * + NPCM7XX_NUM_CLOCKS + sizeof(npcm7xx_clk_data), GFP_KERNEL); + + if (!npcm7xx_clk_data->hws) goto npcm7xx_init_np_err; npcm7xx_clk_data->num = NPCM7XX_NUM_CLOCKS; @@ -568,6 +579,31 @@ static void __init npcm7xx_clk_init(struct device_node *clk_np) for (i = 0; i < NPCM7XX_NUM_CLOCKS; i++) npcm7xx_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER); + /* Read fixed clocks. These 3 clocks must be defined in DT */ + clk = of_clk_get_by_name(clk_np, NPCM7XX_CLK_S_REFCLK); + if (IS_ERR(clk)) { + pr_err("failed to find external REFCLK on device tree, err=%ld\n", + PTR_ERR(clk)); + clk_put(clk); + goto npcm7xx_init_fail_no_clk_on_dt; + } + + clk = of_clk_get_by_name(clk_np, NPCM7XX_CLK_S_SYSBYPCK); + if (IS_ERR(clk)) { + pr_err("failed to find external SYSBYPCK on device tree, err=%ld\n", + PTR_ERR(clk)); + clk_put(clk); + goto npcm7xx_init_fail_no_clk_on_dt; + } + + clk = of_clk_get_by_name(clk_np, NPCM7XX_CLK_S_MCBYPCK); + if (IS_ERR(clk)) { + pr_err("failed to find external MCBYPCK on device tree, err=%ld\n", + PTR_ERR(clk)); + clk_put(clk); + goto npcm7xx_init_fail_no_clk_on_dt; + } + /* Register plls */ for (i = 0; i < ARRAY_SIZE(npcm7xx_plls); i++) { const struct npcm7xx_clk_pll_data *pll_data = &npcm7xx_plls[i]; @@ -646,11 +682,17 @@ static void __init npcm7xx_clk_init(struct device_node *clk_np) return; +npcm7xx_init_fail_no_clk_on_dt: + pr_err("see Documentation/devicetree/bindings/clock/"); + pr_err("nuvoton,npcm750-clk.txt for details\n"); npcm7xx_init_fail: - kfree(npcm7xx_clk_data->hws); + if (npcm7xx_clk_data->num) + kfree(npcm7xx_clk_data->hws); npcm7xx_init_np_err: - iounmap(clk_base); + if (clk_base != NULL) + iounmap(clk_base); npcm7xx_init_error: of_node_put(clk_np); + pr_err("clk setup fail\n"); } CLK_OF_DECLARE(npcm7xx_clk_init, "nuvoton,npcm750-clk", npcm7xx_clk_init); -- 2.14.1