redwood.c 4.1 KB

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