sharpsl-flash.c 3.0 KB

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