xref: /linux/arch/arm/mach-omap2/cm2xxx_3xxx.h (revision d9a16f9ab9332b7cf1c95086a4efb98a0d13a57a)
159fb659bSPaul Walmsley /*
259fb659bSPaul Walmsley  * OMAP2/3 Clock Management (CM) register definitions
359fb659bSPaul Walmsley  *
459fb659bSPaul Walmsley  * Copyright (C) 2007-2009 Texas Instruments, Inc.
559fb659bSPaul Walmsley  * Copyright (C) 2007-2010 Nokia Corporation
659fb659bSPaul Walmsley  * Paul Walmsley
759fb659bSPaul Walmsley  *
859fb659bSPaul Walmsley  * This program is free software; you can redistribute it and/or modify
959fb659bSPaul Walmsley  * it under the terms of the GNU General Public License version 2 as
1059fb659bSPaul Walmsley  * published by the Free Software Foundation.
1159fb659bSPaul Walmsley  *
1259fb659bSPaul Walmsley  * The CM hardware modules on the OMAP2/3 are quite similar to each
1359fb659bSPaul Walmsley  * other.  The CM modules/instances on OMAP4 are quite different, so
1459fb659bSPaul Walmsley  * they are handled in a separate file.
1559fb659bSPaul Walmsley  */
1659fb659bSPaul Walmsley #ifndef __ARCH_ASM_MACH_OMAP2_CM2XXX_3XXX_H
1759fb659bSPaul Walmsley #define __ARCH_ASM_MACH_OMAP2_CM2XXX_3XXX_H
1859fb659bSPaul Walmsley 
19*d9a16f9aSPaul Walmsley #include "cm.h"
2059fb659bSPaul Walmsley 
2159fb659bSPaul Walmsley /*
2259fb659bSPaul Walmsley  * Module specific CM register offsets from CM_BASE + domain offset
2359fb659bSPaul Walmsley  * Use cm_{read,write}_mod_reg() with these registers.
2459fb659bSPaul Walmsley  * These register offsets generally appear in more than one PRCM submodule.
2559fb659bSPaul Walmsley  */
2659fb659bSPaul Walmsley 
2759fb659bSPaul Walmsley /* Common between OMAP2 and OMAP3 */
2859fb659bSPaul Walmsley 
2959fb659bSPaul Walmsley #define CM_FCLKEN					0x0000
3059fb659bSPaul Walmsley #define CM_FCLKEN1					CM_FCLKEN
3159fb659bSPaul Walmsley #define CM_CLKEN					CM_FCLKEN
3259fb659bSPaul Walmsley #define CM_ICLKEN					0x0010
3359fb659bSPaul Walmsley #define CM_ICLKEN1					CM_ICLKEN
3459fb659bSPaul Walmsley #define CM_ICLKEN2					0x0014
3559fb659bSPaul Walmsley #define CM_ICLKEN3					0x0018
3659fb659bSPaul Walmsley #define CM_IDLEST					0x0020
3759fb659bSPaul Walmsley #define CM_IDLEST1					CM_IDLEST
3859fb659bSPaul Walmsley #define CM_IDLEST2					0x0024
39ff4ae5d9SPaul Walmsley #define OMAP2430_CM_IDLEST3				0x0028
4059fb659bSPaul Walmsley #define CM_AUTOIDLE					0x0030
4159fb659bSPaul Walmsley #define CM_AUTOIDLE1					CM_AUTOIDLE
4259fb659bSPaul Walmsley #define CM_AUTOIDLE2					0x0034
4359fb659bSPaul Walmsley #define CM_AUTOIDLE3					0x0038
4459fb659bSPaul Walmsley #define CM_CLKSEL					0x0040
4559fb659bSPaul Walmsley #define CM_CLKSEL1					CM_CLKSEL
4659fb659bSPaul Walmsley #define CM_CLKSEL2					0x0044
4759fb659bSPaul Walmsley #define OMAP2_CM_CLKSTCTRL				0x0048
4859fb659bSPaul Walmsley 
4959fb659bSPaul Walmsley #ifndef __ASSEMBLER__
5059fb659bSPaul Walmsley 
51ff4ae5d9SPaul Walmsley #include <linux/io.h>
5259fb659bSPaul Walmsley 
53ff4ae5d9SPaul Walmsley static inline u32 omap2_cm_read_mod_reg(s16 module, u16 idx)
54ff4ae5d9SPaul Walmsley {
55ff4ae5d9SPaul Walmsley 	return __raw_readl(cm_base + module + idx);
56ff4ae5d9SPaul Walmsley }
5759fb659bSPaul Walmsley 
58ff4ae5d9SPaul Walmsley static inline void omap2_cm_write_mod_reg(u32 val, s16 module, u16 idx)
59ff4ae5d9SPaul Walmsley {
60ff4ae5d9SPaul Walmsley 	__raw_writel(val, cm_base + module + idx);
61ff4ae5d9SPaul Walmsley }
6255ae3507SPaul Walmsley 
63ff4ae5d9SPaul Walmsley /* Read-modify-write a register in a CM module. Caller must lock */
64ff4ae5d9SPaul Walmsley static inline u32 omap2_cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module,
65ff4ae5d9SPaul Walmsley 					    s16 idx)
66ff4ae5d9SPaul Walmsley {
67ff4ae5d9SPaul Walmsley 	u32 v;
6855ae3507SPaul Walmsley 
69ff4ae5d9SPaul Walmsley 	v = omap2_cm_read_mod_reg(module, idx);
70ff4ae5d9SPaul Walmsley 	v &= ~mask;
71ff4ae5d9SPaul Walmsley 	v |= bits;
72ff4ae5d9SPaul Walmsley 	omap2_cm_write_mod_reg(v, module, idx);
730fd0c21bSPaul Walmsley 
74ff4ae5d9SPaul Walmsley 	return v;
75ff4ae5d9SPaul Walmsley }
76ff4ae5d9SPaul Walmsley 
774bd5259eSPaul Walmsley /* Read a CM register, AND it, and shift the result down to bit 0 */
784bd5259eSPaul Walmsley static inline u32 omap2_cm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
794bd5259eSPaul Walmsley {
804bd5259eSPaul Walmsley 	u32 v;
814bd5259eSPaul Walmsley 
824bd5259eSPaul Walmsley 	v = omap2_cm_read_mod_reg(domain, idx);
834bd5259eSPaul Walmsley 	v &= mask;
844bd5259eSPaul Walmsley 	v >>= __ffs(mask);
854bd5259eSPaul Walmsley 
864bd5259eSPaul Walmsley 	return v;
874bd5259eSPaul Walmsley }
884bd5259eSPaul Walmsley 
89ff4ae5d9SPaul Walmsley static inline u32 omap2_cm_set_mod_reg_bits(u32 bits, s16 module, s16 idx)
90ff4ae5d9SPaul Walmsley {
91ff4ae5d9SPaul Walmsley 	return omap2_cm_rmw_mod_reg_bits(bits, bits, module, idx);
92ff4ae5d9SPaul Walmsley }
93ff4ae5d9SPaul Walmsley 
94ff4ae5d9SPaul Walmsley static inline u32 omap2_cm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
95ff4ae5d9SPaul Walmsley {
96ff4ae5d9SPaul Walmsley 	return omap2_cm_rmw_mod_reg_bits(bits, 0x0, module, idx);
97ff4ae5d9SPaul Walmsley }
9892618ff8SPaul Walmsley 
99b6ffa050SPaul Walmsley extern int omap2xxx_cm_apll54_enable(void);
100b6ffa050SPaul Walmsley extern void omap2xxx_cm_apll54_disable(void);
101b6ffa050SPaul Walmsley extern int omap2xxx_cm_apll96_enable(void);
102b6ffa050SPaul Walmsley extern void omap2xxx_cm_apll96_disable(void);
103b6ffa050SPaul Walmsley 
10459fb659bSPaul Walmsley #endif
10559fb659bSPaul Walmsley 
10659fb659bSPaul Walmsley /* CM register bits shared between 24XX and 3430 */
10759fb659bSPaul Walmsley 
10859fb659bSPaul Walmsley /* CM_CLKSEL_GFX */
10959fb659bSPaul Walmsley #define OMAP_CLKSEL_GFX_SHIFT				0
11059fb659bSPaul Walmsley #define OMAP_CLKSEL_GFX_MASK				(0x7 << 0)
11159fb659bSPaul Walmsley 
11259fb659bSPaul Walmsley /* CM_ICLKEN_GFX */
11359fb659bSPaul Walmsley #define OMAP_EN_GFX_SHIFT				0
11459fb659bSPaul Walmsley #define OMAP_EN_GFX_MASK				(1 << 0)
11559fb659bSPaul Walmsley 
11659fb659bSPaul Walmsley /* CM_IDLEST_GFX */
11759fb659bSPaul Walmsley #define OMAP_ST_GFX_MASK				(1 << 0)
11859fb659bSPaul Walmsley 
11959fb659bSPaul Walmsley #endif
120