cb710-mmc.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * cb710/cb710-mmc.h
  4. *
  5. * Copyright by Michał Mirosław, 2008-2009
  6. */
  7. #ifndef LINUX_CB710_MMC_H
  8. #define LINUX_CB710_MMC_H
  9. #include <linux/cb710.h>
  10. #include <linux/workqueue.h>
  11. /* per-MMC-reader structure */
  12. struct cb710_mmc_reader {
  13. struct work_struct finish_req_bh_work;
  14. struct mmc_request *mrq;
  15. spinlock_t irq_lock;
  16. unsigned char last_power_mode;
  17. };
  18. /* some device struct walking */
  19. static inline struct mmc_host *cb710_slot_to_mmc(struct cb710_slot *slot)
  20. {
  21. return platform_get_drvdata(&slot->pdev);
  22. }
  23. static inline struct cb710_slot *cb710_mmc_to_slot(struct mmc_host *mmc)
  24. {
  25. struct platform_device *pdev = to_platform_device(mmc_dev(mmc));
  26. return cb710_pdev_to_slot(pdev);
  27. }
  28. /* registers (this might be all wrong ;) */
  29. #define CB710_MMC_DATA_PORT 0x00
  30. #define CB710_MMC_CONFIG_PORT 0x04
  31. #define CB710_MMC_CONFIG0_PORT 0x04
  32. #define CB710_MMC_CONFIG1_PORT 0x05
  33. #define CB710_MMC_C1_4BIT_DATA_BUS 0x40
  34. #define CB710_MMC_CONFIG2_PORT 0x06
  35. #define CB710_MMC_C2_READ_PIO_SIZE_MASK 0x0F /* N-1 */
  36. #define CB710_MMC_CONFIG3_PORT 0x07
  37. #define CB710_MMC_CONFIGB_PORT 0x08
  38. #define CB710_MMC_IRQ_ENABLE_PORT 0x0C
  39. #define CB710_MMC_IE_TEST_MASK 0x00BF
  40. #define CB710_MMC_IE_CARD_INSERTION_STATUS 0x1000
  41. #define CB710_MMC_IE_IRQ_ENABLE 0x8000
  42. #define CB710_MMC_IE_CISTATUS_MASK \
  43. (CB710_MMC_IE_CARD_INSERTION_STATUS|CB710_MMC_IE_IRQ_ENABLE)
  44. #define CB710_MMC_STATUS_PORT 0x10
  45. #define CB710_MMC_STATUS_ERROR_EVENTS 0x60FF
  46. #define CB710_MMC_STATUS0_PORT 0x10
  47. #define CB710_MMC_S0_FIFO_UNDERFLOW 0x40
  48. #define CB710_MMC_STATUS1_PORT 0x11
  49. #define CB710_MMC_S1_COMMAND_SENT 0x01
  50. #define CB710_MMC_S1_DATA_TRANSFER_DONE 0x02
  51. #define CB710_MMC_S1_PIO_TRANSFER_DONE 0x04
  52. #define CB710_MMC_S1_CARD_CHANGED 0x10
  53. #define CB710_MMC_S1_RESET 0x20
  54. #define CB710_MMC_STATUS2_PORT 0x12
  55. #define CB710_MMC_S2_FIFO_READY 0x01
  56. #define CB710_MMC_S2_FIFO_EMPTY 0x02
  57. #define CB710_MMC_S2_BUSY_10 0x10
  58. #define CB710_MMC_S2_BUSY_20 0x20
  59. #define CB710_MMC_STATUS3_PORT 0x13
  60. #define CB710_MMC_S3_CARD_DETECTED 0x02
  61. #define CB710_MMC_S3_WRITE_PROTECTED 0x04
  62. #define CB710_MMC_CMD_TYPE_PORT 0x14
  63. #define CB710_MMC_RSP_TYPE_MASK 0x0007
  64. #define CB710_MMC_RSP_R1 (0)
  65. #define CB710_MMC_RSP_136 (5)
  66. #define CB710_MMC_RSP_NO_CRC (2)
  67. #define CB710_MMC_RSP_PRESENT_MASK 0x0018
  68. #define CB710_MMC_RSP_NONE (0 << 3)
  69. #define CB710_MMC_RSP_PRESENT (1 << 3)
  70. #define CB710_MMC_RSP_PRESENT_X (2 << 3)
  71. #define CB710_MMC_CMD_TYPE_MASK 0x0060
  72. #define CB710_MMC_CMD_BC (0 << 5)
  73. #define CB710_MMC_CMD_BCR (1 << 5)
  74. #define CB710_MMC_CMD_AC (2 << 5)
  75. #define CB710_MMC_CMD_ADTC (3 << 5)
  76. #define CB710_MMC_DATA_READ 0x0080
  77. #define CB710_MMC_CMD_CODE_MASK 0x3F00
  78. #define CB710_MMC_CMD_CODE_SHIFT 8
  79. #define CB710_MMC_IS_APP_CMD 0x4000
  80. #define CB710_MMC_RSP_BUSY 0x8000
  81. #define CB710_MMC_CMD_PARAM_PORT 0x18
  82. #define CB710_MMC_TRANSFER_SIZE_PORT 0x1C
  83. #define CB710_MMC_RESPONSE0_PORT 0x20
  84. #define CB710_MMC_RESPONSE1_PORT 0x24
  85. #define CB710_MMC_RESPONSE2_PORT 0x28
  86. #define CB710_MMC_RESPONSE3_PORT 0x2C
  87. #endif /* LINUX_CB710_MMC_H */