xref: /linux/arch/arm/mach-omap2/cm2xxx_3xxx.h (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
1*d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
259fb659bSPaul Walmsley /*
359fb659bSPaul Walmsley  * OMAP2/3 Clock Management (CM) register definitions
459fb659bSPaul Walmsley  *
559fb659bSPaul Walmsley  * Copyright (C) 2007-2009 Texas Instruments, Inc.
659fb659bSPaul Walmsley  * Copyright (C) 2007-2010 Nokia Corporation
759fb659bSPaul Walmsley  * Paul Walmsley
859fb659bSPaul Walmsley  *
959fb659bSPaul Walmsley  * The CM hardware modules on the OMAP2/3 are quite similar to each
1059fb659bSPaul Walmsley  * other.  The CM modules/instances on OMAP4 are quite different, so
1159fb659bSPaul Walmsley  * they are handled in a separate file.
1259fb659bSPaul Walmsley  */
1359fb659bSPaul Walmsley #ifndef __ARCH_ASM_MACH_OMAP2_CM2XXX_3XXX_H
1459fb659bSPaul Walmsley #define __ARCH_ASM_MACH_OMAP2_CM2XXX_3XXX_H
1559fb659bSPaul Walmsley 
16d9a16f9aSPaul Walmsley #include "cm.h"
1759fb659bSPaul Walmsley 
1859fb659bSPaul Walmsley /*
1959fb659bSPaul Walmsley  * Module specific CM register offsets from CM_BASE + domain offset
2059fb659bSPaul Walmsley  * Use cm_{read,write}_mod_reg() with these registers.
2159fb659bSPaul Walmsley  * These register offsets generally appear in more than one PRCM submodule.
2259fb659bSPaul Walmsley  */
2359fb659bSPaul Walmsley 
2459fb659bSPaul Walmsley /* Common between OMAP2 and OMAP3 */
2559fb659bSPaul Walmsley 
2659fb659bSPaul Walmsley #define CM_FCLKEN					0x0000
2759fb659bSPaul Walmsley #define CM_FCLKEN1					CM_FCLKEN
2859fb659bSPaul Walmsley #define CM_CLKEN					CM_FCLKEN
2959fb659bSPaul Walmsley #define CM_ICLKEN					0x0010
3059fb659bSPaul Walmsley #define CM_ICLKEN1					CM_ICLKEN
3159fb659bSPaul Walmsley #define CM_ICLKEN2					0x0014
3259fb659bSPaul Walmsley #define CM_ICLKEN3					0x0018
3359fb659bSPaul Walmsley #define CM_IDLEST					0x0020
3459fb659bSPaul Walmsley #define CM_IDLEST1					CM_IDLEST
3559fb659bSPaul Walmsley #define CM_IDLEST2					0x0024
36ff4ae5d9SPaul Walmsley #define OMAP2430_CM_IDLEST3				0x0028
3759fb659bSPaul Walmsley #define CM_AUTOIDLE					0x0030
3859fb659bSPaul Walmsley #define CM_AUTOIDLE1					CM_AUTOIDLE
3959fb659bSPaul Walmsley #define CM_AUTOIDLE2					0x0034
4059fb659bSPaul Walmsley #define CM_AUTOIDLE3					0x0038
4159fb659bSPaul Walmsley #define CM_CLKSEL					0x0040
4259fb659bSPaul Walmsley #define CM_CLKSEL1					CM_CLKSEL
4359fb659bSPaul Walmsley #define CM_CLKSEL2					0x0044
4459fb659bSPaul Walmsley #define OMAP2_CM_CLKSTCTRL				0x0048
4559fb659bSPaul Walmsley 
4659fb659bSPaul Walmsley #ifndef __ASSEMBLER__
4759fb659bSPaul Walmsley 
48ff4ae5d9SPaul Walmsley #include <linux/io.h>
4959fb659bSPaul Walmsley 
omap2_cm_read_mod_reg(s16 module,u16 idx)50ff4ae5d9SPaul Walmsley static inline u32 omap2_cm_read_mod_reg(s16 module, u16 idx)
51ff4ae5d9SPaul Walmsley {
5290129336STero Kristo 	return readl_relaxed(cm_base.va + module + idx);
53ff4ae5d9SPaul Walmsley }
5459fb659bSPaul Walmsley 
omap2_cm_write_mod_reg(u32 val,s16 module,u16 idx)55ff4ae5d9SPaul Walmsley static inline void omap2_cm_write_mod_reg(u32 val, s16 module, u16 idx)
56ff4ae5d9SPaul Walmsley {
5790129336STero Kristo 	writel_relaxed(val, cm_base.va + module + idx);
58ff4ae5d9SPaul Walmsley }
5955ae3507SPaul Walmsley 
60ff4ae5d9SPaul Walmsley /* Read-modify-write a register in a CM module. Caller must lock */
omap2_cm_rmw_mod_reg_bits(u32 mask,u32 bits,s16 module,s16 idx)61ff4ae5d9SPaul Walmsley static inline u32 omap2_cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module,
62ff4ae5d9SPaul Walmsley 					    s16 idx)
63ff4ae5d9SPaul Walmsley {
64ff4ae5d9SPaul Walmsley 	u32 v;
6555ae3507SPaul Walmsley 
66ff4ae5d9SPaul Walmsley 	v = omap2_cm_read_mod_reg(module, idx);
67ff4ae5d9SPaul Walmsley 	v &= ~mask;
68ff4ae5d9SPaul Walmsley 	v |= bits;
69ff4ae5d9SPaul Walmsley 	omap2_cm_write_mod_reg(v, module, idx);
700fd0c21bSPaul Walmsley 
71ff4ae5d9SPaul Walmsley 	return v;
72ff4ae5d9SPaul Walmsley }
73ff4ae5d9SPaul Walmsley 
744bd5259eSPaul Walmsley /* Read a CM register, AND it, and shift the result down to bit 0 */
omap2_cm_read_mod_bits_shift(s16 domain,s16 idx,u32 mask)754bd5259eSPaul Walmsley static inline u32 omap2_cm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
764bd5259eSPaul Walmsley {
774bd5259eSPaul Walmsley 	u32 v;
784bd5259eSPaul Walmsley 
794bd5259eSPaul Walmsley 	v = omap2_cm_read_mod_reg(domain, idx);
804bd5259eSPaul Walmsley 	v &= mask;
814bd5259eSPaul Walmsley 	v >>= __ffs(mask);
824bd5259eSPaul Walmsley 
834bd5259eSPaul Walmsley 	return v;
844bd5259eSPaul Walmsley }
854bd5259eSPaul Walmsley 
omap2_cm_set_mod_reg_bits(u32 bits,s16 module,s16 idx)86ff4ae5d9SPaul Walmsley static inline u32 omap2_cm_set_mod_reg_bits(u32 bits, s16 module, s16 idx)
87ff4ae5d9SPaul Walmsley {
88ff4ae5d9SPaul Walmsley 	return omap2_cm_rmw_mod_reg_bits(bits, bits, module, idx);
89ff4ae5d9SPaul Walmsley }
90ff4ae5d9SPaul Walmsley 
omap2_cm_clear_mod_reg_bits(u32 bits,s16 module,s16 idx)91ff4ae5d9SPaul Walmsley static inline u32 omap2_cm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
92ff4ae5d9SPaul Walmsley {
93ff4ae5d9SPaul Walmsley 	return omap2_cm_rmw_mod_reg_bits(bits, 0x0, module, idx);
94ff4ae5d9SPaul Walmsley }
9592618ff8SPaul Walmsley 
9659fb659bSPaul Walmsley #endif
9759fb659bSPaul Walmsley 
9859fb659bSPaul Walmsley /* CM register bits shared between 24XX and 3430 */
9959fb659bSPaul Walmsley 
10059fb659bSPaul Walmsley /* CM_CLKSEL_GFX */
10159fb659bSPaul Walmsley #define OMAP_CLKSEL_GFX_SHIFT				0
10259fb659bSPaul Walmsley #define OMAP_CLKSEL_GFX_MASK				(0x7 << 0)
10399e7938dSRajendra Nayak #define OMAP_CLKSEL_GFX_WIDTH				3
10459fb659bSPaul Walmsley 
10559fb659bSPaul Walmsley /* CM_ICLKEN_GFX */
10659fb659bSPaul Walmsley #define OMAP_EN_GFX_SHIFT				0
10759fb659bSPaul Walmsley #define OMAP_EN_GFX_MASK				(1 << 0)
10859fb659bSPaul Walmsley 
10959fb659bSPaul Walmsley /* CM_IDLEST_GFX */
11059fb659bSPaul Walmsley #define OMAP_ST_GFX_MASK				(1 << 0)
11159fb659bSPaul Walmsley 
11259fb659bSPaul Walmsley #endif
113