mtx-1_flash.c 2.0 KB

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