linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support
@ 2019-04-03  4:57 Keerthy
  2019-04-03  4:57 ` [PATCH v3 1/4] rtc: OMAP: Add support for rtc-only mode Keerthy
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Keerthy @ 2019-04-03  4:57 UTC (permalink / raw)
  To: tony, alexandre.belloni, a.zummo, t-kristo
  Cc: ssantosh, d-gerlach, linux-omap, linux-arm-kernel, linux-rtc, j-keerthy

RTC plus DDR in self-refresh is a power saving mode where in the entire
system including the different voltage rails from PMIC are shutdown except
the ones feeding on to RTC and DDR. DDR is kept in self-refresh hence the
contents are preserved.

RTC ALARM2 is connected to PMIC_EN line. TPS65218 PMIC has granular voltage rail
control. The voltage rail feeding RTC is kept on while the rest of the PMIC
regulators are powered off.

Once the ALARM2 is triggered we enter the mode with DDR in self-refresh
and RTC Ticking. After a predetermined time an RTC ALARM1 triggers
waking up the system. The control goes to bootloader. The bootloader then checks
RTC scratchpad registers to confirm it was an rtc_only wakeup and follows
a different path, configure bare minimal clocks for ddr and then jumps to
the resume address in another RTC scratchpad registers and transfers the
control to Kernel. Kernel then restores the saved context.

The patch series adds rtc-only + DDR mode support am am437x
Tested DS0, rtc+ddr back and forth on am437x-gp-evm board.

This mode works only with u-boot built with am43xx_evm_rtconly_defconfig

Additional patch is needed for omap-gpio save restore which will
come as fixes later.

Hardware Description of this mode can be found here: 

http://www.ti.com/lit/ug/spruhl7h/spruhl7h.pdf Page 2884.

Changes in v3:

  * Exported out omap_rtc_poweroff_program function & removed
    the patch to add a generic rtc interface as it is specific
    to am43 at the moment.

Keerthy (4):
  rtc: OMAP: Add support for rtc-only mode
  arm: mach-omap2: pm33xx: Add support for rtc+ddr in self  refresh mode
  soc: ti: pm33xx: Push the am33xx_push_sram_idle to the top
  soc: ti: pm33xx: AM437X: Add rtc_only with ddr in self-refresh support

 arch/arm/mach-omap2/pm33xx-core.c    |  76 +++++++-
 drivers/rtc/rtc-omap.c               |  49 ++++-
 drivers/soc/ti/Kconfig               |   5 +-
 drivers/soc/ti/pm33xx.c              | 273 ++++++++++++++++++++++-----
 include/linux/platform_data/pm33xx.h |   5 +
 include/linux/rtc/rtc-omap.h         |   7 +
 6 files changed, 354 insertions(+), 61 deletions(-)
 create mode 100644 include/linux/rtc/rtc-omap.h

-- 
2.17.1


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

* [PATCH v3 1/4] rtc: OMAP: Add support for rtc-only mode
  2019-04-03  4:57 [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support Keerthy
@ 2019-04-03  4:57 ` Keerthy
  2019-04-03 14:49   ` Alexandre Belloni
  2019-04-03  4:57 ` [PATCH v3 2/4] arm: mach-omap2: pm33xx: Add support for rtc+ddr in self refresh mode Keerthy
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Keerthy @ 2019-04-03  4:57 UTC (permalink / raw)
  To: tony, alexandre.belloni, a.zummo, t-kristo
  Cc: ssantosh, d-gerlach, linux-omap, linux-arm-kernel, linux-rtc, j-keerthy

Prepare rtc driver for rtc-only with DDR in self-refresh mode.
omap_rtc_power_off now should cater to two features:

1) RTC plus DDR in self-refresh is power a saving mode where in the
entire system including the different voltage rails from PMIC are
shutdown except the ones feeding on to RTC and DDR. DDR is kept in
self-refresh hence the contents are preserved. RTC ALARM2 is connected
to PMIC_EN line once we the ALARM2 is triggered we enter the mode with
DDR in self-refresh and RTC Ticking. After a predetermined time an RTC
ALARM1 triggers waking up the system[1]. The control goes to bootloader.
The bootloader then checks RTC scratchpad registers to confirm it was an
rtc_only wakeup and follows a different path, configure bare minimal
clocks for ddr and then jumps to the resume address in another RTC
scratchpad registers and transfers the control to Kernel. Kernel then
restores the saved context. omap_rtc_power_off_program does the ALARM2
programming part.

     [1] http://www.ti.com/lit/ug/spruhl7h/spruhl7h.pdf Page 2884

2) Power-off: This is usual poweroff mode. omap_rtc_power_off calls the
above omap_rtc_power_off_program function and in addition to that
programs the OMAP_RTC_PMIC_REG for any external wake ups for PMIC like
the pushbutton and shuts off the PMIC.

Hence the split in omap_rtc_power_off.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---

Changes in v3:

  * Exported out omap_rtc_power_off_program to rtc-omap header file

 drivers/rtc/rtc-omap.c       | 49 ++++++++++++++++++++++++++++++------
 include/linux/rtc/rtc-omap.h |  7 ++++++
 2 files changed, 48 insertions(+), 8 deletions(-)
 create mode 100644 include/linux/rtc/rtc-omap.h

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 32994b0dd139..a2941c875a06 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -403,15 +403,12 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
 
 static struct omap_rtc *omap_rtc_power_off_rtc;
 
-/*
- * omap_rtc_poweroff: RTC-controlled power off
- *
- * The RTC can be used to control an external PMIC via the pmic_power_en pin,
- * which can be configured to transition to OFF on ALARM2 events.
- *
- * Called with local interrupts disabled.
+/**
+ * omap_rtc_power_off_program: Set the pmic power off sequence. The RTC
+ * generates pmic_pwr_enable control, which can be used to control an external
+ * PMIC.
  */
-static void omap_rtc_power_off(void)
+int omap_rtc_power_off_program(struct device *dev)
 {
 	struct omap_rtc *rtc = omap_rtc_power_off_rtc;
 	struct rtc_time tm;
@@ -425,6 +422,9 @@ static void omap_rtc_power_off(void)
 	rtc_writel(rtc, OMAP_RTC_PMIC_REG, val | OMAP_RTC_PMIC_POWER_EN_EN);
 
 again:
+	/* Clear any existing ALARM2 event */
+	rtc_writel(rtc, OMAP_RTC_STATUS_REG, OMAP_RTC_STATUS_ALARM2);
+
 	/* set alarm one second from now */
 	omap_rtc_read_time_raw(rtc, &tm);
 	seconds = tm.tm_sec;
@@ -461,6 +461,39 @@ static void omap_rtc_power_off(void)
 
 	rtc->type->lock(rtc);
 
+	return 0;
+}
+EXPORT_SYMBOL(omap_rtc_power_off_program);
+
+/*
+ * omap_rtc_poweroff: RTC-controlled power off
+ *
+ * The RTC can be used to control an external PMIC via the pmic_power_en pin,
+ * which can be configured to transition to OFF on ALARM2 events.
+ *
+ * Notes:
+ * The one-second alarm offset is the shortest offset possible as the alarm
+ * registers must be set before the next timer update and the offset
+ * calculation is too heavy for everything to be done within a single access
+ * period (~15 us).
+ *
+ * Called with local interrupts disabled.
+ */
+static void omap_rtc_power_off(void)
+{
+	struct rtc_device *rtc = omap_rtc_power_off_rtc->rtc;
+	u32 val;
+
+	omap_rtc_power_off_program(rtc->dev.parent);
+
+	/* Set PMIC power enable and EXT_WAKEUP in case PB power on is used */
+	omap_rtc_power_off_rtc->type->unlock(omap_rtc_power_off_rtc);
+	val = rtc_readl(omap_rtc_power_off_rtc, OMAP_RTC_PMIC_REG);
+	val |= OMAP_RTC_PMIC_POWER_EN_EN | OMAP_RTC_PMIC_EXT_WKUP_POL(0) |
+			OMAP_RTC_PMIC_EXT_WKUP_EN(0);
+	rtc_writel(omap_rtc_power_off_rtc, OMAP_RTC_PMIC_REG, val);
+	omap_rtc_power_off_rtc->type->lock(omap_rtc_power_off_rtc);
+
 	/*
 	 * Wait for alarm to trigger (within one second) and external PMIC to
 	 * power off the system. Add a 500 ms margin for external latencies
diff --git a/include/linux/rtc/rtc-omap.h b/include/linux/rtc/rtc-omap.h
new file mode 100644
index 000000000000..9f03a329e63f
--- /dev/null
+++ b/include/linux/rtc/rtc-omap.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _LINUX_RTCOMAP_H_
+#define _LINUX_RTCOMAP_H_
+
+int omap_rtc_power_off_program(struct device *dev);
+#endif /* _LINUX_RTCOMAP_H_ */
-- 
2.17.1


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

* [PATCH v3 2/4] arm: mach-omap2: pm33xx: Add support for rtc+ddr in self  refresh mode
  2019-04-03  4:57 [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support Keerthy
  2019-04-03  4:57 ` [PATCH v3 1/4] rtc: OMAP: Add support for rtc-only mode Keerthy
@ 2019-04-03  4:57 ` Keerthy
  2019-04-03  4:57 ` [PATCH v3 3/4] soc: ti: pm33xx: Move the am33xx_push_sram_idle to the top Keerthy
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Keerthy @ 2019-04-03  4:57 UTC (permalink / raw)
  To: tony, alexandre.belloni, a.zummo, t-kristo
  Cc: ssantosh, d-gerlach, linux-omap, linux-arm-kernel, linux-rtc, j-keerthy

Add support for rtc+ddr in self refresh mode. Add addtional
pm hooks for save/restore and rtc suspend/resume.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---

Changes in v2:

  * White list check of the boards which have HW support got this mode

 arch/arm/mach-omap2/pm33xx-core.c    | 76 +++++++++++++++++++++++++++-
 include/linux/platform_data/pm33xx.h |  5 ++
 2 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/pm33xx-core.c b/arch/arm/mach-omap2/pm33xx-core.c
index 724cf5774a6c..f81cc45a25b1 100644
--- a/arch/arm/mach-omap2/pm33xx-core.c
+++ b/arch/arm/mach-omap2/pm33xx-core.c
@@ -10,6 +10,12 @@
 #include <asm/suspend.h>
 #include <linux/errno.h>
 #include <linux/platform_data/pm33xx.h>
+#include <linux/clk.h>
+#include <linux/platform_data/gpio-omap.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/wkup_m3_ipc.h>
+#include <linux/of.h>
+#include <linux/rtc.h>
 
 #include "cm33xx.h"
 #include "common.h"
@@ -38,6 +44,29 @@ static int am43xx_map_scu(void)
 	return 0;
 }
 
+static int am33xx_check_off_mode_enable(void)
+{
+	if (enable_off_mode)
+		pr_warn("WARNING: This platform does not support off-mode, entering DeepSleep suspend.\n");
+
+	/* off mode not supported on am335x so return 0 always */
+	return 0;
+}
+
+static int am43xx_check_off_mode_enable(void)
+{
+	/*
+	 * Check for am437x-gp-evm which has the right Hardware design to
+	 * support this mode reliably.
+	 */
+	if (of_machine_is_compatible("ti,am437x-gp-evm") && enable_off_mode)
+		return enable_off_mode;
+	else if (enable_off_mode)
+		pr_warn("WARNING: This platform does not support off-mode, entering DeepSleep suspend.\n");
+
+	return 0;
+}
+
 static int amx3_common_init(void)
 {
 	gfx_pwrdm = pwrdm_lookup("gfx_pwrdm");
@@ -139,7 +168,9 @@ static int am43xx_suspend(unsigned int state, int (*fn)(unsigned long),
 	scu_power_mode(scu_base, SCU_PM_POWEROFF);
 	ret = cpu_suspend(args, fn);
 	scu_power_mode(scu_base, SCU_PM_NORMAL);
-	amx3_post_suspend_common();
+
+	if (!am43xx_check_off_mode_enable())
+		amx3_post_suspend_common();
 
 	return ret;
 }
@@ -161,10 +192,48 @@ void __iomem *am43xx_get_rtc_base_addr(void)
 	return omap_hwmod_get_mpu_rt_va(rtc_oh);
 }
 
+static void am43xx_save_context(void)
+{
+}
+
+static void am33xx_save_context(void)
+{
+	omap_intc_save_context();
+}
+
+static void am33xx_restore_context(void)
+{
+	omap_intc_restore_context();
+}
+
+static void am43xx_restore_context(void)
+{
+	/*
+	 * HACK: restore dpll_per_clkdcoldo register contents, to avoid
+	 * breaking suspend-resume
+	 */
+	writel_relaxed(0x0, AM33XX_L4_WK_IO_ADDRESS(0x44df2e14));
+}
+
+static void am43xx_prepare_rtc_suspend(void)
+{
+	omap_hwmod_enable(rtc_oh);
+}
+
+static void am43xx_prepare_rtc_resume(void)
+{
+	omap_hwmod_idle(rtc_oh);
+}
+
 static struct am33xx_pm_platform_data am33xx_ops = {
 	.init = am33xx_suspend_init,
 	.soc_suspend = am33xx_suspend,
 	.get_sram_addrs = amx3_get_sram_addrs,
+	.save_context = am33xx_save_context,
+	.restore_context = am33xx_restore_context,
+	.prepare_rtc_suspend = am43xx_prepare_rtc_suspend,
+	.prepare_rtc_resume = am43xx_prepare_rtc_resume,
+	.check_off_mode_enable = am33xx_check_off_mode_enable,
 	.get_rtc_base_addr = am43xx_get_rtc_base_addr,
 };
 
@@ -172,6 +241,11 @@ static struct am33xx_pm_platform_data am43xx_ops = {
 	.init = am43xx_suspend_init,
 	.soc_suspend = am43xx_suspend,
 	.get_sram_addrs = amx3_get_sram_addrs,
+	.save_context = am43xx_save_context,
+	.restore_context = am43xx_restore_context,
+	.prepare_rtc_suspend = am43xx_prepare_rtc_suspend,
+	.prepare_rtc_resume = am43xx_prepare_rtc_resume,
+	.check_off_mode_enable = am43xx_check_off_mode_enable,
 	.get_rtc_base_addr = am43xx_get_rtc_base_addr,
 };
 
diff --git a/include/linux/platform_data/pm33xx.h b/include/linux/platform_data/pm33xx.h
index fbf5ed73c7cc..dd5971937a64 100644
--- a/include/linux/platform_data/pm33xx.h
+++ b/include/linux/platform_data/pm33xx.h
@@ -51,6 +51,11 @@ struct am33xx_pm_platform_data {
 			       unsigned long args);
 	struct  am33xx_pm_sram_addr *(*get_sram_addrs)(void);
 	void __iomem *(*get_rtc_base_addr)(void);
+	void (*save_context)(void);
+	void (*restore_context)(void);
+	void (*prepare_rtc_suspend)(void);
+	void (*prepare_rtc_resume)(void);
+	int (*check_off_mode_enable)(void);
 };
 
 struct am33xx_pm_sram_data {
-- 
2.17.1


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

* [PATCH v3 3/4] soc: ti: pm33xx: Move the am33xx_push_sram_idle to the top
  2019-04-03  4:57 [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support Keerthy
  2019-04-03  4:57 ` [PATCH v3 1/4] rtc: OMAP: Add support for rtc-only mode Keerthy
  2019-04-03  4:57 ` [PATCH v3 2/4] arm: mach-omap2: pm33xx: Add support for rtc+ddr in self refresh mode Keerthy
@ 2019-04-03  4:57 ` Keerthy
  2019-04-03  4:57 ` [PATCH v3 4/4] soc: ti: pm33xx: AM437X: Add rtc_only with ddr in self-refresh support Keerthy
  2019-04-08 17:26 ` [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support Tony Lindgren
  4 siblings, 0 replies; 11+ messages in thread
From: Keerthy @ 2019-04-03  4:57 UTC (permalink / raw)
  To: tony, alexandre.belloni, a.zummo, t-kristo
  Cc: ssantosh, d-gerlach, linux-omap, linux-arm-kernel, linux-rtc, j-keerthy

Move the am33xx_push_sram_idle function to the top as a preparation
for rtc+ddr mode as the function will be called by multiple functions
currently present before it.

No functional changes.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---

Changes in v3:

  * Enhanced commit description

 drivers/soc/ti/pm33xx.c | 100 ++++++++++++++++++++--------------------
 1 file changed, 50 insertions(+), 50 deletions(-)

diff --git a/drivers/soc/ti/pm33xx.c b/drivers/soc/ti/pm33xx.c
index d0dab323651f..69128993776d 100644
--- a/drivers/soc/ti/pm33xx.c
+++ b/drivers/soc/ti/pm33xx.c
@@ -49,6 +49,56 @@ static u32 sram_suspend_address(unsigned long addr)
 		AMX3_PM_SRAM_SYMBOL_OFFSET(addr));
 }
 
+static int am33xx_push_sram_idle(void)
+{
+	struct am33xx_pm_ro_sram_data ro_sram_data;
+	int ret;
+	u32 table_addr, ro_data_addr;
+	void *copy_addr;
+
+	ro_sram_data.amx3_pm_sram_data_virt = ocmcram_location_data;
+	ro_sram_data.amx3_pm_sram_data_phys =
+		gen_pool_virt_to_phys(sram_pool_data, ocmcram_location_data);
+	ro_sram_data.rtc_base_virt = pm_ops->get_rtc_base_addr();
+
+	/* Save physical address to calculate resume offset during pm init */
+	am33xx_do_wfi_sram_phys = gen_pool_virt_to_phys(sram_pool,
+							ocmcram_location);
+
+	am33xx_do_wfi_sram = sram_exec_copy(sram_pool, (void *)ocmcram_location,
+					    pm_sram->do_wfi,
+					    *pm_sram->do_wfi_sz);
+	if (!am33xx_do_wfi_sram) {
+		dev_err(pm33xx_dev,
+			"PM: %s: am33xx_do_wfi copy to sram failed\n",
+			__func__);
+		return -ENODEV;
+	}
+
+	table_addr =
+		sram_suspend_address((unsigned long)pm_sram->emif_sram_table);
+	ret = ti_emif_copy_pm_function_table(sram_pool, (void *)table_addr);
+	if (ret) {
+		dev_dbg(pm33xx_dev,
+			"PM: %s: EMIF function copy failed\n", __func__);
+		return -EPROBE_DEFER;
+	}
+
+	ro_data_addr =
+		sram_suspend_address((unsigned long)pm_sram->ro_sram_data);
+	copy_addr = sram_exec_copy(sram_pool, (void *)ro_data_addr,
+				   &ro_sram_data,
+				   sizeof(ro_sram_data));
+	if (!copy_addr) {
+		dev_err(pm33xx_dev,
+			"PM: %s: ro_sram_data copy to sram failed\n",
+			__func__);
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
 #ifdef CONFIG_SUSPEND
 static int am33xx_pm_suspend(suspend_state_t suspend_state)
 {
@@ -219,56 +269,6 @@ static int am33xx_pm_alloc_sram(void)
 	return ret;
 }
 
-static int am33xx_push_sram_idle(void)
-{
-	struct am33xx_pm_ro_sram_data ro_sram_data;
-	int ret;
-	u32 table_addr, ro_data_addr;
-	void *copy_addr;
-
-	ro_sram_data.amx3_pm_sram_data_virt = ocmcram_location_data;
-	ro_sram_data.amx3_pm_sram_data_phys =
-		gen_pool_virt_to_phys(sram_pool_data, ocmcram_location_data);
-	ro_sram_data.rtc_base_virt = pm_ops->get_rtc_base_addr();
-
-	/* Save physical address to calculate resume offset during pm init */
-	am33xx_do_wfi_sram_phys = gen_pool_virt_to_phys(sram_pool,
-							ocmcram_location);
-
-	am33xx_do_wfi_sram = sram_exec_copy(sram_pool, (void *)ocmcram_location,
-					    pm_sram->do_wfi,
-					    *pm_sram->do_wfi_sz);
-	if (!am33xx_do_wfi_sram) {
-		dev_err(pm33xx_dev,
-			"PM: %s: am33xx_do_wfi copy to sram failed\n",
-			__func__);
-		return -ENODEV;
-	}
-
-	table_addr =
-		sram_suspend_address((unsigned long)pm_sram->emif_sram_table);
-	ret = ti_emif_copy_pm_function_table(sram_pool, (void *)table_addr);
-	if (ret) {
-		dev_dbg(pm33xx_dev,
-			"PM: %s: EMIF function copy failed\n", __func__);
-		return -EPROBE_DEFER;
-	}
-
-	ro_data_addr =
-		sram_suspend_address((unsigned long)pm_sram->ro_sram_data);
-	copy_addr = sram_exec_copy(sram_pool, (void *)ro_data_addr,
-				   &ro_sram_data,
-				   sizeof(ro_sram_data));
-	if (!copy_addr) {
-		dev_err(pm33xx_dev,
-			"PM: %s: ro_sram_data copy to sram failed\n",
-			__func__);
-		return -ENODEV;
-	}
-
-	return 0;
-}
-
 static int am33xx_pm_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-- 
2.17.1


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

* [PATCH v3 4/4] soc: ti: pm33xx: AM437X: Add rtc_only with ddr in self-refresh support
  2019-04-03  4:57 [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support Keerthy
                   ` (2 preceding siblings ...)
  2019-04-03  4:57 ` [PATCH v3 3/4] soc: ti: pm33xx: Move the am33xx_push_sram_idle to the top Keerthy
@ 2019-04-03  4:57 ` Keerthy
  2019-04-08 17:26 ` [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support Tony Lindgren
  4 siblings, 0 replies; 11+ messages in thread
From: Keerthy @ 2019-04-03  4:57 UTC (permalink / raw)
  To: tony, alexandre.belloni, a.zummo, t-kristo
  Cc: ssantosh, d-gerlach, linux-omap, linux-arm-kernel, linux-rtc, j-keerthy

During RTC-only suspend, power is lost to the wkup domain, so we need to
save and restore the state of that domain. We also need to store some
information within the RTC registers so that u-boot can do the right thing
at powerup.

The state is entered by getting the RTC to bring the pmic_power_en line low
which will instruct the PMIC to disable the appropriate power rails after
putting DDR into self-refresh mode. To bring pmic_power_en low, we need to
get an ALARM2 event. Since we are running from SRAM at that point, it means
calculating what the next second is (via ASM) and programming that into the
RTC. This patch also adds support for wake up source detection.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
---

Changes in v3:

  * Call the omap_rtc_power_off_program function instead of calling
    rtc inteface function.

 drivers/soc/ti/Kconfig  |   5 +-
 drivers/soc/ti/pm33xx.c | 191 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 185 insertions(+), 11 deletions(-)

diff --git a/drivers/soc/ti/Kconfig b/drivers/soc/ti/Kconfig
index be4570baad96..57960e92ebe0 100644
--- a/drivers/soc/ti/Kconfig
+++ b/drivers/soc/ti/Kconfig
@@ -45,11 +45,12 @@ config KEYSTONE_NAVIGATOR_DMA
 config AMX3_PM
 	tristate "AMx3 Power Management"
 	depends on SOC_AM33XX || SOC_AM43XX
-	depends on WKUP_M3_IPC && TI_EMIF_SRAM && SRAM
+	depends on WKUP_M3_IPC && TI_EMIF_SRAM && SRAM && RTC_DRV_OMAP
 	help
 	  Enable power management on AM335x and AM437x. Required for suspend to mem
 	  and standby states on both AM335x and AM437x platforms and for deeper cpuidle
-	  c-states on AM335x.
+	  c-states on AM335x. Also required for rtc and ddr in self-refresh low
+	  power mode on AM437x platforms.
 
 config WKUP_M3_IPC
 	tristate "TI AMx3 Wkup-M3 IPC Driver"
diff --git a/drivers/soc/ti/pm33xx.c b/drivers/soc/ti/pm33xx.c
index 69128993776d..fc5802ccb1c0 100644
--- a/drivers/soc/ti/pm33xx.c
+++ b/drivers/soc/ti/pm33xx.c
@@ -6,6 +6,7 @@
  *	Vaibhav Bedia, Dave Gerlach
  */
 
+#include <linux/clk.h>
 #include <linux/cpu.h>
 #include <linux/err.h>
 #include <linux/genalloc.h>
@@ -13,9 +14,12 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/nvmem-consumer.h>
 #include <linux/of.h>
 #include <linux/platform_data/pm33xx.h>
 #include <linux/platform_device.h>
+#include <linux/rtc.h>
+#include <linux/rtc/rtc-omap.h>
 #include <linux/sizes.h>
 #include <linux/sram.h>
 #include <linux/suspend.h>
@@ -29,20 +33,47 @@
 #define AMX3_PM_SRAM_SYMBOL_OFFSET(sym) ((unsigned long)(sym) - \
 					 (unsigned long)pm_sram->do_wfi)
 
+#define RTC_SCRATCH_RESUME_REG	0
+#define RTC_SCRATCH_MAGIC_REG	1
+#define RTC_REG_BOOT_MAGIC	0x8cd0 /* RTC */
+#define GIC_INT_SET_PENDING_BASE 0x200
+#define AM43XX_GIC_DIST_BASE	0x48241000
+
+static u32 rtc_magic_val;
+
 static int (*am33xx_do_wfi_sram)(unsigned long unused);
 static phys_addr_t am33xx_do_wfi_sram_phys;
 
 static struct gen_pool *sram_pool, *sram_pool_data;
 static unsigned long ocmcram_location, ocmcram_location_data;
 
+static struct rtc_device *omap_rtc;
+static void __iomem *gic_dist_base;
+
 static struct am33xx_pm_platform_data *pm_ops;
 static struct am33xx_pm_sram_addr *pm_sram;
 
 static struct device *pm33xx_dev;
 static struct wkup_m3_ipc *m3_ipc;
 
+#ifdef CONFIG_SUSPEND
+static int rtc_only_idle;
+static int retrigger_irq;
 static unsigned long suspend_wfi_flags;
 
+static struct wkup_m3_wakeup_src wakeup_src = {.irq_nr = 0,
+	.src = "Unknown",
+};
+
+static struct wkup_m3_wakeup_src rtc_alarm_wakeup = {
+	.irq_nr = 108, .src = "RTC Alarm",
+};
+
+static struct wkup_m3_wakeup_src rtc_ext_wakeup = {
+	.irq_nr = 0, .src = "Ext wakeup",
+};
+#endif
+
 static u32 sram_suspend_address(unsigned long addr)
 {
 	return ((unsigned long)am33xx_do_wfi_sram +
@@ -99,13 +130,65 @@ static int am33xx_push_sram_idle(void)
 	return 0;
 }
 
+static int __init am43xx_map_gic(void)
+{
+	gic_dist_base = ioremap(AM43XX_GIC_DIST_BASE, SZ_4K);
+
+	if (!gic_dist_base)
+		return -ENOMEM;
+
+	return 0;
+}
+
 #ifdef CONFIG_SUSPEND
+struct wkup_m3_wakeup_src rtc_wake_src(void)
+{
+	u32 i;
+
+	i = __raw_readl(pm_ops->get_rtc_base_addr() + 0x44) & 0x40;
+
+	if (i) {
+		retrigger_irq = rtc_alarm_wakeup.irq_nr;
+		return rtc_alarm_wakeup;
+	}
+
+	retrigger_irq = rtc_ext_wakeup.irq_nr;
+
+	return rtc_ext_wakeup;
+}
+
+int am33xx_rtc_only_idle(unsigned long wfi_flags)
+{
+	omap_rtc_power_off_program(&omap_rtc->dev);
+	am33xx_do_wfi_sram(wfi_flags);
+	return 0;
+}
+
 static int am33xx_pm_suspend(suspend_state_t suspend_state)
 {
 	int i, ret = 0;
 
-	ret = pm_ops->soc_suspend((unsigned long)suspend_state,
-				  am33xx_do_wfi_sram, suspend_wfi_flags);
+	if (suspend_state == PM_SUSPEND_MEM &&
+	    pm_ops->check_off_mode_enable()) {
+		pm_ops->prepare_rtc_suspend();
+		pm_ops->save_context();
+		suspend_wfi_flags |= WFI_FLAG_RTC_ONLY;
+		clk_save_context();
+		ret = pm_ops->soc_suspend(suspend_state, am33xx_rtc_only_idle,
+					  suspend_wfi_flags);
+
+		suspend_wfi_flags &= ~WFI_FLAG_RTC_ONLY;
+
+		if (!ret) {
+			clk_restore_context();
+			pm_ops->restore_context();
+			m3_ipc->ops->set_rtc_only(m3_ipc);
+			am33xx_push_sram_idle();
+		}
+	} else {
+		ret = pm_ops->soc_suspend(suspend_state, am33xx_do_wfi_sram,
+					  suspend_wfi_flags);
+	}
 
 	if (ret) {
 		dev_err(pm33xx_dev, "PM: Kernel suspend failure\n");
@@ -127,8 +210,20 @@ static int am33xx_pm_suspend(suspend_state_t suspend_state)
 				"PM: CM3 returned unknown result = %d\n", i);
 			ret = -1;
 		}
+
+		/* print the wakeup reason */
+		if (rtc_only_idle) {
+			wakeup_src = rtc_wake_src();
+			pr_info("PM: Wakeup source %s\n", wakeup_src.src);
+		} else {
+			pr_info("PM: Wakeup source %s\n",
+				m3_ipc->ops->request_wake_src(m3_ipc));
+		}
 	}
 
+	if (suspend_state == PM_SUSPEND_MEM && pm_ops->check_off_mode_enable())
+		pm_ops->prepare_rtc_resume();
+
 	return ret;
 }
 
@@ -151,6 +246,18 @@ static int am33xx_pm_enter(suspend_state_t suspend_state)
 static int am33xx_pm_begin(suspend_state_t state)
 {
 	int ret = -EINVAL;
+	struct nvmem_device *nvmem;
+
+	if (state == PM_SUSPEND_MEM && pm_ops->check_off_mode_enable()) {
+		nvmem = devm_nvmem_device_get(&omap_rtc->dev,
+					      "omap_rtc_scratch0");
+		if (nvmem)
+			nvmem_device_write(nvmem, RTC_SCRATCH_MAGIC_REG * 4, 4,
+					   (void *)&rtc_magic_val);
+		rtc_only_idle = 1;
+	} else {
+		rtc_only_idle = 0;
+	}
 
 	switch (state) {
 	case PM_SUSPEND_MEM:
@@ -166,7 +273,28 @@ static int am33xx_pm_begin(suspend_state_t state)
 
 static void am33xx_pm_end(void)
 {
+	u32 val = 0;
+	struct nvmem_device *nvmem;
+
+	nvmem = devm_nvmem_device_get(&omap_rtc->dev, "omap_rtc_scratch0");
 	m3_ipc->ops->finish_low_power(m3_ipc);
+	if (rtc_only_idle) {
+		if (retrigger_irq)
+			/*
+			 * 32 bits of Interrupt Set-Pending correspond to 32
+			 * 32 interrupts. Compute the bit offset of the
+			 * Interrupt and set that particular bit
+			 * Compute the register offset by dividing interrupt
+			 * number by 32 and mutiplying by 4
+			 */
+			writel_relaxed(1 << (retrigger_irq & 31),
+				       gic_dist_base + GIC_INT_SET_PENDING_BASE
+				       + retrigger_irq / 32 * 4);
+			nvmem_device_write(nvmem, RTC_SCRATCH_MAGIC_REG * 4, 4,
+					   (void *)&val);
+	}
+
+	rtc_only_idle = 0;
 }
 
 static int am33xx_pm_valid(suspend_state_t state)
@@ -269,6 +397,42 @@ static int am33xx_pm_alloc_sram(void)
 	return ret;
 }
 
+static int am33xx_pm_rtc_setup(void)
+{
+	struct device_node *np;
+	unsigned long val = 0;
+	struct nvmem_device *nvmem;
+
+	np = of_find_node_by_name(NULL, "rtc");
+
+	if (of_device_is_available(np)) {
+		omap_rtc = rtc_class_open("rtc0");
+		if (!omap_rtc) {
+			pr_warn("PM: rtc0 not available");
+			return -EPROBE_DEFER;
+		}
+
+		nvmem = devm_nvmem_device_get(&omap_rtc->dev,
+					      "omap_rtc_scratch0");
+		if (nvmem) {
+			nvmem_device_read(nvmem, RTC_SCRATCH_MAGIC_REG * 4,
+					  4, (void *)&rtc_magic_val);
+			if ((rtc_magic_val & 0xffff) != RTC_REG_BOOT_MAGIC)
+				pr_warn("PM: bootloader does not support rtc-only!\n");
+
+			nvmem_device_write(nvmem, RTC_SCRATCH_MAGIC_REG * 4,
+					   4, (void *)&val);
+			val = pm_sram->resume_address;
+			nvmem_device_write(nvmem, RTC_SCRATCH_RESUME_REG * 4,
+					   4, (void *)&val);
+		}
+	} else {
+		pr_warn("PM: no-rtc available, rtc-only mode disabled.\n");
+	}
+
+	return 0;
+}
+
 static int am33xx_pm_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -284,34 +448,42 @@ static int am33xx_pm_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	ret = am43xx_map_gic();
+	if (ret) {
+		pr_err("PM: Could not ioremap GIC base\n");
+		return ret;
+	}
+
 	pm_sram = pm_ops->get_sram_addrs();
 	if (!pm_sram) {
 		dev_err(dev, "PM: Cannot get PM asm function addresses!!\n");
 		return -ENODEV;
 	}
 
+	m3_ipc = wkup_m3_ipc_get();
+	if (!m3_ipc) {
+		pr_err("PM: Cannot get wkup_m3_ipc handle\n");
+		return -EPROBE_DEFER;
+	}
+
 	pm33xx_dev = dev;
 
 	ret = am33xx_pm_alloc_sram();
 	if (ret)
 		return ret;
 
-	ret = am33xx_push_sram_idle();
+	ret = am33xx_pm_rtc_setup();
 	if (ret)
 		goto err_free_sram;
 
-	m3_ipc = wkup_m3_ipc_get();
-	if (!m3_ipc) {
-		dev_dbg(dev, "PM: Cannot get wkup_m3_ipc handle\n");
-		ret = -EPROBE_DEFER;
+	ret = am33xx_push_sram_idle();
+	if (ret)
 		goto err_free_sram;
-	}
 
 	am33xx_pm_set_ipc_ops();
 
 #ifdef CONFIG_SUSPEND
 	suspend_set_ops(&am33xx_pm_ops);
-#endif /* CONFIG_SUSPEND */
 
 	/*
 	 * For a system suspend we must flush the caches, we want
@@ -323,6 +495,7 @@ static int am33xx_pm_probe(struct platform_device *pdev)
 	suspend_wfi_flags |= WFI_FLAG_SELF_REFRESH;
 	suspend_wfi_flags |= WFI_FLAG_SAVE_EMIF;
 	suspend_wfi_flags |= WFI_FLAG_WAKE_M3;
+#endif /* CONFIG_SUSPEND */
 
 	ret = pm_ops->init();
 	if (ret) {
-- 
2.17.1


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

* Re: [PATCH v3 1/4] rtc: OMAP: Add support for rtc-only mode
  2019-04-03  4:57 ` [PATCH v3 1/4] rtc: OMAP: Add support for rtc-only mode Keerthy
@ 2019-04-03 14:49   ` Alexandre Belloni
  0 siblings, 0 replies; 11+ messages in thread
From: Alexandre Belloni @ 2019-04-03 14:49 UTC (permalink / raw)
  To: Keerthy
  Cc: tony, a.zummo, t-kristo, ssantosh, d-gerlach, linux-omap,
	linux-arm-kernel, linux-rtc

On 03/04/2019 10:27:39+0530, Keerthy wrote:
> Prepare rtc driver for rtc-only with DDR in self-refresh mode.
> omap_rtc_power_off now should cater to two features:
> 
> 1) RTC plus DDR in self-refresh is power a saving mode where in the
> entire system including the different voltage rails from PMIC are
> shutdown except the ones feeding on to RTC and DDR. DDR is kept in
> self-refresh hence the contents are preserved. RTC ALARM2 is connected
> to PMIC_EN line once we the ALARM2 is triggered we enter the mode with
> DDR in self-refresh and RTC Ticking. After a predetermined time an RTC
> ALARM1 triggers waking up the system[1]. The control goes to bootloader.
> The bootloader then checks RTC scratchpad registers to confirm it was an
> rtc_only wakeup and follows a different path, configure bare minimal
> clocks for ddr and then jumps to the resume address in another RTC
> scratchpad registers and transfers the control to Kernel. Kernel then
> restores the saved context. omap_rtc_power_off_program does the ALARM2
> programming part.
> 
>      [1] http://www.ti.com/lit/ug/spruhl7h/spruhl7h.pdf Page 2884
> 
> 2) Power-off: This is usual poweroff mode. omap_rtc_power_off calls the
> above omap_rtc_power_off_program function and in addition to that
> programs the OMAP_RTC_PMIC_REG for any external wake ups for PMIC like
> the pushbutton and shuts off the PMIC.
> 
> Hence the split in omap_rtc_power_off.
> 
> Signed-off-by: Keerthy <j-keerthy@ti.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
> 
> Changes in v3:
> 
>   * Exported out omap_rtc_power_off_program to rtc-omap header file
> 
>  drivers/rtc/rtc-omap.c       | 49 ++++++++++++++++++++++++++++++------
>  include/linux/rtc/rtc-omap.h |  7 ++++++
>  2 files changed, 48 insertions(+), 8 deletions(-)
>  create mode 100644 include/linux/rtc/rtc-omap.h
> 
> diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
> index 32994b0dd139..a2941c875a06 100644
> --- a/drivers/rtc/rtc-omap.c
> +++ b/drivers/rtc/rtc-omap.c
> @@ -403,15 +403,12 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
>  
>  static struct omap_rtc *omap_rtc_power_off_rtc;
>  
> -/*
> - * omap_rtc_poweroff: RTC-controlled power off
> - *
> - * The RTC can be used to control an external PMIC via the pmic_power_en pin,
> - * which can be configured to transition to OFF on ALARM2 events.
> - *
> - * Called with local interrupts disabled.
> +/**
> + * omap_rtc_power_off_program: Set the pmic power off sequence. The RTC
> + * generates pmic_pwr_enable control, which can be used to control an external
> + * PMIC.
>   */
> -static void omap_rtc_power_off(void)
> +int omap_rtc_power_off_program(struct device *dev)
>  {
>  	struct omap_rtc *rtc = omap_rtc_power_off_rtc;
>  	struct rtc_time tm;
> @@ -425,6 +422,9 @@ static void omap_rtc_power_off(void)
>  	rtc_writel(rtc, OMAP_RTC_PMIC_REG, val | OMAP_RTC_PMIC_POWER_EN_EN);
>  
>  again:
> +	/* Clear any existing ALARM2 event */
> +	rtc_writel(rtc, OMAP_RTC_STATUS_REG, OMAP_RTC_STATUS_ALARM2);
> +
>  	/* set alarm one second from now */
>  	omap_rtc_read_time_raw(rtc, &tm);
>  	seconds = tm.tm_sec;
> @@ -461,6 +461,39 @@ static void omap_rtc_power_off(void)
>  
>  	rtc->type->lock(rtc);
>  
> +	return 0;
> +}
> +EXPORT_SYMBOL(omap_rtc_power_off_program);
> +
> +/*
> + * omap_rtc_poweroff: RTC-controlled power off
> + *
> + * The RTC can be used to control an external PMIC via the pmic_power_en pin,
> + * which can be configured to transition to OFF on ALARM2 events.
> + *
> + * Notes:
> + * The one-second alarm offset is the shortest offset possible as the alarm
> + * registers must be set before the next timer update and the offset
> + * calculation is too heavy for everything to be done within a single access
> + * period (~15 us).
> + *
> + * Called with local interrupts disabled.
> + */
> +static void omap_rtc_power_off(void)
> +{
> +	struct rtc_device *rtc = omap_rtc_power_off_rtc->rtc;
> +	u32 val;
> +
> +	omap_rtc_power_off_program(rtc->dev.parent);
> +
> +	/* Set PMIC power enable and EXT_WAKEUP in case PB power on is used */
> +	omap_rtc_power_off_rtc->type->unlock(omap_rtc_power_off_rtc);
> +	val = rtc_readl(omap_rtc_power_off_rtc, OMAP_RTC_PMIC_REG);
> +	val |= OMAP_RTC_PMIC_POWER_EN_EN | OMAP_RTC_PMIC_EXT_WKUP_POL(0) |
> +			OMAP_RTC_PMIC_EXT_WKUP_EN(0);
> +	rtc_writel(omap_rtc_power_off_rtc, OMAP_RTC_PMIC_REG, val);
> +	omap_rtc_power_off_rtc->type->lock(omap_rtc_power_off_rtc);
> +
>  	/*
>  	 * Wait for alarm to trigger (within one second) and external PMIC to
>  	 * power off the system. Add a 500 ms margin for external latencies
> diff --git a/include/linux/rtc/rtc-omap.h b/include/linux/rtc/rtc-omap.h
> new file mode 100644
> index 000000000000..9f03a329e63f
> --- /dev/null
> +++ b/include/linux/rtc/rtc-omap.h
> @@ -0,0 +1,7 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef _LINUX_RTCOMAP_H_
> +#define _LINUX_RTCOMAP_H_
> +
> +int omap_rtc_power_off_program(struct device *dev);
> +#endif /* _LINUX_RTCOMAP_H_ */
> -- 
> 2.17.1
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support
  2019-04-03  4:57 [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support Keerthy
                   ` (3 preceding siblings ...)
  2019-04-03  4:57 ` [PATCH v3 4/4] soc: ti: pm33xx: AM437X: Add rtc_only with ddr in self-refresh support Keerthy
@ 2019-04-08 17:26 ` Tony Lindgren
  2019-04-08 17:43   ` Tony Lindgren
  4 siblings, 1 reply; 11+ messages in thread
From: Tony Lindgren @ 2019-04-08 17:26 UTC (permalink / raw)
  To: Keerthy
  Cc: alexandre.belloni, a.zummo, t-kristo, ssantosh, d-gerlach,
	linux-omap, linux-arm-kernel, linux-rtc

* Keerthy <j-keerthy@ti.com> [190402 21:57]:
> RTC plus DDR in self-refresh is a power saving mode where in the entire
> system including the different voltage rails from PMIC are shutdown except
> the ones feeding on to RTC and DDR. DDR is kept in self-refresh hence the
> contents are preserved.
> 
> RTC ALARM2 is connected to PMIC_EN line. TPS65218 PMIC has granular voltage rail
> control. The voltage rail feeding RTC is kept on while the rest of the PMIC
> regulators are powered off.
> 
> Once the ALARM2 is triggered we enter the mode with DDR in self-refresh
> and RTC Ticking. After a predetermined time an RTC ALARM1 triggers
> waking up the system. The control goes to bootloader. The bootloader then checks
> RTC scratchpad registers to confirm it was an rtc_only wakeup and follows
> a different path, configure bare minimal clocks for ddr and then jumps to
> the resume address in another RTC scratchpad registers and transfers the
> control to Kernel. Kernel then restores the saved context.
> 
> The patch series adds rtc-only + DDR mode support am am437x
> Tested DS0, rtc+ddr back and forth on am437x-gp-evm board.
> 
> This mode works only with u-boot built with am43xx_evm_rtconly_defconfig
> 
> Additional patch is needed for omap-gpio save restore which will
> come as fixes later.
> 
> Hardware Description of this mode can be found here: 
> 
> http://www.ti.com/lit/ug/spruhl7h/spruhl7h.pdf Page 2884.
>
> Changes in v3:
> 
>   * Exported out omap_rtc_poweroff_program function & removed
>     the patch to add a generic rtc interface as it is specific
>     to am43 at the moment.

Thanks I'll be applying this series into omap-for-v5.2/am4-pm
today.

Regards,

Tony

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

* Re: [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support
  2019-04-08 17:26 ` [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support Tony Lindgren
@ 2019-04-08 17:43   ` Tony Lindgren
  2019-04-09  3:59     ` Keerthy
  0 siblings, 1 reply; 11+ messages in thread
From: Tony Lindgren @ 2019-04-08 17:43 UTC (permalink / raw)
  To: Keerthy
  Cc: alexandre.belloni, a.zummo, t-kristo, ssantosh, d-gerlach,
	linux-omap, linux-arm-kernel, linux-rtc

* Tony Lindgren <tony@atomide.com> [190408 10:26]:
> * Keerthy <j-keerthy@ti.com> [190402 21:57]:
> > Changes in v3:
> > 
> >   * Exported out omap_rtc_poweroff_program function & removed
> >     the patch to add a generic rtc interface as it is specific
> >     to am43 at the moment.
> 
> Thanks I'll be applying this series into omap-for-v5.2/am4-pm
> today.

Sorry correction for the branch named above. I noticed a build
warning and folded in the following fix. We need to return
-EINVAL if tm2bcd() fails like we do elsewhere in the driver.

So I just pushed out a new branch omap-for-v5.2/am4-pm-v2.
Please just ignore the earlier branch omap-for-v5.2/am4-pm.

Regards,

Tony

8< --------------------
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -447,7 +447,7 @@ int omap_rtc_power_off_program(struct device *dev)
 	if (tm2bcd(&tm) < 0) {
 		dev_err(&rtc->rtc->dev, "power off failed\n");
 		rtc->type->lock(rtc);
-		return;
+		return -EINVAL;
 	}
 
 	rtc_wait_not_busy(rtc);

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

* Re: [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support
  2019-04-08 17:43   ` Tony Lindgren
@ 2019-04-09  3:59     ` Keerthy
  2019-04-09  5:21       ` Keerthy
  0 siblings, 1 reply; 11+ messages in thread
From: Keerthy @ 2019-04-09  3:59 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: alexandre.belloni, a.zummo, t-kristo, ssantosh, d-gerlach,
	linux-omap, linux-arm-kernel, linux-rtc



On 08/04/19 11:13 PM, Tony Lindgren wrote:
> * Tony Lindgren <tony@atomide.com> [190408 10:26]:
>> * Keerthy <j-keerthy@ti.com> [190402 21:57]:
>>> Changes in v3:
>>>
>>>    * Exported out omap_rtc_poweroff_program function & removed
>>>      the patch to add a generic rtc interface as it is specific
>>>      to am43 at the moment.
>>
>> Thanks I'll be applying this series into omap-for-v5.2/am4-pm
>> today.
> 
> Sorry correction for the branch named above. I noticed a build
> warning and folded in the following fix. We need to return
> -EINVAL if tm2bcd() fails like we do elsewhere in the driver.
> 
> So I just pushed out a new branch omap-for-v5.2/am4-pm-v2.
> Please just ignore the earlier branch omap-for-v5.2/am4-pm.

Thanks Tony!

> 
> Regards,
> 
> Tony
> 
> 8< --------------------
> diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
> --- a/drivers/rtc/rtc-omap.c
> +++ b/drivers/rtc/rtc-omap.c
> @@ -447,7 +447,7 @@ int omap_rtc_power_off_program(struct device *dev)
>   	if (tm2bcd(&tm) < 0) {
>   		dev_err(&rtc->rtc->dev, "power off failed\n");
>   		rtc->type->lock(rtc);
> -		return;
> +		return -EINVAL;
>   	}
>   
>   	rtc_wait_not_busy(rtc);
> 

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

* Re: [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support
  2019-04-09  3:59     ` Keerthy
@ 2019-04-09  5:21       ` Keerthy
  2019-04-09 14:20         ` Tony Lindgren
  0 siblings, 1 reply; 11+ messages in thread
From: Keerthy @ 2019-04-09  5:21 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: alexandre.belloni, a.zummo, t-kristo, ssantosh, d-gerlach,
	linux-omap, linux-arm-kernel, linux-rtc



On 09/04/19 9:29 AM, Keerthy wrote:
> 
> 
> On 08/04/19 11:13 PM, Tony Lindgren wrote:
>> * Tony Lindgren <tony@atomide.com> [190408 10:26]:
>>> * Keerthy <j-keerthy@ti.com> [190402 21:57]:
>>>> Changes in v3:
>>>>
>>>>    * Exported out omap_rtc_poweroff_program function & removed
>>>>      the patch to add a generic rtc interface as it is specific
>>>>      to am43 at the moment.
>>>
>>> Thanks I'll be applying this series into omap-for-v5.2/am4-pm
>>> today.
>>
>> Sorry correction for the branch named above. I noticed a build
>> warning and folded in the following fix. We need to return
>> -EINVAL if tm2bcd() fails like we do elsewhere in the driver.
>>
>> So I just pushed out a new branch omap-for-v5.2/am4-pm-v2.
>> Please just ignore the earlier branch omap-for-v5.2/am4-pm.
> 
> Thanks Tony!

Tony,

Seems like your for-next is a little behind. Hence you noticed the 
compilation error which i did not notice. The rtc driver patch i 
formatted from your for-next branch does not apply cleanly on linux-next 
as there are more patches already applied by Alexandre on next.

So the patch you made to return -EINVAL is no longer needed on latest next.

Thanks,
Keerthy
> 
>>
>> Regards,
>>
>> Tony
>>
>> 8< --------------------
>> diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
>> --- a/drivers/rtc/rtc-omap.c
>> +++ b/drivers/rtc/rtc-omap.c
>> @@ -447,7 +447,7 @@ int omap_rtc_power_off_program(struct device *dev)
>>       if (tm2bcd(&tm) < 0) {
>>           dev_err(&rtc->rtc->dev, "power off failed\n");
>>           rtc->type->lock(rtc);
>> -        return;
>> +        return -EINVAL;
>>       }
>>       rtc_wait_not_busy(rtc);
>>

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

* Re: [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support
  2019-04-09  5:21       ` Keerthy
@ 2019-04-09 14:20         ` Tony Lindgren
  0 siblings, 0 replies; 11+ messages in thread
From: Tony Lindgren @ 2019-04-09 14:20 UTC (permalink / raw)
  To: Keerthy
  Cc: alexandre.belloni, a.zummo, t-kristo, ssantosh, d-gerlach,
	linux-omap, linux-arm-kernel, linux-rtc

* Keerthy <j-keerthy@ti.com> [190409 05:21]:
> 
> 
> On 09/04/19 9:29 AM, Keerthy wrote:
> > 
> > 
> > On 08/04/19 11:13 PM, Tony Lindgren wrote:
> > > * Tony Lindgren <tony@atomide.com> [190408 10:26]:
> > > > * Keerthy <j-keerthy@ti.com> [190402 21:57]:
> > > > > Changes in v3:
> > > > > 
> > > > >    * Exported out omap_rtc_poweroff_program function & removed
> > > > >      the patch to add a generic rtc interface as it is specific
> > > > >      to am43 at the moment.
> > > > 
> > > > Thanks I'll be applying this series into omap-for-v5.2/am4-pm
> > > > today.
> > > 
> > > Sorry correction for the branch named above. I noticed a build
> > > warning and folded in the following fix. We need to return
> > > -EINVAL if tm2bcd() fails like we do elsewhere in the driver.
> > > 
> > > So I just pushed out a new branch omap-for-v5.2/am4-pm-v2.
> > > Please just ignore the earlier branch omap-for-v5.2/am4-pm.
> > 
> > Thanks Tony!
> 
> Tony,
> 
> Seems like your for-next is a little behind. Hence you noticed the
> compilation error which i did not notice. The rtc driver patch i formatted
> from your for-next branch does not apply cleanly on linux-next as there are
> more patches already applied by Alexandre on next.
> 
> So the patch you made to return -EINVAL is no longer needed on latest next.

Yeah I noticed there's now a minor conflict with the rtc
tree changes, that's trivial to resolve though.

Regards,

Tony

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

end of thread, other threads:[~2019-04-09 14:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-03  4:57 [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support Keerthy
2019-04-03  4:57 ` [PATCH v3 1/4] rtc: OMAP: Add support for rtc-only mode Keerthy
2019-04-03 14:49   ` Alexandre Belloni
2019-04-03  4:57 ` [PATCH v3 2/4] arm: mach-omap2: pm33xx: Add support for rtc+ddr in self refresh mode Keerthy
2019-04-03  4:57 ` [PATCH v3 3/4] soc: ti: pm33xx: Move the am33xx_push_sram_idle to the top Keerthy
2019-04-03  4:57 ` [PATCH v3 4/4] soc: ti: pm33xx: AM437X: Add rtc_only with ddr in self-refresh support Keerthy
2019-04-08 17:26 ` [PATCH v3 0/4] AM437x: Add rtc-only + DDR mode support Tony Lindgren
2019-04-08 17:43   ` Tony Lindgren
2019-04-09  3:59     ` Keerthy
2019-04-09  5:21       ` Keerthy
2019-04-09 14:20         ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).