netsc520.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* netsc520.c -- MTD map driver for AMD NetSc520 Demonstration Board
  2. *
  3. * Copyright (C) 2001 Mark Langsdorf (mark.langsdorf@amd.com)
  4. * based on sc520cdp.c by Sysgo Real-Time Solutions GmbH
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  19. *
  20. * The NetSc520 is a demonstration board for the Elan Sc520 processor available
  21. * from AMD. It has a single back of 16 megs of 32-bit Flash ROM and another
  22. * 16 megs of SDRAM.
  23. */
  24. #include <linux/module.h>
  25. #include <linux/types.h>
  26. #include <linux/kernel.h>
  27. #include <linux/init.h>
  28. #include <asm/io.h>
  29. #include <linux/mtd/mtd.h>
  30. #include <linux/mtd/map.h>
  31. #include <linux/mtd/partitions.h>
  32. /*
  33. ** The single, 16 megabyte flash bank is divided into four virtual
  34. ** partitions. The first partition is 768 KiB and is intended to
  35. ** store the kernel image loaded by the bootstrap loader. The second
  36. ** partition is 256 KiB and holds the BIOS image. The third
  37. ** partition is 14.5 MiB and is intended for the flash file system
  38. ** image. The last partition is 512 KiB and contains another copy
  39. ** of the BIOS image and the reset vector.
  40. **
  41. ** Only the third partition should be mounted. The first partition
  42. ** should not be mounted, but it can erased and written to using the
  43. ** MTD character routines. The second and fourth partitions should
  44. ** not be touched - it is possible to corrupt the BIOS image by
  45. ** mounting these partitions, and potentially the board will not be
  46. ** recoverable afterwards.
  47. */
  48. /* partition_info gives details on the logical partitions that the split the
  49. * single flash device into. If the size if zero we use up to the end of the
  50. * device. */
  51. static struct mtd_partition partition_info[]={
  52. {
  53. .name = "NetSc520 boot kernel",
  54. .offset = 0,
  55. .size = 0xc0000
  56. },
  57. {
  58. .name = "NetSc520 Low BIOS",
  59. .offset = 0xc0000,
  60. .size = 0x40000
  61. },
  62. {
  63. .name = "NetSc520 file system",
  64. .offset = 0x100000,
  65. .size = 0xe80000
  66. },
  67. {
  68. .name = "NetSc520 High BIOS",
  69. .offset = 0xf80000,
  70. .size = 0x80000
  71. },
  72. };
  73. #define NUM_PARTITIONS ARRAY_SIZE(partition_info)
  74. #define WINDOW_SIZE 0x00100000
  75. #define WINDOW_ADDR 0x00200000
  76. static struct map_info netsc520_map = {
  77. .name = "netsc520 Flash Bank",
  78. .size = WINDOW_SIZE,
  79. .bankwidth = 4,
  80. .phys = WINDOW_ADDR,
  81. };
  82. #define NUM_FLASH_BANKS ARRAY_SIZE(netsc520_map)
  83. static struct mtd_info *mymtd;
  84. static int __init init_netsc520(void)
  85. {
  86. printk(KERN_NOTICE "NetSc520 flash device: 0x%Lx at 0x%Lx\n",
  87. (unsigned long long)netsc520_map.size,
  88. (unsigned long long)netsc520_map.phys);
  89. netsc520_map.virt = ioremap_nocache(netsc520_map.phys, netsc520_map.size);
  90. if (!netsc520_map.virt) {
  91. printk("Failed to ioremap_nocache\n");
  92. return -EIO;
  93. }
  94. simple_map_init(&netsc520_map);
  95. mymtd = do_map_probe("cfi_probe", &netsc520_map);
  96. if(!mymtd)
  97. mymtd = do_map_probe("map_ram", &netsc520_map);
  98. if(!mymtd)
  99. mymtd = do_map_probe("map_rom", &netsc520_map);
  100. if (!mymtd) {
  101. iounmap(netsc520_map.virt);
  102. return -ENXIO;
  103. }
  104. mymtd->owner = THIS_MODULE;
  105. mtd_device_register(mymtd, partition_info, NUM_PARTITIONS);
  106. return 0;
  107. }
  108. static void __exit cleanup_netsc520(void)
  109. {
  110. if (mymtd) {
  111. mtd_device_unregister(mymtd);
  112. map_destroy(mymtd);
  113. }
  114. if (netsc520_map.virt) {
  115. iounmap(netsc520_map.virt);
  116. netsc520_map.virt = NULL;
  117. }
  118. }
  119. module_init(init_netsc520);
  120. module_exit(cleanup_netsc520);
  121. MODULE_LICENSE("GPL");
  122. MODULE_AUTHOR("Mark Langsdorf <mark.langsdorf@amd.com>");
  123. MODULE_DESCRIPTION("MTD map driver for AMD NetSc520 Demonstration Board");