mpc1211.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Flash on MPC-1211
  3. *
  4. * $Id: mpc1211.c,v 1.4 2004/09/16 23:27:13 gleixner Exp $
  5. *
  6. * (C) 2002 Interface, Saito.K & Jeanne
  7. *
  8. * GPL'd
  9. */
  10. #include <linux/module.h>
  11. #include <linux/types.h>
  12. #include <linux/kernel.h>
  13. #include <asm/io.h>
  14. #include <linux/mtd/mtd.h>
  15. #include <linux/mtd/map.h>
  16. #include <linux/mtd/partitions.h>
  17. #include <linux/config.h>
  18. static struct mtd_info *flash_mtd;
  19. static struct mtd_partition *parsed_parts;
  20. struct map_info mpc1211_flash_map = {
  21. .name = "MPC-1211 FLASH",
  22. .size = 0x80000,
  23. .bankwidth = 1,
  24. };
  25. static struct mtd_partition mpc1211_partitions[] = {
  26. {
  27. .name = "IPL & ETH-BOOT",
  28. .offset = 0x00000000,
  29. .size = 0x10000,
  30. },
  31. {
  32. .name = "Flash FS",
  33. .offset = 0x00010000,
  34. .size = MTDPART_SIZ_FULL,
  35. }
  36. };
  37. static int __init init_mpc1211_maps(void)
  38. {
  39. int nr_parts;
  40. mpc1211_flash_map.phys = 0;
  41. mpc1211_flash_map.virt = (void __iomem *)P2SEGADDR(0);
  42. simple_map_init(&mpc1211_flash_map);
  43. printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n");
  44. flash_mtd = do_map_probe("jedec_probe", &mpc1211_flash_map);
  45. if (!flash_mtd) {
  46. printk(KERN_NOTICE "Flash chips not detected at either possible location.\n");
  47. return -ENXIO;
  48. }
  49. printk(KERN_NOTICE "MPC-1211: Flash at 0x%08lx\n", mpc1211_flash_map.virt & 0x1fffffff);
  50. flash_mtd->module = THIS_MODULE;
  51. parsed_parts = mpc1211_partitions;
  52. nr_parts = ARRAY_SIZE(mpc1211_partitions);
  53. add_mtd_partitions(flash_mtd, parsed_parts, nr_parts);
  54. return 0;
  55. }
  56. static void __exit cleanup_mpc1211_maps(void)
  57. {
  58. if (parsed_parts)
  59. del_mtd_partitions(flash_mtd);
  60. else
  61. del_mtd_device(flash_mtd);
  62. map_destroy(flash_mtd);
  63. }
  64. module_init(init_mpc1211_maps);
  65. module_exit(cleanup_mpc1211_maps);
  66. MODULE_LICENSE("GPL");
  67. MODULE_AUTHOR("Saito.K & Jeanne <ksaito@interface.co.jp>");
  68. MODULE_DESCRIPTION("MTD map driver for MPC-1211 boards. Interface");