arctic-mtd.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * $Id: arctic-mtd.c,v 1.14 2005/11/07 11:14:26 gleixner Exp $
  3. *
  4. * drivers/mtd/maps/arctic-mtd.c MTD mappings and partition tables for
  5. * IBM 405LP Arctic boards.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. * Copyright (C) 2002, International Business Machines Corporation
  22. * All Rights Reserved.
  23. *
  24. * Bishop Brock
  25. * IBM Research, Austin Center for Low-Power Computing
  26. * bcbrock@us.ibm.com
  27. * March 2002
  28. *
  29. * modified for Arctic by,
  30. * David Gibson
  31. * IBM OzLabs, Canberra, Australia
  32. * <arctic@gibson.dropbear.id.au>
  33. */
  34. #include <linux/kernel.h>
  35. #include <linux/module.h>
  36. #include <linux/types.h>
  37. #include <linux/init.h>
  38. #include <linux/mtd/mtd.h>
  39. #include <linux/mtd/map.h>
  40. #include <linux/mtd/partitions.h>
  41. #include <asm/io.h>
  42. #include <asm/ibm4xx.h>
  43. /*
  44. * 0 : 0xFE00 0000 - 0xFEFF FFFF : Filesystem 1 (16MiB)
  45. * 1 : 0xFF00 0000 - 0xFF4F FFFF : kernel (5.12MiB)
  46. * 2 : 0xFF50 0000 - 0xFFF5 FFFF : Filesystem 2 (10.624MiB) (if non-XIP)
  47. * 3 : 0xFFF6 0000 - 0xFFFF FFFF : PIBS Firmware (640KiB)
  48. */
  49. #define FFS1_SIZE 0x01000000 /* 16MiB */
  50. #define KERNEL_SIZE 0x00500000 /* 5.12MiB */
  51. #define FFS2_SIZE 0x00a60000 /* 10.624MiB */
  52. #define FIRMWARE_SIZE 0x000a0000 /* 640KiB */
  53. #define NAME "Arctic Linux Flash"
  54. #define PADDR SUBZERO_BOOTFLASH_PADDR
  55. #define BUSWIDTH 2
  56. #define SIZE SUBZERO_BOOTFLASH_SIZE
  57. #define PARTITIONS 4
  58. /* Flash memories on these boards are memory resources, accessed big-endian. */
  59. {
  60. /* do nothing for now */
  61. }
  62. static struct map_info arctic_mtd_map = {
  63. .name = NAME,
  64. .size = SIZE,
  65. .bankwidth = BUSWIDTH,
  66. .phys = PADDR,
  67. };
  68. static struct mtd_info *arctic_mtd;
  69. static struct mtd_partition arctic_partitions[PARTITIONS] = {
  70. { .name = "Filesystem",
  71. .size = FFS1_SIZE,
  72. .offset = 0,},
  73. { .name = "Kernel",
  74. .size = KERNEL_SIZE,
  75. .offset = FFS1_SIZE,},
  76. { .name = "Filesystem",
  77. .size = FFS2_SIZE,
  78. .offset = FFS1_SIZE + KERNEL_SIZE,},
  79. { .name = "Firmware",
  80. .size = FIRMWARE_SIZE,
  81. .offset = SUBZERO_BOOTFLASH_SIZE - FIRMWARE_SIZE,},
  82. };
  83. static int __init
  84. init_arctic_mtd(void)
  85. {
  86. printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR);
  87. arctic_mtd_map.virt = ioremap(PADDR, SIZE);
  88. if (!arctic_mtd_map.virt) {
  89. printk("%s: failed to ioremap 0x%x\n", NAME, PADDR);
  90. return -EIO;
  91. }
  92. simple_map_init(&arctic_mtd_map);
  93. printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8);
  94. arctic_mtd = do_map_probe("cfi_probe", &arctic_mtd_map);
  95. if (!arctic_mtd)
  96. return -ENXIO;
  97. arctic_mtd->owner = THIS_MODULE;
  98. return add_mtd_partitions(arctic_mtd, arctic_partitions, PARTITIONS);
  99. }
  100. static void __exit
  101. cleanup_arctic_mtd(void)
  102. {
  103. if (arctic_mtd) {
  104. del_mtd_partitions(arctic_mtd);
  105. map_destroy(arctic_mtd);
  106. iounmap((void *) arctic_mtd_map.virt);
  107. }
  108. }
  109. module_init(init_arctic_mtd);
  110. module_exit(cleanup_arctic_mtd);
  111. MODULE_LICENSE("GPL");
  112. MODULE_AUTHOR("David Gibson <arctic@gibson.dropbear.id.au>");
  113. MODULE_DESCRIPTION("MTD map and partitions for IBM 405LP Arctic boards");