aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2010-12-21 23:05:14 -0500
committerPaul Walmsley <paul@pwsan.com>2010-12-21 23:05:14 -0500
commit2ace831ffc8feaffb8bc03da89ff43d948efdc97 (patch)
tree4a75814c417ffe94dd2505585305378b7f04b40e /arch
parentf0611a5c220e50dec65041b10bd2fe9484f061a6 (diff)
OMAP4: PRCM: add OMAP4-specific accessor/mutator functions
In some ways, the OMAP4 PRCM register layout is quite different than the OMAP2/3 PRCM register layout. For example, on OMAP2/3, from a register layout point of view, all CM instances were located in the CM subsystem, and all PRM instances were located in the PRM subsystem. OMAP4 changes this. Now, for example, some CM instances, such as WKUP_CM and EMU_CM, are located in the system PRM subsystem. And a "local PRCM" exists for the MPU - this PRCM combines registers that would normally appear in both CM and PRM instances, but uses its own register layout which matches neither the OMAP2/3 PRCM layout nor the OMAP4 PRCM layout. To try to deal with this, introduce some new functions, omap4_cminst* and omap4_prminst*. The former is to be used when writing to a CM instance register (no matter what subsystem or hardware module it exists in), and the latter, similarly, with PRM instance registers. To determine which "PRCM partition" to write to, the functions take a PRCM instance ID argument. Subsequent patches add these partition IDs to the OMAP4 powerdomain and clockdomain definitions. As far as I can see, there's really no good way to handle these types of register access inconsistencies. This patch seemed like the least bad approach. Moving forward, the long-term goal is to remove all direct PRCM register access from the PM code. PRCM register access should go through layers such as the powerdomain and clockdomain code that can hide the details of how to interact with the specific hardware variant. While here, rename cm4xxx.c to cm44xx.c to match the naming convention of the other OMAP4 PRCM files. Thanks to Santosh Shilimkar <santosh.shilimkar@ti.com>, Rajendra Nayak <rnayak@ti.com>, and Benoît Cousson <b-cousson@ti.com> for some comments. Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Benoît Cousson <b-cousson@ti.com> Cc: Rajendra Nayak <rnayak@ti.com> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap2/Makefile4
-rw-r--r--arch/arm/mach-omap2/cm1_44xx.h5
-rw-r--r--arch/arm/mach-omap2/cm2_44xx.h6
-rw-r--r--arch/arm/mach-omap2/cm44xx.c52
-rw-r--r--arch/arm/mach-omap2/cm4xxx.c62
-rw-r--r--arch/arm/mach-omap2/cminst44xx.c109
-rw-r--r--arch/arm/mach-omap2/cminst44xx.h25
-rw-r--r--arch/arm/mach-omap2/prcm.c26
-rw-r--r--arch/arm/mach-omap2/prcm44xx.h42
-rw-r--r--arch/arm/mach-omap2/prcm_mpu44xx.c45
-rw-r--r--arch/arm/mach-omap2/prcm_mpu44xx.h8
-rw-r--r--arch/arm/mach-omap2/prm44xx.c65
-rw-r--r--arch/arm/mach-omap2/prm44xx.h6
-rw-r--r--arch/arm/mach-omap2/prminst44xx.c66
-rw-r--r--arch/arm/mach-omap2/prminst44xx.h25
-rw-r--r--arch/arm/plat-omap/include/plat/prcm.h7
16 files changed, 462 insertions, 91 deletions
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index b2e4f7bcfa34..1fce382a90a9 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -77,7 +77,9 @@ obj-$(CONFIG_ARCH_OMAP3) += prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o
77# XXX The presence of cm2xxx_3xxx.o on the line below is temporary and 77# XXX The presence of cm2xxx_3xxx.o on the line below is temporary and
78# will be removed once the OMAP4 part of the codebase is converted to 78# will be removed once the OMAP4 part of the codebase is converted to
79# use OMAP4-specific PRCM functions. 79# use OMAP4-specific PRCM functions.
80obj-$(CONFIG_ARCH_OMAP4) += prcm.o cm2xxx_3xxx.o cm4xxx.o 80obj-$(CONFIG_ARCH_OMAP4) += prcm.o cm2xxx_3xxx.o cminst44xx.o \
81 cm44xx.o prcm_mpu44xx.o \
82 prminst44xx.o
81 83
82# OMAP powerdomain framework 84# OMAP powerdomain framework
83powerdomain-common += powerdomain.o powerdomain-common.o 85powerdomain-common += powerdomain.o powerdomain-common.o
diff --git a/arch/arm/mach-omap2/cm1_44xx.h b/arch/arm/mach-omap2/cm1_44xx.h
index aa2ee7802631..63ef9e3a857c 100644
--- a/arch/arm/mach-omap2/cm1_44xx.h
+++ b/arch/arm/mach-omap2/cm1_44xx.h
@@ -248,4 +248,9 @@
248#define OMAP4_CM_DYN_DEP_PRESCAL_RESTORE_OFFSET 0x0040 248#define OMAP4_CM_DYN_DEP_PRESCAL_RESTORE_OFFSET 0x0040
249#define OMAP4430_CM_DYN_DEP_PRESCAL_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_INST, 0x0040) 249#define OMAP4430_CM_DYN_DEP_PRESCAL_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_INST, 0x0040)
250 250
251/* Function prototypes */
252extern u32 omap4_cm1_read_inst_reg(s16 inst, u16 idx);
253extern void omap4_cm1_write_inst_reg(u32 val, s16 inst, u16 idx);
254extern u32 omap4_cm1_rmw_inst_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx);
255
251#endif 256#endif
diff --git a/arch/arm/mach-omap2/cm2_44xx.h b/arch/arm/mach-omap2/cm2_44xx.h
index 89c95220d3e9..0fd021069792 100644
--- a/arch/arm/mach-omap2/cm2_44xx.h
+++ b/arch/arm/mach-omap2/cm2_44xx.h
@@ -480,4 +480,10 @@
480#define OMAP4430_CM_L3INIT_USB_TLL_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_INST, 0x0058) 480#define OMAP4430_CM_L3INIT_USB_TLL_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_INST, 0x0058)
481#define OMAP4_CM_SDMA_STATICDEP_RESTORE_OFFSET 0x005c 481#define OMAP4_CM_SDMA_STATICDEP_RESTORE_OFFSET 0x005c
482#define OMAP4430_CM_SDMA_STATICDEP_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_INST, 0x005c) 482#define OMAP4430_CM_SDMA_STATICDEP_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_INST, 0x005c)
483
484/* Function prototypes */
485extern u32 omap4_cm2_read_inst_reg(s16 inst, u16 idx);
486extern void omap4_cm2_write_inst_reg(u32 val, s16 inst, u16 idx);
487extern u32 omap4_cm2_rmw_inst_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx);
488
483#endif 489#endif
diff --git a/arch/arm/mach-omap2/cm44xx.c b/arch/arm/mach-omap2/cm44xx.c
new file mode 100644
index 000000000000..e96f53ea01a1
--- /dev/null
+++ b/arch/arm/mach-omap2/cm44xx.c
@@ -0,0 +1,52 @@
1/*
2 * OMAP4 CM1, CM2 module low-level functions
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 * Paul Walmsley
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * These functions are intended to be used only by the cminst44xx.c file.
12 * XXX Perhaps we should just move them there and make them static.
13 */
14
15#include <linux/kernel.h>
16#include <linux/types.h>
17#include <linux/errno.h>
18#include <linux/err.h>
19#include <linux/io.h>
20
21#include <plat/common.h>
22
23#include "cm.h"
24#include "cm1_44xx.h"
25#include "cm2_44xx.h"
26#include "cm-regbits-44xx.h"
27
28/* CM1 hardware module low-level functions */
29
30/* Read a register in CM1 */
31u32 omap4_cm1_read_inst_reg(s16 inst, u16 reg)
32{
33 return __raw_readl(OMAP44XX_CM1_REGADDR(inst, reg));
34}
35
36/* Write into a register in CM1 */
37void omap4_cm1_write_inst_reg(u32 val, s16 inst, u16 reg)
38{
39 __raw_writel(val, OMAP44XX_CM1_REGADDR(inst, reg));
40}
41
42/* Read a register in CM2 */
43u32 omap4_cm2_read_inst_reg(s16 inst, u16 reg)
44{
45 return __raw_readl(OMAP44XX_CM2_REGADDR(inst, reg));
46}
47
48/* Write into a register in CM2 */
49void omap4_cm2_write_inst_reg(u32 val, s16 inst, u16 reg)
50{
51 __raw_writel(val, OMAP44XX_CM2_REGADDR(inst, reg));
52}
diff --git a/arch/arm/mach-omap2/cm4xxx.c b/arch/arm/mach-omap2/cm4xxx.c
deleted file mode 100644
index 25d2b3e4c6f7..000000000000
--- a/arch/arm/mach-omap2/cm4xxx.c
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * OMAP4 CM module functions
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Paul Walmsley
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/types.h>
15#include <linux/delay.h>
16#include <linux/spinlock.h>
17#include <linux/list.h>
18#include <linux/errno.h>
19#include <linux/err.h>
20#include <linux/io.h>
21
22#include <asm/atomic.h>
23
24#include <plat/common.h>
25
26#include "cm44xx.h"
27#include "cm-regbits-44xx.h"
28
29/**
30 * omap4_cm_wait_module_ready - wait for a module to be in 'func' state
31 * @clkctrl_reg: CLKCTRL module address
32 *
33 * Wait for the module IDLEST to be functional. If the idle state is in any
34 * the non functional state (trans, idle or disabled), module and thus the
35 * sysconfig cannot be accessed and will probably lead to an "imprecise
36 * external abort"
37 *
38 * Module idle state:
39 * 0x0 func: Module is fully functional, including OCP
40 * 0x1 trans: Module is performing transition: wakeup, or sleep, or sleep
41 * abortion
42 * 0x2 idle: Module is in Idle mode (only OCP part). It is functional if
43 * using separate functional clock
44 * 0x3 disabled: Module is disabled and cannot be accessed
45 *
46 */
47int omap4_cm_wait_module_ready(void __iomem *clkctrl_reg)
48{
49 int i = 0;
50
51 if (!clkctrl_reg)
52 return 0;
53
54 omap_test_timeout((
55 ((__raw_readl(clkctrl_reg) & OMAP4430_IDLEST_MASK) == 0) ||
56 (((__raw_readl(clkctrl_reg) & OMAP4430_IDLEST_MASK) >>
57 OMAP4430_IDLEST_SHIFT) == 0x2)),
58 MAX_MODULE_READY_TIME, i);
59
60 return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
61}
62
diff --git a/arch/arm/mach-omap2/cminst44xx.c b/arch/arm/mach-omap2/cminst44xx.c
new file mode 100644
index 000000000000..c13613b513b5
--- /dev/null
+++ b/arch/arm/mach-omap2/cminst44xx.c
@@ -0,0 +1,109 @@
1/*
2 * OMAP4 CM instance functions
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Paul Walmsley
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This is needed since CM instances can be in the PRM, PRCM_MPU, CM1,
12 * or CM2 hardware modules. For example, the EMU_CM CM instance is in
13 * the PRM hardware module. What a mess...
14 */
15
16#include <linux/kernel.h>
17#include <linux/types.h>
18#include <linux/errno.h>
19#include <linux/err.h>
20#include <linux/io.h>
21
22#include <plat/common.h>
23
24#include "cm.h"
25#include "cm1_44xx.h"
26#include "cm2_44xx.h"
27#include "cm44xx.h"
28#include "cminst44xx.h"
29#include "cm-regbits-44xx.h"
30#include "prcm44xx.h"
31#include "prm44xx.h"
32#include "prcm_mpu44xx.h"
33
34static u32 _cm_bases[OMAP4_MAX_PRCM_PARTITIONS] = {
35 [OMAP4430_INVALID_PRCM_PARTITION] = 0,
36 [OMAP4430_PRM_PARTITION] = OMAP4430_PRM_BASE,
37 [OMAP4430_CM1_PARTITION] = OMAP4430_CM1_BASE,
38 [OMAP4430_CM2_PARTITION] = OMAP4430_CM2_BASE,
39 [OMAP4430_SCRM_PARTITION] = 0,
40 [OMAP4430_PRCM_MPU_PARTITION] = OMAP4430_PRCM_MPU_BASE,
41};
42
43/* Read a register in a CM instance */
44u32 omap4_cminst_read_inst_reg(u8 part, s16 inst, u16 idx)
45{
46 BUG_ON(part >= OMAP4_MAX_PRCM_PARTITIONS ||
47 part == OMAP4430_INVALID_PRCM_PARTITION ||
48 !_cm_bases[part]);
49 return __raw_readl(OMAP2_L4_IO_ADDRESS(_cm_bases[part] + inst + idx));
50}
51
52/* Write into a register in a CM instance */
53void omap4_cminst_write_inst_reg(u32 val, u8 part, s16 inst, u16 idx)
54{
55 BUG_ON(part >= OMAP4_MAX_PRCM_PARTITIONS ||
56 part == OMAP4430_INVALID_PRCM_PARTITION ||
57 !_cm_bases[part]);
58 __raw_writel(val, OMAP2_L4_IO_ADDRESS(_cm_bases[part] + inst + idx));
59}
60
61/* Read-modify-write a register in CM1. Caller must lock */
62u32 omap4_cminst_rmw_inst_reg_bits(u32 mask, u32 bits, u8 part, s16 inst,
63 s16 idx)
64{
65 u32 v;
66
67 v = omap4_cminst_read_inst_reg(part, inst, idx);
68 v &= ~mask;
69 v |= bits;
70 omap4_cminst_write_inst_reg(v, part, inst, idx);
71
72 return v;
73}
74
75
76/**
77 * omap4_cm_wait_module_ready - wait for a module to be in 'func' state
78 * @clkctrl_reg: CLKCTRL module address
79 *
80 * Wait for the module IDLEST to be functional. If the idle state is in any
81 * the non functional state (trans, idle or disabled), module and thus the
82 * sysconfig cannot be accessed and will probably lead to an "imprecise
83 * external abort"
84 *
85 * Module idle state:
86 * 0x0 func: Module is fully functional, including OCP
87 * 0x1 trans: Module is performing transition: wakeup, or sleep, or sleep
88 * abortion
89 * 0x2 idle: Module is in Idle mode (only OCP part). It is functional if
90 * using separate functional clock
91 * 0x3 disabled: Module is disabled and cannot be accessed
92 *
93 */
94int omap4_cm_wait_module_ready(void __iomem *clkctrl_reg)
95{
96 int i = 0;
97
98 if (!clkctrl_reg)
99 return 0;
100
101 omap_test_timeout((
102 ((__raw_readl(clkctrl_reg) & OMAP4430_IDLEST_MASK) == 0) ||
103 (((__raw_readl(clkctrl_reg) & OMAP4430_IDLEST_MASK) >>
104 OMAP4430_IDLEST_SHIFT) == 0x2)),
105 MAX_MODULE_READY_TIME, i);
106
107 return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
108}
109
diff --git a/arch/arm/mach-omap2/cminst44xx.h b/arch/arm/mach-omap2/cminst44xx.h
new file mode 100644
index 000000000000..6baa4c7b14f1
--- /dev/null
+++ b/arch/arm/mach-omap2/cminst44xx.h
@@ -0,0 +1,25 @@
1/*
2 * OMAP4 Clock Management (CM) function prototypes
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 * Paul Walmsley
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef __ARCH_ASM_MACH_OMAP2_CMINST44XX_H
12#define __ARCH_ASM_MACH_OMAP2_CMINST44XX_H
13
14/*
15 * In an ideal world, we would not export these low-level functions,
16 * but this will probably take some time to fix properly
17 */
18extern u32 omap4_cminst_read_inst_reg(u8 part, s16 inst, u16 idx);
19extern void omap4_cminst_write_inst_reg(u32 val, u8 part, s16 inst, u16 idx);
20extern u32 omap4_cminst_rmw_inst_reg_bits(u32 mask, u32 bits, u8 part,
21 s16 inst, s16 idx);
22
23extern int omap4_cm_wait_module_ready(void __iomem *clkctrl_reg);
24
25#endif
diff --git a/arch/arm/mach-omap2/prcm.c b/arch/arm/mach-omap2/prcm.c
index dd95cbbdecc7..fe0865bd64cf 100644
--- a/arch/arm/mach-omap2/prcm.c
+++ b/arch/arm/mach-omap2/prcm.c
@@ -33,6 +33,7 @@
33#include "cm44xx.h" 33#include "cm44xx.h"
34#include "prm2xxx_3xxx.h" 34#include "prm2xxx_3xxx.h"
35#include "prm44xx.h" 35#include "prm44xx.h"
36#include "prcm44xx.h"
36#include "prm-regbits-24xx.h" 37#include "prm-regbits-24xx.h"
37#include "prm-regbits-44xx.h" 38#include "prm-regbits-44xx.h"
38#include "control.h" 39#include "control.h"
@@ -80,31 +81,6 @@ void omap_prcm_arch_reset(char mode, const char *cmd)
80 prcm_offs, OMAP4_RM_RSTCTRL); 81 prcm_offs, OMAP4_RM_RSTCTRL);
81} 82}
82 83
83/* Read a PRM register, AND it, and shift the result down to bit 0 */
84u32 omap4_prm_read_bits_shift(void __iomem *reg, u32 mask)
85{
86 u32 v;
87
88 v = __raw_readl(reg);
89 v &= mask;
90 v >>= __ffs(mask);
91
92 return v;
93}
94
95/* Read-modify-write a register in a PRM module. Caller must lock */
96u32 omap4_prm_rmw_reg_bits(u32 mask, u32 bits, void __iomem *reg)
97{
98 u32 v;
99
100 v = __raw_readl(reg);
101 v &= ~mask;
102 v |= bits;
103 __raw_writel(v, reg);
104
105 return v;
106}
107
108/** 84/**
109 * omap2_cm_wait_idlest - wait for IDLEST bit to indicate module readiness 85 * omap2_cm_wait_idlest - wait for IDLEST bit to indicate module readiness
110 * @reg: physical address of module IDLEST register 86 * @reg: physical address of module IDLEST register
diff --git a/arch/arm/mach-omap2/prcm44xx.h b/arch/arm/mach-omap2/prcm44xx.h
new file mode 100644
index 000000000000..7334ffb9d2c1
--- /dev/null
+++ b/arch/arm/mach-omap2/prcm44xx.h
@@ -0,0 +1,42 @@
1/*
2 * OMAP4 PRCM definitions
3 *
4 * Copyright (C) 2010 Texas Instruments, Inc.
5 * Copyright (C) 2010 Nokia Corporation
6 *
7 * Paul Walmsley
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This file contains macros and functions that are common to all of
14 * the PRM/CM/PRCM blocks on the OMAP4 devices: PRM, CM1, CM2,
15 * PRCM_MPU, SCRM
16 */
17
18#ifndef __ARCH_ARM_MACH_OMAP2_PRCM44XX_H
19#define __ARCH_ARM_MACH_OMAP2_PRCM44XX_H
20
21/*
22 * OMAP4 PRCM partition IDs
23 *
24 * The numbers and order are arbitrary, but 0 is reserved for the
25 * 'invalid' partition in case someone forgets to add a
26 * .prcm_partition field.
27 */
28#define OMAP4430_INVALID_PRCM_PARTITION 0
29#define OMAP4430_PRM_PARTITION 1
30#define OMAP4430_CM1_PARTITION 2
31#define OMAP4430_CM2_PARTITION 3
32#define OMAP4430_SCRM_PARTITION 4
33#define OMAP4430_PRCM_MPU_PARTITION 5
34
35/*
36 * OMAP4_MAX_PRCM_PARTITIONS: set to the highest value of the PRCM partition
37 * IDs, plus one
38 */
39#define OMAP4_MAX_PRCM_PARTITIONS 6
40
41
42#endif
diff --git a/arch/arm/mach-omap2/prcm_mpu44xx.c b/arch/arm/mach-omap2/prcm_mpu44xx.c
new file mode 100644
index 000000000000..171fe171a749
--- /dev/null
+++ b/arch/arm/mach-omap2/prcm_mpu44xx.c
@@ -0,0 +1,45 @@
1/*
2 * OMAP4 PRCM_MPU module functions
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Paul Walmsley
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/errno.h>
15#include <linux/err.h>
16#include <linux/io.h>
17
18#include <plat/common.h>
19
20#include "prcm_mpu44xx.h"
21#include "cm-regbits-44xx.h"
22
23/* PRCM_MPU low-level functions */
24
25u32 omap4_prcm_mpu_read_inst_reg(s16 inst, u16 reg)
26{
27 return __raw_readl(OMAP44XX_PRCM_MPU_REGADDR(inst, reg));
28}
29
30void omap4_prcm_mpu_write_inst_reg(u32 val, s16 inst, u16 reg)
31{
32 __raw_writel(val, OMAP44XX_PRCM_MPU_REGADDR(inst, reg));
33}
34
35u32 omap4_prcm_mpu_rmw_inst_reg_bits(u32 mask, u32 bits, s16 inst, s16 reg)
36{
37 u32 v;
38
39 v = omap4_prcm_mpu_read_inst_reg(inst, reg);
40 v &= ~mask;
41 v |= bits;
42 omap4_prcm_mpu_write_inst_reg(v, inst, reg);
43
44 return v;
45}
diff --git a/arch/arm/mach-omap2/prcm_mpu44xx.h b/arch/arm/mach-omap2/prcm_mpu44xx.h
index 80e00c16d36f..e5190e99fd94 100644
--- a/arch/arm/mach-omap2/prcm_mpu44xx.h
+++ b/arch/arm/mach-omap2/prcm_mpu44xx.h
@@ -88,4 +88,12 @@
88#define OMAP4_CM_CPU1_CLKSTCTRL_OFFSET 0x0018 88#define OMAP4_CM_CPU1_CLKSTCTRL_OFFSET 0x0018
89#define OMAP4430_CM_CPU1_CLKSTCTRL OMAP44XX_PRCM_MPU_REGADDR(OMAP4430_PRCM_MPU_CPU1_INST, 0x0018) 89#define OMAP4430_CM_CPU1_CLKSTCTRL OMAP44XX_PRCM_MPU_REGADDR(OMAP4430_PRCM_MPU_CPU1_INST, 0x0018)
90 90
91/* Function prototypes */
92# ifndef __ASSEMBLER__
93extern u32 omap4_prcm_mpu_read_inst_reg(s16 inst, u16 idx);
94extern void omap4_prcm_mpu_write_inst_reg(u32 val, s16 inst, u16 idx);
95extern u32 omap4_prcm_mpu_rmw_inst_reg_bits(u32 mask, u32 bits, s16 inst,
96 s16 idx);
97# endif
98
91#endif 99#endif
diff --git a/arch/arm/mach-omap2/prm44xx.c b/arch/arm/mach-omap2/prm44xx.c
index 697b58f8e4a8..c016ae4cbad1 100644
--- a/arch/arm/mach-omap2/prm44xx.c
+++ b/arch/arm/mach-omap2/prm44xx.c
@@ -15,6 +15,7 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/io.h>
18 19
19#include <plat/common.h> 20#include <plat/common.h>
20#include <plat/cpu.h> 21#include <plat/cpu.h>
@@ -29,6 +30,70 @@
29 */ 30 */
30#define OMAP4_RST_CTRL_ST_OFFSET 4 31#define OMAP4_RST_CTRL_ST_OFFSET 4
31 32
33/* PRM low-level functions */
34
35/* Read a register in a CM/PRM instance in the PRM module */
36u32 omap4_prm_read_inst_reg(s16 inst, u16 reg)
37{
38 return __raw_readl(OMAP44XX_PRM_REGADDR(inst, reg));
39}
40
41/* Write into a register in a CM/PRM instance in the PRM module */
42void omap4_prm_write_inst_reg(u32 val, s16 inst, u16 reg)
43{
44 __raw_writel(val, OMAP44XX_PRM_REGADDR(inst, reg));
45}
46
47/* Read-modify-write a register in a PRM module. Caller must lock */
48u32 omap4_prm_rmw_inst_reg_bits(u32 mask, u32 bits, s16 inst, s16 reg)
49{
50 u32 v;
51
52 v = omap4_prm_read_inst_reg(inst, reg);
53 v &= ~mask;
54 v |= bits;
55 omap4_prm_write_inst_reg(v, inst, reg);
56
57 return v;
58}
59
60/* Read a PRM register, AND it, and shift the result down to bit 0 */
61/* XXX deprecated */
62u32 omap4_prm_read_bits_shift(void __iomem *reg, u32 mask)
63{
64 u32 v;
65
66 v = __raw_readl(reg);
67 v &= mask;
68 v >>= __ffs(mask);
69
70 return v;
71}
72
73/* Read-modify-write a register in a PRM module. Caller must lock */
74/* XXX deprecated */
75u32 omap4_prm_rmw_reg_bits(u32 mask, u32 bits, void __iomem *reg)
76{
77 u32 v;
78
79 v = __raw_readl(reg);
80 v &= ~mask;
81 v |= bits;
82 __raw_writel(v, reg);
83
84 return v;
85}
86
87u32 omap4_prm_set_inst_reg_bits(u32 bits, s16 inst, s16 reg)
88{
89 return omap4_prm_rmw_inst_reg_bits(bits, bits, inst, reg);
90}
91
92u32 omap4_prm_clear_inst_reg_bits(u32 bits, s16 inst, s16 reg)
93{
94 return omap4_prm_rmw_inst_reg_bits(bits, 0x0, inst, reg);
95}
96
32/** 97/**
33 * omap4_prm_is_hardreset_asserted - read the HW reset line state of 98 * omap4_prm_is_hardreset_asserted - read the HW reset line state of
34 * submodules contained in the hwmod module 99 * submodules contained in the hwmod module
diff --git a/arch/arm/mach-omap2/prm44xx.h b/arch/arm/mach-omap2/prm44xx.h
index 3d361497ca70..358865344d58 100644
--- a/arch/arm/mach-omap2/prm44xx.h
+++ b/arch/arm/mach-omap2/prm44xx.h
@@ -744,6 +744,12 @@
744/* Function prototypes */ 744/* Function prototypes */
745# ifndef __ASSEMBLER__ 745# ifndef __ASSEMBLER__
746 746
747extern u32 omap4_prm_read_inst_reg(s16 inst, u16 idx);
748extern void omap4_prm_write_inst_reg(u32 val, s16 inst, u16 idx);
749extern u32 omap4_prm_rmw_inst_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx);
750extern u32 omap4_prm_rmw_reg_bits(u32 mask, u32 bits, void __iomem *reg);
751extern u32 omap4_prm_set_inst_reg_bits(u32 bits, s16 inst, s16 idx);
752extern u32 omap4_prm_clear_inst_reg_bits(u32 bits, s16 inst, s16 idx);
747extern u32 omap4_prm_read_bits_shift(void __iomem *reg, u32 mask); 753extern u32 omap4_prm_read_bits_shift(void __iomem *reg, u32 mask);
748 754
749extern int omap4_prm_is_hardreset_asserted(void __iomem *rstctrl_reg, u8 shift); 755extern int omap4_prm_is_hardreset_asserted(void __iomem *rstctrl_reg, u8 shift);
diff --git a/arch/arm/mach-omap2/prminst44xx.c b/arch/arm/mach-omap2/prminst44xx.c
new file mode 100644
index 000000000000..a30324297278
--- /dev/null
+++ b/arch/arm/mach-omap2/prminst44xx.c
@@ -0,0 +1,66 @@
1/*
2 * OMAP4 PRM instance functions
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Paul Walmsley
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/errno.h>
15#include <linux/err.h>
16#include <linux/io.h>
17
18#include <plat/common.h>
19
20#include "prm44xx.h"
21#include "prminst44xx.h"
22#include "prm-regbits-44xx.h"
23#include "prcm44xx.h"
24#include "prcm_mpu44xx.h"
25
26static u32 _prm_bases[OMAP4_MAX_PRCM_PARTITIONS] = {
27 [OMAP4430_INVALID_PRCM_PARTITION] = 0,
28 [OMAP4430_PRM_PARTITION] = OMAP4430_PRM_BASE,
29 [OMAP4430_CM1_PARTITION] = 0,
30 [OMAP4430_CM2_PARTITION] = 0,
31 [OMAP4430_SCRM_PARTITION] = 0,
32 [OMAP4430_PRCM_MPU_PARTITION] = OMAP4430_PRCM_MPU_BASE,
33};
34
35/* Read a register in a PRM instance */
36u32 omap4_prminst_read_inst_reg(u8 part, s16 inst, u16 idx)
37{
38 BUG_ON(part >= OMAP4_MAX_PRCM_PARTITIONS ||
39 part == OMAP4430_INVALID_PRCM_PARTITION ||
40 !_prm_bases[part]);
41 return __raw_readl(OMAP2_L4_IO_ADDRESS(_prm_bases[part] + inst +
42 idx));
43}
44
45/* Write into a register in a PRM instance */
46void omap4_prminst_write_inst_reg(u32 val, u8 part, s16 inst, u16 idx)
47{
48 BUG_ON(part >= OMAP4_MAX_PRCM_PARTITIONS ||
49 part == OMAP4430_INVALID_PRCM_PARTITION ||
50 !_prm_bases[part]);
51 __raw_writel(val, OMAP2_L4_IO_ADDRESS(_prm_bases[part] + inst + idx));
52}
53
54/* Read-modify-write a register in PRM. Caller must lock */
55u32 omap4_prminst_rmw_inst_reg_bits(u32 mask, u32 bits, u8 part, s16 inst,
56 s16 idx)
57{
58 u32 v;
59
60 v = omap4_prminst_read_inst_reg(part, inst, idx);
61 v &= ~mask;
62 v |= bits;
63 omap4_prminst_write_inst_reg(v, part, inst, idx);
64
65 return v;
66}
diff --git a/arch/arm/mach-omap2/prminst44xx.h b/arch/arm/mach-omap2/prminst44xx.h
new file mode 100644
index 000000000000..02dd66ddda8b
--- /dev/null
+++ b/arch/arm/mach-omap2/prminst44xx.h
@@ -0,0 +1,25 @@
1/*
2 * OMAP4 Power/Reset Management (PRM) function prototypes
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 * Paul Walmsley
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef __ARCH_ASM_MACH_OMAP2_PRMINST44XX_H
12#define __ARCH_ASM_MACH_OMAP2_PRMINST44XX_H
13
14/*
15 * In an ideal world, we would not export these low-level functions,
16 * but this will probably take some time to fix properly
17 */
18extern u32 omap4_prminst_read_inst_reg(u8 part, s16 inst, u16 idx);
19extern void omap4_prminst_write_inst_reg(u32 val, u8 part, s16 inst, u16 idx);
20extern u32 omap4_prminst_rmw_inst_reg_bits(u32 mask, u32 bits, u8 part,
21 s16 inst, s16 idx);
22
23extern void omap4_prm_global_warm_sw_reset(void);
24
25#endif
diff --git a/arch/arm/plat-omap/include/plat/prcm.h b/arch/arm/plat-omap/include/plat/prcm.h
index d059a05bc457..078906d86b6c 100644
--- a/arch/arm/plat-omap/include/plat/prcm.h
+++ b/arch/arm/plat-omap/include/plat/prcm.h
@@ -18,6 +18,10 @@
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * XXX This file is deprecated. The PRCM is an OMAP2+-only subsystem,
23 * so this file doesn't belong in plat-omap/include/plat. Please
24 * do not add anything new to this file.
21 */ 25 */
22 26
23#ifndef __ASM_ARM_ARCH_OMAP_PRCM_H 27#ifndef __ASM_ARM_ARCH_OMAP_PRCM_H
@@ -31,9 +35,6 @@ int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, u8 idlest,
31#define START_PADCONF_SAVE 0x2 35#define START_PADCONF_SAVE 0x2
32#define PADCONF_SAVE_DONE 0x1 36#define PADCONF_SAVE_DONE 0x1
33 37
34u32 omap4_prm_read_bits_shift(void __iomem *reg, u32 mask);
35u32 omap4_prm_rmw_reg_bits(u32 mask, u32 bits, void __iomem *reg);
36
37#endif 38#endif
38 39
39 40