From patchwork Thu Jan 9 14:00:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 23015 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B362C216DD for ; Thu, 9 Jan 2014 14:02:06 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id vb8sf11152149obc.4 for ; Thu, 09 Jan 2014 06:02:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=48Ki4QufHYQYmSbc7s8YbMe9cgzu4VgUXF6Hx3M0Ito=; b=jT/B/6gwYXKEar863ENOoHmo3jcWi8MqKDYUkCQ5t9JcGBH6HJOMVFatgZw7Q/VsQw +CyQgmuKw5AEZtnko4m377o1sLVwS5Z1tqs2XCa3KQRqy7X4hgb+fDNXMs9VmhCodHaD 4T4RvxgwfFRdQaGCST3uQHP2lo5tRdeGcKzJBBHOtiachKfyA6QRYq3Jr9O15+zYcLzB UgRfcfa2zbHJx8YY4ayiN+Eu617EMMihXJC6agpb2dzGjkjmGvmxbYW5MLWpLGEjmeP6 lScMKY7REYMzACp1C/zSEdFkirC4vs5KIvHLKDuVRZXAtB8e+RsfkjllIIpVZ/P/Kalg DuhQ== X-Gm-Message-State: ALoCoQn/6QA/ST+PjvCz5lik+We5yhWpYhQGXI+XxuAmaBrY8meAhx4rYopIJLNWgt1DYe4jf1g3 X-Received: by 10.43.96.73 with SMTP id cf9mr1052382icc.22.1389276125831; Thu, 09 Jan 2014 06:02:05 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.39.102 with SMTP id o6ls1149824qek.28.gmail; Thu, 09 Jan 2014 06:02:05 -0800 (PST) X-Received: by 10.58.255.195 with SMTP id as3mr1330259ved.50.1389276125689; Thu, 09 Jan 2014 06:02:05 -0800 (PST) Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by mx.google.com with ESMTPS id q10si2879550ves.96.2014.01.09.06.02.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Jan 2014 06:02:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.44 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.44; Received: by mail-vb0-f44.google.com with SMTP id x8so2193318vbf.17 for ; Thu, 09 Jan 2014 06:02:05 -0800 (PST) X-Received: by 10.52.53.101 with SMTP id a5mr1049855vdp.80.1389276125568; Thu, 09 Jan 2014 06:02:05 -0800 (PST) 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.59.13.131 with SMTP id ey3csp14271ved; Thu, 9 Jan 2014 06:02:04 -0800 (PST) X-Received: by 10.66.144.137 with SMTP id sm9mr3947516pab.64.1389276124061; Thu, 09 Jan 2014 06:02:04 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sw1si4029475pab.112.2014.01.09.06.02.03; Thu, 09 Jan 2014 06:02:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754859AbaAIOBu (ORCPT + 5 others); Thu, 9 Jan 2014 09:01:50 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:46834 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754760AbaAIOBl (ORCPT ); Thu, 9 Jan 2014 09:01:41 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s09E19f5020543; Thu, 9 Jan 2014 08:01:09 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s09E19Gx024285; Thu, 9 Jan 2014 08:01:09 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Thu, 9 Jan 2014 08:01:08 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s09E12W5030058; Thu, 9 Jan 2014 08:01:06 -0600 From: Tero Kristo To: , , , , , , CC: , Subject: [PATCHv13 01/40] CLK: TI: add DT alias clock registration mechanism Date: Thu, 9 Jan 2014 16:00:12 +0200 Message-ID: <1389276051-1326-2-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1389276051-1326-1-git-send-email-t-kristo@ti.com> References: <1389276051-1326-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: t-kristo@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.44 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , Some devices require their clocks to be available with a specific dev-id con-id mapping. With DT, the clocks can be found by default only with their name, or alternatively through the device node of the consumer. With drivers, that don't support DT fully yet, add mechanism to register specific clock names. Signed-off-by: Tero Kristo --- drivers/clk/Makefile | 1 + drivers/clk/ti/Makefile | 3 +++ drivers/clk/ti/clk.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/clk/ti.h | 42 ++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 drivers/clk/ti/Makefile create mode 100644 drivers/clk/ti/clk.c create mode 100644 include/linux/clk/ti.h diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 7a10bc9..c61f768 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -35,6 +35,7 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-$(CONFIG_PLAT_SAMSUNG) += samsung/ obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o obj-$(CONFIG_COMMON_CLK_KEYSTONE) += keystone/ +obj-$(CONFIG_ARCH_OMAP) += ti/ obj-$(CONFIG_X86) += x86/ diff --git a/drivers/clk/ti/Makefile b/drivers/clk/ti/Makefile new file mode 100644 index 0000000..1825f7f --- /dev/null +++ b/drivers/clk/ti/Makefile @@ -0,0 +1,3 @@ +ifneq ($(CONFIG_OF),) +obj-y += clk.o +endif diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c new file mode 100644 index 0000000..ef1a7cd --- /dev/null +++ b/drivers/clk/ti/clk.c @@ -0,0 +1,55 @@ +/* + * TI clock support + * + * Copyright (C) 2013 Texas Instruments, Inc. + * + * Tero Kristo + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include + +#undef pr_fmt +#define pr_fmt(fmt) "%s: " fmt, __func__ + +/** + * ti_dt_clocks_register - register DT alias clocks during boot + * @oclks: list of clocks to register + * + * Register alias or non-standard DT clock entries during boot. By + * default, DT clocks are found based on their node name. If any + * additional con-id / dev-id -> clock mapping is required, use this + * function to list these. + */ +void __init ti_dt_clocks_register(struct ti_dt_clk oclks[]) +{ + struct ti_dt_clk *c; + struct device_node *node; + struct clk *clk; + struct of_phandle_args clkspec; + + for (c = oclks; c->node_name != NULL; c++) { + node = of_find_node_by_name(NULL, c->node_name); + clkspec.np = node; + clk = of_clk_get_from_provider(&clkspec); + + if (!IS_ERR(clk)) { + c->lk.clk = clk; + clkdev_add(&c->lk); + } else { + pr_warn("failed to lookup clock node %s\n", + c->node_name); + } + } +} diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h new file mode 100644 index 0000000..df94c24 --- /dev/null +++ b/include/linux/clk/ti.h @@ -0,0 +1,42 @@ +/* + * TI clock drivers support + * + * Copyright (C) 2013 Texas Instruments, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#ifndef __LINUX_CLK_TI_H__ +#define __LINUX_CLK_TI_H__ + +#include + +/** + * struct ti_dt_clk - OMAP DT clock alias declarations + * @lk: clock lookup definition + * @node_name: clock DT node to map to + */ +struct ti_dt_clk { + struct clk_lookup lk; + char *node_name; +}; + +#define DT_CLK(dev, con, name) \ + { \ + .lk = { \ + .dev_id = dev, \ + .con_id = con, \ + }, \ + .node_name = name, \ + } + + +void ti_dt_clocks_register(struct ti_dt_clk *oclks); + +#endif