ts5500_flash.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * ts5500_flash.c -- MTD map driver for Technology Systems TS-5500 board
  3. *
  4. * Copyright (C) 2004 Sean Young <sean@mess.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  19. *
  20. * Note:
  21. * - In order for detection to work, jumper 3 must be set.
  22. * - Drive A and B use the resident flash disk (RFD) flash translation layer.
  23. * - If you have created your own jffs file system and the bios overwrites
  24. * it during boot, try disabling Drive A: and B: in the boot order.
  25. *
  26. * $Id: ts5500_flash.c,v 1.5 2005/11/07 11:14:28 gleixner Exp $
  27. */
  28. #include <linux/init.h>
  29. #include <linux/module.h>
  30. #include <linux/kernel.h>
  31. #include <linux/mtd/map.h>
  32. #include <linux/mtd/mtd.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <linux/types.h>
  35. #define WINDOW_ADDR 0x09400000
  36. #define WINDOW_SIZE 0x00200000
  37. static struct map_info ts5500_map = {
  38. .name = "TS-5500 Flash",
  39. .size = WINDOW_SIZE,
  40. .bankwidth = 1,
  41. .phys = WINDOW_ADDR
  42. };
  43. static struct mtd_partition ts5500_partitions[] = {
  44. {
  45. .name = "Drive A",
  46. .offset = 0,
  47. .size = 0x0e0000
  48. },
  49. {
  50. .name = "BIOS",
  51. .offset = 0x0e0000,
  52. .size = 0x020000,
  53. },
  54. {
  55. .name = "Drive B",
  56. .offset = 0x100000,
  57. .size = 0x100000
  58. }
  59. };
  60. #define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions)
  61. static struct mtd_info *mymtd;
  62. static int __init init_ts5500_map(void)
  63. {
  64. int rc = 0;
  65. ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size);
  66. if (!ts5500_map.virt) {
  67. printk(KERN_ERR "Failed to ioremap_nocache\n");
  68. rc = -EIO;
  69. goto err2;
  70. }
  71. simple_map_init(&ts5500_map);
  72. mymtd = do_map_probe("jedec_probe", &ts5500_map);
  73. if (!mymtd)
  74. mymtd = do_map_probe("map_rom", &ts5500_map);
  75. if (!mymtd) {
  76. rc = -ENXIO;
  77. goto err1;
  78. }
  79. mymtd->owner = THIS_MODULE;
  80. add_mtd_partitions(mymtd, ts5500_partitions, NUM_PARTITIONS);
  81. return 0;
  82. err1:
  83. map_destroy(mymtd);
  84. iounmap(ts5500_map.virt);
  85. err2:
  86. return rc;
  87. }
  88. static void __exit cleanup_ts5500_map(void)
  89. {
  90. if (mymtd) {
  91. del_mtd_partitions(mymtd);
  92. map_destroy(mymtd);
  93. }
  94. if (ts5500_map.virt) {
  95. iounmap(ts5500_map.virt);
  96. ts5500_map.virt = NULL;
  97. }
  98. }
  99. module_init(init_ts5500_map);
  100. module_exit(cleanup_ts5500_map);
  101. MODULE_LICENSE("GPL");
  102. MODULE_AUTHOR("Sean Young <sean@mess.org>");
  103. MODULE_DESCRIPTION("MTD map driver for Techology Systems TS-5500 board");