Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10439007imu; Thu, 6 Dec 2018 00:46:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/VYQNYeoDgXkPhVTFMRT+geXryquR74JsYaBHehdiMRI4AiGZ+i1xntP3DPNF9Ib4xTwYdR X-Received: by 2002:a63:7e5b:: with SMTP id o27mr23175554pgn.214.1544086006936; Thu, 06 Dec 2018 00:46:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544086006; cv=none; d=google.com; s=arc-20160816; b=StgJ2fy+PMtxHOnaEzwRgp2R1XWzBsukbYoC2iMixcXg6hSyX35p4Mi0iLkee+msG6 iD9LhGNOkJ1c9GU8KwOmoNOQ5k4nu0cRLI5BUbmRe5NEQLigc8uIMmJLP5eax6iHF/BI jM5CT7G2Lfy4tWAOFpaIwYVdyxQb1HdVG+t/TJV8GgyU9hS2fhLWUDoIzanCCA69Lq8j c67dXefG7ao4rtIPbjZ/IGUolMz3ULaBC9jkqcLcDoHMnsKMKIrVWcn1xuwZHEi6o9Mo idVaa2JmmGFQPBqA2uO/ZP0bDjqgYwb0uGmcxv9Rne6mqUtYDROdDu3xCtmfkJXuQxlp CgYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=gx+aa+s7+bQZ3sERgq3BhmaD2A9AjOEjH+lTy6I6Y4k=; b=0DcNz5valuOgJi5CBWTVKvjAG9rfyODxBKg61lw2dqRL6uw9qW7edVH4Dc8rsVuxPI ZcYXMG0fr85M21ffyjD7BjTyeF3I0doczO0jcbUA9Ml93rEwdomolkaEnpO8uDZvItT0 XHIYmhxMywrFJGOJg+uN8rpfVuLoZy3duOSEqjhP6aI4Z2JqNTI46f9AuHb6hqa/lNEx d1ZSUj/tDr+sQxBhCuhwRFrPDzz+0UBEv2DBqfeyfXX1bXas+a2QPDqFXI574CNxaFvh NZPZzGRGU7Jpmg0qd2S1ZvUGuzs2DjHi4u051/O5vGOzi0Ve48RPKlz4VTth4UtPjq13 IVmA== 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 a193si22861280pfa.214.2018.12.06.00.46.30; Thu, 06 Dec 2018 00:46:46 -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 S1729132AbeLFIpW (ORCPT + 99 others); Thu, 6 Dec 2018 03:45:22 -0500 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:55954 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727763AbeLFIpW (ORCPT ); Thu, 6 Dec 2018 03:45:22 -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 wB68EgB9028134; Thu, 6 Dec 2018 10:14:43 +0200 Received: by taln60.nuvoton.co.il (Postfix, from userid 20088) id F3BE362DA6; Thu, 6 Dec 2018 10:44:40 +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 , Wei Yongjun Subject: [PATCH v2] clk: npcm7xx: get fixed clocks from DT Date: Thu, 6 Dec 2018 10:44:31 +0200 Message-Id: <20181206084431.315559-1-tali.perry1@gmail.com> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The npcm7xx clock module includes 4 PLLs and then a tree of muxes and dividers. All muxes and dividers are preset before Linux boots. The presetting can change according to the board. Linux drivers need to know what the frequencies are, but they cannot change it, so this whole driver is intended as read only mechanism for clocks. Before this change PLLs input clk value was defined inside the driver. With this fix clock will be on the DT. Signed-off-by: Tali Perry Signed-off-by: Wei Yongjun --- drivers/clk/clk-npcm7xx.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-npcm7xx.c b/drivers/clk/clk-npcm7xx.c index 27a86b7a34db..4bd2e40997d4 100644 --- a/drivers/clk/clk-npcm7xx.c +++ b/drivers/clk/clk-npcm7xx.c @@ -8,13 +8,19 @@ */ #include +#include #include +#include #include #include #include +#include +#include #include +#include #include #include +#include #include #include @@ -544,6 +550,7 @@ 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; @@ -568,6 +575,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 +678,16 @@ 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); 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