diff options
Diffstat (limited to 'drivers/mtd/nand/toto.c')
-rw-r--r-- | drivers/mtd/nand/toto.c | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/drivers/mtd/nand/toto.c b/drivers/mtd/nand/toto.c index 7609c43cb3ec..e3a90e60e249 100644 --- a/drivers/mtd/nand/toto.c +++ b/drivers/mtd/nand/toto.c | |||
@@ -48,7 +48,7 @@ static unsigned long toto_io_base = OMAP_FLASH_1_BASE; | |||
48 | 48 | ||
49 | #define T_NAND_CTL_CLRALE(iob) gpiosetout(NAND_ALE, 0) | 49 | #define T_NAND_CTL_CLRALE(iob) gpiosetout(NAND_ALE, 0) |
50 | #define T_NAND_CTL_SETALE(iob) gpiosetout(NAND_ALE, NAND_ALE) | 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 :( */ | 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) | 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) | 53 | #define T_NAND_CTL_SETCLE(iob) gpiosetout(NAND_CLE, NAND_CLE); rts2setout(2, 0) |
54 | #else | 54 | #else |
@@ -98,9 +98,8 @@ static struct mtd_partition partition_info32M[] = { | |||
98 | static void toto_hwcontrol(struct mtd_info *mtd, int cmd) | 98 | static void toto_hwcontrol(struct mtd_info *mtd, int cmd) |
99 | { | 99 | { |
100 | 100 | ||
101 | udelay(1); /* hopefully enough time for tc make proceding write to clear */ | 101 | udelay(1); /* hopefully enough time for tc make proceding write to clear */ |
102 | switch(cmd){ | 102 | switch (cmd) { |
103 | |||
104 | case NAND_CTL_SETCLE: T_NAND_CTL_SETCLE(cmd); break; | 103 | case NAND_CTL_SETCLE: T_NAND_CTL_SETCLE(cmd); break; |
105 | case NAND_CTL_CLRCLE: T_NAND_CTL_CLRCLE(cmd); break; | 104 | case NAND_CTL_CLRCLE: T_NAND_CTL_CLRCLE(cmd); break; |
106 | 105 | ||
@@ -110,32 +109,31 @@ static void toto_hwcontrol(struct mtd_info *mtd, int cmd) | |||
110 | case NAND_CTL_SETNCE: T_NAND_CTL_SETNCE(cmd); break; | 109 | case NAND_CTL_SETNCE: T_NAND_CTL_SETNCE(cmd); break; |
111 | case NAND_CTL_CLRNCE: T_NAND_CTL_CLRNCE(cmd); break; | 110 | case NAND_CTL_CLRNCE: T_NAND_CTL_CLRNCE(cmd); break; |
112 | } | 111 | } |
113 | udelay(1); /* allow time to ensure gpio state to over take memory write */ | 112 | udelay(1); /* allow time to ensure gpio state to over take memory write */ |
114 | } | 113 | } |
115 | 114 | ||
116 | /* | 115 | /* |
117 | * Main initialization routine | 116 | * Main initialization routine |
118 | */ | 117 | */ |
119 | int __init toto_init (void) | 118 | int __init toto_init(void) |
120 | { | 119 | { |
121 | struct nand_chip *this; | 120 | struct nand_chip *this; |
122 | int err = 0; | 121 | int err = 0; |
123 | 122 | ||
124 | /* Allocate memory for MTD device structure and private data */ | 123 | /* Allocate memory for MTD device structure and private data */ |
125 | toto_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip), | 124 | toto_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
126 | GFP_KERNEL); | ||
127 | if (!toto_mtd) { | 125 | if (!toto_mtd) { |
128 | printk (KERN_WARNING "Unable to allocate toto NAND MTD device structure.\n"); | 126 | printk(KERN_WARNING "Unable to allocate toto NAND MTD device structure.\n"); |
129 | err = -ENOMEM; | 127 | err = -ENOMEM; |
130 | goto out; | 128 | goto out; |
131 | } | 129 | } |
132 | 130 | ||
133 | /* Get pointer to private data */ | 131 | /* Get pointer to private data */ |
134 | this = (struct nand_chip *) (&toto_mtd[1]); | 132 | this = (struct nand_chip *)(&toto_mtd[1]); |
135 | 133 | ||
136 | /* Initialize structures */ | 134 | /* Initialize structures */ |
137 | memset((char *) toto_mtd, 0, sizeof(struct mtd_info)); | 135 | memset(toto_mtd, 0, sizeof(struct mtd_info)); |
138 | memset((char *) this, 0, sizeof(struct nand_chip)); | 136 | memset(this, 0, sizeof(struct nand_chip)); |
139 | 137 | ||
140 | /* Link the private data with the MTD structure */ | 138 | /* Link the private data with the MTD structure */ |
141 | toto_mtd->priv = this; | 139 | toto_mtd->priv = this; |
@@ -149,33 +147,37 @@ int __init toto_init (void) | |||
149 | this->chip_delay = 30; | 147 | this->chip_delay = 30; |
150 | this->eccmode = NAND_ECC_SOFT; | 148 | this->eccmode = NAND_ECC_SOFT; |
151 | 149 | ||
152 | /* Scan to find existance of the device */ | 150 | /* Scan to find existance of the device */ |
153 | if (nand_scan (toto_mtd, 1)) { | 151 | if (nand_scan(toto_mtd, 1)) { |
154 | err = -ENXIO; | 152 | err = -ENXIO; |
155 | goto out_mtd; | 153 | goto out_mtd; |
156 | } | 154 | } |
157 | 155 | ||
158 | /* Register the partitions */ | 156 | /* Register the partitions */ |
159 | switch(toto_mtd->size){ | 157 | switch (toto_mtd->size) { |
160 | case SZ_64M: add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M); break; | 158 | case SZ_64M: |
161 | case SZ_32M: add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M); break; | 159 | add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M); |
162 | default: { | 160 | break; |
163 | printk (KERN_WARNING "Unsupported Nand device\n"); | 161 | case SZ_32M: |
162 | add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M); | ||
163 | break; | ||
164 | default:{ | ||
165 | printk(KERN_WARNING "Unsupported Nand device\n"); | ||
164 | err = -ENXIO; | 166 | err = -ENXIO; |
165 | goto out_buf; | 167 | goto out_buf; |
166 | } | 168 | } |
167 | } | 169 | } |
168 | 170 | ||
169 | gpioreserve(NAND_MASK); /* claim our gpios */ | 171 | gpioreserve(NAND_MASK); /* claim our gpios */ |
170 | archflashwp(0,0); /* open up flash for writing */ | 172 | archflashwp(0, 0); /* open up flash for writing */ |
171 | 173 | ||
172 | goto out; | 174 | goto out; |
173 | 175 | ||
174 | out_buf: | 176 | out_buf: |
175 | kfree (this->data_buf); | 177 | kfree(this->data_buf); |
176 | out_mtd: | 178 | out_mtd: |
177 | kfree (toto_mtd); | 179 | kfree(toto_mtd); |
178 | out: | 180 | out: |
179 | return err; | 181 | return err; |
180 | } | 182 | } |
181 | 183 | ||
@@ -184,20 +186,21 @@ module_init(toto_init); | |||
184 | /* | 186 | /* |
185 | * Clean up routine | 187 | * Clean up routine |
186 | */ | 188 | */ |
187 | static void __exit toto_cleanup (void) | 189 | static void __exit toto_cleanup(void) |
188 | { | 190 | { |
189 | /* Release resources, unregister device */ | 191 | /* Release resources, unregister device */ |
190 | nand_release (toto_mtd); | 192 | nand_release(toto_mtd); |
191 | 193 | ||
192 | /* Free the MTD device structure */ | 194 | /* Free the MTD device structure */ |
193 | kfree (toto_mtd); | 195 | kfree(toto_mtd); |
194 | 196 | ||
195 | /* stop flash writes */ | 197 | /* stop flash writes */ |
196 | archflashwp(0,1); | 198 | archflashwp(0, 1); |
197 | 199 | ||
198 | /* release gpios to system */ | 200 | /* release gpios to system */ |
199 | gpiorelease(NAND_MASK); | 201 | gpiorelease(NAND_MASK); |
200 | } | 202 | } |
203 | |||
201 | module_exit(toto_cleanup); | 204 | module_exit(toto_cleanup); |
202 | 205 | ||
203 | MODULE_LICENSE("GPL"); | 206 | MODULE_LICENSE("GPL"); |