sdhci-pci.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __SDHCI_PCI_H
  3. #define __SDHCI_PCI_H
  4. /*
  5. * PCI device IDs, sub IDs
  6. */
  7. #define PCI_DEVICE_ID_O2_SDS0 0x8420
  8. #define PCI_DEVICE_ID_O2_SDS1 0x8421
  9. #define PCI_DEVICE_ID_O2_FUJIN2 0x8520
  10. #define PCI_DEVICE_ID_O2_SEABIRD0 0x8620
  11. #define PCI_DEVICE_ID_O2_SEABIRD1 0x8621
  12. #define PCI_DEVICE_ID_INTEL_PCH_SDIO0 0x8809
  13. #define PCI_DEVICE_ID_INTEL_PCH_SDIO1 0x880a
  14. #define PCI_DEVICE_ID_INTEL_BYT_EMMC 0x0f14
  15. #define PCI_DEVICE_ID_INTEL_BYT_SDIO 0x0f15
  16. #define PCI_DEVICE_ID_INTEL_BYT_SD 0x0f16
  17. #define PCI_DEVICE_ID_INTEL_BYT_EMMC2 0x0f50
  18. #define PCI_DEVICE_ID_INTEL_BSW_EMMC 0x2294
  19. #define PCI_DEVICE_ID_INTEL_BSW_SDIO 0x2295
  20. #define PCI_DEVICE_ID_INTEL_BSW_SD 0x2296
  21. #define PCI_DEVICE_ID_INTEL_MRFLD_MMC 0x1190
  22. #define PCI_DEVICE_ID_INTEL_CLV_SDIO0 0x08f9
  23. #define PCI_DEVICE_ID_INTEL_CLV_SDIO1 0x08fa
  24. #define PCI_DEVICE_ID_INTEL_CLV_SDIO2 0x08fb
  25. #define PCI_DEVICE_ID_INTEL_CLV_EMMC0 0x08e5
  26. #define PCI_DEVICE_ID_INTEL_CLV_EMMC1 0x08e6
  27. #define PCI_DEVICE_ID_INTEL_QRK_SD 0x08A7
  28. #define PCI_DEVICE_ID_INTEL_SPT_EMMC 0x9d2b
  29. #define PCI_DEVICE_ID_INTEL_SPT_SDIO 0x9d2c
  30. #define PCI_DEVICE_ID_INTEL_SPT_SD 0x9d2d
  31. #define PCI_DEVICE_ID_INTEL_DNV_EMMC 0x19db
  32. #define PCI_DEVICE_ID_INTEL_CDF_EMMC 0x18db
  33. #define PCI_DEVICE_ID_INTEL_BXT_SD 0x0aca
  34. #define PCI_DEVICE_ID_INTEL_BXT_EMMC 0x0acc
  35. #define PCI_DEVICE_ID_INTEL_BXT_SDIO 0x0ad0
  36. #define PCI_DEVICE_ID_INTEL_BXTM_SD 0x1aca
  37. #define PCI_DEVICE_ID_INTEL_BXTM_EMMC 0x1acc
  38. #define PCI_DEVICE_ID_INTEL_BXTM_SDIO 0x1ad0
  39. #define PCI_DEVICE_ID_INTEL_APL_SD 0x5aca
  40. #define PCI_DEVICE_ID_INTEL_APL_EMMC 0x5acc
  41. #define PCI_DEVICE_ID_INTEL_APL_SDIO 0x5ad0
  42. #define PCI_DEVICE_ID_INTEL_GLK_SD 0x31ca
  43. #define PCI_DEVICE_ID_INTEL_GLK_EMMC 0x31cc
  44. #define PCI_DEVICE_ID_INTEL_GLK_SDIO 0x31d0
  45. #define PCI_DEVICE_ID_INTEL_CNP_EMMC 0x9dc4
  46. #define PCI_DEVICE_ID_INTEL_CNP_SD 0x9df5
  47. #define PCI_DEVICE_ID_INTEL_CNPH_SD 0xa375
  48. #define PCI_DEVICE_ID_INTEL_ICP_EMMC 0x34c4
  49. #define PCI_DEVICE_ID_INTEL_ICP_SD 0x34f8
  50. #define PCI_DEVICE_ID_SYSKONNECT_8000 0x8000
  51. #define PCI_DEVICE_ID_VIA_95D0 0x95d0
  52. #define PCI_DEVICE_ID_REALTEK_5250 0x5250
  53. #define PCI_SUBDEVICE_ID_NI_7884 0x7884
  54. #define PCI_SUBDEVICE_ID_NI_78E3 0x78e3
  55. #define PCI_VENDOR_ID_ARASAN 0x16e6
  56. #define PCI_DEVICE_ID_ARASAN_PHY_EMMC 0x0670
  57. #define PCI_DEVICE_ID_SYNOPSYS_DWC_MSHC 0xc202
  58. /*
  59. * PCI device class and mask
  60. */
  61. #define SYSTEM_SDHCI (PCI_CLASS_SYSTEM_SDHCI << 8)
  62. #define PCI_CLASS_MASK 0xFFFF00
  63. /*
  64. * Macros for PCI device-description
  65. */
  66. #define _PCI_VEND(vend) PCI_VENDOR_ID_##vend
  67. #define _PCI_DEV(vend, dev) PCI_DEVICE_ID_##vend##_##dev
  68. #define _PCI_SUBDEV(subvend, subdev) PCI_SUBDEVICE_ID_##subvend##_##subdev
  69. #define SDHCI_PCI_DEVICE(vend, dev, cfg) { \
  70. .vendor = _PCI_VEND(vend), .device = _PCI_DEV(vend, dev), \
  71. .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
  72. .driver_data = (kernel_ulong_t)&(sdhci_##cfg) \
  73. }
  74. #define SDHCI_PCI_SUBDEVICE(vend, dev, subvend, subdev, cfg) { \
  75. .vendor = _PCI_VEND(vend), .device = _PCI_DEV(vend, dev), \
  76. .subvendor = _PCI_VEND(subvend), \
  77. .subdevice = _PCI_SUBDEV(subvend, subdev), \
  78. .driver_data = (kernel_ulong_t)&(sdhci_##cfg) \
  79. }
  80. #define SDHCI_PCI_DEVICE_CLASS(vend, cl, cl_msk, cfg) { \
  81. .vendor = _PCI_VEND(vend), .device = PCI_ANY_ID, \
  82. .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
  83. .class = (cl), .class_mask = (cl_msk), \
  84. .driver_data = (kernel_ulong_t)&(sdhci_##cfg) \
  85. }
  86. /*
  87. * PCI registers
  88. */
  89. #define PCI_SDHCI_IFPIO 0x00
  90. #define PCI_SDHCI_IFDMA 0x01
  91. #define PCI_SDHCI_IFVENDOR 0x02
  92. #define PCI_SLOT_INFO 0x40 /* 8 bits */
  93. #define PCI_SLOT_INFO_SLOTS(x) ((x >> 4) & 7)
  94. #define PCI_SLOT_INFO_FIRST_BAR_MASK 0x07
  95. #define MAX_SLOTS 8
  96. struct sdhci_pci_chip;
  97. struct sdhci_pci_slot;
  98. struct sdhci_pci_fixes {
  99. unsigned int quirks;
  100. unsigned int quirks2;
  101. bool allow_runtime_pm;
  102. bool own_cd_for_runtime_pm;
  103. int (*probe) (struct sdhci_pci_chip *);
  104. int (*probe_slot) (struct sdhci_pci_slot *);
  105. int (*add_host) (struct sdhci_pci_slot *);
  106. void (*remove_slot) (struct sdhci_pci_slot *, int);
  107. #ifdef CONFIG_PM_SLEEP
  108. int (*suspend) (struct sdhci_pci_chip *);
  109. int (*resume) (struct sdhci_pci_chip *);
  110. #endif
  111. #ifdef CONFIG_PM
  112. int (*runtime_suspend) (struct sdhci_pci_chip *);
  113. int (*runtime_resume) (struct sdhci_pci_chip *);
  114. #endif
  115. const struct sdhci_ops *ops;
  116. size_t priv_size;
  117. };
  118. struct sdhci_pci_slot {
  119. struct sdhci_pci_chip *chip;
  120. struct sdhci_host *host;
  121. struct sdhci_pci_data *data;
  122. int rst_n_gpio;
  123. int cd_gpio;
  124. int cd_irq;
  125. int cd_idx;
  126. bool cd_override_level;
  127. void (*hw_reset)(struct sdhci_host *host);
  128. unsigned long private[0] ____cacheline_aligned;
  129. };
  130. struct sdhci_pci_chip {
  131. struct pci_dev *pdev;
  132. unsigned int quirks;
  133. unsigned int quirks2;
  134. bool allow_runtime_pm;
  135. bool pm_retune;
  136. bool rpm_retune;
  137. const struct sdhci_pci_fixes *fixes;
  138. int num_slots; /* Slots on controller */
  139. struct sdhci_pci_slot *slots[MAX_SLOTS]; /* Pointers to host slots */
  140. };
  141. static inline void *sdhci_pci_priv(struct sdhci_pci_slot *slot)
  142. {
  143. return (void *)slot->private;
  144. }
  145. #ifdef CONFIG_PM_SLEEP
  146. int sdhci_pci_resume_host(struct sdhci_pci_chip *chip);
  147. #endif
  148. int sdhci_pci_enable_dma(struct sdhci_host *host);
  149. int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot);
  150. int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip);
  151. #ifdef CONFIG_PM_SLEEP
  152. int sdhci_pci_o2_resume(struct sdhci_pci_chip *chip);
  153. #endif
  154. extern const struct sdhci_pci_fixes sdhci_arasan;
  155. extern const struct sdhci_pci_fixes sdhci_snps;
  156. #endif /* __SDHCI_PCI_H */