From patchwork Tue Oct 27 16:50:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Kuske X-Patchwork-Id: 7498761 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 26D55BEEA4 for ; Tue, 27 Oct 2015 16:54:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2D5DA208CB for ; Tue, 27 Oct 2015 16:54:21 +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 44D0D20661 for ; Tue, 27 Oct 2015 16:54:20 +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 1Zr7UG-0002AR-7O; Tue, 27 Oct 2015 16:52:40 +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 1Zr7Sm-00010S-Jl for linux-arm-kernel@lists.infradead.org; Tue, 27 Oct 2015 16:51:13 +0000 Received: by wicfx6 with SMTP id fx6so168377540wic.1 for ; Tue, 27 Oct 2015 09:50:47 -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=eYl7Ja9uVoeBeqdOVUeaGS/82UYmaPW8wRD1xp7Vbb8=; b=ZX0SrzcC8wNaQXgGB7sopP+fGsjhx+IdVS4dKP+pddiLzmC/UIYpg7Bx0yyZkOQsed z3bqYmDqY0U06jJdSjssrdhf15ngF8EKgAUH/2EFSvnDV2adowZTDLCAUH5Z83/07Cd/ N1vkdgNXzLq8jHACnrwJhZ3lixlGKq41sk4ju3XjX9uVCJYPvGUW+JvD3PJ6OWpFJZRN A6uNqck+Ia2mFqIwt8sHItRzn/kW2Qn4Nq3/wskE1WrGpwSphbTI89Yzh+dwuP3SEqvi zz3bRtyhlo9qMHPEo/r/Lcemcsw4HGQ06WnSguifTKY6HJRmNIChLfDAfH78VhXB6rHh X/Dw== X-Received: by 10.194.78.35 with SMTP id y3mr29169234wjw.3.1445964647014; Tue, 27 Oct 2015 09:50:47 -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.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Oct 2015 09:50:46 -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 4/6] reset: sunxi: Add Allwinner H3 bus resets Date: Tue, 27 Oct 2015 17:50:24 +0100 Message-Id: <1445964626-6484-5-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_095109_155870_8C4E170D X-CRM114-Status: GOOD ( 17.16 ) 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 The H3 bus resets have some holes between the registers, so we add an of_xlate() function to skip them according to the datasheet. Signed-off-by: Jens Kuske --- .../bindings/reset/allwinner,sunxi-clock-reset.txt | 1 + drivers/reset/reset-sunxi.c | 30 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt b/Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt index c8f7757..e11f023 100644 --- a/Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt +++ b/Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt @@ -8,6 +8,7 @@ Required properties: - compatible: Should be one of the following: "allwinner,sun6i-a31-ahb1-reset" "allwinner,sun6i-a31-clock-reset" + "allwinner,sun8i-h3-bus-reset" - reg: should be register base and length as documented in the datasheet - #reset-cells: 1, see below diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c index 3d95c87..c91e146 100644 --- a/drivers/reset/reset-sunxi.c +++ b/drivers/reset/reset-sunxi.c @@ -75,7 +75,9 @@ static struct reset_control_ops sunxi_reset_ops = { .deassert = sunxi_reset_deassert, }; -static int sunxi_reset_init(struct device_node *np) +static int sunxi_reset_init(struct device_node *np, + int (*of_xlate)(struct reset_controller_dev *rcdev, + const struct of_phandle_args *reset_spec)) { struct sunxi_reset_data *data; struct resource res; @@ -108,6 +110,7 @@ static int sunxi_reset_init(struct device_node *np) data->rcdev.nr_resets = size * 32; data->rcdev.ops = &sunxi_reset_ops; data->rcdev.of_node = np; + data->rcdev.of_xlate = of_xlate; reset_controller_register(&data->rcdev); return 0; @@ -117,6 +120,21 @@ err_alloc: return ret; }; +static int sun8i_h3_bus_reset_xlate(struct reset_controller_dev *rcdev, + const struct of_phandle_args *reset_spec) +{ + unsigned int index = reset_spec->args[0]; + + if (index < 96) + return index; + else if (index < 128) + return index + 32; + else if (index < 160) + return index + 64; + else + return -EINVAL; +} + /* * These are the reset controller we need to initialize early on in * our system, before we can even think of using a regular device @@ -124,15 +142,21 @@ err_alloc: */ static const struct of_device_id sunxi_early_reset_dt_ids[] __initdata = { { .compatible = "allwinner,sun6i-a31-ahb1-reset", }, + { .compatible = "allwinner,sun8i-h3-bus-reset", .data = sun8i_h3_bus_reset_xlate, }, { /* sentinel */ }, }; void __init sun6i_reset_init(void) { struct device_node *np; + const struct of_device_id *match; + int (*of_xlate)(struct reset_controller_dev *rcdev, + const struct of_phandle_args *reset_spec); - for_each_matching_node(np, sunxi_early_reset_dt_ids) - sunxi_reset_init(np); + for_each_matching_node_and_match(np, sunxi_early_reset_dt_ids, &match) { + of_xlate = match->data; + sunxi_reset_init(np, of_xlate); + } } /*