xref: /openbmc/linux/arch/arm/mach-omap2/cm.h (revision 5fa4a3cc)
169d88a00SPaul Walmsley /*
259fb659bSPaul Walmsley  * OMAP2+ Clock Management prototypes
369d88a00SPaul Walmsley  *
4d9a16f9aSPaul Walmsley  * Copyright (C) 2007-2009, 2012 Texas Instruments, Inc.
59b47267fSRajendra Nayak  * Copyright (C) 2007-2009 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  */
1359fb659bSPaul Walmsley #ifndef __ARCH_ASM_MACH_OMAP2_CM_H
1459fb659bSPaul Walmsley #define __ARCH_ASM_MACH_OMAP2_CM_H
1569d88a00SPaul Walmsley 
16d9e6625cSBenoit Cousson /*
17d9e6625cSBenoit Cousson  * MAX_MODULE_READY_TIME: max duration in microseconds to wait for the
18d9e6625cSBenoit Cousson  * PRCM to request that a module exit the inactive state in the case of
19d9e6625cSBenoit Cousson  * OMAP2 & 3.
20d9e6625cSBenoit Cousson  * In the case of OMAP4 this is the max duration in microseconds for the
21d9e6625cSBenoit Cousson  * module to reach the functionnal state from an inactive state.
22d9e6625cSBenoit Cousson  */
23d9e6625cSBenoit Cousson #define MAX_MODULE_READY_TIME		2000
24d9e6625cSBenoit Cousson 
25d9a16f9aSPaul Walmsley # ifndef __ASSEMBLER__
266c0afb50STero Kristo #include <linux/clk/ti.h>
2790129336STero Kristo 
2890129336STero Kristo #include "prcm-common.h"
2990129336STero Kristo 
3090129336STero Kristo extern struct omap_domain_base cm_base;
3190129336STero Kristo extern struct omap_domain_base cm2_base;
32d9a16f9aSPaul Walmsley extern void omap2_set_globals_cm(void __iomem *cm, void __iomem *cm2);
33d9a16f9aSPaul Walmsley # endif
34d9a16f9aSPaul Walmsley 
35b8f15b7eSPaul Walmsley /*
36b8f15b7eSPaul Walmsley  * MAX_MODULE_DISABLE_TIME: max duration in microseconds to wait for
37b8f15b7eSPaul Walmsley  * the PRCM to request that a module enter the inactive state in the
38b8f15b7eSPaul Walmsley  * case of OMAP2 & 3.  In the case of OMAP4 this is the max duration
39b8f15b7eSPaul Walmsley  * in microseconds for the module to reach the inactive state from
40b8f15b7eSPaul Walmsley  * a functional state.
41b8f15b7eSPaul Walmsley  * XXX FSUSB on OMAP4430 takes ~4ms to idle after reset during
42b8f15b7eSPaul Walmsley  * kernel init.
43b8f15b7eSPaul Walmsley  */
44b8f15b7eSPaul Walmsley #define MAX_MODULE_DISABLE_TIME		5000
45b8f15b7eSPaul Walmsley 
4621325b25SPaul Walmsley # ifndef __ASSEMBLER__
4721325b25SPaul Walmsley 
4821325b25SPaul Walmsley /**
4921325b25SPaul Walmsley  * struct cm_ll_data - fn ptrs to per-SoC CM function implementations
50c4ceedcbSPaul Walmsley  * @split_idlest_reg: ptr to the SoC CM-specific split_idlest_reg impl
51c4ceedcbSPaul Walmsley  * @wait_module_ready: ptr to the SoC CM-specific wait_module_ready impl
52a8ae5afaSTero Kristo  * @wait_module_idle: ptr to the SoC CM-specific wait_module_idle impl
53128603f0STero Kristo  * @module_enable: ptr to the SoC CM-specific module_enable impl
54128603f0STero Kristo  * @module_disable: ptr to the SoC CM-specific module_disable impl
555fa4a3ccSTero Kristo  * @xlate_clkctrl: ptr to the SoC CM-specific clkctrl xlate addr impl
5621325b25SPaul Walmsley  */
57c4ceedcbSPaul Walmsley struct cm_ll_data {
586c0afb50STero Kristo 	int (*split_idlest_reg)(struct clk_omap_reg *idlest_reg, s16 *prcm_inst,
59c4ceedcbSPaul Walmsley 				u8 *idlest_reg_id);
60021b6ff0STero Kristo 	int (*wait_module_ready)(u8 part, s16 prcm_mod, u16 idlest_reg,
61021b6ff0STero Kristo 				 u8 idlest_shift);
62a8ae5afaSTero Kristo 	int (*wait_module_idle)(u8 part, s16 prcm_mod, u16 idlest_reg,
63a8ae5afaSTero Kristo 				u8 idlest_shift);
64128603f0STero Kristo 	void (*module_enable)(u8 mode, u8 part, u16 inst, u16 clkctrl_offs);
65128603f0STero Kristo 	void (*module_disable)(u8 part, u16 inst, u16 clkctrl_offs);
665fa4a3ccSTero Kristo 	u32 (*xlate_clkctrl)(u8 part, u16 inst, u16 clkctrl_offs);
67c4ceedcbSPaul Walmsley };
68c4ceedcbSPaul Walmsley 
696c0afb50STero Kristo extern int cm_split_idlest_reg(struct clk_omap_reg *idlest_reg, s16 *prcm_inst,
70c4ceedcbSPaul Walmsley 			       u8 *idlest_reg_id);
71021b6ff0STero Kristo int omap_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_reg,
72021b6ff0STero Kristo 			      u8 idlest_shift);
73a8ae5afaSTero Kristo int omap_cm_wait_module_idle(u8 part, s16 prcm_mod, u16 idlest_reg,
74a8ae5afaSTero Kristo 			     u8 idlest_shift);
75128603f0STero Kristo int omap_cm_module_enable(u8 mode, u8 part, u16 inst, u16 clkctrl_offs);
76128603f0STero Kristo int omap_cm_module_disable(u8 part, u16 inst, u16 clkctrl_offs);
775fa4a3ccSTero Kristo u32 omap_cm_xlate_clkctrl(u8 part, u16 inst, u16 clkctrl_offs);
7821325b25SPaul Walmsley extern int cm_register(struct cm_ll_data *cld);
7921325b25SPaul Walmsley extern int cm_unregister(struct cm_ll_data *cld);
80fe87414fSTero Kristo int omap_cm_init(void);
815970ca2dSTero Kristo int omap2_cm_base_init(void);
8221325b25SPaul Walmsley 
8321325b25SPaul Walmsley # endif
8421325b25SPaul Walmsley 
8569d88a00SPaul Walmsley #endif
86