latches.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * linux/arch/arm26/kernel/latches.c
  3. *
  4. * Copyright (C) David Alan Gilbert 1995/1996,2000
  5. * Copyright (C) Ian Molton 2003
  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. * Support for the latches on the old Archimedes which control the floppy,
  12. * hard disc and printer
  13. */
  14. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/sched.h>
  18. #include <asm/io.h>
  19. #include <asm/hardware.h>
  20. #include <asm/mach-types.h>
  21. #include <asm/oldlatches.h>
  22. static unsigned char latch_a_copy;
  23. static unsigned char latch_b_copy;
  24. /* newval=(oldval & ~mask)|newdata */
  25. void oldlatch_aupdate(unsigned char mask,unsigned char newdata)
  26. {
  27. unsigned long flags;
  28. BUG_ON(!machine_is_archimedes());
  29. local_irq_save(flags); //FIXME: was local_save_flags
  30. latch_a_copy = (latch_a_copy & ~mask) | newdata;
  31. __raw_writeb(latch_a_copy, LATCHA_BASE);
  32. local_irq_restore(flags);
  33. printk("Latch: A = 0x%02x\n", latch_a_copy);
  34. }
  35. /* newval=(oldval & ~mask)|newdata */
  36. void oldlatch_bupdate(unsigned char mask,unsigned char newdata)
  37. {
  38. unsigned long flags;
  39. BUG_ON(!machine_is_archimedes());
  40. local_irq_save(flags);//FIXME: was local_save_flags
  41. latch_b_copy = (latch_b_copy & ~mask) | newdata;
  42. __raw_writeb(latch_b_copy, LATCHB_BASE);
  43. local_irq_restore(flags);
  44. printk("Latch: B = 0x%02x\n", latch_b_copy);
  45. }
  46. static int __init oldlatch_init(void)
  47. {
  48. if (machine_is_archimedes()) {
  49. oldlatch_aupdate(0xff, 0xff);
  50. /* Thats no FDC reset...*/
  51. oldlatch_bupdate(0xff, LATCHB_FDCRESET);
  52. }
  53. return 0;
  54. }
  55. arch_initcall(oldlatch_init);
  56. EXPORT_SYMBOL(oldlatch_aupdate);
  57. EXPORT_SYMBOL(oldlatch_bupdate);