rpxlite.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Handle mapping of the flash on the RPX Lite and CLLF boards
  3. */
  4. #include <linux/module.h>
  5. #include <linux/types.h>
  6. #include <linux/kernel.h>
  7. #include <linux/init.h>
  8. #include <asm/io.h>
  9. #include <linux/mtd/mtd.h>
  10. #include <linux/mtd/map.h>
  11. #define WINDOW_ADDR 0xfe000000
  12. #define WINDOW_SIZE 0x800000
  13. static struct mtd_info *mymtd;
  14. static struct map_info rpxlite_map = {
  15. .name = "RPX",
  16. .size = WINDOW_SIZE,
  17. .bankwidth = 4,
  18. .phys = WINDOW_ADDR,
  19. };
  20. static int __init init_rpxlite(void)
  21. {
  22. printk(KERN_NOTICE "RPX Lite or CLLF flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR);
  23. rpxlite_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
  24. if (!rpxlite_map.virt) {
  25. printk("Failed to ioremap\n");
  26. return -EIO;
  27. }
  28. simple_map_init(&rpxlite_map);
  29. mymtd = do_map_probe("cfi_probe", &rpxlite_map);
  30. if (mymtd) {
  31. mymtd->owner = THIS_MODULE;
  32. mtd_device_register(mymtd, NULL, 0);
  33. return 0;
  34. }
  35. iounmap((void *)rpxlite_map.virt);
  36. return -ENXIO;
  37. }
  38. static void __exit cleanup_rpxlite(void)
  39. {
  40. if (mymtd) {
  41. mtd_device_unregister(mymtd);
  42. map_destroy(mymtd);
  43. }
  44. if (rpxlite_map.virt) {
  45. iounmap((void *)rpxlite_map.virt);
  46. rpxlite_map.virt = 0;
  47. }
  48. }
  49. module_init(init_rpxlite);
  50. module_exit(cleanup_rpxlite);
  51. MODULE_LICENSE("GPL");
  52. MODULE_AUTHOR("Arnold Christensen <AKC@pel.dk>");
  53. MODULE_DESCRIPTION("MTD map driver for RPX Lite and CLLF boards");