diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/sysdev/commproc.c | 28 | ||||
-rw-r--r-- | arch/powerpc/sysdev/cpm2_common.c | 25 |
2 files changed, 53 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) | |||
240 | #endif | 240 | #endif |
241 | } | 241 | } |
242 | 242 | ||
243 | static DEFINE_SPINLOCK(cmd_lock); | ||
244 | |||
245 | #define MAX_CR_CMD_LOOPS 10000 | ||
246 | |||
247 | int cpm_command(u32 command, u8 opcode) | ||
248 | { | ||
249 | int i, ret; | ||
250 | unsigned long flags; | ||
251 | |||
252 | if (command & 0xffffff0f) | ||
253 | return -EINVAL; | ||
254 | |||
255 | spin_lock_irqsave(&cmd_lock, flags); | ||
256 | |||
257 | ret = 0; | ||
258 | out_be16(&cpmp->cp_cpcr, command | CPM_CR_FLG | (opcode << 8)); | ||
259 | for (i = 0; i < MAX_CR_CMD_LOOPS; i++) | ||
260 | if ((in_be16(&cpmp->cp_cpcr) & CPM_CR_FLG) == 0) | ||
261 | goto out; | ||
262 | |||
263 | printk(KERN_ERR "%s(): Not able to issue CPM command\n", __FUNCTION__); | ||
264 | ret = -EIO; | ||
265 | out: | ||
266 | spin_unlock_irqrestore(&cmd_lock, flags); | ||
267 | return ret; | ||
268 | } | ||
269 | EXPORT_SYMBOL(cpm_command); | ||
270 | |||
243 | /* We used to do this earlier, but have to postpone as long as possible | 271 | /* We used to do this earlier, but have to postpone as long as possible |
244 | * to ensure the kernel VM is now running. | 272 | * to ensure the kernel VM is now running. |
245 | */ | 273 | */ |
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 | ||
86 | static DEFINE_SPINLOCK(cmd_lock); | ||
87 | |||
88 | #define MAX_CR_CMD_LOOPS 10000 | ||
89 | |||
90 | int 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; | ||
105 | out: | ||
106 | spin_unlock_irqrestore(&cmd_lock, flags); | ||
107 | return ret; | ||
108 | } | ||
109 | EXPORT_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 |