1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25
26#if defined(CONFIG_CMD_NAND)
27#include <asm/io.h>
28#include <nand.h>
29
30
31
32
33static void esd405ep_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
34{
35 struct nand_chip *this = mtd->priv;
36 if (ctrl & NAND_CTRL_CHANGE) {
37 if ( ctrl & NAND_CLE )
38 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_NAND_CLE);
39 else
40 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_NAND_CLE);
41 if ( ctrl & NAND_ALE )
42 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_NAND_ALE);
43 else
44 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_NAND_ALE);
45 if ( ctrl & NAND_NCE )
46 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_NAND_CE);
47 else
48 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_NAND_CE);
49 }
50
51 if (cmd != NAND_CMD_NONE)
52 writeb(cmd, this->IO_ADDR_W);
53}
54
55
56
57
58
59static int esd405ep_nand_device_ready(struct mtd_info *mtdinfo)
60{
61 if (in_be32((void *)GPIO0_IR) & CONFIG_SYS_NAND_RDY)
62 return 1;
63 return 0;
64}
65
66
67int board_nand_init(struct nand_chip *nand)
68{
69
70
71
72 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~(CONFIG_SYS_NAND_CLE | CONFIG_SYS_NAND_ALE));
73 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_NAND_CE);
74
75
76
77
78 nand->cmd_ctrl = esd405ep_nand_hwcontrol;
79 nand->dev_ready = esd405ep_nand_device_ready;
80 nand->ecc.mode = NAND_ECC_SOFT;
81 nand->chip_delay = NAND_BIG_DELAY_US;
82 nand->options = NAND_SAMSUNG_LP_OPTIONS;
83 return 0;
84}
85#endif
86