wbsd.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * linux/drivers/mmc/host/wbsd.h - Winbond W83L51xD SD/MMC driver
  3. *
  4. * Copyright (C) 2004-2007 Pierre Ossman, All Rights Reserved.
  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 as published by
  8. * the Free Software Foundation; either version 2 of the License, or (at
  9. * your option) any later version.
  10. */
  11. #define LOCK_CODE 0xAA
  12. #define WBSD_CONF_SWRST 0x02
  13. #define WBSD_CONF_DEVICE 0x07
  14. #define WBSD_CONF_ID_HI 0x20
  15. #define WBSD_CONF_ID_LO 0x21
  16. #define WBSD_CONF_POWER 0x22
  17. #define WBSD_CONF_PME 0x23
  18. #define WBSD_CONF_PMES 0x24
  19. #define WBSD_CONF_ENABLE 0x30
  20. #define WBSD_CONF_PORT_HI 0x60
  21. #define WBSD_CONF_PORT_LO 0x61
  22. #define WBSD_CONF_IRQ 0x70
  23. #define WBSD_CONF_DRQ 0x74
  24. #define WBSD_CONF_PINS 0xF0
  25. #define DEVICE_SD 0x03
  26. #define WBSD_PINS_DAT3_HI 0x20
  27. #define WBSD_PINS_DAT3_OUT 0x10
  28. #define WBSD_PINS_GP11_HI 0x04
  29. #define WBSD_PINS_DETECT_GP11 0x02
  30. #define WBSD_PINS_DETECT_DAT3 0x01
  31. #define WBSD_CMDR 0x00
  32. #define WBSD_DFR 0x01
  33. #define WBSD_EIR 0x02
  34. #define WBSD_ISR 0x03
  35. #define WBSD_FSR 0x04
  36. #define WBSD_IDXR 0x05
  37. #define WBSD_DATAR 0x06
  38. #define WBSD_CSR 0x07
  39. #define WBSD_EINT_CARD 0x40
  40. #define WBSD_EINT_FIFO_THRE 0x20
  41. #define WBSD_EINT_CRC 0x10
  42. #define WBSD_EINT_TIMEOUT 0x08
  43. #define WBSD_EINT_PROGEND 0x04
  44. #define WBSD_EINT_BUSYEND 0x02
  45. #define WBSD_EINT_TC 0x01
  46. #define WBSD_INT_PENDING 0x80
  47. #define WBSD_INT_CARD 0x40
  48. #define WBSD_INT_FIFO_THRE 0x20
  49. #define WBSD_INT_CRC 0x10
  50. #define WBSD_INT_TIMEOUT 0x08
  51. #define WBSD_INT_PROGEND 0x04
  52. #define WBSD_INT_BUSYEND 0x02
  53. #define WBSD_INT_TC 0x01
  54. #define WBSD_FIFO_EMPTY 0x80
  55. #define WBSD_FIFO_FULL 0x40
  56. #define WBSD_FIFO_EMTHRE 0x20
  57. #define WBSD_FIFO_FUTHRE 0x10
  58. #define WBSD_FIFO_SZMASK 0x0F
  59. #define WBSD_MSLED 0x20
  60. #define WBSD_POWER_N 0x10
  61. #define WBSD_WRPT 0x04
  62. #define WBSD_CARDPRESENT 0x01
  63. #define WBSD_IDX_CLK 0x01
  64. #define WBSD_IDX_PBSMSB 0x02
  65. #define WBSD_IDX_TAAC 0x03
  66. #define WBSD_IDX_NSAC 0x04
  67. #define WBSD_IDX_PBSLSB 0x05
  68. #define WBSD_IDX_SETUP 0x06
  69. #define WBSD_IDX_DMA 0x07
  70. #define WBSD_IDX_FIFOEN 0x08
  71. #define WBSD_IDX_STATUS 0x10
  72. #define WBSD_IDX_RSPLEN 0x1E
  73. #define WBSD_IDX_RESP0 0x1F
  74. #define WBSD_IDX_RESP1 0x20
  75. #define WBSD_IDX_RESP2 0x21
  76. #define WBSD_IDX_RESP3 0x22
  77. #define WBSD_IDX_RESP4 0x23
  78. #define WBSD_IDX_RESP5 0x24
  79. #define WBSD_IDX_RESP6 0x25
  80. #define WBSD_IDX_RESP7 0x26
  81. #define WBSD_IDX_RESP8 0x27
  82. #define WBSD_IDX_RESP9 0x28
  83. #define WBSD_IDX_RESP10 0x29
  84. #define WBSD_IDX_RESP11 0x2A
  85. #define WBSD_IDX_RESP12 0x2B
  86. #define WBSD_IDX_RESP13 0x2C
  87. #define WBSD_IDX_RESP14 0x2D
  88. #define WBSD_IDX_RESP15 0x2E
  89. #define WBSD_IDX_RESP16 0x2F
  90. #define WBSD_IDX_CRCSTATUS 0x30
  91. #define WBSD_IDX_ISR 0x3F
  92. #define WBSD_CLK_375K 0x00
  93. #define WBSD_CLK_12M 0x01
  94. #define WBSD_CLK_16M 0x02
  95. #define WBSD_CLK_24M 0x03
  96. #define WBSD_DATA_WIDTH 0x01
  97. #define WBSD_DAT3_H 0x08
  98. #define WBSD_FIFO_RESET 0x04
  99. #define WBSD_SOFT_RESET 0x02
  100. #define WBSD_INC_INDEX 0x01
  101. #define WBSD_DMA_SINGLE 0x02
  102. #define WBSD_DMA_ENABLE 0x01
  103. #define WBSD_FIFOEN_EMPTY 0x20
  104. #define WBSD_FIFOEN_FULL 0x10
  105. #define WBSD_FIFO_THREMASK 0x0F
  106. #define WBSD_BLOCK_READ 0x80
  107. #define WBSD_BLOCK_WRITE 0x40
  108. #define WBSD_BUSY 0x20
  109. #define WBSD_CARDTRAFFIC 0x04
  110. #define WBSD_SENDCMD 0x02
  111. #define WBSD_RECVRES 0x01
  112. #define WBSD_RSP_SHORT 0x00
  113. #define WBSD_RSP_LONG 0x01
  114. #define WBSD_CRC_MASK 0x1F
  115. #define WBSD_CRC_OK 0x05 /* S010E (00101) */
  116. #define WBSD_CRC_FAIL 0x0B /* S101E (01011) */
  117. #define WBSD_DMA_SIZE 65536
  118. struct wbsd_host
  119. {
  120. struct mmc_host* mmc; /* MMC structure */
  121. spinlock_t lock; /* Mutex */
  122. int flags; /* Driver states */
  123. #define WBSD_FCARD_PRESENT (1<<0) /* Card is present */
  124. #define WBSD_FIGNORE_DETECT (1<<1) /* Ignore card detection */
  125. struct mmc_request* mrq; /* Current request */
  126. u8 isr; /* Accumulated ISR */
  127. struct scatterlist* cur_sg; /* Current SG entry */
  128. unsigned int num_sg; /* Number of entries left */
  129. unsigned int offset; /* Offset into current entry */
  130. unsigned int remain; /* Data left in curren entry */
  131. char* dma_buffer; /* ISA DMA buffer */
  132. dma_addr_t dma_addr; /* Physical address for same */
  133. int firsterr; /* See fifo functions */
  134. u8 clk; /* Current clock speed */
  135. unsigned char bus_width; /* Current bus width */
  136. int config; /* Config port */
  137. u8 unlock_code; /* Code to unlock config */
  138. int chip_id; /* ID of controller */
  139. int base; /* I/O port base */
  140. int irq; /* Interrupt */
  141. int dma; /* DMA channel */
  142. struct tasklet_struct card_tasklet; /* Tasklet structures */
  143. struct tasklet_struct fifo_tasklet;
  144. struct tasklet_struct crc_tasklet;
  145. struct tasklet_struct timeout_tasklet;
  146. struct tasklet_struct finish_tasklet;
  147. struct timer_list ignore_timer; /* Ignore detection timer */
  148. };