ARM: OMAP2+: CM: add common APIs for cm_module_enable/disable
Adds a generic CM driver API for enabling/disabling modules. The SoC specific implementations are registered through cm_ll_data. Signed-off-by: Tero Kristo <t-kristo@ti.com> Tested-by: Nishanth Menon <nm@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
This commit is contained in:
parent
f2650d6e4f
commit
128603f05a
7 changed files with 72 additions and 45 deletions
|
@ -46,6 +46,8 @@ extern void omap2_set_globals_cm(void __iomem *cm, void __iomem *cm2);
|
||||||
* @split_idlest_reg: ptr to the SoC CM-specific split_idlest_reg impl
|
* @split_idlest_reg: ptr to the SoC CM-specific split_idlest_reg impl
|
||||||
* @wait_module_ready: ptr to the SoC CM-specific wait_module_ready impl
|
* @wait_module_ready: ptr to the SoC CM-specific wait_module_ready impl
|
||||||
* @wait_module_idle: ptr to the SoC CM-specific wait_module_idle impl
|
* @wait_module_idle: ptr to the SoC CM-specific wait_module_idle impl
|
||||||
|
* @module_enable: ptr to the SoC CM-specific module_enable impl
|
||||||
|
* @module_disable: ptr to the SoC CM-specific module_disable impl
|
||||||
*/
|
*/
|
||||||
struct cm_ll_data {
|
struct cm_ll_data {
|
||||||
int (*split_idlest_reg)(void __iomem *idlest_reg, s16 *prcm_inst,
|
int (*split_idlest_reg)(void __iomem *idlest_reg, s16 *prcm_inst,
|
||||||
|
@ -54,6 +56,8 @@ struct cm_ll_data {
|
||||||
u8 idlest_shift);
|
u8 idlest_shift);
|
||||||
int (*wait_module_idle)(u8 part, s16 prcm_mod, u16 idlest_reg,
|
int (*wait_module_idle)(u8 part, s16 prcm_mod, u16 idlest_reg,
|
||||||
u8 idlest_shift);
|
u8 idlest_shift);
|
||||||
|
void (*module_enable)(u8 mode, u8 part, u16 inst, u16 clkctrl_offs);
|
||||||
|
void (*module_disable)(u8 part, u16 inst, u16 clkctrl_offs);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int cm_split_idlest_reg(void __iomem *idlest_reg, s16 *prcm_inst,
|
extern int cm_split_idlest_reg(void __iomem *idlest_reg, s16 *prcm_inst,
|
||||||
|
@ -62,6 +66,8 @@ int omap_cm_wait_module_ready(u8 part, s16 prcm_mod, u16 idlest_reg,
|
||||||
u8 idlest_shift);
|
u8 idlest_shift);
|
||||||
int omap_cm_wait_module_idle(u8 part, s16 prcm_mod, u16 idlest_reg,
|
int omap_cm_wait_module_idle(u8 part, s16 prcm_mod, u16 idlest_reg,
|
||||||
u8 idlest_shift);
|
u8 idlest_shift);
|
||||||
|
int omap_cm_module_enable(u8 mode, u8 part, u16 inst, u16 clkctrl_offs);
|
||||||
|
int omap_cm_module_disable(u8 part, u16 inst, u16 clkctrl_offs);
|
||||||
extern int cm_register(struct cm_ll_data *cld);
|
extern int cm_register(struct cm_ll_data *cld);
|
||||||
extern int cm_unregister(struct cm_ll_data *cld);
|
extern int cm_unregister(struct cm_ll_data *cld);
|
||||||
|
|
||||||
|
|
|
@ -277,13 +277,14 @@ static int am33xx_cm_wait_module_idle(u8 part, s16 inst, u16 clkctrl_offs,
|
||||||
/**
|
/**
|
||||||
* am33xx_cm_module_enable - Enable the modulemode inside CLKCTRL
|
* am33xx_cm_module_enable - Enable the modulemode inside CLKCTRL
|
||||||
* @mode: Module mode (SW or HW)
|
* @mode: Module mode (SW or HW)
|
||||||
|
* @part: CM partition, ignored for AM33xx
|
||||||
* @inst: CM instance register offset (*_INST macro)
|
* @inst: CM instance register offset (*_INST macro)
|
||||||
* @cdoffs: Clockdomain register offset (*_CDOFFS macro)
|
|
||||||
* @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
|
* @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
|
||||||
*
|
*
|
||||||
* No return value.
|
* No return value.
|
||||||
*/
|
*/
|
||||||
void am33xx_cm_module_enable(u8 mode, u16 inst, s16 cdoffs, u16 clkctrl_offs)
|
static void am33xx_cm_module_enable(u8 mode, u8 part, u16 inst,
|
||||||
|
u16 clkctrl_offs)
|
||||||
{
|
{
|
||||||
u32 v;
|
u32 v;
|
||||||
|
|
||||||
|
@ -295,13 +296,13 @@ void am33xx_cm_module_enable(u8 mode, u16 inst, s16 cdoffs, u16 clkctrl_offs)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* am33xx_cm_module_disable - Disable the module inside CLKCTRL
|
* am33xx_cm_module_disable - Disable the module inside CLKCTRL
|
||||||
|
* @part: CM partition, ignored for AM33xx
|
||||||
* @inst: CM instance register offset (*_INST macro)
|
* @inst: CM instance register offset (*_INST macro)
|
||||||
* @cdoffs: Clockdomain register offset (*_CDOFFS macro)
|
|
||||||
* @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
|
* @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
|
||||||
*
|
*
|
||||||
* No return value.
|
* No return value.
|
||||||
*/
|
*/
|
||||||
void am33xx_cm_module_disable(u16 inst, s16 cdoffs, u16 clkctrl_offs)
|
static void am33xx_cm_module_disable(u8 part, u16 inst, u16 clkctrl_offs)
|
||||||
{
|
{
|
||||||
u32 v;
|
u32 v;
|
||||||
|
|
||||||
|
@ -368,6 +369,8 @@ struct clkdm_ops am33xx_clkdm_operations = {
|
||||||
static struct cm_ll_data am33xx_cm_ll_data = {
|
static struct cm_ll_data am33xx_cm_ll_data = {
|
||||||
.wait_module_ready = &am33xx_cm_wait_module_ready,
|
.wait_module_ready = &am33xx_cm_wait_module_ready,
|
||||||
.wait_module_idle = &am33xx_cm_wait_module_idle,
|
.wait_module_idle = &am33xx_cm_wait_module_idle,
|
||||||
|
.module_enable = &am33xx_cm_module_enable,
|
||||||
|
.module_disable = &am33xx_cm_module_disable,
|
||||||
};
|
};
|
||||||
|
|
||||||
int __init am33xx_cm_init(void)
|
int __init am33xx_cm_init(void)
|
||||||
|
|
|
@ -375,22 +375,5 @@
|
||||||
|
|
||||||
#ifndef __ASSEMBLER__
|
#ifndef __ASSEMBLER__
|
||||||
int am33xx_cm_init(void);
|
int am33xx_cm_init(void);
|
||||||
|
|
||||||
#if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
|
|
||||||
extern void am33xx_cm_module_enable(u8 mode, u16 inst, s16 cdoffs,
|
|
||||||
u16 clkctrl_offs);
|
|
||||||
extern void am33xx_cm_module_disable(u16 inst, s16 cdoffs,
|
|
||||||
u16 clkctrl_offs);
|
|
||||||
#else
|
|
||||||
static inline void am33xx_cm_module_enable(u8 mode, u16 inst, s16 cdoffs,
|
|
||||||
u16 clkctrl_offs)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
static inline void am33xx_cm_module_disable(u16 inst, s16 cdoffs,
|
|
||||||
u16 clkctrl_offs)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* ASSEMBLER */
|
#endif /* ASSEMBLER */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -123,6 +123,51 @@ int omap_cm_wait_module_idle(u8 part, s16 prcm_mod, u16 idlest_reg,
|
||||||
idlest_shift);
|
idlest_shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omap_cm_module_enable - enable a module
|
||||||
|
* @mode: target mode for the module
|
||||||
|
* @part: PRCM partition
|
||||||
|
* @inst: PRCM instance
|
||||||
|
* @clkctrl_offs: CM_CLKCTRL register offset for the module
|
||||||
|
*
|
||||||
|
* Enables clocks for a module identified by (@part, @inst, @clkctrl_offs)
|
||||||
|
* making its IO space accessible. Return 0 upon success, -EINVAL if no
|
||||||
|
* per-SoC module_enable() function pointer has been registered.
|
||||||
|
*/
|
||||||
|
int omap_cm_module_enable(u8 mode, u8 part, u16 inst, u16 clkctrl_offs)
|
||||||
|
{
|
||||||
|
if (!cm_ll_data->module_enable) {
|
||||||
|
WARN_ONCE(1, "cm: %s: no low-level function defined\n",
|
||||||
|
__func__);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cm_ll_data->module_enable(mode, part, inst, clkctrl_offs);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omap_cm_module_disable - disable a module
|
||||||
|
* @part: PRCM partition
|
||||||
|
* @inst: PRCM instance
|
||||||
|
* @clkctrl_offs: CM_CLKCTRL register offset for the module
|
||||||
|
*
|
||||||
|
* Disables clocks for a module identified by (@part, @inst, @clkctrl_offs)
|
||||||
|
* makings its IO space inaccessible. Return 0 upon success, -EINVAL if
|
||||||
|
* no per-SoC module_disable() function pointer has been registered.
|
||||||
|
*/
|
||||||
|
int omap_cm_module_disable(u8 part, u16 inst, u16 clkctrl_offs)
|
||||||
|
{
|
||||||
|
if (!cm_ll_data->module_disable) {
|
||||||
|
WARN_ONCE(1, "cm: %s: no low-level function defined\n",
|
||||||
|
__func__);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cm_ll_data->module_disable(part, inst, clkctrl_offs);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cm_register - register per-SoC low-level data with the CM
|
* cm_register - register per-SoC low-level data with the CM
|
||||||
* @cld: low-level per-SoC OMAP CM data & function pointers to register
|
* @cld: low-level per-SoC OMAP CM data & function pointers to register
|
||||||
|
|
|
@ -319,13 +319,12 @@ static int omap4_cminst_wait_module_idle(u8 part, s16 inst, u16 clkctrl_offs,
|
||||||
* @mode: Module mode (SW or HW)
|
* @mode: Module mode (SW or HW)
|
||||||
* @part: PRCM partition ID that the CM_CLKCTRL register exists in
|
* @part: PRCM partition ID that the CM_CLKCTRL register exists in
|
||||||
* @inst: CM instance register offset (*_INST macro)
|
* @inst: CM instance register offset (*_INST macro)
|
||||||
* @cdoffs: Clockdomain register offset (*_CDOFFS macro)
|
|
||||||
* @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
|
* @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
|
||||||
*
|
*
|
||||||
* No return value.
|
* No return value.
|
||||||
*/
|
*/
|
||||||
void omap4_cminst_module_enable(u8 mode, u8 part, u16 inst, s16 cdoffs,
|
static void omap4_cminst_module_enable(u8 mode, u8 part, u16 inst,
|
||||||
u16 clkctrl_offs)
|
u16 clkctrl_offs)
|
||||||
{
|
{
|
||||||
u32 v;
|
u32 v;
|
||||||
|
|
||||||
|
@ -339,13 +338,11 @@ void omap4_cminst_module_enable(u8 mode, u8 part, u16 inst, s16 cdoffs,
|
||||||
* omap4_cminst_module_disable - Disable the module inside CLKCTRL
|
* omap4_cminst_module_disable - Disable the module inside CLKCTRL
|
||||||
* @part: PRCM partition ID that the CM_CLKCTRL register exists in
|
* @part: PRCM partition ID that the CM_CLKCTRL register exists in
|
||||||
* @inst: CM instance register offset (*_INST macro)
|
* @inst: CM instance register offset (*_INST macro)
|
||||||
* @cdoffs: Clockdomain register offset (*_CDOFFS macro)
|
|
||||||
* @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
|
* @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
|
||||||
*
|
*
|
||||||
* No return value.
|
* No return value.
|
||||||
*/
|
*/
|
||||||
void omap4_cminst_module_disable(u8 part, u16 inst, s16 cdoffs,
|
static void omap4_cminst_module_disable(u8 part, u16 inst, u16 clkctrl_offs)
|
||||||
u16 clkctrl_offs)
|
|
||||||
{
|
{
|
||||||
u32 v;
|
u32 v;
|
||||||
|
|
||||||
|
@ -513,6 +510,8 @@ struct clkdm_ops am43xx_clkdm_operations = {
|
||||||
static struct cm_ll_data omap4xxx_cm_ll_data = {
|
static struct cm_ll_data omap4xxx_cm_ll_data = {
|
||||||
.wait_module_ready = &omap4_cminst_wait_module_ready,
|
.wait_module_ready = &omap4_cminst_wait_module_ready,
|
||||||
.wait_module_idle = &omap4_cminst_wait_module_idle,
|
.wait_module_idle = &omap4_cminst_wait_module_idle,
|
||||||
|
.module_enable = &omap4_cminst_module_enable,
|
||||||
|
.module_disable = &omap4_cminst_module_disable,
|
||||||
};
|
};
|
||||||
|
|
||||||
int __init omap4_cm_init(void)
|
int __init omap4_cm_init(void)
|
||||||
|
|
|
@ -11,10 +11,6 @@
|
||||||
#ifndef __ARCH_ASM_MACH_OMAP2_CMINST44XX_H
|
#ifndef __ARCH_ASM_MACH_OMAP2_CMINST44XX_H
|
||||||
#define __ARCH_ASM_MACH_OMAP2_CMINST44XX_H
|
#define __ARCH_ASM_MACH_OMAP2_CMINST44XX_H
|
||||||
|
|
||||||
extern void omap4_cminst_module_enable(u8 mode, u8 part, u16 inst, s16 cdoffs,
|
|
||||||
u16 clkctrl_offs);
|
|
||||||
extern void omap4_cminst_module_disable(u8 part, u16 inst, s16 cdoffs,
|
|
||||||
u16 clkctrl_offs);
|
|
||||||
/*
|
/*
|
||||||
* In an ideal world, we would not export these low-level functions,
|
* In an ideal world, we would not export these low-level functions,
|
||||||
* but this will probably take some time to fix properly
|
* but this will probably take some time to fix properly
|
||||||
|
|
|
@ -979,11 +979,9 @@ static void _omap4_enable_module(struct omap_hwmod *oh)
|
||||||
pr_debug("omap_hwmod: %s: %s: %d\n",
|
pr_debug("omap_hwmod: %s: %s: %d\n",
|
||||||
oh->name, __func__, oh->prcm.omap4.modulemode);
|
oh->name, __func__, oh->prcm.omap4.modulemode);
|
||||||
|
|
||||||
omap4_cminst_module_enable(oh->prcm.omap4.modulemode,
|
omap_cm_module_enable(oh->prcm.omap4.modulemode,
|
||||||
oh->clkdm->prcm_partition,
|
oh->clkdm->prcm_partition,
|
||||||
oh->clkdm->cm_inst,
|
oh->clkdm->cm_inst, oh->prcm.omap4.clkctrl_offs);
|
||||||
oh->clkdm->clkdm_offs,
|
|
||||||
oh->prcm.omap4.clkctrl_offs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1001,9 +999,8 @@ static void _am33xx_enable_module(struct omap_hwmod *oh)
|
||||||
pr_debug("omap_hwmod: %s: %s: %d\n",
|
pr_debug("omap_hwmod: %s: %s: %d\n",
|
||||||
oh->name, __func__, oh->prcm.omap4.modulemode);
|
oh->name, __func__, oh->prcm.omap4.modulemode);
|
||||||
|
|
||||||
am33xx_cm_module_enable(oh->prcm.omap4.modulemode, oh->clkdm->cm_inst,
|
omap_cm_module_enable(oh->prcm.omap4.modulemode, 0, oh->clkdm->cm_inst,
|
||||||
oh->clkdm->clkdm_offs,
|
oh->prcm.omap4.clkctrl_offs);
|
||||||
oh->prcm.omap4.clkctrl_offs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1857,10 +1854,8 @@ static int _omap4_disable_module(struct omap_hwmod *oh)
|
||||||
|
|
||||||
pr_debug("omap_hwmod: %s: %s\n", oh->name, __func__);
|
pr_debug("omap_hwmod: %s: %s\n", oh->name, __func__);
|
||||||
|
|
||||||
omap4_cminst_module_disable(oh->clkdm->prcm_partition,
|
omap_cm_module_disable(oh->clkdm->prcm_partition, oh->clkdm->cm_inst,
|
||||||
oh->clkdm->cm_inst,
|
oh->prcm.omap4.clkctrl_offs);
|
||||||
oh->clkdm->clkdm_offs,
|
|
||||||
oh->prcm.omap4.clkctrl_offs);
|
|
||||||
|
|
||||||
v = _omap4_wait_target_disable(oh);
|
v = _omap4_wait_target_disable(oh);
|
||||||
if (v)
|
if (v)
|
||||||
|
@ -1889,8 +1884,8 @@ static int _am33xx_disable_module(struct omap_hwmod *oh)
|
||||||
if (_are_any_hardreset_lines_asserted(oh))
|
if (_are_any_hardreset_lines_asserted(oh))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
am33xx_cm_module_disable(oh->clkdm->cm_inst, oh->clkdm->clkdm_offs,
|
omap_cm_module_disable(0, oh->clkdm->cm_inst,
|
||||||
oh->prcm.omap4.clkctrl_offs);
|
oh->prcm.omap4.clkctrl_offs);
|
||||||
|
|
||||||
v = _am33xx_wait_target_disable(oh);
|
v = _am33xx_wait_target_disable(oh);
|
||||||
if (v)
|
if (v)
|
||||||
|
|
Loading…
Add table
Reference in a new issue