From patchwork Tue Apr 22 13:19:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 4031851 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9DA479F391 for ; Tue, 22 Apr 2014 13:19:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE14620260 for ; Tue, 22 Apr 2014 13:19:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E08102021F for ; Tue, 22 Apr 2014 13:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756121AbaDVNTw (ORCPT ); Tue, 22 Apr 2014 09:19:52 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:64781 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752656AbaDVNTq (ORCPT ); Tue, 22 Apr 2014 09:19:46 -0400 Received: by mail-wi0-f173.google.com with SMTP id z2so3247256wiv.0 for ; Tue, 22 Apr 2014 06:19:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FXVzR6cqP9VWlIgAp8xykPDxnI9SHzYjUDCoTakkwdo=; b=HvDizqVlqqpu3pgKGMOpe/6bL6/QQHc7ASsjk7+oX+LVqzznmCFgrg5DSBuSXy3KKh yxY1m0/61WMPMXjV3UwUkH+bOn/u5vllP9skSoCMPdwIy/qQidaq7Icc97hiR0OpI843 RPD6Jms5tTuDRgJLs+WnwWCkkdnyjP4R65LP/4bFCtN82Mfu6rRNZpb/kxBaCAEOUC7r GVH3XeDtw107ZYY1RTHMIC6gz3wfmc4bRsfqFoY7Avaw7Wmg2sLLcEPC/gwYbLkupvF0 np0Re7dh8J4pgUgDc9u4Up0ZwdJYwGll/3at3Op16Wt3oG+NgKVUs8OLB1R3QZGL5774 fWTQ== X-Received: by 10.194.172.38 with SMTP id az6mr33325530wjc.33.1398172784904; Tue, 22 Apr 2014 06:19:44 -0700 (PDT) Received: from groucho.site ([109.201.154.204]) by mx.google.com with ESMTPSA id y20sm22579180wiv.14.2014.04.22.06.19.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Apr 2014 06:19:44 -0700 (PDT) X-Google-Original-From: Ulrich Hecht From: Ulrich Hecht To: linux-sh@vger.kernel.org, laurent.pinchart@ideasonboard.com, horms@verge.net.au Cc: magnus.damm@gmail.com, Ulrich Hecht , Ulrich Hecht Subject: [PATCH 1/4] clk: shmobile: div6: support selectable-input clocks Date: Tue, 22 Apr 2014 15:19:09 +0200 Message-Id: <1398172752-30567-2-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1398172752-30567-1-git-send-email-ulrich.hecht+renesas@gmail.com> References: <1398172752-30567-1-git-send-email-ulrich.hecht+renesas@gmail.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ulrich Hecht Adds support for DIV6 clocks with selectable parents as found in the r8a7740 and other SoCs. Signed-off-by: Ulrich Hecht --- .../bindings/clock/renesas,cpg-div6-clocks.txt | 8 ++++++++ drivers/clk/shmobile/clk-div6.c | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/clock/renesas,cpg-div6-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,cpg-div6-clocks.txt index 952e373..f8302f5 100644 --- a/Documentation/devicetree/bindings/clock/renesas,cpg-div6-clocks.txt +++ b/Documentation/devicetree/bindings/clock/renesas,cpg-div6-clocks.txt @@ -7,6 +7,7 @@ to 64. Required Properties: - compatible: Must be one of the following + - "renesas,r8a7740-div6-clock" for R8A7740 DIV6 clocks - "renesas,r8a7790-div6-clock" for R8A7790 (R-Car H2) DIV6 clocks - "renesas,r8a7791-div6-clock" for R8A7791 (R-Car M2) DIV6 clocks - "renesas,cpg-div6-clock" for generic DIV6 clocks @@ -15,6 +16,13 @@ Required Properties: - #clock-cells: Must be 0 - clock-output-names: The name of the clock as a free-form string +Optional Properties: + + - renesas,src-shift: Bit position of the input clock selector (default: + fixed input clock) + - renesas,src-width: Bit width of the input clock selector (default: fixed + input clock) + Example ------- diff --git a/drivers/clk/shmobile/clk-div6.c b/drivers/clk/shmobile/clk-div6.c index f065f69..5be8161 100644 --- a/drivers/clk/shmobile/clk-div6.c +++ b/drivers/clk/shmobile/clk-div6.c @@ -121,6 +121,7 @@ static void __init cpg_div6_clock_init(struct device_node *np) const char *name; struct clk *clk; int ret; + u32 src_shift, src_width; clock = kzalloc(sizeof(*clock), GFP_KERNEL); if (!clock) { @@ -150,7 +151,23 @@ static void __init cpg_div6_clock_init(struct device_node *np) goto error; } - parent_name = of_clk_get_parent_name(np, 0); + if (!of_property_read_u32(np, "renesas,src-shift", &src_shift)) { + if (!of_property_read_u32(np, "renesas,src-width", + &src_width)) { + unsigned int parent_idx = + (clk_readl(clock->reg) >> src_shift) & + (BIT(src_width) - 1); + parent_name = of_clk_get_parent_name(np, parent_idx); + } + else { + pr_err("%s: renesas,src-shift without renesas," + "src-width in %s\n", __func__, np->name); + goto error; + } + } + else + parent_name = of_clk_get_parent_name(np, 0); + if (parent_name == NULL) { pr_err("%s: failed to get %s DIV6 clock parent name\n", __func__, np->name);