From patchwork Tue Jul 1 16:32:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 32908 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A44F920672 for ; Tue, 1 Jul 2014 16:33:55 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id rp18sf1543748iec.9 for ; Tue, 01 Jul 2014 09:33:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=LC78lytIfrmfKJywkmKBXoMB0APHm9lEpw2he/DQRiY=; b=gwT4NfySJJ+qjqF3P9JoHNzy+42XXVd41aBAiajpqaJLtcAUbi1m3SZ9hZCFJDk2vg YwoMbGHJHkZdMzV5TZb2LAdvJ1lVL1xugSAH+FfJPNZuN9s/uxffoG5Ez74dsRSHVltR CO4tB/Gr/XH6Zs6uGQDPAXEGk3PNFahkblmKCyg30suYzH8VcGM+lhBpAv3xd4lBv1SU fAoyuoPcvWcD6e/MELzotbrXbG4updZ5o2k9jk5ELlF+J4bDxRaG8lq0Ds7cgWeU+dpX Ev/AsKNaWuLXsYaXeheg0Rz9kHo900qxokIGZKiE8WUm47+w5/ZnW4058KjaHT0rTkGl 7OKg== X-Gm-Message-State: ALoCoQmpiV8+K9XLiSbk2E599x2MQxDL5PWJ8HglrU1PGiUtbo9M1cdoFfv3QHwecoATwgyP2IVx X-Received: by 10.182.20.17 with SMTP id j17mr27137805obe.24.1404232434843; Tue, 01 Jul 2014 09:33:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.30.165 with SMTP id d34ls2142435qgd.25.gmail; Tue, 01 Jul 2014 09:33:54 -0700 (PDT) X-Received: by 10.220.182.5 with SMTP id ca5mr1545753vcb.50.1404232434712; Tue, 01 Jul 2014 09:33:54 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id uk3si11631578vec.102.2014.07.01.09.33.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 01 Jul 2014 09:33:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.172 as permitted sender) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id jz11so9910629veb.17 for ; Tue, 01 Jul 2014 09:33:54 -0700 (PDT) X-Received: by 10.53.12.229 with SMTP id et5mr37427937vdd.32.1404232434578; Tue, 01 Jul 2014 09:33:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp228286vcb; Tue, 1 Jul 2014 09:33:54 -0700 (PDT) X-Received: by 10.66.186.238 with SMTP id fn14mr1790502pac.135.1404232433789; Tue, 01 Jul 2014 09:33:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nt4si27551386pbc.39.2014.07.01.09.33.53; Tue, 01 Jul 2014 09:33:53 -0700 (PDT) Received-SPF: none (google.com: linux-arm-msm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755330AbaGAQdq (ORCPT + 3 others); Tue, 1 Jul 2014 12:33:46 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:65022 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758305AbaGAQdo (ORCPT ); Tue, 1 Jul 2014 12:33:44 -0400 Received: by mail-pa0-f41.google.com with SMTP id fb1so10952432pad.0 for ; Tue, 01 Jul 2014 09:33:44 -0700 (PDT) X-Received: by 10.66.121.197 with SMTP id lm5mr1810822pab.118.1404232424245; Tue, 01 Jul 2014 09:33:44 -0700 (PDT) Received: from localhost ([122.166.172.22]) by mx.google.com with ESMTPSA id f2sm118466306pat.11.2014.07.01.09.33.38 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 01 Jul 2014 09:33:43 -0700 (PDT) From: Viresh Kumar To: rjw@rjwysocki.net, shawn.guo@linaro.org Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, arvind.chauhan@arm.com, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, spk.linux@gmail.com, thomas.ab@samsung.com, nm@ti.com, t.figa@samsung.com, Viresh Kumar , Mike Turquette Subject: [PATCH 02/14] clk: Create of_clk_shared_by_cpus() Date: Tue, 1 Jul 2014 22:02:31 +0530 Message-Id: <5f7164d789e87c62d722b575980c92dfd0504334.1404231535.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: References: In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Create a new routine of_clk_shared_by_cpus() that finds if clock lines are shared between two CPUs. This is verified by comparing "clocks" property from CPU's DT node. Returns 1 if clock line is shared between them, 0 if clock isn't shared and return appropriate errors in case nodes/properties are missing. Cc: Mike Turquette Signed-off-by: Viresh Kumar --- drivers/clk/clk.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/clk.h | 6 ++++++ 2 files changed, 62 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 8b73ede..497735c 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -2528,6 +2529,61 @@ const char *of_clk_get_parent_name(struct device_node *np, int index) } EXPORT_SYMBOL_GPL(of_clk_get_parent_name); +/** + * of_clk_shared_by_cpus - Finds if clock line is shared between CPUs + * @cpu1, cpu2: CPU numbers + * + * Finds if clock lines are shared by two CPUs. This is verified by comparing + * "clocks" property from CPU's DT node. + * + * Returns 1 if clock line is shared between them, 0 if clock isn't shared. + * Return appropriate errors in case some requirements aren't met. + */ +int of_clk_shared_by_cpus(int cpu1, int cpu2) +{ + struct device *cpu1_dev, *cpu2_dev; + struct device_node *np1, *np2; + int ret; + + cpu1_dev = get_cpu_device(cpu1); + if (!cpu1_dev) { + pr_err("%s: failed to get cpu_dev for cpu%d\n", __func__, cpu1); + return -ENODEV; + } + + cpu2_dev = get_cpu_device(cpu2); + if (!cpu2_dev) { + pr_err("%s: failed to get cpu_dev for cpu%d\n", __func__, cpu2); + return -ENODEV; + } + + np1 = of_node_get(cpu1_dev->of_node); + if (!np1) { + pr_err("%s: failed to find of_node for cpu%d\n", __func__, + cpu1); + return -ENODEV; + } + + np2 = of_node_get(cpu2_dev->of_node); + if (!np2) { + pr_err("%s: failed to find of_node for cpu%d\n", __func__, + cpu2); + ret = -ENODEV; + goto put_np1; + } + + /* Match "clocks" property */ + ret = of_property_match(np1, np2, "clocks"); + + of_node_put(np2); + +put_np1: + of_node_put(np1); + + return ret; +} +EXPORT_SYMBOL_GPL(of_clk_shared_by_cpus); + struct clock_provider { of_clk_init_cb_t clk_init_cb; struct device_node *np; diff --git a/include/linux/clk.h b/include/linux/clk.h index fb5e097..58e281a 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -399,6 +399,7 @@ struct of_phandle_args; struct clk *of_clk_get(struct device_node *np, int index); struct clk *of_clk_get_by_name(struct device_node *np, const char *name); struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec); +int of_clk_shared_by_cpus(int cpu1, int cpu2); #else static inline struct clk *of_clk_get(struct device_node *np, int index) { @@ -409,6 +410,11 @@ static inline struct clk *of_clk_get_by_name(struct device_node *np, { return ERR_PTR(-ENOENT); } + +static inline int of_clk_shared_by_cpus(int cpu1, int cpu2) +{ + return -ENOSYS; +} #endif #endif