2009-11-24 11:21:35 +00:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2012-10-08 18:52:35 +00:00
|
|
|
#include <mach/generic.h>
|
2012-10-11 07:09:29 +00:00
|
|
|
#include <mach/imx21-regs.h>
|
|
|
|
#include <mach/imx25-regs.h>
|
|
|
|
#include <mach/imx27-regs.h>
|
|
|
|
#include <mach/imx35-regs.h>
|
2011-09-22 17:02:57 +00:00
|
|
|
#include <io.h>
|
2009-11-24 11:21:35 +00:00
|
|
|
|
|
|
|
#define RCSR_NFC_FMS (1 << 8)
|
|
|
|
#define RCSR_NFC_4K (1 << 9)
|
|
|
|
#define RCSR_NFC_16BIT_SEL (1 << 14)
|
|
|
|
|
2012-10-08 18:52:35 +00:00
|
|
|
static __maybe_unused void imx25_35_nand_set_layout(void __iomem *reg_rcsr,
|
|
|
|
int writesize, int datawidth)
|
2009-11-24 11:21:35 +00:00
|
|
|
{
|
|
|
|
unsigned int rcsr;
|
|
|
|
|
2012-10-08 18:52:35 +00:00
|
|
|
rcsr = readl(reg_rcsr);
|
2009-11-24 11:21:35 +00:00
|
|
|
|
|
|
|
switch (writesize) {
|
|
|
|
case 512:
|
|
|
|
rcsr &= ~(RCSR_NFC_FMS | RCSR_NFC_4K);
|
|
|
|
break;
|
|
|
|
case 2048:
|
|
|
|
rcsr |= RCSR_NFC_FMS;
|
|
|
|
break;
|
|
|
|
case 4096:
|
|
|
|
rcsr |= RCSR_NFC_FMS | RCSR_NFC_4K;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (datawidth) {
|
|
|
|
case 8:
|
|
|
|
rcsr &= ~RCSR_NFC_16BIT_SEL;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
rcsr |= RCSR_NFC_16BIT_SEL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-10-08 18:52:35 +00:00
|
|
|
writel(rcsr, reg_rcsr);
|
2009-11-24 11:21:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define FMCR_NF_FMS (1 << 5)
|
|
|
|
#define FMCR_NF_16BIT_SEL (1 << 4)
|
|
|
|
|
2012-10-08 18:52:35 +00:00
|
|
|
static __maybe_unused void imx21_27_nand_set_layout(void __iomem *reg_fmcr,
|
|
|
|
int writesize, int datawidth)
|
2009-11-24 11:21:35 +00:00
|
|
|
{
|
|
|
|
unsigned int fmcr;
|
|
|
|
|
2012-10-08 18:52:35 +00:00
|
|
|
fmcr = readl(reg_fmcr);
|
2009-11-24 11:21:35 +00:00
|
|
|
|
|
|
|
switch (writesize) {
|
|
|
|
case 512:
|
2009-12-09 16:00:47 +00:00
|
|
|
fmcr &= ~FMCR_NF_FMS;
|
2009-11-24 11:21:35 +00:00
|
|
|
break;
|
|
|
|
case 2048:
|
|
|
|
fmcr |= FMCR_NF_FMS;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (datawidth) {
|
|
|
|
case 8:
|
|
|
|
fmcr &= ~FMCR_NF_16BIT_SEL;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
fmcr |= FMCR_NF_16BIT_SEL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-10-08 18:52:35 +00:00
|
|
|
writel(fmcr, reg_fmcr);
|
2010-11-10 11:35:18 +00:00
|
|
|
}
|
|
|
|
|
2009-11-24 11:21:35 +00:00
|
|
|
void imx_nand_set_layout(int writesize, int datawidth)
|
|
|
|
{
|
2012-10-08 18:52:35 +00:00
|
|
|
#ifdef CONFIG_ARCH_IMX21
|
|
|
|
if (cpu_is_mx21())
|
|
|
|
imx21_27_nand_set_layout((void *)(MX21_SYSCTRL_BASE_ADDR +
|
|
|
|
0x14), writesize, datawidth);
|
2009-11-24 11:21:35 +00:00
|
|
|
#endif
|
2012-10-08 18:52:35 +00:00
|
|
|
#ifdef CONFIG_ARCH_IMX27
|
|
|
|
if (cpu_is_mx27())
|
|
|
|
imx21_27_nand_set_layout((void *)(MX27_SYSCTRL_BASE_ADDR +
|
|
|
|
0x14), writesize, datawidth);
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_ARCH_IMX25
|
|
|
|
if (cpu_is_mx25())
|
|
|
|
imx25_35_nand_set_layout((void *)MX25_CCM_BASE_ADDR +
|
2012-10-08 18:59:13 +00:00
|
|
|
MX25_CCM_RCSR, writesize, datawidth);
|
2012-10-08 18:52:35 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_ARCH_IMX35
|
|
|
|
if (cpu_is_mx35())
|
|
|
|
imx25_35_nand_set_layout((void *)MX35_CCM_BASE_ADDR +
|
2012-10-08 19:12:50 +00:00
|
|
|
MX35_CCM_RCSR, writesize, datawidth);
|
2012-10-08 18:52:35 +00:00
|
|
|
#endif
|
|
|
|
}
|