floppy.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * arch/arm/include/asm/floppy.h
  3. *
  4. * Copyright (C) 1996-2000 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Note that we don't touch FLOPPY_DMA nor FLOPPY_IRQ here
  11. */
  12. #ifndef __ASM_ARM_FLOPPY_H
  13. #define __ASM_ARM_FLOPPY_H
  14. #if 0
  15. #include <mach/floppy.h>
  16. #endif
  17. #define fd_outb(val,port) \
  18. do { \
  19. if ((port) == (u32)FD_DOR) \
  20. fd_setdor((val)); \
  21. else \
  22. outb((val),(port)); \
  23. } while(0)
  24. #define fd_inb(port) inb((port))
  25. #define fd_request_irq() request_irq(IRQ_FLOPPYDISK,floppy_interrupt,\
  26. 0,"floppy",NULL)
  27. #define fd_free_irq() free_irq(IRQ_FLOPPYDISK,NULL)
  28. #define fd_disable_irq() disable_irq(IRQ_FLOPPYDISK)
  29. #define fd_enable_irq() enable_irq(IRQ_FLOPPYDISK)
  30. static inline int fd_dma_setup(void *data, unsigned int length,
  31. unsigned int mode, unsigned long addr)
  32. {
  33. set_dma_mode(DMA_FLOPPY, mode);
  34. __set_dma_addr(DMA_FLOPPY, data);
  35. set_dma_count(DMA_FLOPPY, length);
  36. virtual_dma_port = addr;
  37. enable_dma(DMA_FLOPPY);
  38. return 0;
  39. }
  40. #define fd_dma_setup fd_dma_setup
  41. #define fd_request_dma() request_dma(DMA_FLOPPY,"floppy")
  42. #define fd_free_dma() free_dma(DMA_FLOPPY)
  43. #define fd_disable_dma() disable_dma(DMA_FLOPPY)
  44. /* need to clean up dma.h */
  45. #define DMA_FLOPPYDISK DMA_FLOPPY
  46. /* Floppy_selects is the list of DOR's to select drive fd
  47. *
  48. * On initialisation, the floppy list is scanned, and the drives allocated
  49. * in the order that they are found. This is done by seeking the drive
  50. * to a non-zero track, and then restoring it to track 0. If an error occurs,
  51. * then there is no floppy drive present. [to be put back in again]
  52. */
  53. static unsigned char floppy_selects[2][4] =
  54. {
  55. { 0x10, 0x21, 0x23, 0x33 },
  56. { 0x10, 0x21, 0x23, 0x33 }
  57. };
  58. #define fd_setdor(dor) \
  59. do { \
  60. int new_dor = (dor); \
  61. if (new_dor & 0xf0) \
  62. new_dor = (new_dor & 0x0c) | floppy_selects[fdc][new_dor & 3]; \
  63. else \
  64. new_dor &= 0x0c; \
  65. outb(new_dor, FD_DOR); \
  66. } while (0)
  67. /*
  68. * Someday, we'll automatically detect which drives are present...
  69. */
  70. static inline void fd_scandrives (void)
  71. {
  72. #if 0
  73. int floppy, drive_count;
  74. fd_disable_irq();
  75. raw_cmd = &default_raw_cmd;
  76. raw_cmd->flags = FD_RAW_SPIN | FD_RAW_NEED_SEEK;
  77. raw_cmd->track = 0;
  78. raw_cmd->rate = ?;
  79. drive_count = 0;
  80. for (floppy = 0; floppy < 4; floppy ++) {
  81. current_drive = drive_count;
  82. /*
  83. * Turn on floppy motor
  84. */
  85. if (start_motor(redo_fd_request))
  86. continue;
  87. /*
  88. * Set up FDC
  89. */
  90. fdc_specify();
  91. /*
  92. * Tell FDC to recalibrate
  93. */
  94. output_byte(FD_RECALIBRATE);
  95. LAST_OUT(UNIT(floppy));
  96. /* wait for command to complete */
  97. if (!successful) {
  98. int i;
  99. for (i = drive_count; i < 3; i--)
  100. floppy_selects[fdc][i] = floppy_selects[fdc][i + 1];
  101. floppy_selects[fdc][3] = 0;
  102. floppy -= 1;
  103. } else
  104. drive_count++;
  105. }
  106. #else
  107. floppy_selects[0][0] = 0x10;
  108. floppy_selects[0][1] = 0x21;
  109. floppy_selects[0][2] = 0x23;
  110. floppy_selects[0][3] = 0x33;
  111. #endif
  112. }
  113. #define FDC1 (0x3f0)
  114. #define FLOPPY0_TYPE 4
  115. #define FLOPPY1_TYPE 4
  116. #define N_FDC 1
  117. #define N_DRIVE 4
  118. #define CROSS_64KB(a,s) (0)
  119. /*
  120. * This allows people to reverse the order of
  121. * fd0 and fd1, in case their hardware is
  122. * strangely connected (as some RiscPCs
  123. * and A5000s seem to be).
  124. */
  125. static void driveswap(int *ints, int dummy, int dummy2)
  126. {
  127. floppy_selects[0][0] ^= floppy_selects[0][1];
  128. floppy_selects[0][1] ^= floppy_selects[0][0];
  129. floppy_selects[0][0] ^= floppy_selects[0][1];
  130. }
  131. #define EXTRA_FLOPPY_PARAMS ,{ "driveswap", &driveswap, NULL, 0, 0 }
  132. #endif