redwood.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. #define WINDOW_ADDR 0xffc00000
  22. #define WINDOW_SIZE 0x00400000
  23. #define RW_PART0_OF 0
  24. #define RW_PART0_SZ 0x10000
  25. #define RW_PART1_OF RW_PART0_SZ
  26. #define RW_PART1_SZ 0x200000 - 0x10000
  27. #define RW_PART2_OF 0x200000
  28. #define RW_PART2_SZ 0x10000
  29. #define RW_PART3_OF 0x210000
  30. #define RW_PART3_SZ 0x200000 - (0x10000 + 0x20000)
  31. #define RW_PART4_OF 0x3e0000
  32. #define RW_PART4_SZ 0x20000
  33. static struct mtd_partition redwood_flash_partitions[] = {
  34. {
  35. .name = "Redwood OpenBIOS Vital Product Data",
  36. .offset = RW_PART0_OF,
  37. .size = RW_PART0_SZ,
  38. .mask_flags = MTD_WRITEABLE /* force read-only */
  39. },
  40. {
  41. .name = "Redwood kernel",
  42. .offset = RW_PART1_OF,
  43. .size = RW_PART1_SZ
  44. },
  45. {
  46. .name = "Redwood OpenBIOS non-volatile storage",
  47. .offset = RW_PART2_OF,
  48. .size = RW_PART2_SZ,
  49. .mask_flags = MTD_WRITEABLE /* force read-only */
  50. },
  51. {
  52. .name = "Redwood filesystem",
  53. .offset = RW_PART3_OF,
  54. .size = RW_PART3_SZ
  55. },
  56. {
  57. .name = "Redwood OpenBIOS",
  58. .offset = RW_PART4_OF,
  59. .size = RW_PART4_SZ,
  60. .mask_flags = MTD_WRITEABLE /* force read-only */
  61. }
  62. };
  63. struct map_info redwood_flash_map = {
  64. .name = "IBM Redwood",
  65. .size = WINDOW_SIZE,
  66. .bankwidth = 2,
  67. .phys = WINDOW_ADDR,
  68. };
  69. #define NUM_REDWOOD_FLASH_PARTITIONS ARRAY_SIZE(redwood_flash_partitions)
  70. static struct mtd_info *redwood_mtd;
  71. static int __init init_redwood_flash(void)
  72. {
  73. int err;
  74. printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n",
  75. WINDOW_SIZE, WINDOW_ADDR);
  76. redwood_flash_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
  77. if (!redwood_flash_map.virt) {
  78. printk("init_redwood_flash: failed to ioremap\n");
  79. return -EIO;
  80. }
  81. simple_map_init(&redwood_flash_map);
  82. redwood_mtd = do_map_probe("cfi_probe",&redwood_flash_map);
  83. if (redwood_mtd) {
  84. redwood_mtd->owner = THIS_MODULE;
  85. err = add_mtd_partitions(redwood_mtd,
  86. redwood_flash_partitions,
  87. NUM_REDWOOD_FLASH_PARTITIONS);
  88. if (err) {
  89. printk("init_redwood_flash: add_mtd_partitions failed\n");
  90. iounmap(redwood_flash_map.virt);
  91. }
  92. return err;
  93. }
  94. iounmap(redwood_flash_map.virt);
  95. return -ENXIO;
  96. }
  97. static void __exit cleanup_redwood_flash(void)
  98. {
  99. if (redwood_mtd) {
  100. del_mtd_partitions(redwood_mtd);
  101. /* moved iounmap after map_destroy - armin */
  102. map_destroy(redwood_mtd);
  103. iounmap((void *)redwood_flash_map.virt);
  104. }
  105. }
  106. module_init(init_redwood_flash);
  107. module_exit(cleanup_redwood_flash);
  108. MODULE_LICENSE("GPL");
  109. MODULE_AUTHOR("MontaVista Software <source@mvista.com>");
  110. MODULE_DESCRIPTION("MTD map driver for the IBM Redwood reference boards");