redwood.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * $Id: redwood.c,v 1.11 2005/11/07 11:14:28 gleixner Exp $
  3. *
  4. * drivers/mtd/maps/redwood.c
  5. *
  6. * FLASH map for the IBM Redwood 4/5/6 boards.
  7. *
  8. * Author: MontaVista Software, Inc. <source@mvista.com>
  9. *
  10. * 2001-2003 (c) MontaVista, Software, Inc. This file is licensed under
  11. * the terms of the GNU General Public License version 2. This program
  12. * is licensed "as is" without any warranty of any kind, whether express
  13. * or implied.
  14. */
  15. #include <linux/config.h>
  16. #include <linux/module.h>
  17. #include <linux/types.h>
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/mtd/mtd.h>
  21. #include <linux/mtd/map.h>
  22. #include <linux/mtd/partitions.h>
  23. #include <asm/io.h>
  24. #if !defined (CONFIG_REDWOOD_6)
  25. #define WINDOW_ADDR 0xffc00000
  26. #define WINDOW_SIZE 0x00400000
  27. #define RW_PART0_OF 0
  28. #define RW_PART0_SZ 0x10000
  29. #define RW_PART1_OF RW_PART0_SZ
  30. #define RW_PART1_SZ 0x200000 - 0x10000
  31. #define RW_PART2_OF 0x200000
  32. #define RW_PART2_SZ 0x10000
  33. #define RW_PART3_OF 0x210000
  34. #define RW_PART3_SZ 0x200000 - (0x10000 + 0x20000)
  35. #define RW_PART4_OF 0x3e0000
  36. #define RW_PART4_SZ 0x20000
  37. static struct mtd_partition redwood_flash_partitions[] = {
  38. {
  39. .name = "Redwood OpenBIOS Vital Product Data",
  40. .offset = RW_PART0_OF,
  41. .size = RW_PART0_SZ,
  42. .mask_flags = MTD_WRITEABLE /* force read-only */
  43. },
  44. {
  45. .name = "Redwood kernel",
  46. .offset = RW_PART1_OF,
  47. .size = RW_PART1_SZ
  48. },
  49. {
  50. .name = "Redwood OpenBIOS non-volatile storage",
  51. .offset = RW_PART2_OF,
  52. .size = RW_PART2_SZ,
  53. .mask_flags = MTD_WRITEABLE /* force read-only */
  54. },
  55. {
  56. .name = "Redwood filesystem",
  57. .offset = RW_PART3_OF,
  58. .size = RW_PART3_SZ
  59. },
  60. {
  61. .name = "Redwood OpenBIOS",
  62. .offset = RW_PART4_OF,
  63. .size = RW_PART4_SZ,
  64. .mask_flags = MTD_WRITEABLE /* force read-only */
  65. }
  66. };
  67. #else /* CONFIG_REDWOOD_6 */
  68. /* FIXME: the window is bigger - armin */
  69. #define WINDOW_ADDR 0xff800000
  70. #define WINDOW_SIZE 0x00800000
  71. #define RW_PART0_OF 0
  72. #define RW_PART0_SZ 0x400000 /* 4 MiB data */
  73. #define RW_PART1_OF RW_PART0_OF + RW_PART0_SZ
  74. #define RW_PART1_SZ 0x10000 /* 64K VPD */
  75. #define RW_PART2_OF RW_PART1_OF + RW_PART1_SZ
  76. #define RW_PART2_SZ 0x400000 - (0x10000 + 0x20000)
  77. #define RW_PART3_OF RW_PART2_OF + RW_PART2_SZ
  78. #define RW_PART3_SZ 0x20000
  79. static struct mtd_partition redwood_flash_partitions[] = {
  80. {
  81. .name = "Redwood filesystem",
  82. .offset = RW_PART0_OF,
  83. .size = RW_PART0_SZ
  84. },
  85. {
  86. .name = "Redwood OpenBIOS Vital Product Data",
  87. .offset = RW_PART1_OF,
  88. .size = RW_PART1_SZ,
  89. .mask_flags = MTD_WRITEABLE /* force read-only */
  90. },
  91. {
  92. .name = "Redwood kernel",
  93. .offset = RW_PART2_OF,
  94. .size = RW_PART2_SZ
  95. },
  96. {
  97. .name = "Redwood OpenBIOS",
  98. .offset = RW_PART3_OF,
  99. .size = RW_PART3_SZ,
  100. .mask_flags = MTD_WRITEABLE /* force read-only */
  101. }
  102. };
  103. #endif /* CONFIG_REDWOOD_6 */
  104. struct map_info redwood_flash_map = {
  105. .name = "IBM Redwood",
  106. .size = WINDOW_SIZE,
  107. .bankwidth = 2,
  108. .phys = WINDOW_ADDR,
  109. };
  110. #define NUM_REDWOOD_FLASH_PARTITIONS ARRAY_SIZE(redwood_flash_partitions)
  111. static struct mtd_info *redwood_mtd;
  112. int __init init_redwood_flash(void)
  113. {
  114. printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n",
  115. WINDOW_SIZE, WINDOW_ADDR);
  116. redwood_flash_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
  117. if (!redwood_flash_map.virt) {
  118. printk("init_redwood_flash: failed to ioremap\n");
  119. return -EIO;
  120. }
  121. simple_map_init(&redwood_flash_map);
  122. redwood_mtd = do_map_probe("cfi_probe",&redwood_flash_map);
  123. if (redwood_mtd) {
  124. redwood_mtd->owner = THIS_MODULE;
  125. return add_mtd_partitions(redwood_mtd,
  126. redwood_flash_partitions,
  127. NUM_REDWOOD_FLASH_PARTITIONS);
  128. }
  129. return -ENXIO;
  130. }
  131. static void __exit cleanup_redwood_flash(void)
  132. {
  133. if (redwood_mtd) {
  134. del_mtd_partitions(redwood_mtd);
  135. /* moved iounmap after map_destroy - armin */
  136. map_destroy(redwood_mtd);
  137. iounmap((void *)redwood_flash_map.virt);
  138. }
  139. }
  140. module_init(init_redwood_flash);
  141. module_exit(cleanup_redwood_flash);
  142. MODULE_LICENSE("GPL");
  143. MODULE_AUTHOR("MontaVista Software <source@mvista.com>");
  144. MODULE_DESCRIPTION("MTD map driver for the IBM Redwood reference boards");