From patchwork Wed May 11 16:00:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 621189 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3r4h3H2St2z9t3r for ; Thu, 12 May 2016 02:12:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=Qc2gaceK; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2EBF6A750A; Wed, 11 May 2016 18:12:25 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qVWJaJ2spDnF; Wed, 11 May 2016 18:12:24 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 415ACA74BA; Wed, 11 May 2016 18:12:22 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B8596A74C6 for ; Wed, 11 May 2016 18:00:32 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f-3VLwtbLYlV for ; Wed, 11 May 2016 18:00:31 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by theia.denx.de (Postfix) with ESMTPS id 41981A74A8 for ; Wed, 11 May 2016 18:00:27 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id w143so10277004wmw.3 for ; Wed, 11 May 2016 09:00:27 -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; bh=AJggbiyxqXmE9g1Jx2I8+fEacXcl3sNQHipUK5gyuwU=; b=Qc2gaceK3uXIbzh6emZUcs2zDlOm7+JZmirilIJUm0nYSQumveIQ7uBBuVlzqeTQsy IAQqcnhpxA3WDz15j/nlLLH6LpNKyY1i5A04Wot2d1fBM5BnvsteBZ0l8X5xqgvzYvnQ bsD43TVu/doVJ9KNlpZi1lhDWmIh7PDvxXg0YCeVz3w/lwqyG+Z7iZqjRdrHfwuLNkdu QU+VinLOu8tDk+6inzK+vTE6bEqcOqesVyUrdfma958gEEIUjph7qSCTnWjOTo60BwRL 0k7C7uZDqmiQiLu9K4LlTFb8OH4SNe1DntVfkBhzXbCTmv8ldpsTUj+bzmNaG626D7Hp nvTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=AJggbiyxqXmE9g1Jx2I8+fEacXcl3sNQHipUK5gyuwU=; b=e2T9CrDquca2gMNxMGCXCImR4o1ZATsqa0lXo0Ge2CTc9l237RGNpu8SyJtfxSgOaq 3k8UhQg1u/asbbyUaYeTwnfWqWxzJCgj2ffyya8kDAZy6t07RHrsq+ZC2gQPIIlColr0 6CJhe+GMYkplc6Q+1F766NgJkOefZy+xMk2/Bh3pffKjEz7jWwrll3OoZLHa/0u5fkgW MO1MkSZXHbiaAwd6erYNiVAzS66i24SyPZS0h8r2it3XWcoUUXDfqPz4PedFnWZ7ISRv ELLCUJ5QQwPg84XHnTuKWuVUVpiQTsBHYE+mK3qQrrJ2KMyXJ2C4+FxGBAnURcVw8PHS hJ2w== X-Gm-Message-State: AOPr4FXt/af91xCpymZEvxN4U3pA1UA4p9HhRNa2jDlbZUy1QR2vSVRhTX+w8lWoagMKoQ== X-Received: by 10.194.220.230 with SMTP id pz6mr4439839wjc.93.1462982426694; Wed, 11 May 2016 09:00:26 -0700 (PDT) Received: from localhost.localdomain (host199-126-dynamic.20-79-r.retail.telecomitalia.it. [79.20.126.199]) by smtp.gmail.com with ESMTPSA id jq1sm8784552wjc.28.2016.05.11.09.00.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 May 2016 09:00:26 -0700 (PDT) From: Andrea Merello To: u-boot@lists.denx.de Date: Wed, 11 May 2016 18:00:19 +0200 Message-Id: <1462982419-8618-1-git-send-email-andrea.merello@gmail.com> X-Mailer: git-send-email 2.1.4 X-Mailman-Approved-At: Wed, 11 May 2016 18:12:19 +0200 Subject: [U-Boot] [RESEND RFC PATCH] zynq: add support for on-board shared reset gpio X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" I'm adding support [1] for another zynq-based board (MYIR Zturn [2]). This board has one peculiarity that I have to deal with: it has a shared reset signal that hits both the USB PHY and the Ethernet PHY, and this is routed to a GPIO that must be shaken down and up before using those two pheripherals (especially USB) in order to make things working. This must be done before the two ethernet and USB drivers probes, so I couldn't delegate this to any of the twos.. Right now I added a top-level node "board" to my DT containing the GPIO property and I handle this in the board initialization code. board { phys-reset-gpio = <&gpio0 51 GPIO_ACTIVE_LOW>; }; RFC: is this a good/clean way to handle this thing? Ideally I would like to put this mechanism out of the Zynq-specific board file, so that it could be available for any kind of board.. (once a clean way to handle this thing have been agreed I'll rebase and I'll post a patch serie for adding support for that board). [1] https://github.com/andreamerello/u-boot-zynq [2] http://www.myirtech.com/list.asp?id=502 Signed-off-by: Andrea Merello --- 2.1.4 diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 183f642..f72b219 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -11,6 +11,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -70,8 +71,43 @@ int board_init(void) return 0; } +int phys_reset(void) +{ + struct gpio_desc reset_gpio; + int nodeoffset; + const void *blob = gd->fdt_blob; + + nodeoffset = fdt_path_offset(blob, "/board"); + if (nodeoffset == -FDT_ERR_NOTFOUND) + return 0; + if (nodeoffset < 0) + return nodeoffset; + + gpio_request_by_name_nodev(blob, nodeoffset, "phys-reset-gpio", 0, + &reset_gpio, 0); + + if (dm_gpio_is_valid(&reset_gpio)) { + /* reset PHYs (ethernet and USB) before any driver comes up */ + dm_gpio_set_dir_flags(&reset_gpio, reset_gpio.flags | + GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); + + mdelay(100); + dm_gpio_set_dir_flags(&reset_gpio, (reset_gpio.flags | + GPIOD_IS_OUT) & ~GPIOD_IS_OUT_ACTIVE); + + /* wait for PHYs to come up before going on */ + mdelay(100); + + printf("PHYs reset OK\n"); + } + + return 0; +} + int board_late_init(void) { + phys_reset(); + switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) { case ZYNQ_BM_NOR: setenv("modeboot", "norboot");