redwood.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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/module.h>
  16. #include <linux/types.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/map.h>
  21. #include <linux/mtd/partitions.h>
  22. #include <asm/io.h>
  23. #if !defined (CONFIG_REDWOOD_6)
  24. #define WINDOW_ADDR 0xffc00000
  25. #define WINDOW_SIZE 0x00400000
  26. #define RW_PART0_OF 0
  27. #define RW_PART0_SZ 0x10000
  28. #define RW_PART1_OF RW_PART0_SZ
  29. #define RW_PART1_SZ 0x200000 - 0x10000
  30. #define RW_PART2_OF 0x200000
  31. #define RW_PART2_SZ 0x10000
  32. #define RW_PART3_OF 0x210000
  33. #define RW_PART3_SZ 0x200000 - (0x10000 + 0x20000)
  34. #define RW_PART4_OF 0x3e0000
  35. #define RW_PART4_SZ 0x20000
  36. static struct mtd_partition redwood_flash_partitions[] = {
  37. {
  38. .name = "Redwood OpenBIOS Vital Product Data",
  39. .offset = RW_PART0_OF,
  40. .size = RW_PART0_SZ,
  41. .mask_flags = MTD_WRITEABLE /* force read-only */
  42. },
  43. {
  44. .name = "Redwood kernel",
  45. .offset = RW_PART1_OF,
  46. .size = RW_PART1_SZ
  47. },
  48. {
  49. .name = "Redwood OpenBIOS non-volatile storage",
  50. .offset = RW_PART2_OF,
  51. .size = RW_PART2_SZ,
  52. .mask_flags = MTD_WRITEABLE /* force read-only */
  53. },
  54. {
  55. .name = "Redwood filesystem",
  56. .offset = RW_PART3_OF,
  57. .size = RW_PART3_SZ
  58. },
  59. {
  60. .name = "Redwood OpenBIOS",
  61. .offset = RW_PART4_OF,
  62. .size = RW_PART4_SZ,
  63. .mask_flags = MTD_WRITEABLE /* force read-only */
  64. }
  65. };
  66. #else /* CONFIG_REDWOOD_6 */
  67. /* FIXME: the window is bigger - armin */
  68. #define WINDOW_ADDR 0xff800000
  69. #define WINDOW_SIZE 0x00800000
  70. #define RW_PART0_OF 0
  71. #define RW_PART0_SZ 0x400000 /* 4 MiB data */
  72. #define RW_PART1_OF RW_PART0_OF + RW_PART0_SZ
  73. #define RW_PART1_SZ 0x10000 /* 64K VPD */
  74. #define RW_PART2_OF RW_PART1_OF + RW_PART1_SZ
  75. #define RW_PART2_SZ 0x400000 - (0x10000 + 0x20000)
  76. #define RW_PART3_OF RW_PART2_OF + RW_PART2_SZ
  77. #define RW_PART3_SZ 0x20000
  78. static struct mtd_partition redwood_flash_partitions[] = {
  79. {
  80. .name = "Redwood filesystem",
  81. .offset = RW_PART0_OF,
  82. .size = RW_PART0_SZ
  83. },
  84. {
  85. .name = "Redwood OpenBIOS Vital Product Data",
  86. .offset = RW_PART1_OF,
  87. .size = RW_PART1_SZ,
  88. .mask_flags = MTD_WRITEABLE /* force read-only */
  89. },
  90. {
  91. .name = "Redwood kernel",
  92. .offset = RW_PART2_OF,
  93. .size = RW_PART2_SZ
  94. },
  95. {
  96. .name = "Redwood OpenBIOS",
  97. .offset = RW_PART3_OF,
  98. .size = RW_PART3_SZ,
  99. .mask_flags = MTD_WRITEABLE /* force read-only */
  100. }
  101. };
  102. #endif /* CONFIG_REDWOOD_6 */
  103. struct map_info redwood_flash_map = {
  104. .name = "IBM Redwood",
  105. .size = WINDOW_SIZE,
  106. .bankwidth = 2,
  107. .phys = WINDOW_ADDR,
  108. };
  109. #define NUM_REDWOOD_FLASH_PARTITIONS ARRAY_SIZE(redwood_flash_partitions)
  110. static struct mtd_info *redwood_mtd;
  111. int __init init_redwood_flash(void)
  112. {
  113. int err;
  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. err = add_mtd_partitions(redwood_mtd,
  126. redwood_flash_partitions,
  127. NUM_REDWOOD_FLASH_PARTITIONS);
  128. if (err) {
  129. printk("init_redwood_flash: add_mtd_partitions failed\n");
  130. iounmap(redwood_flash_map.virt);
  131. }
  132. return err;
  133. }
  134. iounmap(redwood_flash_map.virt);
  135. return -ENXIO;
  136. }
  137. static void __exit cleanup_redwood_flash(void)
  138. {
  139. if (redwood_mtd) {
  140. del_mtd_partitions(redwood_mtd);
  141. /* moved iounmap after map_destroy - armin */
  142. map_destroy(redwood_mtd);
  143. iounmap((void *)redwood_flash_map.virt);
  144. }
  145. }
  146. module_init(init_redwood_flash);
  147. module_exit(cleanup_redwood_flash);
  148. MODULE_LICENSE("GPL");
  149. MODULE_AUTHOR("MontaVista Software <source@mvista.com>");
  150. MODULE_DESCRIPTION("MTD map driver for the IBM Redwood reference boards");