aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/sysdev')
-rw-r--r--arch/powerpc/sysdev/fsl_lbc.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/arch/powerpc/sysdev/fsl_lbc.c b/arch/powerpc/sysdev/fsl_lbc.c
index 422c8faef593..0494ee55920f 100644
--- a/arch/powerpc/sysdev/fsl_lbc.c
+++ b/arch/powerpc/sysdev/fsl_lbc.c
@@ -11,14 +11,19 @@
11 * (at your option) any later version. 11 * (at your option) any later version.
12 */ 12 */
13 13
14#include <linux/init.h>
15#include <linux/module.h>
14#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/compiler.h>
18#include <linux/spinlock.h>
19#include <linux/types.h>
20#include <linux/io.h>
15#include <linux/of.h> 21#include <linux/of.h>
22#include <asm/prom.h>
16#include <asm/fsl_lbc.h> 23#include <asm/fsl_lbc.h>
17 24
18spinlock_t fsl_lbc_lock = __SPIN_LOCK_UNLOCKED(fsl_lbc_lock); 25static spinlock_t fsl_lbc_lock = __SPIN_LOCK_UNLOCKED(fsl_lbc_lock);
19 26static struct fsl_lbc_regs __iomem *fsl_lbc_regs;
20struct fsl_lbc_regs __iomem *fsl_lbc_regs;
21EXPORT_SYMBOL(fsl_lbc_regs);
22 27
23static char __initdata *compat_lbc[] = { 28static char __initdata *compat_lbc[] = {
24 "fsl,pq2-localbus", 29 "fsl,pq2-localbus",
@@ -127,3 +132,43 @@ int fsl_upm_find(phys_addr_t addr_base, struct fsl_upm *upm)
127 return 0; 132 return 0;
128} 133}
129EXPORT_SYMBOL(fsl_upm_find); 134EXPORT_SYMBOL(fsl_upm_find);
135
136/**
137 * fsl_upm_run_pattern - actually run an UPM pattern
138 * @upm: pointer to the fsl_upm structure obtained via fsl_upm_find
139 * @io_base: remapped pointer to where memory access should happen
140 * @mar: MAR register content during pattern execution
141 *
142 * This function triggers dummy write to the memory specified by the io_base,
143 * thus UPM pattern actually executed. Note that mar usage depends on the
144 * pre-programmed AMX bits in the UPM RAM.
145 */
146int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base, u32 mar)
147{
148 int ret = 0;
149 unsigned long flags;
150
151 spin_lock_irqsave(&fsl_lbc_lock, flags);
152
153 out_be32(&fsl_lbc_regs->mar, mar << (32 - upm->width));
154
155 switch (upm->width) {
156 case 8:
157 out_8(io_base, 0x0);
158 break;
159 case 16:
160 out_be16(io_base, 0x0);
161 break;
162 case 32:
163 out_be32(io_base, 0x0);
164 break;
165 default:
166 ret = -EINVAL;
167 break;
168 }
169
170 spin_unlock_irqrestore(&fsl_lbc_lock, flags);
171
172 return ret;
173}
174EXPORT_SYMBOL(fsl_upm_run_pattern);