aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev/cpm2_common.c
diff options
context:
space:
mode:
authorJochen Friedrich <jochen@scram.de>2007-11-26 12:03:40 -0500
committerKumar Gala <galak@kernel.crashing.org>2007-12-13 23:47:16 -0500
commit362f9b6fa8c9670cc5496390845021c2865d049b (patch)
treeea6a97b113aa8382aeddbcfa4faf2524bd2d96dc /arch/powerpc/sysdev/cpm2_common.c
parent721c0c8af1a27941a34af5046aae4a8369c8404c (diff)
[POWERPC] Move CPM command handling into the cpm drivers
This patch moves the CPM command handling into commproc.c for CPM1 and cpm2_common.c. This is yet another preparation to get rid of drivers accessing the CPM via the global cpmp. Signed-off-by: Jochen Friedrich <jochen@scram.de> Acked-by: Scott Wood <scottwood@freescale.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Vitaly Bordug <vitb@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/sysdev/cpm2_common.c')
-rw-r--r--arch/powerpc/sysdev/cpm2_common.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/arch/powerpc/sysdev/cpm2_common.c b/arch/powerpc/sysdev/cpm2_common.c
index 859362fecb7c..0a7054579d98 100644
--- a/arch/powerpc/sysdev/cpm2_common.c
+++ b/arch/powerpc/sysdev/cpm2_common.c
@@ -83,6 +83,31 @@ cpm2_reset(void)
83 cpmp = &cpm2_immr->im_cpm; 83 cpmp = &cpm2_immr->im_cpm;
84} 84}
85 85
86static DEFINE_SPINLOCK(cmd_lock);
87
88#define MAX_CR_CMD_LOOPS 10000
89
90int cpm_command(u32 command, u8 opcode)
91{
92 int i, ret;
93 unsigned long flags;
94
95 spin_lock_irqsave(&cmd_lock, flags);
96
97 ret = 0;
98 out_be32(&cpmp->cp_cpcr, command | opcode | CPM_CR_FLG);
99 for (i = 0; i < MAX_CR_CMD_LOOPS; i++)
100 if ((in_be32(&cpmp->cp_cpcr) & CPM_CR_FLG) == 0)
101 goto out;
102
103 printk(KERN_ERR "%s(): Not able to issue CPM command\n", __FUNCTION__);
104 ret = -EIO;
105out:
106 spin_unlock_irqrestore(&cmd_lock, flags);
107 return ret;
108}
109EXPORT_SYMBOL(cpm_command);
110
86/* Set a baud rate generator. This needs lots of work. There are 111/* Set a baud rate generator. This needs lots of work. There are
87 * eight BRGs, which can be connected to the CPM channels or output 112 * eight BRGs, which can be connected to the CPM channels or output
88 * as clocks. The BRGs are in two different block of internal 113 * as clocks. The BRGs are in two different block of internal