diff mbox series

[3/3] ARM: rmobile: Implement PMIC reset on V2H Blanche

Message ID 20200321161049.64558-3-marek.vasut+renesas@gmail.com
State New
Headers show
Series [1/3] ARM: dts: rmobile: Add IIC3 node on Gen2 R8A7792 V2H | expand

Commit Message

Marek Vasut March 21, 2020, 4:10 p.m. UTC
Add code to reset the board through PMIC, by writing the required
PMIC registers in the CPU reset handler.

Signed-off-by: Marek Vasut <marek.vasut+renesas at gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
---
 board/renesas/blanche/blanche.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/board/renesas/blanche/blanche.c b/board/renesas/blanche/blanche.c
index 7232370d6f..0807967d6e 100644
--- a/board/renesas/blanche/blanche.c
+++ b/board/renesas/blanche/blanche.c
@@ -355,4 +355,23 @@  int dram_init_banksize(void)
 
 void reset_cpu(ulong addr)
 {
+	struct udevice *dev;
+	const u8 pmic_bus = 6;
+	const u8 pmic_addr = 0x58;
+	u8 data;
+	int ret;
+
+	ret = i2c_get_chip_for_busnum(pmic_bus, pmic_addr, 1, &dev);
+	if (ret)
+		hang();
+
+	ret = dm_i2c_read(dev, 0x13, &data, 1);
+	if (ret)
+		hang();
+
+	data |= BIT(1);
+
+	ret = dm_i2c_write(dev, 0x13, &data, 1);
+	if (ret)
+		hang();
 }