mpc1211.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. static struct mtd_info *flash_mtd;
  18. static struct mtd_partition *parsed_parts;
  19. struct map_info mpc1211_flash_map = {
  20. .name = "MPC-1211 FLASH",
  21. .size = 0x80000,
  22. .bankwidth = 1,
  23. };
  24. static struct mtd_partition mpc1211_partitions[] = {
  25. {
  26. .name = "IPL & ETH-BOOT",
  27. .offset = 0x00000000,
  28. .size = 0x10000,
  29. },
  30. {
  31. .name = "Flash FS",
  32. .offset = 0x00010000,
  33. .size = MTDPART_SIZ_FULL,
  34. }
  35. };
  36. static int __init init_mpc1211_maps(void)
  37. {
  38. int nr_parts;
  39. mpc1211_flash_map.phys = 0;
  40. mpc1211_flash_map.virt = (void __iomem *)P2SEGADDR(0);
  41. simple_map_init(&mpc1211_flash_map);
  42. printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n");
  43. flash_mtd = do_map_probe("jedec_probe", &mpc1211_flash_map);
  44. if (!flash_mtd) {
  45. printk(KERN_NOTICE "Flash chips not detected at either possible location.\n");
  46. return -ENXIO;
  47. }
  48. printk(KERN_NOTICE "MPC-1211: Flash at 0x%08lx\n", mpc1211_flash_map.virt & 0x1fffffff);
  49. flash_mtd->module = THIS_MODULE;
  50. parsed_parts = mpc1211_partitions;
  51. nr_parts = ARRAY_SIZE(mpc1211_partitions);
  52. add_mtd_partitions(flash_mtd, parsed_parts, nr_parts);
  53. return 0;
  54. }
  55. static void __exit cleanup_mpc1211_maps(void)
  56. {
  57. if (parsed_parts)
  58. del_mtd_partitions(flash_mtd);
  59. else
  60. del_mtd_device(flash_mtd);
  61. map_destroy(flash_mtd);
  62. }
  63. module_init(init_mpc1211_maps);
  64. module_exit(cleanup_mpc1211_maps);
  65. MODULE_LICENSE("GPL");
  66. MODULE_AUTHOR("Saito.K & Jeanne <ksaito@interface.co.jp>");
  67. MODULE_DESCRIPTION("MTD map driver for MPC-1211 boards. Interface");