dbox2-flash.c 2.7 KB

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