diff options
author | Jochen Friedrich <jochen@scram.de> | 2007-11-26 18:03:40 +0100 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2007-12-14 05:47:16 +0100 |
commit | 362f9b6fa8c9670cc5496390845021c2865d049b (patch) | |
tree | ea6a97b113aa8382aeddbcfa4faf2524bd2d96dc /arch/powerpc/sysdev/commproc.c | |
parent | [POWERPC] Add support for PORTA and PORTB odr registers (diff) | |
download | linux-362f9b6fa8c9670cc5496390845021c2865d049b.tar.xz linux-362f9b6fa8c9670cc5496390845021c2865d049b.zip |
[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/commproc.c')
-rw-r--r-- | arch/powerpc/sysdev/commproc.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/arch/powerpc/sysdev/commproc.c b/arch/powerpc/sysdev/commproc.c index 74d937249348..621bc6c1d408 100644 --- a/arch/powerpc/sysdev/commproc.c +++ b/arch/powerpc/sysdev/commproc.c @@ -240,6 +240,34 @@ void __init cpm_reset(void) #endif } +static DEFINE_SPINLOCK(cmd_lock); + +#define MAX_CR_CMD_LOOPS 10000 + +int cpm_command(u32 command, u8 opcode) +{ + int i, ret; + unsigned long flags; + + if (command & 0xffffff0f) + return -EINVAL; + + spin_lock_irqsave(&cmd_lock, flags); + + ret = 0; + out_be16(&cpmp->cp_cpcr, command | CPM_CR_FLG | (opcode << 8)); + for (i = 0; i < MAX_CR_CMD_LOOPS; i++) + if ((in_be16(&cpmp->cp_cpcr) & CPM_CR_FLG) == 0) + goto out; + + printk(KERN_ERR "%s(): Not able to issue CPM command\n", __FUNCTION__); + ret = -EIO; +out: + spin_unlock_irqrestore(&cmd_lock, flags); + return ret; +} +EXPORT_SYMBOL(cpm_command); + /* We used to do this earlier, but have to postpone as long as possible * to ensure the kernel VM is now running. */ |