mtx-1_flash.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Flash memory access on 4G Systems MTX-1 boards
  3. *
  4. * (C) 2005 Bruno Randolf <bruno.randolf@4g-systems.biz>
  5. * (C) 2005 Joern Engel <joern@wohnheim.fh-wedel.de>
  6. *
  7. */
  8. #include <linux/module.h>
  9. #include <linux/types.h>
  10. #include <linux/init.h>
  11. #include <linux/kernel.h>
  12. #include <linux/mtd/mtd.h>
  13. #include <linux/mtd/map.h>
  14. #include <linux/mtd/partitions.h>
  15. #include <asm/io.h>
  16. static struct map_info mtx1_map = {
  17. .name = "MTX-1 flash",
  18. .bankwidth = 4,
  19. .size = 0x2000000,
  20. .phys = 0x1E000000,
  21. };
  22. static struct mtd_partition mtx1_partitions[] = {
  23. {
  24. .name = "filesystem",
  25. .size = 0x01C00000,
  26. .offset = 0,
  27. },{
  28. .name = "yamon",
  29. .size = 0x00100000,
  30. .offset = MTDPART_OFS_APPEND,
  31. .mask_flags = MTD_WRITEABLE,
  32. },{
  33. .name = "kernel",
  34. .size = 0x002c0000,
  35. .offset = MTDPART_OFS_APPEND,
  36. },{
  37. .name = "yamon env",
  38. .size = 0x00040000,
  39. .offset = MTDPART_OFS_APPEND,
  40. }
  41. };
  42. static struct mtd_info *mtx1_mtd;
  43. int __init mtx1_mtd_init(void)
  44. {
  45. int ret = -ENXIO;
  46. simple_map_init(&mtx1_map);
  47. mtx1_map.virt = ioremap(mtx1_map.phys, mtx1_map.size);
  48. if (!mtx1_map.virt)
  49. return -EIO;
  50. mtx1_mtd = do_map_probe("cfi_probe", &mtx1_map);
  51. if (!mtx1_mtd)
  52. goto err;
  53. mtx1_mtd->owner = THIS_MODULE;
  54. ret = add_mtd_partitions(mtx1_mtd, mtx1_partitions,
  55. ARRAY_SIZE(mtx1_partitions));
  56. if (ret)
  57. goto err;
  58. return 0;
  59. err:
  60. iounmap(mtx1_map.virt);
  61. return ret;
  62. }
  63. static void __exit mtx1_mtd_cleanup(void)
  64. {
  65. if (mtx1_mtd) {
  66. del_mtd_partitions(mtx1_mtd);
  67. map_destroy(mtx1_mtd);
  68. }
  69. if (mtx1_map.virt)
  70. iounmap(mtx1_map.virt);
  71. }
  72. module_init(mtx1_mtd_init);
  73. module_exit(mtx1_mtd_cleanup);
  74. MODULE_AUTHOR("Bruno Randolf <bruno.randolf@4g-systems.biz>");
  75. MODULE_DESCRIPTION("MTX-1 flash map");
  76. MODULE_LICENSE("GPL");