lasat.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 <linux/config.h>
  22. #include <asm/lasat/lasat.h>
  23. static struct mtd_info *lasat_mtd;
  24. static struct mtd_partition partition_info[LASAT_MTD_LAST];
  25. static char *lasat_mtd_partnames[] = {"Bootloader", "Service", "Normal", "Filesystem", "Config"};
  26. static void lasat_set_vpp(struct map_info *map, int vpp)
  27. {
  28. if (vpp)
  29. *lasat_misc->flash_wp_reg |= 1 << lasat_misc->flash_wp_bit;
  30. else
  31. *lasat_misc->flash_wp_reg &= ~(1 << lasat_misc->flash_wp_bit);
  32. }
  33. static struct map_info lasat_map = {
  34. .name = "LASAT flash",
  35. .bankwidth = 4,
  36. .set_vpp = lasat_set_vpp
  37. };
  38. static int __init init_lasat(void)
  39. {
  40. int i;
  41. /* since we use AMD chips and set_vpp is not implimented
  42. * for these (yet) we still have to permanently enable flash write */
  43. printk(KERN_NOTICE "Unprotecting flash\n");
  44. ENABLE_VPP((&lasat_map));
  45. lasat_map.phys = lasat_flash_partition_start(LASAT_MTD_BOOTLOADER);
  46. lasat_map.virt = ioremap_nocache(
  47. lasat_map.phys, lasat_board_info.li_flash_size);
  48. lasat_map.size = lasat_board_info.li_flash_size;
  49. simple_map_init(&lasat_map);
  50. for (i=0; i < LASAT_MTD_LAST; i++)
  51. partition_info[i].name = lasat_mtd_partnames[i];
  52. lasat_mtd = do_map_probe("cfi_probe", &lasat_map);
  53. if (!lasat_mtd)
  54. lasat_mtd = do_map_probe("jedec_probe", &lasat_map);
  55. if (lasat_mtd) {
  56. u32 size, offset = 0;
  57. lasat_mtd->owner = THIS_MODULE;
  58. for (i=0; i < LASAT_MTD_LAST; i++) {
  59. size = lasat_flash_partition_size(i);
  60. partition_info[i].size = size;
  61. partition_info[i].offset = offset;
  62. offset += size;
  63. }
  64. add_mtd_partitions( lasat_mtd, partition_info, LASAT_MTD_LAST );
  65. return 0;
  66. }
  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. lasat_map.virt = 0;
  77. }
  78. }
  79. module_init(init_lasat);
  80. module_exit(cleanup_lasat);
  81. MODULE_LICENSE("GPL");
  82. MODULE_AUTHOR("Brian Murphy <brian@murphy.dk>");
  83. MODULE_DESCRIPTION("Lasat Safepipe/Masquerade MTD map driver");