pb1xxx-flash.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * Flash memory access on Alchemy Pb1xxx boards
  3. *
  4. * (C) 2001 Pete Popov <ppopov@mvista.com>
  5. *
  6. * $Id: pb1xxx-flash.c,v 1.14 2004/11/04 13:24:15 gleixner Exp $
  7. */
  8. #include <linux/config.h>
  9. #include <linux/module.h>
  10. #include <linux/types.h>
  11. #include <linux/init.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/io.h>
  17. #ifdef DEBUG_RW
  18. #define DBG(x...) printk(x)
  19. #else
  20. #define DBG(x...)
  21. #endif
  22. #ifdef CONFIG_MIPS_PB1000
  23. #define WINDOW_ADDR 0x1F800000
  24. #define WINDOW_SIZE 0x800000
  25. static struct mtd_partition pb1xxx_partitions[] = {
  26. {
  27. .name = "yamon env",
  28. .size = 0x00020000,
  29. .offset = 0,
  30. .mask_flags = MTD_WRITEABLE},
  31. {
  32. .name = "User FS",
  33. .size = 0x003e0000,
  34. .offset = 0x20000,},
  35. {
  36. .name = "boot code",
  37. .size = 0x100000,
  38. .offset = 0x400000,
  39. .mask_flags = MTD_WRITEABLE},
  40. {
  41. .name = "raw/kernel",
  42. .size = 0x300000,
  43. .offset = 0x500000}
  44. };
  45. #elif defined(CONFIG_MIPS_PB1500) || defined(CONFIG_MIPS_PB1100)
  46. #if defined(CONFIG_MTD_PB1500_BOOT) && defined(CONFIG_MTD_PB1500_USER)
  47. /* both 32MB banks will be used. Combine the first 32MB bank and the
  48. * first 28MB of the second bank together into a single jffs/jffs2
  49. * partition.
  50. */
  51. #define WINDOW_ADDR 0x1C000000
  52. #define WINDOW_SIZE 0x4000000
  53. static struct mtd_partition pb1xxx_partitions[] = {
  54. {
  55. .name = "User FS",
  56. .size = 0x3c00000,
  57. .offset = 0x0000000
  58. },{
  59. .name = "yamon",
  60. .size = 0x0100000,
  61. .offset = 0x3c00000,
  62. .mask_flags = MTD_WRITEABLE
  63. },{
  64. .name = "raw kernel",
  65. .size = 0x02c0000,
  66. .offset = 0x3d00000
  67. }
  68. };
  69. #elif defined(CONFIG_MTD_PB1500_BOOT) && !defined(CONFIG_MTD_PB1500_USER)
  70. #define WINDOW_ADDR 0x1E000000
  71. #define WINDOW_SIZE 0x2000000
  72. static struct mtd_partition pb1xxx_partitions[] = {
  73. {
  74. .name = "User FS",
  75. .size = 0x1c00000,
  76. .offset = 0x0000000
  77. },{
  78. .name = "yamon",
  79. .size = 0x0100000,
  80. .offset = 0x1c00000,
  81. .mask_flags = MTD_WRITEABLE
  82. },{
  83. .name = "raw kernel",
  84. .size = 0x02c0000,
  85. .offset = 0x1d00000
  86. }
  87. };
  88. #elif !defined(CONFIG_MTD_PB1500_BOOT) && defined(CONFIG_MTD_PB1500_USER)
  89. #define WINDOW_ADDR 0x1C000000
  90. #define WINDOW_SIZE 0x2000000
  91. static struct mtd_partition pb1xxx_partitions[] = {
  92. {
  93. .name = "User FS",
  94. .size = 0x1e00000,
  95. .offset = 0x0000000
  96. },{
  97. .name = "raw kernel",
  98. .size = 0x0200000,
  99. .offset = 0x1e00000,
  100. }
  101. };
  102. #else
  103. #error MTD_PB1500 define combo error /* should never happen */
  104. #endif
  105. #else
  106. #error Unsupported board
  107. #endif
  108. #define NAME "Pb1x00 Linux Flash"
  109. #define PADDR WINDOW_ADDR
  110. #define BUSWIDTH 4
  111. #define SIZE WINDOW_SIZE
  112. #define PARTITIONS 4
  113. static struct map_info pb1xxx_mtd_map = {
  114. .name = NAME,
  115. .size = SIZE,
  116. .bankwidth = BUSWIDTH,
  117. .phys = PADDR,
  118. };
  119. static struct mtd_info *pb1xxx_mtd;
  120. int __init pb1xxx_mtd_init(void)
  121. {
  122. struct mtd_partition *parts;
  123. int nb_parts = 0;
  124. char *part_type;
  125. /*
  126. * Static partition definition selection
  127. */
  128. part_type = "static";
  129. parts = pb1xxx_partitions;
  130. nb_parts = ARRAY_SIZE(pb1xxx_partitions);
  131. /*
  132. * Now let's probe for the actual flash. Do it here since
  133. * specific machine settings might have been set above.
  134. */
  135. printk(KERN_NOTICE "Pb1xxx flash: probing %d-bit flash bus\n",
  136. BUSWIDTH*8);
  137. pb1xxx_mtd_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
  138. simple_map_init(&pb1xxx_mtd_map);
  139. pb1xxx_mtd = do_map_probe("cfi_probe", &pb1xxx_mtd_map);
  140. if (!pb1xxx_mtd) return -ENXIO;
  141. pb1xxx_mtd->owner = THIS_MODULE;
  142. add_mtd_partitions(pb1xxx_mtd, parts, nb_parts);
  143. return 0;
  144. }
  145. static void __exit pb1xxx_mtd_cleanup(void)
  146. {
  147. if (pb1xxx_mtd) {
  148. del_mtd_partitions(pb1xxx_mtd);
  149. map_destroy(pb1xxx_mtd);
  150. iounmap((void *) pb1xxx_mtd_map.virt);
  151. }
  152. }
  153. module_init(pb1xxx_mtd_init);
  154. module_exit(pb1xxx_mtd_cleanup);
  155. MODULE_AUTHOR("Pete Popov");
  156. MODULE_DESCRIPTION("Pb1xxx CFI map driver");
  157. MODULE_LICENSE("GPL");