dbox2-flash.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * $Id: dbox2-flash.c,v 1.14 2005/11/07 11:14:26 gleixner Exp $
  3. *
  4. * D-Box 2 flash driver
  5. */
  6. #include <linux/module.h>
  7. #include <linux/types.h>
  8. #include <linux/kernel.h>
  9. #include <linux/init.h>
  10. #include <asm/io.h>
  11. #include <linux/mtd/mtd.h>
  12. #include <linux/mtd/map.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/config.h>
  15. #include <linux/errno.h>
  16. /* partition_info gives details on the logical partitions that the split the
  17. * single flash device into. If the size if zero we use up to the end of the
  18. * device. */
  19. static struct mtd_partition partition_info[]= {
  20. {
  21. .name = "BR bootloader",
  22. .size = 128 * 1024,
  23. .offset = 0,
  24. .mask_flags = MTD_WRITEABLE
  25. },
  26. {
  27. .name = "FLFS (U-Boot)",
  28. .size = 128 * 1024,
  29. .offset = MTDPART_OFS_APPEND,
  30. .mask_flags = 0
  31. },
  32. {
  33. .name = "Root (SquashFS)",
  34. .size = 7040 * 1024,
  35. .offset = MTDPART_OFS_APPEND,
  36. .mask_flags = 0
  37. },
  38. {
  39. .name = "var (JFFS2)",
  40. .size = 896 * 1024,
  41. .offset = MTDPART_OFS_APPEND,
  42. .mask_flags = 0
  43. },
  44. {
  45. .name = "Flash without bootloader",
  46. .size = MTDPART_SIZ_FULL,
  47. .offset = 128 * 1024,
  48. .mask_flags = 0
  49. },
  50. {
  51. .name = "Complete Flash",
  52. .size = MTDPART_SIZ_FULL,
  53. .offset = 0,
  54. .mask_flags = MTD_WRITEABLE
  55. }
  56. };
  57. #define NUM_PARTITIONS ARRAY_SIZE(partition_info)
  58. #define WINDOW_ADDR 0x10000000
  59. #define WINDOW_SIZE 0x800000
  60. static struct mtd_info *mymtd;
  61. struct map_info dbox2_flash_map = {
  62. .name = "D-Box 2 flash memory",
  63. .size = WINDOW_SIZE,
  64. .bankwidth = 4,
  65. .phys = WINDOW_ADDR,
  66. };
  67. int __init init_dbox2_flash(void)
  68. {
  69. printk(KERN_NOTICE "D-Box 2 flash driver (size->0x%X mem->0x%X)\n", WINDOW_SIZE, WINDOW_ADDR);
  70. dbox2_flash_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
  71. if (!dbox2_flash_map.virt) {
  72. printk("Failed to ioremap\n");
  73. return -EIO;
  74. }
  75. simple_map_init(&dbox2_flash_map);
  76. // Probe for dual Intel 28F320 or dual AMD
  77. mymtd = do_map_probe("cfi_probe", &dbox2_flash_map);
  78. if (!mymtd) {
  79. // Probe for single Intel 28F640
  80. dbox2_flash_map.bankwidth = 2;
  81. mymtd = do_map_probe("cfi_probe", &dbox2_flash_map);
  82. }
  83. if (mymtd) {
  84. mymtd->owner = THIS_MODULE;
  85. /* Create MTD devices for each partition. */
  86. add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
  87. return 0;
  88. }
  89. iounmap((void *)dbox2_flash_map.virt);
  90. return -ENXIO;
  91. }
  92. static void __exit cleanup_dbox2_flash(void)
  93. {
  94. if (mymtd) {
  95. del_mtd_partitions(mymtd);
  96. map_destroy(mymtd);
  97. }
  98. if (dbox2_flash_map.virt) {
  99. iounmap((void *)dbox2_flash_map.virt);
  100. dbox2_flash_map.virt = 0;
  101. }
  102. }
  103. module_init(init_dbox2_flash);
  104. module_exit(cleanup_dbox2_flash);
  105. MODULE_LICENSE("GPL");
  106. MODULE_AUTHOR("Kári Davíðsson <kd@flaga.is>, Bastian Blank <waldi@tuxbox.org>, Alexander Wild <wild@te-elektronik.com>");
  107. MODULE_DESCRIPTION("MTD map driver for D-Box 2 board");