sharpsl-flash.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.2 2004/11/24 20:38:06 rpurdie 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 <asm/io.h>
  27. #include <linux/mtd/mtd.h>
  28. #include <linux/mtd/map.h>
  29. #include <linux/mtd/partitions.h>
  30. #define WINDOW_ADDR 0x00000000
  31. #define WINDOW_SIZE 0x01000000
  32. #define BANK_WIDTH 2
  33. static struct mtd_info *mymtd;
  34. struct map_info sharpsl_map = {
  35. .name = "sharpsl-flash",
  36. .size = WINDOW_SIZE,
  37. .bankwidth = BANK_WIDTH,
  38. .phys = WINDOW_ADDR
  39. };
  40. static struct mtd_partition sharpsl_partitions[1] = {
  41. {
  42. name: "Filesystem",
  43. size: 0x006d0000,
  44. offset: 0x00120000
  45. }
  46. };
  47. #define NB_OF(x) (sizeof(x)/sizeof(x[0]))
  48. int __init init_sharpsl(void)
  49. {
  50. struct mtd_partition *parts;
  51. int nb_parts = 0;
  52. char *part_type = "static";
  53. printk(KERN_NOTICE "Sharp SL series flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR);
  54. sharpsl_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
  55. if (!sharpsl_map.virt) {
  56. printk("Failed to ioremap\n");
  57. return -EIO;
  58. }
  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. parts = sharpsl_partitions;
  66. nb_parts = NB_OF(sharpsl_partitions);
  67. printk(KERN_NOTICE "Using %s partision definition\n", part_type);
  68. add_mtd_partitions(mymtd, parts, nb_parts);
  69. return 0;
  70. }
  71. static void __exit cleanup_sharpsl(void)
  72. {
  73. if (mymtd) {
  74. del_mtd_partitions(mymtd);
  75. map_destroy(mymtd);
  76. }
  77. if (sharpsl_map.virt) {
  78. iounmap(sharpsl_map.virt);
  79. sharpsl_map.virt = 0;
  80. }
  81. }
  82. module_init(init_sharpsl);
  83. module_exit(cleanup_sharpsl);
  84. MODULE_LICENSE("GPL");
  85. MODULE_AUTHOR("SHARP (Original: Arnold Christensen <AKC@pel.dk>)");
  86. MODULE_DESCRIPTION("MTD map driver for SHARP SL series");