tmio_mmc.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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/mmc/tmio.h>
  19. #include <linux/pagemap.h>
  20. /* Definitions for values the CTRL_SDIO_STATUS register can take. */
  21. #define TMIO_SDIO_STAT_IOIRQ 0x0001
  22. #define TMIO_SDIO_STAT_EXPUB52 0x4000
  23. #define TMIO_SDIO_STAT_EXWT 0x8000
  24. #define TMIO_SDIO_MASK_ALL 0xc007
  25. /* Define some IRQ masks */
  26. /* This is the mask used at reset by the chip */
  27. #define TMIO_MASK_ALL 0x837f031d
  28. #define TMIO_MASK_READOP (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND)
  29. #define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND)
  30. #define TMIO_MASK_CMD (TMIO_STAT_CMDRESPEND | TMIO_STAT_CMDTIMEOUT | \
  31. TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT)
  32. #define TMIO_MASK_IRQ (TMIO_MASK_READOP | TMIO_MASK_WRITEOP | TMIO_MASK_CMD)
  33. struct tmio_mmc_data;
  34. struct tmio_mmc_host {
  35. void __iomem *ctl;
  36. unsigned long bus_shift;
  37. struct mmc_command *cmd;
  38. struct mmc_request *mrq;
  39. struct mmc_data *data;
  40. struct mmc_host *mmc;
  41. int irq;
  42. unsigned int sdio_irq_enabled;
  43. /* Callbacks for clock / power control */
  44. void (*set_pwr)(struct platform_device *host, int state);
  45. void (*set_clk_div)(struct platform_device *host, int state);
  46. int pm_error;
  47. /* pio related stuff */
  48. struct scatterlist *sg_ptr;
  49. struct scatterlist *sg_orig;
  50. unsigned int sg_len;
  51. unsigned int sg_off;
  52. struct platform_device *pdev;
  53. struct tmio_mmc_data *pdata;
  54. /* DMA support */
  55. bool force_pio;
  56. struct dma_chan *chan_rx;
  57. struct dma_chan *chan_tx;
  58. struct tasklet_struct dma_complete;
  59. struct tasklet_struct dma_issue;
  60. struct scatterlist bounce_sg;
  61. u8 *bounce_buf;
  62. /* Track lost interrupts */
  63. struct delayed_work delayed_reset_work;
  64. spinlock_t lock;
  65. unsigned long last_req_ts;
  66. };
  67. int tmio_mmc_host_probe(struct tmio_mmc_host **host,
  68. struct platform_device *pdev,
  69. struct tmio_mmc_data *pdata);
  70. void tmio_mmc_host_remove(struct tmio_mmc_host *host);
  71. void tmio_mmc_do_data_irq(struct tmio_mmc_host *host);
  72. void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i);
  73. void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i);
  74. static inline char *tmio_mmc_kmap_atomic(struct scatterlist *sg,
  75. unsigned long *flags)
  76. {
  77. local_irq_save(*flags);
  78. return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset;
  79. }
  80. static inline void tmio_mmc_kunmap_atomic(struct scatterlist *sg,
  81. unsigned long *flags, void *virt)
  82. {
  83. kunmap_atomic(virt - sg->offset, KM_BIO_SRC_IRQ);
  84. local_irq_restore(*flags);
  85. }
  86. #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
  87. void tmio_mmc_start_dma(struct tmio_mmc_host *host, struct mmc_data *data);
  88. void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata);
  89. void tmio_mmc_release_dma(struct tmio_mmc_host *host);
  90. #else
  91. static inline void tmio_mmc_start_dma(struct tmio_mmc_host *host,
  92. struct mmc_data *data)
  93. {
  94. }
  95. static inline void tmio_mmc_request_dma(struct tmio_mmc_host *host,
  96. struct tmio_mmc_data *pdata)
  97. {
  98. host->chan_tx = NULL;
  99. host->chan_rx = NULL;
  100. }
  101. static inline void tmio_mmc_release_dma(struct tmio_mmc_host *host)
  102. {
  103. }
  104. #endif
  105. #ifdef CONFIG_PM
  106. int tmio_mmc_host_suspend(struct device *dev);
  107. int tmio_mmc_host_resume(struct device *dev);
  108. #else
  109. #define tmio_mmc_host_suspend NULL
  110. #define tmio_mmc_host_resume NULL
  111. #endif
  112. #endif