alchemy-flash.c 4.7 KB

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