From patchwork Mon Feb 1 14:42:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 8180181 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5FB059F4DD for ; Mon, 1 Feb 2016 14:45:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 68C8820434 for ; Mon, 1 Feb 2016 14:45:41 +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 82FBF203C2 for ; Mon, 1 Feb 2016 14:45:40 +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 1aQFhb-00059Q-Tg; Mon, 01 Feb 2016 14:43:39 +0000 Received: from smtp.csie.ntu.edu.tw ([140.112.30.61]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQFhC-0004qw-7G for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2016 14:43:15 +0000 Received: from wens.csie.org (mirror2.csie.ntu.edu.tw [140.112.30.76]) (Authenticated sender: b93043) by smtp.csie.ntu.edu.tw (Postfix) with ESMTPSA id DE07320524; Mon, 1 Feb 2016 22:42:51 +0800 (CST) Received: by wens.csie.org (Postfix, from userid 1000) id ACE725F898; Mon, 1 Feb 2016 22:42:51 +0800 (CST) From: Chen-Yu Tsai To: Maxime Ripard , Michael Turquette , Stephen Boyd Subject: [PATCH 1/2] clk: sunxi: Add support for A80 APBS clock Date: Mon, 1 Feb 2016 22:42:48 +0800 Message-Id: <1454337769-4130-2-git-send-email-wens@csie.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454337769-4130-1-git-send-email-wens@csie.org> References: <1454337769-4130-1-git-send-email-wens@csie.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160201_064314_633258_8B66ABAE X-CRM114-Status: GOOD ( 14.60 ) X-Spam-Score: -4.2 (----) 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, Chen-Yu Tsai , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 A80's APBS clock is not the same as the APB0 clock on A23. The A80's is a zero-based divider, while the A23's is a power-of-two divider. Signed-off-by: Chen-Yu Tsai Acked-by: Rob Herring --- Documentation/devicetree/bindings/clock/sunxi.txt | 1 + drivers/clk/sunxi/Makefile | 2 +- drivers/clk/sunxi/clk-sun9i-apbs.c | 64 +++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/sunxi/clk-sun9i-apbs.c diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt index e59f57b24777..fad81157798c 100644 --- a/Documentation/devicetree/bindings/clock/sunxi.txt +++ b/Documentation/devicetree/bindings/clock/sunxi.txt @@ -58,6 +58,7 @@ Required properties: "allwinner,sun6i-a31-apb2-gates-clk" - for the APB2 gates on A31 "allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23 "allwinner,sun8i-h3-bus-gates-clk" - for the bus gates on H3 + "allwinner,sun9i-a80-apbs-clk" - for the APBS clock on A80 "allwinner,sun9i-a80-apbs-gates-clk" - for the APBS gates on A80 "allwinner,sun4i-a10-dram-gates-clk" - for the DRAM gates on A10 "allwinner,sun5i-a13-mbus-clk" - for the MBUS clock on A13 diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile index 3fd7901d48e4..df433b3f789d 100644 --- a/drivers/clk/sunxi/Makefile +++ b/drivers/clk/sunxi/Makefile @@ -17,7 +17,7 @@ obj-y += clk-sun9i-core.o obj-y += clk-sun9i-mmc.o obj-y += clk-usb.o -obj-$(CONFIG_MACH_SUN9I) += clk-sun8i-apb0.o +obj-$(CONFIG_MACH_SUN9I) += clk-sun9i-apbs.o obj-$(CONFIG_MACH_SUN9I) += clk-sun9i-cpus.o obj-$(CONFIG_MFD_SUN6I_PRCM) += \ diff --git a/drivers/clk/sunxi/clk-sun9i-apbs.c b/drivers/clk/sunxi/clk-sun9i-apbs.c new file mode 100644 index 000000000000..aacb92873621 --- /dev/null +++ b/drivers/clk/sunxi/clk-sun9i-apbs.c @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2016 Chen-Yu Tsai + * Author: Chen-Yu Tsai + * + * Allwinner A80 APBS clock driver + * + * License Terms: GNU General Public License v2 + * + * Based on clk-sun6i-apbs.c + * Allwinner A31 APB0 clock driver + * + * Copyright (C) 2014 Free Electrons + * Author: Boris BREZILLON + * + */ + +#include +#include +#include +#include +#include + +static void sun9i_apbs_setup(struct device_node *node) +{ + const char *name = node->name; + const char *parent; + struct resource res; + struct clk *clk; + void __iomem *reg; + int ret; + + reg = of_io_request_and_map(node, 0, of_node_full_name(node)); + if (IS_ERR(reg)) { + pr_err("Could not get registers for a80-apbs-clk\n"); + return; + } + + parent = of_clk_get_parent_name(node, 0); + if (!parent) + return; + + of_property_read_string(node, "clock-output-names", &name); + + /* The A80 APBS clock is a standard 2 bit wide divider clock */ + clk = clk_register_divider(NULL, name, parent, 0, reg, 0, 2, 0, NULL); + if (IS_ERR(clk)) { + pr_err("failed to register a80-apbs-clk: %ld\n", PTR_ERR(clk)); + goto err_unmap; + } + + ret = of_clk_add_provider(node, of_clk_src_simple_get, clk); + if (ret) + goto err_unregister; + + return; + +err_unregister: + clk_unregister_divider(clk); +err_unmap: + iounmap(reg); + of_address_to_resource(node, 0, &res); + release_mem_region(res.start, resource_size(&res)); +} +CLK_OF_DECLARE(sun9i_apbs, "allwinner,sun9i-a80-apbs-clk", sun9i_apbs_setup);