From patchwork Wed May 17 14:46:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 99983 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp267170qge; Wed, 17 May 2017 07:47:20 -0700 (PDT) X-Received: by 10.99.95.88 with SMTP id t85mr4365042pgb.50.1495032440418; Wed, 17 May 2017 07:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495032440; cv=none; d=google.com; s=arc-20160816; b=OsJ3Y5NJESKHnfixAXJNZpNFCFC5MdfYh7iyBUeze6NJCzL8MXvO9JiezyO+5yM9gK BONlHyYwtaIPolApEvvF9gSmeR+7Sn1NNH2mGzgWFN5Xr4L21hMcv6vxsHmfFqvD7HWl kPZaU3kSbIlYu/pxVfK6OZZxx5PfSP4PdTI4mX9UgTQlPVZVAAU1fOboaymLLI42pAHg BrCdCq1wK3pOY/WohufkkGxnF+drQN3pwVc7oDDuASxiTvRsT3jgsaw04eethYcATDso wjGpOALPJ0tDLjo95CSWzv5cqVTxEtnzkKgNYprHGystKgGSM4QxxH9c+MLsgIogYKIx 6WZQ== 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:dkim-signature:arc-authentication-results; bh=7zWEZPpu93+n0wx93U3ummvk7Kyrf9cVDLndhDPIAQE=; b=d/1hIcr+fOrf7lgXmW2W8k9X5ArTHBC+bh1cUMeV13N3ZhRMvtEEaBA2HEXkbBxsQw 6yWTivmVsidIoTIidik9fRbXQe1rHn69kRb+ikENh2XeY1mv9Mr36daLVKgqEPelBztr YKB7BEm5GKyPJXIuPeb9WH9FaimANrvSuSVjH3z6uZLrEQ3UB32O9hLd5Gyurj16/Qdn 8TeBes3qCHKK08kSvtZCOWHd6QjnfCkNLjU1I7cUX+5YiXHjl/8hRYaymrXIvBg3k3hM zkBzUvS+NN1RKkyb45bmOo9V7vpLNbgJs0biO5ykkgbeEqWXcniwOG+cWTYXM+VIBy+Y yNAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y27si2297283pgc.178.2017.05.17.07.47.20; Wed, 17 May 2017 07:47:20 -0700 (PDT) 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; dkim=pass header.i=@linaro.org; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754568AbdEQOq6 (ORCPT + 25 others); Wed, 17 May 2017 10:46:58 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:33164 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753780AbdEQOq4 (ORCPT ); Wed, 17 May 2017 10:46:56 -0400 Received: by mail-pf0-f169.google.com with SMTP id e193so8588684pfh.0 for ; Wed, 17 May 2017 07:46:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7zWEZPpu93+n0wx93U3ummvk7Kyrf9cVDLndhDPIAQE=; b=kxhW6RqUlcqfZP+TgxRvLI5owAdyrnVcTQghiw6zG+FHTOhMdCCZHn7RJXnAByAfDr ZteZ/x+JvRjLhd498kusKRo4szNoGH1XA6+2AZ0JAAFqrBtgSCd9oNTS/s5wsP5vxeoD J8g/0xINdFUERyZmM0kQ62I3RiGUHKGy98L1Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7zWEZPpu93+n0wx93U3ummvk7Kyrf9cVDLndhDPIAQE=; b=uSlyC1kqPCzaAtK4JtIWvcHLqnP5HCDUnzrkse3+LZhPIouiXxYp2Ua+n0gWhnvdEC 1wy9VQuDPYK4CJWb87pvan1cLpo0mAzCW/QYf5zqcl50BOFmpKJyIxSywGG4yuLDgvGT 6aRKv6ofpfdFaLbTEepn7SouXL9pvzGXtcGHlmYWF9Cm0QWQL6KIoIA61MNTE5CYajuw 7nA7VmOnGj+8V8oKsZHksI+12EfDLTeHM8qbw6NLQFrHxNxwOlQsnIK9K6+9h+R0p3Ra u9w45+dZcmsORzwPI18ki718//wRT6RXHNbVjNd0DsWI9qwdbbqRvSVIul7YeFSX85oR z06Q== X-Gm-Message-State: AODbwcD8aZIgydHWE41J+ye6dZmgpyLdVjZC0r0pNDfN1vWzkO8DdtnS nj4vaxp3C7hPK1E9 X-Received: by 10.98.101.6 with SMTP id z6mr4166632pfb.221.1495032415747; Wed, 17 May 2017 07:46:55 -0700 (PDT) Received: from localhost.localdomain (li637-108.members.linode.com. [106.186.117.108]) by smtp.gmail.com with ESMTPSA id v9sm4845037pfa.43.2017.05.17.07.46.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 May 2017 07:46:53 -0700 (PDT) From: Leo Yan To: Wei Xu , Rob Herring , Mark Rutland , Catalin Marinas , Will Deacon , Michael Turquette , Stephen Boyd , Guodong Xu , Zhong Kaihua , Zhangfei Gao , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 1/2] clk: Hi3660: change to register clock with CLK_OF_DECLARE Date: Wed, 17 May 2017 22:46:31 +0800 Message-Id: <1495032392-19102-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1495032392-19102-1-git-send-email-leo.yan@linaro.org> References: <1495032392-19102-1-git-send-email-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The timer will register into system at very early phase at kernel boot; if timer needs to use clock, the clock should be get ready in function of_clk_init() so later the timer driver probe can retrieve clock successfully. This is finished in below flow on arm64: start_kernel() `-> time_init() `-> of_clk_init(NULL) => register timer's clock `-> clocksource_probe() => register timer On Hi3660 the sp804 timer uses clock "osc32k", this clock is registered as platform driver rather than CLK_OF_DECLARE method. As result, sp804 timer probe returns failure due if cannot bind clock properly. To fix the failure, this patch is to change crgctrl clock registration from platform driver to CLK_OF_DECLARE method so the clocks can be registered ahead with function of_clk_init() and then timer driver can use it. In the clock driver clk-hi3660.c, it's pointless to mix clock registration with platform driver mode and CLK_OF_DECLARE mode; this patch changes all clocks registration to CLK_OF_DECLARE mode to make code neat. Signed-off-by: Leo Yan --- drivers/clk/hisilicon/clk-hi3660.c | 48 ++++---------------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) -- 1.9.1 diff --git a/drivers/clk/hisilicon/clk-hi3660.c b/drivers/clk/hisilicon/clk-hi3660.c index fd5ce7f..fc11719 100644 --- a/drivers/clk/hisilicon/clk-hi3660.c +++ b/drivers/clk/hisilicon/clk-hi3660.c @@ -465,6 +465,7 @@ static void hi3660_clk_iomcu_init(struct device_node *np) ARRAY_SIZE(hi3660_iomcu_gate_sep_clks), clk_data); } +CLK_OF_DECLARE(hi3660_clk_iomcu, "hisilicon,hi3660-iomcu", hi3660_clk_iomcu_init); static void hi3660_clk_pmuctrl_init(struct device_node *np) { @@ -478,6 +479,7 @@ static void hi3660_clk_pmuctrl_init(struct device_node *np) hisi_clk_register_gate(hi3660_pmu_gate_clks, ARRAY_SIZE(hi3660_pmu_gate_clks), clk_data); } +CLK_OF_DECLARE(hi3660_clk_pmuctrl, "hisilicon,hi3660-pmuctrl", hi3660_clk_pmuctrl_init); static void hi3660_clk_pctrl_init(struct device_node *np) { @@ -490,6 +492,7 @@ static void hi3660_clk_pctrl_init(struct device_node *np) hisi_clk_register_gate(hi3660_pctrl_gate_clks, ARRAY_SIZE(hi3660_pctrl_gate_clks), clk_data); } +CLK_OF_DECLARE(hi3660_clk_pctrl, "hisilicon,hi3660-pctrl", hi3660_clk_pctrl_init); static void hi3660_clk_sctrl_init(struct device_node *np) { @@ -513,6 +516,7 @@ static void hi3660_clk_sctrl_init(struct device_node *np) ARRAY_SIZE(hi3660_sctrl_divider_clks), clk_data); } +CLK_OF_DECLARE(hi3660_clk_sctrl, "hisilicon,hi3660-sctrl", hi3660_clk_sctrl_init); static void hi3660_clk_crgctrl_init(struct device_node *np) { @@ -547,46 +551,4 @@ static void hi3660_clk_crgctrl_init(struct device_node *np) ARRAY_SIZE(hi3660_crgctrl_divider_clks), clk_data); } - -static const struct of_device_id hi3660_clk_match_table[] = { - { .compatible = "hisilicon,hi3660-crgctrl", - .data = hi3660_clk_crgctrl_init }, - { .compatible = "hisilicon,hi3660-pctrl", - .data = hi3660_clk_pctrl_init }, - { .compatible = "hisilicon,hi3660-pmuctrl", - .data = hi3660_clk_pmuctrl_init }, - { .compatible = "hisilicon,hi3660-sctrl", - .data = hi3660_clk_sctrl_init }, - { .compatible = "hisilicon,hi3660-iomcu", - .data = hi3660_clk_iomcu_init }, - { } -}; - -static int hi3660_clk_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct device_node *np = pdev->dev.of_node; - void (*init_func)(struct device_node *np); - - init_func = of_device_get_match_data(dev); - if (!init_func) - return -ENODEV; - - init_func(np); - - return 0; -} - -static struct platform_driver hi3660_clk_driver = { - .probe = hi3660_clk_probe, - .driver = { - .name = "hi3660-clk", - .of_match_table = hi3660_clk_match_table, - }, -}; - -static int __init hi3660_clk_init(void) -{ - return platform_driver_register(&hi3660_clk_driver); -} -core_initcall(hi3660_clk_init); +CLK_OF_DECLARE(hi3660_clk_crgctrl, "hisilicon,hi3660-crgctrl", hi3660_clk_crgctrl_init);