aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTero Kristo <t-kristo@ti.com>2014-10-27 11:39:24 -0400
committerTony Lindgren <tony@atomide.com>2014-10-27 11:39:24 -0400
commit128603f05af371acc09e4cfd9124388f1b3e2966 (patch)
tree73f6800d7fdd87c96f1ac26f3205f60d92a4347d
parentf2650d6e4fb797b436af5999ea89aa279712544b (diff)
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>
-rw-r--r--arch/arm/mach-omap2/cm.h6
-rw-r--r--arch/arm/mach-omap2/cm33xx.c11
-rw-r--r--arch/arm/mach-omap2/cm33xx.h17
-rw-r--r--arch/arm/mach-omap2/cm_common.c45
-rw-r--r--arch/arm/mach-omap2/cminst44xx.c11
-rw-r--r--arch/arm/mach-omap2/cminst44xx.h4
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c23
7 files changed, 72 insertions, 45 deletions
diff --git a/arch/arm/mach-omap2/cm.h b/arch/arm/mach-omap2/cm.h
index 3ecc5d73e2c5..6222e87a79b6 100644
--- a/arch/arm/mach-omap2/cm.h
+++ b/arch/arm/mach-omap2/cm.h
@@ -46,6 +46,8 @@ extern void omap2_set_globals_cm(void __iomem *cm, void __iomem *cm2);
46 * @split_idlest_reg: ptr to the SoC CM-specific split_idlest_reg impl 46 * @split_idlest_reg: ptr to the SoC CM-specific split_idlest_reg impl
47 * @wait_module_ready: ptr to the SoC CM-specific wait_module_ready impl 47 * @wait_module_ready: ptr to the SoC CM-specific wait_module_ready impl
48 * @wait_module_idle: ptr to the SoC CM-specific wait_module_idle impl 48 * @wait_module_idle: ptr to the SoC CM-specific wait_module_idle impl
49 * @module_enable: ptr to the SoC CM-specific module_enable impl
50 * @module_disable: ptr to the SoC CM-specific module_disable impl
49 */ 51 */
50struct cm_ll_data { 52struct cm_ll_data {
51 int (*split_idlest_reg)(void __iomem *idlest_reg, s16 *prcm_inst, 53 int (*split_idlest_reg)(void __iomem *idlest_reg, s16 *prcm_inst,
@@ -54,6 +56,8 @@ struct cm_ll_data {
54 u8 idlest_shift); 56 u8 idlest_shift);
55 int (*wait_module_idle)(u8 part, s16 prcm_mod, u16 idlest_reg, 57 int (*wait_module_idle)(u8 part, s16 prcm_mod, u16 idlest_reg,
56 u8 idlest_shift); 58 u8 idlest_shift);
59 void (*module_enable)(u8 mode, u8 part, u16 inst, u16 clkctrl_offs);
60 void (*module_disable)(u8 part, u16 inst, u16 clkctrl_offs);
57}; 61};
58 62
59extern int cm_split_idlest_reg(void __iomem *idlest_reg, s16 *prcm_inst, 63extern 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,
62 u8 idlest_shift); 66 u8 idlest_shift);
63int omap_cm_wait_module_idle(u8 part, s16 prcm_mod, u16 idlest_reg, 67int omap_cm_wait_module_idle(u8 part, s16 prcm_mod, u16 idlest_reg,
64 u8 idlest_shift); 68 u8 idlest_shift);
69int omap_cm_module_enable(u8 mode, u8 part, u16 inst, u16 clkctrl_offs);
70int omap_cm_module_disable(u8 part, u16 inst, u16 clkctrl_offs);
65extern int cm_register(struct cm_ll_data *cld); 71extern int cm_register(struct cm_ll_data *cld);
66extern int cm_unregister(struct cm_ll_data *cld); 72extern int cm_unregister(struct cm_ll_data *cld);
67 73
diff --git a/arch/arm/mach-omap2/cm33xx.c b/arch/arm/mach-omap2/cm33xx.c
index ffdcb7abf092..b9ad463a368a 100644
--- a/arch/arm/mach-omap2/cm33xx.c
+++ b/arch/arm/mach-omap2/cm33xx.c
@@ -277,13 +277,14 @@ static int am33xx_cm_wait_module_idle(u8 part, s16 inst, u16 clkctrl_offs,
277/** 277/**
278 * am33xx_cm_module_enable - Enable the modulemode inside CLKCTRL 278 * am33xx_cm_module_enable - Enable the modulemode inside CLKCTRL
279 * @mode: Module mode (SW or HW) 279 * @mode: Module mode (SW or HW)
280 * @part: CM partition, ignored for AM33xx
280 * @inst: CM instance register offset (*_INST macro) 281 * @inst: CM instance register offset (*_INST macro)
281 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
282 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro) 282 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
283 * 283 *
284 * No return value. 284 * No return value.
285 */ 285 */
286void am33xx_cm_module_enable(u8 mode, u16 inst, s16 cdoffs, u16 clkctrl_offs) 286static void am33xx_cm_module_enable(u8 mode, u8 part, u16 inst,
287 u16 clkctrl_offs)
287{ 288{
288 u32 v; 289 u32 v;
289 290
@@ -295,13 +296,13 @@ void am33xx_cm_module_enable(u8 mode, u16 inst, s16 cdoffs, u16 clkctrl_offs)
295 296
296/** 297/**
297 * am33xx_cm_module_disable - Disable the module inside CLKCTRL 298 * am33xx_cm_module_disable - Disable the module inside CLKCTRL
299 * @part: CM partition, ignored for AM33xx
298 * @inst: CM instance register offset (*_INST macro) 300 * @inst: CM instance register offset (*_INST macro)
299 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
300 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro) 301 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
301 * 302 *
302 * No return value. 303 * No return value.
303 */ 304 */
304void am33xx_cm_module_disable(u16 inst, s16 cdoffs, u16 clkctrl_offs) 305static void am33xx_cm_module_disable(u8 part, u16 inst, u16 clkctrl_offs)
305{ 306{
306 u32 v; 307 u32 v;
307 308
@@ -368,6 +369,8 @@ struct clkdm_ops am33xx_clkdm_operations = {
368static struct cm_ll_data am33xx_cm_ll_data = { 369static struct cm_ll_data am33xx_cm_ll_data = {
369 .wait_module_ready = &am33xx_cm_wait_module_ready, 370 .wait_module_ready = &am33xx_cm_wait_module_ready,
370 .wait_module_idle = &am33xx_cm_wait_module_idle, 371 .wait_module_idle = &am33xx_cm_wait_module_idle,
372 .module_enable = &am33xx_cm_module_enable,
373 .module_disable = &am33xx_cm_module_disable,
371}; 374};
372 375
373int __init am33xx_cm_init(void) 376int __init am33xx_cm_init(void)
diff --git a/arch/arm/mach-omap2/cm33xx.h b/arch/arm/mach-omap2/cm33xx.h
index 78a61e5d80e2..046b4b2bc9d9 100644
--- a/arch/arm/mach-omap2/cm33xx.h
+++ b/arch/arm/mach-omap2/cm33xx.h
@@ -375,22 +375,5 @@
375 375
376#ifndef __ASSEMBLER__ 376#ifndef __ASSEMBLER__
377int am33xx_cm_init(void); 377int am33xx_cm_init(void);
378
379#if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
380extern void am33xx_cm_module_enable(u8 mode, u16 inst, s16 cdoffs,
381 u16 clkctrl_offs);
382extern void am33xx_cm_module_disable(u16 inst, s16 cdoffs,
383 u16 clkctrl_offs);
384#else
385static inline void am33xx_cm_module_enable(u8 mode, u16 inst, s16 cdoffs,
386 u16 clkctrl_offs)
387{
388}
389static inline void am33xx_cm_module_disable(u16 inst, s16 cdoffs,
390 u16 clkctrl_offs)
391{
392}
393#endif
394
395#endif /* ASSEMBLER */ 378#endif /* ASSEMBLER */
396#endif 379#endif
diff --git a/arch/arm/mach-omap2/cm_common.c b/arch/arm/mach-omap2/cm_common.c
index c6237df288d8..8fe02fcedc48 100644
--- a/arch/arm/mach-omap2/cm_common.c
+++ b/arch/arm/mach-omap2/cm_common.c
@@ -124,6 +124,51 @@ int omap_cm_wait_module_idle(u8 part, s16 prcm_mod, u16 idlest_reg,
124} 124}
125 125
126/** 126/**
127 * omap_cm_module_enable - enable a module
128 * @mode: target mode for the module
129 * @part: PRCM partition
130 * @inst: PRCM instance
131 * @clkctrl_offs: CM_CLKCTRL register offset for the module
132 *
133 * Enables clocks for a module identified by (@part, @inst, @clkctrl_offs)
134 * making its IO space accessible. Return 0 upon success, -EINVAL if no
135 * per-SoC module_enable() function pointer has been registered.
136 */
137int omap_cm_module_enable(u8 mode, u8 part, u16 inst, u16 clkctrl_offs)
138{
139 if (!cm_ll_data->module_enable) {
140 WARN_ONCE(1, "cm: %s: no low-level function defined\n",
141 __func__);
142 return -EINVAL;
143 }
144
145 cm_ll_data->module_enable(mode, part, inst, clkctrl_offs);
146 return 0;
147}
148
149/**
150 * omap_cm_module_disable - disable a module
151 * @part: PRCM partition
152 * @inst: PRCM instance
153 * @clkctrl_offs: CM_CLKCTRL register offset for the module
154 *
155 * Disables clocks for a module identified by (@part, @inst, @clkctrl_offs)
156 * makings its IO space inaccessible. Return 0 upon success, -EINVAL if
157 * no per-SoC module_disable() function pointer has been registered.
158 */
159int omap_cm_module_disable(u8 part, u16 inst, u16 clkctrl_offs)
160{
161 if (!cm_ll_data->module_disable) {
162 WARN_ONCE(1, "cm: %s: no low-level function defined\n",
163 __func__);
164 return -EINVAL;
165 }
166
167 cm_ll_data->module_disable(part, inst, clkctrl_offs);
168 return 0;
169}
170
171/**
127 * cm_register - register per-SoC low-level data with the CM 172 * cm_register - register per-SoC low-level data with the CM
128 * @cld: low-level per-SoC OMAP CM data & function pointers to register 173 * @cld: low-level per-SoC OMAP CM data & function pointers to register
129 * 174 *
diff --git a/arch/arm/mach-omap2/cminst44xx.c b/arch/arm/mach-omap2/cminst44xx.c
index b189a2b46808..ac034109078e 100644
--- a/arch/arm/mach-omap2/cminst44xx.c
+++ b/arch/arm/mach-omap2/cminst44xx.c
@@ -319,13 +319,12 @@ static int omap4_cminst_wait_module_idle(u8 part, s16 inst, u16 clkctrl_offs,
319 * @mode: Module mode (SW or HW) 319 * @mode: Module mode (SW or HW)
320 * @part: PRCM partition ID that the CM_CLKCTRL register exists in 320 * @part: PRCM partition ID that the CM_CLKCTRL register exists in
321 * @inst: CM instance register offset (*_INST macro) 321 * @inst: CM instance register offset (*_INST macro)
322 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
323 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro) 322 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
324 * 323 *
325 * No return value. 324 * No return value.
326 */ 325 */
327void omap4_cminst_module_enable(u8 mode, u8 part, u16 inst, s16 cdoffs, 326static void omap4_cminst_module_enable(u8 mode, u8 part, u16 inst,
328 u16 clkctrl_offs) 327 u16 clkctrl_offs)
329{ 328{
330 u32 v; 329 u32 v;
331 330
@@ -339,13 +338,11 @@ void omap4_cminst_module_enable(u8 mode, u8 part, u16 inst, s16 cdoffs,
339 * omap4_cminst_module_disable - Disable the module inside CLKCTRL 338 * omap4_cminst_module_disable - Disable the module inside CLKCTRL
340 * @part: PRCM partition ID that the CM_CLKCTRL register exists in 339 * @part: PRCM partition ID that the CM_CLKCTRL register exists in
341 * @inst: CM instance register offset (*_INST macro) 340 * @inst: CM instance register offset (*_INST macro)
342 * @cdoffs: Clockdomain register offset (*_CDOFFS macro)
343 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro) 341 * @clkctrl_offs: Module clock control register offset (*_CLKCTRL macro)
344 * 342 *
345 * No return value. 343 * No return value.
346 */ 344 */
347void omap4_cminst_module_disable(u8 part, u16 inst, s16 cdoffs, 345static void omap4_cminst_module_disable(u8 part, u16 inst, u16 clkctrl_offs)
348 u16 clkctrl_offs)
349{ 346{
350 u32 v; 347 u32 v;
351 348
@@ -513,6 +510,8 @@ struct clkdm_ops am43xx_clkdm_operations = {
513static struct cm_ll_data omap4xxx_cm_ll_data = { 510static struct cm_ll_data omap4xxx_cm_ll_data = {
514 .wait_module_ready = &omap4_cminst_wait_module_ready, 511 .wait_module_ready = &omap4_cminst_wait_module_ready,
515 .wait_module_idle = &omap4_cminst_wait_module_idle, 512 .wait_module_idle = &omap4_cminst_wait_module_idle,
513 .module_enable = &omap4_cminst_module_enable,
514 .module_disable = &omap4_cminst_module_disable,
516}; 515};
517 516
518int __init omap4_cm_init(void) 517int __init omap4_cm_init(void)
diff --git a/arch/arm/mach-omap2/cminst44xx.h b/arch/arm/mach-omap2/cminst44xx.h
index d6634fada357..ffbd7219bb81 100644
--- a/arch/arm/mach-omap2/cminst44xx.h
+++ b/arch/arm/mach-omap2/cminst44xx.h
@@ -11,10 +11,6 @@
11#ifndef __ARCH_ASM_MACH_OMAP2_CMINST44XX_H 11#ifndef __ARCH_ASM_MACH_OMAP2_CMINST44XX_H
12#define __ARCH_ASM_MACH_OMAP2_CMINST44XX_H 12#define __ARCH_ASM_MACH_OMAP2_CMINST44XX_H
13 13
14extern void omap4_cminst_module_enable(u8 mode, u8 part, u16 inst, s16 cdoffs,
15 u16 clkctrl_offs);
16extern void omap4_cminst_module_disable(u8 part, u16 inst, s16 cdoffs,
17 u16 clkctrl_offs);
18/* 14/*
19 * In an ideal world, we would not export these low-level functions, 15 * In an ideal world, we would not export these low-level functions,
20 * but this will probably take some time to fix properly 16 * but this will probably take some time to fix properly
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 03a42b37ef18..a8f57ef1e1d4 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -979,11 +979,9 @@ static void _omap4_enable_module(struct omap_hwmod *oh)
979 pr_debug("omap_hwmod: %s: %s: %d\n", 979 pr_debug("omap_hwmod: %s: %s: %d\n",
980 oh->name, __func__, oh->prcm.omap4.modulemode); 980 oh->name, __func__, oh->prcm.omap4.modulemode);
981 981
982 omap4_cminst_module_enable(oh->prcm.omap4.modulemode, 982 omap_cm_module_enable(oh->prcm.omap4.modulemode,
983 oh->clkdm->prcm_partition, 983 oh->clkdm->prcm_partition,
984 oh->clkdm->cm_inst, 984 oh->clkdm->cm_inst, oh->prcm.omap4.clkctrl_offs);
985 oh->clkdm->clkdm_offs,
986 oh->prcm.omap4.clkctrl_offs);
987} 985}
988 986
989/** 987/**
@@ -1001,9 +999,8 @@ static void _am33xx_enable_module(struct omap_hwmod *oh)
1001 pr_debug("omap_hwmod: %s: %s: %d\n", 999 pr_debug("omap_hwmod: %s: %s: %d\n",
1002 oh->name, __func__, oh->prcm.omap4.modulemode); 1000 oh->name, __func__, oh->prcm.omap4.modulemode);
1003 1001
1004 am33xx_cm_module_enable(oh->prcm.omap4.modulemode, oh->clkdm->cm_inst, 1002 omap_cm_module_enable(oh->prcm.omap4.modulemode, 0, oh->clkdm->cm_inst,
1005 oh->clkdm->clkdm_offs, 1003 oh->prcm.omap4.clkctrl_offs);
1006 oh->prcm.omap4.clkctrl_offs);
1007} 1004}
1008 1005
1009/** 1006/**
@@ -1857,10 +1854,8 @@ static int _omap4_disable_module(struct omap_hwmod *oh)
1857 1854
1858 pr_debug("omap_hwmod: %s: %s\n", oh->name, __func__); 1855 pr_debug("omap_hwmod: %s: %s\n", oh->name, __func__);
1859 1856
1860 omap4_cminst_module_disable(oh->clkdm->prcm_partition, 1857 omap_cm_module_disable(oh->clkdm->prcm_partition, oh->clkdm->cm_inst,
1861 oh->clkdm->cm_inst, 1858 oh->prcm.omap4.clkctrl_offs);
1862 oh->clkdm->clkdm_offs,
1863 oh->prcm.omap4.clkctrl_offs);
1864 1859
1865 v = _omap4_wait_target_disable(oh); 1860 v = _omap4_wait_target_disable(oh);
1866 if (v) 1861 if (v)
@@ -1889,8 +1884,8 @@ static int _am33xx_disable_module(struct omap_hwmod *oh)
1889 if (_are_any_hardreset_lines_asserted(oh)) 1884 if (_are_any_hardreset_lines_asserted(oh))
1890 return 0; 1885 return 0;
1891 1886
1892 am33xx_cm_module_disable(oh->clkdm->cm_inst, oh->clkdm->clkdm_offs, 1887 omap_cm_module_disable(0, oh->clkdm->cm_inst,
1893 oh->prcm.omap4.clkctrl_offs); 1888 oh->prcm.omap4.clkctrl_offs);
1894 1889
1895 v = _am33xx_wait_target_disable(oh); 1890 v = _am33xx_wait_target_disable(oh);
1896 if (v) 1891 if (v)