floppy.h 2.4 KB

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