mbx860.c 2.4 KB

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