xref: /openbmc/linux/arch/arm/mach-omap2/control.c (revision 0c3492467c99f3d0d83a48012ee6e672b016759c)
169d88a00SPaul Walmsley /*
269d88a00SPaul Walmsley  * OMAP2/3 System Control Module register access
369d88a00SPaul Walmsley  *
469d88a00SPaul Walmsley  * Copyright (C) 2007 Texas Instruments, Inc.
569d88a00SPaul Walmsley  * Copyright (C) 2007 Nokia Corporation
669d88a00SPaul Walmsley  *
769d88a00SPaul Walmsley  * Written by Paul Walmsley
869d88a00SPaul Walmsley  *
969d88a00SPaul Walmsley  * This program is free software; you can redistribute it and/or modify
1069d88a00SPaul Walmsley  * it under the terms of the GNU General Public License version 2 as
1169d88a00SPaul Walmsley  * published by the Free Software Foundation.
1269d88a00SPaul Walmsley  */
1369d88a00SPaul Walmsley #undef DEBUG
1469d88a00SPaul Walmsley 
1569d88a00SPaul Walmsley #include <linux/kernel.h>
16a58caad1STony Lindgren #include <linux/io.h>
1769d88a00SPaul Walmsley 
18ce491cf8STony Lindgren #include <plat/common.h>
19ce491cf8STony Lindgren #include <plat/control.h>
2080140786SRajendra Nayak #include <plat/sdrc.h>
2180140786SRajendra Nayak #include "cm-regbits-34xx.h"
2280140786SRajendra Nayak #include "prm-regbits-34xx.h"
2380140786SRajendra Nayak #include "cm.h"
2480140786SRajendra Nayak #include "prm.h"
2580140786SRajendra Nayak #include "sdrc.h"
2669d88a00SPaul Walmsley 
27a58caad1STony Lindgren static void __iomem *omap2_ctrl_base;
28*0c349246SSantosh Shilimkar static void __iomem *omap4_ctrl_pad_base;
2969d88a00SPaul Walmsley 
30c96631e1SRajendra Nayak #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
3180140786SRajendra Nayak struct omap3_scratchpad {
3280140786SRajendra Nayak 	u32 boot_config_ptr;
3380140786SRajendra Nayak 	u32 public_restore_ptr;
3480140786SRajendra Nayak 	u32 secure_ram_restore_ptr;
3580140786SRajendra Nayak 	u32 sdrc_module_semaphore;
3680140786SRajendra Nayak 	u32 prcm_block_offset;
3780140786SRajendra Nayak 	u32 sdrc_block_offset;
3880140786SRajendra Nayak };
3980140786SRajendra Nayak 
4080140786SRajendra Nayak struct omap3_scratchpad_prcm_block {
4180140786SRajendra Nayak 	u32 prm_clksrc_ctrl;
4280140786SRajendra Nayak 	u32 prm_clksel;
4380140786SRajendra Nayak 	u32 cm_clksel_core;
4480140786SRajendra Nayak 	u32 cm_clksel_wkup;
4580140786SRajendra Nayak 	u32 cm_clken_pll;
4680140786SRajendra Nayak 	u32 cm_autoidle_pll;
4780140786SRajendra Nayak 	u32 cm_clksel1_pll;
4880140786SRajendra Nayak 	u32 cm_clksel2_pll;
4980140786SRajendra Nayak 	u32 cm_clksel3_pll;
5080140786SRajendra Nayak 	u32 cm_clken_pll_mpu;
5180140786SRajendra Nayak 	u32 cm_autoidle_pll_mpu;
5280140786SRajendra Nayak 	u32 cm_clksel1_pll_mpu;
5380140786SRajendra Nayak 	u32 cm_clksel2_pll_mpu;
5480140786SRajendra Nayak 	u32 prcm_block_size;
5580140786SRajendra Nayak };
5680140786SRajendra Nayak 
5780140786SRajendra Nayak struct omap3_scratchpad_sdrc_block {
5880140786SRajendra Nayak 	u16 sysconfig;
5980140786SRajendra Nayak 	u16 cs_cfg;
6080140786SRajendra Nayak 	u16 sharing;
6180140786SRajendra Nayak 	u16 err_type;
6280140786SRajendra Nayak 	u32 dll_a_ctrl;
6380140786SRajendra Nayak 	u32 dll_b_ctrl;
6480140786SRajendra Nayak 	u32 power;
6580140786SRajendra Nayak 	u32 cs_0;
6680140786SRajendra Nayak 	u32 mcfg_0;
6780140786SRajendra Nayak 	u16 mr_0;
6880140786SRajendra Nayak 	u16 emr_1_0;
6980140786SRajendra Nayak 	u16 emr_2_0;
7080140786SRajendra Nayak 	u16 emr_3_0;
7180140786SRajendra Nayak 	u32 actim_ctrla_0;
7280140786SRajendra Nayak 	u32 actim_ctrlb_0;
7380140786SRajendra Nayak 	u32 rfr_ctrl_0;
7480140786SRajendra Nayak 	u32 cs_1;
7580140786SRajendra Nayak 	u32 mcfg_1;
7680140786SRajendra Nayak 	u16 mr_1;
7780140786SRajendra Nayak 	u16 emr_1_1;
7880140786SRajendra Nayak 	u16 emr_2_1;
7980140786SRajendra Nayak 	u16 emr_3_1;
8080140786SRajendra Nayak 	u32 actim_ctrla_1;
8180140786SRajendra Nayak 	u32 actim_ctrlb_1;
8280140786SRajendra Nayak 	u32 rfr_ctrl_1;
8380140786SRajendra Nayak 	u16 dcdl_1_ctrl;
8480140786SRajendra Nayak 	u16 dcdl_2_ctrl;
8580140786SRajendra Nayak 	u32 flags;
8680140786SRajendra Nayak 	u32 block_size;
8780140786SRajendra Nayak };
8880140786SRajendra Nayak 
8927d59a4aSTero Kristo void *omap3_secure_ram_storage;
9027d59a4aSTero Kristo 
9180140786SRajendra Nayak /*
9280140786SRajendra Nayak  * This is used to store ARM registers in SDRAM before attempting
9380140786SRajendra Nayak  * an MPU OFF. The save and restore happens from the SRAM sleep code.
9480140786SRajendra Nayak  * The address is stored in scratchpad, so that it can be used
9580140786SRajendra Nayak  * during the restore path.
9680140786SRajendra Nayak  */
9780140786SRajendra Nayak u32 omap3_arm_context[128];
9880140786SRajendra Nayak 
99c96631e1SRajendra Nayak struct omap3_control_regs {
100c96631e1SRajendra Nayak 	u32 sysconfig;
101c96631e1SRajendra Nayak 	u32 devconf0;
102c96631e1SRajendra Nayak 	u32 mem_dftrw0;
103c96631e1SRajendra Nayak 	u32 mem_dftrw1;
104c96631e1SRajendra Nayak 	u32 msuspendmux_0;
105c96631e1SRajendra Nayak 	u32 msuspendmux_1;
106c96631e1SRajendra Nayak 	u32 msuspendmux_2;
107c96631e1SRajendra Nayak 	u32 msuspendmux_3;
108c96631e1SRajendra Nayak 	u32 msuspendmux_4;
109c96631e1SRajendra Nayak 	u32 msuspendmux_5;
110c96631e1SRajendra Nayak 	u32 sec_ctrl;
111c96631e1SRajendra Nayak 	u32 devconf1;
112c96631e1SRajendra Nayak 	u32 csirxfe;
113c96631e1SRajendra Nayak 	u32 iva2_bootaddr;
114c96631e1SRajendra Nayak 	u32 iva2_bootmod;
115c96631e1SRajendra Nayak 	u32 debobs_0;
116c96631e1SRajendra Nayak 	u32 debobs_1;
117c96631e1SRajendra Nayak 	u32 debobs_2;
118c96631e1SRajendra Nayak 	u32 debobs_3;
119c96631e1SRajendra Nayak 	u32 debobs_4;
120c96631e1SRajendra Nayak 	u32 debobs_5;
121c96631e1SRajendra Nayak 	u32 debobs_6;
122c96631e1SRajendra Nayak 	u32 debobs_7;
123c96631e1SRajendra Nayak 	u32 debobs_8;
124c96631e1SRajendra Nayak 	u32 prog_io0;
125c96631e1SRajendra Nayak 	u32 prog_io1;
126c96631e1SRajendra Nayak 	u32 dss_dpll_spreading;
127c96631e1SRajendra Nayak 	u32 core_dpll_spreading;
128c96631e1SRajendra Nayak 	u32 per_dpll_spreading;
129c96631e1SRajendra Nayak 	u32 usbhost_dpll_spreading;
130c96631e1SRajendra Nayak 	u32 pbias_lite;
131c96631e1SRajendra Nayak 	u32 temp_sensor;
132c96631e1SRajendra Nayak 	u32 sramldo4;
133c96631e1SRajendra Nayak 	u32 sramldo5;
134c96631e1SRajendra Nayak 	u32 csi;
135c96631e1SRajendra Nayak };
136c96631e1SRajendra Nayak 
137c96631e1SRajendra Nayak static struct omap3_control_regs control_context;
138c96631e1SRajendra Nayak #endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */
139c96631e1SRajendra Nayak 
140a58caad1STony Lindgren #define OMAP_CTRL_REGADDR(reg)		(omap2_ctrl_base + (reg))
14169d88a00SPaul Walmsley 
142a58caad1STony Lindgren void __init omap2_set_globals_control(struct omap_globals *omap2_globals)
14369d88a00SPaul Walmsley {
144b7ebb10bSSantosh Shilimkar 	/* Static mapping, never released */
145b7ebb10bSSantosh Shilimkar 	if (omap2_globals->ctrl) {
146b7ebb10bSSantosh Shilimkar 		omap2_ctrl_base = ioremap(omap2_globals->ctrl, SZ_4K);
147b7ebb10bSSantosh Shilimkar 		WARN_ON(!omap2_ctrl_base);
148b7ebb10bSSantosh Shilimkar 	}
149*0c349246SSantosh Shilimkar 
150*0c349246SSantosh Shilimkar 	/* Static mapping, never released */
151*0c349246SSantosh Shilimkar 	if (omap2_globals->ctrl_pad) {
152*0c349246SSantosh Shilimkar 		omap4_ctrl_pad_base = ioremap(omap2_globals->ctrl_pad, SZ_4K);
153*0c349246SSantosh Shilimkar 		WARN_ON(!omap4_ctrl_pad_base);
154*0c349246SSantosh Shilimkar 	}
15569d88a00SPaul Walmsley }
15669d88a00SPaul Walmsley 
157a58caad1STony Lindgren void __iomem *omap_ctrl_base_get(void)
15869d88a00SPaul Walmsley {
15969d88a00SPaul Walmsley 	return omap2_ctrl_base;
16069d88a00SPaul Walmsley }
16169d88a00SPaul Walmsley 
16269d88a00SPaul Walmsley u8 omap_ctrl_readb(u16 offset)
16369d88a00SPaul Walmsley {
16469d88a00SPaul Walmsley 	return __raw_readb(OMAP_CTRL_REGADDR(offset));
16569d88a00SPaul Walmsley }
16669d88a00SPaul Walmsley 
16769d88a00SPaul Walmsley u16 omap_ctrl_readw(u16 offset)
16869d88a00SPaul Walmsley {
16969d88a00SPaul Walmsley 	return __raw_readw(OMAP_CTRL_REGADDR(offset));
17069d88a00SPaul Walmsley }
17169d88a00SPaul Walmsley 
17269d88a00SPaul Walmsley u32 omap_ctrl_readl(u16 offset)
17369d88a00SPaul Walmsley {
17469d88a00SPaul Walmsley 	return __raw_readl(OMAP_CTRL_REGADDR(offset));
17569d88a00SPaul Walmsley }
17669d88a00SPaul Walmsley 
17769d88a00SPaul Walmsley void omap_ctrl_writeb(u8 val, u16 offset)
17869d88a00SPaul Walmsley {
17969d88a00SPaul Walmsley 	__raw_writeb(val, OMAP_CTRL_REGADDR(offset));
18069d88a00SPaul Walmsley }
18169d88a00SPaul Walmsley 
18269d88a00SPaul Walmsley void omap_ctrl_writew(u16 val, u16 offset)
18369d88a00SPaul Walmsley {
18469d88a00SPaul Walmsley 	__raw_writew(val, OMAP_CTRL_REGADDR(offset));
18569d88a00SPaul Walmsley }
18669d88a00SPaul Walmsley 
18769d88a00SPaul Walmsley void omap_ctrl_writel(u32 val, u16 offset)
18869d88a00SPaul Walmsley {
18969d88a00SPaul Walmsley 	__raw_writel(val, OMAP_CTRL_REGADDR(offset));
19069d88a00SPaul Walmsley }
19169d88a00SPaul Walmsley 
192c96631e1SRajendra Nayak #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
19380140786SRajendra Nayak /*
19480140786SRajendra Nayak  * Clears the scratchpad contents in case of cold boot-
19580140786SRajendra Nayak  * called during bootup
19680140786SRajendra Nayak  */
19780140786SRajendra Nayak void omap3_clear_scratchpad_contents(void)
19880140786SRajendra Nayak {
19980140786SRajendra Nayak 	u32 max_offset = OMAP343X_SCRATCHPAD_ROM_OFFSET;
20080140786SRajendra Nayak 	u32 *v_addr;
20180140786SRajendra Nayak 	u32 offset = 0;
20280140786SRajendra Nayak 	v_addr = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD_ROM);
20380140786SRajendra Nayak 	if (prm_read_mod_reg(OMAP3430_GR_MOD, OMAP3_PRM_RSTST_OFFSET) &
2042bc4ef71SPaul Walmsley 	    OMAP3430_GLOBAL_COLD_RST_MASK) {
20580140786SRajendra Nayak 		for ( ; offset <= max_offset; offset += 0x4)
20680140786SRajendra Nayak 			__raw_writel(0x0, (v_addr + offset));
2072bc4ef71SPaul Walmsley 		prm_set_mod_reg_bits(OMAP3430_GLOBAL_COLD_RST_MASK,
2082bc4ef71SPaul Walmsley 				     OMAP3430_GR_MOD,
20980140786SRajendra Nayak 				     OMAP3_PRM_RSTST_OFFSET);
21080140786SRajendra Nayak 	}
21180140786SRajendra Nayak }
21280140786SRajendra Nayak 
21380140786SRajendra Nayak /* Populate the scratchpad structure with restore structure */
21480140786SRajendra Nayak void omap3_save_scratchpad_contents(void)
21580140786SRajendra Nayak {
21680140786SRajendra Nayak 	void * __iomem scratchpad_address;
21780140786SRajendra Nayak 	u32 arm_context_addr;
21880140786SRajendra Nayak 	struct omap3_scratchpad scratchpad_contents;
21980140786SRajendra Nayak 	struct omap3_scratchpad_prcm_block prcm_block_contents;
22080140786SRajendra Nayak 	struct omap3_scratchpad_sdrc_block sdrc_block_contents;
22180140786SRajendra Nayak 
22280140786SRajendra Nayak 	/* Populate the Scratchpad contents */
22380140786SRajendra Nayak 	scratchpad_contents.boot_config_ptr = 0x0;
2240795a75aSTero Kristo 	if (omap_rev() != OMAP3430_REV_ES3_0 &&
2250795a75aSTero Kristo 					omap_rev() != OMAP3430_REV_ES3_1)
22680140786SRajendra Nayak 		scratchpad_contents.public_restore_ptr =
22780140786SRajendra Nayak 			virt_to_phys(get_restore_pointer());
2280795a75aSTero Kristo 	else
2290795a75aSTero Kristo 		scratchpad_contents.public_restore_ptr =
2300795a75aSTero Kristo 			virt_to_phys(get_es3_restore_pointer());
23127d59a4aSTero Kristo 	if (omap_type() == OMAP2_DEVICE_TYPE_GP)
23280140786SRajendra Nayak 		scratchpad_contents.secure_ram_restore_ptr = 0x0;
23327d59a4aSTero Kristo 	else
23427d59a4aSTero Kristo 		scratchpad_contents.secure_ram_restore_ptr =
23527d59a4aSTero Kristo 			(u32) __pa(omap3_secure_ram_storage);
23680140786SRajendra Nayak 	scratchpad_contents.sdrc_module_semaphore = 0x0;
23780140786SRajendra Nayak 	scratchpad_contents.prcm_block_offset = 0x2C;
23880140786SRajendra Nayak 	scratchpad_contents.sdrc_block_offset = 0x64;
23980140786SRajendra Nayak 
24080140786SRajendra Nayak 	/* Populate the PRCM block contents */
24180140786SRajendra Nayak 	prcm_block_contents.prm_clksrc_ctrl = prm_read_mod_reg(OMAP3430_GR_MOD,
24280140786SRajendra Nayak 			OMAP3_PRM_CLKSRC_CTRL_OFFSET);
24380140786SRajendra Nayak 	prcm_block_contents.prm_clksel = prm_read_mod_reg(OMAP3430_CCR_MOD,
24480140786SRajendra Nayak 			OMAP3_PRM_CLKSEL_OFFSET);
24580140786SRajendra Nayak 	prcm_block_contents.cm_clksel_core =
24680140786SRajendra Nayak 			cm_read_mod_reg(CORE_MOD, CM_CLKSEL);
24780140786SRajendra Nayak 	prcm_block_contents.cm_clksel_wkup =
24880140786SRajendra Nayak 			cm_read_mod_reg(WKUP_MOD, CM_CLKSEL);
24980140786SRajendra Nayak 	prcm_block_contents.cm_clken_pll =
250cb0cb2b8SKalle Jokiniemi 			cm_read_mod_reg(PLL_MOD, CM_CLKEN);
25180140786SRajendra Nayak 	prcm_block_contents.cm_autoidle_pll =
25280140786SRajendra Nayak 			cm_read_mod_reg(PLL_MOD, OMAP3430_CM_AUTOIDLE_PLL);
25380140786SRajendra Nayak 	prcm_block_contents.cm_clksel1_pll =
25480140786SRajendra Nayak 			cm_read_mod_reg(PLL_MOD, OMAP3430_CM_CLKSEL1_PLL);
25580140786SRajendra Nayak 	prcm_block_contents.cm_clksel2_pll =
25680140786SRajendra Nayak 			cm_read_mod_reg(PLL_MOD, OMAP3430_CM_CLKSEL2_PLL);
25780140786SRajendra Nayak 	prcm_block_contents.cm_clksel3_pll =
25880140786SRajendra Nayak 			cm_read_mod_reg(PLL_MOD, OMAP3430_CM_CLKSEL3);
25980140786SRajendra Nayak 	prcm_block_contents.cm_clken_pll_mpu =
26080140786SRajendra Nayak 			cm_read_mod_reg(MPU_MOD, OMAP3430_CM_CLKEN_PLL);
26180140786SRajendra Nayak 	prcm_block_contents.cm_autoidle_pll_mpu =
26280140786SRajendra Nayak 			cm_read_mod_reg(MPU_MOD, OMAP3430_CM_AUTOIDLE_PLL);
26380140786SRajendra Nayak 	prcm_block_contents.cm_clksel1_pll_mpu =
26480140786SRajendra Nayak 			cm_read_mod_reg(MPU_MOD, OMAP3430_CM_CLKSEL1_PLL);
26580140786SRajendra Nayak 	prcm_block_contents.cm_clksel2_pll_mpu =
26680140786SRajendra Nayak 			cm_read_mod_reg(MPU_MOD, OMAP3430_CM_CLKSEL2_PLL);
26780140786SRajendra Nayak 	prcm_block_contents.prcm_block_size = 0x0;
26880140786SRajendra Nayak 
26980140786SRajendra Nayak 	/* Populate the SDRC block contents */
27080140786SRajendra Nayak 	sdrc_block_contents.sysconfig =
27180140786SRajendra Nayak 			(sdrc_read_reg(SDRC_SYSCONFIG) & 0xFFFF);
27280140786SRajendra Nayak 	sdrc_block_contents.cs_cfg =
27380140786SRajendra Nayak 			(sdrc_read_reg(SDRC_CS_CFG) & 0xFFFF);
27480140786SRajendra Nayak 	sdrc_block_contents.sharing =
27580140786SRajendra Nayak 			(sdrc_read_reg(SDRC_SHARING) & 0xFFFF);
27680140786SRajendra Nayak 	sdrc_block_contents.err_type =
27780140786SRajendra Nayak 			(sdrc_read_reg(SDRC_ERR_TYPE) & 0xFFFF);
27880140786SRajendra Nayak 	sdrc_block_contents.dll_a_ctrl = sdrc_read_reg(SDRC_DLLA_CTRL);
27980140786SRajendra Nayak 	sdrc_block_contents.dll_b_ctrl = 0x0;
280f265dc4cSRajendra Nayak 	/*
281f265dc4cSRajendra Nayak 	 * Due to a OMAP3 errata (1.142), on EMU/HS devices SRDC should
282f265dc4cSRajendra Nayak 	 * be programed to issue automatic self refresh on timeout
283f265dc4cSRajendra Nayak 	 * of AUTO_CNT = 1 prior to any transition to OFF mode.
284f265dc4cSRajendra Nayak 	 */
285f265dc4cSRajendra Nayak 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)
286f265dc4cSRajendra Nayak 			&& (omap_rev() >= OMAP3430_REV_ES3_0))
287f265dc4cSRajendra Nayak 		sdrc_block_contents.power = (sdrc_read_reg(SDRC_POWER) &
288f265dc4cSRajendra Nayak 				~(SDRC_POWER_AUTOCOUNT_MASK|
289f265dc4cSRajendra Nayak 				SDRC_POWER_CLKCTRL_MASK)) |
290f265dc4cSRajendra Nayak 				(1 << SDRC_POWER_AUTOCOUNT_SHIFT) |
291f265dc4cSRajendra Nayak 				SDRC_SELF_REFRESH_ON_AUTOCOUNT;
292f265dc4cSRajendra Nayak 	else
29380140786SRajendra Nayak 		sdrc_block_contents.power = sdrc_read_reg(SDRC_POWER);
294f265dc4cSRajendra Nayak 
29580140786SRajendra Nayak 	sdrc_block_contents.cs_0 = 0x0;
29680140786SRajendra Nayak 	sdrc_block_contents.mcfg_0 = sdrc_read_reg(SDRC_MCFG_0);
29780140786SRajendra Nayak 	sdrc_block_contents.mr_0 = (sdrc_read_reg(SDRC_MR_0) & 0xFFFF);
29880140786SRajendra Nayak 	sdrc_block_contents.emr_1_0 = 0x0;
29980140786SRajendra Nayak 	sdrc_block_contents.emr_2_0 = 0x0;
30080140786SRajendra Nayak 	sdrc_block_contents.emr_3_0 = 0x0;
30180140786SRajendra Nayak 	sdrc_block_contents.actim_ctrla_0 =
30280140786SRajendra Nayak 			sdrc_read_reg(SDRC_ACTIM_CTRL_A_0);
30380140786SRajendra Nayak 	sdrc_block_contents.actim_ctrlb_0 =
30480140786SRajendra Nayak 			sdrc_read_reg(SDRC_ACTIM_CTRL_B_0);
30580140786SRajendra Nayak 	sdrc_block_contents.rfr_ctrl_0 =
30680140786SRajendra Nayak 			sdrc_read_reg(SDRC_RFR_CTRL_0);
30780140786SRajendra Nayak 	sdrc_block_contents.cs_1 = 0x0;
30880140786SRajendra Nayak 	sdrc_block_contents.mcfg_1 = sdrc_read_reg(SDRC_MCFG_1);
30980140786SRajendra Nayak 	sdrc_block_contents.mr_1 = sdrc_read_reg(SDRC_MR_1) & 0xFFFF;
31080140786SRajendra Nayak 	sdrc_block_contents.emr_1_1 = 0x0;
31180140786SRajendra Nayak 	sdrc_block_contents.emr_2_1 = 0x0;
31280140786SRajendra Nayak 	sdrc_block_contents.emr_3_1 = 0x0;
31380140786SRajendra Nayak 	sdrc_block_contents.actim_ctrla_1 =
31480140786SRajendra Nayak 			sdrc_read_reg(SDRC_ACTIM_CTRL_A_1);
31580140786SRajendra Nayak 	sdrc_block_contents.actim_ctrlb_1 =
31680140786SRajendra Nayak 			sdrc_read_reg(SDRC_ACTIM_CTRL_B_1);
31780140786SRajendra Nayak 	sdrc_block_contents.rfr_ctrl_1 =
31880140786SRajendra Nayak 			sdrc_read_reg(SDRC_RFR_CTRL_1);
31980140786SRajendra Nayak 	sdrc_block_contents.dcdl_1_ctrl = 0x0;
32080140786SRajendra Nayak 	sdrc_block_contents.dcdl_2_ctrl = 0x0;
32180140786SRajendra Nayak 	sdrc_block_contents.flags = 0x0;
32280140786SRajendra Nayak 	sdrc_block_contents.block_size = 0x0;
32380140786SRajendra Nayak 
32480140786SRajendra Nayak 	arm_context_addr = virt_to_phys(omap3_arm_context);
32580140786SRajendra Nayak 
32680140786SRajendra Nayak 	/* Copy all the contents to the scratchpad location */
32780140786SRajendra Nayak 	scratchpad_address = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD);
32880140786SRajendra Nayak 	memcpy_toio(scratchpad_address, &scratchpad_contents,
32980140786SRajendra Nayak 		 sizeof(scratchpad_contents));
33080140786SRajendra Nayak 	/* Scratchpad contents being 32 bits, a divide by 4 done here */
33180140786SRajendra Nayak 	memcpy_toio(scratchpad_address +
33280140786SRajendra Nayak 		scratchpad_contents.prcm_block_offset,
33380140786SRajendra Nayak 		&prcm_block_contents, sizeof(prcm_block_contents));
33480140786SRajendra Nayak 	memcpy_toio(scratchpad_address +
33580140786SRajendra Nayak 		scratchpad_contents.sdrc_block_offset,
33680140786SRajendra Nayak 		&sdrc_block_contents, sizeof(sdrc_block_contents));
33780140786SRajendra Nayak 	/*
33880140786SRajendra Nayak 	 * Copies the address of the location in SDRAM where ARM
33980140786SRajendra Nayak 	 * registers get saved during a MPU OFF transition.
34080140786SRajendra Nayak 	 */
34180140786SRajendra Nayak 	memcpy_toio(scratchpad_address +
34280140786SRajendra Nayak 		scratchpad_contents.sdrc_block_offset +
34380140786SRajendra Nayak 		sizeof(sdrc_block_contents), &arm_context_addr, 4);
34480140786SRajendra Nayak }
34580140786SRajendra Nayak 
346c96631e1SRajendra Nayak void omap3_control_save_context(void)
347c96631e1SRajendra Nayak {
348c96631e1SRajendra Nayak 	control_context.sysconfig = omap_ctrl_readl(OMAP2_CONTROL_SYSCONFIG);
349c96631e1SRajendra Nayak 	control_context.devconf0 = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
350c96631e1SRajendra Nayak 	control_context.mem_dftrw0 =
351c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_MEM_DFTRW0);
352c96631e1SRajendra Nayak 	control_context.mem_dftrw1 =
353c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_MEM_DFTRW1);
354c96631e1SRajendra Nayak 	control_context.msuspendmux_0 =
355c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_0);
356c96631e1SRajendra Nayak 	control_context.msuspendmux_1 =
357c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_1);
358c96631e1SRajendra Nayak 	control_context.msuspendmux_2 =
359c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_2);
360c96631e1SRajendra Nayak 	control_context.msuspendmux_3 =
361c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_3);
362c96631e1SRajendra Nayak 	control_context.msuspendmux_4 =
363c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_4);
364c96631e1SRajendra Nayak 	control_context.msuspendmux_5 =
365c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_5);
366c96631e1SRajendra Nayak 	control_context.sec_ctrl = omap_ctrl_readl(OMAP2_CONTROL_SEC_CTRL);
367c96631e1SRajendra Nayak 	control_context.devconf1 = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
368c96631e1SRajendra Nayak 	control_context.csirxfe = omap_ctrl_readl(OMAP343X_CONTROL_CSIRXFE);
369c96631e1SRajendra Nayak 	control_context.iva2_bootaddr =
370c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_IVA2_BOOTADDR);
371c96631e1SRajendra Nayak 	control_context.iva2_bootmod =
372c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_IVA2_BOOTMOD);
373c96631e1SRajendra Nayak 	control_context.debobs_0 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(0));
374c96631e1SRajendra Nayak 	control_context.debobs_1 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(1));
375c96631e1SRajendra Nayak 	control_context.debobs_2 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(2));
376c96631e1SRajendra Nayak 	control_context.debobs_3 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(3));
377c96631e1SRajendra Nayak 	control_context.debobs_4 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(4));
378c96631e1SRajendra Nayak 	control_context.debobs_5 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(5));
379c96631e1SRajendra Nayak 	control_context.debobs_6 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(6));
380c96631e1SRajendra Nayak 	control_context.debobs_7 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(7));
381c96631e1SRajendra Nayak 	control_context.debobs_8 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(8));
382c96631e1SRajendra Nayak 	control_context.prog_io0 = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO0);
383c96631e1SRajendra Nayak 	control_context.prog_io1 = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO1);
384c96631e1SRajendra Nayak 	control_context.dss_dpll_spreading =
385c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_DSS_DPLL_SPREADING);
386c96631e1SRajendra Nayak 	control_context.core_dpll_spreading =
387c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_CORE_DPLL_SPREADING);
388c96631e1SRajendra Nayak 	control_context.per_dpll_spreading =
389c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_PER_DPLL_SPREADING);
390c96631e1SRajendra Nayak 	control_context.usbhost_dpll_spreading =
391c96631e1SRajendra Nayak 		omap_ctrl_readl(OMAP343X_CONTROL_USBHOST_DPLL_SPREADING);
392c96631e1SRajendra Nayak 	control_context.pbias_lite =
393c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_PBIAS_LITE);
394c96631e1SRajendra Nayak 	control_context.temp_sensor =
395c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_TEMP_SENSOR);
396c96631e1SRajendra Nayak 	control_context.sramldo4 = omap_ctrl_readl(OMAP343X_CONTROL_SRAMLDO4);
397c96631e1SRajendra Nayak 	control_context.sramldo5 = omap_ctrl_readl(OMAP343X_CONTROL_SRAMLDO5);
398c96631e1SRajendra Nayak 	control_context.csi = omap_ctrl_readl(OMAP343X_CONTROL_CSI);
399c96631e1SRajendra Nayak 	return;
400c96631e1SRajendra Nayak }
401c96631e1SRajendra Nayak 
402c96631e1SRajendra Nayak void omap3_control_restore_context(void)
403c96631e1SRajendra Nayak {
404c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.sysconfig, OMAP2_CONTROL_SYSCONFIG);
405c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.devconf0, OMAP2_CONTROL_DEVCONF0);
406c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.mem_dftrw0,
407c96631e1SRajendra Nayak 					OMAP343X_CONTROL_MEM_DFTRW0);
408c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.mem_dftrw1,
409c96631e1SRajendra Nayak 					OMAP343X_CONTROL_MEM_DFTRW1);
410c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.msuspendmux_0,
411c96631e1SRajendra Nayak 					OMAP2_CONTROL_MSUSPENDMUX_0);
412c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.msuspendmux_1,
413c96631e1SRajendra Nayak 					OMAP2_CONTROL_MSUSPENDMUX_1);
414c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.msuspendmux_2,
415c96631e1SRajendra Nayak 					OMAP2_CONTROL_MSUSPENDMUX_2);
416c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.msuspendmux_3,
417c96631e1SRajendra Nayak 					OMAP2_CONTROL_MSUSPENDMUX_3);
418c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.msuspendmux_4,
419c96631e1SRajendra Nayak 					OMAP2_CONTROL_MSUSPENDMUX_4);
420c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.msuspendmux_5,
421c96631e1SRajendra Nayak 					OMAP2_CONTROL_MSUSPENDMUX_5);
422c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.sec_ctrl, OMAP2_CONTROL_SEC_CTRL);
423c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.devconf1, OMAP343X_CONTROL_DEVCONF1);
424c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.csirxfe, OMAP343X_CONTROL_CSIRXFE);
425c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.iva2_bootaddr,
426c96631e1SRajendra Nayak 					OMAP343X_CONTROL_IVA2_BOOTADDR);
427c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.iva2_bootmod,
428c96631e1SRajendra Nayak 					OMAP343X_CONTROL_IVA2_BOOTMOD);
429c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_0, OMAP343X_CONTROL_DEBOBS(0));
430c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_1, OMAP343X_CONTROL_DEBOBS(1));
431c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_2, OMAP343X_CONTROL_DEBOBS(2));
432c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_3, OMAP343X_CONTROL_DEBOBS(3));
433c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_4, OMAP343X_CONTROL_DEBOBS(4));
434c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_5, OMAP343X_CONTROL_DEBOBS(5));
435c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_6, OMAP343X_CONTROL_DEBOBS(6));
436c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_7, OMAP343X_CONTROL_DEBOBS(7));
437c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_8, OMAP343X_CONTROL_DEBOBS(8));
438c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.prog_io0, OMAP343X_CONTROL_PROG_IO0);
439c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.prog_io1, OMAP343X_CONTROL_PROG_IO1);
440c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.dss_dpll_spreading,
441c96631e1SRajendra Nayak 					OMAP343X_CONTROL_DSS_DPLL_SPREADING);
442c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.core_dpll_spreading,
443c96631e1SRajendra Nayak 					OMAP343X_CONTROL_CORE_DPLL_SPREADING);
444c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.per_dpll_spreading,
445c96631e1SRajendra Nayak 					OMAP343X_CONTROL_PER_DPLL_SPREADING);
446c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.usbhost_dpll_spreading,
447c96631e1SRajendra Nayak 				OMAP343X_CONTROL_USBHOST_DPLL_SPREADING);
448c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.pbias_lite,
449c96631e1SRajendra Nayak 					OMAP343X_CONTROL_PBIAS_LITE);
450c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.temp_sensor,
451c96631e1SRajendra Nayak 					OMAP343X_CONTROL_TEMP_SENSOR);
452c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.sramldo4, OMAP343X_CONTROL_SRAMLDO4);
453c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.sramldo5, OMAP343X_CONTROL_SRAMLDO5);
454c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.csi, OMAP343X_CONTROL_CSI);
455c96631e1SRajendra Nayak 	return;
456c96631e1SRajendra Nayak }
457c96631e1SRajendra Nayak #endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */
458