solutionengine.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 * const probes[] = { "RedBoot", "cmdlinepart", NULL };
  30. static int __init init_soleng_maps(void)
  31. {
  32. /* First probe at offset 0 */
  33. soleng_flash_map.phys = 0;
  34. soleng_flash_map.virt = (void __iomem *)P2SEGADDR(0);
  35. soleng_eprom_map.phys = 0x01000000;
  36. soleng_eprom_map.virt = (void __iomem *)P1SEGADDR(0x01000000);
  37. simple_map_init(&soleng_eprom_map);
  38. simple_map_init(&soleng_flash_map);
  39. printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n");
  40. flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map);
  41. if (!flash_mtd) {
  42. /* Not there. Try swapping */
  43. printk(KERN_NOTICE "Probing for flash chips at 0x01000000:\n");
  44. soleng_flash_map.phys = 0x01000000;
  45. soleng_flash_map.virt = P2SEGADDR(0x01000000);
  46. soleng_eprom_map.phys = 0;
  47. soleng_eprom_map.virt = P1SEGADDR(0);
  48. flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map);
  49. if (!flash_mtd) {
  50. /* Eep. */
  51. printk(KERN_NOTICE "Flash chips not detected at either possible location.\n");
  52. return -ENXIO;
  53. }
  54. }
  55. printk(KERN_NOTICE "Solution Engine: Flash at 0x%pap, EPROM at 0x%pap\n",
  56. &soleng_flash_map.phys,
  57. &soleng_eprom_map.phys);
  58. flash_mtd->owner = THIS_MODULE;
  59. eprom_mtd = do_map_probe("map_rom", &soleng_eprom_map);
  60. if (eprom_mtd) {
  61. eprom_mtd->owner = THIS_MODULE;
  62. mtd_device_register(eprom_mtd, NULL, 0);
  63. }
  64. mtd_device_parse_register(flash_mtd, probes, NULL, NULL, 0);
  65. return 0;
  66. }
  67. static void __exit cleanup_soleng_maps(void)
  68. {
  69. if (eprom_mtd) {
  70. mtd_device_unregister(eprom_mtd);
  71. map_destroy(eprom_mtd);
  72. }
  73. mtd_device_unregister(flash_mtd);
  74. map_destroy(flash_mtd);
  75. }
  76. module_init(init_soleng_maps);
  77. module_exit(cleanup_soleng_maps);
  78. MODULE_LICENSE("GPL");
  79. MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
  80. MODULE_DESCRIPTION("MTD map driver for Hitachi SolutionEngine (and similar) boards");