floppy.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1996, 1997, 1998, 2003 by Ralf Baechle
  7. */
  8. #ifndef __ASM_MACH_GENERIC_FLOPPY_H
  9. #define __ASM_MACH_GENERIC_FLOPPY_H
  10. #include <linux/delay.h>
  11. #include <linux/ioport.h>
  12. #include <linux/sched.h>
  13. #include <linux/linkage.h>
  14. #include <linux/types.h>
  15. #include <linux/mm.h>
  16. #include <asm/bootinfo.h>
  17. #include <asm/cachectl.h>
  18. #include <asm/dma.h>
  19. #include <asm/floppy.h>
  20. #include <asm/io.h>
  21. #include <asm/irq.h>
  22. #include <asm/pgtable.h>
  23. /*
  24. * How to access the FDC's registers.
  25. */
  26. static inline unsigned char fd_inb(unsigned int port)
  27. {
  28. return inb_p(port);
  29. }
  30. static inline void fd_outb(unsigned char value, unsigned int port)
  31. {
  32. outb_p(value, port);
  33. }
  34. /*
  35. * How to access the floppy DMA functions.
  36. */
  37. static inline void fd_enable_dma(void)
  38. {
  39. enable_dma(FLOPPY_DMA);
  40. }
  41. static inline void fd_disable_dma(void)
  42. {
  43. disable_dma(FLOPPY_DMA);
  44. }
  45. static inline int fd_request_dma(void)
  46. {
  47. return request_dma(FLOPPY_DMA, "floppy");
  48. }
  49. static inline void fd_free_dma(void)
  50. {
  51. free_dma(FLOPPY_DMA);
  52. }
  53. static inline void fd_clear_dma_ff(void)
  54. {
  55. clear_dma_ff(FLOPPY_DMA);
  56. }
  57. static inline void fd_set_dma_mode(char mode)
  58. {
  59. set_dma_mode(FLOPPY_DMA, mode);
  60. }
  61. static inline void fd_set_dma_addr(char *addr)
  62. {
  63. set_dma_addr(FLOPPY_DMA, (unsigned long) addr);
  64. }
  65. static inline void fd_set_dma_count(unsigned int count)
  66. {
  67. set_dma_count(FLOPPY_DMA, count);
  68. }
  69. static inline int fd_get_dma_residue(void)
  70. {
  71. return get_dma_residue(FLOPPY_DMA);
  72. }
  73. static inline void fd_enable_irq(void)
  74. {
  75. enable_irq(FLOPPY_IRQ);
  76. }
  77. static inline void fd_disable_irq(void)
  78. {
  79. disable_irq(FLOPPY_IRQ);
  80. }
  81. static inline int fd_request_irq(void)
  82. {
  83. return request_irq(FLOPPY_IRQ, floppy_interrupt,
  84. 0, "floppy", NULL);
  85. }
  86. static inline void fd_free_irq(void)
  87. {
  88. free_irq(FLOPPY_IRQ, NULL);
  89. }
  90. #define fd_free_irq() free_irq(FLOPPY_IRQ, NULL);
  91. static inline unsigned long fd_getfdaddr1(void)
  92. {
  93. return 0x3f0;
  94. }
  95. static inline unsigned long fd_dma_mem_alloc(unsigned long size)
  96. {
  97. unsigned long mem;
  98. mem = __get_dma_pages(GFP_KERNEL, get_order(size));
  99. return mem;
  100. }
  101. static inline void fd_dma_mem_free(unsigned long addr, unsigned long size)
  102. {
  103. free_pages(addr, get_order(size));
  104. }
  105. static inline unsigned long fd_drive_type(unsigned long n)
  106. {
  107. if (n == 0)
  108. return 4; /* 3,5", 1.44mb */
  109. return 0;
  110. }
  111. #endif /* __ASM_MACH_GENERIC_FLOPPY_H */