solutionengine.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Flash and EPROM on Hitachi Solution Engine and similar boards.
  3. *
  4. * (C) 2001 Red Hat, Inc.
  5. *
  6. * GPL'd
  7. */
  8. #include <linux/module.h>
  9. #include <linux/types.h>
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <asm/io.h>
  13. #include <linux/mtd/mtd.h>
  14. #include <linux/mtd/map.h>
  15. #include <linux/mtd/partitions.h>
  16. #include <linux/errno.h>
  17. static struct mtd_info *flash_mtd;
  18. static struct mtd_info *eprom_mtd;
  19. struct map_info soleng_eprom_map = {
  20. .name = "Solution Engine EPROM",
  21. .size = 0x400000,
  22. .bankwidth = 4,
  23. };
  24. struct map_info soleng_flash_map = {
  25. .name = "Solution Engine FLASH",
  26. .size = 0x400000,
  27. .bankwidth = 4,
  28. };
  29. static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
  30. #ifdef CONFIG_MTD_SUPERH_RESERVE
  31. static struct mtd_partition superh_se_partitions[] = {
  32. /* Reserved for boot code, read-only */
  33. {
  34. .name = "flash_boot",
  35. .offset = 0x00000000,
  36. .size = CONFIG_MTD_SUPERH_RESERVE,
  37. .mask_flags = MTD_WRITEABLE,
  38. },
  39. /* All else is writable (e.g. JFFS) */
  40. {
  41. .name = "Flash FS",
  42. .offset = MTDPART_OFS_NXTBLK,
  43. .size = MTDPART_SIZ_FULL,
  44. }
  45. };
  46. #define NUM_PARTITIONS ARRAY_SIZE(superh_se_partitions)
  47. #else
  48. #define superh_se_partitions NULL
  49. #define NUM_PARTITIONS 0
  50. #endif /* CONFIG_MTD_SUPERH_RESERVE */
  51. static int __init init_soleng_maps(void)
  52. {
  53. /* First probe at offset 0 */
  54. soleng_flash_map.phys = 0;
  55. soleng_flash_map.virt = (void __iomem *)P2SEGADDR(0);
  56. soleng_eprom_map.phys = 0x01000000;
  57. soleng_eprom_map.virt = (void __iomem *)P1SEGADDR(0x01000000);
  58. simple_map_init(&soleng_eprom_map);
  59. simple_map_init(&soleng_flash_map);
  60. printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n");
  61. flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map);
  62. if (!flash_mtd) {
  63. /* Not there. Try swapping */
  64. printk(KERN_NOTICE "Probing for flash chips at 0x01000000:\n");
  65. soleng_flash_map.phys = 0x01000000;
  66. soleng_flash_map.virt = P2SEGADDR(0x01000000);
  67. soleng_eprom_map.phys = 0;
  68. soleng_eprom_map.virt = P1SEGADDR(0);
  69. flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map);
  70. if (!flash_mtd) {
  71. /* Eep. */
  72. printk(KERN_NOTICE "Flash chips not detected at either possible location.\n");
  73. return -ENXIO;
  74. }
  75. }
  76. printk(KERN_NOTICE "Solution Engine: Flash at 0x%08lx, EPROM at 0x%08lx\n",
  77. soleng_flash_map.phys & 0x1fffffff,
  78. soleng_eprom_map.phys & 0x1fffffff);
  79. flash_mtd->owner = THIS_MODULE;
  80. eprom_mtd = do_map_probe("map_rom", &soleng_eprom_map);
  81. if (eprom_mtd) {
  82. eprom_mtd->owner = THIS_MODULE;
  83. mtd_device_register(eprom_mtd, NULL, 0);
  84. }
  85. mtd_device_parse_register(flash_mtd, probes, NULL,
  86. superh_se_partitions, NUM_PARTITIONS);
  87. return 0;
  88. }
  89. static void __exit cleanup_soleng_maps(void)
  90. {
  91. if (eprom_mtd) {
  92. mtd_device_unregister(eprom_mtd);
  93. map_destroy(eprom_mtd);
  94. }
  95. mtd_device_unregister(flash_mtd);
  96. map_destroy(flash_mtd);
  97. }
  98. module_init(init_soleng_maps);
  99. module_exit(cleanup_soleng_maps);
  100. MODULE_LICENSE("GPL");
  101. MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
  102. MODULE_DESCRIPTION("MTD map driver for Hitachi SolutionEngine (and similar) boards");