iq80310.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * $Id: iq80310.c,v 1.20 2004/11/04 13:24:15 gleixner Exp $
  3. *
  4. * Mapping for the Intel XScale IQ80310 evaluation board
  5. *
  6. * Author: Nicolas Pitre
  7. * Copyright: (C) 2001 MontaVista Software Inc.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/types.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/slab.h>
  18. #include <asm/io.h>
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/map.h>
  21. #include <linux/mtd/partitions.h>
  22. #define WINDOW_ADDR 0
  23. #define WINDOW_SIZE 8*1024*1024
  24. #define BUSWIDTH 1
  25. static struct mtd_info *mymtd;
  26. static struct map_info iq80310_map = {
  27. .name = "IQ80310 flash",
  28. .size = WINDOW_SIZE,
  29. .bankwidth = BUSWIDTH,
  30. .phys = WINDOW_ADDR
  31. };
  32. static struct mtd_partition iq80310_partitions[4] = {
  33. {
  34. .name = "Firmware",
  35. .size = 0x00080000,
  36. .offset = 0,
  37. .mask_flags = MTD_WRITEABLE /* force read-only */
  38. },{
  39. .name = "Kernel",
  40. .size = 0x000a0000,
  41. .offset = 0x00080000,
  42. },{
  43. .name = "Filesystem",
  44. .size = 0x00600000,
  45. .offset = 0x00120000
  46. },{
  47. .name = "RedBoot",
  48. .size = 0x000e0000,
  49. .offset = 0x00720000,
  50. .mask_flags = MTD_WRITEABLE
  51. }
  52. };
  53. static struct mtd_info *mymtd;
  54. static struct mtd_partition *parsed_parts;
  55. static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
  56. static int __init init_iq80310(void)
  57. {
  58. struct mtd_partition *parts;
  59. int nb_parts = 0;
  60. int parsed_nr_parts = 0;
  61. int ret;
  62. iq80310_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
  63. if (!iq80310_map.virt) {
  64. printk("Failed to ioremap\n");
  65. return -EIO;
  66. }
  67. simple_map_init(&iq80310_map);
  68. mymtd = do_map_probe("cfi_probe", &iq80310_map);
  69. if (!mymtd) {
  70. iounmap((void *)iq80310_map.virt);
  71. return -ENXIO;
  72. }
  73. mymtd->owner = THIS_MODULE;
  74. ret = parse_mtd_partitions(mymtd, probes, &parsed_parts, 0);
  75. if (ret > 0)
  76. parsed_nr_parts = ret;
  77. if (parsed_nr_parts > 0) {
  78. parts = parsed_parts;
  79. nb_parts = parsed_nr_parts;
  80. } else {
  81. parts = iq80310_partitions;
  82. nb_parts = ARRAY_SIZE(iq80310_partitions);
  83. }
  84. add_mtd_partitions(mymtd, parts, nb_parts);
  85. return 0;
  86. }
  87. static void __exit cleanup_iq80310(void)
  88. {
  89. if (mymtd) {
  90. del_mtd_partitions(mymtd);
  91. map_destroy(mymtd);
  92. if (parsed_parts)
  93. kfree(parsed_parts);
  94. }
  95. if (iq80310_map.virt)
  96. iounmap((void *)iq80310_map.virt);
  97. }
  98. module_init(init_iq80310);
  99. module_exit(cleanup_iq80310);
  100. MODULE_LICENSE("GPL");
  101. MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>");
  102. MODULE_DESCRIPTION("MTD map driver for Intel XScale IQ80310 evaluation board");