Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 1 | #ifndef __SDHCI_PCI_H |
| 2 | #define __SDHCI_PCI_H |
| 3 | |
| 4 | /* |
Matthias Kraemer | c949c90 | 2017-05-15 23:44:17 +0200 | [diff] [blame^] | 5 | * PCI device IDs, sub IDs |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #define PCI_DEVICE_ID_INTEL_PCH_SDIO0 0x8809 |
| 9 | #define PCI_DEVICE_ID_INTEL_PCH_SDIO1 0x880a |
| 10 | #define PCI_DEVICE_ID_INTEL_BYT_EMMC 0x0f14 |
| 11 | #define PCI_DEVICE_ID_INTEL_BYT_SDIO 0x0f15 |
| 12 | #define PCI_DEVICE_ID_INTEL_BYT_SD 0x0f16 |
| 13 | #define PCI_DEVICE_ID_INTEL_BYT_EMMC2 0x0f50 |
Alan Cox | 066173b | 2014-08-20 13:27:44 +0300 | [diff] [blame] | 14 | #define PCI_DEVICE_ID_INTEL_BSW_EMMC 0x2294 |
| 15 | #define PCI_DEVICE_ID_INTEL_BSW_SDIO 0x2295 |
| 16 | #define PCI_DEVICE_ID_INTEL_BSW_SD 0x2296 |
Andy Shevchenko | 1f64cec | 2016-07-12 14:03:42 +0300 | [diff] [blame] | 17 | #define PCI_DEVICE_ID_INTEL_MRFLD_MMC 0x1190 |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 18 | #define PCI_DEVICE_ID_INTEL_CLV_SDIO0 0x08f9 |
| 19 | #define PCI_DEVICE_ID_INTEL_CLV_SDIO1 0x08fa |
| 20 | #define PCI_DEVICE_ID_INTEL_CLV_SDIO2 0x08fb |
| 21 | #define PCI_DEVICE_ID_INTEL_CLV_EMMC0 0x08e5 |
| 22 | #define PCI_DEVICE_ID_INTEL_CLV_EMMC1 0x08e6 |
Derek Browne | 43e968c | 2014-06-24 06:56:36 -0700 | [diff] [blame] | 23 | #define PCI_DEVICE_ID_INTEL_QRK_SD 0x08A7 |
Adrian Hunter | 1f7f265 | 2015-01-05 14:47:58 +0200 | [diff] [blame] | 24 | #define PCI_DEVICE_ID_INTEL_SPT_EMMC 0x9d2b |
| 25 | #define PCI_DEVICE_ID_INTEL_SPT_SDIO 0x9d2c |
| 26 | #define PCI_DEVICE_ID_INTEL_SPT_SD 0x9d2d |
Adrian Hunter | 06bf9c5 | 2015-10-06 10:26:21 +0300 | [diff] [blame] | 27 | #define PCI_DEVICE_ID_INTEL_DNV_EMMC 0x19db |
Adrian Hunter | 4fd4c06 | 2015-10-21 11:15:45 +0300 | [diff] [blame] | 28 | #define PCI_DEVICE_ID_INTEL_BXT_SD 0x0aca |
| 29 | #define PCI_DEVICE_ID_INTEL_BXT_EMMC 0x0acc |
| 30 | #define PCI_DEVICE_ID_INTEL_BXT_SDIO 0x0ad0 |
Adrian Hunter | 01d6b2a | 2016-04-04 12:40:37 +0300 | [diff] [blame] | 31 | #define PCI_DEVICE_ID_INTEL_BXTM_SD 0x1aca |
| 32 | #define PCI_DEVICE_ID_INTEL_BXTM_EMMC 0x1acc |
| 33 | #define PCI_DEVICE_ID_INTEL_BXTM_SDIO 0x1ad0 |
Adrian Hunter | 4fd4c06 | 2015-10-21 11:15:45 +0300 | [diff] [blame] | 34 | #define PCI_DEVICE_ID_INTEL_APL_SD 0x5aca |
| 35 | #define PCI_DEVICE_ID_INTEL_APL_EMMC 0x5acc |
| 36 | #define PCI_DEVICE_ID_INTEL_APL_SDIO 0x5ad0 |
Adrian Hunter | 2d1956d | 2016-11-22 11:03:37 +0200 | [diff] [blame] | 37 | #define PCI_DEVICE_ID_INTEL_GLK_SD 0x31ca |
| 38 | #define PCI_DEVICE_ID_INTEL_GLK_EMMC 0x31cc |
| 39 | #define PCI_DEVICE_ID_INTEL_GLK_SDIO 0x31d0 |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 40 | |
Matthias Kraemer | c949c90 | 2017-05-15 23:44:17 +0200 | [diff] [blame^] | 41 | #define PCI_DEVICE_ID_SYSKONNECT_8000 0x8000 |
| 42 | #define PCI_DEVICE_ID_VIA_95D0 0x95d0 |
| 43 | #define PCI_DEVICE_ID_REALTEK_5250 0x5250 |
| 44 | |
| 45 | #define PCI_SUBDEVICE_ID_NI_7884 0x7884 |
| 46 | |
| 47 | /* |
| 48 | * PCI device class and mask |
| 49 | */ |
| 50 | |
| 51 | #define SYSTEM_SDHCI (PCI_CLASS_SYSTEM_SDHCI << 8) |
| 52 | #define PCI_CLASS_MASK 0xFFFF00 |
| 53 | |
| 54 | /* |
| 55 | * Macros for PCI device-description |
| 56 | */ |
| 57 | |
| 58 | #define _PCI_VEND(vend) PCI_VENDOR_ID_##vend |
| 59 | #define _PCI_DEV(vend, dev) PCI_DEVICE_ID_##vend##_##dev |
| 60 | #define _PCI_SUBDEV(subvend, subdev) PCI_SUBDEVICE_ID_##subvend##_##subdev |
| 61 | |
| 62 | #define SDHCI_PCI_DEVICE(vend, dev, cfg) { \ |
| 63 | .vendor = _PCI_VEND(vend), .device = _PCI_DEV(vend, dev), \ |
| 64 | .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \ |
| 65 | .driver_data = (kernel_ulong_t)&(sdhci_##cfg) \ |
| 66 | } |
| 67 | |
| 68 | #define SDHCI_PCI_SUBDEVICE(vend, dev, subvend, subdev, cfg) { \ |
| 69 | .vendor = _PCI_VEND(vend), .device = _PCI_DEV(vend, dev), \ |
| 70 | .subvendor = _PCI_VEND(subvend), \ |
| 71 | .subdevice = _PCI_SUBDEV(subvend, subdev), \ |
| 72 | .driver_data = (kernel_ulong_t)&(sdhci_##cfg) \ |
| 73 | } |
| 74 | |
| 75 | #define SDHCI_PCI_DEVICE_CLASS(vend, cl, cl_msk, cfg) { \ |
| 76 | .vendor = _PCI_VEND(vend), .device = PCI_ANY_ID, \ |
| 77 | .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \ |
| 78 | .class = (cl), .class_mask = (cl_msk), \ |
| 79 | .driver_data = (kernel_ulong_t)&(sdhci_##cfg) \ |
| 80 | } |
| 81 | |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 82 | /* |
| 83 | * PCI registers |
| 84 | */ |
| 85 | |
| 86 | #define PCI_SDHCI_IFPIO 0x00 |
| 87 | #define PCI_SDHCI_IFDMA 0x01 |
| 88 | #define PCI_SDHCI_IFVENDOR 0x02 |
| 89 | |
| 90 | #define PCI_SLOT_INFO 0x40 /* 8 bits */ |
| 91 | #define PCI_SLOT_INFO_SLOTS(x) ((x >> 4) & 7) |
| 92 | #define PCI_SLOT_INFO_FIRST_BAR_MASK 0x07 |
| 93 | |
| 94 | #define MAX_SLOTS 8 |
| 95 | |
| 96 | struct sdhci_pci_chip; |
| 97 | struct sdhci_pci_slot; |
| 98 | |
| 99 | struct sdhci_pci_fixes { |
| 100 | unsigned int quirks; |
| 101 | unsigned int quirks2; |
| 102 | bool allow_runtime_pm; |
Adrian Hunter | 77a0122 | 2014-01-13 09:49:16 +0200 | [diff] [blame] | 103 | bool own_cd_for_runtime_pm; |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 104 | |
| 105 | int (*probe) (struct sdhci_pci_chip *); |
| 106 | |
| 107 | int (*probe_slot) (struct sdhci_pci_slot *); |
Adrian Hunter | 61c951d | 2017-03-20 19:50:48 +0200 | [diff] [blame] | 108 | int (*add_host) (struct sdhci_pci_slot *); |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 109 | void (*remove_slot) (struct sdhci_pci_slot *, int); |
| 110 | |
Adrian Hunter | b7813f0 | 2017-03-20 19:50:50 +0200 | [diff] [blame] | 111 | #ifdef CONFIG_PM_SLEEP |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 112 | int (*suspend) (struct sdhci_pci_chip *); |
| 113 | int (*resume) (struct sdhci_pci_chip *); |
Adrian Hunter | b7813f0 | 2017-03-20 19:50:50 +0200 | [diff] [blame] | 114 | #endif |
Adrian Hunter | 966d696 | 2017-03-20 19:50:52 +0200 | [diff] [blame] | 115 | #ifdef CONFIG_PM |
| 116 | int (*runtime_suspend) (struct sdhci_pci_chip *); |
| 117 | int (*runtime_resume) (struct sdhci_pci_chip *); |
| 118 | #endif |
Adrian Hunter | 6bc0906 | 2016-10-05 12:11:23 +0300 | [diff] [blame] | 119 | |
| 120 | const struct sdhci_ops *ops; |
Adrian Hunter | ac9f67b | 2017-03-20 19:50:33 +0200 | [diff] [blame] | 121 | size_t priv_size; |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | struct sdhci_pci_slot { |
| 125 | struct sdhci_pci_chip *chip; |
| 126 | struct sdhci_host *host; |
| 127 | struct sdhci_pci_data *data; |
| 128 | |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 129 | int rst_n_gpio; |
| 130 | int cd_gpio; |
| 131 | int cd_irq; |
| 132 | |
Adrian Hunter | ff59c52 | 2014-09-24 10:27:31 +0300 | [diff] [blame] | 133 | int cd_idx; |
| 134 | bool cd_override_level; |
| 135 | |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 136 | void (*hw_reset)(struct sdhci_host *host); |
Adrian Hunter | ac9f67b | 2017-03-20 19:50:33 +0200 | [diff] [blame] | 137 | unsigned long private[0] ____cacheline_aligned; |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | struct sdhci_pci_chip { |
| 141 | struct pci_dev *pdev; |
| 142 | |
| 143 | unsigned int quirks; |
| 144 | unsigned int quirks2; |
| 145 | bool allow_runtime_pm; |
Adrian Hunter | d38dcad | 2017-03-20 19:50:32 +0200 | [diff] [blame] | 146 | bool pm_retune; |
| 147 | bool rpm_retune; |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 148 | const struct sdhci_pci_fixes *fixes; |
| 149 | |
| 150 | int num_slots; /* Slots on controller */ |
| 151 | struct sdhci_pci_slot *slots[MAX_SLOTS]; /* Pointers to host slots */ |
| 152 | }; |
| 153 | |
Adrian Hunter | ac9f67b | 2017-03-20 19:50:33 +0200 | [diff] [blame] | 154 | static inline void *sdhci_pci_priv(struct sdhci_pci_slot *slot) |
| 155 | { |
| 156 | return (void *)slot->private; |
| 157 | } |
| 158 | |
Adrian Hunter | 30cf280 | 2017-03-20 19:50:51 +0200 | [diff] [blame] | 159 | #ifdef CONFIG_PM_SLEEP |
| 160 | int sdhci_pci_resume_host(struct sdhci_pci_chip *chip); |
| 161 | #endif |
| 162 | |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 163 | #endif /* __SDHCI_PCI_H */ |