All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Agner <stefan@agner.ch>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 09/10] colibri_imx7: use Ricoh RN5T567 to reboot the board
Date: Mon, 25 Jul 2016 23:22:32 -0700	[thread overview]
Message-ID: <20160726062233.7656-10-stefan@agner.ch> (raw)
In-Reply-To: <20160726062233.7656-1-stefan@agner.ch>

From: Stefan Agner <stefan.agner@toradex.com>

Use the external PMIC Ricoh RN5T567 to reliably restart the system.

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
---

 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 <mmc.h>
 #include <miiphy.h>
 #include <netdev.h>
+#include <power/pmic.h>
+#include <power/rn5t567_pmic.h>
 #include <usb/ehci-ci.h>
 
 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",
-- 
2.9.0

  parent reply	other threads:[~2016-07-26  6:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-26  6:22 [U-Boot] [PATCH 00/10] mx7: add dt support for Colibri iMX7S/iMX7D Stefan Agner
2016-07-26  6:22 ` [U-Boot] [PATCH 01/10] dm: imx: serial: support device tree Stefan Agner
2016-08-01  1:01   ` Simon Glass
2016-08-02  5:33     ` Stefan Agner
2016-08-26 14:10   ` Stefano Babic
2016-08-29  0:00     ` Stefan Agner
2016-10-04 13:02       ` Stefano Babic
2016-10-05 21:58         ` Stefan Agner
2016-10-06  7:25           ` Stefano Babic
2016-07-26  6:22 ` [U-Boot] [PATCH 02/10] pinctrl: imx: do not announce driver initialization Stefan Agner
2016-08-01  1:01   ` Simon Glass
2016-07-26  6:22 ` [U-Boot] [PATCH 03/10] arm: dts: imx7: add pinctrl defines Stefan Agner
2016-07-26  6:35   ` Wolfgang Denk
2016-07-26  6:22 ` [U-Boot] [PATCH 04/10] arm: dts: imx7: add basic i.MX 7/Colibri iMX7 device tree Stefan Agner
2016-08-01  1:01   ` Simon Glass
2016-07-26  6:22 ` [U-Boot] [PATCH 05/10] colibri_imx7: remove legancy I2C support Stefan Agner
2016-07-26  6:22 ` [U-Boot] [PATCH 06/10] colibri_imx7: remove legancy UART platform data Stefan Agner
2016-07-26  6:22 ` [U-Boot] [PATCH 07/10] power: pmic: add Ricoh RN5T567 PMIC support Stefan Agner
2016-08-01  1:01   ` Simon Glass
2016-07-26  6:22 ` [U-Boot] [PATCH 08/10] arm: dts: imx7: add Ricoh RN5T567 PMIC node Stefan Agner
2016-07-26  6:22 ` Stefan Agner [this message]
2016-07-26  6:22 ` [U-Boot] [PATCH 10/10] configs: enable device tree for Colibri iMX7 Stefan Agner
2016-08-26 13:25 ` [U-Boot] [PATCH 00/10] mx7: add dt support for Colibri iMX7S/iMX7D Stefano Babic
2016-10-03 19:59   ` Stefan Agner
2016-10-04  8:07     ` Stefano Babic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160726062233.7656-10-stefan@agner.ch \
    --to=stefan@agner.ch \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.