007-flash.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. Index: linux-2.6.21.7/drivers/mtd/maps/gumstix-flash.c
  2. ===================================================================
  3. --- /dev/null
  4. +++ linux-2.6.21.7/drivers/mtd/maps/gumstix-flash.c
  5. @@ -0,0 +1,136 @@
  6. +/*
  7. + * Map driver for the Gumstix platform
  8. + *
  9. + * Author: Craig Hughes
  10. + *
  11. + * This program is free software; you can redistribute it and/or modify
  12. + * it under the terms of the GNU General Public License version 2 as
  13. + * published by the Free Software Foundation.
  14. + */
  15. +
  16. +#include <linux/module.h>
  17. +#include <linux/types.h>
  18. +#include <linux/kernel.h>
  19. +#include <linux/init.h>
  20. +#include <linux/mtd/mtd.h>
  21. +#include <linux/mtd/map.h>
  22. +#include <linux/mtd/partitions.h>
  23. +#include <asm/io.h>
  24. +#include <asm/hardware.h>
  25. +#include <asm/arch/gumstix.h>
  26. +
  27. +
  28. +#define ROM_ADDR 0x00000000
  29. +#define FLASH_ADDR 0x00000000
  30. +
  31. +#define WINDOW_SIZE 64*1024*1024
  32. +
  33. +static struct map_info gumstix_flash_maps[1] = { {
  34. + .name = "Gumstix Flash ROM",
  35. + .size = WINDOW_SIZE,
  36. + .phys = FLASH_ADDR,
  37. + .bankwidth = 2,
  38. +} };
  39. +
  40. +static struct mtd_partition gumstix_flash_partitions[] = {
  41. + {
  42. + .name = "Bootloader",
  43. + .size = 0x00040000,
  44. + .offset = FLASH_ADDR
  45. + },{
  46. + .name = "RootFS",
  47. + .size = MTDPART_SIZ_FULL,
  48. + .offset = MTDPART_OFS_APPEND
  49. + }
  50. +};
  51. +
  52. +static struct mtd_info *mymtds[1];
  53. +static struct mtd_partition *parsed_parts[1];
  54. +static int nr_parsed_parts[1];
  55. +
  56. +static const char *probes[] = { NULL };
  57. +
  58. +static int __init gumstix_flashmap_init(void)
  59. +{
  60. + int ret = 0, i;
  61. +
  62. + for (i = 0; i < 1; i++) {
  63. + gumstix_flash_maps[i].virt = ioremap(gumstix_flash_maps[i].phys, WINDOW_SIZE);
  64. + if (!gumstix_flash_maps[i].virt) {
  65. + printk(KERN_WARNING "Failed to ioremap %s\n", gumstix_flash_maps[i].name);
  66. + if (!ret)
  67. + ret = -ENOMEM;
  68. + continue;
  69. + }
  70. + simple_map_init(&gumstix_flash_maps[i]);
  71. +
  72. + printk(KERN_NOTICE "Probing %s at physical address 0x%08lx (%d-bit bankwidth)\n",
  73. + gumstix_flash_maps[i].name, gumstix_flash_maps[i].phys,
  74. + gumstix_flash_maps[i].bankwidth * 8);
  75. +
  76. + mymtds[i] = do_map_probe("cfi_probe", &gumstix_flash_maps[i]);
  77. +
  78. + if (!mymtds[i]) {
  79. + iounmap((void *)gumstix_flash_maps[i].virt);
  80. + if (gumstix_flash_maps[i].cached)
  81. + iounmap(gumstix_flash_maps[i].cached);
  82. + if (!ret)
  83. + ret = -EIO;
  84. + continue;
  85. + }
  86. + mymtds[i]->owner = THIS_MODULE;
  87. +
  88. + ret = parse_mtd_partitions(mymtds[i], probes,
  89. + &parsed_parts[i], 0);
  90. +
  91. + if (ret > 0)
  92. + nr_parsed_parts[i] = ret;
  93. + }
  94. +
  95. + if (!mymtds[0])
  96. + return ret;
  97. +
  98. + for (i = 0; i < 1; i++) {
  99. + if (!mymtds[i]) {
  100. + printk(KERN_WARNING "%s is absent. Skipping\n", gumstix_flash_maps[i].name);
  101. + } else if (nr_parsed_parts[i]) {
  102. + add_mtd_partitions(mymtds[i], parsed_parts[i], nr_parsed_parts[i]);
  103. + } else if (!i) {
  104. + printk("Using static partitions on %s\n", gumstix_flash_maps[i].name);
  105. + add_mtd_partitions(mymtds[i], gumstix_flash_partitions, ARRAY_SIZE(gumstix_flash_partitions));
  106. + } else {
  107. + printk("Registering %s as whole device\n", gumstix_flash_maps[i].name);
  108. + add_mtd_device(mymtds[i]);
  109. + }
  110. + }
  111. + return 0;
  112. +}
  113. +
  114. +static void __exit gumstix_flashmap_cleanup(void)
  115. +{
  116. + int i;
  117. + for (i = 0; i < 1; i++) {
  118. + if (!mymtds[i])
  119. + continue;
  120. +
  121. + if (nr_parsed_parts[i] || !i)
  122. + del_mtd_partitions(mymtds[i]);
  123. + else
  124. + del_mtd_device(mymtds[i]);
  125. +
  126. + map_destroy(mymtds[i]);
  127. + iounmap((void *)gumstix_flash_maps[i].virt);
  128. + if (gumstix_flash_maps[i].cached)
  129. + iounmap(gumstix_flash_maps[i].cached);
  130. +
  131. + if (parsed_parts[i])
  132. + kfree(parsed_parts[i]);
  133. + }
  134. +}
  135. +
  136. +module_init(gumstix_flashmap_init);
  137. +module_exit(gumstix_flashmap_cleanup);
  138. +
  139. +MODULE_LICENSE("GPL");
  140. +MODULE_AUTHOR("Gumstix, Inc. <[email protected]>");
  141. +MODULE_DESCRIPTION("MTD map driver for the Gumstix Platform");
  142. Index: linux-2.6.21.7/drivers/mtd/maps/Kconfig
  143. ===================================================================
  144. --- linux-2.6.21.7.orig/drivers/mtd/maps/Kconfig
  145. +++ linux-2.6.21.7/drivers/mtd/maps/Kconfig
  146. @@ -131,6 +131,13 @@ config MTD_SBC_GXX
  147. More info at
  148. <http://www.arcomcontrols.com/products/icp/pc104/processors/SBC_GX1.htm>.
  149. +config MTD_GUMSTIX
  150. + tristate "CFI Flash device mapped on Gumstix"
  151. + depends on ARCH_GUMSTIX && MTD_CFI_INTELEXT && MTD_PARTITIONS
  152. + help
  153. + This provides a driver for the on-board flash of the Gumstix
  154. + single board computers.
  155. +
  156. config MTD_LUBBOCK
  157. tristate "CFI Flash device mapped on Intel Lubbock XScale eval board"
  158. depends on ARCH_LUBBOCK && MTD_CFI_INTELEXT && MTD_PARTITIONS
  159. Index: linux-2.6.21.7/drivers/mtd/maps/Makefile
  160. ===================================================================
  161. --- linux-2.6.21.7.orig/drivers/mtd/maps/Makefile
  162. +++ linux-2.6.21.7/drivers/mtd/maps/Makefile
  163. @@ -21,6 +21,7 @@ obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o
  164. obj-$(CONFIG_MTD_CK804XROM) += ck804xrom.o
  165. obj-$(CONFIG_MTD_TSUNAMI) += tsunami_flash.o
  166. obj-$(CONFIG_MTD_LUBBOCK) += lubbock-flash.o
  167. +obj-$(CONFIG_MTD_GUMSTIX) += gumstix-flash.o
  168. obj-$(CONFIG_MTD_MAINSTONE) += mainstone-flash.o
  169. obj-$(CONFIG_MTD_MBX860) += mbx860.o
  170. obj-$(CONFIG_MTD_CEIVA) += ceiva.o