From patchwork Tue Aug 2 05:50:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 654568 X-Patchwork-Delegate: sbabic@denx.de 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 3s3QM51t2Nz9t32 for ; Tue, 2 Aug 2016 15:52:01 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=agner.ch header.i=@agner.ch header.b=HVYlzak1; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 99655A75FF; Tue, 2 Aug 2016 07:51: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 kB4N92_Wbbje; Tue, 2 Aug 2016 07:51:32 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9EB16A75E5; Tue, 2 Aug 2016 07:51:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CA790A74FB for ; Tue, 2 Aug 2016 07:51:00 +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 cqUwd0jHvn6T for ; Tue, 2 Aug 2016 07:51:00 +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.kmu-office.ch (mail.kmu-office.ch [178.209.48.109]) by theia.denx.de (Postfix) with ESMTPS id A1DA9A74F1 for ; Tue, 2 Aug 2016 07:51:00 +0200 (CEST) Received: from trochilidae.lan (unknown [IPv6:2601:602:8802:504f:3e97:eff:fe92:db3b]) by mail.kmu-office.ch (Postfix) with ESMTPSA id E9B735C1855; Tue, 2 Aug 2016 07:46:42 +0200 (CEST) From: Stefan Agner To: u-boot@lists.denx.de, Stefano Babic Date: Mon, 1 Aug 2016 22:50:23 -0700 Message-Id: <20160802055024.13979-10-stefan@agner.ch> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160802055024.13979-1-stefan@agner.ch> References: <20160802055024.13979-1-stefan@agner.ch> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1470116804; bh=6TqxQQ3o2y3ipaUNjoPzVXDBywpssdBnZDjqq5FM78E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=HVYlzak1E/OTG+G6pDepShJgQSX06P+YCM+hMpnzGjGiRSYqFOmV/HL1GUMxRyDxXUOpvAO6XKXLdPqMQAXLi2YbBefZ0nlqMN+HmuzzX7FKu2OiXD1ZB5iONohbOHE6URbNwG8xtu+IunkZ9LGlXXug8+5qXgUJ+sEi/TpdnFc= Cc: Marcel Ziswiler , Stefan Agner , Max Krummenacher Subject: [U-Boot] [PATCH v2 09/10] colibri_imx7: use Ricoh RN5T567 to reboot the board 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" From: Stefan Agner Use the external PMIC Ricoh RN5T567 to reliably restart the system. Signed-off-by: Stefan Agner --- board/toradex/colibri_imx7/colibri_imx7.c | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/board/toradex/colibri_imx7/colibri_imx7.c b/board/toradex/colibri_imx7/colibri_imx7.c index bd7d5bc..c64e31e 100644 --- a/board/toradex/colibri_imx7/colibri_imx7.c +++ b/board/toradex/colibri_imx7/colibri_imx7.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -337,6 +339,46 @@ int board_late_init(void) return 0; } +#ifdef CONFIG_DM_PMIC +int power_init_board(void) +{ + struct udevice *dev; + int reg, ver; + int ret; + + + ret = pmic_get("rn5t567", &dev); + if (ret) + return ret; + ver = pmic_reg_read(dev, RN5T567_LSIVER); + reg = pmic_reg_read(dev, RN5T567_OTPVER); + + printf("PMIC: RN5T567 LSIVER=0x%02x OTPVER=0x%02x\n", ver, reg); + + /* set judge and press timer of N_OE to minimal values */ + pmic_clrsetbits(dev, RN5T567_NOETIMSETCNT, 0x7, 0); + + return 0; +} + +void reset_cpu(ulong addr) +{ + struct udevice *dev; + + pmic_get("rn5t567", &dev); + + /* Use PMIC to reset, set REPWRTIM to 0 and REPWRON to 1 */ + pmic_reg_write(dev, RN5T567_REPCNT, 0x1); + pmic_reg_write(dev, RN5T567_SLPCNT, 0x1); + + /* + * Re-power factor detection on PMIC side is not instant. 1ms + * proved to be enough time until reset takes effect. + */ + mdelay(1); +} +#endif + int checkboard(void) { printf("Model: Toradex Colibri iMX7%c\n",