diff options
Diffstat (limited to 'drivers/mtd/nand/sharpsl.c')
-rw-r--r-- | drivers/mtd/nand/sharpsl.c | 93 |
1 files changed, 42 insertions, 51 deletions
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c index c294374871a4..25322a8d44d8 100644 --- a/drivers/mtd/nand/sharpsl.c +++ b/drivers/mtd/nand/sharpsl.c | |||
@@ -46,7 +46,6 @@ static int sharpsl_phys_base = 0x0C000000; | |||
46 | #define FLCLE (1 << 1) | 46 | #define FLCLE (1 << 1) |
47 | #define FLCE0 (1 << 0) | 47 | #define FLCE0 (1 << 0) |
48 | 48 | ||
49 | |||
50 | /* | 49 | /* |
51 | * MTD structure for SharpSL | 50 | * MTD structure for SharpSL |
52 | */ | 51 | */ |
@@ -60,27 +59,26 @@ static struct mtd_info *sharpsl_mtd = NULL; | |||
60 | static int nr_partitions; | 59 | static int nr_partitions; |
61 | static struct mtd_partition sharpsl_nand_default_partition_info[] = { | 60 | static struct mtd_partition sharpsl_nand_default_partition_info[] = { |
62 | { | 61 | { |
63 | .name = "System Area", | 62 | .name = "System Area", |
64 | .offset = 0, | 63 | .offset = 0, |
65 | .size = 7 * 1024 * 1024, | 64 | .size = 7 * 1024 * 1024, |
66 | }, | 65 | }, |
67 | { | 66 | { |
68 | .name = "Root Filesystem", | 67 | .name = "Root Filesystem", |
69 | .offset = 7 * 1024 * 1024, | 68 | .offset = 7 * 1024 * 1024, |
70 | .size = 30 * 1024 * 1024, | 69 | .size = 30 * 1024 * 1024, |
71 | }, | 70 | }, |
72 | { | 71 | { |
73 | .name = "Home Filesystem", | 72 | .name = "Home Filesystem", |
74 | .offset = MTDPART_OFS_APPEND , | 73 | .offset = MTDPART_OFS_APPEND, |
75 | .size = MTDPART_SIZ_FULL , | 74 | .size = MTDPART_SIZ_FULL, |
76 | }, | 75 | }, |
77 | }; | 76 | }; |
78 | 77 | ||
79 | /* | 78 | /* |
80 | * hardware specific access to control-lines | 79 | * hardware specific access to control-lines |
81 | */ | 80 | */ |
82 | static void | 81 | static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd) |
83 | sharpsl_nand_hwcontrol(struct mtd_info* mtd, int cmd) | ||
84 | { | 82 | { |
85 | switch (cmd) { | 83 | switch (cmd) { |
86 | case NAND_CTL_SETCLE: | 84 | case NAND_CTL_SETCLE: |
@@ -98,10 +96,10 @@ sharpsl_nand_hwcontrol(struct mtd_info* mtd, int cmd) | |||
98 | break; | 96 | break; |
99 | 97 | ||
100 | case NAND_CTL_SETNCE: | 98 | case NAND_CTL_SETNCE: |
101 | writeb(readb(FLASHCTL) & ~(FLCE0|FLCE1), FLASHCTL); | 99 | writeb(readb(FLASHCTL) & ~(FLCE0 | FLCE1), FLASHCTL); |
102 | break; | 100 | break; |
103 | case NAND_CTL_CLRNCE: | 101 | case NAND_CTL_CLRNCE: |
104 | writeb(readb(FLASHCTL) | (FLCE0|FLCE1), FLASHCTL); | 102 | writeb(readb(FLASHCTL) | (FLCE0 | FLCE1), FLASHCTL); |
105 | break; | 103 | break; |
106 | } | 104 | } |
107 | } | 105 | } |
@@ -126,27 +124,23 @@ static struct nand_oobinfo akita_oobinfo = { | |||
126 | .useecc = MTD_NANDECC_AUTOPLACE, | 124 | .useecc = MTD_NANDECC_AUTOPLACE, |
127 | .eccbytes = 24, | 125 | .eccbytes = 24, |
128 | .eccpos = { | 126 | .eccpos = { |
129 | 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11, | 127 | 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11, |
130 | 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23, | 128 | 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23, |
131 | 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37}, | 129 | 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37}, |
132 | .oobfree = { {0x08, 0x09} } | 130 | .oobfree = {{0x08, 0x09}} |
133 | }; | 131 | }; |
134 | 132 | ||
135 | static int | 133 | static int sharpsl_nand_dev_ready(struct mtd_info *mtd) |
136 | sharpsl_nand_dev_ready(struct mtd_info* mtd) | ||
137 | { | 134 | { |
138 | return !((readb(FLASHCTL) & FLRYBY) == 0); | 135 | return !((readb(FLASHCTL) & FLRYBY) == 0); |
139 | } | 136 | } |
140 | 137 | ||
141 | static void | 138 | static void sharpsl_nand_enable_hwecc(struct mtd_info *mtd, int mode) |
142 | sharpsl_nand_enable_hwecc(struct mtd_info* mtd, int mode) | ||
143 | { | 139 | { |
144 | writeb(0 ,ECCCLRR); | 140 | writeb(0, ECCCLRR); |
145 | } | 141 | } |
146 | 142 | ||
147 | static int | 143 | static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat, u_char * ecc_code) |
148 | sharpsl_nand_calculate_ecc(struct mtd_info* mtd, const u_char* dat, | ||
149 | u_char* ecc_code) | ||
150 | { | 144 | { |
151 | ecc_code[0] = ~readb(ECCLPUB); | 145 | ecc_code[0] = ~readb(ECCLPUB); |
152 | ecc_code[1] = ~readb(ECCLPLB); | 146 | ecc_code[1] = ~readb(ECCLPLB); |
@@ -154,44 +148,40 @@ sharpsl_nand_calculate_ecc(struct mtd_info* mtd, const u_char* dat, | |||
154 | return readb(ECCCNTR) != 0; | 148 | return readb(ECCCNTR) != 0; |
155 | } | 149 | } |
156 | 150 | ||
157 | |||
158 | #ifdef CONFIG_MTD_PARTITIONS | 151 | #ifdef CONFIG_MTD_PARTITIONS |
159 | const char *part_probes[] = { "cmdlinepart", NULL }; | 152 | const char *part_probes[] = { "cmdlinepart", NULL }; |
160 | #endif | 153 | #endif |
161 | 154 | ||
162 | |||
163 | /* | 155 | /* |
164 | * Main initialization routine | 156 | * Main initialization routine |
165 | */ | 157 | */ |
166 | int __init | 158 | int __init sharpsl_nand_init(void) |
167 | sharpsl_nand_init(void) | ||
168 | { | 159 | { |
169 | struct nand_chip *this; | 160 | struct nand_chip *this; |
170 | struct mtd_partition* sharpsl_partition_info; | 161 | struct mtd_partition *sharpsl_partition_info; |
171 | int err = 0; | 162 | int err = 0; |
172 | 163 | ||
173 | /* Allocate memory for MTD device structure and private data */ | 164 | /* Allocate memory for MTD device structure and private data */ |
174 | sharpsl_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), | 165 | sharpsl_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
175 | GFP_KERNEL); | ||
176 | if (!sharpsl_mtd) { | 166 | if (!sharpsl_mtd) { |
177 | printk ("Unable to allocate SharpSL NAND MTD device structure.\n"); | 167 | printk("Unable to allocate SharpSL NAND MTD device structure.\n"); |
178 | return -ENOMEM; | 168 | return -ENOMEM; |
179 | } | 169 | } |
180 | 170 | ||
181 | /* map physical adress */ | 171 | /* map physical adress */ |
182 | sharpsl_io_base = ioremap(sharpsl_phys_base, 0x1000); | 172 | sharpsl_io_base = ioremap(sharpsl_phys_base, 0x1000); |
183 | if(!sharpsl_io_base){ | 173 | if (!sharpsl_io_base) { |
184 | printk("ioremap to access Sharp SL NAND chip failed\n"); | 174 | printk("ioremap to access Sharp SL NAND chip failed\n"); |
185 | kfree(sharpsl_mtd); | 175 | kfree(sharpsl_mtd); |
186 | return -EIO; | 176 | return -EIO; |
187 | } | 177 | } |
188 | 178 | ||
189 | /* Get pointer to private data */ | 179 | /* Get pointer to private data */ |
190 | this = (struct nand_chip *) (&sharpsl_mtd[1]); | 180 | this = (struct nand_chip *)(&sharpsl_mtd[1]); |
191 | 181 | ||
192 | /* Initialize structures */ | 182 | /* Initialize structures */ |
193 | memset((char *) sharpsl_mtd, 0, sizeof(struct mtd_info)); | 183 | memset(sharpsl_mtd, 0, sizeof(struct mtd_info)); |
194 | memset((char *) this, 0, sizeof(struct nand_chip)); | 184 | memset(this, 0, sizeof(struct nand_chip)); |
195 | 185 | ||
196 | /* Link the private data with the MTD structure */ | 186 | /* Link the private data with the MTD structure */ |
197 | sharpsl_mtd->priv = this; | 187 | sharpsl_mtd->priv = this; |
@@ -221,7 +211,7 @@ sharpsl_nand_init(void) | |||
221 | this->correct_data = nand_correct_data; | 211 | this->correct_data = nand_correct_data; |
222 | 212 | ||
223 | /* Scan to find existence of the device */ | 213 | /* Scan to find existence of the device */ |
224 | err=nand_scan(sharpsl_mtd,1); | 214 | err = nand_scan(sharpsl_mtd, 1); |
225 | if (err) { | 215 | if (err) { |
226 | iounmap(sharpsl_io_base); | 216 | iounmap(sharpsl_io_base); |
227 | kfree(sharpsl_mtd); | 217 | kfree(sharpsl_mtd); |
@@ -230,24 +220,23 @@ sharpsl_nand_init(void) | |||
230 | 220 | ||
231 | /* Register the partitions */ | 221 | /* Register the partitions */ |
232 | sharpsl_mtd->name = "sharpsl-nand"; | 222 | sharpsl_mtd->name = "sharpsl-nand"; |
233 | nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, | 223 | nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, &sharpsl_partition_info, 0); |
234 | &sharpsl_partition_info, 0); | ||
235 | 224 | ||
236 | if (nr_partitions <= 0) { | 225 | if (nr_partitions <= 0) { |
237 | nr_partitions = DEFAULT_NUM_PARTITIONS; | 226 | nr_partitions = DEFAULT_NUM_PARTITIONS; |
238 | sharpsl_partition_info = sharpsl_nand_default_partition_info; | 227 | sharpsl_partition_info = sharpsl_nand_default_partition_info; |
239 | if (machine_is_poodle()) { | 228 | if (machine_is_poodle()) { |
240 | sharpsl_partition_info[1].size=22 * 1024 * 1024; | 229 | sharpsl_partition_info[1].size = 22 * 1024 * 1024; |
241 | } else if (machine_is_corgi() || machine_is_shepherd()) { | 230 | } else if (machine_is_corgi() || machine_is_shepherd()) { |
242 | sharpsl_partition_info[1].size=25 * 1024 * 1024; | 231 | sharpsl_partition_info[1].size = 25 * 1024 * 1024; |
243 | } else if (machine_is_husky()) { | 232 | } else if (machine_is_husky()) { |
244 | sharpsl_partition_info[1].size=53 * 1024 * 1024; | 233 | sharpsl_partition_info[1].size = 53 * 1024 * 1024; |
245 | } else if (machine_is_spitz()) { | 234 | } else if (machine_is_spitz()) { |
246 | sharpsl_partition_info[1].size=5 * 1024 * 1024; | 235 | sharpsl_partition_info[1].size = 5 * 1024 * 1024; |
247 | } else if (machine_is_akita()) { | 236 | } else if (machine_is_akita()) { |
248 | sharpsl_partition_info[1].size=58 * 1024 * 1024; | 237 | sharpsl_partition_info[1].size = 58 * 1024 * 1024; |
249 | } else if (machine_is_borzoi()) { | 238 | } else if (machine_is_borzoi()) { |
250 | sharpsl_partition_info[1].size=32 * 1024 * 1024; | 239 | sharpsl_partition_info[1].size = 32 * 1024 * 1024; |
251 | } | 240 | } |
252 | } | 241 | } |
253 | 242 | ||
@@ -261,6 +250,7 @@ sharpsl_nand_init(void) | |||
261 | /* Return happy */ | 250 | /* Return happy */ |
262 | return 0; | 251 | return 0; |
263 | } | 252 | } |
253 | |||
264 | module_init(sharpsl_nand_init); | 254 | module_init(sharpsl_nand_init); |
265 | 255 | ||
266 | /* | 256 | /* |
@@ -269,7 +259,7 @@ module_init(sharpsl_nand_init); | |||
269 | #ifdef MODULE | 259 | #ifdef MODULE |
270 | static void __exit sharpsl_nand_cleanup(void) | 260 | static void __exit sharpsl_nand_cleanup(void) |
271 | { | 261 | { |
272 | struct nand_chip *this = (struct nand_chip *) &sharpsl_mtd[1]; | 262 | struct nand_chip *this = (struct nand_chip *)&sharpsl_mtd[1]; |
273 | 263 | ||
274 | /* Release resources, unregister device */ | 264 | /* Release resources, unregister device */ |
275 | nand_release(sharpsl_mtd); | 265 | nand_release(sharpsl_mtd); |
@@ -279,6 +269,7 @@ static void __exit sharpsl_nand_cleanup(void) | |||
279 | /* Free the MTD device structure */ | 269 | /* Free the MTD device structure */ |
280 | kfree(sharpsl_mtd); | 270 | kfree(sharpsl_mtd); |
281 | } | 271 | } |
272 | |||
282 | module_exit(sharpsl_nand_cleanup); | 273 | module_exit(sharpsl_nand_cleanup); |
283 | #endif | 274 | #endif |
284 | 275 | ||