sa1100-flash.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:23k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Flash memory access on SA11x0 based devices
  3.  * 
  4.  * (C) 2000 Nicolas Pitre <nico@cam.org>
  5.  * 
  6.  * $Id: sa1100-flash.c,v 1.26 2002/03/13 16:30:44 rmk Exp $
  7.  */
  8. #include <linux/config.h>
  9. #include <linux/module.h>
  10. #include <linux/types.h>
  11. #include <linux/ioport.h>
  12. #include <linux/kernel.h>
  13. #include <linux/mtd/mtd.h>
  14. #include <linux/mtd/map.h>
  15. #include <linux/mtd/partitions.h>
  16. #include <asm/hardware.h>
  17. #include <asm/io.h>
  18. #ifndef CONFIG_ARCH_SA1100
  19. #error This is for SA1100 architecture only
  20. #endif
  21. #define WINDOW_ADDR 0xe8000000
  22. static __u8 sa1100_read8(struct map_info *map, unsigned long ofs)
  23. {
  24. return readb(map->map_priv_1 + ofs);
  25. }
  26. static __u16 sa1100_read16(struct map_info *map, unsigned long ofs)
  27. {
  28. return readw(map->map_priv_1 + ofs);
  29. }
  30. static __u32 sa1100_read32(struct map_info *map, unsigned long ofs)
  31. {
  32. return readl(map->map_priv_1 + ofs);
  33. }
  34. static void sa1100_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
  35. {
  36. memcpy(to, (void *)(map->map_priv_1 + from), len);
  37. }
  38. static void sa1100_write8(struct map_info *map, __u8 d, unsigned long adr)
  39. {
  40. writeb(d, map->map_priv_1 + adr);
  41. }
  42. static void sa1100_write16(struct map_info *map, __u16 d, unsigned long adr)
  43. {
  44. writew(d, map->map_priv_1 + adr);
  45. }
  46. static void sa1100_write32(struct map_info *map, __u32 d, unsigned long adr)
  47. {
  48. writel(d, map->map_priv_1 + adr);
  49. }
  50. static void sa1100_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
  51. {
  52. memcpy((void *)(map->map_priv_1 + to), from, len);
  53. }
  54. static struct map_info sa1100_map = {
  55. name: "SA1100 flash",
  56. read8: sa1100_read8,
  57. read16: sa1100_read16,
  58. read32: sa1100_read32,
  59. copy_from: sa1100_copy_from,
  60. write8: sa1100_write8,
  61. write16: sa1100_write16,
  62. write32: sa1100_write32,
  63. copy_to: sa1100_copy_to,
  64. map_priv_1: WINDOW_ADDR,
  65. map_priv_2: -1,
  66. };
  67. /*
  68.  * Here are partition information for all known SA1100-based devices.
  69.  * See include/linux/mtd/partitions.h for definition of the mtd_partition
  70.  * structure.
  71.  *
  72.  * The *_max_flash_size is the maximum possible mapped flash size which
  73.  * is not necessarily the actual flash size.  It must be no more than
  74.  * the value specified in the "struct map_desc *_io_desc" mapping
  75.  * definition for the corresponding machine.
  76.  *
  77.  * Please keep these in alphabetical order, and formatted as per existing
  78.  * entries.  Thanks.
  79.  */
  80. #ifdef CONFIG_SA1100_ADSBITSY
  81. #define ADSBITSY_FLASH_SIZE 0x02000000
  82. static struct mtd_partition adsbitsy_partitions[] = {
  83. {
  84. name: "bootROM",
  85. size: 0x80000,
  86. offset: 0,
  87. mask_flags: MTD_WRITEABLE,  /* force read-only */
  88. }, {
  89. name: "zImage",
  90. size: 0x100000,
  91. offset: MTDPART_OFS_APPEND,
  92. mask_flags: MTD_WRITEABLE,  /* force read-only */
  93. }, {
  94. name: "ramdisk.gz",
  95. size: 0x300000,
  96. offset: MTDPART_OFS_APPEND,
  97. mask_flags: MTD_WRITEABLE,  /* force read-only */
  98. }, {
  99. name: "User FS",
  100. size: MTDPART_SIZ_FULL,
  101. offset: MTDPART_OFS_APPEND,
  102. }
  103. };
  104. #endif
  105. #ifdef CONFIG_SA1100_ASSABET
  106. /* Phase 4 Assabet has two 28F160B3 flash parts in bank 0: */
  107. #define ASSABET4_FLASH_SIZE 0x00400000
  108. static struct mtd_partition assabet4_partitions[] = {
  109. {
  110. name: "bootloader",
  111. size: 0x00020000,
  112. offset: 0,
  113. mask_flags: MTD_WRITEABLE,
  114. }, {
  115. name: "bootloader params",
  116. size: 0x00020000,
  117. offset: MTDPART_OFS_APPEND,
  118. mask_flags: MTD_WRITEABLE,
  119. }, {
  120. name: "jffs",
  121. size: MTDPART_SIZ_FULL,
  122. offset: MTDPART_OFS_APPEND,
  123. }
  124. };
  125. /* Phase 5 Assabet has two 28F128J3A flash parts in bank 0: */
  126. #define ASSABET5_FLASH_SIZE 0x02000000
  127. static struct mtd_partition assabet5_partitions[] = {
  128. {
  129. name: "bootloader",
  130. size: 0x00040000,
  131. offset: 0,
  132. mask_flags: MTD_WRITEABLE,
  133. }, {
  134. name: "bootloader params",
  135. size: 0x00040000,
  136. offset: MTDPART_OFS_APPEND,
  137. mask_flags: MTD_WRITEABLE,
  138. }, {
  139. name: "jffs",
  140. size: MTDPART_SIZ_FULL,
  141. offset: MTDPART_OFS_APPEND,
  142. }
  143. };
  144. #define ASSABET_FLASH_SIZE ASSABET5_FLASH_SIZE
  145. #define assabet_partitions assabet5_partitions
  146. #endif
  147. #ifdef CONFIG_SA1100_BADGE4
  148. /*
  149.  * 1 x Intel 28F320C3BA100 Advanced+ Boot Block Flash (32 Mi bit)
  150.  *   Eight 4 KiW Parameter Bottom Blocks (64 KiB)
  151.  *   Sixty-three 32 KiW Main Blocks (4032 Ki b)
  152.  */
  153. #define BADGE4_FLASH_SIZE 0x00400000
  154. static struct mtd_partition badge4_partitions[] = {
  155. {
  156. name: "BLOB boot loader",
  157. offset: 0,
  158. size: 0x0000A000
  159. }, {
  160. name: "params",
  161. offset: MTDPART_OFS_APPEND,
  162. size: 0x00006000
  163. }, {
  164. name: "kernel",
  165. offset: MTDPART_OFS_APPEND,
  166. size: 0x00100000
  167. }, {
  168. name: "root",
  169. offset: MTDPART_OFS_APPEND,
  170. size: MTDPART_SIZ_FULL
  171. }
  172. };
  173. #endif
  174. #ifdef CONFIG_SA1100_CERF
  175. #ifdef CONFIG_SA1100_CERF_FLASH_32MB
  176. #define CERF_FLASH_SIZE 0x02000000
  177. static struct mtd_partition cerf_partitions[] = {
  178. {
  179. name: "firmware",
  180. size: 0x00040000,
  181. offset: 0,
  182. }, {
  183. name: "params",
  184. size: 0x00040000,
  185. offset: 0x00040000,
  186. }, {
  187. name: "kernel",
  188. size: 0x00100000,
  189. offset: 0x00080000,
  190. }, {
  191. name: "rootdisk",
  192. size: 0x01E80000,
  193. offset: 0x00180000,
  194. }
  195. };
  196. #elif defined CONFIG_SA1100_CERF_FLASH_16MB
  197. #define CERF_FLASH_SIZE 0x01000000
  198. static struct mtd_partition cerf_partitions[] = {
  199. {
  200. name: "firmware",
  201. size: 0x00020000,
  202. offset: 0,
  203. }, {
  204. name: "params",
  205. size: 0x00020000,
  206. offset: 0x00020000,
  207. }, {
  208. name: "kernel",
  209. size: 0x00100000,
  210. offset: 0x00040000,
  211. }, {
  212. name: "rootdisk",
  213. size: 0x00EC0000,
  214. offset: 0x00140000,
  215. }
  216. };
  217. #elif defined CONFIG_SA1100_CERF_FLASH_8MB
  218. #   error "Unwritten type definition"
  219. #else
  220. #   error "Undefined memory orientation for CERF in sa1100-flash.c"
  221. #endif
  222. #endif
  223. #ifdef CONFIG_SA1100_CONSUS
  224. #define CONSUS_FLASH_SIZE 0x02000000
  225. static struct mtd_partition consus_partitions[] = {
  226. {
  227. name: "Consus boot firmware",
  228. offset: 0,
  229. size: 0x00040000,
  230. mask_flags: MTD_WRITABLE, /* force read-only */
  231. }, {
  232. name: "Consus kernel",
  233. offset: 0x00040000,
  234. size: 0x00100000,
  235. mask_flags: 0,
  236. }, {
  237. name: "Consus disk",
  238. offset: 0x00140000,
  239. /* The rest (up to 16M) for jffs.  We could put 0 and
  240.    make it find the size automatically, but right now
  241.    i have 32 megs.  jffs will use all 32 megs if given
  242.    the chance, and this leads to horrible problems
  243.    when you try to re-flash the image because blob
  244.    won't erase the whole partition. */
  245. size: 0x01000000 - 0x00140000,
  246. mask_flags: 0,
  247. }, {
  248. /* this disk is a secondary disk, which can be used as
  249.    needed, for simplicity, make it the size of the other
  250.    consus partition, although realistically it could be
  251.    the remainder of the disk (depending on the file
  252.    system used) */
  253.  name: "Consus disk2",
  254.  offset: 0x01000000,
  255.  size: 0x01000000 - 0x00140000,
  256.  mask_flags: 0,
  257. }
  258. };
  259. #endif
  260. #ifdef CONFIG_SA1100_FLEXANET
  261. /* Flexanet has two 28F128J3A flash parts in bank 0: */
  262. #define FLEXANET_FLASH_SIZE 0x02000000
  263. static struct mtd_partition flexanet_partitions[] = {
  264. {
  265. name: "bootloader",
  266. size: 0x00040000,
  267. offset: 0,
  268. mask_flags: MTD_WRITEABLE,
  269. }, {
  270. name: "bootloader params",
  271. size: 0x00040000,
  272. offset: MTDPART_OFS_APPEND,
  273. mask_flags: MTD_WRITEABLE,
  274. }, {
  275. name: "kernel",
  276. size: 0x000C0000,
  277. offset: MTDPART_OFS_APPEND,
  278. mask_flags: MTD_WRITEABLE,
  279. }, {
  280. name: "altkernel",
  281. size: 0x000C0000,
  282. offset: MTDPART_OFS_APPEND,
  283. mask_flags: MTD_WRITEABLE,
  284. }, {
  285. name: "root",
  286. size: 0x00400000,
  287. offset: MTDPART_OFS_APPEND,
  288. mask_flags: MTD_WRITEABLE,
  289. }, {
  290. name: "free1",
  291. size: 0x00300000,
  292. offset: MTDPART_OFS_APPEND,
  293. mask_flags: MTD_WRITEABLE,
  294. }, {
  295. name: "free2",
  296. size: 0x00300000,
  297. offset: MTDPART_OFS_APPEND,
  298. mask_flags: MTD_WRITEABLE,
  299. }, {
  300. name: "free3",
  301. size: MTDPART_SIZ_FULL,
  302. offset: MTDPART_OFS_APPEND,
  303. mask_flags: MTD_WRITEABLE,
  304. }
  305. };
  306. #endif
  307. #ifdef CONFIG_SA1100_FREEBIRD
  308. #define FREEBIRD_FLASH_SIZE 0x02000000
  309. static struct mtd_partition freebird_partitions[] = {
  310. #if CONFIG_SA1100_FREEBIRD_NEW
  311. {
  312. name: "firmware",
  313. size: 0x00040000,
  314. offset: 0,
  315. mask_flags: MTD_WRITEABLE,  /* force read-only */
  316. }, {
  317. name: "kernel",
  318. size: 0x00080000,
  319. offset: 0x00040000,
  320. }, {
  321. name: "params",
  322. size: 0x00040000,
  323. offset: 0x000C0000,
  324. }, {
  325. name: "initrd",
  326. size: 0x00100000,
  327. offset: 0x00100000,
  328. }, {
  329. name: "root cramfs",
  330. size: 0x00300000,
  331. offset: 0x00200000,
  332. }, {
  333. name: "usr cramfs",
  334. size: 0x00C00000,
  335. offset: 0x00500000,
  336. }, {
  337. name: "local",
  338. size: MTDPART_SIZ_FULL,
  339. offset: 0x01100000,
  340. }
  341. #else
  342. {
  343. size: 0x00040000,
  344. offset: 0,
  345. }, {
  346. size: 0x000c0000,
  347. offset: MTDPART_OFS_APPEND,
  348. }, {
  349. size: 0x00400000,
  350. offset: MTDPART_OFS_APPEND,
  351. }, {
  352. size: MTDPART_SIZ_FULL,
  353. offset: MTDPART_OFS_APPEND,
  354. }
  355. #endif
  356. };
  357. #endif
  358. #ifdef CONFIG_SA1100_FRODO
  359. /* Frodo has 2 x 16M 28F128J3A flash chips in bank 0: */
  360. #define FRODO_FLASH_SIZE 0x02000000
  361. static struct mtd_partition frodo_partitions[] =
  362. {
  363. {
  364. name: "bootloader",
  365. size: 0x00040000,
  366. offset: 0x00000000,
  367. mask_flags: MTD_WRITEABLE
  368. }, {
  369. name: "bootloader params",
  370. size: 0x00040000,
  371. offset: MTDPART_OFS_APPEND,
  372. mask_flags: MTD_WRITEABLE
  373. }, {
  374. name: "kernel",
  375. size: 0x00100000,
  376. offset: MTDPART_OFS_APPEND,
  377. mask_flags: MTD_WRITEABLE
  378. }, {
  379. name: "ramdisk",
  380. size: 0x00400000,
  381. offset: MTDPART_OFS_APPEND,
  382. mask_flags: MTD_WRITEABLE
  383. }, {
  384. name: "file system",
  385. size: MTDPART_SIZ_FULL,
  386. offset: MTDPART_OFS_APPEND
  387. }
  388. };
  389. #endif
  390. #ifdef CONFIG_SA1100_GRAPHICSCLIENT
  391. #define GRAPHICSCLIENT_FLASH_SIZE 0x02000000
  392. static struct mtd_partition graphicsclient_partitions[] = {
  393. {
  394. name: "zImage",
  395. size: 0x100000,
  396. offset: 0,
  397. mask_flags: MTD_WRITEABLE,  /* force read-only */
  398. }, {
  399. name: "ramdisk.gz",
  400. size: 0x300000,
  401. offset: MTDPART_OFS_APPEND,
  402. mask_flags: MTD_WRITEABLE,  /* force read-only */
  403. }, {
  404. name: "User FS",
  405. size: MTDPART_SIZ_FULL,
  406. offset: MTDPART_OFS_APPEND,
  407. }
  408. };
  409. #endif
  410. #ifdef CONFIG_SA1100_GRAPHICSMASTER
  411. #define GRAPHICSMASTER_FLASH_SIZE 0x01000000
  412. static struct mtd_partition graphicsmaster_partitions[] = {
  413. {
  414. name: "zImage",
  415. size: 0x100000,
  416. offset: 0,
  417. mask_flags: MTD_WRITEABLE,  /* force read-only */
  418. },
  419. {
  420. name: "ramdisk.gz",
  421. size: 0x300000,
  422. offset: MTDPART_OFS_APPEND,
  423. mask_flags: MTD_WRITEABLE,  /* force read-only */
  424. },
  425. {
  426. name: "User FS",
  427. size: MTDPART_SIZ_FULL,
  428. offset: MTDPART_OFS_APPEND,
  429. }
  430. };
  431. #endif
  432. #ifdef CONFIG_SA1100_H3600
  433. #define H3600_FLASH_SIZE 0x02000000
  434. static struct mtd_partition h3600_partitions[] = {
  435. {
  436. name: "H3600 boot firmware",
  437. size: 0x00040000,
  438. offset: 0,
  439. mask_flags: MTD_WRITEABLE,  /* force read-only */
  440. }, {
  441. name: "H3600 kernel",
  442. size: 0x00080000,
  443. offset: 0x00040000,
  444. }, {
  445. name: "H3600 params",
  446. size: 0x00040000,
  447. offset: 0x000C0000,
  448. }, {
  449. #ifdef CONFIG_JFFS2_FS
  450. name: "H3600 root jffs2",
  451. size: MTDPART_SIZ_FULL,
  452. offset: 0x00100000,
  453. #else
  454. name: "H3600 initrd",
  455. size: 0x00100000,
  456. offset: 0x00100000,
  457. }, {
  458. name: "H3600 root cramfs",
  459. size: 0x00300000,
  460. offset: 0x00200000,
  461. }, {
  462. name: "H3600 usr cramfs",
  463. size: 0x00800000,
  464. offset: 0x00500000,
  465. }, {
  466. name: "H3600 usr local",
  467. size: MTDPART_SIZ_FULL,
  468. offset: 0x00d00000,
  469. #endif
  470. }
  471. };
  472. static void h3600_set_vpp(struct map_info *map, int vpp)
  473. {
  474. assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, vpp);
  475. }
  476. #endif
  477. #ifdef CONFIG_SA1100_HUW_WEBPANEL
  478. #define HUW_WEBPANEL_FLASH_SIZE 0x01000000
  479. static struct mtd_partition huw_webpanel_partitions[] = {
  480. {
  481. name: "Loader",
  482. size: 0x00040000,
  483. offset: 0,
  484. }, {
  485. name: "Sector 1",
  486. size: 0x00040000,
  487. offset: MTDPART_OFS_APPEND,
  488. }, {
  489. size: MTDPART_SIZ_FULL,
  490. offset: MTDPART_OFS_APPEND,
  491. }
  492. };
  493. #endif
  494. #ifdef CONFIG_SA1100_JORNADA720
  495. #define JORNADA720_FLASH_SIZE 0x02000000
  496. static struct mtd_partition jornada720_partitions[] = {
  497. {
  498. name: "JORNADA720 boot firmware",
  499. size: 0x00040000,
  500. offset: 0,
  501. mask_flags: MTD_WRITEABLE,  /* force read-only */
  502. }, {
  503. name: "JORNADA720 kernel",
  504. size: 0x000c0000,
  505. offset: 0x00040000,
  506. }, {
  507. name: "JORNADA720 params",
  508. size: 0x00040000,
  509. offset: 0x00100000,
  510. }, {
  511. name: "JORNADA720 initrd",
  512. size: 0x00100000,
  513. offset: 0x00140000,
  514. }, {
  515. name: "JORNADA720 root cramfs",
  516. size: 0x00300000,
  517. offset: 0x00240000,
  518. }, {
  519. name: "JORNADA720 usr cramfs",
  520. size: 0x00800000,
  521. offset: 0x00540000,
  522. }, {
  523. name: "JORNADA720 usr local",
  524. size: 0  /* will expand to the end of the flash */
  525. offset: 0x00d00000,
  526. }
  527. };
  528. static void jornada720_set_vpp(int vpp)
  529. {
  530. if (vpp)
  531. PPSR |= 0x80;
  532. else
  533. PPSR &= ~0x80;
  534. PPDR |= 0x80;
  535. }
  536. #endif
  537. #ifdef CONFIG_SA1100_PANGOLIN
  538. #define PANGOLIN_FLASH_SIZE 0x04000000
  539. static struct mtd_partition pangolin_partitions[] = {
  540. {
  541. name: "boot firmware",
  542. size: 0x00080000,
  543. offset: 0x00000000,
  544. mask_flags: MTD_WRITEABLE,  /* force read-only */
  545. }, {
  546. name: "kernel",
  547. size: 0x00100000,
  548. offset: 0x00080000,
  549. }, {
  550. name: "initrd",
  551. size: 0x00280000,
  552. offset: 0x00180000,
  553. }, {
  554. name: "initrd-test",
  555. size: 0x03C00000,
  556. offset: 0x00400000,
  557. }
  558. };
  559. #endif
  560. #ifdef CONFIG_SA1100_PT_SYSTEM3
  561. /* erase size is 0x40000 == 256k partitions have to have this boundary */
  562. #define SYSTEM3_FLASH_SIZE 0x01000000
  563. static struct mtd_partition system3_partitions[] = {
  564. {
  565. name: "BLOB",
  566. size: 0x00040000,
  567. offset: 0x00000000,
  568. mask_flags: MTD_WRITEABLE,  /* force read-only */
  569. }, {
  570. name: "config",
  571. size: 0x00040000,
  572. offset: MTDPART_OFS_APPEND,
  573. }, {
  574. name: "kernel",
  575. size: 0x00100000,
  576. offset: MTDPART_OFS_APPEND,
  577. }, {
  578. name: "root",
  579. size: MTDPART_SIZ_FULL,
  580. offset: MTDPART_OFS_APPEND,
  581. }
  582. };
  583. #endif
  584. #ifdef CONFIG_SA1100_SHANNON
  585. #define SHANNON_FLASH_SIZE 0x00400000
  586. static struct mtd_partition shannon_partitions[] = {
  587. {
  588. name: "BLOB boot loader",
  589. offset: 0,
  590. size: 0x20000
  591. },
  592. {
  593. name: "kernel",
  594. offset: MTDPART_OFS_APPEND,
  595. size: 0xe0000
  596. },
  597. name: "initrd",
  598. offset: MTDPART_OFS_APPEND,
  599. size: MTDPART_SIZ_FULL
  600. }
  601. };
  602. #endif
  603. #ifdef CONFIG_SA1100_SHERMAN
  604. #define SHERMAN_FLASH_SIZE 0x02000000
  605. static struct mtd_partition sherman_partitions[] = {
  606. {
  607. size: 0x50000,
  608. offset: 0,
  609. }, {
  610. size: 0x70000,
  611. offset: MTDPART_OFS_APPEND,
  612. }, {
  613. size: 0x600000,
  614. offset: MTDPART_OFS_APPEND,
  615. }, {
  616. size: 0xA0000,
  617. offset: MTDPART_OFS_APPEND,
  618. }
  619. };
  620. #endif
  621. #ifdef CONFIG_SA1100_SIMPAD
  622. #define SIMPAD_FLASH_SIZE 0x02000000
  623. static struct mtd_partition simpad_partitions[] = {
  624. {
  625. name: "SIMpad boot firmware",
  626. size: 0x00080000,
  627. offset: 0,
  628. mask_flags: MTD_WRITEABLE,  /* force read-only */
  629. }, {
  630. name: "SIMpad kernel",
  631. size: 0x00100000,
  632. offset: 0x00080000,
  633. }, {
  634. #ifdef CONFIG_JFFS2_FS
  635. name: "SIMpad root jffs2",
  636. size: MTDPART_SIZ_FULL,
  637. offset: 0x00180000,
  638. #else
  639. name: "SIMpad initrd",
  640. size: 0x00300000,
  641. offset: 0x00180000,
  642. }, {
  643. name: "SIMpad root cramfs",
  644. size: 0x00300000,
  645. offset: 0x00480000,
  646. }, {
  647. name: "SIMpad usr cramfs",
  648. size: 0x005c0000,
  649. offset: 0x00780000,
  650. }, {
  651. name: "SIMpad usr local",
  652. size: MTDPART_SIZ_FULL,
  653. offset: 0x00d40000,
  654. #endif
  655. }
  656. };
  657. #endif /* CONFIG_SA1100_SIMPAD */
  658. #ifdef CONFIG_SA1100_STORK
  659. #define STORK_FLASH_SIZE 0x02000000
  660. static struct mtd_partition stork_partitions[] = {
  661. {
  662. name: "STORK boot firmware",
  663. size: 0x00040000,
  664. offset: 0,
  665. mask_flags: MTD_WRITEABLE,  /* force read-only */
  666. }, {
  667. name: "STORK params",
  668. size: 0x00040000,
  669. offset: 0x00040000,
  670. }, {
  671. name: "STORK kernel",
  672. size: 0x00100000,
  673. offset: 0x00080000,
  674. }, {
  675. #ifdef CONFIG_JFFS2_FS
  676. name: "STORK root jffs2",
  677. offset: 0x00180000,
  678. size: MTDPART_SIZ_FULL,
  679. #else
  680. name: "STORK initrd",
  681. size: 0x00100000,
  682. offset: 0x00180000,
  683. }, {
  684. name: "STORK root cramfs",
  685. size: 0x00300000,
  686. offset: 0x00280000,
  687. }, {
  688. name: "STORK usr cramfs",
  689. size: 0x00800000,
  690. offset: 0x00580000,
  691. }, {
  692. name: "STORK usr local",
  693. offset: 0x00d80000,
  694. size: MTDPART_SIZ_FULL,
  695. #endif
  696. }
  697. };
  698. #endif
  699. #ifdef CONFIG_SA1100_YOPY
  700. #define YOPY_FLASH_SIZE 0x08000000
  701. static struct mtd_partition yopy_partitions[] = {
  702. {
  703. name: "boot firmware",
  704. size: 0x00040000,
  705. offset: 0x00000000,
  706. mask_flags: MTD_WRITEABLE,  /* force read-only */
  707. }, {
  708. name: "kernel",
  709. size: 0x00080000,
  710. offset: 0x00080000,
  711. }, {
  712. name: "initrd",
  713. size: 0x00300000,
  714. offset: 0x00100000,
  715. }, {
  716. name: "root",
  717. size: 0x01000000,
  718. offset: 0x00400000,
  719. }
  720. };
  721. #endif
  722. extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts);
  723. extern int parse_bootldr_partitions(struct mtd_info *master, struct mtd_partition **pparts);
  724. static struct mtd_partition *parsed_parts;
  725. static struct mtd_info *mymtd;
  726. int __init sa1100_mtd_init(void)
  727. {
  728. struct mtd_partition *parts;
  729. int nb_parts = 0, ret;
  730. int parsed_nr_parts = 0;
  731. const char *part_type;
  732. unsigned long base = -1UL;
  733. /* Default flash buswidth */
  734. sa1100_map.buswidth = (MSC0 & MSC_RBW) ? 2 : 4;
  735. /*
  736.  * Static partition definition selection
  737.  */
  738. part_type = "static";
  739. #ifdef CONFIG_SA1100_ADSBITSY
  740. if (machine_is_adsbitsy()) {
  741. parts = adsbitsy_partitions;
  742. nb_parts = ARRAY_SIZE(adsbitsy_partitions);
  743. sa1100_map.size = ADSBITSY_FLASH_SIZE;
  744. sa1100_map.buswidth = (MSC1 & MSC_RBW) ? 2 : 4;
  745. }
  746. #endif
  747. #ifdef CONFIG_SA1100_ASSABET
  748. if (machine_is_assabet()) {
  749. parts = assabet_partitions;
  750. nb_parts = ARRAY_SIZE(assabet_partitions);
  751. sa1100_map.size = ASSABET_FLASH_SIZE;
  752. }
  753. #endif
  754. #ifdef CONFIG_SA1100_BADGE4
  755. if (machine_is_badge4()) {
  756. parts = badge4_partitions;
  757. nb_parts = ARRAY_SIZE(badge4_partitions);
  758. sa1100_map.size = BADGE4_FLASH_SIZE;
  759. }
  760. #endif
  761. #ifdef CONFIG_SA1100_CERF
  762. if (machine_is_cerf()) {
  763. parts = cerf_partitions;
  764. nb_parts = ARRAY_SIZE(cerf_partitions);
  765. sa1100_map.size = CERF_FLASH_SIZE;
  766. }
  767. #endif
  768. #ifdef CONFIG_SA1100_CONSUS
  769. if (machine_is_consus()) {
  770. parts = consus_partitions;
  771. nb_parts = ARRAY_SIZE(consus_partitions);
  772. sa1100_map.size = CONSUS_FLASH_SIZE;
  773. }
  774. #endif
  775. #ifdef CONFIG_SA1100_FLEXANET
  776. if (machine_is_flexanet()) {
  777. parts = flexanet_partitions;
  778. nb_parts = ARRAY_SIZE(flexanet_partitions);
  779. sa1100_map.size = FLEXANET_FLASH_SIZE;
  780. }
  781. #endif
  782. #ifdef CONFIG_SA1100_FREEBIRD
  783. if (machine_is_freebird()) {
  784. parts = freebird_partitions;
  785. nb_parts = ARRAY_SIZE(freebird_partitions);
  786. sa1100_map.size = FREEBIRD_FLASH_SIZE;
  787. }
  788. #endif
  789. #ifdef CONFIG_SA1100_FRODO
  790. if (machine_is_frodo()) {
  791. parts = frodo_partitions;
  792. nb_parts = ARRAY_SIZE(frodo_partitions);
  793. sa1100_map.size = FRODO_FLASH_SIZE;
  794. base = 0x00000000;
  795. }
  796. #ifdef CONFIG_SA1100_GRAPHICSCLIENT
  797. if (machine_is_graphicsclient()) {
  798. parts = graphicsclient_partitions;
  799. nb_parts = ARRAY_SIZE(graphicsclient_partitions);
  800. sa1100_map.size = GRAPHICSCLIENT_FLASH_SIZE;
  801. sa1100_map.buswidth = (MSC1 & MSC_RBW) ? 2:4;
  802. }
  803. #endif
  804. #ifdef CONFIG_SA1100_GRAPHICSMASTER
  805. if (machine_is_graphicsmaster()) {
  806. parts = graphicsmaster_partitions;
  807. nb_parts = ARRAY_SIZE(graphicsmaster_partitions);
  808. sa1100_map.size = GRAPHICSMASTER_FLASH_SIZE;
  809. sa1100_map.buswidth = (MSC1 & MSC_RBW) ? 2:4;
  810. }
  811. #endif
  812. #ifdef CONFIG_SA1100_H3600
  813. if (machine_is_h3600()) {
  814. parts = h3600_partitions;
  815. nb_parts = ARRAY_SIZE(h3600_partitions);
  816. sa1100_map.size = H3600_FLASH_SIZE;
  817. sa1100_map.set_vpp = h3600_set_vpp;
  818. }
  819. #endif
  820. #ifdef CONFIG_SA1100_HUW_WEBPANEL
  821. if (machine_is_huw_webpanel()) {
  822. parts = huw_webpanel_partitions;
  823. nb_parts = ARRAY_SIZE(huw_webpanel_partitions);
  824. sa1100_map.size = HUW_WEBPANEL_FLASH_SIZE;
  825. }
  826. #endif
  827. #ifdef CONFIG_SA1100_JORNADA720
  828. if (machine_is_jornada720()) {
  829. parts = jornada720_partitions;
  830. nb_parts = ARRAY_SIZE(jornada720_partitions);
  831. sa1100_map.size = JORNADA720_FLASH_SIZE;
  832. sa1100_map.set_vpp = jornada720_set_vpp;
  833. }
  834. #endif
  835. #ifdef CONFIG_SA1100_PANGOLIN
  836. if (machine_is_pangolin()) {
  837. parts = pangolin_partitions;
  838. nb_parts = ARRAY_SIZE(pangolin_partitions);
  839. sa1100_map.size = PANGOLIN_FLASH_SIZE;
  840. }
  841. #endif
  842. #ifdef CONFIG_SA1100_PT_SYSTEM3
  843. if (machine_is_pt_system3()) {
  844. parts = system3_partitions;
  845. nb_parts = ARRAY_SIZE(system3_partitions);
  846. sa1100_map.size = SYSTEM3_FLASH_SIZE;
  847. }
  848. #endif
  849. #ifdef CONFIG_SA1100_SHANNON
  850. if (machine_is_shannon()) {
  851. parts = shannon_partitions;
  852. nb_parts = ARRAY_SIZE(shannon_partitions);
  853. sa1100_map.size = SHANNON_FLASH_SIZE;
  854. }
  855. #endif
  856. #ifdef CONFIG_SA1100_SHERMAN
  857. if (machine_is_sherman()) {
  858. parts = sherman_partitions;
  859. nb_parts = ARRAY_SIZE(sherman_partitions);
  860. sa1100_map.size = SHERMAN_FLASH_SIZE;
  861. }
  862. #endif
  863. #ifdef CONFIG_SA1100_SIMPAD
  864. if (machine_is_simpad()) {
  865. parts = simpad_partitions;
  866. nb_parts = ARRAY_SIZE(simpad_partitions);
  867. sa1100_map.size = SIMPAD_FLASH_SIZE;
  868. }
  869. #endif
  870. #ifdef CONFIG_SA1100_STORK
  871. if (machine_is_stork()) {
  872. parts = stork_partitions;
  873. nb_parts = ARRAY_SIZE(stork_partitions);
  874. sa1100_map.size = STORK_FLASH_SIZE;
  875. }
  876. #endif
  877. #ifdef CONFIG_SA1100_YOPY
  878. if (machine_is_yopy()) {
  879. parts = yopy_partitions;
  880. nb_parts = ARRAY_SIZE(yopy_partitions);
  881. sa1100_map.size = YOPY_FLASH_SIZE;
  882. }
  883. #endif
  884. /*
  885.  * For simple flash devices, use ioremap to map the flash.
  886.  */
  887. if (base != (unsigned long)-1) {
  888. if (!request_mem_region(base, sa1100_map.size, "flash"))
  889. return -EBUSY;
  890. sa1100_map.map_priv_2 = base;
  891. sa1100_map.map_priv_1 = (unsigned long)
  892. ioremap(base, sa1100_map.size);
  893. ret = -ENOMEM;
  894. if (!sa1100_map.map_priv_1)
  895. goto out_err;
  896. }
  897. /*
  898.  * Now let's probe for the actual flash.  Do it here since
  899.  * specific machine settings might have been set above.
  900.  */
  901. printk(KERN_NOTICE "SA1100 flash: probing %d-bit flash busn", sa1100_map.buswidth*8);
  902. mymtd = do_map_probe("cfi_probe", &sa1100_map);
  903. ret = -ENXIO;
  904. if (!mymtd)
  905. goto out_err;
  906. mymtd->module = THIS_MODULE;
  907. /*
  908.  * Dynamic partition selection stuff (might override the static ones)
  909.  */
  910. #ifdef CONFIG_MTD_REDBOOT_PARTS
  911. if (parsed_nr_parts == 0) {
  912. int ret = parse_redboot_partitions(mymtd, &parsed_parts);
  913. if (ret > 0) {
  914. part_type = "RedBoot";
  915. parsed_nr_parts = ret;
  916. }
  917. }
  918. #endif
  919. #ifdef CONFIG_MTD_BOOTLDR_PARTS
  920. if (parsed_nr_parts == 0) {
  921. int ret = parse_bootldr_partitions(mymtd, &parsed_parts);
  922. if (ret > 0) {
  923. part_type = "Compaq bootldr";
  924. parsed_nr_parts = ret;
  925. }
  926. }
  927. #endif
  928. if (parsed_nr_parts > 0) {
  929. parts = parsed_parts;
  930. nb_parts = parsed_nr_parts;
  931. }
  932. if (nb_parts == 0) {
  933. printk(KERN_NOTICE "SA1100 flash: no partition info available, registering whole flash at oncen");
  934. add_mtd_device(mymtd);
  935. } else {
  936. printk(KERN_NOTICE "Using %s partition definitionn", part_type);
  937. add_mtd_partitions(mymtd, parts, nb_parts);
  938. }
  939. return 0;
  940.  out_err:
  941. if (sa1100_map.map_priv_2 != -1) {
  942. iounmap((void *)sa1100_map.map_priv_1);
  943. release_mem_region(sa1100_map.map_priv_2, sa1100_map.size);
  944. }
  945. return ret;
  946. }
  947. static void __exit sa1100_mtd_cleanup(void)
  948. {
  949. if (mymtd) {
  950. del_mtd_partitions(mymtd);
  951. map_destroy(mymtd);
  952. if (parsed_parts)
  953. kfree(parsed_parts);
  954. }
  955. if (sa1100_map.map_priv_2 != -1) {
  956. iounmap((void *)sa1100_map.map_priv_1);
  957. release_mem_region(sa1100_map.map_priv_2, sa1100_map.size);
  958. }
  959. }
  960. module_init(sa1100_mtd_init);
  961. module_exit(sa1100_mtd_cleanup);
  962. MODULE_AUTHOR("Nicolas Pitre");
  963. MODULE_DESCRIPTION("SA1100 CFI map driver");
  964. MODULE_LICENSE("GPL");