sharpsl-flash.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * sharpsl-flash.c
  3. *
  4. * Copyright (C) 2001 Lineo Japan, Inc.
  5. * Copyright (C) 2002 SHARP
  6. *
  7. * based on rpxlite.c,v 1.15 2001/10/02 15:05:14 dwmw2 Exp
  8. * Handle mapping of the flash on the RPX Lite and CLLF boards
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. */
  21. #include <linux/module.h>
  22. #include <linux/types.h>
  23. #include <linux/kernel.h>
  24. #include <linux/mtd/mtd.h>
  25. #include <linux/mtd/map.h>
  26. #include <linux/mtd/partitions.h>
  27. #include <asm/io.h>
  28. #include <asm/mach-types.h>
  29. #define WINDOW_ADDR 0x00000000
  30. #define WINDOW_SIZE 0x00800000
  31. #define BANK_WIDTH 2
  32. static struct mtd_info *mymtd;
  33. struct map_info sharpsl_map = {
  34. .name = "sharpsl-flash",
  35. .size = WINDOW_SIZE,
  36. .bankwidth = BANK_WIDTH,
  37. .phys = WINDOW_ADDR
  38. };
  39. static struct mtd_partition sharpsl_partitions[1] = {
  40. {
  41. name: "Boot PROM Filesystem",
  42. }
  43. };
  44. int __init init_sharpsl(void)
  45. {
  46. struct mtd_partition *parts;
  47. int nb_parts = 0;
  48. char *part_type = "static";
  49. printk(KERN_NOTICE "Sharp SL series flash device: %x at %x\n",
  50. WINDOW_SIZE, WINDOW_ADDR);
  51. sharpsl_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
  52. if (!sharpsl_map.virt) {
  53. printk("Failed to ioremap\n");
  54. return -EIO;
  55. }
  56. simple_map_init(&sharpsl_map);
  57. mymtd = do_map_probe("map_rom", &sharpsl_map);
  58. if (!mymtd) {
  59. iounmap(sharpsl_map.virt);
  60. return -ENXIO;
  61. }
  62. mymtd->owner = THIS_MODULE;
  63. if (machine_is_corgi() || machine_is_shepherd() || machine_is_husky()
  64. || machine_is_poodle()) {
  65. sharpsl_partitions[0].size=0x006d0000;
  66. sharpsl_partitions[0].offset=0x00120000;
  67. } else if (machine_is_tosa()) {
  68. sharpsl_partitions[0].size=0x006a0000;
  69. sharpsl_partitions[0].offset=0x00160000;
  70. } else if (machine_is_spitz() || machine_is_akita() || machine_is_borzoi()) {
  71. sharpsl_partitions[0].size=0x006b0000;
  72. sharpsl_partitions[0].offset=0x00140000;
  73. } else {
  74. map_destroy(mymtd);
  75. iounmap(sharpsl_map.virt);
  76. return -ENODEV;
  77. }
  78. parts = sharpsl_partitions;
  79. nb_parts = ARRAY_SIZE(sharpsl_partitions);
  80. printk(KERN_NOTICE "Using %s partition definition\n", part_type);
  81. add_mtd_partitions(mymtd, parts, nb_parts);
  82. return 0;
  83. }
  84. static void __exit cleanup_sharpsl(void)
  85. {
  86. if (mymtd) {
  87. del_mtd_partitions(mymtd);
  88. map_destroy(mymtd);
  89. }
  90. if (sharpsl_map.virt) {
  91. iounmap(sharpsl_map.virt);
  92. sharpsl_map.virt = 0;
  93. }
  94. }
  95. module_init(init_sharpsl);
  96. module_exit(cleanup_sharpsl);
  97. MODULE_LICENSE("GPL");
  98. MODULE_AUTHOR("SHARP (Original: Arnold Christensen <AKC@pel.dk>)");
  99. MODULE_DESCRIPTION("MTD map driver for SHARP SL series");