diff options
Diffstat (limited to 'drivers/mtd/nand/toto.c')
-rw-r--r-- | drivers/mtd/nand/toto.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/drivers/mtd/nand/toto.c b/drivers/mtd/nand/toto.c index 50aa6a46911f..a9cf0190c27a 100644 --- a/drivers/mtd/nand/toto.c +++ b/drivers/mtd/nand/toto.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include <asm/arch-omap1510/hardware.h> | 32 | #include <asm/arch-omap1510/hardware.h> |
33 | #include <asm/arch/gpio.h> | 33 | #include <asm/arch/gpio.h> |
34 | 34 | ||
35 | #define CONFIG_NAND_WORKAROUND 1 | ||
36 | |||
35 | /* | 37 | /* |
36 | * MTD structure for TOTO board | 38 | * MTD structure for TOTO board |
37 | */ | 39 | */ |
@@ -39,25 +41,6 @@ static struct mtd_info *toto_mtd = NULL; | |||
39 | 41 | ||
40 | static unsigned long toto_io_base = OMAP_FLASH_1_BASE; | 42 | static unsigned long toto_io_base = OMAP_FLASH_1_BASE; |
41 | 43 | ||
42 | #define CONFIG_NAND_WORKAROUND 1 | ||
43 | |||
44 | #define NAND_NCE 0x4000 | ||
45 | #define NAND_CLE 0x1000 | ||
46 | #define NAND_ALE 0x0002 | ||
47 | #define NAND_MASK (NAND_CLE | NAND_ALE | NAND_NCE) | ||
48 | |||
49 | #define T_NAND_CTL_CLRALE(iob) gpiosetout(NAND_ALE, 0) | ||
50 | #define T_NAND_CTL_SETALE(iob) gpiosetout(NAND_ALE, NAND_ALE) | ||
51 | #ifdef CONFIG_NAND_WORKAROUND /* "some" dev boards busted, blue wired to rts2 :( */ | ||
52 | #define T_NAND_CTL_CLRCLE(iob) gpiosetout(NAND_CLE, 0); rts2setout(2, 2) | ||
53 | #define T_NAND_CTL_SETCLE(iob) gpiosetout(NAND_CLE, NAND_CLE); rts2setout(2, 0) | ||
54 | #else | ||
55 | #define T_NAND_CTL_CLRCLE(iob) gpiosetout(NAND_CLE, 0) | ||
56 | #define T_NAND_CTL_SETCLE(iob) gpiosetout(NAND_CLE, NAND_CLE) | ||
57 | #endif | ||
58 | #define T_NAND_CTL_SETNCE(iob) gpiosetout(NAND_NCE, 0) | ||
59 | #define T_NAND_CTL_CLRNCE(iob) gpiosetout(NAND_NCE, NAND_NCE) | ||
60 | |||
61 | /* | 44 | /* |
62 | * Define partitions for flash devices | 45 | * Define partitions for flash devices |
63 | */ | 46 | */ |
@@ -91,25 +74,43 @@ static struct mtd_partition partition_info32M[] = { | |||
91 | 74 | ||
92 | #define NUM_PARTITIONS32M 3 | 75 | #define NUM_PARTITIONS32M 3 |
93 | #define NUM_PARTITIONS64M 4 | 76 | #define NUM_PARTITIONS64M 4 |
77 | |||
94 | /* | 78 | /* |
95 | * hardware specific access to control-lines | 79 | * hardware specific access to control-lines |
96 | */ | 80 | * |
97 | 81 | * ctrl: | |
98 | static void toto_hwcontrol(struct mtd_info *mtd, int cmd) | 82 | * NAND_NCE: bit 0 -> bit 14 (0x4000) |
83 | * NAND_CLE: bit 1 -> bit 12 (0x1000) | ||
84 | * NAND_ALE: bit 2 -> bit 1 (0x0002) | ||
85 | */ | ||
86 | static void toto_hwcontrol(struct mtd_info *mtd, int cmd, | ||
87 | unsigned int ctrl) | ||
99 | { | 88 | { |
89 | struct nand_chip *chip = mtd->priv; | ||
90 | |||
91 | if (ctrl & NAND_CTRL_CHANGE) { | ||
92 | unsigned long bits; | ||
100 | 93 | ||
101 | udelay(1); /* hopefully enough time for tc make proceding write to clear */ | 94 | /* hopefully enough time for tc make proceding write to clear */ |
102 | switch (cmd) { | 95 | udelay(1); |
103 | case NAND_CTL_SETCLE: T_NAND_CTL_SETCLE(cmd); break; | ||
104 | case NAND_CTL_CLRCLE: T_NAND_CTL_CLRCLE(cmd); break; | ||
105 | 96 | ||
106 | case NAND_CTL_SETALE: T_NAND_CTL_SETALE(cmd); break; | 97 | bits = (~ctrl & NAND_NCE) << 14; |
107 | case NAND_CTL_CLRALE: T_NAND_CTL_CLRALE(cmd); break; | 98 | bits |= (ctrl & NAND_CLE) << 12; |
99 | bits |= (ctrl & NAND_ALE) >> 1; | ||
108 | 100 | ||
109 | case NAND_CTL_SETNCE: T_NAND_CTL_SETNCE(cmd); break; | 101 | #warning Wild guess as gpiosetout() is nowhere defined in the kernel source - tglx |
110 | case NAND_CTL_CLRNCE: T_NAND_CTL_CLRNCE(cmd); break; | 102 | gpiosetout(0x5002, bits); |
103 | |||
104 | #ifdef CONFIG_NAND_WORKAROUND | ||
105 | /* "some" dev boards busted, blue wired to rts2 :( */ | ||
106 | rts2setout(2, (ctrl & NAND_CLE) << 1); | ||
107 | #endif | ||
108 | /* allow time to ensure gpio state to over take memory write */ | ||
109 | udelay(1); | ||
111 | } | 110 | } |
112 | udelay(1); /* allow time to ensure gpio state to over take memory write */ | 111 | |
112 | if (cmd != NAND_CMD_NONE) | ||
113 | writeb(cmd, chip->IO_ADDR_W); | ||
113 | } | 114 | } |
114 | 115 | ||
115 | /* | 116 | /* |
@@ -142,7 +143,7 @@ static int __init toto_init(void) | |||
142 | /* Set address of NAND IO lines */ | 143 | /* Set address of NAND IO lines */ |
143 | this->IO_ADDR_R = toto_io_base; | 144 | this->IO_ADDR_R = toto_io_base; |
144 | this->IO_ADDR_W = toto_io_base; | 145 | this->IO_ADDR_W = toto_io_base; |
145 | this->hwcontrol = toto_hwcontrol; | 146 | this->cmd_ctrl = toto_hwcontrol; |
146 | this->dev_ready = NULL; | 147 | this->dev_ready = NULL; |
147 | /* 25 us command delay time */ | 148 | /* 25 us command delay time */ |
148 | this->chip_delay = 30; | 149 | this->chip_delay = 30; |