xref: /openbmc/linux/arch/arm/mach-omap2/control.c (revision 668468b161745df666b75fbfb76d14155b0f9df6)
169d88a00SPaul Walmsley /*
269d88a00SPaul Walmsley  * OMAP2/3 System Control Module register access
369d88a00SPaul Walmsley  *
43e6ece13SPaul Walmsley  * Copyright (C) 2007, 2012 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 
18dbc04161STony Lindgren #include "soc.h"
19ee0839c2STony Lindgren #include "iomap.h"
20ee0839c2STony Lindgren #include "common.h"
2180140786SRajendra Nayak #include "cm-regbits-34xx.h"
2280140786SRajendra Nayak #include "prm-regbits-34xx.h"
23139563adSPaul Walmsley #include "prm3xxx.h"
24ff4ae5d9SPaul Walmsley #include "cm3xxx.h"
2580140786SRajendra Nayak #include "sdrc.h"
2638815733SManjunath Kondaiah G #include "pm.h"
274814ced5SPaul Walmsley #include "control.h"
2869d88a00SPaul Walmsley 
29596efe47SPaul Walmsley /* Used by omap3_ctrl_save_padconf() */
30596efe47SPaul Walmsley #define START_PADCONF_SAVE		0x2
31596efe47SPaul Walmsley #define PADCONF_SAVE_DONE		0x1
32596efe47SPaul Walmsley 
33a58caad1STony Lindgren static void __iomem *omap2_ctrl_base;
340c349246SSantosh Shilimkar static void __iomem *omap4_ctrl_pad_base;
3569d88a00SPaul Walmsley 
36c96631e1SRajendra Nayak #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
3780140786SRajendra Nayak struct omap3_scratchpad {
3880140786SRajendra Nayak 	u32 boot_config_ptr;
3980140786SRajendra Nayak 	u32 public_restore_ptr;
4080140786SRajendra Nayak 	u32 secure_ram_restore_ptr;
4180140786SRajendra Nayak 	u32 sdrc_module_semaphore;
4280140786SRajendra Nayak 	u32 prcm_block_offset;
4380140786SRajendra Nayak 	u32 sdrc_block_offset;
4480140786SRajendra Nayak };
4580140786SRajendra Nayak 
4680140786SRajendra Nayak struct omap3_scratchpad_prcm_block {
4780140786SRajendra Nayak 	u32 prm_clksrc_ctrl;
4880140786SRajendra Nayak 	u32 prm_clksel;
4980140786SRajendra Nayak 	u32 cm_clksel_core;
5080140786SRajendra Nayak 	u32 cm_clksel_wkup;
5180140786SRajendra Nayak 	u32 cm_clken_pll;
5280140786SRajendra Nayak 	u32 cm_autoidle_pll;
5380140786SRajendra Nayak 	u32 cm_clksel1_pll;
5480140786SRajendra Nayak 	u32 cm_clksel2_pll;
5580140786SRajendra Nayak 	u32 cm_clksel3_pll;
5680140786SRajendra Nayak 	u32 cm_clken_pll_mpu;
5780140786SRajendra Nayak 	u32 cm_autoidle_pll_mpu;
5880140786SRajendra Nayak 	u32 cm_clksel1_pll_mpu;
5980140786SRajendra Nayak 	u32 cm_clksel2_pll_mpu;
6080140786SRajendra Nayak 	u32 prcm_block_size;
6180140786SRajendra Nayak };
6280140786SRajendra Nayak 
6380140786SRajendra Nayak struct omap3_scratchpad_sdrc_block {
6480140786SRajendra Nayak 	u16 sysconfig;
6580140786SRajendra Nayak 	u16 cs_cfg;
6680140786SRajendra Nayak 	u16 sharing;
6780140786SRajendra Nayak 	u16 err_type;
6880140786SRajendra Nayak 	u32 dll_a_ctrl;
6980140786SRajendra Nayak 	u32 dll_b_ctrl;
7080140786SRajendra Nayak 	u32 power;
7180140786SRajendra Nayak 	u32 cs_0;
7280140786SRajendra Nayak 	u32 mcfg_0;
7380140786SRajendra Nayak 	u16 mr_0;
7480140786SRajendra Nayak 	u16 emr_1_0;
7580140786SRajendra Nayak 	u16 emr_2_0;
7680140786SRajendra Nayak 	u16 emr_3_0;
7780140786SRajendra Nayak 	u32 actim_ctrla_0;
7880140786SRajendra Nayak 	u32 actim_ctrlb_0;
7980140786SRajendra Nayak 	u32 rfr_ctrl_0;
8080140786SRajendra Nayak 	u32 cs_1;
8180140786SRajendra Nayak 	u32 mcfg_1;
8280140786SRajendra Nayak 	u16 mr_1;
8380140786SRajendra Nayak 	u16 emr_1_1;
8480140786SRajendra Nayak 	u16 emr_2_1;
8580140786SRajendra Nayak 	u16 emr_3_1;
8680140786SRajendra Nayak 	u32 actim_ctrla_1;
8780140786SRajendra Nayak 	u32 actim_ctrlb_1;
8880140786SRajendra Nayak 	u32 rfr_ctrl_1;
8980140786SRajendra Nayak 	u16 dcdl_1_ctrl;
9080140786SRajendra Nayak 	u16 dcdl_2_ctrl;
9180140786SRajendra Nayak 	u32 flags;
9280140786SRajendra Nayak 	u32 block_size;
9380140786SRajendra Nayak };
9480140786SRajendra Nayak 
9527d59a4aSTero Kristo void *omap3_secure_ram_storage;
9627d59a4aSTero Kristo 
9780140786SRajendra Nayak /*
9880140786SRajendra Nayak  * This is used to store ARM registers in SDRAM before attempting
9980140786SRajendra Nayak  * an MPU OFF. The save and restore happens from the SRAM sleep code.
10080140786SRajendra Nayak  * The address is stored in scratchpad, so that it can be used
10180140786SRajendra Nayak  * during the restore path.
10280140786SRajendra Nayak  */
10380140786SRajendra Nayak u32 omap3_arm_context[128];
10480140786SRajendra Nayak 
105c96631e1SRajendra Nayak struct omap3_control_regs {
106c96631e1SRajendra Nayak 	u32 sysconfig;
107c96631e1SRajendra Nayak 	u32 devconf0;
108c96631e1SRajendra Nayak 	u32 mem_dftrw0;
109c96631e1SRajendra Nayak 	u32 mem_dftrw1;
110c96631e1SRajendra Nayak 	u32 msuspendmux_0;
111c96631e1SRajendra Nayak 	u32 msuspendmux_1;
112c96631e1SRajendra Nayak 	u32 msuspendmux_2;
113c96631e1SRajendra Nayak 	u32 msuspendmux_3;
114c96631e1SRajendra Nayak 	u32 msuspendmux_4;
115c96631e1SRajendra Nayak 	u32 msuspendmux_5;
116c96631e1SRajendra Nayak 	u32 sec_ctrl;
117c96631e1SRajendra Nayak 	u32 devconf1;
118c96631e1SRajendra Nayak 	u32 csirxfe;
119c96631e1SRajendra Nayak 	u32 iva2_bootaddr;
120c96631e1SRajendra Nayak 	u32 iva2_bootmod;
121c96631e1SRajendra Nayak 	u32 debobs_0;
122c96631e1SRajendra Nayak 	u32 debobs_1;
123c96631e1SRajendra Nayak 	u32 debobs_2;
124c96631e1SRajendra Nayak 	u32 debobs_3;
125c96631e1SRajendra Nayak 	u32 debobs_4;
126c96631e1SRajendra Nayak 	u32 debobs_5;
127c96631e1SRajendra Nayak 	u32 debobs_6;
128c96631e1SRajendra Nayak 	u32 debobs_7;
129c96631e1SRajendra Nayak 	u32 debobs_8;
130c96631e1SRajendra Nayak 	u32 prog_io0;
131c96631e1SRajendra Nayak 	u32 prog_io1;
132c96631e1SRajendra Nayak 	u32 dss_dpll_spreading;
133c96631e1SRajendra Nayak 	u32 core_dpll_spreading;
134c96631e1SRajendra Nayak 	u32 per_dpll_spreading;
135c96631e1SRajendra Nayak 	u32 usbhost_dpll_spreading;
136c96631e1SRajendra Nayak 	u32 pbias_lite;
137c96631e1SRajendra Nayak 	u32 temp_sensor;
138c96631e1SRajendra Nayak 	u32 sramldo4;
139c96631e1SRajendra Nayak 	u32 sramldo5;
140c96631e1SRajendra Nayak 	u32 csi;
141f5f9d132SPaul Walmsley 	u32 padconf_sys_nirq;
142c96631e1SRajendra Nayak };
143c96631e1SRajendra Nayak 
144c96631e1SRajendra Nayak static struct omap3_control_regs control_context;
145c96631e1SRajendra Nayak #endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */
146c96631e1SRajendra Nayak 
147a58caad1STony Lindgren #define OMAP_CTRL_REGADDR(reg)		(omap2_ctrl_base + (reg))
14870ba71a2SSantosh Shilimkar #define OMAP4_CTRL_PAD_REGADDR(reg)	(omap4_ctrl_pad_base + (reg))
14969d88a00SPaul Walmsley 
150b6a4226cSPaul Walmsley void __init omap2_set_globals_control(void __iomem *ctrl,
151b6a4226cSPaul Walmsley 				      void __iomem *ctrl_pad)
15269d88a00SPaul Walmsley {
153b6a4226cSPaul Walmsley 	omap2_ctrl_base = ctrl;
154b6a4226cSPaul Walmsley 	omap4_ctrl_pad_base = ctrl_pad;
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 
19270ba71a2SSantosh Shilimkar /*
19370ba71a2SSantosh Shilimkar  * On OMAP4 control pad are not addressable from control
19470ba71a2SSantosh Shilimkar  * core base. So the common omap_ctrl_read/write APIs breaks
19570ba71a2SSantosh Shilimkar  * Hence export separate APIs to manage the omap4 pad control
19670ba71a2SSantosh Shilimkar  * registers. This APIs will work only for OMAP4
19770ba71a2SSantosh Shilimkar  */
19870ba71a2SSantosh Shilimkar 
19970ba71a2SSantosh Shilimkar u32 omap4_ctrl_pad_readl(u16 offset)
20070ba71a2SSantosh Shilimkar {
20170ba71a2SSantosh Shilimkar 	return __raw_readl(OMAP4_CTRL_PAD_REGADDR(offset));
20270ba71a2SSantosh Shilimkar }
20370ba71a2SSantosh Shilimkar 
20470ba71a2SSantosh Shilimkar void omap4_ctrl_pad_writel(u32 val, u16 offset)
20570ba71a2SSantosh Shilimkar {
20670ba71a2SSantosh Shilimkar 	__raw_writel(val, OMAP4_CTRL_PAD_REGADDR(offset));
20770ba71a2SSantosh Shilimkar }
20870ba71a2SSantosh Shilimkar 
209166353bdSPaul Walmsley #ifdef CONFIG_ARCH_OMAP3
210166353bdSPaul Walmsley 
211166353bdSPaul Walmsley /**
212166353bdSPaul Walmsley  * omap3_ctrl_write_boot_mode - set scratchpad boot mode for the next boot
213166353bdSPaul Walmsley  * @bootmode: 8-bit value to pass to some boot code
214166353bdSPaul Walmsley  *
215166353bdSPaul Walmsley  * Set the bootmode in the scratchpad RAM.  This is used after the
216166353bdSPaul Walmsley  * system restarts.  Not sure what actually uses this - it may be the
217166353bdSPaul Walmsley  * bootloader, rather than the boot ROM - contrary to the preserved
218166353bdSPaul Walmsley  * comment below.  No return value.
219166353bdSPaul Walmsley  */
220166353bdSPaul Walmsley void omap3_ctrl_write_boot_mode(u8 bootmode)
221166353bdSPaul Walmsley {
222166353bdSPaul Walmsley 	u32 l;
223166353bdSPaul Walmsley 
224166353bdSPaul Walmsley 	l = ('B' << 24) | ('M' << 16) | bootmode;
225166353bdSPaul Walmsley 
226166353bdSPaul Walmsley 	/*
227166353bdSPaul Walmsley 	 * Reserve the first word in scratchpad for communicating
228166353bdSPaul Walmsley 	 * with the boot ROM. A pointer to a data structure
229166353bdSPaul Walmsley 	 * describing the boot process can be stored there,
230166353bdSPaul Walmsley 	 * cf. OMAP34xx TRM, Initialization / Software Booting
231166353bdSPaul Walmsley 	 * Configuration.
232166353bdSPaul Walmsley 	 *
233166353bdSPaul Walmsley 	 * XXX This should use some omap_ctrl_writel()-type function
234166353bdSPaul Walmsley 	 */
235166353bdSPaul Walmsley 	__raw_writel(l, OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD + 4));
236166353bdSPaul Walmsley }
237166353bdSPaul Walmsley 
238166353bdSPaul Walmsley #endif
239166353bdSPaul Walmsley 
24090f1380eSOmar Ramirez Luna /**
24190f1380eSOmar Ramirez Luna  * omap_ctrl_write_dsp_boot_addr - set boot address for a remote processor
24290f1380eSOmar Ramirez Luna  * @bootaddr: physical address of the boot loader
24390f1380eSOmar Ramirez Luna  *
24490f1380eSOmar Ramirez Luna  * Set boot address for the boot loader of a supported processor
24590f1380eSOmar Ramirez Luna  * when a power ON sequence occurs.
24690f1380eSOmar Ramirez Luna  */
24790f1380eSOmar Ramirez Luna void omap_ctrl_write_dsp_boot_addr(u32 bootaddr)
24890f1380eSOmar Ramirez Luna {
24990f1380eSOmar Ramirez Luna 	u32 offset = cpu_is_omap243x() ? OMAP243X_CONTROL_IVA2_BOOTADDR :
25090f1380eSOmar Ramirez Luna 		     cpu_is_omap34xx() ? OMAP343X_CONTROL_IVA2_BOOTADDR :
25190f1380eSOmar Ramirez Luna 		     cpu_is_omap44xx() ? OMAP4_CTRL_MODULE_CORE_DSP_BOOTADDR :
252*668468b1SSuman Anna 		     soc_is_omap54xx() ? OMAP4_CTRL_MODULE_CORE_DSP_BOOTADDR :
25390f1380eSOmar Ramirez Luna 		     0;
25490f1380eSOmar Ramirez Luna 
25590f1380eSOmar Ramirez Luna 	if (!offset) {
25690f1380eSOmar Ramirez Luna 		pr_err("%s: unsupported omap type\n", __func__);
25790f1380eSOmar Ramirez Luna 		return;
25890f1380eSOmar Ramirez Luna 	}
25990f1380eSOmar Ramirez Luna 
26090f1380eSOmar Ramirez Luna 	omap_ctrl_writel(bootaddr, offset);
26190f1380eSOmar Ramirez Luna }
26290f1380eSOmar Ramirez Luna 
26390f1380eSOmar Ramirez Luna /**
26490f1380eSOmar Ramirez Luna  * omap_ctrl_write_dsp_boot_mode - set boot mode for a remote processor
26590f1380eSOmar Ramirez Luna  * @bootmode: 8-bit value to pass to some boot code
26690f1380eSOmar Ramirez Luna  *
26790f1380eSOmar Ramirez Luna  * Sets boot mode for the boot loader of a supported processor
26890f1380eSOmar Ramirez Luna  * when a power ON sequence occurs.
26990f1380eSOmar Ramirez Luna  */
27090f1380eSOmar Ramirez Luna void omap_ctrl_write_dsp_boot_mode(u8 bootmode)
27190f1380eSOmar Ramirez Luna {
27290f1380eSOmar Ramirez Luna 	u32 offset = cpu_is_omap243x() ? OMAP243X_CONTROL_IVA2_BOOTMOD :
27390f1380eSOmar Ramirez Luna 		     cpu_is_omap34xx() ? OMAP343X_CONTROL_IVA2_BOOTMOD :
27490f1380eSOmar Ramirez Luna 		     0;
27590f1380eSOmar Ramirez Luna 
27690f1380eSOmar Ramirez Luna 	if (!offset) {
27790f1380eSOmar Ramirez Luna 		pr_err("%s: unsupported omap type\n", __func__);
27890f1380eSOmar Ramirez Luna 		return;
27990f1380eSOmar Ramirez Luna 	}
28090f1380eSOmar Ramirez Luna 
28190f1380eSOmar Ramirez Luna 	omap_ctrl_writel(bootmode, offset);
28290f1380eSOmar Ramirez Luna }
28390f1380eSOmar Ramirez Luna 
284c96631e1SRajendra Nayak #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
28580140786SRajendra Nayak /*
28680140786SRajendra Nayak  * Clears the scratchpad contents in case of cold boot-
28780140786SRajendra Nayak  * called during bootup
28880140786SRajendra Nayak  */
28980140786SRajendra Nayak void omap3_clear_scratchpad_contents(void)
29080140786SRajendra Nayak {
29180140786SRajendra Nayak 	u32 max_offset = OMAP343X_SCRATCHPAD_ROM_OFFSET;
2924d63bc1dSManjunath Kondaiah G 	void __iomem *v_addr;
29380140786SRajendra Nayak 	u32 offset = 0;
29480140786SRajendra Nayak 	v_addr = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD_ROM);
295c4d7e58fSPaul Walmsley 	if (omap2_prm_read_mod_reg(OMAP3430_GR_MOD, OMAP3_PRM_RSTST_OFFSET) &
2962bc4ef71SPaul Walmsley 	    OMAP3430_GLOBAL_COLD_RST_MASK) {
29780140786SRajendra Nayak 		for ( ; offset <= max_offset; offset += 0x4)
29880140786SRajendra Nayak 			__raw_writel(0x0, (v_addr + offset));
299c4d7e58fSPaul Walmsley 		omap2_prm_set_mod_reg_bits(OMAP3430_GLOBAL_COLD_RST_MASK,
3002bc4ef71SPaul Walmsley 					   OMAP3430_GR_MOD,
30180140786SRajendra Nayak 					   OMAP3_PRM_RSTST_OFFSET);
30280140786SRajendra Nayak 	}
30380140786SRajendra Nayak }
30480140786SRajendra Nayak 
30580140786SRajendra Nayak /* Populate the scratchpad structure with restore structure */
30680140786SRajendra Nayak void omap3_save_scratchpad_contents(void)
30780140786SRajendra Nayak {
3084d63bc1dSManjunath Kondaiah G 	void  __iomem *scratchpad_address;
30980140786SRajendra Nayak 	u32 arm_context_addr;
31080140786SRajendra Nayak 	struct omap3_scratchpad scratchpad_contents;
31180140786SRajendra Nayak 	struct omap3_scratchpad_prcm_block prcm_block_contents;
31280140786SRajendra Nayak 	struct omap3_scratchpad_sdrc_block sdrc_block_contents;
31380140786SRajendra Nayak 
314f7dfe3d8SJean Pihet 	/*
315f7dfe3d8SJean Pihet 	 * Populate the Scratchpad contents
316f7dfe3d8SJean Pihet 	 *
317f7dfe3d8SJean Pihet 	 * The "get_*restore_pointer" functions are used to provide a
318f7dfe3d8SJean Pihet 	 * physical restore address where the ROM code jumps while waking
319f7dfe3d8SJean Pihet 	 * up from MPU OFF/OSWR state.
320f7dfe3d8SJean Pihet 	 * The restore pointer is stored into the scratchpad.
321f7dfe3d8SJean Pihet 	 */
32280140786SRajendra Nayak 	scratchpad_contents.boot_config_ptr = 0x0;
323458e999eSNishanth Menon 	if (cpu_is_omap3630())
324458e999eSNishanth Menon 		scratchpad_contents.public_restore_ptr =
32514c79bbeSKevin Hilman 			virt_to_phys(omap3_restore_3630);
326458e999eSNishanth Menon 	else if (omap_rev() != OMAP3430_REV_ES3_0 &&
3270795a75aSTero Kristo 					omap_rev() != OMAP3430_REV_ES3_1)
32880140786SRajendra Nayak 		scratchpad_contents.public_restore_ptr =
32914c79bbeSKevin Hilman 			virt_to_phys(omap3_restore);
3300795a75aSTero Kristo 	else
3310795a75aSTero Kristo 		scratchpad_contents.public_restore_ptr =
33214c79bbeSKevin Hilman 			virt_to_phys(omap3_restore_es3);
33314c79bbeSKevin Hilman 
33427d59a4aSTero Kristo 	if (omap_type() == OMAP2_DEVICE_TYPE_GP)
33580140786SRajendra Nayak 		scratchpad_contents.secure_ram_restore_ptr = 0x0;
33627d59a4aSTero Kristo 	else
33727d59a4aSTero Kristo 		scratchpad_contents.secure_ram_restore_ptr =
33827d59a4aSTero Kristo 			(u32) __pa(omap3_secure_ram_storage);
33980140786SRajendra Nayak 	scratchpad_contents.sdrc_module_semaphore = 0x0;
34080140786SRajendra Nayak 	scratchpad_contents.prcm_block_offset = 0x2C;
34180140786SRajendra Nayak 	scratchpad_contents.sdrc_block_offset = 0x64;
34280140786SRajendra Nayak 
34380140786SRajendra Nayak 	/* Populate the PRCM block contents */
344c4d7e58fSPaul Walmsley 	prcm_block_contents.prm_clksrc_ctrl =
345c4d7e58fSPaul Walmsley 		omap2_prm_read_mod_reg(OMAP3430_GR_MOD,
34680140786SRajendra Nayak 				       OMAP3_PRM_CLKSRC_CTRL_OFFSET);
347c4d7e58fSPaul Walmsley 	prcm_block_contents.prm_clksel =
348c4d7e58fSPaul Walmsley 		omap2_prm_read_mod_reg(OMAP3430_CCR_MOD,
34980140786SRajendra Nayak 				       OMAP3_PRM_CLKSEL_OFFSET);
35080140786SRajendra Nayak 	prcm_block_contents.cm_clksel_core =
351c4d7e58fSPaul Walmsley 			omap2_cm_read_mod_reg(CORE_MOD, CM_CLKSEL);
35280140786SRajendra Nayak 	prcm_block_contents.cm_clksel_wkup =
353c4d7e58fSPaul Walmsley 			omap2_cm_read_mod_reg(WKUP_MOD, CM_CLKSEL);
35480140786SRajendra Nayak 	prcm_block_contents.cm_clken_pll =
355c4d7e58fSPaul Walmsley 			omap2_cm_read_mod_reg(PLL_MOD, CM_CLKEN);
356a8ae645cSEduardo Valentin 	/*
357a8ae645cSEduardo Valentin 	 * As per erratum i671, ROM code does not respect the PER DPLL
358a8ae645cSEduardo Valentin 	 * programming scheme if CM_AUTOIDLE_PLL..AUTO_PERIPH_DPLL == 1.
359a8ae645cSEduardo Valentin 	 * Then,  in anycase, clear these bits to avoid extra latencies.
360a8ae645cSEduardo Valentin 	 */
36180140786SRajendra Nayak 	prcm_block_contents.cm_autoidle_pll =
362a8ae645cSEduardo Valentin 			omap2_cm_read_mod_reg(PLL_MOD, CM_AUTOIDLE) &
363a8ae645cSEduardo Valentin 			~OMAP3430_AUTO_PERIPH_DPLL_MASK;
36480140786SRajendra Nayak 	prcm_block_contents.cm_clksel1_pll =
365c4d7e58fSPaul Walmsley 			omap2_cm_read_mod_reg(PLL_MOD, OMAP3430_CM_CLKSEL1_PLL);
36680140786SRajendra Nayak 	prcm_block_contents.cm_clksel2_pll =
367c4d7e58fSPaul Walmsley 			omap2_cm_read_mod_reg(PLL_MOD, OMAP3430_CM_CLKSEL2_PLL);
36880140786SRajendra Nayak 	prcm_block_contents.cm_clksel3_pll =
369c4d7e58fSPaul Walmsley 			omap2_cm_read_mod_reg(PLL_MOD, OMAP3430_CM_CLKSEL3);
37080140786SRajendra Nayak 	prcm_block_contents.cm_clken_pll_mpu =
371c4d7e58fSPaul Walmsley 			omap2_cm_read_mod_reg(MPU_MOD, OMAP3430_CM_CLKEN_PLL);
37280140786SRajendra Nayak 	prcm_block_contents.cm_autoidle_pll_mpu =
373c4d7e58fSPaul Walmsley 			omap2_cm_read_mod_reg(MPU_MOD, OMAP3430_CM_AUTOIDLE_PLL);
37480140786SRajendra Nayak 	prcm_block_contents.cm_clksel1_pll_mpu =
375c4d7e58fSPaul Walmsley 			omap2_cm_read_mod_reg(MPU_MOD, OMAP3430_CM_CLKSEL1_PLL);
37680140786SRajendra Nayak 	prcm_block_contents.cm_clksel2_pll_mpu =
377c4d7e58fSPaul Walmsley 			omap2_cm_read_mod_reg(MPU_MOD, OMAP3430_CM_CLKSEL2_PLL);
37880140786SRajendra Nayak 	prcm_block_contents.prcm_block_size = 0x0;
37980140786SRajendra Nayak 
38080140786SRajendra Nayak 	/* Populate the SDRC block contents */
38180140786SRajendra Nayak 	sdrc_block_contents.sysconfig =
38280140786SRajendra Nayak 			(sdrc_read_reg(SDRC_SYSCONFIG) & 0xFFFF);
38380140786SRajendra Nayak 	sdrc_block_contents.cs_cfg =
38480140786SRajendra Nayak 			(sdrc_read_reg(SDRC_CS_CFG) & 0xFFFF);
38580140786SRajendra Nayak 	sdrc_block_contents.sharing =
38680140786SRajendra Nayak 			(sdrc_read_reg(SDRC_SHARING) & 0xFFFF);
38780140786SRajendra Nayak 	sdrc_block_contents.err_type =
38880140786SRajendra Nayak 			(sdrc_read_reg(SDRC_ERR_TYPE) & 0xFFFF);
38980140786SRajendra Nayak 	sdrc_block_contents.dll_a_ctrl = sdrc_read_reg(SDRC_DLLA_CTRL);
39080140786SRajendra Nayak 	sdrc_block_contents.dll_b_ctrl = 0x0;
391f265dc4cSRajendra Nayak 	/*
392f265dc4cSRajendra Nayak 	 * Due to a OMAP3 errata (1.142), on EMU/HS devices SRDC should
393f265dc4cSRajendra Nayak 	 * be programed to issue automatic self refresh on timeout
394f265dc4cSRajendra Nayak 	 * of AUTO_CNT = 1 prior to any transition to OFF mode.
395f265dc4cSRajendra Nayak 	 */
396f265dc4cSRajendra Nayak 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)
397f265dc4cSRajendra Nayak 			&& (omap_rev() >= OMAP3430_REV_ES3_0))
398f265dc4cSRajendra Nayak 		sdrc_block_contents.power = (sdrc_read_reg(SDRC_POWER) &
399f265dc4cSRajendra Nayak 				~(SDRC_POWER_AUTOCOUNT_MASK|
400f265dc4cSRajendra Nayak 				SDRC_POWER_CLKCTRL_MASK)) |
401f265dc4cSRajendra Nayak 				(1 << SDRC_POWER_AUTOCOUNT_SHIFT) |
402f265dc4cSRajendra Nayak 				SDRC_SELF_REFRESH_ON_AUTOCOUNT;
403f265dc4cSRajendra Nayak 	else
40480140786SRajendra Nayak 		sdrc_block_contents.power = sdrc_read_reg(SDRC_POWER);
405f265dc4cSRajendra Nayak 
40680140786SRajendra Nayak 	sdrc_block_contents.cs_0 = 0x0;
40780140786SRajendra Nayak 	sdrc_block_contents.mcfg_0 = sdrc_read_reg(SDRC_MCFG_0);
40880140786SRajendra Nayak 	sdrc_block_contents.mr_0 = (sdrc_read_reg(SDRC_MR_0) & 0xFFFF);
40980140786SRajendra Nayak 	sdrc_block_contents.emr_1_0 = 0x0;
41080140786SRajendra Nayak 	sdrc_block_contents.emr_2_0 = 0x0;
41180140786SRajendra Nayak 	sdrc_block_contents.emr_3_0 = 0x0;
41280140786SRajendra Nayak 	sdrc_block_contents.actim_ctrla_0 =
41380140786SRajendra Nayak 			sdrc_read_reg(SDRC_ACTIM_CTRL_A_0);
41480140786SRajendra Nayak 	sdrc_block_contents.actim_ctrlb_0 =
41580140786SRajendra Nayak 			sdrc_read_reg(SDRC_ACTIM_CTRL_B_0);
41680140786SRajendra Nayak 	sdrc_block_contents.rfr_ctrl_0 =
41780140786SRajendra Nayak 			sdrc_read_reg(SDRC_RFR_CTRL_0);
41880140786SRajendra Nayak 	sdrc_block_contents.cs_1 = 0x0;
41980140786SRajendra Nayak 	sdrc_block_contents.mcfg_1 = sdrc_read_reg(SDRC_MCFG_1);
42080140786SRajendra Nayak 	sdrc_block_contents.mr_1 = sdrc_read_reg(SDRC_MR_1) & 0xFFFF;
42180140786SRajendra Nayak 	sdrc_block_contents.emr_1_1 = 0x0;
42280140786SRajendra Nayak 	sdrc_block_contents.emr_2_1 = 0x0;
42380140786SRajendra Nayak 	sdrc_block_contents.emr_3_1 = 0x0;
42480140786SRajendra Nayak 	sdrc_block_contents.actim_ctrla_1 =
42580140786SRajendra Nayak 			sdrc_read_reg(SDRC_ACTIM_CTRL_A_1);
42680140786SRajendra Nayak 	sdrc_block_contents.actim_ctrlb_1 =
42780140786SRajendra Nayak 			sdrc_read_reg(SDRC_ACTIM_CTRL_B_1);
42880140786SRajendra Nayak 	sdrc_block_contents.rfr_ctrl_1 =
42980140786SRajendra Nayak 			sdrc_read_reg(SDRC_RFR_CTRL_1);
43080140786SRajendra Nayak 	sdrc_block_contents.dcdl_1_ctrl = 0x0;
43180140786SRajendra Nayak 	sdrc_block_contents.dcdl_2_ctrl = 0x0;
43280140786SRajendra Nayak 	sdrc_block_contents.flags = 0x0;
43380140786SRajendra Nayak 	sdrc_block_contents.block_size = 0x0;
43480140786SRajendra Nayak 
43580140786SRajendra Nayak 	arm_context_addr = virt_to_phys(omap3_arm_context);
43680140786SRajendra Nayak 
43780140786SRajendra Nayak 	/* Copy all the contents to the scratchpad location */
43880140786SRajendra Nayak 	scratchpad_address = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD);
43980140786SRajendra Nayak 	memcpy_toio(scratchpad_address, &scratchpad_contents,
44080140786SRajendra Nayak 		 sizeof(scratchpad_contents));
44180140786SRajendra Nayak 	/* Scratchpad contents being 32 bits, a divide by 4 done here */
44280140786SRajendra Nayak 	memcpy_toio(scratchpad_address +
44380140786SRajendra Nayak 		scratchpad_contents.prcm_block_offset,
44480140786SRajendra Nayak 		&prcm_block_contents, sizeof(prcm_block_contents));
44580140786SRajendra Nayak 	memcpy_toio(scratchpad_address +
44680140786SRajendra Nayak 		scratchpad_contents.sdrc_block_offset,
44780140786SRajendra Nayak 		&sdrc_block_contents, sizeof(sdrc_block_contents));
44880140786SRajendra Nayak 	/*
44980140786SRajendra Nayak 	 * Copies the address of the location in SDRAM where ARM
45080140786SRajendra Nayak 	 * registers get saved during a MPU OFF transition.
45180140786SRajendra Nayak 	 */
45280140786SRajendra Nayak 	memcpy_toio(scratchpad_address +
45380140786SRajendra Nayak 		scratchpad_contents.sdrc_block_offset +
45480140786SRajendra Nayak 		sizeof(sdrc_block_contents), &arm_context_addr, 4);
45580140786SRajendra Nayak }
45680140786SRajendra Nayak 
457c96631e1SRajendra Nayak void omap3_control_save_context(void)
458c96631e1SRajendra Nayak {
459c96631e1SRajendra Nayak 	control_context.sysconfig = omap_ctrl_readl(OMAP2_CONTROL_SYSCONFIG);
460c96631e1SRajendra Nayak 	control_context.devconf0 = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
461c96631e1SRajendra Nayak 	control_context.mem_dftrw0 =
462c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_MEM_DFTRW0);
463c96631e1SRajendra Nayak 	control_context.mem_dftrw1 =
464c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_MEM_DFTRW1);
465c96631e1SRajendra Nayak 	control_context.msuspendmux_0 =
466c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_0);
467c96631e1SRajendra Nayak 	control_context.msuspendmux_1 =
468c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_1);
469c96631e1SRajendra Nayak 	control_context.msuspendmux_2 =
470c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_2);
471c96631e1SRajendra Nayak 	control_context.msuspendmux_3 =
472c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_3);
473c96631e1SRajendra Nayak 	control_context.msuspendmux_4 =
474c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_4);
475c96631e1SRajendra Nayak 	control_context.msuspendmux_5 =
476c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP2_CONTROL_MSUSPENDMUX_5);
477c96631e1SRajendra Nayak 	control_context.sec_ctrl = omap_ctrl_readl(OMAP2_CONTROL_SEC_CTRL);
478c96631e1SRajendra Nayak 	control_context.devconf1 = omap_ctrl_readl(OMAP343X_CONTROL_DEVCONF1);
479c96631e1SRajendra Nayak 	control_context.csirxfe = omap_ctrl_readl(OMAP343X_CONTROL_CSIRXFE);
480c96631e1SRajendra Nayak 	control_context.iva2_bootaddr =
481c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_IVA2_BOOTADDR);
482c96631e1SRajendra Nayak 	control_context.iva2_bootmod =
483c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_IVA2_BOOTMOD);
484c96631e1SRajendra Nayak 	control_context.debobs_0 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(0));
485c96631e1SRajendra Nayak 	control_context.debobs_1 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(1));
486c96631e1SRajendra Nayak 	control_context.debobs_2 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(2));
487c96631e1SRajendra Nayak 	control_context.debobs_3 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(3));
488c96631e1SRajendra Nayak 	control_context.debobs_4 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(4));
489c96631e1SRajendra Nayak 	control_context.debobs_5 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(5));
490c96631e1SRajendra Nayak 	control_context.debobs_6 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(6));
491c96631e1SRajendra Nayak 	control_context.debobs_7 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(7));
492c96631e1SRajendra Nayak 	control_context.debobs_8 = omap_ctrl_readl(OMAP343X_CONTROL_DEBOBS(8));
493c96631e1SRajendra Nayak 	control_context.prog_io0 = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO0);
494c96631e1SRajendra Nayak 	control_context.prog_io1 = omap_ctrl_readl(OMAP343X_CONTROL_PROG_IO1);
495c96631e1SRajendra Nayak 	control_context.dss_dpll_spreading =
496c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_DSS_DPLL_SPREADING);
497c96631e1SRajendra Nayak 	control_context.core_dpll_spreading =
498c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_CORE_DPLL_SPREADING);
499c96631e1SRajendra Nayak 	control_context.per_dpll_spreading =
500c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_PER_DPLL_SPREADING);
501c96631e1SRajendra Nayak 	control_context.usbhost_dpll_spreading =
502c96631e1SRajendra Nayak 		omap_ctrl_readl(OMAP343X_CONTROL_USBHOST_DPLL_SPREADING);
503c96631e1SRajendra Nayak 	control_context.pbias_lite =
504c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_PBIAS_LITE);
505c96631e1SRajendra Nayak 	control_context.temp_sensor =
506c96631e1SRajendra Nayak 			omap_ctrl_readl(OMAP343X_CONTROL_TEMP_SENSOR);
507c96631e1SRajendra Nayak 	control_context.sramldo4 = omap_ctrl_readl(OMAP343X_CONTROL_SRAMLDO4);
508c96631e1SRajendra Nayak 	control_context.sramldo5 = omap_ctrl_readl(OMAP343X_CONTROL_SRAMLDO5);
509c96631e1SRajendra Nayak 	control_context.csi = omap_ctrl_readl(OMAP343X_CONTROL_CSI);
510f5f9d132SPaul Walmsley 	control_context.padconf_sys_nirq =
511f5f9d132SPaul Walmsley 		omap_ctrl_readl(OMAP343X_CONTROL_PADCONF_SYSNIRQ);
512c96631e1SRajendra Nayak 	return;
513c96631e1SRajendra Nayak }
514c96631e1SRajendra Nayak 
515c96631e1SRajendra Nayak void omap3_control_restore_context(void)
516c96631e1SRajendra Nayak {
517c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.sysconfig, OMAP2_CONTROL_SYSCONFIG);
518c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.devconf0, OMAP2_CONTROL_DEVCONF0);
519c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.mem_dftrw0,
520c96631e1SRajendra Nayak 					OMAP343X_CONTROL_MEM_DFTRW0);
521c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.mem_dftrw1,
522c96631e1SRajendra Nayak 					OMAP343X_CONTROL_MEM_DFTRW1);
523c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.msuspendmux_0,
524c96631e1SRajendra Nayak 					OMAP2_CONTROL_MSUSPENDMUX_0);
525c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.msuspendmux_1,
526c96631e1SRajendra Nayak 					OMAP2_CONTROL_MSUSPENDMUX_1);
527c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.msuspendmux_2,
528c96631e1SRajendra Nayak 					OMAP2_CONTROL_MSUSPENDMUX_2);
529c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.msuspendmux_3,
530c96631e1SRajendra Nayak 					OMAP2_CONTROL_MSUSPENDMUX_3);
531c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.msuspendmux_4,
532c96631e1SRajendra Nayak 					OMAP2_CONTROL_MSUSPENDMUX_4);
533c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.msuspendmux_5,
534c96631e1SRajendra Nayak 					OMAP2_CONTROL_MSUSPENDMUX_5);
535c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.sec_ctrl, OMAP2_CONTROL_SEC_CTRL);
536c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.devconf1, OMAP343X_CONTROL_DEVCONF1);
537c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.csirxfe, OMAP343X_CONTROL_CSIRXFE);
538c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.iva2_bootaddr,
539c96631e1SRajendra Nayak 					OMAP343X_CONTROL_IVA2_BOOTADDR);
540c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.iva2_bootmod,
541c96631e1SRajendra Nayak 					OMAP343X_CONTROL_IVA2_BOOTMOD);
542c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_0, OMAP343X_CONTROL_DEBOBS(0));
543c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_1, OMAP343X_CONTROL_DEBOBS(1));
544c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_2, OMAP343X_CONTROL_DEBOBS(2));
545c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_3, OMAP343X_CONTROL_DEBOBS(3));
546c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_4, OMAP343X_CONTROL_DEBOBS(4));
547c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_5, OMAP343X_CONTROL_DEBOBS(5));
548c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_6, OMAP343X_CONTROL_DEBOBS(6));
549c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_7, OMAP343X_CONTROL_DEBOBS(7));
550c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.debobs_8, OMAP343X_CONTROL_DEBOBS(8));
551c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.prog_io0, OMAP343X_CONTROL_PROG_IO0);
552c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.prog_io1, OMAP343X_CONTROL_PROG_IO1);
553c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.dss_dpll_spreading,
554c96631e1SRajendra Nayak 					OMAP343X_CONTROL_DSS_DPLL_SPREADING);
555c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.core_dpll_spreading,
556c96631e1SRajendra Nayak 					OMAP343X_CONTROL_CORE_DPLL_SPREADING);
557c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.per_dpll_spreading,
558c96631e1SRajendra Nayak 					OMAP343X_CONTROL_PER_DPLL_SPREADING);
559c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.usbhost_dpll_spreading,
560c96631e1SRajendra Nayak 				OMAP343X_CONTROL_USBHOST_DPLL_SPREADING);
561c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.pbias_lite,
562c96631e1SRajendra Nayak 					OMAP343X_CONTROL_PBIAS_LITE);
563c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.temp_sensor,
564c96631e1SRajendra Nayak 					OMAP343X_CONTROL_TEMP_SENSOR);
565c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.sramldo4, OMAP343X_CONTROL_SRAMLDO4);
566c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.sramldo5, OMAP343X_CONTROL_SRAMLDO5);
567c96631e1SRajendra Nayak 	omap_ctrl_writel(control_context.csi, OMAP343X_CONTROL_CSI);
568f5f9d132SPaul Walmsley 	omap_ctrl_writel(control_context.padconf_sys_nirq,
569f5f9d132SPaul Walmsley 			 OMAP343X_CONTROL_PADCONF_SYSNIRQ);
570c96631e1SRajendra Nayak 	return;
571c96631e1SRajendra Nayak }
572458e999eSNishanth Menon 
573458e999eSNishanth Menon void omap3630_ctrl_disable_rta(void)
574458e999eSNishanth Menon {
575458e999eSNishanth Menon 	if (!cpu_is_omap3630())
576458e999eSNishanth Menon 		return;
577458e999eSNishanth Menon 	omap_ctrl_writel(OMAP36XX_RTA_DISABLE, OMAP36XX_CONTROL_MEM_RTA_CTRL);
578458e999eSNishanth Menon }
579458e999eSNishanth Menon 
580596efe47SPaul Walmsley /**
581596efe47SPaul Walmsley  * omap3_ctrl_save_padconf - save padconf registers to scratchpad RAM
582596efe47SPaul Walmsley  *
583596efe47SPaul Walmsley  * Tell the SCM to start saving the padconf registers, then wait for
584596efe47SPaul Walmsley  * the process to complete.  Returns 0 unconditionally, although it
585596efe47SPaul Walmsley  * should also eventually be able to return -ETIMEDOUT, if the save
586596efe47SPaul Walmsley  * does not complete.
587596efe47SPaul Walmsley  *
588596efe47SPaul Walmsley  * XXX This function is missing a timeout.  What should it be?
589596efe47SPaul Walmsley  */
590596efe47SPaul Walmsley int omap3_ctrl_save_padconf(void)
591596efe47SPaul Walmsley {
592596efe47SPaul Walmsley 	u32 cpo;
593596efe47SPaul Walmsley 
594596efe47SPaul Walmsley 	/* Save the padconf registers */
595596efe47SPaul Walmsley 	cpo = omap_ctrl_readl(OMAP343X_CONTROL_PADCONF_OFF);
596596efe47SPaul Walmsley 	cpo |= START_PADCONF_SAVE;
597596efe47SPaul Walmsley 	omap_ctrl_writel(cpo, OMAP343X_CONTROL_PADCONF_OFF);
598596efe47SPaul Walmsley 
599596efe47SPaul Walmsley 	/* wait for the save to complete */
600596efe47SPaul Walmsley 	while (!(omap_ctrl_readl(OMAP343X_CONTROL_GENERAL_PURPOSE_STATUS)
601596efe47SPaul Walmsley 		 & PADCONF_SAVE_DONE))
602596efe47SPaul Walmsley 		udelay(1);
603596efe47SPaul Walmsley 
604596efe47SPaul Walmsley 	return 0;
605596efe47SPaul Walmsley }
606596efe47SPaul Walmsley 
607c96631e1SRajendra Nayak #endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */
608