Commit 0b824d2b authored by Lan Chunhe-B25806's avatar Lan Chunhe-B25806 Committed by David Woodhouse

P4080/mtd: Fix the freescale lbc issue with 36bit mode

When system uses 36bit physical address, res.start is 36bit
physical address. But the function of in_be32 returns 32bit
physical address. Then both of them compared each other is
wrong. So by converting the address of res.start into
the right format fixes this issue.
Signed-off-by: default avatarLan Chunhe-B25806 <b25806@freescale.com>
Signed-off-by: default avatarRoy Zang <tie-fei.zang@freescale.com>
Reviewed-by: default avatarAnton Vorontsov <cbouatmailru@gmail.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 3ab8f2a2
...@@ -248,6 +248,7 @@ struct fsl_upm { ...@@ -248,6 +248,7 @@ struct fsl_upm {
int width; int width;
}; };
extern u32 fsl_lbc_addr(phys_addr_t addr_base);
extern int fsl_lbc_find(phys_addr_t addr_base); extern int fsl_lbc_find(phys_addr_t addr_base);
extern int fsl_upm_find(phys_addr_t addr_base, struct fsl_upm *upm); extern int fsl_upm_find(phys_addr_t addr_base, struct fsl_upm *upm);
......
...@@ -33,6 +33,27 @@ static spinlock_t fsl_lbc_lock = __SPIN_LOCK_UNLOCKED(fsl_lbc_lock); ...@@ -33,6 +33,27 @@ static spinlock_t fsl_lbc_lock = __SPIN_LOCK_UNLOCKED(fsl_lbc_lock);
struct fsl_lbc_ctrl *fsl_lbc_ctrl_dev; struct fsl_lbc_ctrl *fsl_lbc_ctrl_dev;
EXPORT_SYMBOL(fsl_lbc_ctrl_dev); EXPORT_SYMBOL(fsl_lbc_ctrl_dev);
/**
* fsl_lbc_addr - convert the base address
* @addr_base: base address of the memory bank
*
* This function converts a base address of lbc into the right format for the
* BR register. If the SOC has eLBC then it returns 32bit physical address
* else it convers a 34bit local bus physical address to correct format of
* 32bit address for BR register (Example: MPC8641).
*/
u32 fsl_lbc_addr(phys_addr_t addr_base)
{
struct device_node *np = fsl_lbc_ctrl_dev->dev->of_node;
u32 addr = addr_base & 0xffff8000;
if (of_device_is_compatible(np, "fsl,elbc"))
return addr;
return addr | ((addr_base & 0x300000000ull) >> 19);
}
EXPORT_SYMBOL(fsl_lbc_addr);
/** /**
* fsl_lbc_find - find Localbus bank * fsl_lbc_find - find Localbus bank
* @addr_base: base address of the memory bank * @addr_base: base address of the memory bank
...@@ -55,7 +76,7 @@ int fsl_lbc_find(phys_addr_t addr_base) ...@@ -55,7 +76,7 @@ int fsl_lbc_find(phys_addr_t addr_base)
__be32 br = in_be32(&lbc->bank[i].br); __be32 br = in_be32(&lbc->bank[i].br);
__be32 or = in_be32(&lbc->bank[i].or); __be32 or = in_be32(&lbc->bank[i].or);
if (br & BR_V && (br & or & BR_BA) == addr_base) if (br & BR_V && (br & or & BR_BA) == fsl_lbc_addr(addr_base))
return i; return i;
} }
......
...@@ -868,7 +868,7 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev) ...@@ -868,7 +868,7 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)
(in_be32(&lbc->bank[bank].br) & BR_MSEL) == BR_MS_FCM && (in_be32(&lbc->bank[bank].br) & BR_MSEL) == BR_MS_FCM &&
(in_be32(&lbc->bank[bank].br) & (in_be32(&lbc->bank[bank].br) &
in_be32(&lbc->bank[bank].or) & BR_BA) in_be32(&lbc->bank[bank].or) & BR_BA)
== res.start) == fsl_lbc_addr(res.start))
break; break;
if (bank >= MAX_BANKS) { if (bank >= MAX_BANKS) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment