ts5500_flash.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 a proprietary FTL from General Software which isn't
  23. * supported as of yet so standard drives can't be mounted; you can create
  24. * your own (e.g. jffs) file system.
  25. * - If you have created your own jffs file system and the bios overwrites
  26. * it during boot, try disabling Drive A: and B: in the boot order.
  27. *
  28. * $Id: ts5500_flash.c,v 1.2 2004/11/28 09:40:40 dwmw2 Exp $
  29. */
  30. #include <linux/config.h>
  31. #include <linux/module.h>
  32. #include <linux/types.h>
  33. #include <linux/kernel.h>
  34. #include <linux/init.h>
  35. #include <linux/mtd/mtd.h>
  36. #include <linux/mtd/map.h>
  37. #ifdef CONFIG_MTD_PARTITIONS
  38. #include <linux/mtd/partitions.h>
  39. #endif
  40. #define WINDOW_ADDR 0x09400000
  41. #define WINDOW_SIZE 0x00200000
  42. static struct map_info ts5500_map = {
  43. .name = "TS-5500 Flash",
  44. .size = WINDOW_SIZE,
  45. .bankwidth = 1,
  46. .phys = WINDOW_ADDR
  47. };
  48. #ifdef CONFIG_MTD_PARTITIONS
  49. static struct mtd_partition ts5500_partitions[] = {
  50. {
  51. .name = "Drive A",
  52. .offset = 0,
  53. .size = 0x0e0000
  54. },
  55. {
  56. .name = "BIOS",
  57. .offset = 0x0e0000,
  58. .size = 0x020000,
  59. },
  60. {
  61. .name = "Drive B",
  62. .offset = 0x100000,
  63. .size = 0x100000
  64. }
  65. };
  66. #define NUM_PARTITIONS (sizeof(ts5500_partitions)/sizeof(struct mtd_partition))
  67. #endif
  68. static struct mtd_info *mymtd;
  69. static int __init init_ts5500_map(void)
  70. {
  71. int rc = 0;
  72. ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size);
  73. if(!ts5500_map.virt) {
  74. printk(KERN_ERR "Failed to ioremap_nocache\n");
  75. rc = -EIO;
  76. goto err_out_ioremap;
  77. }
  78. simple_map_init(&ts5500_map);
  79. mymtd = do_map_probe("jedec_probe", &ts5500_map);
  80. if(!mymtd)
  81. mymtd = do_map_probe("map_rom", &ts5500_map);
  82. if(!mymtd) {
  83. rc = -ENXIO;
  84. goto err_out_map;
  85. }
  86. mymtd->owner = THIS_MODULE;
  87. #ifdef CONFIG_MTD_PARTITIONS
  88. add_mtd_partitions(mymtd, ts5500_partitions, NUM_PARTITIONS);
  89. #else
  90. add_mtd_device(mymtd);
  91. #endif
  92. return 0;
  93. err_out_map:
  94. map_destroy(mymtd);
  95. err_out_ioremap:
  96. iounmap(ts5500_map.virt);
  97. return rc;
  98. }
  99. static void __exit cleanup_ts5500_map(void)
  100. {
  101. if (mymtd) {
  102. #ifdef CONFIG_MTD_PARTITIONS
  103. del_mtd_partitions(mymtd);
  104. #else
  105. del_mtd_device(mymtd);
  106. #endif
  107. map_destroy(mymtd);
  108. }
  109. if (ts5500_map.virt) {
  110. iounmap(ts5500_map.virt);
  111. ts5500_map.virt = NULL;
  112. }
  113. }
  114. module_init(init_ts5500_map);
  115. module_exit(cleanup_ts5500_map);
  116. MODULE_LICENSE("GPL");
  117. MODULE_AUTHOR("Sean Young <sean@mess.org>");
  118. MODULE_DESCRIPTION("MTD map driver for Techology Systems TS-5500 board");