tmio_mmc.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * linux/drivers/mmc/host/tmio_mmc.h
  3. *
  4. * Copyright (C) 2007 Ian Molton
  5. * Copyright (C) 2004 Ian Molton
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * Driver for the MMC / SD / SDIO cell found in:
  12. *
  13. * TC6393XB TC6391XB TC6387XB T7L66XB ASIC3
  14. */
  15. #ifndef TMIO_MMC_H
  16. #define TMIO_MMC_H
  17. #include <linux/highmem.h>
  18. #include <linux/pagemap.h>
  19. /* Definitions for values the CTRL_STATUS register can take. */
  20. #define TMIO_STAT_CMDRESPEND 0x00000001
  21. #define TMIO_STAT_DATAEND 0x00000004
  22. #define TMIO_STAT_CARD_REMOVE 0x00000008
  23. #define TMIO_STAT_CARD_INSERT 0x00000010
  24. #define TMIO_STAT_SIGSTATE 0x00000020
  25. #define TMIO_STAT_WRPROTECT 0x00000080
  26. #define TMIO_STAT_CARD_REMOVE_A 0x00000100
  27. #define TMIO_STAT_CARD_INSERT_A 0x00000200
  28. #define TMIO_STAT_SIGSTATE_A 0x00000400
  29. #define TMIO_STAT_CMD_IDX_ERR 0x00010000
  30. #define TMIO_STAT_CRCFAIL 0x00020000
  31. #define TMIO_STAT_STOPBIT_ERR 0x00040000
  32. #define TMIO_STAT_DATATIMEOUT 0x00080000
  33. #define TMIO_STAT_RXOVERFLOW 0x00100000
  34. #define TMIO_STAT_TXUNDERRUN 0x00200000
  35. #define TMIO_STAT_CMDTIMEOUT 0x00400000
  36. #define TMIO_STAT_RXRDY 0x01000000
  37. #define TMIO_STAT_TXRQ 0x02000000
  38. #define TMIO_STAT_ILL_FUNC 0x20000000
  39. #define TMIO_STAT_CMD_BUSY 0x40000000
  40. #define TMIO_STAT_ILL_ACCESS 0x80000000
  41. /* Definitions for values the CTRL_SDIO_STATUS register can take. */
  42. #define TMIO_SDIO_STAT_IOIRQ 0x0001
  43. #define TMIO_SDIO_STAT_EXPUB52 0x4000
  44. #define TMIO_SDIO_STAT_EXWT 0x8000
  45. #define TMIO_SDIO_MASK_ALL 0xc007
  46. /* Define some IRQ masks */
  47. /* This is the mask used at reset by the chip */
  48. #define TMIO_MASK_ALL 0x837f031d
  49. #define TMIO_MASK_READOP (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND)
  50. #define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND)
  51. #define TMIO_MASK_CMD (TMIO_STAT_CMDRESPEND | TMIO_STAT_CMDTIMEOUT | \
  52. TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT)
  53. #define TMIO_MASK_IRQ (TMIO_MASK_READOP | TMIO_MASK_WRITEOP | TMIO_MASK_CMD)
  54. struct tmio_mmc_data;
  55. struct tmio_mmc_host {
  56. void __iomem *ctl;
  57. unsigned long bus_shift;
  58. struct mmc_command *cmd;
  59. struct mmc_request *mrq;
  60. struct mmc_data *data;
  61. struct mmc_host *mmc;
  62. int irq;
  63. unsigned int sdio_irq_enabled;
  64. /* Callbacks for clock / power control */
  65. void (*set_pwr)(struct platform_device *host, int state);
  66. void (*set_clk_div)(struct platform_device *host, int state);
  67. /* pio related stuff */
  68. struct scatterlist *sg_ptr;
  69. struct scatterlist *sg_orig;
  70. unsigned int sg_len;
  71. unsigned int sg_off;
  72. struct platform_device *pdev;
  73. struct tmio_mmc_data *pdata;
  74. /* DMA support */
  75. bool force_pio;
  76. struct dma_chan *chan_rx;
  77. struct dma_chan *chan_tx;
  78. struct tasklet_struct dma_complete;
  79. struct tasklet_struct dma_issue;
  80. struct scatterlist bounce_sg;
  81. u8 *bounce_buf;
  82. /* Track lost interrupts */
  83. struct delayed_work delayed_reset_work;
  84. spinlock_t lock;
  85. unsigned long last_req_ts;
  86. };
  87. int tmio_mmc_host_probe(struct tmio_mmc_host **host,
  88. struct platform_device *pdev,
  89. struct tmio_mmc_data *pdata);
  90. void tmio_mmc_host_remove(struct tmio_mmc_host *host);
  91. void tmio_mmc_do_data_irq(struct tmio_mmc_host *host);
  92. void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i);
  93. void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i);
  94. static inline char *tmio_mmc_kmap_atomic(struct scatterlist *sg,
  95. unsigned long *flags)
  96. {
  97. local_irq_save(*flags);
  98. return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset;
  99. }
  100. static inline void tmio_mmc_kunmap_atomic(struct scatterlist *sg,
  101. unsigned long *flags, void *virt)
  102. {
  103. kunmap_atomic(virt - sg->offset, KM_BIO_SRC_IRQ);
  104. local_irq_restore(*flags);
  105. }
  106. #ifdef CONFIG_TMIO_MMC_DMA
  107. void tmio_mmc_start_dma(struct tmio_mmc_host *host, struct mmc_data *data);
  108. void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata);
  109. void tmio_mmc_release_dma(struct tmio_mmc_host *host);
  110. #else
  111. static inline void tmio_mmc_start_dma(struct tmio_mmc_host *host,
  112. struct mmc_data *data)
  113. {
  114. }
  115. static inline void tmio_mmc_request_dma(struct tmio_mmc_host *host,
  116. struct tmio_mmc_data *pdata)
  117. {
  118. host->chan_tx = NULL;
  119. host->chan_rx = NULL;
  120. }
  121. static inline void tmio_mmc_release_dma(struct tmio_mmc_host *host)
  122. {
  123. }
  124. #endif
  125. #endif