ts5500_flash.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * ts5500_flash.c -- MTD map driver for Technology Systems TS-5500 board
  4. *
  5. * Copyright (C) 2004 Sean Young <[email protected]>
  6. *
  7. * Note:
  8. * - In order for detection to work, jumper 3 must be set.
  9. * - Drive A and B use the resident flash disk (RFD) flash translation layer.
  10. * - If you have created your own jffs file system and the bios overwrites
  11. * it during boot, try disabling Drive A: and B: in the boot order.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/mtd/map.h>
  17. #include <linux/mtd/mtd.h>
  18. #include <linux/mtd/partitions.h>
  19. #include <linux/types.h>
  20. #define WINDOW_ADDR 0x09400000
  21. #define WINDOW_SIZE 0x00200000
  22. static struct map_info ts5500_map = {
  23. .name = "TS-5500 Flash",
  24. .size = WINDOW_SIZE,
  25. .bankwidth = 1,
  26. .phys = WINDOW_ADDR
  27. };
  28. static const struct mtd_partition ts5500_partitions[] = {
  29. {
  30. .name = "Drive A",
  31. .offset = 0,
  32. .size = 0x0e0000
  33. },
  34. {
  35. .name = "BIOS",
  36. .offset = 0x0e0000,
  37. .size = 0x020000,
  38. },
  39. {
  40. .name = "Drive B",
  41. .offset = 0x100000,
  42. .size = 0x100000
  43. }
  44. };
  45. #define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions)
  46. static struct mtd_info *mymtd;
  47. static int __init init_ts5500_map(void)
  48. {
  49. int rc = 0;
  50. ts5500_map.virt = ioremap(ts5500_map.phys, ts5500_map.size);
  51. if (!ts5500_map.virt) {
  52. printk(KERN_ERR "Failed to ioremap\n");
  53. rc = -EIO;
  54. goto err2;
  55. }
  56. simple_map_init(&ts5500_map);
  57. mymtd = do_map_probe("jedec_probe", &ts5500_map);
  58. if (!mymtd)
  59. mymtd = do_map_probe("map_rom", &ts5500_map);
  60. if (!mymtd) {
  61. rc = -ENXIO;
  62. goto err1;
  63. }
  64. mymtd->owner = THIS_MODULE;
  65. mtd_device_register(mymtd, ts5500_partitions, NUM_PARTITIONS);
  66. return 0;
  67. err1:
  68. iounmap(ts5500_map.virt);
  69. err2:
  70. return rc;
  71. }
  72. static void __exit cleanup_ts5500_map(void)
  73. {
  74. if (mymtd) {
  75. mtd_device_unregister(mymtd);
  76. map_destroy(mymtd);
  77. }
  78. if (ts5500_map.virt) {
  79. iounmap(ts5500_map.virt);
  80. ts5500_map.virt = NULL;
  81. }
  82. }
  83. module_init(init_ts5500_map);
  84. module_exit(cleanup_ts5500_map);
  85. MODULE_LICENSE("GPL");
  86. MODULE_AUTHOR("Sean Young <[email protected]>");
  87. MODULE_DESCRIPTION("MTD map driver for Technology Systems TS-5500 board");