floppy.h 2.5 KB

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