lasat.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Flash device on Lasat 100 and 200 boards
  3. *
  4. * (C) 2002 Brian Murphy <brian@murphy.dk>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License version
  8. * 2 as published by the Free Software Foundation.
  9. *
  10. * $Id: lasat.c,v 1.9 2004/11/04 13:24:15 gleixner Exp $
  11. *
  12. */
  13. #include <linux/module.h>
  14. #include <linux/types.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <asm/io.h>
  18. #include <linux/mtd/mtd.h>
  19. #include <linux/mtd/map.h>
  20. #include <linux/mtd/partitions.h>
  21. #include <asm/lasat/lasat.h>
  22. static struct mtd_info *lasat_mtd;
  23. static struct mtd_partition partition_info[LASAT_MTD_LAST];
  24. static char *lasat_mtd_partnames[] = {"Bootloader", "Service", "Normal", "Filesystem", "Config"};
  25. static void lasat_set_vpp(struct map_info *map, int vpp)
  26. {
  27. if (vpp)
  28. *lasat_misc->flash_wp_reg |= 1 << lasat_misc->flash_wp_bit;
  29. else
  30. *lasat_misc->flash_wp_reg &= ~(1 << lasat_misc->flash_wp_bit);
  31. }
  32. static struct map_info lasat_map = {
  33. .name = "LASAT flash",
  34. .bankwidth = 4,
  35. .set_vpp = lasat_set_vpp
  36. };
  37. static int __init init_lasat(void)
  38. {
  39. int i;
  40. /* since we use AMD chips and set_vpp is not implimented
  41. * for these (yet) we still have to permanently enable flash write */
  42. printk(KERN_NOTICE "Unprotecting flash\n");
  43. ENABLE_VPP((&lasat_map));
  44. lasat_map.phys = lasat_flash_partition_start(LASAT_MTD_BOOTLOADER);
  45. lasat_map.virt = ioremap_nocache(
  46. lasat_map.phys, lasat_board_info.li_flash_size);
  47. lasat_map.size = lasat_board_info.li_flash_size;
  48. simple_map_init(&lasat_map);
  49. for (i=0; i < LASAT_MTD_LAST; i++)
  50. partition_info[i].name = lasat_mtd_partnames[i];
  51. lasat_mtd = do_map_probe("cfi_probe", &lasat_map);
  52. if (!lasat_mtd)
  53. lasat_mtd = do_map_probe("jedec_probe", &lasat_map);
  54. if (lasat_mtd) {
  55. u32 size, offset = 0;
  56. lasat_mtd->owner = THIS_MODULE;
  57. for (i=0; i < LASAT_MTD_LAST; i++) {
  58. size = lasat_flash_partition_size(i);
  59. partition_info[i].size = size;
  60. partition_info[i].offset = offset;
  61. offset += size;
  62. }
  63. add_mtd_partitions( lasat_mtd, partition_info, LASAT_MTD_LAST );
  64. return 0;
  65. }
  66. iounmap(lasat_map.virt);
  67. return -ENXIO;
  68. }
  69. static void __exit cleanup_lasat(void)
  70. {
  71. if (lasat_mtd) {
  72. del_mtd_partitions(lasat_mtd);
  73. map_destroy(lasat_mtd);
  74. }
  75. if (lasat_map.virt) {
  76. iounmap(lasat_map.virt);
  77. lasat_map.virt = 0;
  78. }
  79. }
  80. module_init(init_lasat);
  81. module_exit(cleanup_lasat);
  82. MODULE_LICENSE("GPL");
  83. MODULE_AUTHOR("Brian Murphy <brian@murphy.dk>");
  84. MODULE_DESCRIPTION("Lasat Safepipe/Masquerade MTD map driver");