alchemy-flash.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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_BOSPORUS
  65. #define BOARD_MAP_NAME "Bosporus Flash"
  66. #define BOARD_FLASH_SIZE 0x01000000 /* 16MB */
  67. #define BOARD_FLASH_WIDTH 2 /* 16-bits */
  68. #endif
  69. #ifdef CONFIG_MIPS_MIRAGE
  70. #define BOARD_MAP_NAME "Mirage Flash"
  71. #define BOARD_FLASH_SIZE 0x04000000 /* 64MB */
  72. #define BOARD_FLASH_WIDTH 4 /* 32-bits */
  73. #define USE_LOCAL_ACCESSORS /* why? */
  74. #endif
  75. static struct map_info alchemy_map = {
  76. .name = BOARD_MAP_NAME,
  77. };
  78. static struct mtd_partition alchemy_partitions[] = {
  79. {
  80. .name = "User FS",
  81. .size = BOARD_FLASH_SIZE - 0x00400000,
  82. .offset = 0x0000000
  83. },{
  84. .name = "YAMON",
  85. .size = 0x0100000,
  86. .offset = MTDPART_OFS_APPEND,
  87. .mask_flags = MTD_WRITEABLE
  88. },{
  89. .name = "raw kernel",
  90. .size = (0x300000 - 0x40000), /* last 256KB is yamon env */
  91. .offset = MTDPART_OFS_APPEND,
  92. }
  93. };
  94. static struct mtd_info *mymtd;
  95. int __init alchemy_mtd_init(void)
  96. {
  97. struct mtd_partition *parts;
  98. int nb_parts = 0;
  99. unsigned long window_addr;
  100. unsigned long window_size;
  101. /* Default flash buswidth */
  102. alchemy_map.bankwidth = BOARD_FLASH_WIDTH;
  103. window_addr = 0x20000000 - BOARD_FLASH_SIZE;
  104. window_size = BOARD_FLASH_SIZE;
  105. /*
  106. * Static partition definition selection
  107. */
  108. parts = alchemy_partitions;
  109. nb_parts = ARRAY_SIZE(alchemy_partitions);
  110. alchemy_map.size = window_size;
  111. /*
  112. * Now let's probe for the actual flash. Do it here since
  113. * specific machine settings might have been set above.
  114. */
  115. printk(KERN_NOTICE BOARD_MAP_NAME ": probing %d-bit flash bus\n",
  116. alchemy_map.bankwidth*8);
  117. alchemy_map.virt = ioremap(window_addr, window_size);
  118. mymtd = do_map_probe("cfi_probe", &alchemy_map);
  119. if (!mymtd) {
  120. iounmap(alchemy_map.virt);
  121. return -ENXIO;
  122. }
  123. mymtd->owner = THIS_MODULE;
  124. add_mtd_partitions(mymtd, parts, nb_parts);
  125. return 0;
  126. }
  127. static void __exit alchemy_mtd_cleanup(void)
  128. {
  129. if (mymtd) {
  130. del_mtd_partitions(mymtd);
  131. map_destroy(mymtd);
  132. iounmap(alchemy_map.virt);
  133. }
  134. }
  135. module_init(alchemy_mtd_init);
  136. module_exit(alchemy_mtd_cleanup);
  137. MODULE_AUTHOR("Embedded Alley Solutions, Inc");
  138. MODULE_DESCRIPTION(BOARD_MAP_NAME " MTD driver");
  139. MODULE_LICENSE("GPL");