xref: /openbmc/linux/drivers/mmc/host/sdhci-pci.h (revision 3d757ddb)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2522624f9SAdam Lee #ifndef __SDHCI_PCI_H
3522624f9SAdam Lee #define __SDHCI_PCI_H
4522624f9SAdam Lee 
5522624f9SAdam Lee /*
6c949c907SMatthias Kraemer  * PCI device IDs, sub IDs
7522624f9SAdam Lee  */
8522624f9SAdam Lee 
9361eeda0SAdrian Hunter #define PCI_DEVICE_ID_O2_SDS0		0x8420
10361eeda0SAdrian Hunter #define PCI_DEVICE_ID_O2_SDS1		0x8421
11361eeda0SAdrian Hunter #define PCI_DEVICE_ID_O2_FUJIN2		0x8520
12361eeda0SAdrian Hunter #define PCI_DEVICE_ID_O2_SEABIRD0	0x8620
13361eeda0SAdrian Hunter #define PCI_DEVICE_ID_O2_SEABIRD1	0x8621
14*3d757ddbSChevron Li #define PCI_DEVICE_ID_O2_GG8_9860	0x9860
15*3d757ddbSChevron Li #define PCI_DEVICE_ID_O2_GG8_9861	0x9861
16*3d757ddbSChevron Li #define PCI_DEVICE_ID_O2_GG8_9862	0x9862
17*3d757ddbSChevron Li #define PCI_DEVICE_ID_O2_GG8_9863	0x9863
18361eeda0SAdrian Hunter 
19522624f9SAdam Lee #define PCI_DEVICE_ID_INTEL_PCH_SDIO0	0x8809
20522624f9SAdam Lee #define PCI_DEVICE_ID_INTEL_PCH_SDIO1	0x880a
21522624f9SAdam Lee #define PCI_DEVICE_ID_INTEL_BYT_EMMC	0x0f14
22522624f9SAdam Lee #define PCI_DEVICE_ID_INTEL_BYT_SDIO	0x0f15
23522624f9SAdam Lee #define PCI_DEVICE_ID_INTEL_BYT_SD	0x0f16
24522624f9SAdam Lee #define PCI_DEVICE_ID_INTEL_BYT_EMMC2	0x0f50
25066173b6SAlan Cox #define PCI_DEVICE_ID_INTEL_BSW_EMMC	0x2294
26066173b6SAlan Cox #define PCI_DEVICE_ID_INTEL_BSW_SDIO	0x2295
27066173b6SAlan Cox #define PCI_DEVICE_ID_INTEL_BSW_SD	0x2296
281f64cec2SAndy Shevchenko #define PCI_DEVICE_ID_INTEL_MRFLD_MMC	0x1190
29522624f9SAdam Lee #define PCI_DEVICE_ID_INTEL_CLV_SDIO0	0x08f9
30522624f9SAdam Lee #define PCI_DEVICE_ID_INTEL_CLV_SDIO1	0x08fa
31522624f9SAdam Lee #define PCI_DEVICE_ID_INTEL_CLV_SDIO2	0x08fb
32522624f9SAdam Lee #define PCI_DEVICE_ID_INTEL_CLV_EMMC0	0x08e5
33522624f9SAdam Lee #define PCI_DEVICE_ID_INTEL_CLV_EMMC1	0x08e6
3443e968ceSDerek Browne #define PCI_DEVICE_ID_INTEL_QRK_SD	0x08A7
351f7f2652SAdrian Hunter #define PCI_DEVICE_ID_INTEL_SPT_EMMC	0x9d2b
361f7f2652SAdrian Hunter #define PCI_DEVICE_ID_INTEL_SPT_SDIO	0x9d2c
371f7f2652SAdrian Hunter #define PCI_DEVICE_ID_INTEL_SPT_SD	0x9d2d
3806bf9c56SAdrian Hunter #define PCI_DEVICE_ID_INTEL_DNV_EMMC	0x19db
39cdaba732SAdrian Hunter #define PCI_DEVICE_ID_INTEL_CDF_EMMC	0x18db
404fd4c065SAdrian Hunter #define PCI_DEVICE_ID_INTEL_BXT_SD	0x0aca
414fd4c065SAdrian Hunter #define PCI_DEVICE_ID_INTEL_BXT_EMMC	0x0acc
424fd4c065SAdrian Hunter #define PCI_DEVICE_ID_INTEL_BXT_SDIO	0x0ad0
4301d6b2a4SAdrian Hunter #define PCI_DEVICE_ID_INTEL_BXTM_SD	0x1aca
4401d6b2a4SAdrian Hunter #define PCI_DEVICE_ID_INTEL_BXTM_EMMC	0x1acc
4501d6b2a4SAdrian Hunter #define PCI_DEVICE_ID_INTEL_BXTM_SDIO	0x1ad0
464fd4c065SAdrian Hunter #define PCI_DEVICE_ID_INTEL_APL_SD	0x5aca
474fd4c065SAdrian Hunter #define PCI_DEVICE_ID_INTEL_APL_EMMC	0x5acc
484fd4c065SAdrian Hunter #define PCI_DEVICE_ID_INTEL_APL_SDIO	0x5ad0
492d1956d0SAdrian Hunter #define PCI_DEVICE_ID_INTEL_GLK_SD	0x31ca
502d1956d0SAdrian Hunter #define PCI_DEVICE_ID_INTEL_GLK_EMMC	0x31cc
512d1956d0SAdrian Hunter #define PCI_DEVICE_ID_INTEL_GLK_SDIO	0x31d0
52bc55dcd8SAdrian Hunter #define PCI_DEVICE_ID_INTEL_CNP_EMMC	0x9dc4
53bc55dcd8SAdrian Hunter #define PCI_DEVICE_ID_INTEL_CNP_SD	0x9df5
54bc55dcd8SAdrian Hunter #define PCI_DEVICE_ID_INTEL_CNPH_SD	0xa375
555637ffadSAdrian Hunter #define PCI_DEVICE_ID_INTEL_ICP_EMMC	0x34c4
565637ffadSAdrian Hunter #define PCI_DEVICE_ID_INTEL_ICP_SD	0x34f8
57cb3a7d4aSAdrian Hunter #define PCI_DEVICE_ID_INTEL_EHL_EMMC	0x4b47
58cb3a7d4aSAdrian Hunter #define PCI_DEVICE_ID_INTEL_EHL_SD	0x4b48
59765c5967SAdrian Hunter #define PCI_DEVICE_ID_INTEL_CML_EMMC	0x02c4
60765c5967SAdrian Hunter #define PCI_DEVICE_ID_INTEL_CML_SD	0x02f5
618f05eee6SAdrian Hunter #define PCI_DEVICE_ID_INTEL_CMLH_SD	0x06f5
62315e3bd7SAdrian Hunter #define PCI_DEVICE_ID_INTEL_JSL_EMMC	0x4dc4
63315e3bd7SAdrian Hunter #define PCI_DEVICE_ID_INTEL_JSL_SD	0x4df8
64ee629112SAdrian Hunter #define PCI_DEVICE_ID_INTEL_LKF_EMMC	0x98c4
65ee629112SAdrian Hunter #define PCI_DEVICE_ID_INTEL_LKF_SD	0x98f8
66e53e97f8SAdrian Hunter #define PCI_DEVICE_ID_INTEL_ADL_EMMC	0x54c4
67522624f9SAdam Lee 
68c949c907SMatthias Kraemer #define PCI_DEVICE_ID_SYSKONNECT_8000	0x8000
69c949c907SMatthias Kraemer #define PCI_DEVICE_ID_VIA_95D0		0x95d0
70c949c907SMatthias Kraemer #define PCI_DEVICE_ID_REALTEK_5250	0x5250
71c949c907SMatthias Kraemer 
72c949c907SMatthias Kraemer #define PCI_SUBDEVICE_ID_NI_7884	0x7884
73bb26b841SKyle Roeschley #define PCI_SUBDEVICE_ID_NI_78E3	0x78e3
74c949c907SMatthias Kraemer 
75d72d72cdSAtul Garg #define PCI_VENDOR_ID_ARASAN		0x16e6
76d72d72cdSAtul Garg #define PCI_DEVICE_ID_ARASAN_PHY_EMMC	0x0670
77d72d72cdSAtul Garg 
78152f8204SPrabu Thangamuthu #define PCI_DEVICE_ID_SYNOPSYS_DWC_MSHC 0xc202
79152f8204SPrabu Thangamuthu 
80e51df6ceSBen Chuang #define PCI_DEVICE_ID_GLI_9755		0x9755
81e51df6ceSBen Chuang #define PCI_DEVICE_ID_GLI_9750		0x9750
821ae1d2d6SBen Chuang #define PCI_DEVICE_ID_GLI_9763E		0xe763
83f3a5b56cSVictor Shih #define PCI_DEVICE_ID_GLI_9767		0x9767
84e51df6ceSBen Chuang 
85c949c907SMatthias Kraemer /*
86c949c907SMatthias Kraemer  * PCI device class and mask
87c949c907SMatthias Kraemer  */
88c949c907SMatthias Kraemer 
89c949c907SMatthias Kraemer #define SYSTEM_SDHCI			(PCI_CLASS_SYSTEM_SDHCI << 8)
90c949c907SMatthias Kraemer #define PCI_CLASS_MASK			0xFFFF00
91c949c907SMatthias Kraemer 
92c949c907SMatthias Kraemer /*
93c949c907SMatthias Kraemer  * Macros for PCI device-description
94c949c907SMatthias Kraemer  */
95c949c907SMatthias Kraemer 
96c949c907SMatthias Kraemer #define _PCI_VEND(vend) PCI_VENDOR_ID_##vend
97c949c907SMatthias Kraemer #define _PCI_DEV(vend, dev) PCI_DEVICE_ID_##vend##_##dev
98c949c907SMatthias Kraemer #define _PCI_SUBDEV(subvend, subdev) PCI_SUBDEVICE_ID_##subvend##_##subdev
99c949c907SMatthias Kraemer 
100c949c907SMatthias Kraemer #define SDHCI_PCI_DEVICE(vend, dev, cfg) { \
101c949c907SMatthias Kraemer 	.vendor = _PCI_VEND(vend), .device = _PCI_DEV(vend, dev), \
102c949c907SMatthias Kraemer 	.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
103c949c907SMatthias Kraemer 	.driver_data = (kernel_ulong_t)&(sdhci_##cfg) \
104c949c907SMatthias Kraemer }
105c949c907SMatthias Kraemer 
106c949c907SMatthias Kraemer #define SDHCI_PCI_SUBDEVICE(vend, dev, subvend, subdev, cfg) { \
107c949c907SMatthias Kraemer 	.vendor = _PCI_VEND(vend), .device = _PCI_DEV(vend, dev), \
108c949c907SMatthias Kraemer 	.subvendor = _PCI_VEND(subvend), \
109c949c907SMatthias Kraemer 	.subdevice = _PCI_SUBDEV(subvend, subdev), \
110c949c907SMatthias Kraemer 	.driver_data = (kernel_ulong_t)&(sdhci_##cfg) \
111c949c907SMatthias Kraemer }
112c949c907SMatthias Kraemer 
113c949c907SMatthias Kraemer #define SDHCI_PCI_DEVICE_CLASS(vend, cl, cl_msk, cfg) { \
114c949c907SMatthias Kraemer 	.vendor = _PCI_VEND(vend), .device = PCI_ANY_ID, \
115c949c907SMatthias Kraemer 	.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
116c949c907SMatthias Kraemer 	.class = (cl), .class_mask = (cl_msk), \
117c949c907SMatthias Kraemer 	.driver_data = (kernel_ulong_t)&(sdhci_##cfg) \
118c949c907SMatthias Kraemer }
119c949c907SMatthias Kraemer 
120522624f9SAdam Lee /*
121522624f9SAdam Lee  * PCI registers
122522624f9SAdam Lee  */
123522624f9SAdam Lee 
124522624f9SAdam Lee #define PCI_SDHCI_IFPIO			0x00
125522624f9SAdam Lee #define PCI_SDHCI_IFDMA			0x01
126522624f9SAdam Lee #define PCI_SDHCI_IFVENDOR		0x02
127522624f9SAdam Lee 
128522624f9SAdam Lee #define PCI_SLOT_INFO			0x40	/* 8 bits */
129522624f9SAdam Lee #define  PCI_SLOT_INFO_SLOTS(x)		((x >> 4) & 7)
130522624f9SAdam Lee #define  PCI_SLOT_INFO_FIRST_BAR_MASK	0x07
131522624f9SAdam Lee 
132522624f9SAdam Lee #define MAX_SLOTS			8
133522624f9SAdam Lee 
134522624f9SAdam Lee struct sdhci_pci_chip;
135522624f9SAdam Lee struct sdhci_pci_slot;
136522624f9SAdam Lee 
137522624f9SAdam Lee struct sdhci_pci_fixes {
138522624f9SAdam Lee 	unsigned int		quirks;
139522624f9SAdam Lee 	unsigned int		quirks2;
140522624f9SAdam Lee 	bool			allow_runtime_pm;
14177a0122eSAdrian Hunter 	bool			own_cd_for_runtime_pm;
142522624f9SAdam Lee 
143522624f9SAdam Lee 	int			(*probe) (struct sdhci_pci_chip *);
144522624f9SAdam Lee 
145522624f9SAdam Lee 	int			(*probe_slot) (struct sdhci_pci_slot *);
14661c951deSAdrian Hunter 	int			(*add_host) (struct sdhci_pci_slot *);
147522624f9SAdam Lee 	void			(*remove_slot) (struct sdhci_pci_slot *, int);
148522624f9SAdam Lee 
149b7813f0fSAdrian Hunter #ifdef CONFIG_PM_SLEEP
150522624f9SAdam Lee 	int			(*suspend) (struct sdhci_pci_chip *);
151522624f9SAdam Lee 	int			(*resume) (struct sdhci_pci_chip *);
152b7813f0fSAdrian Hunter #endif
153966d696aSAdrian Hunter #ifdef CONFIG_PM
154966d696aSAdrian Hunter 	int			(*runtime_suspend) (struct sdhci_pci_chip *);
155966d696aSAdrian Hunter 	int			(*runtime_resume) (struct sdhci_pci_chip *);
156966d696aSAdrian Hunter #endif
1576bc09063SAdrian Hunter 
1586bc09063SAdrian Hunter 	const struct sdhci_ops	*ops;
159ac9f67b5SAdrian Hunter 	size_t			priv_size;
160522624f9SAdam Lee };
161522624f9SAdam Lee 
162522624f9SAdam Lee struct sdhci_pci_slot {
163522624f9SAdam Lee 	struct sdhci_pci_chip	*chip;
164522624f9SAdam Lee 	struct sdhci_host	*host;
165522624f9SAdam Lee 
166ff59c520SAdrian Hunter 	int			cd_idx;
167ff59c520SAdrian Hunter 	bool			cd_override_level;
168ff59c520SAdrian Hunter 
169522624f9SAdam Lee 	void (*hw_reset)(struct sdhci_host *host);
1701a91a36aSGustavo A. R. Silva 	unsigned long		private[] ____cacheline_aligned;
171522624f9SAdam Lee };
172522624f9SAdam Lee 
173522624f9SAdam Lee struct sdhci_pci_chip {
174522624f9SAdam Lee 	struct pci_dev		*pdev;
175522624f9SAdam Lee 
176522624f9SAdam Lee 	unsigned int		quirks;
177522624f9SAdam Lee 	unsigned int		quirks2;
178522624f9SAdam Lee 	bool			allow_runtime_pm;
179d38dcad4SAdrian Hunter 	bool			pm_retune;
180d38dcad4SAdrian Hunter 	bool			rpm_retune;
181522624f9SAdam Lee 	const struct sdhci_pci_fixes *fixes;
182522624f9SAdam Lee 
183522624f9SAdam Lee 	int			num_slots;	/* Slots on controller */
184522624f9SAdam Lee 	struct sdhci_pci_slot	*slots[MAX_SLOTS]; /* Pointers to host slots */
185522624f9SAdam Lee };
186522624f9SAdam Lee 
sdhci_pci_priv(struct sdhci_pci_slot * slot)187ac9f67b5SAdrian Hunter static inline void *sdhci_pci_priv(struct sdhci_pci_slot *slot)
188ac9f67b5SAdrian Hunter {
189ac9f67b5SAdrian Hunter 	return (void *)slot->private;
190ac9f67b5SAdrian Hunter }
191ac9f67b5SAdrian Hunter 
19230cf2803SAdrian Hunter #ifdef CONFIG_PM_SLEEP
19330cf2803SAdrian Hunter int sdhci_pci_resume_host(struct sdhci_pci_chip *chip);
19430cf2803SAdrian Hunter #endif
195d72d72cdSAtul Garg int sdhci_pci_enable_dma(struct sdhci_host *host);
196361eeda0SAdrian Hunter 
197d72d72cdSAtul Garg extern const struct sdhci_pci_fixes sdhci_arasan;
198152f8204SPrabu Thangamuthu extern const struct sdhci_pci_fixes sdhci_snps;
199328be8beSErnest Zhang(WH) extern const struct sdhci_pci_fixes sdhci_o2;
200e51df6ceSBen Chuang extern const struct sdhci_pci_fixes sdhci_gl9750;
201e51df6ceSBen Chuang extern const struct sdhci_pci_fixes sdhci_gl9755;
2021ae1d2d6SBen Chuang extern const struct sdhci_pci_fixes sdhci_gl9763e;
203f3a5b56cSVictor Shih extern const struct sdhci_pci_fixes sdhci_gl9767;
204d72d72cdSAtul Garg 
205522624f9SAdam Lee #endif /* __SDHCI_PCI_H */
206