mtx-1_flash.c 2.0 KB

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