mbx860.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * $Id: mbx860.c,v 1.9 2005/11/07 11:14:27 gleixner Exp $
  3. *
  4. * Handle mapping of the flash on MBX860 boards
  5. *
  6. * Author: Anton Todorov
  7. * Copyright: (C) 2001 Emness Technology
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. */
  14. #include <linux/module.h>
  15. #include <linux/types.h>
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <asm/io.h>
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/map.h>
  21. #include <linux/mtd/partitions.h>
  22. #define WINDOW_ADDR 0xfe000000
  23. #define WINDOW_SIZE 0x00200000
  24. /* Flash / Partition sizing */
  25. #define MAX_SIZE_KiB 8192
  26. #define BOOT_PARTITION_SIZE_KiB 512
  27. #define KERNEL_PARTITION_SIZE_KiB 5632
  28. #define APP_PARTITION_SIZE_KiB 2048
  29. #define NUM_PARTITIONS 3
  30. /* partition_info gives details on the logical partitions that the split the
  31. * single flash device into. If the size if zero we use up to the end of the
  32. * device. */
  33. static struct mtd_partition partition_info[]={
  34. { .name = "MBX flash BOOT partition",
  35. .offset = 0,
  36. .size = BOOT_PARTITION_SIZE_KiB*1024 },
  37. { .name = "MBX flash DATA partition",
  38. .offset = BOOT_PARTITION_SIZE_KiB*1024,
  39. .size = (KERNEL_PARTITION_SIZE_KiB)*1024 },
  40. { .name = "MBX flash APPLICATION partition",
  41. .offset = (BOOT_PARTITION_SIZE_KiB+KERNEL_PARTITION_SIZE_KiB)*1024 }
  42. };
  43. static struct mtd_info *mymtd;
  44. struct map_info mbx_map = {
  45. .name = "MBX flash",
  46. .size = WINDOW_SIZE,
  47. .phys = WINDOW_ADDR,
  48. .bankwidth = 4,
  49. };
  50. int __init init_mbx(void)
  51. {
  52. printk(KERN_NOTICE "Motorola MBX flash device: 0x%x at 0x%x\n", WINDOW_SIZE*4, WINDOW_ADDR);
  53. mbx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
  54. if (!mbx_map.virt) {
  55. printk("Failed to ioremap\n");
  56. return -EIO;
  57. }
  58. simple_map_init(&mbx_map);
  59. mymtd = do_map_probe("jedec_probe", &mbx_map);
  60. if (mymtd) {
  61. mymtd->owner = THIS_MODULE;
  62. add_mtd_device(mymtd);
  63. add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
  64. return 0;
  65. }
  66. iounmap((void *)mbx_map.virt);
  67. return -ENXIO;
  68. }
  69. static void __exit cleanup_mbx(void)
  70. {
  71. if (mymtd) {
  72. del_mtd_device(mymtd);
  73. map_destroy(mymtd);
  74. }
  75. if (mbx_map.virt) {
  76. iounmap((void *)mbx_map.virt);
  77. mbx_map.virt = 0;
  78. }
  79. }
  80. module_init(init_mbx);
  81. module_exit(cleanup_mbx);
  82. MODULE_AUTHOR("Anton Todorov <a.todorov@emness.com>");
  83. MODULE_DESCRIPTION("MTD map driver for Motorola MBX860 board");
  84. MODULE_LICENSE("GPL");