25 #include <linux/slab.h>
26 #include <linux/module.h>
31 #include <platforms/PPChameleonEVB.h>
33 #undef USE_READY_BUSY_PIN
34 #define USE_READY_BUSY_PIN
36 #define NAND_BIG_DELAY_US 25
37 #define NAND_SMALL_DELAY_US 10
40 #define SZ_4M 0x00400000
41 #define NAND_SMALL_SIZE 0x02000000
42 #define NAND_MTD_NAME "ppchameleon-nand"
43 #define NAND_EVB_MTD_NAME "ppchameleonevb-nand"
46 #define NAND_nCE_GPIO_PIN (0x80000000 >> 1)
47 #define NAND_CLE_GPIO_PIN (0x80000000 >> 2)
48 #define NAND_ALE_GPIO_PIN (0x80000000 >> 3)
49 #define NAND_RB_GPIO_PIN (0x80000000 >> 4)
51 #define NAND_EVB_nCE_GPIO_PIN (0x80000000 >> 14)
52 #define NAND_EVB_CLE_GPIO_PIN (0x80000000 >> 15)
53 #define NAND_EVB_ALE_GPIO_PIN (0x80000000 >> 16)
54 #define NAND_EVB_RB_GPIO_PIN (0x80000000 >> 31)
65 static unsigned long ppchameleon_fio_pbase = CFG_NAND0_PADDR;
66 static unsigned long ppchameleonevb_fio_pbase = CFG_NAND1_PADDR;
72 __setup(
"ppchameleon_fio_pbase=", ppchameleon_fio_pbase);
73 __setup(
"ppchameleonevb_fio_pbase=", ppchameleonevb_fio_pbase);
80 { .name =
"PPChameleon HI Nand Flash",
82 .size = 128 * 1024 * 1024
87 { .name =
"PPChameleon ME Nand Flash",
89 .size = 32 * 1024 * 1024
94 { .name =
"PPChameleonEVB Nand Flash",
96 .size = 32 * 1024 * 1024
100 #define NUM_PARTITIONS 1
105 static void ppchameleon_hwcontrol(
struct mtd_info *mtdinfo,
int cmd,
111 #error Missing headerfiles. No way to fix this. -tglx
114 MACRO_NAND_CTL_SETCLE((
unsigned long)CFG_NAND0_PADDR);
117 MACRO_NAND_CTL_CLRCLE((
unsigned long)CFG_NAND0_PADDR);
120 MACRO_NAND_CTL_SETALE((
unsigned long)CFG_NAND0_PADDR);
123 MACRO_NAND_CTL_CLRALE((
unsigned long)CFG_NAND0_PADDR);
126 MACRO_NAND_ENABLE_CE((
unsigned long)CFG_NAND0_PADDR);
129 MACRO_NAND_DISABLE_CE((
unsigned long)CFG_NAND0_PADDR);
137 static void ppchameleonevb_hwcontrol(
struct mtd_info *mtdinfo,
int cmd,
143 #error Missing headerfiles. No way to fix this. -tglx
146 MACRO_NAND_CTL_SETCLE((
unsigned long)CFG_NAND1_PADDR);
149 MACRO_NAND_CTL_CLRCLE((
unsigned long)CFG_NAND1_PADDR);
152 MACRO_NAND_CTL_SETALE((
unsigned long)CFG_NAND1_PADDR);
155 MACRO_NAND_CTL_CLRALE((
unsigned long)CFG_NAND1_PADDR);
158 MACRO_NAND_ENABLE_CE((
unsigned long)CFG_NAND1_PADDR);
161 MACRO_NAND_DISABLE_CE((
unsigned long)CFG_NAND1_PADDR);
169 #ifdef USE_READY_BUSY_PIN
173 static int ppchameleon_device_ready(
struct mtd_info *minfo)
180 static int ppchameleonevb_device_ready(
struct mtd_info *minfo)
191 static int __init ppchameleonevb_init(
void)
194 void __iomem *ppchameleon_fio_base;
195 void __iomem *ppchameleonevb_fio_base;
202 if (!ppchameleon_mtd) {
203 printk(
"Unable to allocate PPChameleon NAND MTD device structure.\n");
208 ppchameleon_fio_base =
ioremap(ppchameleon_fio_pbase,
SZ_4M);
209 if (!ppchameleon_fio_base) {
210 printk(
"ioremap PPChameleon NAND flash failed\n");
211 kfree(ppchameleon_mtd);
216 this = (
struct nand_chip *)(&ppchameleon_mtd[1]);
223 ppchameleon_mtd->
priv =
this;
239 out_be32((
volatile unsigned *)GPIO0_TCR,
241 #ifdef USE_READY_BUSY_PIN
254 this->
cmd_ctrl = ppchameleon_hwcontrol;
255 #ifdef USE_READY_BUSY_PIN
256 this->
dev_ready = ppchameleon_device_ready;
264 iounmap((
void *)ppchameleon_fio_base);
265 ppchameleon_fio_base =
NULL;
266 kfree(ppchameleon_mtd);
269 #ifndef USE_READY_BUSY_PIN
275 ppchameleon_mtd->
name =
"ppchameleon-nand";
280 partition_info_me : partition_info_hi,
289 if (!ppchameleonevb_mtd) {
290 printk(
"Unable to allocate PPChameleonEVB NAND MTD device structure.\n");
291 if (ppchameleon_fio_base)
297 ppchameleonevb_fio_base =
ioremap(ppchameleonevb_fio_pbase,
SZ_4M);
298 if (!ppchameleonevb_fio_base) {
299 printk(
"ioremap PPChameleonEVB NAND flash failed\n");
300 kfree(ppchameleonevb_mtd);
301 if (ppchameleon_fio_base)
307 this = (
struct nand_chip *)(&ppchameleonevb_mtd[1]);
314 ppchameleonevb_mtd->
priv =
this;
326 out_be32((
volatile unsigned *)GPIO0_OSRL,
in_be32((
volatile unsigned *)GPIO0_OSRL) & 0x3FFFFFFF);
329 out_be32((
volatile unsigned *)GPIO0_TSRL,
in_be32((
volatile unsigned *)GPIO0_TSRL) & 0x3FFFFFFF);
333 #ifdef USE_READY_BUSY_PIN
335 out_be32((
volatile unsigned *)GPIO0_TSRL,
in_be32((
volatile unsigned *)GPIO0_TSRL) & 0xFFFFFFFC);
339 out_be32((
volatile unsigned *)GPIO0_ISR1L,
340 (
in_be32((
volatile unsigned *)GPIO0_ISR1L) & 0xFFFFFFFC) | 0x00000001);
344 this->
IO_ADDR_R = ppchameleonevb_fio_base;
345 this->
IO_ADDR_W = ppchameleonevb_fio_base;
346 this->
cmd_ctrl = ppchameleonevb_hwcontrol;
347 #ifdef USE_READY_BUSY_PIN
348 this->
dev_ready = ppchameleonevb_device_ready;
357 iounmap((
void *)ppchameleonevb_fio_base);
358 kfree(ppchameleonevb_mtd);
359 if (ppchameleon_fio_base)
369 partition_info_me : partition_info_hi,
381 static void __exit ppchameleonevb_cleanup(
void)
390 this = (
struct nand_chip *) &ppchameleon_mtd[1];
392 this = (
struct nand_chip *) &ppchameleonevb_mtd[1];
396 kfree (ppchameleon_mtd);
397 kfree (ppchameleonevb_mtd);