From patchwork Tue Oct 27 16:50:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Kuske X-Patchwork-Id: 7498741 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 859C9BEEA4 for ; Tue, 27 Oct 2015 16:52:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9888E2081F for ; Tue, 27 Oct 2015 16:52:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C4DEC20661 for ; Tue, 27 Oct 2015 16:52:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zr7Sm-0001C2-W3; Tue, 27 Oct 2015 16:51:09 +0000 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zr7Sh-0000yF-LF for linux-arm-kernel@lists.infradead.org; Tue, 27 Oct 2015 16:51:05 +0000 Received: by wicfx6 with SMTP id fx6so168374516wic.1 for ; Tue, 27 Oct 2015 09:50:42 -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=BYcBXvsmEzW9XBxe7xFx6mzap7aZK3il5jLLa37/7WY=; b=WCMkdqsk8dVyOCKUcj4yLERF3cFwawLDHv04dLFXw89ekaQ1k1cahDFY3OOdxSvxbx PeW8HMUFp9V7H8F6k1LzN3ebBwTBkKpfH5QZ22cxzaMqe9vFp0BZtmo9XC1YS4loD87w V+Eqk8OyY6SFxcimB20xWqbXDm9E3aFdJwKSKaC+FJVNq0aXyIigGIqe5NxEX+lhxb2c rfRxqSi2eWAWy0FpV8HviQgA9VjiDNRnFU1J9U3Sun11tDw5SAT8NV7QFzdxxcz9muZm 9v/f88k+7va6DcgrZCRGLesJ7SZNMfzMT+8uMIjHaC/MgEac7tkxLybyy3QIryuh/DY3 RRIg== X-Received: by 10.180.182.84 with SMTP id ec20mr28738578wic.42.1445964642681; Tue, 27 Oct 2015 09:50:42 -0700 (PDT) Received: from pc-jens.localdomain (p5B2E9A57.dip0.t-ipconnect.de. [91.46.154.87]) by smtp.gmail.com with ESMTPSA id r13sm2752058wmg.12.2015.10.27.09.50.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Oct 2015 09:50:42 -0700 (PDT) From: Jens Kuske To: Maxime Ripard , Chen-Yu Tsai , Michael Turquette , Linus Walleij , Rob Herring , Philipp Zabel , =?UTF-8?q?Emilio=20L=C3=B3pez?= Subject: [PATCH v4 1/6] clk: sunxi: Let divs clocks read the base factor clock name from devicetree Date: Tue, 27 Oct 2015 17:50:21 +0100 Message-Id: <1445964626-6484-2-git-send-email-jenskuske@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1445964626-6484-1-git-send-email-jenskuske@gmail.com> References: <1445964626-6484-1-git-send-email-jenskuske@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151027_095103_895898_B1E20B19 X-CRM114-Status: GOOD ( 19.48 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Vishnu Patekar , linux-kernel@vger.kernel.org, Hans de Goede , linux-sunxi@googlegroups.com, Jens Kuske , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 Currently, the sunxi clock driver gets the name for the base factor clock of divs clocks from the name field in factors_data. This prevents reusing of the factor clock for clocks with same properties, but different name. This commit makes the divs setup function try to get a name from clock-output-names in the devicetree. It also removes the name field where possible and merges the sun4i PLL5 and PLL6 clocks. Signed-off-by: Jens Kuske --- drivers/clk/sunxi/clk-sunxi.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index 9c79af0c..270de42 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c @@ -704,21 +704,12 @@ static const struct factors_data sun4i_pll5_data __initconst = { .enable = 31, .table = &sun4i_pll5_config, .getter = sun4i_get_pll5_factors, - .name = "pll5", -}; - -static const struct factors_data sun4i_pll6_data __initconst = { - .enable = 31, - .table = &sun4i_pll5_config, - .getter = sun4i_get_pll5_factors, - .name = "pll6", }; static const struct factors_data sun6i_a31_pll6_data __initconst = { .enable = 31, .table = &sun6i_a31_pll6_config, .getter = sun6i_a31_get_pll6_factors, - .name = "pll6x2", }; static const struct factors_data sun5i_a13_ahb_data __initconst = { @@ -902,6 +893,7 @@ struct gates_data { #define SUNXI_DIVS_MAX_QTY 4 #define SUNXI_DIVISOR_WIDTH 2 +#define SUNXI_DIVS_BASE_NAME_MAX_LEN 8 struct divs_data { const struct factors_data *factors; /* data for the factor clock */ @@ -941,7 +933,7 @@ static const struct divs_data pll5_divs_data __initconst = { }; static const struct divs_data pll6_divs_data __initconst = { - .factors = &sun4i_pll6_data, + .factors = &sun4i_pll5_data, .ndivs = 4, .div = { { .shift = 0, .table = pll6_sata_tbl, .gate = 14 }, /* M, SATA */ @@ -983,6 +975,8 @@ static void __init sunxi_divs_clk_setup(struct device_node *node, struct clk_gate *gate = NULL; struct clk_fixed_factor *fix_factor; struct clk_divider *divider; + struct factors_data factors = *data->factors; + char base_name[SUNXI_DIVS_BASE_NAME_MAX_LEN]; void __iomem *reg; int ndivs = SUNXI_DIVS_MAX_QTY, i = 0; int flags, clkflags; @@ -991,8 +985,30 @@ static void __init sunxi_divs_clk_setup(struct device_node *node, if (data->ndivs) ndivs = data->ndivs; + /* Try to find a name for base factor clock */ + for (i = 0; i < ndivs; i++) { + if (data->div[i].self) { + of_property_read_string_index(node, "clock-output-names", + i, &factors.name); + break; + } + } + /* If we don't have a .self clk use the first output-name up to '_' */ + if (factors.name == NULL) { + of_property_read_string_index(node, "clock-output-names", + 0, &clk_name); + + for (i = 0; i < SUNXI_DIVS_BASE_NAME_MAX_LEN - 1 && + clk_name[i] != '_' && + clk_name[i] != '\0'; i++) + base_name[i] = clk_name[i]; + + base_name[i] = '\0'; + factors.name = base_name; + } + /* Set up factor clock that we will be dividing */ - pclk = sunxi_factors_clk_setup(node, data->factors); + pclk = sunxi_factors_clk_setup(node, &factors); parent = __clk_get_name(pclk); reg = of_iomap(node, 0);