aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/include/asm/fsl_lbc.h1
-rw-r--r--arch/powerpc/sysdev/fsl_lbc.c23
2 files changed, 23 insertions, 1 deletions
diff --git a/arch/powerpc/include/asm/fsl_lbc.h b/arch/powerpc/include/asm/fsl_lbc.h
index 06a11124dde1..5c1bf3466749 100644
--- a/arch/powerpc/include/asm/fsl_lbc.h
+++ b/arch/powerpc/include/asm/fsl_lbc.h
@@ -248,6 +248,7 @@ struct fsl_upm {
248 int width; 248 int width;
249}; 249};
250 250
251extern u32 fsl_lbc_addr(phys_addr_t addr_base);
251extern int fsl_lbc_find(phys_addr_t addr_base); 252extern int fsl_lbc_find(phys_addr_t addr_base);
252extern int fsl_upm_find(phys_addr_t addr_base, struct fsl_upm *upm); 253extern int fsl_upm_find(phys_addr_t addr_base, struct fsl_upm *upm);
253 254
diff --git a/arch/powerpc/sysdev/fsl_lbc.c b/arch/powerpc/sysdev/fsl_lbc.c
index 91c9c53b1845..4fcb5a4e60dd 100644
--- a/arch/powerpc/sysdev/fsl_lbc.c
+++ b/arch/powerpc/sysdev/fsl_lbc.c
@@ -34,6 +34,27 @@ struct fsl_lbc_ctrl *fsl_lbc_ctrl_dev;
34EXPORT_SYMBOL(fsl_lbc_ctrl_dev); 34EXPORT_SYMBOL(fsl_lbc_ctrl_dev);
35 35
36/** 36/**
37 * fsl_lbc_addr - convert the base address
38 * @addr_base: base address of the memory bank
39 *
40 * This function converts a base address of lbc into the right format for the
41 * BR register. If the SOC has eLBC then it returns 32bit physical address
42 * else it convers a 34bit local bus physical address to correct format of
43 * 32bit address for BR register (Example: MPC8641).
44 */
45u32 fsl_lbc_addr(phys_addr_t addr_base)
46{
47 struct device_node *np = fsl_lbc_ctrl_dev->dev->of_node;
48 u32 addr = addr_base & 0xffff8000;
49
50 if (of_device_is_compatible(np, "fsl,elbc"))
51 return addr;
52
53 return addr | ((addr_base & 0x300000000ull) >> 19);
54}
55EXPORT_SYMBOL(fsl_lbc_addr);
56
57/**
37 * fsl_lbc_find - find Localbus bank 58 * fsl_lbc_find - find Localbus bank
38 * @addr_base: base address of the memory bank 59 * @addr_base: base address of the memory bank
39 * 60 *
@@ -55,7 +76,7 @@ int fsl_lbc_find(phys_addr_t addr_base)
55 __be32 br = in_be32(&lbc->bank[i].br); 76 __be32 br = in_be32(&lbc->bank[i].br);
56 __be32 or = in_be32(&lbc->bank[i].or); 77 __be32 or = in_be32(&lbc->bank[i].or);
57 78
58 if (br & BR_V && (br & or & BR_BA) == addr_base) 79 if (br & BR_V && (br & or & BR_BA) == fsl_lbc_addr(addr_base))
59 return i; 80 return i;
60 } 81 }
61 82