From patchwork Fri May 15 16:38:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Kuske X-Patchwork-Id: 6415521 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 85046C0432 for ; Fri, 15 May 2015 16:42:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B528C202F8 for ; Fri, 15 May 2015 16:42:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB1472013A for ; Fri, 15 May 2015 16:42:38 +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 1YtIeo-0002yv-8x; Fri, 15 May 2015 16:40:18 +0000 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YtIe5-0001am-EG for linux-arm-kernel@lists.infradead.org; Fri, 15 May 2015 16:39:34 +0000 Received: by wibt6 with SMTP id t6so64809014wib.0 for ; Fri, 15 May 2015 09:39:11 -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=RljHkEO6fwmVG4PJViu1QSd9IX4aP+XSv5JHkalCPgA=; b=J2xjdjmPY99sz4RYXReIGQwbyDbcby/8Nj79RQR67IGQDjG942+mKxPqY500lma+Rc BITSZjdj9voGcB40PcI5r0MJ3KrIww+11lg2w3PCAv3XzEs3eT7vwqfVsBNxzfVso8Zw tGbLJrl/v9kDun9gYXzunjqoQMa4+oUOhpAiqbxT6eB3g4Ad83wS4ivLLPFQ3WZYz/yx jjkCgjFQKDjjX87KyJ9ZAqi1yaW8I/EtUs3bP/+rAMzVNx9sm3NmhwjyNS2mropNnQsU aPR2PZJ6EsKEWnSQZuQDnWupraV7nZ7WI60t1sS+iYFQ8dfI1KG1az9w1ir/wiwc33/1 PO+g== X-Received: by 10.180.74.208 with SMTP id w16mr35310489wiv.31.1431707951374; Fri, 15 May 2015 09:39:11 -0700 (PDT) Received: from pc-jens.localdomain (p5B2E8A8F.dip0.t-ipconnect.de. [91.46.138.143]) by mx.google.com with ESMTPSA id ek10sm3726040wid.1.2015.05.15.09.39.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 May 2015 09:39:10 -0700 (PDT) From: Jens Kuske To: Maxime Ripard , =?UTF-8?q?Emilio=20L=C3=B3pez?= , Mike Turquette , Linus Walleij , Rob Herring Subject: [PATCH v2 02/10] clk: sunxi: Add support for multiple parents to gates Date: Fri, 15 May 2015 18:38:52 +0200 Message-Id: <1431707940-19372-3-git-send-email-jenskuske@gmail.com> X-Mailer: git-send-email 2.4.0 In-Reply-To: <1431707940-19372-1-git-send-email-jenskuske@gmail.com> References: <1431707940-19372-1-git-send-email-jenskuske@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150515_093933_656465_0A884713 X-CRM114-Status: GOOD ( 13.81 ) X-Spam-Score: -0.8 (/) Cc: devicetree@vger.kernel.org, Vishnu Patekar , linux-sunxi@googlegroups.com, linux-kernel@vger.kernel.org, Hans de Goede , Chen-Yu Tsai , Jens Kuske , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 Some newer sunxi SoCs (A83T, H3) don't have individual registers for AHB1, APB1 and APB2 gates anymore, but one big bus gates area where each gate can have a different parent. The current clock driver sets the same parent for all gates in a group. This commit adds a new parents field to the gates_data structure, which allows us to specify an array of parent indices for every single gate. Signed-off-by: Jens Kuske --- drivers/clk/sunxi/clk-sunxi.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index 9a82f17..17cba4d 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c @@ -898,6 +898,8 @@ static void __init sunxi_divider_clk_setup(struct device_node *node, struct gates_data { DECLARE_BITMAP(mask, SUNXI_GATES_MAX_SIZE); + /* If used, ARRAY_SIZE(parents) has to be >= bitmap_weight(mask) */ + const u8 *parents; }; static const struct gates_data sun4i_axi_gates_data __initconst = { @@ -1000,16 +1002,21 @@ static void __init sunxi_gates_clk_setup(struct device_node *node, struct gates_data *data) { struct clk_onecell_data *clk_data; + const char *parents[SUNXI_MAX_PARENTS]; const char *clk_parent; const char *clk_name; void __iomem *reg; + int npar = 0; int qty; int i = 0; int j = 0; reg = of_iomap(node, 0); - clk_parent = of_clk_get_parent_name(node, 0); + while (npar < SUNXI_MAX_PARENTS && + (parents[npar] = of_clk_get_parent_name(node, npar)) != NULL) + npar++; + clk_parent = parents[0]; /* Worst-case size approximation and memory allocation */ qty = find_last_bit(data->mask, SUNXI_GATES_MAX_SIZE); @@ -1026,6 +1033,9 @@ static void __init sunxi_gates_clk_setup(struct device_node *node, of_property_read_string_index(node, "clock-output-names", j, &clk_name); + if (data->parents && !WARN_ON(data->parents[j] >= npar)) + clk_parent = parents[data->parents[j]]; + clk_data->clks[i] = clk_register_gate(NULL, clk_name, clk_parent, 0, reg + 4 * (i/32), i % 32,