lart.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * MTD driver for the 28F160F3 Flash Memory (non-CFI) on LART.
  4. *
  5. * Author: Abraham vd Merwe <[email protected]>
  6. *
  7. * Copyright (c) 2001, 2d3D, Inc.
  8. *
  9. * References:
  10. *
  11. * [1] 3 Volt Fast Boot Block Flash Memory" Intel Datasheet
  12. * - Order Number: 290644-005
  13. * - January 2000
  14. *
  15. * [2] MTD internal API documentation
  16. * - http://www.linux-mtd.infradead.org/
  17. *
  18. * Limitations:
  19. *
  20. * Even though this driver is written for 3 Volt Fast Boot
  21. * Block Flash Memory, it is rather specific to LART. With
  22. * Minor modifications, notably the without data/address line
  23. * mangling and different bus settings, etc. it should be
  24. * trivial to adapt to other platforms.
  25. *
  26. * If somebody would sponsor me a different board, I'll
  27. * adapt the driver (:
  28. */
  29. /* debugging */
  30. //#define LART_DEBUG
  31. #include <linux/kernel.h>
  32. #include <linux/module.h>
  33. #include <linux/types.h>
  34. #include <linux/init.h>
  35. #include <linux/errno.h>
  36. #include <linux/string.h>
  37. #include <linux/mtd/mtd.h>
  38. #include <linux/mtd/partitions.h>
  39. #ifndef CONFIG_SA1100_LART
  40. #error This is for LART architecture only
  41. #endif
  42. static char module_name[] = "lart";
  43. /*
  44. * These values is specific to 28Fxxxx3 flash memory.
  45. * See section 2.3.1 in "3 Volt Fast Boot Block Flash Memory" Intel Datasheet
  46. */
  47. #define FLASH_BLOCKSIZE_PARAM (4096 * BUSWIDTH)
  48. #define FLASH_NUMBLOCKS_16m_PARAM 8
  49. #define FLASH_NUMBLOCKS_8m_PARAM 8
  50. /*
  51. * These values is specific to 28Fxxxx3 flash memory.
  52. * See section 2.3.2 in "3 Volt Fast Boot Block Flash Memory" Intel Datasheet
  53. */
  54. #define FLASH_BLOCKSIZE_MAIN (32768 * BUSWIDTH)
  55. #define FLASH_NUMBLOCKS_16m_MAIN 31
  56. #define FLASH_NUMBLOCKS_8m_MAIN 15
  57. /*
  58. * These values are specific to LART
  59. */
  60. /* general */
  61. #define BUSWIDTH 4 /* don't change this - a lot of the code _will_ break if you change this */
  62. #define FLASH_OFFSET 0xe8000000 /* see linux/arch/arm/mach-sa1100/lart.c */
  63. /* blob */
  64. #define NUM_BLOB_BLOCKS FLASH_NUMBLOCKS_16m_PARAM
  65. #define PART_BLOB_START 0x00000000
  66. #define PART_BLOB_LEN (NUM_BLOB_BLOCKS * FLASH_BLOCKSIZE_PARAM)
  67. /* kernel */
  68. #define NUM_KERNEL_BLOCKS 7
  69. #define PART_KERNEL_START (PART_BLOB_START + PART_BLOB_LEN)
  70. #define PART_KERNEL_LEN (NUM_KERNEL_BLOCKS * FLASH_BLOCKSIZE_MAIN)
  71. /* initial ramdisk */
  72. #define NUM_INITRD_BLOCKS 24
  73. #define PART_INITRD_START (PART_KERNEL_START + PART_KERNEL_LEN)
  74. #define PART_INITRD_LEN (NUM_INITRD_BLOCKS * FLASH_BLOCKSIZE_MAIN)
  75. /*
  76. * See section 4.0 in "3 Volt Fast Boot Block Flash Memory" Intel Datasheet
  77. */
  78. #define READ_ARRAY 0x00FF00FF /* Read Array/Reset */
  79. #define READ_ID_CODES 0x00900090 /* Read Identifier Codes */
  80. #define ERASE_SETUP 0x00200020 /* Block Erase */
  81. #define ERASE_CONFIRM 0x00D000D0 /* Block Erase and Program Resume */
  82. #define PGM_SETUP 0x00400040 /* Program */
  83. #define STATUS_READ 0x00700070 /* Read Status Register */
  84. #define STATUS_CLEAR 0x00500050 /* Clear Status Register */
  85. #define STATUS_BUSY 0x00800080 /* Write State Machine Status (WSMS) */
  86. #define STATUS_ERASE_ERR 0x00200020 /* Erase Status (ES) */
  87. #define STATUS_PGM_ERR 0x00100010 /* Program Status (PS) */
  88. /*
  89. * See section 4.2 in "3 Volt Fast Boot Block Flash Memory" Intel Datasheet
  90. */
  91. #define FLASH_MANUFACTURER 0x00890089
  92. #define FLASH_DEVICE_8mbit_TOP 0x88f188f1
  93. #define FLASH_DEVICE_8mbit_BOTTOM 0x88f288f2
  94. #define FLASH_DEVICE_16mbit_TOP 0x88f388f3
  95. #define FLASH_DEVICE_16mbit_BOTTOM 0x88f488f4
  96. /***************************************************************************************************/
  97. /*
  98. * The data line mapping on LART is as follows:
  99. *
  100. * U2 CPU | U3 CPU
  101. * -------------------
  102. * 0 20 | 0 12
  103. * 1 22 | 1 14
  104. * 2 19 | 2 11
  105. * 3 17 | 3 9
  106. * 4 24 | 4 0
  107. * 5 26 | 5 2
  108. * 6 31 | 6 7
  109. * 7 29 | 7 5
  110. * 8 21 | 8 13
  111. * 9 23 | 9 15
  112. * 10 18 | 10 10
  113. * 11 16 | 11 8
  114. * 12 25 | 12 1
  115. * 13 27 | 13 3
  116. * 14 30 | 14 6
  117. * 15 28 | 15 4
  118. */
  119. /* Mangle data (x) */
  120. #define DATA_TO_FLASH(x) \
  121. ( \
  122. (((x) & 0x08009000) >> 11) + \
  123. (((x) & 0x00002000) >> 10) + \
  124. (((x) & 0x04004000) >> 8) + \
  125. (((x) & 0x00000010) >> 4) + \
  126. (((x) & 0x91000820) >> 3) + \
  127. (((x) & 0x22080080) >> 2) + \
  128. ((x) & 0x40000400) + \
  129. (((x) & 0x00040040) << 1) + \
  130. (((x) & 0x00110000) << 4) + \
  131. (((x) & 0x00220100) << 5) + \
  132. (((x) & 0x00800208) << 6) + \
  133. (((x) & 0x00400004) << 9) + \
  134. (((x) & 0x00000001) << 12) + \
  135. (((x) & 0x00000002) << 13) \
  136. )
  137. /* Unmangle data (x) */
  138. #define FLASH_TO_DATA(x) \
  139. ( \
  140. (((x) & 0x00010012) << 11) + \
  141. (((x) & 0x00000008) << 10) + \
  142. (((x) & 0x00040040) << 8) + \
  143. (((x) & 0x00000001) << 4) + \
  144. (((x) & 0x12200104) << 3) + \
  145. (((x) & 0x08820020) << 2) + \
  146. ((x) & 0x40000400) + \
  147. (((x) & 0x00080080) >> 1) + \
  148. (((x) & 0x01100000) >> 4) + \
  149. (((x) & 0x04402000) >> 5) + \
  150. (((x) & 0x20008200) >> 6) + \
  151. (((x) & 0x80000800) >> 9) + \
  152. (((x) & 0x00001000) >> 12) + \
  153. (((x) & 0x00004000) >> 13) \
  154. )
  155. /*
  156. * The address line mapping on LART is as follows:
  157. *
  158. * U3 CPU | U2 CPU
  159. * -------------------
  160. * 0 2 | 0 2
  161. * 1 3 | 1 3
  162. * 2 9 | 2 9
  163. * 3 13 | 3 8
  164. * 4 8 | 4 7
  165. * 5 12 | 5 6
  166. * 6 11 | 6 5
  167. * 7 10 | 7 4
  168. * 8 4 | 8 10
  169. * 9 5 | 9 11
  170. * 10 6 | 10 12
  171. * 11 7 | 11 13
  172. *
  173. * BOOT BLOCK BOUNDARY
  174. *
  175. * 12 15 | 12 15
  176. * 13 14 | 13 14
  177. * 14 16 | 14 16
  178. *
  179. * MAIN BLOCK BOUNDARY
  180. *
  181. * 15 17 | 15 18
  182. * 16 18 | 16 17
  183. * 17 20 | 17 20
  184. * 18 19 | 18 19
  185. * 19 21 | 19 21
  186. *
  187. * As we can see from above, the addresses aren't mangled across
  188. * block boundaries, so we don't need to worry about address
  189. * translations except for sending/reading commands during
  190. * initialization
  191. */
  192. /* Mangle address (x) on chip U2 */
  193. #define ADDR_TO_FLASH_U2(x) \
  194. ( \
  195. (((x) & 0x00000f00) >> 4) + \
  196. (((x) & 0x00042000) << 1) + \
  197. (((x) & 0x0009c003) << 2) + \
  198. (((x) & 0x00021080) << 3) + \
  199. (((x) & 0x00000010) << 4) + \
  200. (((x) & 0x00000040) << 5) + \
  201. (((x) & 0x00000024) << 7) + \
  202. (((x) & 0x00000008) << 10) \
  203. )
  204. /* Unmangle address (x) on chip U2 */
  205. #define FLASH_U2_TO_ADDR(x) \
  206. ( \
  207. (((x) << 4) & 0x00000f00) + \
  208. (((x) >> 1) & 0x00042000) + \
  209. (((x) >> 2) & 0x0009c003) + \
  210. (((x) >> 3) & 0x00021080) + \
  211. (((x) >> 4) & 0x00000010) + \
  212. (((x) >> 5) & 0x00000040) + \
  213. (((x) >> 7) & 0x00000024) + \
  214. (((x) >> 10) & 0x00000008) \
  215. )
  216. /* Mangle address (x) on chip U3 */
  217. #define ADDR_TO_FLASH_U3(x) \
  218. ( \
  219. (((x) & 0x00000080) >> 3) + \
  220. (((x) & 0x00000040) >> 1) + \
  221. (((x) & 0x00052020) << 1) + \
  222. (((x) & 0x00084f03) << 2) + \
  223. (((x) & 0x00029010) << 3) + \
  224. (((x) & 0x00000008) << 5) + \
  225. (((x) & 0x00000004) << 7) \
  226. )
  227. /* Unmangle address (x) on chip U3 */
  228. #define FLASH_U3_TO_ADDR(x) \
  229. ( \
  230. (((x) << 3) & 0x00000080) + \
  231. (((x) << 1) & 0x00000040) + \
  232. (((x) >> 1) & 0x00052020) + \
  233. (((x) >> 2) & 0x00084f03) + \
  234. (((x) >> 3) & 0x00029010) + \
  235. (((x) >> 5) & 0x00000008) + \
  236. (((x) >> 7) & 0x00000004) \
  237. )
  238. /***************************************************************************************************/
  239. static __u8 read8 (__u32 offset)
  240. {
  241. volatile __u8 *data = (__u8 *) (FLASH_OFFSET + offset);
  242. #ifdef LART_DEBUG
  243. printk (KERN_DEBUG "%s(): 0x%.8x -> 0x%.2x\n", __func__, offset, *data);
  244. #endif
  245. return (*data);
  246. }
  247. static __u32 read32 (__u32 offset)
  248. {
  249. volatile __u32 *data = (__u32 *) (FLASH_OFFSET + offset);
  250. #ifdef LART_DEBUG
  251. printk (KERN_DEBUG "%s(): 0x%.8x -> 0x%.8x\n", __func__, offset, *data);
  252. #endif
  253. return (*data);
  254. }
  255. static void write32 (__u32 x,__u32 offset)
  256. {
  257. volatile __u32 *data = (__u32 *) (FLASH_OFFSET + offset);
  258. *data = x;
  259. #ifdef LART_DEBUG
  260. printk (KERN_DEBUG "%s(): 0x%.8x <- 0x%.8x\n", __func__, offset, *data);
  261. #endif
  262. }
  263. /***************************************************************************************************/
  264. /*
  265. * Probe for 16mbit flash memory on a LART board without doing
  266. * too much damage. Since we need to write 1 dword to memory,
  267. * we're f**cked if this happens to be DRAM since we can't
  268. * restore the memory (otherwise we might exit Read Array mode).
  269. *
  270. * Returns 1 if we found 16mbit flash memory on LART, 0 otherwise.
  271. */
  272. static int flash_probe (void)
  273. {
  274. __u32 manufacturer,devtype;
  275. /* setup "Read Identifier Codes" mode */
  276. write32 (DATA_TO_FLASH (READ_ID_CODES),0x00000000);
  277. /* probe U2. U2/U3 returns the same data since the first 3
  278. * address lines is mangled in the same way */
  279. manufacturer = FLASH_TO_DATA (read32 (ADDR_TO_FLASH_U2 (0x00000000)));
  280. devtype = FLASH_TO_DATA (read32 (ADDR_TO_FLASH_U2 (0x00000001)));
  281. /* put the flash back into command mode */
  282. write32 (DATA_TO_FLASH (READ_ARRAY),0x00000000);
  283. return (manufacturer == FLASH_MANUFACTURER && (devtype == FLASH_DEVICE_16mbit_TOP || devtype == FLASH_DEVICE_16mbit_BOTTOM));
  284. }
  285. /*
  286. * Erase one block of flash memory at offset ``offset'' which is any
  287. * address within the block which should be erased.
  288. *
  289. * Returns 1 if successful, 0 otherwise.
  290. */
  291. static inline int erase_block (__u32 offset)
  292. {
  293. __u32 status;
  294. #ifdef LART_DEBUG
  295. printk (KERN_DEBUG "%s(): 0x%.8x\n", __func__, offset);
  296. #endif
  297. /* erase and confirm */
  298. write32 (DATA_TO_FLASH (ERASE_SETUP),offset);
  299. write32 (DATA_TO_FLASH (ERASE_CONFIRM),offset);
  300. /* wait for block erase to finish */
  301. do
  302. {
  303. write32 (DATA_TO_FLASH (STATUS_READ),offset);
  304. status = FLASH_TO_DATA (read32 (offset));
  305. }
  306. while ((~status & STATUS_BUSY) != 0);
  307. /* put the flash back into command mode */
  308. write32 (DATA_TO_FLASH (READ_ARRAY),offset);
  309. /* was the erase successful? */
  310. if ((status & STATUS_ERASE_ERR))
  311. {
  312. printk (KERN_WARNING "%s: erase error at address 0x%.8x.\n",module_name,offset);
  313. return (0);
  314. }
  315. return (1);
  316. }
  317. static int flash_erase (struct mtd_info *mtd,struct erase_info *instr)
  318. {
  319. __u32 addr,len;
  320. int i,first;
  321. #ifdef LART_DEBUG
  322. printk (KERN_DEBUG "%s(addr = 0x%.8x, len = %d)\n", __func__, instr->addr, instr->len);
  323. #endif
  324. /*
  325. * check that both start and end of the requested erase are
  326. * aligned with the erasesize at the appropriate addresses.
  327. *
  328. * skip all erase regions which are ended before the start of
  329. * the requested erase. Actually, to save on the calculations,
  330. * we skip to the first erase region which starts after the
  331. * start of the requested erase, and then go back one.
  332. */
  333. for (i = 0; i < mtd->numeraseregions && instr->addr >= mtd->eraseregions[i].offset; i++) ;
  334. i--;
  335. /*
  336. * ok, now i is pointing at the erase region in which this
  337. * erase request starts. Check the start of the requested
  338. * erase range is aligned with the erase size which is in
  339. * effect here.
  340. */
  341. if (i < 0 || (instr->addr & (mtd->eraseregions[i].erasesize - 1)))
  342. return -EINVAL;
  343. /* Remember the erase region we start on */
  344. first = i;
  345. /*
  346. * next, check that the end of the requested erase is aligned
  347. * with the erase region at that address.
  348. *
  349. * as before, drop back one to point at the region in which
  350. * the address actually falls
  351. */
  352. for (; i < mtd->numeraseregions && instr->addr + instr->len >= mtd->eraseregions[i].offset; i++) ;
  353. i--;
  354. /* is the end aligned on a block boundary? */
  355. if (i < 0 || ((instr->addr + instr->len) & (mtd->eraseregions[i].erasesize - 1)))
  356. return -EINVAL;
  357. addr = instr->addr;
  358. len = instr->len;
  359. i = first;
  360. /* now erase those blocks */
  361. while (len)
  362. {
  363. if (!erase_block (addr))
  364. return (-EIO);
  365. addr += mtd->eraseregions[i].erasesize;
  366. len -= mtd->eraseregions[i].erasesize;
  367. if (addr == mtd->eraseregions[i].offset + (mtd->eraseregions[i].erasesize * mtd->eraseregions[i].numblocks)) i++;
  368. }
  369. return (0);
  370. }
  371. static int flash_read (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,u_char *buf)
  372. {
  373. #ifdef LART_DEBUG
  374. printk (KERN_DEBUG "%s(from = 0x%.8x, len = %d)\n", __func__, (__u32)from, len);
  375. #endif
  376. /* we always read len bytes */
  377. *retlen = len;
  378. /* first, we read bytes until we reach a dword boundary */
  379. if (from & (BUSWIDTH - 1))
  380. {
  381. int gap = BUSWIDTH - (from & (BUSWIDTH - 1));
  382. while (len && gap--) {
  383. *buf++ = read8 (from++);
  384. len--;
  385. }
  386. }
  387. /* now we read dwords until we reach a non-dword boundary */
  388. while (len >= BUSWIDTH)
  389. {
  390. *((__u32 *) buf) = read32 (from);
  391. buf += BUSWIDTH;
  392. from += BUSWIDTH;
  393. len -= BUSWIDTH;
  394. }
  395. /* top up the last unaligned bytes */
  396. if (len & (BUSWIDTH - 1))
  397. while (len--) *buf++ = read8 (from++);
  398. return (0);
  399. }
  400. /*
  401. * Write one dword ``x'' to flash memory at offset ``offset''. ``offset''
  402. * must be 32 bits, i.e. it must be on a dword boundary.
  403. *
  404. * Returns 1 if successful, 0 otherwise.
  405. */
  406. static inline int write_dword (__u32 offset,__u32 x)
  407. {
  408. __u32 status;
  409. #ifdef LART_DEBUG
  410. printk (KERN_DEBUG "%s(): 0x%.8x <- 0x%.8x\n", __func__, offset, x);
  411. #endif
  412. /* setup writing */
  413. write32 (DATA_TO_FLASH (PGM_SETUP),offset);
  414. /* write the data */
  415. write32 (x,offset);
  416. /* wait for the write to finish */
  417. do
  418. {
  419. write32 (DATA_TO_FLASH (STATUS_READ),offset);
  420. status = FLASH_TO_DATA (read32 (offset));
  421. }
  422. while ((~status & STATUS_BUSY) != 0);
  423. /* put the flash back into command mode */
  424. write32 (DATA_TO_FLASH (READ_ARRAY),offset);
  425. /* was the write successful? */
  426. if ((status & STATUS_PGM_ERR) || read32 (offset) != x)
  427. {
  428. printk (KERN_WARNING "%s: write error at address 0x%.8x.\n",module_name,offset);
  429. return (0);
  430. }
  431. return (1);
  432. }
  433. static int flash_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen,const u_char *buf)
  434. {
  435. __u8 tmp[4];
  436. int i,n;
  437. #ifdef LART_DEBUG
  438. printk (KERN_DEBUG "%s(to = 0x%.8x, len = %d)\n", __func__, (__u32)to, len);
  439. #endif
  440. /* sanity checks */
  441. if (!len) return (0);
  442. /* first, we write a 0xFF.... padded byte until we reach a dword boundary */
  443. if (to & (BUSWIDTH - 1))
  444. {
  445. __u32 aligned = to & ~(BUSWIDTH - 1);
  446. int gap = to - aligned;
  447. i = n = 0;
  448. while (gap--) tmp[i++] = 0xFF;
  449. while (len && i < BUSWIDTH) {
  450. tmp[i++] = buf[n++];
  451. len--;
  452. }
  453. while (i < BUSWIDTH) tmp[i++] = 0xFF;
  454. if (!write_dword (aligned,*((__u32 *) tmp))) return (-EIO);
  455. to += n;
  456. buf += n;
  457. *retlen += n;
  458. }
  459. /* now we write dwords until we reach a non-dword boundary */
  460. while (len >= BUSWIDTH)
  461. {
  462. if (!write_dword (to,*((__u32 *) buf))) return (-EIO);
  463. to += BUSWIDTH;
  464. buf += BUSWIDTH;
  465. *retlen += BUSWIDTH;
  466. len -= BUSWIDTH;
  467. }
  468. /* top up the last unaligned bytes, padded with 0xFF.... */
  469. if (len & (BUSWIDTH - 1))
  470. {
  471. i = n = 0;
  472. while (len--) tmp[i++] = buf[n++];
  473. while (i < BUSWIDTH) tmp[i++] = 0xFF;
  474. if (!write_dword (to,*((__u32 *) tmp))) return (-EIO);
  475. *retlen += n;
  476. }
  477. return (0);
  478. }
  479. /***************************************************************************************************/
  480. static struct mtd_info mtd;
  481. static struct mtd_erase_region_info erase_regions[] = {
  482. /* parameter blocks */
  483. {
  484. .offset = 0x00000000,
  485. .erasesize = FLASH_BLOCKSIZE_PARAM,
  486. .numblocks = FLASH_NUMBLOCKS_16m_PARAM,
  487. },
  488. /* main blocks */
  489. {
  490. .offset = FLASH_BLOCKSIZE_PARAM * FLASH_NUMBLOCKS_16m_PARAM,
  491. .erasesize = FLASH_BLOCKSIZE_MAIN,
  492. .numblocks = FLASH_NUMBLOCKS_16m_MAIN,
  493. }
  494. };
  495. static const struct mtd_partition lart_partitions[] = {
  496. /* blob */
  497. {
  498. .name = "blob",
  499. .offset = PART_BLOB_START,
  500. .size = PART_BLOB_LEN,
  501. },
  502. /* kernel */
  503. {
  504. .name = "kernel",
  505. .offset = PART_KERNEL_START, /* MTDPART_OFS_APPEND */
  506. .size = PART_KERNEL_LEN,
  507. },
  508. /* initial ramdisk / file system */
  509. {
  510. .name = "file system",
  511. .offset = PART_INITRD_START, /* MTDPART_OFS_APPEND */
  512. .size = PART_INITRD_LEN, /* MTDPART_SIZ_FULL */
  513. }
  514. };
  515. #define NUM_PARTITIONS ARRAY_SIZE(lart_partitions)
  516. static int __init lart_flash_init (void)
  517. {
  518. int result;
  519. memset (&mtd,0,sizeof (mtd));
  520. printk ("MTD driver for LART. Written by Abraham vd Merwe <[email protected]>\n");
  521. printk ("%s: Probing for 28F160x3 flash on LART...\n",module_name);
  522. if (!flash_probe ())
  523. {
  524. printk (KERN_WARNING "%s: Found no LART compatible flash device\n",module_name);
  525. return (-ENXIO);
  526. }
  527. printk ("%s: This looks like a LART board to me.\n",module_name);
  528. mtd.name = module_name;
  529. mtd.type = MTD_NORFLASH;
  530. mtd.writesize = 1;
  531. mtd.writebufsize = 4;
  532. mtd.flags = MTD_CAP_NORFLASH;
  533. mtd.size = FLASH_BLOCKSIZE_PARAM * FLASH_NUMBLOCKS_16m_PARAM + FLASH_BLOCKSIZE_MAIN * FLASH_NUMBLOCKS_16m_MAIN;
  534. mtd.erasesize = FLASH_BLOCKSIZE_MAIN;
  535. mtd.numeraseregions = ARRAY_SIZE(erase_regions);
  536. mtd.eraseregions = erase_regions;
  537. mtd._erase = flash_erase;
  538. mtd._read = flash_read;
  539. mtd._write = flash_write;
  540. mtd.owner = THIS_MODULE;
  541. #ifdef LART_DEBUG
  542. printk (KERN_DEBUG
  543. "mtd.name = %s\n"
  544. "mtd.size = 0x%.8x (%uM)\n"
  545. "mtd.erasesize = 0x%.8x (%uK)\n"
  546. "mtd.numeraseregions = %d\n",
  547. mtd.name,
  548. mtd.size,mtd.size / (1024*1024),
  549. mtd.erasesize,mtd.erasesize / 1024,
  550. mtd.numeraseregions);
  551. if (mtd.numeraseregions)
  552. for (result = 0; result < mtd.numeraseregions; result++)
  553. printk (KERN_DEBUG
  554. "\n\n"
  555. "mtd.eraseregions[%d].offset = 0x%.8x\n"
  556. "mtd.eraseregions[%d].erasesize = 0x%.8x (%uK)\n"
  557. "mtd.eraseregions[%d].numblocks = %d\n",
  558. result,mtd.eraseregions[result].offset,
  559. result,mtd.eraseregions[result].erasesize,mtd.eraseregions[result].erasesize / 1024,
  560. result,mtd.eraseregions[result].numblocks);
  561. printk ("\npartitions = %d\n", ARRAY_SIZE(lart_partitions));
  562. for (result = 0; result < ARRAY_SIZE(lart_partitions); result++)
  563. printk (KERN_DEBUG
  564. "\n\n"
  565. "lart_partitions[%d].name = %s\n"
  566. "lart_partitions[%d].offset = 0x%.8x\n"
  567. "lart_partitions[%d].size = 0x%.8x (%uK)\n",
  568. result,lart_partitions[result].name,
  569. result,lart_partitions[result].offset,
  570. result,lart_partitions[result].size,lart_partitions[result].size / 1024);
  571. #endif
  572. result = mtd_device_register(&mtd, lart_partitions,
  573. ARRAY_SIZE(lart_partitions));
  574. return (result);
  575. }
  576. static void __exit lart_flash_exit (void)
  577. {
  578. mtd_device_unregister(&mtd);
  579. }
  580. module_init (lart_flash_init);
  581. module_exit (lart_flash_exit);
  582. MODULE_LICENSE("GPL");
  583. MODULE_AUTHOR("Abraham vd Merwe <[email protected]>");
  584. MODULE_DESCRIPTION("MTD driver for Intel 28F160F3 on LART board");