dmv182.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * drivers/mtd/maps/svme182.c
  3. *
  4. * Flash map driver for the Dy4 SVME182 board
  5. *
  6. * $Id: dmv182.c,v 1.5 2004/11/04 13:24:14 gleixner Exp $
  7. *
  8. * Copyright 2003-2004, TimeSys Corporation
  9. *
  10. * Based on the SVME181 flash map, by Tom Nelson, Dot4, Inc. for TimeSys Corp.
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. */
  17. #include <linux/config.h>
  18. #include <linux/module.h>
  19. #include <linux/init.h>
  20. #include <linux/types.h>
  21. #include <linux/kernel.h>
  22. #include <asm/io.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/map.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <linux/errno.h>
  27. /*
  28. * This driver currently handles only the 16MiB user flash bank 1 on the
  29. * board. It does not provide access to bank 0 (contains the Dy4 FFW), bank 2
  30. * (VxWorks boot), or the optional 48MiB expansion flash.
  31. *
  32. * scott.wood@timesys.com: On the newer boards with 128MiB flash, it
  33. * now supports the first 96MiB (the boot flash bank containing FFW
  34. * is excluded). The VxWorks loader is in partition 1.
  35. */
  36. #define FLASH_BASE_ADDR 0xf0000000
  37. #define FLASH_BANK_SIZE (128*1024*1024)
  38. MODULE_AUTHOR("Scott Wood, TimeSys Corporation <scott.wood@timesys.com>");
  39. MODULE_DESCRIPTION("User-programmable flash device on the Dy4 SVME182 board");
  40. MODULE_LICENSE("GPL");
  41. static struct map_info svme182_map = {
  42. .name = "Dy4 SVME182",
  43. .bankwidth = 32,
  44. .size = 128 * 1024 * 1024
  45. };
  46. #define BOOTIMAGE_PART_SIZE ((6*1024*1024)-RESERVED_PART_SIZE)
  47. // Allow 6MiB for the kernel
  48. #define NEW_BOOTIMAGE_PART_SIZE (6 * 1024 * 1024)
  49. // Allow 1MiB for the bootloader
  50. #define NEW_BOOTLOADER_PART_SIZE (1024 * 1024)
  51. // Use the remaining 9MiB at the end of flash for the RFS
  52. #define NEW_RFS_PART_SIZE (0x01000000 - NEW_BOOTLOADER_PART_SIZE - \
  53. NEW_BOOTIMAGE_PART_SIZE)
  54. static struct mtd_partition svme182_partitions[] = {
  55. // The Lower PABS is only 128KiB, but the partition code doesn't
  56. // like partitions that don't end on the largest erase block
  57. // size of the device, even if all of the erase blocks in the
  58. // partition are small ones. The hardware should prevent
  59. // writes to the actual PABS areas.
  60. {
  61. name: "Lower PABS and CPU 0 bootloader or kernel",
  62. size: 6*1024*1024,
  63. offset: 0,
  64. },
  65. {
  66. name: "Root Filesystem",
  67. size: 10*1024*1024,
  68. offset: MTDPART_OFS_NXTBLK
  69. },
  70. {
  71. name: "CPU1 Bootloader",
  72. size: 1024*1024,
  73. offset: MTDPART_OFS_NXTBLK,
  74. },
  75. {
  76. name: "Extra",
  77. size: 110*1024*1024,
  78. offset: MTDPART_OFS_NXTBLK
  79. },
  80. {
  81. name: "Foundation Firmware and Upper PABS",
  82. size: 1024*1024,
  83. offset: MTDPART_OFS_NXTBLK,
  84. mask_flags: MTD_WRITEABLE // read-only
  85. }
  86. };
  87. static struct mtd_info *this_mtd;
  88. static int __init init_svme182(void)
  89. {
  90. struct mtd_partition *partitions;
  91. int num_parts = sizeof(svme182_partitions) / sizeof(struct mtd_partition);
  92. partitions = svme182_partitions;
  93. svme182_map.virt = ioremap(FLASH_BASE_ADDR, svme182_map.size);
  94. if (svme182_map.virt == 0) {
  95. printk("Failed to ioremap FLASH memory area.\n");
  96. return -EIO;
  97. }
  98. simple_map_init(&svme182_map);
  99. this_mtd = do_map_probe("cfi_probe", &svme182_map);
  100. if (!this_mtd)
  101. {
  102. iounmap((void *)svme182_map.virt);
  103. return -ENXIO;
  104. }
  105. printk(KERN_NOTICE "SVME182 flash device: %dMiB at 0x%08x\n",
  106. this_mtd->size >> 20, FLASH_BASE_ADDR);
  107. this_mtd->owner = THIS_MODULE;
  108. add_mtd_partitions(this_mtd, partitions, num_parts);
  109. return 0;
  110. }
  111. static void __exit cleanup_svme182(void)
  112. {
  113. if (this_mtd)
  114. {
  115. del_mtd_partitions(this_mtd);
  116. map_destroy(this_mtd);
  117. }
  118. if (svme182_map.virt)
  119. {
  120. iounmap((void *)svme182_map.virt);
  121. svme182_map.virt = 0;
  122. }
  123. return;
  124. }
  125. module_init(init_svme182);
  126. module_exit(cleanup_svme182);