162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * OMAP2/3 Power Management Routines
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2008 Nokia Corporation
662306a36Sopenharmony_ci * Jouni Hogander
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci#ifndef __ARCH_ARM_MACH_OMAP2_PM_H
962306a36Sopenharmony_ci#define __ARCH_ARM_MACH_OMAP2_PM_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <linux/err.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include "powerdomain.h"
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#ifdef CONFIG_CPU_IDLE
1662306a36Sopenharmony_ciextern int __init omap3_idle_init(void);
1762306a36Sopenharmony_ciextern int __init omap4_idle_init(void);
1862306a36Sopenharmony_ci#else
1962306a36Sopenharmony_cistatic inline int omap3_idle_init(void)
2062306a36Sopenharmony_ci{
2162306a36Sopenharmony_ci	return 0;
2262306a36Sopenharmony_ci}
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_cistatic inline int omap4_idle_init(void)
2562306a36Sopenharmony_ci{
2662306a36Sopenharmony_ci	return 0;
2762306a36Sopenharmony_ci}
2862306a36Sopenharmony_ci#endif
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ciextern void *omap3_secure_ram_storage;
3162306a36Sopenharmony_ciextern void omap3_pm_off_mode_enable(int);
3262306a36Sopenharmony_ciextern void omap_sram_idle(bool rcuidle);
3362306a36Sopenharmony_ciextern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciextern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm);
3662306a36Sopenharmony_ciextern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state);
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciextern u32 enable_off_mode;
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
4162306a36Sopenharmony_ciextern void pm_dbg_update_time(struct powerdomain *pwrdm, int prev);
4262306a36Sopenharmony_ci#else
4362306a36Sopenharmony_ci#define pm_dbg_update_time(pwrdm, prev) do {} while (0);
4462306a36Sopenharmony_ci#endif /* CONFIG_PM_DEBUG */
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci/* 24xx */
4762306a36Sopenharmony_ciextern void omap24xx_cpu_suspend(u32 dll_ctrl, void __iomem *sdrc_dlla_ctrl,
4862306a36Sopenharmony_ci					void __iomem *sdrc_power);
4962306a36Sopenharmony_ciextern unsigned int omap24xx_cpu_suspend_sz;
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci/* 3xxx */
5262306a36Sopenharmony_ciextern void omap34xx_cpu_suspend(int save_state);
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci/* omap3_do_wfi function pointer and size, for copy to SRAM */
5562306a36Sopenharmony_ciextern void omap3_do_wfi(void);
5662306a36Sopenharmony_ciextern unsigned int omap3_do_wfi_sz;
5762306a36Sopenharmony_ci/* ... and its pointer from SRAM after copy */
5862306a36Sopenharmony_ciextern void (*omap3_do_wfi_sram)(void);
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ciextern struct am33xx_pm_sram_addr am33xx_pm_sram;
6162306a36Sopenharmony_ciextern struct am33xx_pm_sram_addr am43xx_pm_sram;
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ciextern void omap3_save_scratchpad_contents(void);
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci#define PM_RTA_ERRATUM_i608		(1 << 0)
6662306a36Sopenharmony_ci#define PM_SDRC_WAKEUP_ERRATUM_i583	(1 << 1)
6762306a36Sopenharmony_ci#define PM_PER_MEMORIES_ERRATUM_i582	(1 << 2)
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci#if defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3)
7062306a36Sopenharmony_ciextern u16 pm34xx_errata;
7162306a36Sopenharmony_ci#define IS_PM34XX_ERRATUM(id)		(pm34xx_errata & (id))
7262306a36Sopenharmony_ciextern void enable_omap3630_toggle_l2_on_restore(void);
7362306a36Sopenharmony_ci#else
7462306a36Sopenharmony_ci#define IS_PM34XX_ERRATUM(id)		0
7562306a36Sopenharmony_cistatic inline void enable_omap3630_toggle_l2_on_restore(void) { }
7662306a36Sopenharmony_ci#endif		/* defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3) */
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#define PM_OMAP4_ROM_SMP_BOOT_ERRATUM_GICD	(1 << 0)
7962306a36Sopenharmony_ci#define PM_OMAP4_CPU_OSWR_DISABLE		(1 << 1)
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci#if defined(CONFIG_PM) && (defined(CONFIG_ARCH_OMAP4) ||\
8262306a36Sopenharmony_ci	   defined(CONFIG_SOC_OMAP5) || defined(CONFIG_SOC_DRA7XX))
8362306a36Sopenharmony_ciextern u16 pm44xx_errata;
8462306a36Sopenharmony_ci#define IS_PM44XX_ERRATUM(id)		(pm44xx_errata & (id))
8562306a36Sopenharmony_ci#else
8662306a36Sopenharmony_ci#define IS_PM44XX_ERRATUM(id)		0
8762306a36Sopenharmony_ci#endif
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci#define OMAP4_VP_CONFIG_ERROROFFSET	0x00
9062306a36Sopenharmony_ci#define OMAP4_VP_VSTEPMIN_VSTEPMIN	0x01
9162306a36Sopenharmony_ci#define OMAP4_VP_VSTEPMAX_VSTEPMAX	0x04
9262306a36Sopenharmony_ci#define OMAP4_VP_VLIMITTO_TIMEOUT_US	200
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci#ifdef CONFIG_POWER_AVS_OMAP
9562306a36Sopenharmony_ciextern int omap_devinit_smartreflex(void);
9662306a36Sopenharmony_ci#else
9762306a36Sopenharmony_cistatic inline int omap_devinit_smartreflex(void)
9862306a36Sopenharmony_ci{
9962306a36Sopenharmony_ci	return -EINVAL;
10062306a36Sopenharmony_ci}
10162306a36Sopenharmony_ci#endif
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci#ifdef CONFIG_TWL4030_CORE
10462306a36Sopenharmony_ciextern int omap3_twl_init(void);
10562306a36Sopenharmony_ciextern int omap4_twl_init(void);
10662306a36Sopenharmony_ci#else
10762306a36Sopenharmony_cistatic inline int omap3_twl_init(void)
10862306a36Sopenharmony_ci{
10962306a36Sopenharmony_ci	return -EINVAL;
11062306a36Sopenharmony_ci}
11162306a36Sopenharmony_cistatic inline int omap4_twl_init(void)
11262306a36Sopenharmony_ci{
11362306a36Sopenharmony_ci	return -EINVAL;
11462306a36Sopenharmony_ci}
11562306a36Sopenharmony_ci#endif
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_MFD_CPCAP)
11862306a36Sopenharmony_ciextern int omap4_cpcap_init(void);
11962306a36Sopenharmony_ci#else
12062306a36Sopenharmony_cistatic inline int omap4_cpcap_init(void)
12162306a36Sopenharmony_ci{
12262306a36Sopenharmony_ci	return -EINVAL;
12362306a36Sopenharmony_ci}
12462306a36Sopenharmony_ci#endif
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci#ifdef CONFIG_PM
12762306a36Sopenharmony_ciextern void omap_pm_get_oscillator(u32 *tstart, u32 *tshut);
12862306a36Sopenharmony_ci#else
12962306a36Sopenharmony_cistatic inline void omap_pm_get_oscillator(u32 *tstart, u32 *tshut) { *tstart = *tshut = 0; }
13062306a36Sopenharmony_ci#endif
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci#ifdef CONFIG_SUSPEND
13362306a36Sopenharmony_civoid omap_common_suspend_init(void *pm_suspend);
13462306a36Sopenharmony_ci#else
13562306a36Sopenharmony_cistatic inline void omap_common_suspend_init(void *pm_suspend)
13662306a36Sopenharmony_ci{
13762306a36Sopenharmony_ci}
13862306a36Sopenharmony_ci#endif /* CONFIG_SUSPEND */
13962306a36Sopenharmony_ci#endif
140