h720x-flash.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Flash memory access on Hynix GMS30C7201/HMS30C7202 based
  3. * evaluation boards
  4. *
  5. * (C) 2002 Jungjun Kim <jungjun.kim@hynix.com>
  6. * 2003 Thomas Gleixner <tglx@linutronix.de>
  7. */
  8. #include <linux/module.h>
  9. #include <linux/types.h>
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/errno.h>
  13. #include <linux/slab.h>
  14. #include <linux/mtd/mtd.h>
  15. #include <linux/mtd/map.h>
  16. #include <linux/mtd/partitions.h>
  17. #include <mach/hardware.h>
  18. #include <asm/io.h>
  19. static struct mtd_info *mymtd;
  20. static struct map_info h720x_map = {
  21. .name = "H720X",
  22. .bankwidth = 4,
  23. .size = H720X_FLASH_SIZE,
  24. .phys = H720X_FLASH_PHYS,
  25. };
  26. static struct mtd_partition h720x_partitions[] = {
  27. {
  28. .name = "ArMon",
  29. .size = 0x00080000,
  30. .offset = 0,
  31. .mask_flags = MTD_WRITEABLE
  32. },{
  33. .name = "Env",
  34. .size = 0x00040000,
  35. .offset = 0x00080000,
  36. .mask_flags = MTD_WRITEABLE
  37. },{
  38. .name = "Kernel",
  39. .size = 0x00180000,
  40. .offset = 0x000c0000,
  41. .mask_flags = MTD_WRITEABLE
  42. },{
  43. .name = "Ramdisk",
  44. .size = 0x00400000,
  45. .offset = 0x00240000,
  46. .mask_flags = MTD_WRITEABLE
  47. },{
  48. .name = "jffs2",
  49. .size = MTDPART_SIZ_FULL,
  50. .offset = MTDPART_OFS_APPEND
  51. }
  52. };
  53. #define NUM_PARTITIONS ARRAY_SIZE(h720x_partitions)
  54. /*
  55. * Initialize FLASH support
  56. */
  57. static int __init h720x_mtd_init(void)
  58. {
  59. h720x_map.virt = ioremap(h720x_map.phys, h720x_map.size);
  60. if (!h720x_map.virt) {
  61. printk(KERN_ERR "H720x-MTD: ioremap failed\n");
  62. return -EIO;
  63. }
  64. simple_map_init(&h720x_map);
  65. // Probe for flash bankwidth 4
  66. printk (KERN_INFO "H720x-MTD probing 32bit FLASH\n");
  67. mymtd = do_map_probe("cfi_probe", &h720x_map);
  68. if (!mymtd) {
  69. printk (KERN_INFO "H720x-MTD probing 16bit FLASH\n");
  70. // Probe for bankwidth 2
  71. h720x_map.bankwidth = 2;
  72. mymtd = do_map_probe("cfi_probe", &h720x_map);
  73. }
  74. if (mymtd) {
  75. mymtd->owner = THIS_MODULE;
  76. mtd_device_parse_register(mymtd, NULL, NULL,
  77. h720x_partitions, NUM_PARTITIONS);
  78. return 0;
  79. }
  80. iounmap((void *)h720x_map.virt);
  81. return -ENXIO;
  82. }
  83. /*
  84. * Cleanup
  85. */
  86. static void __exit h720x_mtd_cleanup(void)
  87. {
  88. if (mymtd) {
  89. mtd_device_unregister(mymtd);
  90. map_destroy(mymtd);
  91. }
  92. if (h720x_map.virt) {
  93. iounmap((void *)h720x_map.virt);
  94. h720x_map.virt = 0;
  95. }
  96. }
  97. module_init(h720x_mtd_init);
  98. module_exit(h720x_mtd_cleanup);
  99. MODULE_LICENSE("GPL");
  100. MODULE_AUTHOR("Thomas Gleixner <tglx@linutronix.de>");
  101. MODULE_DESCRIPTION("MTD map driver for Hynix evaluation boards");