aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/sharpsl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand/sharpsl.c')
-rw-r--r--drivers/mtd/nand/sharpsl.c96
1 files changed, 43 insertions, 53 deletions
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c
index c294374871a4..60e10c0d6980 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;
60static int nr_partitions; 59static int nr_partitions;
61static struct mtd_partition sharpsl_nand_default_partition_info[] = { 60static 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 */
82static void 81static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd)
83sharpsl_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
135static int 133static int sharpsl_nand_dev_ready(struct mtd_info *mtd)
136sharpsl_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
141static void 138static void sharpsl_nand_enable_hwecc(struct mtd_info *mtd, int mode)
142sharpsl_nand_enable_hwecc(struct mtd_info* mtd, int mode)
143{ 139{
144 writeb(0 ,ECCCLRR); 140 writeb(0, ECCCLRR);
145} 141}
146 142
147static int 143static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat, u_char * ecc_code)
148sharpsl_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,47 +148,44 @@ 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
159const char *part_probes[] = { "cmdlinepart", NULL }; 152const char *part_probes[] = { "cmdlinepart", NULL };
160#endif 153#endif
161 154
162
163/* 155/*
164 * Main initialization routine 156 * Main initialization routine
165 */ 157 */
166int __init 158static int __init sharpsl_nand_init(void)
167sharpsl_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;
188 sharpsl_mtd->owner = THIS_MODULE;
198 189
199 /* 190 /*
200 * PXA initialize 191 * PXA initialize
@@ -221,7 +212,7 @@ sharpsl_nand_init(void)
221 this->correct_data = nand_correct_data; 212 this->correct_data = nand_correct_data;
222 213
223 /* Scan to find existence of the device */ 214 /* Scan to find existence of the device */
224 err=nand_scan(sharpsl_mtd,1); 215 err = nand_scan(sharpsl_mtd, 1);
225 if (err) { 216 if (err) {
226 iounmap(sharpsl_io_base); 217 iounmap(sharpsl_io_base);
227 kfree(sharpsl_mtd); 218 kfree(sharpsl_mtd);
@@ -230,24 +221,23 @@ sharpsl_nand_init(void)
230 221
231 /* Register the partitions */ 222 /* Register the partitions */
232 sharpsl_mtd->name = "sharpsl-nand"; 223 sharpsl_mtd->name = "sharpsl-nand";
233 nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, 224 nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, &sharpsl_partition_info, 0);
234 &sharpsl_partition_info, 0);
235 225
236 if (nr_partitions <= 0) { 226 if (nr_partitions <= 0) {
237 nr_partitions = DEFAULT_NUM_PARTITIONS; 227 nr_partitions = DEFAULT_NUM_PARTITIONS;
238 sharpsl_partition_info = sharpsl_nand_default_partition_info; 228 sharpsl_partition_info = sharpsl_nand_default_partition_info;
239 if (machine_is_poodle()) { 229 if (machine_is_poodle()) {
240 sharpsl_partition_info[1].size=22 * 1024 * 1024; 230 sharpsl_partition_info[1].size = 22 * 1024 * 1024;
241 } else if (machine_is_corgi() || machine_is_shepherd()) { 231 } else if (machine_is_corgi() || machine_is_shepherd()) {
242 sharpsl_partition_info[1].size=25 * 1024 * 1024; 232 sharpsl_partition_info[1].size = 25 * 1024 * 1024;
243 } else if (machine_is_husky()) { 233 } else if (machine_is_husky()) {
244 sharpsl_partition_info[1].size=53 * 1024 * 1024; 234 sharpsl_partition_info[1].size = 53 * 1024 * 1024;
245 } else if (machine_is_spitz()) { 235 } else if (machine_is_spitz()) {
246 sharpsl_partition_info[1].size=5 * 1024 * 1024; 236 sharpsl_partition_info[1].size = 5 * 1024 * 1024;
247 } else if (machine_is_akita()) { 237 } else if (machine_is_akita()) {
248 sharpsl_partition_info[1].size=58 * 1024 * 1024; 238 sharpsl_partition_info[1].size = 58 * 1024 * 1024;
249 } else if (machine_is_borzoi()) { 239 } else if (machine_is_borzoi()) {
250 sharpsl_partition_info[1].size=32 * 1024 * 1024; 240 sharpsl_partition_info[1].size = 32 * 1024 * 1024;
251 } 241 }
252 } 242 }
253 243
@@ -261,15 +251,15 @@ sharpsl_nand_init(void)
261 /* Return happy */ 251 /* Return happy */
262 return 0; 252 return 0;
263} 253}
254
264module_init(sharpsl_nand_init); 255module_init(sharpsl_nand_init);
265 256
266/* 257/*
267 * Clean up routine 258 * Clean up routine
268 */ 259 */
269#ifdef MODULE
270static void __exit sharpsl_nand_cleanup(void) 260static 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,8 +269,8 @@ 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
282module_exit(sharpsl_nand_cleanup); 273module_exit(sharpsl_nand_cleanup);
283#endif
284 274
285MODULE_LICENSE("GPL"); 275MODULE_LICENSE("GPL");
286MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); 276MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");