All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] poweroff: add poweroff for mt6323 pmic
@ 2019-11-22 14:32 Frank Wunderlich
  2019-11-23  9:18 ` Frank Wunderlich
  2020-01-10 21:49 ` Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: Frank Wunderlich @ 2019-11-22 14:32 UTC (permalink / raw)
  To: u-boot

this adds poweroff to bananapi r2 / mt7623 / mt6323 pmic

Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
---
 drivers/power/Kconfig  |  7 +++++++
 drivers/power/Makefile |  1 +
 drivers/power/mt6323.c | 37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+)
 create mode 100644 drivers/power/mt6323.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 9495dca33b..0ac906e86d 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -364,4 +364,11 @@ config TWL4030_POWER
 	The TWL4030 in a combination audio CODEC/power management with
 	GPIO and it is commonly used with the OMAP3 family of processors
 
+config POWER_MT6323
+	bool "Poweroff driver for mediatek mt6323"
+	select CMD_POWEROFF
+	help
+	  This adds poweroff driver for mt6323
+	  this pmic is used on mt7623 / Bananapi R2
+
 endmenu
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index dd5bc0dc44..2dcc7bb99d 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -20,3 +20,4 @@ obj-$(CONFIG_DIALOG_POWER) += power_dialog.o
 obj-$(CONFIG_POWER_FSL) += power_fsl.o
 obj-$(CONFIG_POWER_I2C) += power_i2c.o
 obj-$(CONFIG_POWER_SPI) += power_spi.o
+obj-$(CONFIG_POWER_MT6323) += mt6323.o
diff --git a/drivers/power/mt6323.c b/drivers/power/mt6323.c
new file mode 100644
index 0000000000..566be5f39e
--- /dev/null
+++ b/drivers/power/mt6323.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Frank Wunderlich <frank-w@public-files.de>
+ */
+
+#include <common.h>
+#include <command.h>
+#include <asm/io.h>
+
+#define PWRAP_BASE		0x1000d000
+#define PWRAP_WACS2_CMD		0x9c
+
+#define PWRAP_CALC(adr, wdata) ((1 << 31) | (((adr) >> 1) << 16) | (wdata))
+
+#define MT6323_PWRC_BASE	0x8000
+#define RTC_BBPU		0x0000
+#define RTC_BBPU_KEY		(0x43 << 8)
+#define RTC_WRTGR		0x003c
+
+int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	u32 addr, val;
+
+	addr = PWRAP_BASE + PWRAP_WACS2_CMD;
+	val = PWRAP_CALC(MT6323_PWRC_BASE + RTC_BBPU, RTC_BBPU_KEY);
+	writel(val, addr);
+
+	mdelay(10);
+
+	val = PWRAP_CALC(MT6323_PWRC_BASE + RTC_WRTGR, 1);
+	writel(val, addr);
+
+	// wait some time and then print error
+	mdelay(10000);
+	printf("Failed to power off!!!\n");
+	return 1;
+}
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] poweroff: add poweroff for mt6323 pmic
  2019-11-22 14:32 [U-Boot] [PATCH] poweroff: add poweroff for mt6323 pmic Frank Wunderlich
@ 2019-11-23  9:18 ` Frank Wunderlich
  2019-12-22 13:34   ` Aw: " Frank Wunderlich
  2020-01-10 21:49 ` Tom Rini
  1 sibling, 1 reply; 4+ messages in thread
From: Frank Wunderlich @ 2019-11-23  9:18 UTC (permalink / raw)
  To: u-boot

Cc MTK Uboot list and Matthias as MTK Maintainer

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Aw: Re: [U-Boot] [PATCH] poweroff: add poweroff for mt6323 pmic
  2019-11-23  9:18 ` Frank Wunderlich
@ 2019-12-22 13:34   ` Frank Wunderlich
  0 siblings, 0 replies; 4+ messages in thread
From: Frank Wunderlich @ 2019-12-22 13:34 UTC (permalink / raw)
  To: u-boot

any opinions about this Patch?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] poweroff: add poweroff for mt6323 pmic
  2019-11-22 14:32 [U-Boot] [PATCH] poweroff: add poweroff for mt6323 pmic Frank Wunderlich
  2019-11-23  9:18 ` Frank Wunderlich
@ 2020-01-10 21:49 ` Tom Rini
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2020-01-10 21:49 UTC (permalink / raw)
  To: u-boot

On Fri, Nov 22, 2019 at 03:32:24PM +0100, Frank Wunderlich wrote:

> this adds poweroff to bananapi r2 / mt7623 / mt6323 pmic
> 
> Signed-off-by: Frank Wunderlich <frank-w@public-files.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200110/61272a26/attachment.sig>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-10 21:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-22 14:32 [U-Boot] [PATCH] poweroff: add poweroff for mt6323 pmic Frank Wunderlich
2019-11-23  9:18 ` Frank Wunderlich
2019-12-22 13:34   ` Aw: " Frank Wunderlich
2020-01-10 21:49 ` Tom Rini

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.