tifm.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * tifm.h - TI FlashMedia driver
  4. *
  5. * Copyright (C) 2006 Alex Dubov <oakad@yahoo.com>
  6. */
  7. #ifndef _TIFM_H
  8. #define _TIFM_H
  9. #include <linux/spinlock.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/delay.h>
  12. #include <linux/pci.h>
  13. #include <linux/workqueue.h>
  14. /* Host registers (relative to pci base address): */
  15. enum {
  16. FM_SET_INTERRUPT_ENABLE = 0x008,
  17. FM_CLEAR_INTERRUPT_ENABLE = 0x00c,
  18. FM_INTERRUPT_STATUS = 0x014
  19. };
  20. /* Socket registers (relative to socket base address): */
  21. enum {
  22. SOCK_CONTROL = 0x004,
  23. SOCK_PRESENT_STATE = 0x008,
  24. SOCK_DMA_ADDRESS = 0x00c,
  25. SOCK_DMA_CONTROL = 0x010,
  26. SOCK_DMA_FIFO_INT_ENABLE_SET = 0x014,
  27. SOCK_DMA_FIFO_INT_ENABLE_CLEAR = 0x018,
  28. SOCK_DMA_FIFO_STATUS = 0x020,
  29. SOCK_FIFO_CONTROL = 0x024,
  30. SOCK_FIFO_PAGE_SIZE = 0x028,
  31. SOCK_MMCSD_COMMAND = 0x104,
  32. SOCK_MMCSD_ARG_LOW = 0x108,
  33. SOCK_MMCSD_ARG_HIGH = 0x10c,
  34. SOCK_MMCSD_CONFIG = 0x110,
  35. SOCK_MMCSD_STATUS = 0x114,
  36. SOCK_MMCSD_INT_ENABLE = 0x118,
  37. SOCK_MMCSD_COMMAND_TO = 0x11c,
  38. SOCK_MMCSD_DATA_TO = 0x120,
  39. SOCK_MMCSD_DATA = 0x124,
  40. SOCK_MMCSD_BLOCK_LEN = 0x128,
  41. SOCK_MMCSD_NUM_BLOCKS = 0x12c,
  42. SOCK_MMCSD_BUFFER_CONFIG = 0x130,
  43. SOCK_MMCSD_SPI_CONFIG = 0x134,
  44. SOCK_MMCSD_SDIO_MODE_CONFIG = 0x138,
  45. SOCK_MMCSD_RESPONSE = 0x144,
  46. SOCK_MMCSD_SDIO_SR = 0x164,
  47. SOCK_MMCSD_SYSTEM_CONTROL = 0x168,
  48. SOCK_MMCSD_SYSTEM_STATUS = 0x16c,
  49. SOCK_MS_COMMAND = 0x184,
  50. SOCK_MS_DATA = 0x188,
  51. SOCK_MS_STATUS = 0x18c,
  52. SOCK_MS_SYSTEM = 0x190,
  53. SOCK_FIFO_ACCESS = 0x200
  54. };
  55. #define TIFM_CTRL_LED 0x00000040
  56. #define TIFM_CTRL_FAST_CLK 0x00000100
  57. #define TIFM_CTRL_POWER_MASK 0x00000007
  58. #define TIFM_SOCK_STATE_OCCUPIED 0x00000008
  59. #define TIFM_SOCK_STATE_POWERED 0x00000080
  60. #define TIFM_FIFO_ENABLE 0x00000001
  61. #define TIFM_FIFO_READY 0x00000001
  62. #define TIFM_FIFO_MORE 0x00000008
  63. #define TIFM_FIFO_INT_SETALL 0x0000ffff
  64. #define TIFM_FIFO_INTMASK 0x00000005
  65. #define TIFM_DMA_RESET 0x00000002
  66. #define TIFM_DMA_TX 0x00008000
  67. #define TIFM_DMA_EN 0x00000001
  68. #define TIFM_DMA_TSIZE 0x0000007f
  69. #define TIFM_TYPE_XD 1
  70. #define TIFM_TYPE_MS 2
  71. #define TIFM_TYPE_SD 3
  72. struct tifm_device_id {
  73. unsigned char type;
  74. };
  75. struct tifm_driver;
  76. struct tifm_dev {
  77. char __iomem *addr;
  78. spinlock_t lock;
  79. unsigned char type;
  80. unsigned int socket_id;
  81. void (*card_event)(struct tifm_dev *sock);
  82. void (*data_event)(struct tifm_dev *sock);
  83. struct device dev;
  84. };
  85. struct tifm_driver {
  86. struct tifm_device_id *id_table;
  87. int (*probe)(struct tifm_dev *dev);
  88. void (*remove)(struct tifm_dev *dev);
  89. int (*suspend)(struct tifm_dev *dev,
  90. pm_message_t state);
  91. int (*resume)(struct tifm_dev *dev);
  92. struct device_driver driver;
  93. };
  94. struct tifm_adapter {
  95. char __iomem *addr;
  96. spinlock_t lock;
  97. unsigned int irq_status;
  98. unsigned int socket_change_set;
  99. unsigned int id;
  100. unsigned int num_sockets;
  101. struct completion *finish_me;
  102. struct work_struct media_switcher;
  103. struct device dev;
  104. void (*eject)(struct tifm_adapter *fm,
  105. struct tifm_dev *sock);
  106. int (*has_ms_pif)(struct tifm_adapter *fm,
  107. struct tifm_dev *sock);
  108. struct tifm_dev *sockets[];
  109. };
  110. struct tifm_adapter *tifm_alloc_adapter(unsigned int num_sockets,
  111. struct device *dev);
  112. int tifm_add_adapter(struct tifm_adapter *fm);
  113. void tifm_remove_adapter(struct tifm_adapter *fm);
  114. void tifm_free_adapter(struct tifm_adapter *fm);
  115. void tifm_free_device(struct device *dev);
  116. struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm, unsigned int id,
  117. unsigned char type);
  118. int tifm_register_driver(struct tifm_driver *drv);
  119. void tifm_unregister_driver(struct tifm_driver *drv);
  120. void tifm_eject(struct tifm_dev *sock);
  121. int tifm_has_ms_pif(struct tifm_dev *sock);
  122. int tifm_map_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents,
  123. int direction);
  124. void tifm_unmap_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents,
  125. int direction);
  126. void tifm_queue_work(struct work_struct *work);
  127. static inline void *tifm_get_drvdata(struct tifm_dev *dev)
  128. {
  129. return dev_get_drvdata(&dev->dev);
  130. }
  131. static inline void tifm_set_drvdata(struct tifm_dev *dev, void *data)
  132. {
  133. dev_set_drvdata(&dev->dev, data);
  134. }
  135. #endif