Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 2 | #ifndef __SDHCI_PCI_H |
| 3 | #define __SDHCI_PCI_H |
| 4 | |
| 5 | /* |
Matthias Kraemer | c949c90 | 2017-05-15 23:44:17 +0200 | [diff] [blame] | 6 | * PCI device IDs, sub IDs |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 7 | */ |
| 8 | |
Adrian Hunter | 361eeda | 2017-10-19 15:04:13 +0300 | [diff] [blame] | 9 | #define PCI_DEVICE_ID_O2_SDS0 0x8420 |
| 10 | #define PCI_DEVICE_ID_O2_SDS1 0x8421 |
| 11 | #define PCI_DEVICE_ID_O2_FUJIN2 0x8520 |
| 12 | #define PCI_DEVICE_ID_O2_SEABIRD0 0x8620 |
| 13 | #define PCI_DEVICE_ID_O2_SEABIRD1 0x8621 |
| 14 | |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 15 | #define PCI_DEVICE_ID_INTEL_PCH_SDIO0 0x8809 |
| 16 | #define PCI_DEVICE_ID_INTEL_PCH_SDIO1 0x880a |
| 17 | #define PCI_DEVICE_ID_INTEL_BYT_EMMC 0x0f14 |
| 18 | #define PCI_DEVICE_ID_INTEL_BYT_SDIO 0x0f15 |
| 19 | #define PCI_DEVICE_ID_INTEL_BYT_SD 0x0f16 |
| 20 | #define PCI_DEVICE_ID_INTEL_BYT_EMMC2 0x0f50 |
Alan Cox | 066173b | 2014-08-20 13:27:44 +0300 | [diff] [blame] | 21 | #define PCI_DEVICE_ID_INTEL_BSW_EMMC 0x2294 |
| 22 | #define PCI_DEVICE_ID_INTEL_BSW_SDIO 0x2295 |
| 23 | #define PCI_DEVICE_ID_INTEL_BSW_SD 0x2296 |
Andy Shevchenko | 1f64cec | 2016-07-12 14:03:42 +0300 | [diff] [blame] | 24 | #define PCI_DEVICE_ID_INTEL_MRFLD_MMC 0x1190 |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 25 | #define PCI_DEVICE_ID_INTEL_CLV_SDIO0 0x08f9 |
| 26 | #define PCI_DEVICE_ID_INTEL_CLV_SDIO1 0x08fa |
| 27 | #define PCI_DEVICE_ID_INTEL_CLV_SDIO2 0x08fb |
| 28 | #define PCI_DEVICE_ID_INTEL_CLV_EMMC0 0x08e5 |
| 29 | #define PCI_DEVICE_ID_INTEL_CLV_EMMC1 0x08e6 |
Derek Browne | 43e968c | 2014-06-24 06:56:36 -0700 | [diff] [blame] | 30 | #define PCI_DEVICE_ID_INTEL_QRK_SD 0x08A7 |
Adrian Hunter | 1f7f265 | 2015-01-05 14:47:58 +0200 | [diff] [blame] | 31 | #define PCI_DEVICE_ID_INTEL_SPT_EMMC 0x9d2b |
| 32 | #define PCI_DEVICE_ID_INTEL_SPT_SDIO 0x9d2c |
| 33 | #define PCI_DEVICE_ID_INTEL_SPT_SD 0x9d2d |
Adrian Hunter | 06bf9c5 | 2015-10-06 10:26:21 +0300 | [diff] [blame] | 34 | #define PCI_DEVICE_ID_INTEL_DNV_EMMC 0x19db |
Adrian Hunter | cdaba73 | 2017-09-18 15:17:05 +0300 | [diff] [blame] | 35 | #define PCI_DEVICE_ID_INTEL_CDF_EMMC 0x18db |
Adrian Hunter | 4fd4c06 | 2015-10-21 11:15:45 +0300 | [diff] [blame] | 36 | #define PCI_DEVICE_ID_INTEL_BXT_SD 0x0aca |
| 37 | #define PCI_DEVICE_ID_INTEL_BXT_EMMC 0x0acc |
| 38 | #define PCI_DEVICE_ID_INTEL_BXT_SDIO 0x0ad0 |
Adrian Hunter | 01d6b2a | 2016-04-04 12:40:37 +0300 | [diff] [blame] | 39 | #define PCI_DEVICE_ID_INTEL_BXTM_SD 0x1aca |
| 40 | #define PCI_DEVICE_ID_INTEL_BXTM_EMMC 0x1acc |
| 41 | #define PCI_DEVICE_ID_INTEL_BXTM_SDIO 0x1ad0 |
Adrian Hunter | 4fd4c06 | 2015-10-21 11:15:45 +0300 | [diff] [blame] | 42 | #define PCI_DEVICE_ID_INTEL_APL_SD 0x5aca |
| 43 | #define PCI_DEVICE_ID_INTEL_APL_EMMC 0x5acc |
| 44 | #define PCI_DEVICE_ID_INTEL_APL_SDIO 0x5ad0 |
Adrian Hunter | 2d1956d | 2016-11-22 11:03:37 +0200 | [diff] [blame] | 45 | #define PCI_DEVICE_ID_INTEL_GLK_SD 0x31ca |
| 46 | #define PCI_DEVICE_ID_INTEL_GLK_EMMC 0x31cc |
| 47 | #define PCI_DEVICE_ID_INTEL_GLK_SDIO 0x31d0 |
Adrian Hunter | bc55dcd | 2017-06-01 12:10:07 +0300 | [diff] [blame] | 48 | #define PCI_DEVICE_ID_INTEL_CNP_EMMC 0x9dc4 |
| 49 | #define PCI_DEVICE_ID_INTEL_CNP_SD 0x9df5 |
| 50 | #define PCI_DEVICE_ID_INTEL_CNPH_SD 0xa375 |
Adrian Hunter | 5637ffa | 2018-06-20 09:23:13 +0300 | [diff] [blame] | 51 | #define PCI_DEVICE_ID_INTEL_ICP_EMMC 0x34c4 |
| 52 | #define PCI_DEVICE_ID_INTEL_ICP_SD 0x34f8 |
Adrian Hunter | cb3a7d4a | 2019-06-20 12:49:01 +0300 | [diff] [blame] | 53 | #define PCI_DEVICE_ID_INTEL_EHL_EMMC 0x4b47 |
| 54 | #define PCI_DEVICE_ID_INTEL_EHL_SD 0x4b48 |
Adrian Hunter | 765c596 | 2019-04-08 11:32:11 +0300 | [diff] [blame] | 55 | #define PCI_DEVICE_ID_INTEL_CML_EMMC 0x02c4 |
| 56 | #define PCI_DEVICE_ID_INTEL_CML_SD 0x02f5 |
Adrian Hunter | 8f05eee | 2019-07-30 09:07:23 +0300 | [diff] [blame] | 57 | #define PCI_DEVICE_ID_INTEL_CMLH_SD 0x06f5 |
Adrian Hunter | 315e3bd7a | 2019-10-10 15:46:30 +0300 | [diff] [blame] | 58 | #define PCI_DEVICE_ID_INTEL_JSL_EMMC 0x4dc4 |
| 59 | #define PCI_DEVICE_ID_INTEL_JSL_SD 0x4df8 |
Adrian Hunter | ee62911 | 2021-03-22 07:53:56 +0200 | [diff] [blame^] | 60 | #define PCI_DEVICE_ID_INTEL_LKF_EMMC 0x98c4 |
| 61 | #define PCI_DEVICE_ID_INTEL_LKF_SD 0x98f8 |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 62 | |
Matthias Kraemer | c949c90 | 2017-05-15 23:44:17 +0200 | [diff] [blame] | 63 | #define PCI_DEVICE_ID_SYSKONNECT_8000 0x8000 |
| 64 | #define PCI_DEVICE_ID_VIA_95D0 0x95d0 |
| 65 | #define PCI_DEVICE_ID_REALTEK_5250 0x5250 |
| 66 | |
| 67 | #define PCI_SUBDEVICE_ID_NI_7884 0x7884 |
Kyle Roeschley | bb26b84 | 2018-04-13 16:54:58 -0500 | [diff] [blame] | 68 | #define PCI_SUBDEVICE_ID_NI_78E3 0x78e3 |
Matthias Kraemer | c949c90 | 2017-05-15 23:44:17 +0200 | [diff] [blame] | 69 | |
Atul Garg | d72d72c | 2018-01-03 20:17:36 -0800 | [diff] [blame] | 70 | #define PCI_VENDOR_ID_ARASAN 0x16e6 |
| 71 | #define PCI_DEVICE_ID_ARASAN_PHY_EMMC 0x0670 |
| 72 | |
Prabu Thangamuthu | 152f820 | 2018-07-11 13:26:17 +0530 | [diff] [blame] | 73 | #define PCI_DEVICE_ID_SYNOPSYS_DWC_MSHC 0xc202 |
| 74 | |
Ben Chuang | e51df6c | 2019-09-11 15:23:44 +0800 | [diff] [blame] | 75 | #define PCI_DEVICE_ID_GLI_9755 0x9755 |
| 76 | #define PCI_DEVICE_ID_GLI_9750 0x9750 |
Ben Chuang | 1ae1d2d | 2020-05-08 14:41:54 +0800 | [diff] [blame] | 77 | #define PCI_DEVICE_ID_GLI_9763E 0xe763 |
Ben Chuang | e51df6c | 2019-09-11 15:23:44 +0800 | [diff] [blame] | 78 | |
Matthias Kraemer | c949c90 | 2017-05-15 23:44:17 +0200 | [diff] [blame] | 79 | /* |
| 80 | * PCI device class and mask |
| 81 | */ |
| 82 | |
| 83 | #define SYSTEM_SDHCI (PCI_CLASS_SYSTEM_SDHCI << 8) |
| 84 | #define PCI_CLASS_MASK 0xFFFF00 |
| 85 | |
| 86 | /* |
| 87 | * Macros for PCI device-description |
| 88 | */ |
| 89 | |
| 90 | #define _PCI_VEND(vend) PCI_VENDOR_ID_##vend |
| 91 | #define _PCI_DEV(vend, dev) PCI_DEVICE_ID_##vend##_##dev |
| 92 | #define _PCI_SUBDEV(subvend, subdev) PCI_SUBDEVICE_ID_##subvend##_##subdev |
| 93 | |
| 94 | #define SDHCI_PCI_DEVICE(vend, dev, cfg) { \ |
| 95 | .vendor = _PCI_VEND(vend), .device = _PCI_DEV(vend, dev), \ |
| 96 | .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \ |
| 97 | .driver_data = (kernel_ulong_t)&(sdhci_##cfg) \ |
| 98 | } |
| 99 | |
| 100 | #define SDHCI_PCI_SUBDEVICE(vend, dev, subvend, subdev, cfg) { \ |
| 101 | .vendor = _PCI_VEND(vend), .device = _PCI_DEV(vend, dev), \ |
| 102 | .subvendor = _PCI_VEND(subvend), \ |
| 103 | .subdevice = _PCI_SUBDEV(subvend, subdev), \ |
| 104 | .driver_data = (kernel_ulong_t)&(sdhci_##cfg) \ |
| 105 | } |
| 106 | |
| 107 | #define SDHCI_PCI_DEVICE_CLASS(vend, cl, cl_msk, cfg) { \ |
| 108 | .vendor = _PCI_VEND(vend), .device = PCI_ANY_ID, \ |
| 109 | .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \ |
| 110 | .class = (cl), .class_mask = (cl_msk), \ |
| 111 | .driver_data = (kernel_ulong_t)&(sdhci_##cfg) \ |
| 112 | } |
| 113 | |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 114 | /* |
| 115 | * PCI registers |
| 116 | */ |
| 117 | |
| 118 | #define PCI_SDHCI_IFPIO 0x00 |
| 119 | #define PCI_SDHCI_IFDMA 0x01 |
| 120 | #define PCI_SDHCI_IFVENDOR 0x02 |
| 121 | |
| 122 | #define PCI_SLOT_INFO 0x40 /* 8 bits */ |
| 123 | #define PCI_SLOT_INFO_SLOTS(x) ((x >> 4) & 7) |
| 124 | #define PCI_SLOT_INFO_FIRST_BAR_MASK 0x07 |
| 125 | |
| 126 | #define MAX_SLOTS 8 |
| 127 | |
| 128 | struct sdhci_pci_chip; |
| 129 | struct sdhci_pci_slot; |
| 130 | |
| 131 | struct sdhci_pci_fixes { |
| 132 | unsigned int quirks; |
| 133 | unsigned int quirks2; |
| 134 | bool allow_runtime_pm; |
Adrian Hunter | 77a0122 | 2014-01-13 09:49:16 +0200 | [diff] [blame] | 135 | bool own_cd_for_runtime_pm; |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 136 | |
| 137 | int (*probe) (struct sdhci_pci_chip *); |
| 138 | |
| 139 | int (*probe_slot) (struct sdhci_pci_slot *); |
Adrian Hunter | 61c951d | 2017-03-20 19:50:48 +0200 | [diff] [blame] | 140 | int (*add_host) (struct sdhci_pci_slot *); |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 141 | void (*remove_slot) (struct sdhci_pci_slot *, int); |
| 142 | |
Adrian Hunter | b7813f0 | 2017-03-20 19:50:50 +0200 | [diff] [blame] | 143 | #ifdef CONFIG_PM_SLEEP |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 144 | int (*suspend) (struct sdhci_pci_chip *); |
| 145 | int (*resume) (struct sdhci_pci_chip *); |
Adrian Hunter | b7813f0 | 2017-03-20 19:50:50 +0200 | [diff] [blame] | 146 | #endif |
Adrian Hunter | 966d696 | 2017-03-20 19:50:52 +0200 | [diff] [blame] | 147 | #ifdef CONFIG_PM |
| 148 | int (*runtime_suspend) (struct sdhci_pci_chip *); |
| 149 | int (*runtime_resume) (struct sdhci_pci_chip *); |
| 150 | #endif |
Adrian Hunter | 6bc0906 | 2016-10-05 12:11:23 +0300 | [diff] [blame] | 151 | |
| 152 | const struct sdhci_ops *ops; |
Adrian Hunter | ac9f67b | 2017-03-20 19:50:33 +0200 | [diff] [blame] | 153 | size_t priv_size; |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | struct sdhci_pci_slot { |
| 157 | struct sdhci_pci_chip *chip; |
| 158 | struct sdhci_host *host; |
| 159 | struct sdhci_pci_data *data; |
| 160 | |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 161 | int rst_n_gpio; |
| 162 | int cd_gpio; |
| 163 | int cd_irq; |
| 164 | |
Adrian Hunter | ff59c52 | 2014-09-24 10:27:31 +0300 | [diff] [blame] | 165 | int cd_idx; |
| 166 | bool cd_override_level; |
| 167 | |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 168 | void (*hw_reset)(struct sdhci_host *host); |
Gustavo A. R. Silva | 1a91a36a | 2020-02-26 16:31:25 -0600 | [diff] [blame] | 169 | unsigned long private[] ____cacheline_aligned; |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | struct sdhci_pci_chip { |
| 173 | struct pci_dev *pdev; |
| 174 | |
| 175 | unsigned int quirks; |
| 176 | unsigned int quirks2; |
| 177 | bool allow_runtime_pm; |
Adrian Hunter | d38dcad | 2017-03-20 19:50:32 +0200 | [diff] [blame] | 178 | bool pm_retune; |
| 179 | bool rpm_retune; |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 180 | const struct sdhci_pci_fixes *fixes; |
| 181 | |
| 182 | int num_slots; /* Slots on controller */ |
| 183 | struct sdhci_pci_slot *slots[MAX_SLOTS]; /* Pointers to host slots */ |
| 184 | }; |
| 185 | |
Adrian Hunter | ac9f67b | 2017-03-20 19:50:33 +0200 | [diff] [blame] | 186 | static inline void *sdhci_pci_priv(struct sdhci_pci_slot *slot) |
| 187 | { |
| 188 | return (void *)slot->private; |
| 189 | } |
| 190 | |
Adrian Hunter | 30cf280 | 2017-03-20 19:50:51 +0200 | [diff] [blame] | 191 | #ifdef CONFIG_PM_SLEEP |
| 192 | int sdhci_pci_resume_host(struct sdhci_pci_chip *chip); |
| 193 | #endif |
Atul Garg | d72d72c | 2018-01-03 20:17:36 -0800 | [diff] [blame] | 194 | int sdhci_pci_enable_dma(struct sdhci_host *host); |
Adrian Hunter | 361eeda | 2017-10-19 15:04:13 +0300 | [diff] [blame] | 195 | |
Atul Garg | d72d72c | 2018-01-03 20:17:36 -0800 | [diff] [blame] | 196 | extern const struct sdhci_pci_fixes sdhci_arasan; |
Prabu Thangamuthu | 152f820 | 2018-07-11 13:26:17 +0530 | [diff] [blame] | 197 | extern const struct sdhci_pci_fixes sdhci_snps; |
Ernest Zhang(WH) | 328be8b | 2019-01-04 02:26:10 +0000 | [diff] [blame] | 198 | extern const struct sdhci_pci_fixes sdhci_o2; |
Ben Chuang | e51df6c | 2019-09-11 15:23:44 +0800 | [diff] [blame] | 199 | extern const struct sdhci_pci_fixes sdhci_gl9750; |
| 200 | extern const struct sdhci_pci_fixes sdhci_gl9755; |
Ben Chuang | 1ae1d2d | 2020-05-08 14:41:54 +0800 | [diff] [blame] | 201 | extern const struct sdhci_pci_fixes sdhci_gl9763e; |
Atul Garg | d72d72c | 2018-01-03 20:17:36 -0800 | [diff] [blame] | 202 | |
Adam Lee | 522624f | 2013-12-18 22:23:38 +0800 | [diff] [blame] | 203 | #endif /* __SDHCI_PCI_H */ |