alchemy-flash.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Flash memory access on AMD Alchemy evaluation boards
  3. *
  4. * (C) 2003, 2004 Pete Popov <ppopov@embeddedalley.com>
  5. */
  6. #include <linux/init.h>
  7. #include <linux/module.h>
  8. #include <linux/types.h>
  9. #include <linux/kernel.h>
  10. #include <linux/mtd/mtd.h>
  11. #include <linux/mtd/map.h>
  12. #include <linux/mtd/partitions.h>
  13. #include <asm/io.h>
  14. #ifdef CONFIG_MIPS_PB1000
  15. #define BOARD_MAP_NAME "Pb1000 Flash"
  16. #define BOARD_FLASH_SIZE 0x00800000 /* 8MB */
  17. #define BOARD_FLASH_WIDTH 4 /* 32-bits */
  18. #endif
  19. #ifdef CONFIG_MIPS_PB1500
  20. #define BOARD_MAP_NAME "Pb1500 Flash"
  21. #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
  22. #define BOARD_FLASH_WIDTH 4 /* 32-bits */
  23. #endif
  24. #ifdef CONFIG_MIPS_PB1100
  25. #define BOARD_MAP_NAME "Pb1100 Flash"
  26. #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
  27. #define BOARD_FLASH_WIDTH 4 /* 32-bits */
  28. #endif
  29. #ifdef CONFIG_MIPS_PB1550
  30. #define BOARD_MAP_NAME "Pb1550 Flash"
  31. #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
  32. #define BOARD_FLASH_WIDTH 4 /* 32-bits */
  33. #endif
  34. #ifdef CONFIG_MIPS_PB1200
  35. #define BOARD_MAP_NAME "Pb1200 Flash"
  36. #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
  37. #define BOARD_FLASH_WIDTH 2 /* 16-bits */
  38. #endif
  39. #ifdef CONFIG_MIPS_DB1000
  40. #define BOARD_MAP_NAME "Db1000 Flash"
  41. #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
  42. #define BOARD_FLASH_WIDTH 4 /* 32-bits */
  43. #endif
  44. #ifdef CONFIG_MIPS_DB1500
  45. #define BOARD_MAP_NAME "Db1500 Flash"
  46. #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
  47. #define BOARD_FLASH_WIDTH 4 /* 32-bits */
  48. #endif
  49. #ifdef CONFIG_MIPS_DB1100
  50. #define BOARD_MAP_NAME "Db1100 Flash"
  51. #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
  52. #define BOARD_FLASH_WIDTH 4 /* 32-bits */
  53. #endif
  54. #ifdef CONFIG_MIPS_DB1550
  55. #define BOARD_MAP_NAME "Db1550 Flash"
  56. #define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
  57. #define BOARD_FLASH_WIDTH 4 /* 32-bits */
  58. #endif
  59. #ifdef CONFIG_MIPS_DB1200
  60. #define BOARD_MAP_NAME "Db1200 Flash"
  61. #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
  62. #define BOARD_FLASH_WIDTH 2 /* 16-bits */
  63. #endif
  64. #ifdef CONFIG_MIPS_HYDROGEN3
  65. #define BOARD_MAP_NAME "Hydrogen3 Flash"
  66. #define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
  67. #define BOARD_FLASH_WIDTH 4 /* 32-bits */
  68. #define USE_LOCAL_ACCESSORS /* why? */
  69. #endif
  70. #ifdef CONFIG_MIPS_BOSPORUS
  71. #define BOARD_MAP_NAME "Bosporus Flash"
  72. #define BOARD_FLASH_SIZE 0x01000000 /* 16MB */
  73. #define BOARD_FLASH_WIDTH 2 /* 16-bits */
  74. #endif
  75. #ifdef CONFIG_MIPS_MIRAGE
  76. #define BOARD_MAP_NAME "Mirage Flash"
  77. #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
  78. #define BOARD_FLASH_WIDTH 4 /* 32-bits */
  79. #define USE_LOCAL_ACCESSORS /* why? */
  80. #endif
  81. static struct map_info alchemy_map = {
  82. .name = BOARD_MAP_NAME,
  83. };
  84. static struct mtd_partition alchemy_partitions[] = {
  85. {
  86. .name = "User FS",
  87. .size = BOARD_FLASH_SIZE - 0x00400000,
  88. .offset = 0x0000000
  89. },{
  90. .name = "YAMON",
  91. .size = 0x0100000,
  92. .offset = MTDPART_OFS_APPEND,
  93. .mask_flags = MTD_WRITEABLE
  94. },{
  95. .name = "raw kernel",
  96. .size = (0x300000 - 0x40000), /* last 256KB is yamon env */
  97. .offset = MTDPART_OFS_APPEND,
  98. }
  99. };
  100. static struct mtd_info *mymtd;
  101. int __init alchemy_mtd_init(void)
  102. {
  103. struct mtd_partition *parts;
  104. int nb_parts = 0;
  105. unsigned long window_addr;
  106. unsigned long window_size;
  107. /* Default flash buswidth */
  108. alchemy_map.bankwidth = BOARD_FLASH_WIDTH;
  109. window_addr = 0x20000000 - BOARD_FLASH_SIZE;
  110. window_size = BOARD_FLASH_SIZE;
  111. #ifdef CONFIG_MIPS_MIRAGE_WHY
  112. /* Boot ROM flash bank only; no user bank */
  113. window_addr = 0x1C000000;
  114. window_size = 0x04000000;
  115. /* USERFS from 0x1C00 0000 to 0x1FC00000 */
  116. alchemy_partitions[0].size = 0x03C00000;
  117. #endif
  118. /*
  119. * Static partition definition selection
  120. */
  121. parts = alchemy_partitions;
  122. nb_parts = ARRAY_SIZE(alchemy_partitions);
  123. alchemy_map.size = window_size;
  124. /*
  125. * Now let's probe for the actual flash. Do it here since
  126. * specific machine settings might have been set above.
  127. */
  128. printk(KERN_NOTICE BOARD_MAP_NAME ": probing %d-bit flash bus\n",
  129. alchemy_map.bankwidth*8);
  130. alchemy_map.virt = ioremap(window_addr, window_size);
  131. mymtd = do_map_probe("cfi_probe", &alchemy_map);
  132. if (!mymtd) {
  133. iounmap(alchemy_map.virt);
  134. return -ENXIO;
  135. }
  136. mymtd->owner = THIS_MODULE;
  137. add_mtd_partitions(mymtd, parts, nb_parts);
  138. return 0;
  139. }
  140. static void __exit alchemy_mtd_cleanup(void)
  141. {
  142. if (mymtd) {
  143. del_mtd_partitions(mymtd);
  144. map_destroy(mymtd);
  145. iounmap(alchemy_map.virt);
  146. }
  147. }
  148. module_init(alchemy_mtd_init);
  149. module_exit(alchemy_mtd_cleanup);
  150. MODULE_AUTHOR("Embedded Alley Solutions, Inc");
  151. MODULE_DESCRIPTION(BOARD_MAP_NAME " MTD driver");
  152. MODULE_LICENSE("GPL");