blob: 3661a224fb04a115d48fa00dcfe814e43c01c671 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Adam Lee522624f2013-12-18 22:23:38 +08002#ifndef __SDHCI_PCI_H
3#define __SDHCI_PCI_H
4
5/*
Matthias Kraemerc949c902017-05-15 23:44:17 +02006 * PCI device IDs, sub IDs
Adam Lee522624f2013-12-18 22:23:38 +08007 */
8
Adrian Hunter361eeda2017-10-19 15:04:13 +03009#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 Lee522624f2013-12-18 22:23:38 +080015#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 Cox066173b2014-08-20 13:27:44 +030021#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 Shevchenko1f64cec2016-07-12 14:03:42 +030024#define PCI_DEVICE_ID_INTEL_MRFLD_MMC 0x1190
Adam Lee522624f2013-12-18 22:23:38 +080025#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 Browne43e968c2014-06-24 06:56:36 -070030#define PCI_DEVICE_ID_INTEL_QRK_SD 0x08A7
Adrian Hunter1f7f2652015-01-05 14:47:58 +020031#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 Hunter06bf9c52015-10-06 10:26:21 +030034#define PCI_DEVICE_ID_INTEL_DNV_EMMC 0x19db
Adrian Huntercdaba732017-09-18 15:17:05 +030035#define PCI_DEVICE_ID_INTEL_CDF_EMMC 0x18db
Adrian Hunter4fd4c062015-10-21 11:15:45 +030036#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 Hunter01d6b2a2016-04-04 12:40:37 +030039#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 Hunter4fd4c062015-10-21 11:15:45 +030042#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 Hunter2d1956d2016-11-22 11:03:37 +020045#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 Hunterbc55dcd2017-06-01 12:10:07 +030048#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 Hunter5637ffa2018-06-20 09:23:13 +030051#define PCI_DEVICE_ID_INTEL_ICP_EMMC 0x34c4
52#define PCI_DEVICE_ID_INTEL_ICP_SD 0x34f8
Adrian Huntercb3a7d4a2019-06-20 12:49:01 +030053#define PCI_DEVICE_ID_INTEL_EHL_EMMC 0x4b47
54#define PCI_DEVICE_ID_INTEL_EHL_SD 0x4b48
Adrian Hunter765c5962019-04-08 11:32:11 +030055#define PCI_DEVICE_ID_INTEL_CML_EMMC 0x02c4
56#define PCI_DEVICE_ID_INTEL_CML_SD 0x02f5
Adrian Hunter8f05eee2019-07-30 09:07:23 +030057#define PCI_DEVICE_ID_INTEL_CMLH_SD 0x06f5
Adrian Hunter315e3bd7a2019-10-10 15:46:30 +030058#define PCI_DEVICE_ID_INTEL_JSL_EMMC 0x4dc4
59#define PCI_DEVICE_ID_INTEL_JSL_SD 0x4df8
Adrian Hunteree629112021-03-22 07:53:56 +020060#define PCI_DEVICE_ID_INTEL_LKF_EMMC 0x98c4
61#define PCI_DEVICE_ID_INTEL_LKF_SD 0x98f8
Adrian Huntere53e97f2021-11-24 11:48:50 +020062#define PCI_DEVICE_ID_INTEL_ADL_EMMC 0x54c4
Adam Lee522624f2013-12-18 22:23:38 +080063
Matthias Kraemerc949c902017-05-15 23:44:17 +020064#define PCI_DEVICE_ID_SYSKONNECT_8000 0x8000
65#define PCI_DEVICE_ID_VIA_95D0 0x95d0
66#define PCI_DEVICE_ID_REALTEK_5250 0x5250
67
68#define PCI_SUBDEVICE_ID_NI_7884 0x7884
Kyle Roeschleybb26b842018-04-13 16:54:58 -050069#define PCI_SUBDEVICE_ID_NI_78E3 0x78e3
Matthias Kraemerc949c902017-05-15 23:44:17 +020070
Atul Gargd72d72c2018-01-03 20:17:36 -080071#define PCI_VENDOR_ID_ARASAN 0x16e6
72#define PCI_DEVICE_ID_ARASAN_PHY_EMMC 0x0670
73
Prabu Thangamuthu152f8202018-07-11 13:26:17 +053074#define PCI_DEVICE_ID_SYNOPSYS_DWC_MSHC 0xc202
75
Ben Chuange51df6c2019-09-11 15:23:44 +080076#define PCI_DEVICE_ID_GLI_9755 0x9755
77#define PCI_DEVICE_ID_GLI_9750 0x9750
Ben Chuang1ae1d2d2020-05-08 14:41:54 +080078#define PCI_DEVICE_ID_GLI_9763E 0xe763
Ben Chuange51df6c2019-09-11 15:23:44 +080079
Matthias Kraemerc949c902017-05-15 23:44:17 +020080/*
81 * PCI device class and mask
82 */
83
84#define SYSTEM_SDHCI (PCI_CLASS_SYSTEM_SDHCI << 8)
85#define PCI_CLASS_MASK 0xFFFF00
86
87/*
88 * Macros for PCI device-description
89 */
90
91#define _PCI_VEND(vend) PCI_VENDOR_ID_##vend
92#define _PCI_DEV(vend, dev) PCI_DEVICE_ID_##vend##_##dev
93#define _PCI_SUBDEV(subvend, subdev) PCI_SUBDEVICE_ID_##subvend##_##subdev
94
95#define SDHCI_PCI_DEVICE(vend, dev, cfg) { \
96 .vendor = _PCI_VEND(vend), .device = _PCI_DEV(vend, dev), \
97 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
98 .driver_data = (kernel_ulong_t)&(sdhci_##cfg) \
99}
100
101#define SDHCI_PCI_SUBDEVICE(vend, dev, subvend, subdev, cfg) { \
102 .vendor = _PCI_VEND(vend), .device = _PCI_DEV(vend, dev), \
103 .subvendor = _PCI_VEND(subvend), \
104 .subdevice = _PCI_SUBDEV(subvend, subdev), \
105 .driver_data = (kernel_ulong_t)&(sdhci_##cfg) \
106}
107
108#define SDHCI_PCI_DEVICE_CLASS(vend, cl, cl_msk, cfg) { \
109 .vendor = _PCI_VEND(vend), .device = PCI_ANY_ID, \
110 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
111 .class = (cl), .class_mask = (cl_msk), \
112 .driver_data = (kernel_ulong_t)&(sdhci_##cfg) \
113}
114
Adam Lee522624f2013-12-18 22:23:38 +0800115/*
116 * PCI registers
117 */
118
119#define PCI_SDHCI_IFPIO 0x00
120#define PCI_SDHCI_IFDMA 0x01
121#define PCI_SDHCI_IFVENDOR 0x02
122
123#define PCI_SLOT_INFO 0x40 /* 8 bits */
124#define PCI_SLOT_INFO_SLOTS(x) ((x >> 4) & 7)
125#define PCI_SLOT_INFO_FIRST_BAR_MASK 0x07
126
127#define MAX_SLOTS 8
128
129struct sdhci_pci_chip;
130struct sdhci_pci_slot;
131
132struct sdhci_pci_fixes {
133 unsigned int quirks;
134 unsigned int quirks2;
135 bool allow_runtime_pm;
Adrian Hunter77a01222014-01-13 09:49:16 +0200136 bool own_cd_for_runtime_pm;
Adam Lee522624f2013-12-18 22:23:38 +0800137
138 int (*probe) (struct sdhci_pci_chip *);
139
140 int (*probe_slot) (struct sdhci_pci_slot *);
Adrian Hunter61c951d2017-03-20 19:50:48 +0200141 int (*add_host) (struct sdhci_pci_slot *);
Adam Lee522624f2013-12-18 22:23:38 +0800142 void (*remove_slot) (struct sdhci_pci_slot *, int);
143
Adrian Hunterb7813f02017-03-20 19:50:50 +0200144#ifdef CONFIG_PM_SLEEP
Adam Lee522624f2013-12-18 22:23:38 +0800145 int (*suspend) (struct sdhci_pci_chip *);
146 int (*resume) (struct sdhci_pci_chip *);
Adrian Hunterb7813f02017-03-20 19:50:50 +0200147#endif
Adrian Hunter966d6962017-03-20 19:50:52 +0200148#ifdef CONFIG_PM
149 int (*runtime_suspend) (struct sdhci_pci_chip *);
150 int (*runtime_resume) (struct sdhci_pci_chip *);
151#endif
Adrian Hunter6bc09062016-10-05 12:11:23 +0300152
153 const struct sdhci_ops *ops;
Adrian Hunterac9f67b2017-03-20 19:50:33 +0200154 size_t priv_size;
Adam Lee522624f2013-12-18 22:23:38 +0800155};
156
157struct sdhci_pci_slot {
158 struct sdhci_pci_chip *chip;
159 struct sdhci_host *host;
Adam Lee522624f2013-12-18 22:23:38 +0800160
Adrian Hunterff59c522014-09-24 10:27:31 +0300161 int cd_idx;
162 bool cd_override_level;
163
Adam Lee522624f2013-12-18 22:23:38 +0800164 void (*hw_reset)(struct sdhci_host *host);
Gustavo A. R. Silva1a91a36a2020-02-26 16:31:25 -0600165 unsigned long private[] ____cacheline_aligned;
Adam Lee522624f2013-12-18 22:23:38 +0800166};
167
168struct sdhci_pci_chip {
169 struct pci_dev *pdev;
170
171 unsigned int quirks;
172 unsigned int quirks2;
173 bool allow_runtime_pm;
Adrian Hunterd38dcad2017-03-20 19:50:32 +0200174 bool pm_retune;
175 bool rpm_retune;
Adam Lee522624f2013-12-18 22:23:38 +0800176 const struct sdhci_pci_fixes *fixes;
177
178 int num_slots; /* Slots on controller */
179 struct sdhci_pci_slot *slots[MAX_SLOTS]; /* Pointers to host slots */
180};
181
Adrian Hunterac9f67b2017-03-20 19:50:33 +0200182static inline void *sdhci_pci_priv(struct sdhci_pci_slot *slot)
183{
184 return (void *)slot->private;
185}
186
Adrian Hunter30cf2802017-03-20 19:50:51 +0200187#ifdef CONFIG_PM_SLEEP
188int sdhci_pci_resume_host(struct sdhci_pci_chip *chip);
189#endif
Atul Gargd72d72c2018-01-03 20:17:36 -0800190int sdhci_pci_enable_dma(struct sdhci_host *host);
Adrian Hunter361eeda2017-10-19 15:04:13 +0300191
Atul Gargd72d72c2018-01-03 20:17:36 -0800192extern const struct sdhci_pci_fixes sdhci_arasan;
Prabu Thangamuthu152f8202018-07-11 13:26:17 +0530193extern const struct sdhci_pci_fixes sdhci_snps;
Ernest Zhang(WH)328be8b2019-01-04 02:26:10 +0000194extern const struct sdhci_pci_fixes sdhci_o2;
Ben Chuange51df6c2019-09-11 15:23:44 +0800195extern const struct sdhci_pci_fixes sdhci_gl9750;
196extern const struct sdhci_pci_fixes sdhci_gl9755;
Ben Chuang1ae1d2d2020-05-08 14:41:54 +0800197extern const struct sdhci_pci_fixes sdhci_gl9763e;
Atul Gargd72d72c2018-01-03 20:17:36 -0800198
Adam Lee522624f2013-12-18 22:23:38 +0800199#endif /* __SDHCI_PCI_H */