Skip to content

Commit 2152fbb

Browse files
committed
soc: ti: pm33xx: Simplify RTC usage to prepare to drop platform data
We must re-enable the RTC module clock enabled in RTC+DDR suspend, and pm33xx has been using platform data callbacks for that. Looks like for retention suspend the RTC module clock must not be re-enabled. To remove the legacy platform data callbacks, and eventually be able to drop the RTC legacy platform data, let's manage the RTC module clock and register range directly in pm33xx. Acked-by: Santosh Shilimkar <ssantosh@kernel.org> Signed-off-by: Tony Lindgren <tony@atomide.com>
1 parent 9123e3a commit 2152fbb

3 files changed

Lines changed: 42 additions & 33 deletions

File tree

arch/arm/mach-omap2/pm33xx-core.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "control.h"
2626
#include "clockdomain.h"
2727
#include "iomap.h"
28-
#include "omap_hwmod.h"
2928
#include "pm.h"
3029
#include "powerdomain.h"
3130
#include "prm33xx.h"
@@ -36,7 +35,6 @@
3635
static struct powerdomain *cefuse_pwrdm, *gfx_pwrdm, *per_pwrdm, *mpu_pwrdm;
3736
static struct clockdomain *gfx_l4ls_clkdm;
3837
static void __iomem *scu_base;
39-
static struct omap_hwmod *rtc_oh;
4038

4139
static int (*idle_fn)(u32 wfi_flags);
4240

@@ -267,13 +265,6 @@ static struct am33xx_pm_sram_addr *amx3_get_sram_addrs(void)
267265
return NULL;
268266
}
269267

270-
static void __iomem *am43xx_get_rtc_base_addr(void)
271-
{
272-
rtc_oh = omap_hwmod_lookup("rtc");
273-
274-
return omap_hwmod_get_mpu_rt_va(rtc_oh);
275-
}
276-
277268
static void am43xx_save_context(void)
278269
{
279270
}
@@ -297,16 +288,6 @@ static void am43xx_restore_context(void)
297288
writel_relaxed(0x0, AM33XX_L4_WK_IO_ADDRESS(0x44df2e14));
298289
}
299290

300-
static void am43xx_prepare_rtc_suspend(void)
301-
{
302-
omap_hwmod_enable(rtc_oh);
303-
}
304-
305-
static void am43xx_prepare_rtc_resume(void)
306-
{
307-
omap_hwmod_idle(rtc_oh);
308-
}
309-
310291
static struct am33xx_pm_platform_data am33xx_ops = {
311292
.init = am33xx_suspend_init,
312293
.deinit = amx3_suspend_deinit,
@@ -317,10 +298,7 @@ static struct am33xx_pm_platform_data am33xx_ops = {
317298
.get_sram_addrs = amx3_get_sram_addrs,
318299
.save_context = am33xx_save_context,
319300
.restore_context = am33xx_restore_context,
320-
.prepare_rtc_suspend = am43xx_prepare_rtc_suspend,
321-
.prepare_rtc_resume = am43xx_prepare_rtc_resume,
322301
.check_off_mode_enable = am33xx_check_off_mode_enable,
323-
.get_rtc_base_addr = am43xx_get_rtc_base_addr,
324302
};
325303

326304
static struct am33xx_pm_platform_data am43xx_ops = {
@@ -333,10 +311,7 @@ static struct am33xx_pm_platform_data am43xx_ops = {
333311
.get_sram_addrs = amx3_get_sram_addrs,
334312
.save_context = am43xx_save_context,
335313
.restore_context = am43xx_restore_context,
336-
.prepare_rtc_suspend = am43xx_prepare_rtc_suspend,
337-
.prepare_rtc_resume = am43xx_prepare_rtc_resume,
338314
.check_off_mode_enable = am43xx_check_off_mode_enable,
339-
.get_rtc_base_addr = am43xx_get_rtc_base_addr,
340315
};
341316

342317
static struct am33xx_pm_platform_data *am33xx_pm_get_pdata(void)

drivers/soc/ti/pm33xx.c

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/module.h>
1717
#include <linux/nvmem-consumer.h>
1818
#include <linux/of.h>
19+
#include <linux/of_address.h>
1920
#include <linux/platform_data/pm33xx.h>
2021
#include <linux/platform_device.h>
2122
#include <linux/rtc.h>
@@ -39,6 +40,8 @@
3940
#define GIC_INT_SET_PENDING_BASE 0x200
4041
#define AM43XX_GIC_DIST_BASE 0x48241000
4142

43+
static void __iomem *rtc_base_virt;
44+
static struct clk *rtc_fck;
4245
static u32 rtc_magic_val;
4346

4447
static int (*am33xx_do_wfi_sram)(unsigned long unused);
@@ -90,7 +93,7 @@ static int am33xx_push_sram_idle(void)
9093
ro_sram_data.amx3_pm_sram_data_virt = ocmcram_location_data;
9194
ro_sram_data.amx3_pm_sram_data_phys =
9295
gen_pool_virt_to_phys(sram_pool_data, ocmcram_location_data);
93-
ro_sram_data.rtc_base_virt = pm_ops->get_rtc_base_addr();
96+
ro_sram_data.rtc_base_virt = rtc_base_virt;
9497

9598
/* Save physical address to calculate resume offset during pm init */
9699
am33xx_do_wfi_sram_phys = gen_pool_virt_to_phys(sram_pool,
@@ -158,7 +161,7 @@ static struct wkup_m3_wakeup_src rtc_wake_src(void)
158161
{
159162
u32 i;
160163

161-
i = __raw_readl(pm_ops->get_rtc_base_addr() + 0x44) & 0x40;
164+
i = __raw_readl(rtc_base_virt + 0x44) & 0x40;
162165

163166
if (i) {
164167
retrigger_irq = rtc_alarm_wakeup.irq_nr;
@@ -177,13 +180,24 @@ static int am33xx_rtc_only_idle(unsigned long wfi_flags)
177180
return 0;
178181
}
179182

183+
/*
184+
* Note that the RTC module clock must be re-enabled only for rtc+ddr suspend.
185+
* And looks like the module can stay in SYSC_IDLE_SMART_WKUP mode configured
186+
* by the interconnect code just fine for both rtc+ddr suspend and retention
187+
* suspend.
188+
*/
180189
static int am33xx_pm_suspend(suspend_state_t suspend_state)
181190
{
182191
int i, ret = 0;
183192

184193
if (suspend_state == PM_SUSPEND_MEM &&
185194
pm_ops->check_off_mode_enable()) {
186-
pm_ops->prepare_rtc_suspend();
195+
ret = clk_prepare_enable(rtc_fck);
196+
if (ret) {
197+
dev_err(pm33xx_dev, "Failed to enable clock: %i\n", ret);
198+
return ret;
199+
}
200+
187201
pm_ops->save_context();
188202
suspend_wfi_flags |= WFI_FLAG_RTC_ONLY;
189203
clk_save_context();
@@ -236,7 +250,7 @@ static int am33xx_pm_suspend(suspend_state_t suspend_state)
236250
}
237251

238252
if (suspend_state == PM_SUSPEND_MEM && pm_ops->check_off_mode_enable())
239-
pm_ops->prepare_rtc_resume();
253+
clk_disable_unprepare(rtc_fck);
240254

241255
return ret;
242256
}
@@ -425,14 +439,28 @@ static int am33xx_pm_rtc_setup(void)
425439
struct device_node *np;
426440
unsigned long val = 0;
427441
struct nvmem_device *nvmem;
442+
int error;
428443

429444
np = of_find_node_by_name(NULL, "rtc");
430445

431446
if (of_device_is_available(np)) {
447+
/* RTC interconnect target module clock */
448+
rtc_fck = of_clk_get_by_name(np->parent, "fck");
449+
if (IS_ERR(rtc_fck))
450+
return PTR_ERR(rtc_fck);
451+
452+
rtc_base_virt = of_iomap(np, 0);
453+
if (!rtc_base_virt) {
454+
pr_warn("PM: could not iomap rtc");
455+
error = -ENODEV;
456+
goto err_clk_put;
457+
}
458+
432459
omap_rtc = rtc_class_open("rtc0");
433460
if (!omap_rtc) {
434461
pr_warn("PM: rtc0 not available");
435-
return -EPROBE_DEFER;
462+
error = -EPROBE_DEFER;
463+
goto err_iounmap;
436464
}
437465

438466
nvmem = devm_nvmem_device_get(&omap_rtc->dev,
@@ -454,6 +482,13 @@ static int am33xx_pm_rtc_setup(void)
454482
}
455483

456484
return 0;
485+
486+
err_iounmap:
487+
iounmap(rtc_base_virt);
488+
err_clk_put:
489+
clk_put(rtc_fck);
490+
491+
return error;
457492
}
458493

459494
static int am33xx_pm_probe(struct platform_device *pdev)
@@ -544,6 +579,8 @@ static int am33xx_pm_remove(struct platform_device *pdev)
544579
suspend_set_ops(NULL);
545580
wkup_m3_ipc_put(m3_ipc);
546581
am33xx_pm_free_sram();
582+
iounmap(rtc_base_virt);
583+
clk_put(rtc_fck);
547584
return 0;
548585
}
549586

include/linux/platform_data/pm33xx.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,8 @@ struct am33xx_pm_platform_data {
5454
void (*begin_suspend)(void);
5555
void (*finish_suspend)(void);
5656
struct am33xx_pm_sram_addr *(*get_sram_addrs)(void);
57-
void __iomem *(*get_rtc_base_addr)(void);
5857
void (*save_context)(void);
5958
void (*restore_context)(void);
60-
void (*prepare_rtc_suspend)(void);
61-
void (*prepare_rtc_resume)(void);
6259
int (*check_off_mode_enable)(void);
6360
};
6461

0 commit comments

Comments
 (0)