]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - sitara-epos/sitara-epos-kernel.git/blob - arch/arm/mach-omap2/cm33xx.c
ARM: OMAP: AM33XX: Update the suspend code for DS1
[sitara-epos/sitara-epos-kernel.git] / arch / arm / mach-omap2 / cm33xx.c
1 /*
2  * AM33XX CM module functions
3  *
4  * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5  *
6  * Based on arch/arm/mach-omap2/cm4xxx.c
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12 #include <linux/delay.h>
13 #include <linux/errno.h>
14 #include <linux/err.h>
15 #include <linux/io.h>
17 #include "common.h"
19 #include "cm.h"
20 #include "cm-regbits-33xx.h"
21 #include "cm33xx.h"
23 /**
24  * am33xx_cm_wait_module_ready - wait for a module to be in 'func' state
25  * @inst: Offset of CM instance associated with
26  * @clkctrl_reg: CLKCTRL offset from CM instance base
27  *
28  * Wait for the module IDLEST to be functional. If the idle state is in any
29  * the non functional state (trans, idle or disabled), module and thus the
30  * sysconfig cannot be accessed and will probably lead to an "imprecise
31  * external abort"
32  *
33  * Module idle state:
34  *   0x0 func:     Module is fully functional, including OCP
35  *   0x1 trans:    Module is performing transition: wakeup, or sleep, or sleep
36  *                 abortion
37  *   0x2 idle:     Module is in Idle mode (only OCP part). It is functional if
38  *                 using separate functional clock
39  *   0x3 disabled: Module is disabled and cannot be accessed
40  *
41  */
42 int am33xx_cm_wait_module_ready(u16 inst, u16 clkctrl_reg)
43 {
44         int i = 0;
46         omap_test_timeout((
47                 ((__raw_readl(AM33XX_CM_REGADDR(inst, clkctrl_reg)) &
48                   AM33XX_IDLEST_MASK) == 0)), MAX_MODULE_READY_TIME, i);
50         return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
51 }